Search code examples
phpcurljoomlavirtuemart

Virtuemart apply coupon from query string


I want to apply coupon in virtuemart. Is it possible directly with a query string?

I managed to add a product using the following statement in PHP:

 header('Location: http://www.url.es/index.php?option=com_virtuemart&view=cart&task=add&virtuemart_product_id[]=25&virtuemart_category_id[]=70&quantity[]=1');

Solution

  • You could use this url:

    index.php?option=com_virtuemart&controller=cart&task=setcoupon&view=cart&coupon_code=COUPON_CODE
    

    I have tested that with virtuemart 3.0.18 and it works just fine.

    You could see how this url is being created by checking the input fields that the form is posting in:

    components/com_virtuemart/views/cart/tmpl/default_coupon.php
    

    Hope this helps