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

Commit d3c2efc

Browse files
authored
Avoid get_billing and get_shipping method when updating the order (#4013)
1 parent 00b3995 commit d3c2efc

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

src/StoreApi/Utilities/OrderController.php

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -453,28 +453,29 @@ protected function update_line_items_from_cart( \WC_Order $order ) {
453453
* @param \WC_Order $order The order object to update.
454454
*/
455455
protected function update_addresses_from_cart( \WC_Order $order ) {
456-
$customer_billing = wc()->customer->get_billing();
457-
$customer_billing = array_combine(
458-
array_map(
459-
function( $key ) {
460-
return 'billing_' . $key;
461-
},
462-
array_keys( $customer_billing )
463-
),
464-
$customer_billing
456+
$order->set_props(
457+
[
458+
'billing_first_name' => wc()->customer->get_billing_first_name(),
459+
'billing_last_name' => wc()->customer->get_billing_last_name(),
460+
'billing_company' => wc()->customer->get_billing_company(),
461+
'billing_address_1' => wc()->customer->get_billing_address_1(),
462+
'billing_address_2' => wc()->customer->get_billing_address_2(),
463+
'billing_city' => wc()->customer->get_billing_city(),
464+
'billing_state' => wc()->customer->get_billing_state(),
465+
'billing_postcode' => wc()->customer->get_billing_postcode(),
466+
'billing_country' => wc()->customer->get_billing_country(),
467+
'billing_email' => wc()->customer->get_billing_email(),
468+
'billing_phone' => wc()->customer->get_billing_phone(),
469+
'shipping_first_name' => wc()->customer->get_shipping_first_name(),
470+
'shipping_last_name' => wc()->customer->get_shipping_last_name(),
471+
'shipping_company' => wc()->customer->get_shipping_company(),
472+
'shipping_address_1' => wc()->customer->get_shipping_address_1(),
473+
'shipping_address_2' => wc()->customer->get_shipping_address_2(),
474+
'shipping_city' => wc()->customer->get_shipping_city(),
475+
'shipping_state' => wc()->customer->get_shipping_state(),
476+
'shipping_postcode' => wc()->customer->get_shipping_postcode(),
477+
'shipping_country' => wc()->customer->get_shipping_country(),
478+
]
465479
);
466-
$order->set_props( $customer_billing );
467-
468-
$customer_shipping = wc()->customer->get_shipping();
469-
$customer_shipping = array_combine(
470-
array_map(
471-
function( $key ) {
472-
return 'shipping_' . $key;
473-
},
474-
array_keys( $customer_shipping )
475-
),
476-
$customer_shipping
477-
);
478-
$order->set_props( $customer_shipping );
479480
}
480481
}

0 commit comments

Comments
 (0)