mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Refactor patch request
This commit is contained in:
parent
47d6933288
commit
f396870610
4 changed files with 32 additions and 21 deletions
|
@ -71,7 +71,15 @@ class PatchCollectionFactory {
|
|||
);
|
||||
$operation = $purchase_unit_from ? 'replace' : 'add';
|
||||
$value = $purchase_unit_to->to_array();
|
||||
$patches[] = new Patch(
|
||||
|
||||
if ( ! isset( $value['shipping'] ) ) {
|
||||
$shipping = $purchase_unit_from && null !== $purchase_unit_from->shipping() ? $purchase_unit_from->shipping() : null;
|
||||
if ( $shipping ) {
|
||||
$value['shipping'] = $shipping->to_array();
|
||||
}
|
||||
}
|
||||
|
||||
$patches[] = new Patch(
|
||||
$operation,
|
||||
$path . "/@reference_id=='" . $purchase_unit_to->reference_id() . "'",
|
||||
$value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue