Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Avoid get_billing and get_shipping method when updating the order #4013

Merged
merged 1 commit into from Mar 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 23 additions & 22 deletions src/StoreApi/Utilities/OrderController.php
Expand Up @@ -453,28 +453,29 @@ protected function update_line_items_from_cart( \WC_Order $order ) {
* @param \WC_Order $order The order object to update.
*/
protected function update_addresses_from_cart( \WC_Order $order ) {
$customer_billing = wc()->customer->get_billing();
$customer_billing = array_combine(
array_map(
function( $key ) {
return 'billing_' . $key;
},
array_keys( $customer_billing )
),
$customer_billing
$order->set_props(
[
'billing_first_name' => wc()->customer->get_billing_first_name(),
'billing_last_name' => wc()->customer->get_billing_last_name(),
'billing_company' => wc()->customer->get_billing_company(),
'billing_address_1' => wc()->customer->get_billing_address_1(),
'billing_address_2' => wc()->customer->get_billing_address_2(),
'billing_city' => wc()->customer->get_billing_city(),
'billing_state' => wc()->customer->get_billing_state(),
'billing_postcode' => wc()->customer->get_billing_postcode(),
'billing_country' => wc()->customer->get_billing_country(),
'billing_email' => wc()->customer->get_billing_email(),
'billing_phone' => wc()->customer->get_billing_phone(),
'shipping_first_name' => wc()->customer->get_shipping_first_name(),
'shipping_last_name' => wc()->customer->get_shipping_last_name(),
'shipping_company' => wc()->customer->get_shipping_company(),
'shipping_address_1' => wc()->customer->get_shipping_address_1(),
'shipping_address_2' => wc()->customer->get_shipping_address_2(),
'shipping_city' => wc()->customer->get_shipping_city(),
'shipping_state' => wc()->customer->get_shipping_state(),
'shipping_postcode' => wc()->customer->get_shipping_postcode(),
'shipping_country' => wc()->customer->get_shipping_country(),
]
);
$order->set_props( $customer_billing );

$customer_shipping = wc()->customer->get_shipping();
$customer_shipping = array_combine(
array_map(
function( $key ) {
return 'shipping_' . $key;
},
array_keys( $customer_shipping )
),
$customer_shipping
);
$order->set_props( $customer_shipping );
}
}