From c82faf616adc43035ce5ff54348ccc042005bd6f Mon Sep 17 00:00:00 2001 From: Konstantin Date: Wed, 13 Mar 2019 11:46:58 +0300 Subject: [PATCH 1/3] Fixed bug of sending incorrect externalId when editing payment --- src/include/class-wc-retailcrm-orders.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/include/class-wc-retailcrm-orders.php b/src/include/class-wc-retailcrm-orders.php index 216c9f2..9de5935 100644 --- a/src/include/class-wc-retailcrm-orders.php +++ b/src/include/class-wc-retailcrm-orders.php @@ -194,7 +194,7 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) : } if (isset($payment) && $payment['type'] == $this->retailcrm_settings[$order->get_payment_method()] && $order->is_paid()) { - $payment = $this->sendPayment($order, true); + $payment = $this->sendPayment($order, true, $payment['externalId']); return $payment; } @@ -402,13 +402,21 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) : * * @return array $payment */ - protected function sendPayment($order, $update = false) + protected function sendPayment($order, $update = false, $externalId = false) { $payment = array( - 'amount' => $order->get_total(), - 'externalId' => $order->get_id() . uniqid('-') + 'amount' => $order->get_total() ); + if ($update) + { + $payment['externalId'] = $externalId; + } + else + { + $payment['externalId'] = $order->get_id() . uniqid('-'); + } + $payment['order'] = array( 'externalId' => $order->get_id() ); From da3a8285609a815341914d8ca8fc9a0cb8dcfaf6 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Thu, 14 Mar 2019 15:54:25 +0300 Subject: [PATCH 2/3] Fixed bug of sending incorrect externalId when editing payment 2 --- src/include/class-wc-retailcrm-orders.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/include/class-wc-retailcrm-orders.php b/src/include/class-wc-retailcrm-orders.php index 9de5935..9ad84e6 100644 --- a/src/include/class-wc-retailcrm-orders.php +++ b/src/include/class-wc-retailcrm-orders.php @@ -408,12 +408,10 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) : 'amount' => $order->get_total() ); - if ($update) - { + if ($update) { $payment['externalId'] = $externalId; } - else - { + else { $payment['externalId'] = $order->get_id() . uniqid('-'); } From 5055bb710cc929f509a9ac83f073ad16ef391152 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Thu, 14 Mar 2019 15:58:36 +0300 Subject: [PATCH 3/3] Fixed bug of sending incorrect externalId when editing payment 2 --- src/include/class-wc-retailcrm-orders.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/include/class-wc-retailcrm-orders.php b/src/include/class-wc-retailcrm-orders.php index 9ad84e6..3dbea98 100644 --- a/src/include/class-wc-retailcrm-orders.php +++ b/src/include/class-wc-retailcrm-orders.php @@ -410,8 +410,7 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) : if ($update) { $payment['externalId'] = $externalId; - } - else { + } else { $payment['externalId'] = $order->get_id() . uniqid('-'); }