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

Использование ФИО из платежного адреса, в случае, если ФИО в адресе доставки пусто

This commit is contained in:
max-baranikov 2020-09-28 13:38:23 +03:00 committed by GitHub
parent 754e1e8245
commit 155a2d5716
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 4 deletions

View File

@ -189,8 +189,17 @@ if ( ! class_exists( 'WC_Retailcrm_Orders' ) ) :
}
if ($update && $customerWasChanged) {
$this->order['firstName'] = $wcOrder->get_shipping_first_name();
$this->order['lastName'] = $wcOrder->get_shipping_last_name();
$firstName = $wcOrder->get_shipping_first_name();
$lastName = $wcOrder->get_shipping_last_name();
if(empty($firstName) && empty($lastName))
{
$firstName = $wcOrder->get_billing_first_name();
$lastName = $wcOrder->get_billing_last_name();
}
$this->order['firstName'] = $firstName;
$this->order['lastName'] = $lastName;
}
return true;

View File

@ -53,11 +53,20 @@ class WC_Retailcrm_Order extends WC_Retailcrm_Abstracts_Data
*/
public function build($order)
{
$firstName = $order->get_shipping_first_name();
$lastName = $order->get_shipping_last_name();
if(empty($firstName) && empty($lastName))
{
$firstName = $order->get_billing_first_name();
$lastName = $order->get_billing_last_name();
}
$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(),
'firstName' => $firstName,
'lastName' => $lastName,
'email' => $order->get_billing_email(),
'customerComment' => $order->get_customer_note(),
'phone' => $order->get_billing_phone(),