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

Please LogIn to Reply!

Post By: guest | 01-19-2013 07:57 Reply

Question

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

Answers

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.

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

Reply Or Comment!
Please LogIn to Reply!