Fix client info if shipping address empty, use billing address
This commit is contained in:
parent
c7c3065834
commit
2fd1a1088b
@ -91,12 +91,13 @@ abstract class WC_Retailcrm_Abstracts_Address extends WC_Retailcrm_Abstracts_Dat
|
|||||||
protected function getOrderAddress($order)
|
protected function getOrderAddress($order)
|
||||||
{
|
{
|
||||||
$orderAddress = $order->get_address($this->address_type);
|
$orderAddress = $order->get_address($this->address_type);
|
||||||
|
$checkEmptyArray = array_filter($orderAddress);
|
||||||
|
|
||||||
if (empty($orderAddress) && $this->address_type === self::ADDRESS_TYPE_BILLING && $this->fallback_to_shipping) {
|
if (empty($checkEmptyArray) && $this->address_type === self::ADDRESS_TYPE_BILLING && $this->fallback_to_shipping) {
|
||||||
$orderAddress = $order->get_address(self::ADDRESS_TYPE_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);
|
$orderAddress = $order->get_address(self::ADDRESS_TYPE_BILLING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +65,8 @@ class WC_Retailcrm_Order extends WC_Retailcrm_Abstracts_Data
|
|||||||
$data = array(
|
$data = array(
|
||||||
'externalId' => $order->get_id(),
|
'externalId' => $order->get_id(),
|
||||||
'createdAt' => $order->get_date_created()->date('Y-m-d H:i:s'),
|
'createdAt' => $order->get_date_created()->date('Y-m-d H:i:s'),
|
||||||
'firstName' => $order->get_shipping_first_name(),
|
'firstName' => $firstName,
|
||||||
'lastName' => $order->get_shipping_last_name(),
|
'lastName' => $lastName,
|
||||||
'email' => strtolower($order->get_billing_email()),
|
'email' => strtolower($order->get_billing_email()),
|
||||||
'customerComment' => $order->get_customer_note(),
|
'customerComment' => $order->get_customer_note(),
|
||||||
'phone' => $order->get_billing_phone(),
|
'phone' => $order->get_billing_phone(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user