Post by Biggen » Sat Sep 19, 2009 6:06 am

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

Post by Qphoria » Sun Sep 20, 2009 8:56 am

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

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Mon Sep 21, 2009 12:11 am

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.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Fri Oct 09, 2009 5:03 am

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.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Thu Oct 22, 2009 9:40 pm

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

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by loadaverage » Mon Dec 14, 2009 9:51 pm

is this fix in 1.3.4?

we is experts(tm)


New member

Posts

Joined
Fri Nov 20, 2009 2:10 am

Post by Qphoria » Mon Dec 14, 2009 10:03 pm

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

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by loadaverage » Tue Dec 15, 2009 12:00 am

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

Post by tokoflanel » Mon Apr 05, 2010 10:59 pm

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

Post by Qphoria » Thu Apr 08, 2010 1:01 pm

its the same code in all versions to date

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Tue Apr 13, 2010 4:40 am

This was added to the core in 1.4.7

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by judasat » Fri Jul 25, 2014 9:50 pm

I have this problem, is valid for 1.5.6.4 ?

Newbie

Posts

Joined
Thu Dec 20, 2012 6:21 pm

Post by Qphoria » Thu Jul 31, 2014 4:34 am

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

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by kayoz » Mon Feb 02, 2015 11:46 pm

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