From ec97a280ba87d8fe04cc419611ea366be40fce50 Mon Sep 17 00:00:00 2001 From: Dima Uryvskiy Date: Wed, 27 Oct 2021 19:14:38 +0300 Subject: [PATCH] Fix PHP warning and deprecated --- src/include/class-wc-retailcrm-customers.php | 13 +++++++------ src/include/class-wc-retailcrm-orders.php | 6 +++--- src/include/class-wc-retailcrm-uploader.php | 12 ++++++------ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/include/class-wc-retailcrm-customers.php b/src/include/class-wc-retailcrm-customers.php index b4aa0a8..e6c4170 100644 --- a/src/include/class-wc-retailcrm-customers.php +++ b/src/include/class-wc-retailcrm-customers.php @@ -43,7 +43,7 @@ if (!class_exists('WC_Retailcrm_Customers')) : * @param array $retailcrm_settings * @param WC_Retailcrm_Customer_Address $customer_address */ - public function __construct($retailcrm = false, $retailcrm_settings, $customer_address) + public function __construct($retailcrm, $retailcrm_settings, $customer_address) { $this->retailcrm = $retailcrm; $this->retailcrm_settings = $retailcrm_settings; @@ -73,7 +73,7 @@ if (!class_exists('WC_Retailcrm_Customers')) : */ public function isCorporateEnabled() { - if (!$this->retailcrm) { + if (!$this->retailcrm instanceof WC_Retailcrm_Proxy) { return false; } @@ -92,7 +92,7 @@ if (!class_exists('WC_Retailcrm_Customers')) : */ public function createCustomer($customer, $order = null) { - if (!$this->retailcrm) { + if (!$this->retailcrm instanceof WC_Retailcrm_Proxy) { return null; } @@ -126,7 +126,7 @@ if (!class_exists('WC_Retailcrm_Customers')) : */ public function updateCustomer($customer_id) { - if (!$this->retailcrm) { + if (!$this->retailcrm instanceof WC_Retailcrm_Proxy) { return; } @@ -151,7 +151,7 @@ if (!class_exists('WC_Retailcrm_Customers')) : */ public function updateCustomerById($customer_id, $crmCustomerId) { - if (!$this->retailcrm) { + if (!$this->retailcrm instanceof WC_Retailcrm_Proxy) { return; } @@ -178,7 +178,7 @@ if (!class_exists('WC_Retailcrm_Customers')) : */ public function createCorporateCustomerForOrder($crmCustomerId, $customer, $order) { - if (!$this->retailcrm) { + if (!$this->retailcrm instanceof WC_Retailcrm_Proxy) { return null; } @@ -277,6 +277,7 @@ if (!class_exists('WC_Retailcrm_Customers')) : $this->customerCorporateCompany['address'] = array( 'id' => $response['id'], ); + $this->retailcrm->customersCorporateCompaniesCreate( $customerId, $this->customerCorporateCompany, diff --git a/src/include/class-wc-retailcrm-orders.php b/src/include/class-wc-retailcrm-orders.php index 9abbf5c..bb41eb8 100644 --- a/src/include/class-wc-retailcrm-orders.php +++ b/src/include/class-wc-retailcrm-orders.php @@ -45,7 +45,7 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) : private $payment = array(); public function __construct( - $retailcrm = false, + $retailcrm, $retailcrm_settings, $order_item, $order_address, @@ -72,7 +72,7 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) : */ public function orderCreate($order_id) { - if (!$this->retailcrm) { + if (!$this->retailcrm instanceof WC_Retailcrm_Proxy) { return null; } @@ -245,7 +245,7 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) : */ public function updateOrder($order_id) { - if (!$this->retailcrm) { + if (!$this->retailcrm instanceof WC_Retailcrm_Proxy) { return null; } diff --git a/src/include/class-wc-retailcrm-uploader.php b/src/include/class-wc-retailcrm-uploader.php index e74f43f..95d86c6 100644 --- a/src/include/class-wc-retailcrm-uploader.php +++ b/src/include/class-wc-retailcrm-uploader.php @@ -76,16 +76,16 @@ if (class_exists('WC_Retailcrm_Uploader') === false) { /** * Uploads archive order in CRM * - * @param integer $page Number page uploads. + * @param int $page Number page uploads. * @param array $ids Ids orders upload. * - * @return array + * @return array|null * @throws Exception Invalid argument exception. */ public function uploadArchiveOrders($page, $ids = array()) { - if (is_object($this->retailcrm) === false) { - return; + if (!$this->retailcrm instanceof WC_Retailcrm_Proxy) { + return null; } $uploadErrors = array(); @@ -117,8 +117,8 @@ if (class_exists('WC_Retailcrm_Uploader') === false) { */ public function uploadArchiveCustomers($page) { - if (is_object($this->retailcrm) === false) { - return; + if (!$this->retailcrm instanceof WC_Retailcrm_Proxy) { + return null; } $users = $this->getCmsUsers($page);