Plugin Directory

Changeset 3177307


Ignore:
Timestamp:
10/28/2024 03:31:09 PM (17 months ago)
Author:
acteamintegrations
Message:

Version 2.7.10

Location:
activecampaign-for-woocommerce/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • activecampaign-for-woocommerce/trunk/README.txt

    r3170365 r3177307  
    44Requires at least: 6.0
    55Tested up to: 6.6.2
    6 Stable tag: 2.7.9
     6Stable tag: 2.7.10
    77Requires PHP: 7.4
    88License: GPLv2 or later
     
    9595== Changelog ==
    9696
     97= 2.7.10 2024-10-28 =
     98* Bugfix - Solving various issues with order update
     99* Bugfix - Abandoned cart created date error resolved
     100
    97101= 2.7.9 2024-10-16 =
    98102* Bugfix - Issue with our order action event has been resolved
  • activecampaign-for-woocommerce/trunk/ac_vendor/autoload.php

    r3169593 r3177307  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInit5559985682c8e8debf7e2ee247bd1345::getLoader();
     7return ComposerAutoloaderInit4d7c758a86e1a845ec0bd96a9d87bdef::getLoader();
  • activecampaign-for-woocommerce/trunk/ac_vendor/composer/autoload_real.php

    r3169593 r3177307  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit5559985682c8e8debf7e2ee247bd1345
     5class ComposerAutoloaderInit4d7c758a86e1a845ec0bd96a9d87bdef
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInit5559985682c8e8debf7e2ee247bd1345', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInit4d7c758a86e1a845ec0bd96a9d87bdef', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
    29         spl_autoload_unregister(array('ComposerAutoloaderInit5559985682c8e8debf7e2ee247bd1345', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInit4d7c758a86e1a845ec0bd96a9d87bdef', 'loadClassLoader'));
    3030
    3131        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    3333            require __DIR__ . '/autoload_static.php';
    3434
    35             call_user_func(\Composer\Autoload\ComposerStaticInit5559985682c8e8debf7e2ee247bd1345::getInitializer($loader));
     35            call_user_func(\Composer\Autoload\ComposerStaticInit4d7c758a86e1a845ec0bd96a9d87bdef::getInitializer($loader));
    3636        } else {
    3737            $map = require __DIR__ . '/autoload_namespaces.php';
     
    5454
    5555        if ($useStaticLoader) {
    56             $includeFiles = Composer\Autoload\ComposerStaticInit5559985682c8e8debf7e2ee247bd1345::$files;
     56            $includeFiles = Composer\Autoload\ComposerStaticInit4d7c758a86e1a845ec0bd96a9d87bdef::$files;
    5757        } else {
    5858            $includeFiles = require __DIR__ . '/autoload_files.php';
    5959        }
    6060        foreach ($includeFiles as $fileIdentifier => $file) {
    61             composerRequire5559985682c8e8debf7e2ee247bd1345($fileIdentifier, $file);
     61            composerRequire4d7c758a86e1a845ec0bd96a9d87bdef($fileIdentifier, $file);
    6262        }
    6363
     
    6666}
    6767
    68 function composerRequire5559985682c8e8debf7e2ee247bd1345($fileIdentifier, $file)
     68function composerRequire4d7c758a86e1a845ec0bd96a9d87bdef($fileIdentifier, $file)
    6969{
    7070    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • activecampaign-for-woocommerce/trunk/ac_vendor/composer/autoload_static.php

    r3169593 r3177307  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit5559985682c8e8debf7e2ee247bd1345
     7class ComposerStaticInit4d7c758a86e1a845ec0bd96a9d87bdef
    88{
    99    public static $files = array (
     
    487487    {
    488488        return \Closure::bind(function () use ($loader) {
    489             $loader->prefixLengthsPsr4 = ComposerStaticInit5559985682c8e8debf7e2ee247bd1345::$prefixLengthsPsr4;
    490             $loader->prefixDirsPsr4 = ComposerStaticInit5559985682c8e8debf7e2ee247bd1345::$prefixDirsPsr4;
    491             $loader->classMap = ComposerStaticInit5559985682c8e8debf7e2ee247bd1345::$classMap;
     489            $loader->prefixLengthsPsr4 = ComposerStaticInit4d7c758a86e1a845ec0bd96a9d87bdef::$prefixLengthsPsr4;
     490            $loader->prefixDirsPsr4 = ComposerStaticInit4d7c758a86e1a845ec0bd96a9d87bdef::$prefixDirsPsr4;
     491            $loader->classMap = ComposerStaticInit4d7c758a86e1a845ec0bd96a9d87bdef::$classMap;
    492492
    493493        }, null, ClassLoader::class);
  • activecampaign-for-woocommerce/trunk/activecampaign-for-woocommerce.php

    r3170365 r3177307  
    1717 * Plugin URI:           https://www.activecampaign.com/
    1818 * Description:          Add Abandoned Cart functionality to your WooCommerce store, synchronize order & customer information using ActiveCampaign.
    19  * Version:              2.7.9
     19 * Version:              2.7.10
    2020 * WC requires at least: 7.4.0
    2121 * 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  
    2929 */
    3030class 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;
    3535
    3636    /**
     
    251251            $this->logger->warning(
    252252                'Activecampaign_For_Woocommerce_Run_Abandonment_Sync_Command [force_sync_row]: No abandoned carts found by id',
    253                 [
     253                array(
    254254                    'id'             => $id,
    255255                    'abandoned_cart' => $abandoned_cart,
    256256                    'ac_code'        => 'RASC_251',
    257                 ]
     257                )
    258258            );
    259259            wp_send_json_error( 'Could not find the abandoned cart row ' . $id . ' in the database' );
     
    305305                $this->logger->error(
    306306                    'A database error was encountered while getting results for abandoned cart records.',
    307                     [
     307                    array(
    308308                        'wpdb_last_error'  => $wpdb->last_error,
    309309                        'wpdb_last_query'  => $wpdb->last_query,
    310310                        'suggested_action' => 'Please verify that the query is correct and cron process has read access to the ' . ACTIVECAMPAIGN_FOR_WOOCOMMERCE_TABLE_NAME . ' table',
    311311                        'ac_code'          => 'RASC_301',
    312                     ]
     312                    )
    313313                );
    314314            }
     
    325325            $this->logger->error(
    326326                'An error was thrown while preparing or getting abandoned cart results.',
    327                 [
     327                array(
    328328                    'message' => $t->getMessage(),
    329329                    'ac_code' => 'RASC_320',
    330330                    'trace'   => $this->logger->clean_trace( $t->getTrace() ),
    331                 ]
     331                )
    332332            );
    333333        }
     
    376376                $this->logger->notice(
    377377                    'Abandonment sync: There was an error getting results for abandoned cart records.',
    378                     [
     378                    array(
    379379                        'wpdb_last_error' => $wpdb->last_error,
    380                     ]
     380                    )
    381381                );
    382382            }
     
    394394            $this->logger->notice(
    395395                'Abandonment Sync: There was an error with preparing or getting abandoned cart results.',
    396                 [
     396                array(
    397397                    'message' => $t->getMessage(),
    398398                    'trace'   => $this->logger->clean_trace( $t->getTrace() ),
    399                 ]
     399                )
    400400            );
    401401        }
     
    424424            $this->logger->debug_calls(
    425425                'Abandoned cart was not able to establish a valid connection ID',
    426                 [
     426                array(
    427427                    'connection_id'       => $this->connection_id,
    428428                    'conneciton_settings' => $storage,
    429                 ]
     429                )
    430430            );
    431431
     
    476476            $this->logger->warning(
    477477                'Abandonment sync: Process single abandon cart - Could not find or create customer...',
    478                 [
     478                array(
    479479                    'customer id'         => isset( $customer->id ) ? $customer->id : null,
    480480                    'customer first name' => isset( $customer->first_name ) ? $customer->first_name : null,
    481481                    'customer last name'  => isset( $customer->last_name ) ? $customer->last_name : null,
    482                 ]
     482                )
    483483            );
    484484
     
    495495                $this->logger->warning(
    496496                    'No product data found in abandoned cart',
    497                     [
     497                    array(
    498498                        'cart'         => $abc_order,
    499499                        'product_data' => $product_data,
    500                     ]
     500                    )
    501501                );
    502502                $this->mark_abandoned_cart_failed( $abc_order );
     
    512512            $this->logger->debug(
    513513                'Products could not be built for an abandoned cart.',
    514                 [
     514                array(
    515515                    'cart' => $abc_order,
    516                 ]
     516                )
    517517            );
    518518
     
    529529                $this->logger->notice(
    530530                    'Abandoned cart could not find valid connection ID or the cart. Please repair your connection to ActiveCampaign.',
    531                     [
     531                    array(
    532532                        'connection_id' => $this->connection_id,
    533                     ]
     533                    )
    534534                );
    535535
     
    553553            $this->logger->warning(
    554554                'Abandonment Sync: Failed to build ecom order.',
    555                 [
     555                array(
    556556                    'exception_message' => $t->getMessage(),
    557557                    'exception_trace'   => $this->logger->clean_trace( $t->getTrace() ),
    558                 ]
     558                )
    559559            );
    560560        }
     
    563563            // Step 3: Add the products to the order
    564564            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' ) );
    566566            } else {
    567567                $this->logger->warning(
    568568                    'Abandonment Sync: Failed to add products to ecom order.',
    569                     [
     569                    array(
    570570                        'email' => isset( $customer->email ) ? $customer->email : null,
    571                     ]
     571                    )
    572572                );
    573573            }
     
    575575            $this->logger->warning(
    576576                'Abandonment Sync: Failed to add products to ecom order.',
    577                 [
     577                array(
    578578                    'exception_message' => $t->getMessage(),
    579579                    'exception_trace'   => $this->logger->clean_trace( $t->getTrace() ),
    580                 ]
     580                )
    581581            );
    582582        }
     
    588588            $this->logger->debug(
    589589                'Abandonment Sync: Find order in AC exception. ',
    590                 [
     590                array(
    591591                    'exception_message'   => $t->getMessage(),
    592592                    'connection_id'       => isset( $this->connection_id ) ? $this->connection_id : null,
     
    594594                    'externalcheckout_id' => $externalcheckout_id,
    595595                    'exception_trace'     => $this->logger->clean_trace( $t->getTrace() ),
    596                 ]
     596                )
    597597            );
    598598        }
     
    604604                $ab_datetime = $this->calculate_abandoned_date( $abc_order );
    605605
     606                $ecom_order->set_external_created_date( $ab_datetime );
    606607                $ecom_order->set_external_updated_date( $ab_datetime );
    607                 $ecom_order->set_external_created_date( $ab_datetime );
    608608                $ecom_order->set_abandoned_date( $ab_datetime );
    609609
     
    613613                $this->logger->debug_excess(
    614614                    'Abandonment Sync: This abandoned cart has already been synced to ActiveCampaign and will be updated.',
    615                     [
     615                    array(
    616616                        'order'                     => self::validate_object( $ecom_order, 'serialize_to_array' ) ? $ecom_order->serialize_to_array() : null,
    617617                        'connection_id'             => isset( $this->connection_id ) ? $this->connection_id : null,
     
    621621                        'customer_email'            => isset( $customer->email ) ? $customer->email : null,
    622622                        'externalcheckout_id'       => $externalcheckout_id,
    623                     ]
     623                    )
    624624                );
    625625
     
    628628                $this->logger->warning(
    629629                    'Abandonment Sync: Order update exception: ',
    630                     [
     630                    array(
    631631                        'connection_id'       => isset( $this->connection_id ) ? $this->connection_id : null,
    632632                        'customer_email'      => isset( $customer->email ) ? $customer->email : null,
     
    634634                        'exception_message'   => $t->getMessage(),
    635635                        'exception_trace'     => $this->logger->clean_trace( $t->getTrace() ),
    636                     ]
     636                    )
    637637                );
    638638            }
     
    643643                $this->logger->debug(
    644644                    'Abandonment Sync: Creating abandoned cart entry in ActiveCampaign: ',
    645                     [
     645                    array(
    646646                        'order_created' => self::validate_object( $ecom_order, 'serialize_to_array' ) ? wp_json_encode( $ecom_order->serialize_to_array() ) : null,
    647                     ]
     647                    )
    648648                );
    649649
    650650                $ab_datetime = $this->calculate_abandoned_date( $abc_order );
    651651                $ecom_order->set_abandoned_date( $ab_datetime );
     652                $ecom_order->set_external_created_date( $ab_datetime );
    652653                $ecom_order->set_external_updated_date( $ab_datetime );
    653                 $ecom_order->set_external_created_date( $ab_datetime );
    654654
    655655                $order_ac = $this->order_repository->create( $ecom_order );
    656656                $this->logger->debug_calls(
    657657                    'Abandoned cart create result',
    658                     [
     658                    array(
    659659                        'order_ac'         => $order_ac,
    660660                        'serialized order' => self::validate_object( $order_ac, 'serialize_to_array' ) ? $order_ac->serialize_to_array() : null,
    661                     ]
     661                    )
    662662                );
    663663            } catch ( Throwable $t ) {
    664664                $this->logger->debug(
    665665                    'Abandonment Sync: Order creation exception: ',
    666                     [
     666                    array(
    667667                        'connection_id'       => isset( $this->connection_id ) ? $this->connection_id : null,
    668668                        'customer_email'      => isset( $customer->email ) ? $customer->email : null,
     
    670670                        'exception_message'   => $t->getMessage(),
    671671                        'exception_trace'     => $this->logger->clean_trace( $t->getTrace() ),
    672                     ]
     672                    )
    673673                );
    674674            }
     
    686686                    $this->logger->debug_calls(
    687687                        'Abandonment Sync: Abandoned order creation failed: ',
    688                         [
     688                        array(
    689689                            $order_ac,
    690                         ]
     690                        )
    691691                    );
    692692                }
     
    697697            $this->logger->debug(
    698698                'Abandonment Sync: Could not read sync ID, record may not have synced to AC: ',
    699                 [
     699                array(
    700700                    'connection_id'       => isset( $this->connection_id ) ? $this->connection_id : null,
    701701                    'customer_email'      => isset( $customer->email ) ? $customer->email : null,
     
    703703                    'exception_message'   => $t->getMessage(),
    704704                    'exception_trace'     => $this->logger->clean_trace( $t->getTrace() ),
    705                 ]
     705                )
    706706            );
    707707
     
    715715                $wpdb->update(
    716716                    $wpdb->prefix . ACTIVECAMPAIGN_FOR_WOOCOMMERCE_TABLE_NAME,
    717                     [
     717                    array(
    718718                        'synced_to_ac'   => self::STATUS_ABANDONED_CART_AUTO_SYNCED,
    719719                        'abandoned_date' => $this->calculate_abandoned_date( $abc_order ),
    720720                        'ac_order_id'    => self::validate_object( $order_ac, 'get_id' ) ? $order_ac->get_id() : null,
    721721                        'ac_customer_id' => self::validate_object( $order_ac, 'get_customerid' ) ? $order_ac->get_customerid() : null,
    722                     ],
    723                     [
     722                    ),
     723                    array(
    724724                        'id' => $abc_order->id,
    725                     ]
     725                    )
    726726                );
    727727
     
    729729                    $this->logger->notice(
    730730                        'A database error was encountered while attempting to update a record in the ' . ACTIVECAMPAIGN_FOR_WOOCOMMERCE_TABLE_NAME . ' table',
    731                         [
     731                        array(
    732732                            'wpdb_last_error'  => $wpdb->last_error,
    733733                            'suggested_action' => 'Please check the message for explanation and contact ActiveCampaign support if the issue repeats.',
    734734                            'ac_code'          => 'TSSH_713',
    735735                            'order_id'         => $abc_order->id,
    736                         ]
     736                        )
    737737                    );
    738738                }
     
    741741            $this->logger->notice(
    742742                'An exception was encountered while attempting to update a record in the ' . ACTIVECAMPAIGN_FOR_WOOCOMMERCE_TABLE_NAME . ' table',
    743                 [
     743                array(
    744744                    'message'             => $t->getMessage(),
    745745                    'abandoned_order_id'  => isset( $abc_order->id ) ? $abc_order->id : null,
     
    749749                    'exception_message'   => $t->getMessage(),
    750750                    'exception_trace'     => $this->logger->clean_trace( $t->getTrace() ),
    751                 ]
     751                )
    752752            );
    753753        }
     
    784784            $this->logger->error(
    785785                'There was an issue rounding the amount to 2 decimals.',
    786                 [
     786                array(
    787787                    'message'       => $t->getMessage(),
    788788                    'amount_passed' => $amount,
    789789                    'stack_trace'   => $this->logger->clean_trace( $t->getTrace() ),
    790                 ]
     790                )
    791791            );
    792792        }
     
    799799                $this->logger->error(
    800800                    'There was an issue converting rounded amount to cents.',
    801                     [
     801                    array(
    802802                        'message'       => $t->getMessage(),
    803803                        'amount_passed' => $amount,
    804804                        'rounded'       => $dec,
    805805                        'stack_trace'   => $this->logger->clean_trace( $t->getTrace() ),
    806                     ]
     806                    )
    807807                );
    808808            }
     
    816816                $this->logger->error(
    817817                    'There was an issue converting amount to cents.',
    818                     [
     818                    array(
    819819                        'message'       => $t->getMessage(),
    820820                        'amount_passed' => $amount,
    821821                        'stack_trace'   => $this->logger->clean_trace( $t->getTrace() ),
    822                     ]
     822                    )
    823823                );
    824824            }
     
    836836        // Get the products set up for the order/cart
    837837        $item_count_total = 0;
    838         $products         = [];
     838        $products         = array();
    839839
    840840        foreach ( $cart as $product ) {
     
    880880                $this->logger->error(
    881881                    'An exception was thrown while attempting to build the abandoned cart.',
    882                     [
     882                    array(
    883883                        'exception_message' => $t->getMessage(),
    884884                        'suggested_action'  => 'Verify that cart and product data can be accessed by cron.',
     
    886886                        'product_id'        => $product_id,
    887887                        'exception_trace'   => $this->logger->clean_trace( $t->getTrace() ),
    888                     ]
     888                    )
    889889                );
    890890
     
    893893        }
    894894
    895         return [
     895        return array(
    896896            'products'         => $products,
    897897            'item_count_total' => $item_count_total,
    898         ];
     898        );
    899899    }
    900900
     
    912912            $this->logger->warning(
    913913                'Abandoned cart could not find valid connection ID. Please repair your connection to ActiveCampaign.',
    914                 [
     914                array(
    915915                    'connection_id' => $this->connection_id,
    916916                    'ac_code'       => 'RASC_825',
    917                 ]
     917                )
    918918            );
    919919
     
    927927            $this->logger->debug(
    928928                'Abandonment sync: Find customer exception.',
    929                 [
     929                array(
    930930                    'customer_email'      => isset( $customer->email ) ? $customer->email : null,
    931931                    'customer_first_name' => isset( $customer->first_name ) ? $customer->first_name : null,
     
    934934                    'exception'           => $t->getMessage(),
    935935                    'exception_trace'     => $this->logger->clean_trace( $t->getTrace() ),
    936                 ]
     936                )
    937937            );
    938938        }
     
    952952                $this->logger->debug(
    953953                    'Abandonment sync: Creating customer in ActiveCampaign: ',
    954                     [
     954                    array(
    955955                        'serialized customer' => wp_json_encode( $new_customer->serialize_to_array() ),
    956                     ]
     956                    )
    957957                );
    958958
     
    962962                    $this->logger->warning(
    963963                        'Abandonment sync: Email missing, cannot create a customer in AC.',
    964                         [
     964                        array(
    965965                            'email'    => self::validate_object( $new_customer, 'get_email' ) ? $new_customer->get_email() : null,
    966966                            'customer' => $customer,
    967                         ]
     967                        )
    968968                    );
    969969                }
     
    971971                $this->logger->warning(
    972972                    'Abandonment sync: Abandon customer creation exception.',
    973                     [
     973                    array(
    974974                        'customer_email'      => isset( $customer->email ) ? $customer->email : null,
    975975                        'customer_first_name' => isset( $customer->first_name ) ? $customer->first_name : null,
     
    979979                        'ac_code'             => 'RASC_884',
    980980                        'exception_trace'     => $this->logger->clean_trace( $t->getTrace() ),
    981                     ]
     981                    )
    982982                );
    983983            }
     
    986986                $this->logger->warning(
    987987                    'Abandonment sync: Invalid AC customer.',
    988                     [
     988                    array(
    989989                        'customer_email'      => isset( $customer->email ) ? $customer->email : null,
    990990                        'customer_first_name' => isset( $customer->first_name ) ? $customer->first_name : null,
     
    992992                        'connection_id'       => $this->connection_id,
    993993                        'ac_code'             => 'RASC_899',
    994                     ]
     994                    )
    995995                );
    996996            }
     
    10181018                }
    10191019
    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' ) );
    10231022
    10241023                $diff = $expire_datetime->diff( $ab_date, true );
     
    10431042                $logger->warning(
    10441043                    'Could not set a date time for abandoned cart.',
    1045                     [
     1044                    array(
    10461045                        'message' => $t->getMessage(),
    10471046                        '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' );
    10531062    }
    10541063}
  • activecampaign-for-woocommerce/trunk/includes/config/activecampaign-for-woocommerce-global-constants.php

    r3170365 r3177307  
    2626 */
    2727if ( ! defined( 'ACTIVECAMPAIGN_FOR_WOOCOMMERCE_VERSION' ) ) {
    28     define( 'ACTIVECAMPAIGN_FOR_WOOCOMMERCE_VERSION', '2.7.9' );
     28    define( 'ACTIVECAMPAIGN_FOR_WOOCOMMERCE_VERSION', '2.7.10' );
    2929}
    3030
  • activecampaign-for-woocommerce/trunk/includes/orders/class-activecampaign-for-woocommerce-order-action-events.php

    r3170365 r3177307  
    399399    /**
    400400     * Check to make sure we are not double syncing the same data.
     401     * True means that it is valid for update.
    401402     *
    402403     * @param WC_Subscription|WC_Order $wc_order The order or subscription. Both carry these functions.
     
    405406     */
    406407    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();
    409409        $last_synced      = $wc_order->get_meta( 'ac_order_last_synced_time' );
    410410        $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.
    419458        }
    420459
Note: See TracChangeset for help on using the changeset viewer.