Apply coupon through request

AvraamAvraam Member
I cant figure out from the documentation on how I can trigger a request to apply a coupon to the current selected products,
and listen to result (or errors if coupons are not valid). Any help?
  • fc_adamfc_adam FoxyCart Team
    edited March 2017

    Happy to help! If I'm understanding your post correctly there - you're wanting to apply a coupon in the background dynamically, rather than as part of an normal add to cart request or through the cart/checkout UI.

    If that's the case - you will use our JSONP functionality to send off a quick request. We've got some documentation available about that on - but it'd look like this:
    FC.client.request('https://' + FC.settings.storedomain + '/cart?coupon=YOUR_COUPON_CODE').done(function() {
    if ("YOUR_COUPON_CODE")) {
    // Coupon added successfully
    } else {
    // Didn't add, errors available as array within FC.json.messages.errors
    I hope that helps!
Sign In or Register to comment.