module and plugin to add google adsense to joomla based websites

The Binary World

How to Install Discount Module For Virtuemart
User Rating: / 24

Latest version 1.1

Virtuemart version 1.1.3

Follow the same instructions below for upgrade, skip the Step 4 (Running SQL queries Modifying Database) only if you are upgrading.

Note: If you are facing problems in implementation of this module, I will do it for you, Please Contact me here

Step 1 (Download)

First you will need to download the files here

Step 2 (Replacing Old Files)

Now Please take the backup of all files and database ... If you cannot take backup of whole site take the back of at least vituemart component foldes which are


Step 3 (Hacking files)

Note: If your virtuemart code is already modified by installation of some other module , Please don't replace the files by unzipping, But add the code in each file by editing the files mentioned below, You can trace code by searching for //binary added comment 

After Downloading, unzip the files in your joomla root directory ...(By removing the from unzip path)

If you do it the correct way, The files listed below will replace the old files of virtuemart, Please take backup before unzipping.

If you dont have unzip feature and you have just FTP just unzip somewhere ( desktop) and upload the directories through FTP... Like upload the directory /administrator, it will prompt that administrator directory already exists do you want to replace it? , Just click yes , Your whole administrator directory will not be replaced, only the files listed below will be replaced, But a backup is must.Do the same with components directory.

Note: To unzip properly you must make sure that it do not create a separate folder in your root directory.

Note: The Changes and modifications can be traced by looking for the comment code: //binary added 

List of files which will be modified

  • administrator/components/com_virtuemart/languages/common/english.php
  • administrator/components/com_virtuemart/header.php
  • administrator/components/com_virtuemart/html/admin.show_cfg.php
  • administrator/components/com_virtuemart/html/basket.php
  • administrator/components/com_virtuemart/html/order.order_print.php
  • administrator/components/com_virtuemart/html/ro_basket.php
  • administrator/components/com_virtuemart/classes/ps_checkout.php
  • administrator/components/com_virtuemart/classes/ps_cart.php
  • administrator/components/com_virtuemart/classes/ps_config.php


  • components/com_virtuemart/themes/default/templates/basket/basket_b2b.html.php
  • components/com_virtuemart/themes/default/templates/basket/basket_b2c.html.php
  • components/com_virtuemart/themes/default/templates/basket/ro_basket_b2b.html.php
  • components/com_virtuemart/themes/default/templates/basket/ro_basket_b2c.html.php
  • components/com_virtuemart/themes/default/templates/checkout/get_final_confirmation.tpl.php
  • components/com_virtuemart/themes/default/templates/order_emails/confirmation_email.tpl.php
  • components/com_virtuemart/themes/default/templates/pages/account.order_details.tpl.php
  • components/com_virtuemart/js/extlayout.js.php

New Files which belong only to this module

  • administrator/components/com_virtuemart/html/discount.discount_form.php
  • administrator/components/com_virtuemart/html/discount.discount_list.php
  • administrator/components/com_virtuemart/classes/ps_discount.php
  • administrator/components/com_virtuemart/languages/discount/english.php

Note: If you are not using virtuemart default template you have to copy and paste front end files manually or make a new archive to extract and replace other template files, Backup is must


Step 4 (Running SQL queries Modifying Database)

You can skip this step if you are performing an upgrade

Now either import the provided sql "database.sql" file in phpmyadmin or open the file, copy the sql queries and run it from phpmyadmin (Backup is must)

If you dont have phpmyadmin, Download and install a component for joomla to run sql queries
you can find such component here

Note: Please Change Database prefix from jos_ to your own database prefix.

Step 5 (Creating Functions)

Discount menu


 Now you will be able to see The new pane with title Discount

 Note: I am using Simple Layout


Now before we start using it we will need to register some functions 


To create function please do as follows

List Modules



Now click on the "Function list" of the Discount Module in the list.


and create a new fuctions




You should create 3 functions details are

Function Name: addDiscount
Class Name: ps_discount
Class Method: add_discount
Function Perms: storeadmin, admin

