From 758ff802480744d757ac93fea8959029ea8b0979 Mon Sep 17 00:00:00 2001 From: Ivan Chaplygin Date: Thu, 6 Jun 2024 15:44:21 +0300 Subject: [PATCH] ref #95040 Added check of cancel and refund statuses --- src/include/class-wc-retailcrm-orders.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/include/class-wc-retailcrm-orders.php b/src/include/class-wc-retailcrm-orders.php index 0f28a55..18256ab 100644 --- a/src/include/class-wc-retailcrm-orders.php +++ b/src/include/class-wc-retailcrm-orders.php @@ -496,7 +496,13 @@ if (!class_exists('WC_Retailcrm_Orders')) : if ($result !== []) { $crmItems = $result['items']; - $this->cancelLoyalty = $this->order_item->isCancelLoyalty($wcItems, $crmItems); + if ($result['discountType'] !== null && in_array($order->get_status(), ['cancelled', 'refunded'])) { + $this->cancelLoyalty = true; + $this->order_item->cancelLoyalty = true; + } else { + $this->cancelLoyalty = $this->order_item->isCancelLoyalty($wcItems, $crmItems); + } + $this->loyaltyDiscountType = $result['discountType']; } }