Add coupon on click


  • Default avatar
    peter49    
     8 years ago
    0

    Hi, is it possible to apply a coupon on-click from a content page?

    Desired situation:

    • I have a coupon called 'welcome'

    • I have a landing page for new customers

    • on this page they can click a discount button

    • when they go to their cart, they see the 'welcome' coupon already applied

  • Your avatar
    seyi    
     8 years ago
    0

    Hello,

    I dont think that would work if there are no items in the cart, the code would be rejected.

    You would probably need a module for display of the button and a plugin to process it. By clicking the button, the coupon is added in a session, and the cart is checked on every page load. If there are items in the cart, then apply the coupon code.

    This is really out of the scope of AwoCoupon, but can be worked on as a custom extension.
  • Default avatar
    peter49    
     8 years ago
    0

    Hi Seyi, I just managed to do it with the following code:

    <script type="text/javascript">
    jQuery(document).ready(function(){
     jQuery.ajax({url: "https://www.mydomain.com/cart?coupon_code=mycouponcode&option=com_virtuemart&view=cart&task=setcoupon&controller=cart"
                  ,success: function(result){}
                 });
    });
    </script>


    Also works with 0 products in the cart!
  • Your avatar
    seyi    
     8 years ago
    0

    Ok great, assumed it would not accept the coupon if there is nothing to discount.