### Quantity Discount w/ Option Scenario

I have been playing around with quantity discounts and have come across something that may or may not be a bug.

Lets assume I have ONE item that I am wanting to sell and its base price is \$10.00. Lets also assume that I have an "option" added to it, that if chosen by the customer, adds another \$5 on the item.

Now, lets also assume I have a quantity discout plugged into OC in that if a person buys 2 OR MORE, the the items will be reduced thereafter. So now, lets add the item to the cart and NOT buy the option I have set for it. Ok, no problem here. I can keep adding and adding to the cart and OC recognizes that I have 2 or more in the cart (no matter how many over 2 I have in the cart) and applies the discount properly.

Here is where the curve ball comes in. Lets say, that the customer has 5 items in the cart and he DID NOT choose the +\$5 option on any of them. Now, he wants to add a 6th item, but on this item, he decides to purchase the option. Well OC doesn't seem to apply the quantity discount here. The price on the item WITH the option just went back to the original price which is \$10 instead of applying the discount -\$2 discount.

I understand what is happening. OC is treating the item with the option as a totally NEW item item and it won't apply the discount until (in this scenario) 2 of the "option" items have been purchased.

Is there any way around this? What about OC simply looking to see if "X" number of items are in the shopping cart regardless of whether the option was chosen or not??

Newbie

Posts

Joined
Wed Sep 02, 2009 6:31 am

### Re: Quantity Discount w/ Option Scenario

eh? By default options aren't discounted. A fresh install works the way you are describing.

Product 1 - 10.00
Option1 - 5.00
Option2 - 6.00

10% discount = 9.90 + 5 + 6

Posts

Joined
Tue Jul 22, 2008 3:02 am

### Re: Quantity Discount w/ Option Scenario

Ohhhh I see what you mean.
Opencart treats products plus options as separate items from eachother

Product 1 w/ color red
is different from Product 1 w/ color blue
and different from Product 1 w/ no options

I'd have to look into how to commonize by base product.

Posts

Joined
Tue Jul 22, 2008 3:02 am

### Re: Quantity Discount w/ Option Scenario

I've got this working now.

Basically during the cart item check, I check if there are any other items with the same base product, if there are, then add their qty to the current product qty for the sake of the discount db query.

Product 1 = \$100
Set a discount on Product 1 that if you buy 10, the price is \$75.00 each

Normally this combination would give:
5 x Product 1 with option A = \$100 x 5 = \$500
and
5 x Product 1 with option B = \$150 x 5 = \$750

But now I add the 5 + 5 together during the discount check so it is valid for the discount. So I get:
5 x Product 1 with option A = \$75 x 5 = \$375
and
5 x Product 1 with option B = \$125 x 5 = \$625

Try it out and see if I got it right: (v1.3.2 or later)
1. EDIT: system/helper/cart.php or system/library/cart.php (later than 1.3.2)
2. FIND:

Code: Select all

\$product_discount_query = \$this->db->query("SELECT price FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)\$product_id . "' AND customer_group_id = '" . (int)\$customer_group_id . "' AND quantity <= '" . (int)\$quantity . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY quantity DESC, priority ASC, price ASC LIMIT 1");
3. REPLACE WITH: (or comment it out and put this below)

Code: Select all

//Q: Common Base Discounts
\$discount_quantity = 0;
foreach (\$this->session->data['cart'] as \$k => \$v) {
\$array2 = explode(':', \$k);
if (\$array2[0] == \$product_id) {
\$discount_quantity += \$v;
}
}

\$product_discount_query = \$this->db->query("SELECT price FROM " . DB_PREFIX . "product_discount WHERE product_id = '" . (int)\$product_id . "' AND customer_group_id = '" . (int)\$customer_group_id . "' AND quantity <= '" . (int)\$discount_quantity . "' AND ((date_start = '0000-00-00' OR date_start < NOW()) AND (date_end = '0000-00-00' OR date_end > NOW())) ORDER BY quantity DESC, priority ASC, price ASC LIMIT 1");
//
Then try adding a product that has 2 options with a discount at some qty and see if a split of both achieves the discount. Should be able to split it into any number of products. As long as the common product adds up it should work.

Posts

Joined
Tue Jul 22, 2008 3:02 am

### Re: Quantity Discount w/ Option Scenario

Ok... I've updated the code and cleaned up the topic. I've moved the other Options Quantity Discount contrib to its own post

Posts

Joined
Tue Jul 22, 2008 3:02 am

### Re: Quantity Discount w/ Option Scenario

is this fix in 1.3.4?

we is experts(tm)

New member

Posts

Joined
Fri Nov 20, 2009 2:10 am

### Re: Quantity Discount w/ Option Scenario

It's not a fix.. its a customization that somebody wanted. v1.3.4 does not have this customization.

Posts

Joined
Tue Jul 22, 2008 3:02 am

### Re: Quantity Discount w/ Option Scenario

i am not entirely sure this is a customisation, but of course
everything is in the eye of the beholder.

i find this "fixed" behaviour logical, the one that the customer
probably expects as well (i as a customer do). if items with
options are to be considered separate items, that is a customisation
from my point of view.

either way, i think it would be great to have this as a setting
in the configuration.

we is experts(tm)

New member

Posts

Joined
Fri Nov 20, 2009 2:10 am

### Re: Quantity Discount w/ Option Scenario

this module is very great, unfortunately it is only for ver 1.3.2
Anybody has this module for 1.4.x ?
thx

Newbie

Posts

Joined
Mon Apr 05, 2010 10:57 pm

### Re: Quantity Discount w/ Option Scenario

its the same code in all versions to date

Posts

Joined
Tue Jul 22, 2008 3:02 am

### Re: Quantity Discount w/ Option Scenario

This was added to the core in 1.4.7

Posts

Joined
Tue Jul 22, 2008 3:02 am

### Re: Quantity Discount w/ Option Scenario

I have this problem, is valid for 1.5.6.4 ?

Newbie

Posts

Joined
Thu Dec 20, 2012 6:21 pm

### Re: Quantity Discount w/ Option Scenario

You do not need this mod in 1.5.6.4 as it is already part of the core.

To test...

Create a product with 3 option values (like Color: Red, Blue, Green)
Set the product price to \$100
Set the qty discount for 3 item to \$90

Add the item to the cart 3 times, each with a separate option value
1x Product (Red)
1x Product (Blue)
1x Product (Green)

The Price in the cart should be \$90 x 3 = \$270
as opposed to \$100 x 3 = \$300

Posts

Joined
Tue Jul 22, 2008 3:02 am

### Re: Quantity Discount w/ Option Scenario

I am having a similar problem.
I have to add wholesale discounts to products with 3 different pricing levels and several different options

something like this

Option
Twin duvet 1- \$50.00 3+= 45.00 6 += \$40.00
Queen Duvet 1- 90.00 3+= 80.00 6+= \$70.00
King 1- 120.00 3+= 110.00. 6+= \$100.00

In some cases there are even more options...the skus are the same but I am finding that
when I set option 1 and qt 1 then set 3 different prices they don't display
only the first price displays

How can i do this with opencart? Will I need a specific module to do this?

Newbie

Posts

Joined
Tue Jan 27, 2015 6:58 am
Who is online

Users browsing this forum: No registered users and 41 guests