How to Unpublish coupon After user paid successfully

  • Default avatar
     3 years ago

    Currently, one time use coupons are unpublished when user press "Place Order" on the checkout page.
    On my site, the user is being redirected to a secure payment form.

    The problem is, if the user fails to pay on first attempt, the coupon is not valid anymore.
    Is there a way to unpublish the coupon only when an order is confirmed?
  • Your avatar
     3 years ago

    The short answer is no. The main reason is the cleanup function is called when the order is created and the session of the coupon is not guaranteed to be alive when the order is actually confirmed. For example confirming the order in the backend. In order to do this, a order coupon table would have to be created and the coupon data stored there when the order is created. Then when the order is confirmed, read that table and update the history. It is not a very easy thing to do.

    Also I gave a quick solution here for Virtuemart 1:

    But the user never got it to work.