javascript - Function to update total cost not working -
i building simple shopping cart using simplecart.js.
i have been able display items, add them basket , checkout. however, trying add dropdown allow users select country determine shipping cost.
plunker: http://plnkr.co/edit/ab6jlxmycppwr4isuqez?p=preview
i have added following select
, how can connect simplecart.js? believe update() needs called:
js:
<select class="item_shipping" id="addshipping"> <option value="4.99">england £4.99</option> <option value="5.99">ireland £5.99</option> <option value="7.99">europe £7.99</option> </select>
see http://plnkr.co/edit/cizshalarqmbrqnb6hgf?p=preview
first need way shipping cost:
simplecart({ shippingcustom: function(){ var ddl = document.getelementbyid("addshipping"); return ddl.options[ddl.selectedindex].value; } });
and when drop down changes, update values:
document.getelementbyid("addshipping").addeventlistener("change", function(){ simplecart.update(); });
Comments
Post a Comment