1
0
mirror of synced 2025-02-21 09:23:14 +03:00

Update filling field createAt customer

This commit is contained in:
dima-uryvskiy 2020-11-19 18:02:04 +03:00
parent 415c2edf0e
commit 277d1924b4
2 changed files with 6 additions and 3 deletions

View File

@ -374,9 +374,9 @@ if (!class_exists('WC_Retailcrm_Customers')) :
}
}
if (empty($createdAt)) {
$createdAt = new WC_DateTime();
}
// If a customer has placed an order as a guest, then $customer->get_date_created() == null,
// then we take $order->get_date_created() order
$createdAt = empty($createdAt) ? $order->get_date_created() : $createdAt;
$data_customer = array(
'createdAt' => $createdAt->date('Y-m-d H:i:s'),

View File

@ -44,6 +44,7 @@ class WC_Retailcrm_Customers_Test extends WC_Retailcrm_Test_Case_Helper
$this->customer->set_billing_email($this->customer->get_email());
$this->customer->set_password('password');
$this->customer->set_billing_phone('89000000000');
$this->customer->set_date_created(date('Y-m-d H:i:s'));
$this->customer->save();
}
@ -91,6 +92,7 @@ class WC_Retailcrm_Customers_Test extends WC_Retailcrm_Test_Case_Helper
$this->assertArrayHasKey('createdAt', $customer_send);
$this->assertArrayHasKey('email', $customer_send);
$this->assertNotEmpty($customer_send['externalId']);
$this->assertNotEmpty($customer_send['createdAt']);
$this->assertNotEmpty($customer_send['firstName']);
$this->assertNotEmpty($customer_send['email']);
} else {
@ -115,6 +117,7 @@ class WC_Retailcrm_Customers_Test extends WC_Retailcrm_Test_Case_Helper
$this->assertArrayHasKey('createdAt', $customer_send);
$this->assertArrayHasKey('email', $customer_send);
$this->assertNotEmpty($customer_send['externalId']);
$this->assertNotEmpty($customer_send['createdAt']);
$this->assertNotEmpty($customer_send['firstName']);
$this->assertNotEmpty($customer_send['email']);
$this->assertInstanceOf('WC_Customer', $customer);