Plugin Directory

Changeset 3032248


Ignore:
Timestamp:
02/06/2024 03:24:08 PM (2 years ago)
Author:
shadim
Message:

tagging v1.1.0

Location:
quipu-accounting-for-woocommerce
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • quipu-accounting-for-woocommerce/tags/1.1.0/includes/class-wc-quipu-integration.php

    r1436028 r3032248  
    354354
    355355
    356         $orders = get_posts( array(
    357                         'post_type'         => 'shop_order',
    358                         'post_status'       => array( 'wc-processing', 'wc-completed' ),
    359                         'posts_per_page'    => -1, // get all orders
    360         ) );
    361         // error_log(print_r($orders, true));
    362 
    363         // Get "Completed" date not order date
    364         foreach ($orders as $order) {
    365             // error_log(print_r($order->ID, true));
    366             $completed_date = get_post_meta($order->ID, '_completed_date', true);
    367             if(empty($completed_date)) {
    368                 $orders_comp[$order->ID] = $order->post_date;
     356        $orders = wc_get_orders(array(
     357            'status'         => array('wc-processing', 'wc-completed'),
     358            'posts_per_page' => -1,
     359        ));
     360       
     361        // Get "Completed" date, not order date
     362        $orders_comp = array();
     363       
     364        foreach ($orders as $wk_order) {
     365            $completed_date = $wk_order->get_date_completed();
     366       
     367            if (empty($completed_date)) {
     368                $orders_comp[$wk_order->get_id()] = $wk_order->get_date_created()->date('Y-m-d H:i:s');
    369369            } else {
    370                 $orders_comp[$order->ID] = $completed_date;
    371             }               
     370                $orders_comp[$wk_order->get_id()] = $completed_date->date('Y-m-d H:i:s');
     371            }
    372372        }
    373373       
     
    392392     */
    393393    public function create_quipu_invoice( $order_id , $prefix, $completed_date) {
    394 
    395         $quipu_invoice_id = get_post_meta($order_id, "_quipu_invoice_id", true);
     394        // error_log ( 'completed date: ' . $completed_date );
     395
     396        $wk_order = wc_get_order( $order_id );
     397
     398        $quipu_invoice_id = $wk_order->get_meta( '_quipu_invoice_id', true );
     399        // error_log( 'invoice id:' . $quipu_invoice_id );
    396400
    397401        // If no Quipu id exists then create Quipu invoice, otherwise it was already accounted for
     
    410414                $quipu_contact = new Quipu_Api_Contact($this->api_connection);
    411415
     416                $billing_country = get_post_meta($order_id, '_billing_country', true);
     417
     418                if( empty($billing_country) ) {
     419                    $billing_country = wc_get_base_location();
     420                    $billing_country = $billing_country['country'];
     421                    // error_log($billing_country);
     422                }
     423
    412424                $contact = array(
    413                             "name" => get_post_meta($order_id, '_billing_first_name', true)." ".get_post_meta($order_id, '_billing_last_name', true)." ".get_post_meta($order_id, '_billing_company', true),
    414                             "tax_id" => get_post_meta($order_id, '_vat_number', true),
    415                             "phone" => get_post_meta($order_id, '_billing_phone', true),
    416                             "email" => get_post_meta($order_id, '_billing_email', true),
    417                             "address" => get_post_meta($order_id, '_billing_address_1', true).",".get_post_meta($order_id, '_billing_address_2', true),
    418                             "town" => get_post_meta($order_id, '_billing_city', true),
    419                             "zip_code" => get_post_meta($order_id, '_billing_postcode', true),
    420                             "country_code" => get_post_meta($order_id, '_billing_country', true)
    421                         );
     425                    "name" => $wk_order->get_billing_first_name() . " " . $wk_order->get_billing_last_name() . " " . $wk_order->get_billing_company(),
     426                    "tax_id" => $wk_order->get_meta( '_vat_number', true ),
     427                    "phone" => $wk_order->get_billing_phone(),
     428                    "email" => $wk_order->get_billing_email(),
     429                    "address" => $wk_order->get_billing_address_1() . "," . $wk_order->get_billing_address_2(),
     430                    "town" => $wk_order->get_billing_city(),
     431                    "zip_code" => $wk_order->get_billing_postcode(),
     432                    "country_code" => $wk_order->get_billing_country()
     433                );
     434
     435                // error_log ( 'contact array: ' . print_r( $contact, true ) );
    422436
    423437                $this->logger->write("Contact: ".print_r($contact, true));
     
    429443                $order = new WC_Order( $order_id );
    430444                // error_log(print_r($order, true));
    431                 $ordered_items = $order->get_items();
     445                $ordered_items = $wk_order->get_items();
    432446                // error_log(print_r($ordered_items, true));
    433                 $shipping_items = $order->get_items('shipping');
     447                $shipping_items = $wk_order->get_items('shipping');
    434448                // error_log(print_r($shipping_items, true));
    435449                // Add shipping "item"
     
    443457                // error_log($wc_order_date);
    444458
    445                 $wc_payment_method = get_post_meta($order_id, '_payment_method', true);
     459                $wc_payment_method = $wk_order->get_payment_method();
    446460                // The below are the default payment methods that come with WC
    447461                // These Quipu options were not set; "direct_debit", "factoring"
     
    486500                    $shipping_name = 'Shipping: '.$value['name'];
    487501                    $shipping_total = $value['cost'];
    488                     $shipping_tax = $value['taxes'];
    489 
    490                     if( is_serialized( $shipping_tax )) {
    491                         $shipping_tax = maybe_unserialize($shipping_tax);
    492                         // error_log(print_r($shipping_tax, true));
    493                         $shipping_tax = $shipping_tax[1];
    494                         // error_log($shipping_tax);
     502                    $shipping_tax = $value['cost'];
     503                    // error_log(print_r($shipping_tax, true));
     504
     505                    if (is_serialized($shipping_tax)) {
     506                        $shipping_tax = maybe_unserialize($shipping_tax);
     507                   
     508                        // Check if the 'total' key exists and is an array
     509                        if (is_array($shipping_tax['cost'])) {
     510                            // Access the first element of the 'total' array
     511                            $shipping_tax = $shipping_tax[1];
     512                            // error_log('Shipping Tax: ' . $shipping_tax);
     513                        }
    495514                    }
     515
     516                    // error_log( 'Shipping Name: ' . $shipping_name );
     517                    // error_log( 'Shipping Total: ' . $shipping_total );
     518                   
    496519
    497520                    $shipping_tax_per = round( (($shipping_tax*100)/$shipping_total), 4);
     
    514537                $this->logger->write("Order Response: ".print_r($quipu_invoice->get_response(), true));
    515538
    516                 if(!add_post_meta($order_id, "_quipu_invoice_id", $quipu_invoice->get_id(), true)) {
    517                     $this->logger->write("Couldn't save Quipu ID");
     539                $quipu_invoice_id = $quipu_invoice->get_id();
     540                // error_log ('invoice id before: ' . $quipu_invoice_id );
     541                $wk_order = wc_get_order( $order_id );
     542
     543                // Check and log the result of updating "_quipu_invoice_id" in the order meta
     544                if ( $wk_order->update_meta('_quipu_invoice_id', $quipu_invoice_id )) {
     545                    $wk_order->save();
     546                    $this->logger->write( "Quipu Invoice ID: " . $quipu_invoice_id );
    518547                } else {
    519                     $this->logger->write("Quipu Invoice ID: ".$quipu_invoice->get_id());   
     548                    $this->logger->write( "Couldn't save Quipu ID" );
    520549                }
    521550            } catch (Exception $e) {
     
    538567        // error_log(print_r($args, true));
    539568
    540         $quipu_invoice_id = get_post_meta($args['order_id'], "_quipu_invoice_id", true);
     569        $wk_order = wc_get_order($args['order_id']);
     570
     571        $quipu_invoice_id = $wk_order->get_meta('_quipu_invoice_id', true);
    541572
    542573        if( !empty($quipu_invoice_id) ) {
     
    548579            $order = new WC_Order( $args['order_id'] );
    549580            // error_log(print_r($order, true));
    550             $order_items = $order->get_items();
     581            $order_items = $wk_order->get_items();
    551582            // error_log(print_r($order_items, true));
    552             $order_amount = $order->get_total();
     583            $order_amount = $wk_order->get_total();
    553584            // error_log("Order $: ".$order_amount);
    554585
  • quipu-accounting-for-woocommerce/tags/1.1.0/readme.md

    r1658660 r3032248  
    55Requires at least: 4.1
    66Tested up to: 4.6
    7 Stable tag: 1.0.2
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • quipu-accounting-for-woocommerce/tags/1.1.0/readme.txt

    r1658660 r3032248  
    55Requires at least: 4.1
    66Tested up to: 4.6
    7 Stable tag: 1.0.2
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 Quipu plugin for WooCommerce 2 allows you to automate all your business' billing. Send custom invoices and manage your
     11Quipu plugin for WooCommerce allows you to automate all your business' billing. Send custom invoices and manage your
    1212online store!
    1313
    1414== Description ==
    1515
    16 Quipu plugin for WooCommerce 2 allows you to automate all your business’ billing. Send custom invoices and manage your online store quickly and easily!
     16Quipu plugin for WooCommerce allows you to automate all your business’ billing. Send custom invoices and manage your online store quickly and easily!
    1717
    18 All you can do with Quipu Accounting for WooCommerce 2:
     18All you can do with Quipu Accounting for WooCommerce:
    1919
    2020* Every time an order is successfully paid, the invoice automatically appears in your Quipu account
     
    34344. Customize your brand in your Quipu account
    3535
    36 This plugin requires that you have an account created in both [WooCommerce 2](https://www.woothemes.com/woocommerce/) and [Quipu](https://getquipu.com/en).
     36This plugin requires that you have an account created in both [WooCommerce](https://www.woothemes.com/woocommerce/) and [Quipu](https://getquipu.com/en).
    3737
    3838== Installation ==
    3939
    40 Follow the steps listed below to install the Quipu plugin for WooComerce 2
     40Follow the steps listed below to install the Quipu plugin for WooComerce
    4141
    42421. Download the plugin and upload it to your website
     
    5252You can also find the plugin by using the search. Go to Plugins > Add New > and type "Quipu".
    5353
    54 Once done, you have connected Quipu with WooCommerce 2 and you can start controlling your entire billing easily and quickly!
     54Once done, you have connected Quipu with WooCommerce and you can start controlling your entire billing easily and quickly!
    5555
    5656== Frequently Asked Questions ==
  • quipu-accounting-for-woocommerce/trunk/readme.txt

    r1658660 r3032248  
    55Requires at least: 4.1
    66Tested up to: 4.6
    7 Stable tag: 1.0.2
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.