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.

Automatically remove coupon code when an item is removed

cbootcboot Member
in Help edited July 2012
I am currently automatically adding a coupon code when the customer clicks on one of the products in my store. However, if they decide they don't want the product anymore, and they remove the product from their cart, the coupon remains. This wouldn't be a big problem, as the coupon only applies to that one product. However, if they try to add a different product and use a different coupon, they are alerted that they can't use said coupon because there is already a coupon in the cart (we have made them not combinable). Is there a way to automatically remove the coupon when the product is removed?
  • cbootcboot Member
    Quick update: we've decided to make all of our coupons combinable, but only applicable to specific categories. This way we don't have the last problem I mentioned. However, the first coupon is still in the cart unless manually removed by the customer. It deducts $0, so it's not a huge deal, but if there's a simple solution to this, it may help reduce confusion.
  • fc_adamfc_adam FoxyCart Team

    What you'd want to do is add some javascript to your cart that loops through the coupons present in the cart, and if products that they relate to don't exist then you'd remove them. In terms of actually removing them, if you view the link that is run when you delete them manually using the cross icon in the cart, that will give you an idea of what to do.

    Something worth considering with this, if a customer has added the coupon to their cart, they may well expect it to remain in their cart, so if they made a mistake and decide to re-add the products, they may find it frustrating to then discover they need to re-add the coupon, especially if they only realise it's not there when they hit the checkout and have to back-track.
  • charlie_mezakcharlie_mezak Member
    edited July 2012

    Could you post a clue about the link to remove a coupon code? I'm using a custom cart and can't easily switch back to the colorbox cart just to look at that link.

    I imagine it's something like

    I'll experiment.

  • fc_adamfc_adam FoxyCart Team

    Not quite, lifted straight from the cart it looks like this:

    Where the coupon ID can be found in the fc_json object.
  • @fc_adam Thank you!
Sign In or Register to comment.