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

Order creation date

This commit is contained in:
Yura 2020-07-23 14:50:09 +03:00 committed by GitHub
parent b25e9e4a2b
commit 782b4781ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -602,6 +602,7 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) :
/** @var WC_Order|WP_Error $wc_order */ /** @var WC_Order|WP_Error $wc_order */
$wc_order = wc_create_order($args); $wc_order = wc_create_order($args);
$wc_order->set_date_created($order['createdAt']);
$customer = $order['customer']; $customer = $order['customer'];
$contactOrCustomer = array(); $contactOrCustomer = array();
$address = isset($order['customer']['address']) ? $order['customer']['address'] : array(); $address = isset($order['customer']['address']) ? $order['customer']['address'] : array();
@ -1181,4 +1182,4 @@ if ( ! class_exists( 'WC_Retailcrm_History' ) ) :
} }
} }
endif; endif;

View File

@ -23,12 +23,13 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
public function test_history_order_create() public function test_history_order_create()
{ {
$product = WC_Helper_Product::create_simple_product(); $product = WC_Helper_Product::create_simple_product();
$order = $this->get_history_data_new_order($product->get_id());
$this->mockHistory( $this->mockHistory(
true, true,
true, true,
$this->empty_history(), $this->empty_history(),
$this->get_history_data_new_order($product->get_id()) $order
); );
$retailcrm_history = new \WC_Retailcrm_History($this->apiMock); $retailcrm_history = new \WC_Retailcrm_History($this->apiMock);
@ -52,6 +53,8 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
$this->assertEquals($product->get_id(), $order_added_item->get_product()->get_id()); $this->assertEquals($product->get_id(), $order_added_item->get_product()->get_id());
} }
$this->assertNotEmpty($order_added->get_date_created());
$this->assertEquals($order_added->get_date_created()->date('Y-m-d H:i:s'), $order['history'][0]['createdAt']);
$this->assertNotEmpty($shipping_address['first_name']); $this->assertNotEmpty($shipping_address['first_name']);
$this->assertNotEmpty($shipping_address['last_name']); $this->assertNotEmpty($shipping_address['last_name']);
$this->assertNotEmpty($shipping_address['postcode']); $this->assertNotEmpty($shipping_address['postcode']);
@ -133,7 +136,7 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
$this->regenerateMocks(); $this->regenerateMocks();
$this->history_order_switch_customer($order_id); $this->history_order_switch_customer($order_id);
$this->regenerateMocks(); $this->regenerateMocks();
$this->history_order_switch_customer_to_corporate($order_id); $this->history_order_switch_customer_to_corporate($order_id);
@ -173,7 +176,7 @@ class WC_Retailcrm_History_Test extends WC_Retailcrm_Test_Case_Helper
$this->assertEquals('tester001@example.com', $order_added->get_billing_email()); $this->assertEquals('tester001@example.com', $order_added->get_billing_email());
$this->assertNotEmpty($order_added->get_id()); $this->assertNotEmpty($order_added->get_id());
return $order_added->get_id(); return $order_added->get_id();
} }