Refactor patch request

This commit is contained in:
Alex P 2023-04-26 16:41:47 +03:00
parent 47d6933288
commit f396870610
No known key found for this signature in database
GPG key ID: 54487A734A204D71
4 changed files with 32 additions and 21 deletions

View file

@ -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