Post by Qphoria » Sat Sep 19, 2009 10:51 am

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'];
                        }
                    }//    

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by timfenn » Tue Nov 22, 2011 2:23 am

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.

Newbie

Posts

Joined
Tue Nov 22, 2011 2:21 am

Post by jty » Sat Feb 04, 2012 11:02 am

look at the date. it was in 2009 so it was for a very old version hence won't work in 1.5.x

jty
Active Member

Posts

Joined
Sat Aug 30, 2008 8:19 am

Post by webnhostbiz » Wed Dec 25, 2019 12:58 pm

Hi,

You have this coding for opencart version 2.1.0.1.

Thanks

Newbie

Posts

Joined
Fri Feb 15, 2019 3:43 pm

Post by xxvirusxx » Wed Dec 25, 2019 8:12 pm

Try this.
Should work on 2.1.x, 2.2.x, 2.3.x, 3.0.x

Attachments


Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România
Who is online

Users browsing this forum: No registered users and 44 guests