JS SDK V2 onShippingChange update items list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, I need to update the items list on shipping change but I can't find the correct path. My case is that I offer some items for free but only in some countries. when the user selects his country on my website, I generate the list of offers and add it to the cart that is them sent to Paypal. If the user wants the parcel delivered to other country I need to remove these offers and also update some prices. We use discount coupons that are valid only for defined countries.
I am able to update the amounts (subtotal, shipping and discounts) but can't update the list of items.
The code I have now is (that is running OK):
onShippingChange: function(data, actions) {
calculatetotals(data.shipping_address.country_code);
return actions.order.patch([
{
op: 'replace',
path: '/purchase_units/@reference_id==\'default\'/amount',
value: {
currency_code: 'EUR',
value: (parseFloat(itemssubtotal) + parseFloat(itemsshipping)-parseFloat(itemsdiscounts)).toFixed(2),
breakdown: {
item_total: {
currency_code: 'EUR',
value: (parseFloat(itemssubtotal)).toFixed(2)
},
shipping: {
currency_code: 'EUR',
value: (parseFloat(itemsshipping)).toFixed(2)
},
discount:{
currency_code: "EUR",
value: (parseFloat(itemsdiscounts)).toFixed(2)
}
}
}
}
//,
//{
// op: 'replace',
// path: '/purchase_units/@reference_id==\'default\'/purchase_units',
// value: {
// items: itemscart
// }
//}
]);
}
Is there a way to replace the items list or update the existing list? any help is appreciated.
Thanks,

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Selected Shipping Method amount not updating to cart for card payment in SDKs
- Why are outgoing funds no longer shown as negative dollar amounts? in PayPal Reporting
- How do I update shipping in the popup when using onShippingAddressChange() in REST APIs
- Payment not automatically being captured, funds not transferred in Sandbox Environment
- patch_payment_resource returns generic 422 on second request in REST APIs