Page 1 of 1

[MOD][1.4.x] Option Quantity Discount Support

Posted: Sat Sep 19, 2009 10:51 am
by Qphoria
What does it do:
================
This mod makes qty discounts apply to product options as well. It applies qty discounts to options by taking whatever the percentage the discount is to the price, and apply that same percentage to the options.

Example.
Product base price is 100
Option: Color: Red is 5.00
Option: Size: Lrg is 10.00

Discount @ 1 is 95.00 = 95.00
Percentage difference is 95/100 (.95) or 95% of the normal price
95% of 5.00 makes Option: Color: Red = 4.75
95% of 10.00 makes Option: Size: Lrg = 9.50
Before mod Total: 95 + 5.00 + 10.00 = 110.00
After mod Total: 95+ 4.75 + 9.50 = 109.25

Discount @ 2 is 75.00 x 2 = 140
Percentage difference is 75/100 (.75) or 75% of the normal price
75% of 5.00 makes Option: Color: Red = 3.75 x 2 = 7.50
75% of 10.00 makes Option: Size: Lrg = 7.50 x 2 = 15.00
Before mod Total: 140 + 10.00 + 20.00 = 170.00
After mod Total: 140 + 7.50 + 15.00 = 162.50
Should be the same for all versions to date

1. EDIT: system/library/cart.php (or system/helper/cart.php for older versions)

2. FIND:

Code: Select all

$price = $product_discount_query->row['price']; 
3. AFTER, ADD:

Code: Select all

//Q: Apply discount percentage to Option
                    foreach ($option_data as $key => $value) {
                        $option_data[$key]['price'] = $option_data[$key]['price'] * ($product_discount_query->row['price'] / $product_query->row['price']);
                    }
                    $option_price = $option_price * ($product_discount_query->row['price'] / $product_query->row['price']);
                    //    
4. EDIT: catalog/controller/product/product.php

5. FIND:

Code: Select all

foreach ($option['option_value'] as $option_value) { 
6. AFTER, ADD:

Code: Select all

//Q: Option Discounts
                    if ($option_value['price']) {
                        if (isset($option_discount) && $option_discount) {
                            $option_value_price = (float)$option_value['price'] * $option_discount;
                        } else {
                            $option_value_price = (float)$option_value['price'];
                        }
                    }//    

Re: [MOD] Option Quantity Discount Support

Posted: Tue Nov 22, 2011 2:23 am
by timfenn
This mod seems to be broken, if i add the update, i cant add multiple items with different options to the cart. they are in the database but not displaying.

Re: [MOD] Option Quantity Discount Support

Posted: Sat Feb 04, 2012 11:02 am
by jty
look at the date. it was in 2009 so it was for a very old version hence won't work in 1.5.x

Re: [MOD][1.4.x] Option Quantity Discount Support

Posted: Wed Dec 25, 2019 12:58 pm
by webnhostbiz
Hi,

You have this coding for opencart version 2.1.0.1.

Thanks

Re: [MOD][1.4.x] Option Quantity Discount Support

Posted: Wed Dec 25, 2019 8:12 pm
by xxvirusxx
Try this.
Should work on 2.1.x, 2.2.x, 2.3.x, 3.0.x