Changeset 3032248
- Timestamp:
- 02/06/2024 03:24:08 PM (2 years ago)
- Location:
- quipu-accounting-for-woocommerce
- Files:
-
- 4 edited
- 1 copied
-
tags/1.1.0 (copied) (copied from quipu-accounting-for-woocommerce/tags/1.0.2)
-
tags/1.1.0/includes/class-wc-quipu-integration.php (modified) (9 diffs)
-
tags/1.1.0/readme.md (modified) (1 diff)
-
tags/1.1.0/readme.txt (modified) (3 diffs)
-
trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
quipu-accounting-for-woocommerce/tags/1.1.0/includes/class-wc-quipu-integration.php
r1436028 r3032248 354 354 355 355 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 orders360 ) );361 // error_log(print_r($orders, true));362 363 // Get "Completed" date not order date364 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'); 369 369 } 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 } 372 372 } 373 373 … … 392 392 */ 393 393 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 ); 396 400 397 401 // If no Quipu id exists then create Quipu invoice, otherwise it was already accounted for … … 410 414 $quipu_contact = new Quipu_Api_Contact($this->api_connection); 411 415 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 412 424 $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 ) ); 422 436 423 437 $this->logger->write("Contact: ".print_r($contact, true)); … … 429 443 $order = new WC_Order( $order_id ); 430 444 // error_log(print_r($order, true)); 431 $ordered_items = $ order->get_items();445 $ordered_items = $wk_order->get_items(); 432 446 // error_log(print_r($ordered_items, true)); 433 $shipping_items = $ order->get_items('shipping');447 $shipping_items = $wk_order->get_items('shipping'); 434 448 // error_log(print_r($shipping_items, true)); 435 449 // Add shipping "item" … … 443 457 // error_log($wc_order_date); 444 458 445 $wc_payment_method = get_post_meta($order_id, '_payment_method', true);459 $wc_payment_method = $wk_order->get_payment_method(); 446 460 // The below are the default payment methods that come with WC 447 461 // These Quipu options were not set; "direct_debit", "factoring" … … 486 500 $shipping_name = 'Shipping: '.$value['name']; 487 501 $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 } 495 514 } 515 516 // error_log( 'Shipping Name: ' . $shipping_name ); 517 // error_log( 'Shipping Total: ' . $shipping_total ); 518 496 519 497 520 $shipping_tax_per = round( (($shipping_tax*100)/$shipping_total), 4); … … 514 537 $this->logger->write("Order Response: ".print_r($quipu_invoice->get_response(), true)); 515 538 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 ); 518 547 } else { 519 $this->logger->write("Quipu Invoice ID: ".$quipu_invoice->get_id());548 $this->logger->write( "Couldn't save Quipu ID" ); 520 549 } 521 550 } catch (Exception $e) { … … 538 567 // error_log(print_r($args, true)); 539 568 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); 541 572 542 573 if( !empty($quipu_invoice_id) ) { … … 548 579 $order = new WC_Order( $args['order_id'] ); 549 580 // error_log(print_r($order, true)); 550 $order_items = $ order->get_items();581 $order_items = $wk_order->get_items(); 551 582 // error_log(print_r($order_items, true)); 552 $order_amount = $ order->get_total();583 $order_amount = $wk_order->get_total(); 553 584 // error_log("Order $: ".$order_amount); 554 585 -
quipu-accounting-for-woocommerce/tags/1.1.0/readme.md
r1658660 r3032248 5 5 Requires at least: 4.1 6 6 Tested up to: 4.6 7 Stable tag: 1. 0.27 Stable tag: 1.1.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
quipu-accounting-for-woocommerce/tags/1.1.0/readme.txt
r1658660 r3032248 5 5 Requires at least: 4.1 6 6 Tested up to: 4.6 7 Stable tag: 1. 0.27 Stable tag: 1.1.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 10 11 Quipu plugin for WooCommerce 2allows you to automate all your business' billing. Send custom invoices and manage your11 Quipu plugin for WooCommerce allows you to automate all your business' billing. Send custom invoices and manage your 12 12 online store! 13 13 14 14 == Description == 15 15 16 Quipu plugin for WooCommerce 2allows you to automate all your business’ billing. Send custom invoices and manage your online store quickly and easily!16 Quipu plugin for WooCommerce allows you to automate all your business’ billing. Send custom invoices and manage your online store quickly and easily! 17 17 18 All you can do with Quipu Accounting for WooCommerce 2:18 All you can do with Quipu Accounting for WooCommerce: 19 19 20 20 * Every time an order is successfully paid, the invoice automatically appears in your Quipu account … … 34 34 4. Customize your brand in your Quipu account 35 35 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).36 This plugin requires that you have an account created in both [WooCommerce](https://www.woothemes.com/woocommerce/) and [Quipu](https://getquipu.com/en). 37 37 38 38 == Installation == 39 39 40 Follow the steps listed below to install the Quipu plugin for WooComerce 240 Follow the steps listed below to install the Quipu plugin for WooComerce 41 41 42 42 1. Download the plugin and upload it to your website … … 52 52 You can also find the plugin by using the search. Go to Plugins > Add New > and type "Quipu". 53 53 54 Once done, you have connected Quipu with WooCommerce 2and you can start controlling your entire billing easily and quickly!54 Once done, you have connected Quipu with WooCommerce and you can start controlling your entire billing easily and quickly! 55 55 56 56 == Frequently Asked Questions == -
quipu-accounting-for-woocommerce/trunk/readme.txt
r1658660 r3032248 5 5 Requires at least: 4.1 6 6 Tested up to: 4.6 7 Stable tag: 1. 0.27 Stable tag: 1.1.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.