Virtuemart Remove Coupon from Cart

Once a coupon code is added to the cart in Virtuemart 2.x, there is no way of removing it. There are 2 immediate workarounds which can be used, depending on your situation:
1) If logged in, then log out, this will kill your session and remove the coupon code
2) if logged out, then log in and log out again, this will kill the session

However, we cannot expect the customer to understand or implement that. So to make Virtuemart more user friendly and allow for customers to delete a coupon entered at will, you can use one of the following solutions:


This solution is very easy and just requires you install AwoCoupon Free or AwoCoupon Pro. The remove button is built into the coupon extension.

Customize Display

The display of the coupon is also customizable through template overrides. Simply copy:


You can then make your modifications.


Step 1 - install Coupon Delete plugin

Download this plugin: VmCoupon - Coupon Delete
Install through Joomla installer
And make sure you publish it

Step 2 - find default_pricelist.php

You will need to find this file.  It is potentially in 2 locations:
1) Within Virtuemart component: www/components/com_virtuemart/views/cart/tmpl/default_pricelist.php
2) Within your template: www/templates/[YOUR_TEMPLATE_FOLDER]/html/com_virtuemart/cart/default_pricelist.php
If it exists in your template override, then skip to step 4, otherwise go to Step 3

Step 3 - create an override

The way Joomla works, your template is first checked to see if the file has been overriden, and if so, use that version.  If it is not found there, then it uses the version in the component.   So in order to make this feature update proof, we should first create the file in the override.   Copy the file:
to this location

Step 4 - modify default_pricelist.php

Now that the override file is in your template, we need to modify it.  So open

Within this file, locate the below code.  At the time of writing, using Virtuemart 2.6.6, it was around line 251

                <span style="color: #000000">
                    <span style="color: #007700">echo </span><span style="color: #0000BB">$this</span><span style="color: #007700">-></span><span style="color: #0000BB">cart</span><span style="color: #007700">-></span><span style="color: #0000BB">cartData</span><span style="color: #007700">[</span><span style="color: #DD0000">'couponCode'</span><span style="color: #007700">];
                    echo </span><span style="color: #0000BB">$this</span><span style="color: #007700">-></span><span style="color: #0000BB">cart</span><span style="color: #007700">-></span><span style="color: #0000BB">cartData</span><span style="color: #007700">[</span><span style="color: #DD0000">'couponDescr'</span><span style="color: #007700">] ? (</span><span style="color: #DD0000">' (' </span><span style="color: #007700">. </span><span style="color: #0000BB">$this</span><span style="color: #007700">-></span><span style="color: #0000BB">cart</span><span style="color: #007700">-></span><span style="color: #0000BB">cartData</span><span style="color: #007700">[</span><span style="color: #DD0000">'couponDescr'</span><span style="color: #007700">] . </span><span style="color: #DD0000">')'</span><span style="color: #007700">) : </span><span style="color: #DD0000">''</span><span style="color: #007700">;</span>

Right after that code block, add the following code

                <span style="color: #000000">
                    <span style="color: #007700">echo </span><span style="color: #DD0000">'<a rel="nofollow" href="'</span><span style="color: #007700">.</span><span style="color: #0000BB">JRoute</span><span style="color: #007700">::</span><span style="color: #0000BB">_</span><span style="color: #007700">(</span><span style="color: #DD0000">'index.php?option=com_virtuemart&view=cart&task=deletecoupons'</span><span style="color: #007700">).</span><span style="color: #DD0000">'" align="middle" title="Delete From Basket" class="vmicon vm2-remove_from_cart"> </a>'</span><span style="color: #007700">;</span>

Step 6 - test and verify it works

That is it. This will add the remove icon next to the coupon code.  And once a customer clicks on it, presto, the coupon is removed from the session. Here is an image of the finished product.

Comments (0)