mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Ensure shipping info when patching order
This commit is contained in:
parent
f1555d4db4
commit
3e6efdea76
1 changed files with 9 additions and 1 deletions
|
@ -502,6 +502,14 @@ class OrderEndpoint {
|
||||||
return $order_to_update;
|
return $order_to_update;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$patches_array = $patches->to_array();
|
||||||
|
if ( ! isset( $patches_array[0]['value']['shipping'] ) ) {
|
||||||
|
$shipping = isset( $order_to_update->purchase_units()[0] ) && null !== $order_to_update->purchase_units()[0]->shipping() ? $order_to_update->purchase_units()[0]->shipping() : null;
|
||||||
|
if ( $shipping ) {
|
||||||
|
$patches_array[0]['value']['shipping'] = $shipping->to_array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$bearer = $this->bearer->bearer();
|
$bearer = $this->bearer->bearer();
|
||||||
$url = trailingslashit( $this->host ) . 'v2/checkout/orders/' . $order_to_update->id();
|
$url = trailingslashit( $this->host ) . 'v2/checkout/orders/' . $order_to_update->id();
|
||||||
$args = array(
|
$args = array(
|
||||||
|
@ -514,7 +522,7 @@ class OrderEndpoint {
|
||||||
$order_to_update
|
$order_to_update
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'body' => wp_json_encode( $patches->to_array() ),
|
'body' => wp_json_encode( $patches_array ),
|
||||||
);
|
);
|
||||||
if ( $this->bn_code ) {
|
if ( $this->bn_code ) {
|
||||||
$args['headers']['PayPal-Partner-Attribution-Id'] = $this->bn_code;
|
$args['headers']['PayPal-Partner-Attribution-Id'] = $this->bn_code;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue