Apply hidden surcharges
Connect JS API
Configure the hidden surcharge
Ecwid.OnAPILoaded.add(function () {
Ecwid.OnPageLoaded.add(function (page) {
if (page.type == "CART") {
// Initialize extra fields
window.ec = window.ec || {};
ec.order = ec.order || {};
ec.order.extraFields = ec.order.extraFields || {};
// Set order surcharge
//'surcharge' part after the 'ec.order.extraFields.' becomes ID of the extra field
ec.order.extraFields.surcharge = {
'value': 'Custom charge',
"options": [
{
"title": "Custom charge",
"surcharge": 5
},
],
"surchargeShortName": {
"name": "Surcharge",
"showSurchargePercentValue": false
},
'surchargeType': 'PERCENT'
}
window.Ecwid && Ecwid.refreshConfig();
}
});
});See also
Last updated
Was this helpful?