Function Name: deleteDiscount
Class Name: ps_discount
Class Method: remove_discount
Function Perms: storeadmin, admin

Function Name: updateDiscount
Class Name: ps_discount
Class Method: update_discount
Function Perms: storeadmin, admin

Note: You should create the above functions exactly as mentioned.

We are almost done, now you can add, delete, update discounts which will apply Globally to all products

Step 7 (Modify Paypal payment method)

Now we have to modify the paypal payment extra info because if we do not it will not subtract from total shown on paypal

Go to Virtuemart administration then Store -> List Payment Methods -> Paypal

Click Configuration Tab


$discount_total = $db->f("coupon_discount") + $db->f("order_discount");


$discount_total = $db->f("coupon_discount") + $db->f("order_discount") + $db->f("quantity_discount");


See the screen shot below and add the highlighted code the same way it looksPayment Extra Info
Click to enlarge

Step 8 (Global Configuration)

Open virtuemart global configuration and Save or Apply it once to generate a new control for quantity discount shown below

Global Config

After saving the configuration file once without any changes you should be able to see the above highlighted control to enable and disable quantity discounts.

Step 9 (Enjoy)

Go to site frond end and add something to your shopping cart

You will see a new Label below subtotal with quantity Discount as shown below


Virtuemart Quantity Discount

 p.s. If you add any improvements to this module please send it to me i will upgrade it here and i will submit it to virtuemart as well Plus if you want to request any feature you can do so in the comments,

The up coming features are

  1. Discount based on quantity of products from specific categories
  2. A tool-tip to show all discount rules in the front-end


Add this page to your favorite Social Bookmarking websites
Reddit!! Mixx! Free and Open Source Software News Google! Live! Facebook! StumbleUpon! Yahoo! Joomla Free PHP
Comments (56)Add Comment
Very Nice
written by Dranzer, May 07, 2009
Hi very nice tutorial thanks
works great
written by movies-u, May 15, 2009
hey everything works fantastic..the only problem I have is that i cant work it with Colombian Pesos (COP)
re: works great
written by a guest, May 15, 2009
hey everything works fantastic..the only problem I have is that i cant work it with Colombian Pesos (COP)
it is not showing currency symbol or something else?
Tax not calculating
written by Iain, June 08, 2009
Hi there - great module. I notice though that the tax is calculating on the original pre discount amount - not the post discount amount. how can I fix that - or have I missed a file somewhere in installing this.


written by rob, June 15, 2009

Two questions,
Is it possible to give a group of products a quantity discount?

So for instance the second shirt half price?

Question 2
Is it possible to give the discount to the cheapest product in range?
Not Yet
written by binaryworld, June 17, 2009
No sorry its not possible in the current version , I have a couple of requests i have noted down , i will try to make it possible plus if some one can take the code and improve it and send it back i will contribute this to virtuemart development including the contributors name and website
Baby Beginner - need more step-by-step instruction
written by alesiam, June 17, 2009
So, I am not a programmer. I know only HTML and I used to know more CSS, but that's it! I'm learning to navigate this whole Joomla!/CMS thing and I don't know PHP or Sql or anything, so some things in this tutorial are not basic enough for me. For example, in step 3, how do I unzip the files in my Joomla root directory? Is this something other than just doing an install/uninstall in my extensions manager? Also, I have no idea how to do step 4. Finally, will step 5 be obvious as to how and where to create the functions, or will a baby beginner like me need to know more?

Help? Please?
Baby Beginner
written by binaryworld, June 25, 2009
Hi Baby Beginner, This is virtuemart hacking, You must have knowledge about applying hacks to virtuemart before doing this,

Before doing anything always take the backup, Or setup a test site to play around...
written by Clark, July 04, 2009
thanks so much! saved my bacon!
written by bob, July 05, 2009
Can anyone give a bit more decsription for #4? Import the sql file how?

As for the other guys question as to what the joomla root directory is... its the top level directory that has all your joomla folders it in... administrator, templates, components etc.

