Shipping fees depending of country of delivery

Anthony1235
Contributeur
Contributeur

Hi everyone,
I am using the new paypal button, I like to have free shipping to Belgium and flat rate in Europe, but no delivery outside Europe.

I have this script from the paypal guide:
I don't know how to replace the       data.shipping_address.state === 'CA' ?       for Belgium.

Thank you

const baseOrderAmount = '15.00';
paypal.Buttons({
onShippingChange: function(data, actions) {

// Patch the shipping amount
const shippingAmount = data.shipping_address.country === 'CA' ? '0.00' : '5.00';
return actions.order.patch([
{
op: 'replace',
path: '/purchase_units/@reference_id==\'default\'/amount',
value: {
currency_code: 'EUR',
value: (parseFloat(baseOrderAmount) + parseFloat(shippingAmount)).toFixed(2),
breakdown: {
item_total: {
currency_code: 'EUR',
value: baseOrderAmount
},
shipping: {
currency_code: 'EUR',
value: shippingAmount
}
}
}
}
]);
}
}).render('#paypal-button-container');

Login to Me Too
0 RÉPONSES 0

Haven't Found your Answer?

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