The code below is for automatically adding a coupon code in the background, on pageload.
fcc.events.cart.ready.add(function(){ // check for coupon $.getJSON('https://' + storedomain + '/cart?output=json' + fcc.session_get() +'&cart=view&callback=?', function(data){ if (!data.coupons) { $.getJSON('https://' + storedomain + '/cart?cart=update&output=json' + fcc.session_get() +'&coupon=free-special-product-shipping&callback=?', function(data){ // console.log('Coupon added.'); FC.json = data; }); } }); return true; });
function fc_BuildFoxyCart() { // check for coupon $.getJSON('https://example.foxycart.com/cart?output=json&cart=view&callback=?' + fc_AddSession(), function(data){ if (!data.coupons) { $.getJSON('https://example.foxycart.com/cart?cart=update&output=json&coupon=free-special-product-shipping&callback=?' + fc_AddSession(), function(data){ fc_json = data; }); } }); return true; }
For further details, please see the forum link below.