diff --git a/src/include/abstracts/class-wc-retailcrm-abstracts-address.php b/src/include/abstracts/class-wc-retailcrm-abstracts-address.php index aae346e..a2a7b0f 100644 --- a/src/include/abstracts/class-wc-retailcrm-abstracts-address.php +++ b/src/include/abstracts/class-wc-retailcrm-abstracts-address.php @@ -91,12 +91,13 @@ abstract class WC_Retailcrm_Abstracts_Address extends WC_Retailcrm_Abstracts_Dat protected function getOrderAddress($order) { $orderAddress = $order->get_address($this->address_type); - - if (empty($orderAddress) && $this->address_type === self::ADDRESS_TYPE_BILLING && $this->fallback_to_shipping) { + $checkEmptyArray = array_filter($orderAddress); + + if (empty($checkEmptyArray) && $this->address_type === self::ADDRESS_TYPE_BILLING && $this->fallback_to_shipping) { $orderAddress = $order->get_address(self::ADDRESS_TYPE_SHIPPING); } - if (empty($orderAddress) && $this->address_type === self::ADDRESS_TYPE_SHIPPING && $this->fallback_to_billing) { + if (empty($checkEmptyArray) && $this->address_type === self::ADDRESS_TYPE_SHIPPING && $this->fallback_to_billing) { $orderAddress = $order->get_address(self::ADDRESS_TYPE_BILLING); } diff --git a/src/include/order/class-wc-retailcrm-order.php b/src/include/order/class-wc-retailcrm-order.php index a44ca6d..8eeb9e8 100644 --- a/src/include/order/class-wc-retailcrm-order.php +++ b/src/include/order/class-wc-retailcrm-order.php @@ -64,9 +64,9 @@ class WC_Retailcrm_Order extends WC_Retailcrm_Abstracts_Data $data = array( 'externalId' => $order->get_id(), - 'createdAt' => $order->get_date_created()->date('Y-m-d H:i:s'), - 'firstName' => $order->get_shipping_first_name(), - 'lastName' => $order->get_shipping_last_name(), + 'createdAt' => $order->get_date_created()->date('Y-m-d H:i:s'), + 'firstName' => $firstName, + 'lastName' => $lastName, 'email' => strtolower($order->get_billing_email()), 'customerComment' => $order->get_customer_note(), 'phone' => $order->get_billing_phone(),