From b8c1305eca0aa24128c8c8519610880f683f6e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D1=80=D1=83=D0=B3=D0=BB=D0=BE=D0=B2=20=D0=94=D0=BC?= =?UTF-8?q?=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Thu, 25 Jul 2019 12:07:20 +0300 Subject: [PATCH] fixed getting sku from product --- src/include/order/class-wc-retailcrm-order-item.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/include/order/class-wc-retailcrm-order-item.php b/src/include/order/class-wc-retailcrm-order-item.php index 96404e22..d5f63349 100644 --- a/src/include/order/class-wc-retailcrm-order-item.php +++ b/src/include/order/class-wc-retailcrm-order-item.php @@ -77,8 +77,13 @@ private function set_offer(WC_Order_Item_Product $item) $uid = ($item['variation_id'] > 0) ? $item['variation_id'] : $item['product_id'] ; $offer = array('externalId' => $uid); - if (isset($this->settings['bind_by_sku']) && $this->settings['bind_by_sku'] == WC_Retailcrm_Base::YES) { - $offer['xmlId'] = $item->get_product()->get_sku(); + $product = $item->get_product(); + + if (!empty($product) && + isset($this->settings['bind_by_sku']) && + $this->settings['bind_by_sku'] == WC_Retailcrm_Base::YES + ) { + $offer['xmlId'] = $product->get_sku(); } $this->set_data_field('offer', $offer);