written by bobII, July 05, 2009
I installed the extension... but it appears to only let me add discounts for quantity purchases...

buy 5 get $20 off... or 20% off

I have multiple items that have multiple prices... so when the combined price reaches say $25.25 a 5% discount is applied...

is that possible to do with this extension?

written by binaryworld, July 06, 2009
Hi, you can import sql file or run sql queries in phpmyadmin, If you cannot use phpmyadmin, please install a component in joomla which enables you to run sql queries

you can find some good components here for database management

Please make sure to take a backup before running the queries from database.sql
@ bobII
written by binaryworld, July 06, 2009
No, Actually this is a discount based on products quantity only

But you can apply such discounts on payment methods
written by bobII, July 06, 2009
any chance you can expand or point me in the right direction in "applying such discounts on payment methods"?
@ bobII
written by binaryworld, July 06, 2009
go to vm admin then store->List Payment Methods and click on one of the payment method you like, check some discount options on the first tab
cart totals for paypal payments
written by Clark, July 09, 2009
this works very well, put i have just discovered when paying with paypal the discount does not transfer to the paypal website. anyone know how to fix this? Thanks
written by Clark, July 09, 2009
been doing some research on the virtuemart forum and I',m guessing its something to do with the payment extra info script at List Payment Methods >> PayPal >> Configuration tab. I don't know php so cant see what to or wrong.
New Version With bug fixes
written by binaryworld, July 09, 2009
I have completed the new version , You can download and upgrade following the same instructions above ... The paypal issue is also removed ...
db issue
written by Clark, July 09, 2009
thanks for taking the time to look at this. I am having a problem with the databas import. When I try to import database.sql using phpMyAdmin i get this error:


SQL query:

ALTER TABLE `jos_vm_orders` ADD `quantity_discount` DECIMAL( 12, 2 ) NOT NULL AFTER `order_shipping_tax` ;

MySQL said: Documentation
#1060 - Duplicate column name 'quantity_discount'
Skip step 4
written by binaryworld, July 09, 2009
Please skip step 4, if you are upgrading .. Thanks
written by richie, July 16, 2009
Hi... guess am still stuck at step 4...

according to this : you can find some good components here for database management

I have install the easySQL component and couldn't find any english guide/tutorial on how to use it. So I have 2 questions here "(

1) How do I use the database.sql or where should I copy it to? any directory?

2) As of this statement : "Please Change Database prefix from jos_ to your own database prefix." Any example of own database prefix? thanks.

Pardon for the newbie/noob questions. I do need this option in my website but have no knowledge of PHP/SQL... greatly appreciate your kind effort to explain step 4 more precisely.


Step 4 to Step 5
written by richie, July 16, 2009
I wonder "The new pane with title Discount" could appear if I skip step 4... is it a compulsory for step4 even am not performing any upgrade?

written by binaryworld, July 17, 2009
You have to run sql queries from database.sql, Please take a backup of your database first ...

But i think you let an expert do this for you ... Thanks
Couple of questions
written by Andrew, August 03, 2009
Hi there. Just a couple of questions before I try and install.
First, will this run on an old VM 1.0.15 site?
And will existing discounts be affected?
I have a site I am doing for a winery and I have wine sold as single bottles and as cases of 12 bottles. For the cases I have a 10% discount applied. no problem there, but we also want to offer a 10% discount if they buy 12 single different types of wine bottles. So it will be a mixed case. Will that work? And if they buy a case, which will have 10% discount and then 12 singles which would then take 10% off, would that ignore the discount already applied to the case or take off another 10%?
Thanks for your help.
written by binaryworld, August 06, 2009
I have not tested it on vm 1.0.15 but if you can try it on a testing version of your site and if you face any problem i would love to solve them ...

This discount module does not affect any other discounts ...
written by Andrew, August 07, 2009
Thanks, was going to give it a try but saw that the folders are different, ie I don't have the themes folder, and I'm thinking I'll just bugger it up.
Thanks for your reply though.
SQL Queries Error
written by JT, September 08, 2009
I've run into a problem when trying to do step #4. My DB is MySQL4.0. i'm running Joomla 1.5.10 & VirtueMart 1.1.3 stable.

