The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

Adding Coupon w/ JSON during checkout

BillDABillDA Member
in Help edited November 2010
I've been playing around and trying to let my customers add a coupon from the checkout page. I've got the following HTML and Javascript in my checkout template, but I'm a total JS novice. Am I on the right track here?
<script type="text/javascript">
function fc_add_coupon() {
$.getJSON('http://kpelements.foxycart.com/cart?cart=update&coupon='+document.getElementById('coupon_code').value+'&callback=?' + fcc.session_get(), function(){});
}
</script>

And then later
<h3>Do You Have a Coupon?</h3>
<input type="text" name="coupon_code" id="coupon_code" />
<label class="fc_error" style="display:none;" for="coupon_code">That coupon is either expired, invalid, or has already been used.</label>
<input type="button" value="Apply Coupon" id="apply_coupon" onclick="fc_add_coupon()"/>

Should this do the trick? Also, how can I capture an error adding the coupon (any error at all) and display the fc_error above?

Thanks for the help as always guys.

Bill
Comments
Sign In or Register to comment.