1
0
mirror of synced 2025-01-18 08:51:41 +03:00

Fix client info if shipping address empty, use billing address

This commit is contained in:
Dima Uryvskiy 2020-11-23 13:05:46 +03:00 committed by GitHub
parent c7c3065834
commit 2fd1a1088b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -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);
}

View File

@ -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(),