Changeset 3177307
- Timestamp:
- 10/28/2024 03:31:09 PM (17 months ago)
- Location:
- activecampaign-for-woocommerce/trunk
- Files:
-
- 8 edited
-
README.txt (modified) (2 diffs)
-
ac_vendor/autoload.php (modified) (1 diff)
-
ac_vendor/composer/autoload_real.php (modified) (5 diffs)
-
ac_vendor/composer/autoload_static.php (modified) (2 diffs)
-
activecampaign-for-woocommerce.php (modified) (1 diff)
-
includes/abandoned_carts/class-activecampaign-for-woocommerce-run-abandonment-sync-command.php (modified) (48 diffs)
-
includes/config/activecampaign-for-woocommerce-global-constants.php (modified) (1 diff)
-
includes/orders/class-activecampaign-for-woocommerce-order-action-events.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
activecampaign-for-woocommerce/trunk/README.txt
r3170365 r3177307 4 4 Requires at least: 6.0 5 5 Tested up to: 6.6.2 6 Stable tag: 2.7. 96 Stable tag: 2.7.10 7 7 Requires PHP: 7.4 8 8 License: GPLv2 or later … … 95 95 == Changelog == 96 96 97 = 2.7.10 2024-10-28 = 98 * Bugfix - Solving various issues with order update 99 * Bugfix - Abandoned cart created date error resolved 100 97 101 = 2.7.9 2024-10-16 = 98 102 * Bugfix - Issue with our order action event has been resolved -
activecampaign-for-woocommerce/trunk/ac_vendor/autoload.php
r3169593 r3177307 5 5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 return ComposerAutoloaderInit 5559985682c8e8debf7e2ee247bd1345::getLoader();7 return ComposerAutoloaderInit4d7c758a86e1a845ec0bd96a9d87bdef::getLoader(); -
activecampaign-for-woocommerce/trunk/ac_vendor/composer/autoload_real.php
r3169593 r3177307 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 5559985682c8e8debf7e2ee247bd13455 class ComposerAutoloaderInit4d7c758a86e1a845ec0bd96a9d87bdef 6 6 { 7 7 private static $loader; … … 25 25 require __DIR__ . '/platform_check.php'; 26 26 27 spl_autoload_register(array('ComposerAutoloaderInit 5559985682c8e8debf7e2ee247bd1345', 'loadClassLoader'), true, true);27 spl_autoload_register(array('ComposerAutoloaderInit4d7c758a86e1a845ec0bd96a9d87bdef', 'loadClassLoader'), true, true); 28 28 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); 29 spl_autoload_unregister(array('ComposerAutoloaderInit 5559985682c8e8debf7e2ee247bd1345', 'loadClassLoader'));29 spl_autoload_unregister(array('ComposerAutoloaderInit4d7c758a86e1a845ec0bd96a9d87bdef', 'loadClassLoader')); 30 30 31 31 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); … … 33 33 require __DIR__ . '/autoload_static.php'; 34 34 35 call_user_func(\Composer\Autoload\ComposerStaticInit 5559985682c8e8debf7e2ee247bd1345::getInitializer($loader));35 call_user_func(\Composer\Autoload\ComposerStaticInit4d7c758a86e1a845ec0bd96a9d87bdef::getInitializer($loader)); 36 36 } else { 37 37 $map = require __DIR__ . '/autoload_namespaces.php'; … … 54 54 55 55 if ($useStaticLoader) { 56 $includeFiles = Composer\Autoload\ComposerStaticInit 5559985682c8e8debf7e2ee247bd1345::$files;56 $includeFiles = Composer\Autoload\ComposerStaticInit4d7c758a86e1a845ec0bd96a9d87bdef::$files; 57 57 } else { 58 58 $includeFiles = require __DIR__ . '/autoload_files.php'; 59 59 } 60 60 foreach ($includeFiles as $fileIdentifier => $file) { 61 composerRequire 5559985682c8e8debf7e2ee247bd1345($fileIdentifier, $file);61 composerRequire4d7c758a86e1a845ec0bd96a9d87bdef($fileIdentifier, $file); 62 62 } 63 63 … … 66 66 } 67 67 68 function composerRequire 5559985682c8e8debf7e2ee247bd1345($fileIdentifier, $file)68 function composerRequire4d7c758a86e1a845ec0bd96a9d87bdef($fileIdentifier, $file) 69 69 { 70 70 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
activecampaign-for-woocommerce/trunk/ac_vendor/composer/autoload_static.php
r3169593 r3177307 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 5559985682c8e8debf7e2ee247bd13457 class ComposerStaticInit4d7c758a86e1a845ec0bd96a9d87bdef 8 8 { 9 9 public static $files = array ( … … 487 487 { 488 488 return \Closure::bind(function () use ($loader) { 489 $loader->prefixLengthsPsr4 = ComposerStaticInit 5559985682c8e8debf7e2ee247bd1345::$prefixLengthsPsr4;490 $loader->prefixDirsPsr4 = ComposerStaticInit 5559985682c8e8debf7e2ee247bd1345::$prefixDirsPsr4;491 $loader->classMap = ComposerStaticInit 5559985682c8e8debf7e2ee247bd1345::$classMap;489 $loader->prefixLengthsPsr4 = ComposerStaticInit4d7c758a86e1a845ec0bd96a9d87bdef::$prefixLengthsPsr4; 490 $loader->prefixDirsPsr4 = ComposerStaticInit4d7c758a86e1a845ec0bd96a9d87bdef::$prefixDirsPsr4; 491 $loader->classMap = ComposerStaticInit4d7c758a86e1a845ec0bd96a9d87bdef::$classMap; 492 492 493 493 }, null, ClassLoader::class); -
activecampaign-for-woocommerce/trunk/activecampaign-for-woocommerce.php
r3170365 r3177307 17 17 * Plugin URI: https://www.activecampaign.com/ 18 18 * Description: Add Abandoned Cart functionality to your WooCommerce store, synchronize order & customer information using ActiveCampaign. 19 * Version: 2.7. 919 * Version: 2.7.10 20 20 * WC requires at least: 7.4.0 21 21 * WC tested up to: 9.3.3 -
activecampaign-for-woocommerce/trunk/includes/abandoned_carts/class-activecampaign-for-woocommerce-run-abandonment-sync-command.php
r3032832 r3177307 29 29 */ 30 30 class Activecampaign_For_Woocommerce_Run_Abandonment_Sync_Command implements Synced_Status { 31 use Activecampaign_For_Woocommerce_Data_Validation ,32 Activecampaign_For_Woocommerce_Synced_Status_Handler,33 Activecampaign_For_Woocommerce_Abandoned_Cart_Utilities,34 Activecampaign_For_Woocommerce_Order_Line_Item_Gathering;31 use Activecampaign_For_Woocommerce_Data_Validation; 32 use Activecampaign_For_Woocommerce_Synced_Status_Handler; 33 use Activecampaign_For_Woocommerce_Abandoned_Cart_Utilities; 34 use Activecampaign_For_Woocommerce_Order_Line_Item_Gathering; 35 35 36 36 /** … … 251 251 $this->logger->warning( 252 252 'Activecampaign_For_Woocommerce_Run_Abandonment_Sync_Command [force_sync_row]: No abandoned carts found by id', 253 [253 array( 254 254 'id' => $id, 255 255 'abandoned_cart' => $abandoned_cart, 256 256 'ac_code' => 'RASC_251', 257 ]257 ) 258 258 ); 259 259 wp_send_json_error( 'Could not find the abandoned cart row ' . $id . ' in the database' ); … … 305 305 $this->logger->error( 306 306 'A database error was encountered while getting results for abandoned cart records.', 307 [307 array( 308 308 'wpdb_last_error' => $wpdb->last_error, 309 309 'wpdb_last_query' => $wpdb->last_query, 310 310 'suggested_action' => 'Please verify that the query is correct and cron process has read access to the ' . ACTIVECAMPAIGN_FOR_WOOCOMMERCE_TABLE_NAME . ' table', 311 311 'ac_code' => 'RASC_301', 312 ]312 ) 313 313 ); 314 314 } … … 325 325 $this->logger->error( 326 326 'An error was thrown while preparing or getting abandoned cart results.', 327 [327 array( 328 328 'message' => $t->getMessage(), 329 329 'ac_code' => 'RASC_320', 330 330 'trace' => $this->logger->clean_trace( $t->getTrace() ), 331 ]331 ) 332 332 ); 333 333 } … … 376 376 $this->logger->notice( 377 377 'Abandonment sync: There was an error getting results for abandoned cart records.', 378 [378 array( 379 379 'wpdb_last_error' => $wpdb->last_error, 380 ]380 ) 381 381 ); 382 382 } … … 394 394 $this->logger->notice( 395 395 'Abandonment Sync: There was an error with preparing or getting abandoned cart results.', 396 [396 array( 397 397 'message' => $t->getMessage(), 398 398 'trace' => $this->logger->clean_trace( $t->getTrace() ), 399 ]399 ) 400 400 ); 401 401 } … … 424 424 $this->logger->debug_calls( 425 425 'Abandoned cart was not able to establish a valid connection ID', 426 [426 array( 427 427 'connection_id' => $this->connection_id, 428 428 'conneciton_settings' => $storage, 429 ]429 ) 430 430 ); 431 431 … … 476 476 $this->logger->warning( 477 477 'Abandonment sync: Process single abandon cart - Could not find or create customer...', 478 [478 array( 479 479 'customer id' => isset( $customer->id ) ? $customer->id : null, 480 480 'customer first name' => isset( $customer->first_name ) ? $customer->first_name : null, 481 481 'customer last name' => isset( $customer->last_name ) ? $customer->last_name : null, 482 ]482 ) 483 483 ); 484 484 … … 495 495 $this->logger->warning( 496 496 'No product data found in abandoned cart', 497 [497 array( 498 498 'cart' => $abc_order, 499 499 'product_data' => $product_data, 500 ]500 ) 501 501 ); 502 502 $this->mark_abandoned_cart_failed( $abc_order ); … … 512 512 $this->logger->debug( 513 513 'Products could not be built for an abandoned cart.', 514 [514 array( 515 515 'cart' => $abc_order, 516 ]516 ) 517 517 ); 518 518 … … 529 529 $this->logger->notice( 530 530 'Abandoned cart could not find valid connection ID or the cart. Please repair your connection to ActiveCampaign.', 531 [531 array( 532 532 'connection_id' => $this->connection_id, 533 ]533 ) 534 534 ); 535 535 … … 553 553 $this->logger->warning( 554 554 'Abandonment Sync: Failed to build ecom order.', 555 [555 array( 556 556 'exception_message' => $t->getMessage(), 557 557 'exception_trace' => $this->logger->clean_trace( $t->getTrace() ), 558 ]558 ) 559 559 ); 560 560 } … … 563 563 // Step 3: Add the products to the order 564 564 if ( ! empty( $products ) && count( $products ) > 0 ) { 565 array_walk( $products, [ $ecom_order, 'push_order_product' ]);565 array_walk( $products, array( $ecom_order, 'push_order_product' ) ); 566 566 } else { 567 567 $this->logger->warning( 568 568 'Abandonment Sync: Failed to add products to ecom order.', 569 [569 array( 570 570 'email' => isset( $customer->email ) ? $customer->email : null, 571 ]571 ) 572 572 ); 573 573 } … … 575 575 $this->logger->warning( 576 576 'Abandonment Sync: Failed to add products to ecom order.', 577 [577 array( 578 578 'exception_message' => $t->getMessage(), 579 579 'exception_trace' => $this->logger->clean_trace( $t->getTrace() ), 580 ]580 ) 581 581 ); 582 582 } … … 588 588 $this->logger->debug( 589 589 'Abandonment Sync: Find order in AC exception. ', 590 [590 array( 591 591 'exception_message' => $t->getMessage(), 592 592 'connection_id' => isset( $this->connection_id ) ? $this->connection_id : null, … … 594 594 'externalcheckout_id' => $externalcheckout_id, 595 595 'exception_trace' => $this->logger->clean_trace( $t->getTrace() ), 596 ]596 ) 597 597 ); 598 598 } … … 604 604 $ab_datetime = $this->calculate_abandoned_date( $abc_order ); 605 605 606 $ecom_order->set_external_created_date( $ab_datetime ); 606 607 $ecom_order->set_external_updated_date( $ab_datetime ); 607 $ecom_order->set_external_created_date( $ab_datetime );608 608 $ecom_order->set_abandoned_date( $ab_datetime ); 609 609 … … 613 613 $this->logger->debug_excess( 614 614 'Abandonment Sync: This abandoned cart has already been synced to ActiveCampaign and will be updated.', 615 [615 array( 616 616 'order' => self::validate_object( $ecom_order, 'serialize_to_array' ) ? $ecom_order->serialize_to_array() : null, 617 617 'connection_id' => isset( $this->connection_id ) ? $this->connection_id : null, … … 621 621 'customer_email' => isset( $customer->email ) ? $customer->email : null, 622 622 'externalcheckout_id' => $externalcheckout_id, 623 ]623 ) 624 624 ); 625 625 … … 628 628 $this->logger->warning( 629 629 'Abandonment Sync: Order update exception: ', 630 [630 array( 631 631 'connection_id' => isset( $this->connection_id ) ? $this->connection_id : null, 632 632 'customer_email' => isset( $customer->email ) ? $customer->email : null, … … 634 634 'exception_message' => $t->getMessage(), 635 635 'exception_trace' => $this->logger->clean_trace( $t->getTrace() ), 636 ]636 ) 637 637 ); 638 638 } … … 643 643 $this->logger->debug( 644 644 'Abandonment Sync: Creating abandoned cart entry in ActiveCampaign: ', 645 [645 array( 646 646 'order_created' => self::validate_object( $ecom_order, 'serialize_to_array' ) ? wp_json_encode( $ecom_order->serialize_to_array() ) : null, 647 ]647 ) 648 648 ); 649 649 650 650 $ab_datetime = $this->calculate_abandoned_date( $abc_order ); 651 651 $ecom_order->set_abandoned_date( $ab_datetime ); 652 $ecom_order->set_external_created_date( $ab_datetime ); 652 653 $ecom_order->set_external_updated_date( $ab_datetime ); 653 $ecom_order->set_external_created_date( $ab_datetime );654 654 655 655 $order_ac = $this->order_repository->create( $ecom_order ); 656 656 $this->logger->debug_calls( 657 657 'Abandoned cart create result', 658 [658 array( 659 659 'order_ac' => $order_ac, 660 660 'serialized order' => self::validate_object( $order_ac, 'serialize_to_array' ) ? $order_ac->serialize_to_array() : null, 661 ]661 ) 662 662 ); 663 663 } catch ( Throwable $t ) { 664 664 $this->logger->debug( 665 665 'Abandonment Sync: Order creation exception: ', 666 [666 array( 667 667 'connection_id' => isset( $this->connection_id ) ? $this->connection_id : null, 668 668 'customer_email' => isset( $customer->email ) ? $customer->email : null, … … 670 670 'exception_message' => $t->getMessage(), 671 671 'exception_trace' => $this->logger->clean_trace( $t->getTrace() ), 672 ]672 ) 673 673 ); 674 674 } … … 686 686 $this->logger->debug_calls( 687 687 'Abandonment Sync: Abandoned order creation failed: ', 688 [688 array( 689 689 $order_ac, 690 ]690 ) 691 691 ); 692 692 } … … 697 697 $this->logger->debug( 698 698 'Abandonment Sync: Could not read sync ID, record may not have synced to AC: ', 699 [699 array( 700 700 'connection_id' => isset( $this->connection_id ) ? $this->connection_id : null, 701 701 'customer_email' => isset( $customer->email ) ? $customer->email : null, … … 703 703 'exception_message' => $t->getMessage(), 704 704 'exception_trace' => $this->logger->clean_trace( $t->getTrace() ), 705 ]705 ) 706 706 ); 707 707 … … 715 715 $wpdb->update( 716 716 $wpdb->prefix . ACTIVECAMPAIGN_FOR_WOOCOMMERCE_TABLE_NAME, 717 [717 array( 718 718 'synced_to_ac' => self::STATUS_ABANDONED_CART_AUTO_SYNCED, 719 719 'abandoned_date' => $this->calculate_abandoned_date( $abc_order ), 720 720 'ac_order_id' => self::validate_object( $order_ac, 'get_id' ) ? $order_ac->get_id() : null, 721 721 'ac_customer_id' => self::validate_object( $order_ac, 'get_customerid' ) ? $order_ac->get_customerid() : null, 722 ],723 [722 ), 723 array( 724 724 'id' => $abc_order->id, 725 ]725 ) 726 726 ); 727 727 … … 729 729 $this->logger->notice( 730 730 'A database error was encountered while attempting to update a record in the ' . ACTIVECAMPAIGN_FOR_WOOCOMMERCE_TABLE_NAME . ' table', 731 [731 array( 732 732 'wpdb_last_error' => $wpdb->last_error, 733 733 'suggested_action' => 'Please check the message for explanation and contact ActiveCampaign support if the issue repeats.', 734 734 'ac_code' => 'TSSH_713', 735 735 'order_id' => $abc_order->id, 736 ]736 ) 737 737 ); 738 738 } … … 741 741 $this->logger->notice( 742 742 'An exception was encountered while attempting to update a record in the ' . ACTIVECAMPAIGN_FOR_WOOCOMMERCE_TABLE_NAME . ' table', 743 [743 array( 744 744 'message' => $t->getMessage(), 745 745 'abandoned_order_id' => isset( $abc_order->id ) ? $abc_order->id : null, … … 749 749 'exception_message' => $t->getMessage(), 750 750 'exception_trace' => $this->logger->clean_trace( $t->getTrace() ), 751 ]751 ) 752 752 ); 753 753 } … … 784 784 $this->logger->error( 785 785 'There was an issue rounding the amount to 2 decimals.', 786 [786 array( 787 787 'message' => $t->getMessage(), 788 788 'amount_passed' => $amount, 789 789 'stack_trace' => $this->logger->clean_trace( $t->getTrace() ), 790 ]790 ) 791 791 ); 792 792 } … … 799 799 $this->logger->error( 800 800 'There was an issue converting rounded amount to cents.', 801 [801 array( 802 802 'message' => $t->getMessage(), 803 803 'amount_passed' => $amount, 804 804 'rounded' => $dec, 805 805 'stack_trace' => $this->logger->clean_trace( $t->getTrace() ), 806 ]806 ) 807 807 ); 808 808 } … … 816 816 $this->logger->error( 817 817 'There was an issue converting amount to cents.', 818 [818 array( 819 819 'message' => $t->getMessage(), 820 820 'amount_passed' => $amount, 821 821 'stack_trace' => $this->logger->clean_trace( $t->getTrace() ), 822 ]822 ) 823 823 ); 824 824 } … … 836 836 // Get the products set up for the order/cart 837 837 $item_count_total = 0; 838 $products = [];838 $products = array(); 839 839 840 840 foreach ( $cart as $product ) { … … 880 880 $this->logger->error( 881 881 'An exception was thrown while attempting to build the abandoned cart.', 882 [882 array( 883 883 'exception_message' => $t->getMessage(), 884 884 'suggested_action' => 'Verify that cart and product data can be accessed by cron.', … … 886 886 'product_id' => $product_id, 887 887 'exception_trace' => $this->logger->clean_trace( $t->getTrace() ), 888 ]888 ) 889 889 ); 890 890 … … 893 893 } 894 894 895 return [895 return array( 896 896 'products' => $products, 897 897 'item_count_total' => $item_count_total, 898 ];898 ); 899 899 } 900 900 … … 912 912 $this->logger->warning( 913 913 'Abandoned cart could not find valid connection ID. Please repair your connection to ActiveCampaign.', 914 [914 array( 915 915 'connection_id' => $this->connection_id, 916 916 'ac_code' => 'RASC_825', 917 ]917 ) 918 918 ); 919 919 … … 927 927 $this->logger->debug( 928 928 'Abandonment sync: Find customer exception.', 929 [929 array( 930 930 'customer_email' => isset( $customer->email ) ? $customer->email : null, 931 931 'customer_first_name' => isset( $customer->first_name ) ? $customer->first_name : null, … … 934 934 'exception' => $t->getMessage(), 935 935 'exception_trace' => $this->logger->clean_trace( $t->getTrace() ), 936 ]936 ) 937 937 ); 938 938 } … … 952 952 $this->logger->debug( 953 953 'Abandonment sync: Creating customer in ActiveCampaign: ', 954 [954 array( 955 955 'serialized customer' => wp_json_encode( $new_customer->serialize_to_array() ), 956 ]956 ) 957 957 ); 958 958 … … 962 962 $this->logger->warning( 963 963 'Abandonment sync: Email missing, cannot create a customer in AC.', 964 [964 array( 965 965 'email' => self::validate_object( $new_customer, 'get_email' ) ? $new_customer->get_email() : null, 966 966 'customer' => $customer, 967 ]967 ) 968 968 ); 969 969 } … … 971 971 $this->logger->warning( 972 972 'Abandonment sync: Abandon customer creation exception.', 973 [973 array( 974 974 'customer_email' => isset( $customer->email ) ? $customer->email : null, 975 975 'customer_first_name' => isset( $customer->first_name ) ? $customer->first_name : null, … … 979 979 'ac_code' => 'RASC_884', 980 980 'exception_trace' => $this->logger->clean_trace( $t->getTrace() ), 981 ]981 ) 982 982 ); 983 983 } … … 986 986 $this->logger->warning( 987 987 'Abandonment sync: Invalid AC customer.', 988 [988 array( 989 989 'customer_email' => isset( $customer->email ) ? $customer->email : null, 990 990 'customer_first_name' => isset( $customer->first_name ) ? $customer->first_name : null, … … 992 992 'connection_id' => $this->connection_id, 993 993 'ac_code' => 'RASC_899', 994 ]994 ) 995 995 ); 996 996 } … … 1018 1018 } 1019 1019 1020 $last_access_date = new DateTime( $cart->last_access_time, new DateTimeZone( 'UTC' ) ); 1021 $expire_datetime = new DateTime( 'now -' . $this->expire_time . ' hours', new DateTimeZone( 'UTC' ) ); 1022 $ab_date = new DateTime( $cart->last_access_time . ' + ' . $this->expire_time . ' hours', new DateTimeZone( 'UTC' ) ); 1020 $expire_datetime = new DateTime( 'now -' . $this->expire_time . ' hours', new DateTimeZone( 'UTC' ) ); 1021 $ab_date = new DateTime( $cart->last_access_time . ' + ' . $this->expire_time . ' hours', new DateTimeZone( 'UTC' ) ); 1023 1022 1024 1023 $diff = $expire_datetime->diff( $ab_date, true ); … … 1043 1042 $logger->warning( 1044 1043 'Could not set a date time for abandoned cart.', 1045 [1044 array( 1046 1045 'message' => $t->getMessage(), 1047 1046 'trace' => $t->getTrace(), 1048 ] 1049 ); 1050 } 1051 } 1052 1047 ) 1048 ); 1049 1050 if ( isset( $cart->calc_abandoned_date ) && ! empty( $cart->calc_abandoned_date ) ) { 1051 $ab_date = new DateTime( $cart->abandoned_date, new DateTimeZone( 'UTC' ) ); 1052 return $ab_date->format( 'Y-m-d H:i:s e' ); 1053 } 1054 } 1055 } elseif ( isset( $cart->abandoned_date ) && ! empty( $cart->abandoned_date ) ) { 1056 $ab_date = new DateTime( $cart->abandoned_date, new DateTimeZone( 'UTC' ) ); 1057 return $ab_date->format( 'Y-m-d H:i:s e' ); 1058 } 1059 1060 $now = new DateTime( 'now', new DateTimeZone( 'UTC' ) ); 1061 return $now->format( 'Y-m-d H:i:s e' ); 1053 1062 } 1054 1063 } -
activecampaign-for-woocommerce/trunk/includes/config/activecampaign-for-woocommerce-global-constants.php
r3170365 r3177307 26 26 */ 27 27 if ( ! defined( 'ACTIVECAMPAIGN_FOR_WOOCOMMERCE_VERSION' ) ) { 28 define( 'ACTIVECAMPAIGN_FOR_WOOCOMMERCE_VERSION', '2.7. 9' );28 define( 'ACTIVECAMPAIGN_FOR_WOOCOMMERCE_VERSION', '2.7.10' ); 29 29 } 30 30 -
activecampaign-for-woocommerce/trunk/includes/orders/class-activecampaign-for-woocommerce-order-action-events.php
r3170365 r3177307 399 399 /** 400 400 * Check to make sure we are not double syncing the same data. 401 * True means that it is valid for update. 401 402 * 402 403 * @param WC_Subscription|WC_Order $wc_order The order or subscription. Both carry these functions. … … 405 406 */ 406 407 private function check_update_validity( $wc_order ) { 407 $ac_datahash = $wc_order->get_meta( 'ac_datahash' ); 408 $current_datahash = md5( json_encode( $wc_order->get_data() ) ); 408 $logger = new Logger(); 409 409 $last_synced = $wc_order->get_meta( 'ac_order_last_synced_time' ); 410 410 $last_status = $wc_order->get_meta( 'ac_last_synced_status' ); 411 412 if ( 413 time() - $last_synced > 120 && 414 isset( $last_status ) && 415 $last_status === $wc_order->get_status() && 416 $ac_datahash === $current_datahash 417 ) { 418 return false; 411 $ac_datahash = $wc_order->get_meta( 'ac_datahash' ); 412 try { 413 $current_datahash = md5( wp_json_encode( $wc_order->get_data() ) ); 414 } catch ( Throwable $t ) { 415 $logger->warning( 416 'There was an issue attempting to create a datahash for the update validity on the order update.', 417 [ 418 'order_id' => $wc_order->get_id(), 419 ] 420 ); 421 // If this fails return true. Better to double sync than miss it entirely. 422 } 423 424 try { 425 if ( ! empty( $last_synced ) && time() - intval( $last_synced ) < 120 ) { 426 $last_synced_too_soon = true; 427 } else { 428 $last_synced_too_soon = false; 429 } 430 } catch ( Throwable $t ) { 431 $logger->warning( 432 'There was an issue attempting to validate the order update.', 433 [ 434 'order_id' => $wc_order->get_id(), 435 ] 436 ); 437 // If this fails return true. Better to double sync than miss it entirely. 438 } 439 440 try { 441 if ( 442 isset( $last_status ) && 443 $last_status === $wc_order->get_status() && 444 $last_synced_too_soon && 445 $ac_datahash === $current_datahash 446 ) { 447 return false; 448 } 449 } catch ( Throwable $t ) { 450 451 $logger->warning( 452 'There was an issue attempting to validate the order update.', 453 [ 454 'order_id' => $wc_order->get_id(), 455 ] 456 ); 457 // If this fails return true. Better to double sync than miss it entirely. 419 458 } 420 459
Note: See TracChangeset
for help on using the changeset viewer.