I ran the sql queries with the file provided (database.sql) and got an error:

SQL query:

CREATE TABLE IF NOT EXISTS `jos_vm_discount` (
`discount_id` int( 16 ) NOT NULL AUTO_INCREMENT ,
`products_quantity` int( 11 ) NOT NULL ,
`amount` float NOT NULL ,
`percent_or_total` varchar( 32 ) NOT NULL ,
PRIMARY KEY ( `discount_id` )

MySQL said: Documentation
#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT CHARSET=utf8 AUTO_INCREMENT=25' at line 7

Flexibility of module to calculate different discount amounts
written by Andrew Scott, October 02, 2009
Hi Bob(?),
thanks for a great module.
Supposing one customer wishes to order 50 items, another 27, a third 156.
Do I need to create separate discounts for any and all numbers up to however high I expect someone to order?
Is there a way to set up your module to group discounts as follows,
2- 4 copies – 15%
5 - 9 copies – 25%
10 + copies – 45%

Jesper Bo Larsen
Error message when no discount
written by Jesper Bo Larsen, January 18, 2010

Thanks for a great module.

I just installed and everything works perfect, I have only one problem.

When the user buy 1 or 2 product and get not discount, I get this message in the basket:

Warning: number_format() expects parameter 1 to be double, string given in C:UsersJBLXamppxampphtdocsCreeto3administratorcomponent
scom_virtuemartclassescurrencyclass_currency_display.php on line 107

If they buy 3 product and get a discount there is no problems.

Could you please help me solve this problem?

Best regards Jesper
written by binaryworld, January 20, 2010
Its is not an error, its just warnings are enabled in your server configuration , but i will check where this occurs, Plus you can disable warning messages to get rid of it , Most of the web servers have warnings disabled
Jesper Bo Larsen
Recalculate tax
written by Jesper Bo Larsen, January 20, 2010

Thank you for your answer.

In one of the first post someone asked how to update tax after discount. Did you solve this problem?

Best regards Jesper
written by Jacob F, January 28, 2010
HI, which versions of Joomla and Virtuemart, does this script run with.
Kevin Medri
written by Kevin Medri, June 24, 2010
Hi have you added the to dos yet, especially the category discount option
Thank you.
Total instead of Quantity?
written by CyberVisionMedia, June 28, 2010
is it possible for the module to work with the TOTAL instead of the QUANTITY of items purchased?
Verry nice working
written by dhriendra rathod, July 16, 2010
This is Good..
Thanks for this step..
Is it possible to give the discount to the cheapest product in range?
written by dhriendra rathod, July 16, 2010
Is it possible to give the discount to the cheapest product in range?
Quantity wise discount possible..?
written by dhriendra rathod, July 16, 2010
1- 5 product– 15%,6 - 10 product –30%,10 >product – 60%
written by binaryworld, July 16, 2010
It works by counting the quantity of the products in the shopping cart, If you have created a discount package from admin and suppose it is like 10 products to trigger the discount, now it is up to you to have a fixed price discount or a percentage of the total amount.
Use module only for default shopping group
written by Joepvth89, August 26, 2010

I have just installed the module, it works perfect!

Is it possible for only using this module ONLY for the default shopping group? so exclude all other shopping groups?

Thanks for your afford!
written by amolk, September 02, 2010

Quantity discounts

thank you
QTY based on single product or multiple
written by Wayne, September 27, 2010
Does the discount work on individual product qty's or just total qty of all products added to the cart?
Error in total after processing payment?
written by rvbgnu, November 24, 2010
Thank you for this module, it is very helpful.
I have just tested it with VirtueMart 1.1.5 and Joomla 1.5.22. All is fine until checkout and payment processing. But when I look into the order history (account.order_details), and even in the confirmation email, the discount is shown, but not apply. The full price in the database is wrong. I did not put my head in the price calculation source code.
Any thought?
written by rvbgnu, November 24, 2010
By the way, I could not see any relevant changes to components/com_virtuemart/themes/default/templates/checkout/get_final_confirmation.tpl.php, compare to VM 1.1.4 or 1.1.5. Maybe my mistake is here.
Any help with this matter would be great!
Have a nice day!
quantity discount line not showing up in cart
written by James, December 13, 2010
I am having two problems

1. the line in the checkout cart that says "Quantity Discount" is not displaying.
2. the discount is being applied after taxes when I need it to be before taxes (i checked the box for tax config that says apply discounts before tax and shipping but is not working)
Menu Bar Discount
written by Angelo, December 17, 2010
Hi, please I need your help!
I have installed the Discount Module on my Virtuemart (I have VM 1.1.4), but in the Administration bar the only thing I get is an empty cell without the title "Discount" and the submenu with "Discount list" and "New discount".
I think something in the installation is missing but I don't know what.
Could you please help me?
Same problem here
written by crazy, December 18, 2010
Error in total after processing payment?
written by rvbgnu, November 24, 2010

Thank you for this module, it is very helpful.
I have just tested it with VirtueMart 1.1.5 and Joomla 1.5.22. All is fine until checkout and payment processing. But when I look into the order history (account.order_details), and even in the confirmation email, the discount is shown, but not apply. The full price in the database is wrong. I did not put my head in the price calculation source code.
Any thought?
written by binaryworld, December 18, 2010
This code is for VM 1.1.3 I haven't upgraded it for the latest vm

nice work
written by bon, January 14, 2011
hi, this is a great hack..
but is there a way to let the discount available only for some of category
lets say im selling a apparel, i want to give a discount $1 for every 2 items and $3 for 5 for 1 parent category , but it wont count or ignoring to count if customer also buying another items from another parent category
for example discount apply to parent category of clothes, and the shoes are doesnt count on this discount

so when people buying 3 shoes and 2 clothes they only get a discount as $1
and when they are buying 5 or more shoes only, they wont get any discountsmilies/wink.gif
Quanity Discount required for particuler User Group
written by Signity, March 18, 2011
Nice Contribution smilies/smiley.gif
Is there any way to show quantity discount to particular user group in virtuemart ?
Actually i am having two type of user groups in my VM shop and want to apply this discount for wholesalers only.

Thanks in advance !!
written by hadigolii, April 06, 2011
The module seems to work, it's just the math that does not make sense in the cart page.
For example I get:

Subtotal: $5 490.00
Tax Total: $658.80
Quantity Discount:- $823.50

Total: $4 501.80

The Tax is 12% of the subtotal
the Discount is set to 15%
but the math in the cart does not make sense, any ideas as to why this might be the case?

written by receptiveMedia, April 29, 2011
I've spent two nights without sleeping to try and find a script like this and found this one to work really well. A big thankyou from me.
One recommendation, if possible, is to maybe introduce a way of expelling individual products from the totaled quantities.
written by Bob25, January 10, 2012
its great. virtual 2.0 is a lot different then version 1.1. I like it. To learn how to install it here:
Great Job
written by Michael K., January 14, 2012
The module is excellent. I can't thank you enough.
Could you inform us when the "Discount based on quantity of products from specific categories" feature will be ready?
That would be really perfect!
Thank again and keep the great work.
With regards
Virtuemart 2.06 ???
written by LMW1, May 26, 2012
Will this work with Virtuemart 2.06 by any chance?
problem with quantity discount and standard coupon discount module
written by seppl, June 13, 2012
hej folks, i followed the instruction and the module works. but...

there are two problems - J 1.5.26 / VM 1.1.9

a) the standard coupon code field wont be shown
b) the quantity discount will show up as coupon-code-discount in the check-out process.

does anybody has a solution for this? would be great!

yours sepp
written by ram, September 24, 2014
is their any easy way to display discount price..

Write comment

You are here  : Home Training & Tutoials Joomla How to Install Discount Module For Virtuemart