JS SDK V2 onShippingChange update items list

LM80PT
New Community Member

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,

 

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.