Page 1 of 2
Special discounts not showing for wholesale customers
Posted: Fri Jan 21, 2011 4:53 am
by jcgadgets
Hi,
I've got two products that are currently discounted on my store, and have them in the featured box module on the right column of my pages.
Here is what I have set:
Regular price for particular item: $1099
Wholesale login "discount" price for 1 unit: $1079
Regular "special" price for 1 unit: $1029
Wholesale login "special" price for 1 unit: $1009
What I get:
Price displayed for guests / retail customers: $1099 (strikethrough) $1029
Only price ever displayed for wholesale logins: $1079
What I want:
Price displayed for guests / retail customers: $1099 (strikethrough) $1029
Price displayed for wholesale customers: $1079 (strikethrough) $1009
In short, by getting moved to the wholesale group right now, you pay more for this particular item.
Is this a known bug, or is there a known workaround? Any suggestions?
Thank you,
Jared
Re: Special discounts not showing for wholesale customers
Posted: Wed Jan 26, 2011 3:30 pm
by jcgadgets
Just wanted to bump this to see if anyone is experiencing this problem at all? I don't mean to seem impatient after only five days, but the OpenCart community is usually extremely responsive - so I figured it was a little passed due
I'm using OpenCart v 1.4.9.3 and using the free "Black Theme" or cc_carbon_tab theme.
Any help much appreciated!
Thank you,
Jared
Re: Special discounts not showing for wholesale customers
Posted: Wed Jan 26, 2011 11:08 pm
by Qphoria
discount price takes priority over special price in the code. I do wonder why this is tbh. Specials should be top priority over all qty discounts
To fix:
1. EDIT: catalog/controller/product/product.php
2. FIND:
Code: Select all
$discount = $this->model_catalog_product->getProductDiscount($this->request->get['product_id']);
if ($discount) {
$this->data['price'] = $this->currency->format($this->tax->calculate($discount, $product_info['tax_class_id'], $this->config->get('config_tax')));
$this->data['special'] = FALSE;
} else {
$this->data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
$special = $this->model_catalog_product->getProductSpecial($this->request->get['product_id']);
if ($special) {
$this->data['special'] = $this->currency->format($this->tax->calculate($special, $product_info['tax_class_id'], $this->config->get('config_tax')));
} else {
$this->data['special'] = FALSE;
}
}
3. REPLACE WITH:
Code: Select all
$discount = $this->model_catalog_product->getProductDiscount($this->request->get['product_id']);
if ($discount) {
$this->data['price'] = $this->currency->format($this->tax->calculate($discount, $product_info['tax_class_id'], $this->config->get('config_tax')));
$this->data['special'] = FALSE;
} else {
$this->data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
}
$special = $this->model_catalog_product->getProductSpecial($this->request->get['product_id']);
if ($special) {
$this->data['special'] = $this->currency->format($this->tax->calculate($special, $product_info['tax_class_id'], $this->config->get('config_tax')));
} else {
$this->data['special'] = FALSE;
}
Re: Special discounts not showing for wholesale customers
Posted: Wed Jan 26, 2011 11:57 pm
by Xsecrets
honestly special should take precedence, but only if it is less than the discount.
Re: Special discounts not showing for wholesale customers
Posted: Thu Jan 27, 2011 12:11 am
by Qphoria
Right..
if price is 10.00 for normies
first qty discount for 1 is 8.00 for wholesalies
Special is 5.00 for both
Before the fix:
if logged in as normie see
10.00 crossed out and 5.00 in red <-- correct
if logged in as wholesalie
show 8.00 with no special<--incorrect
After the fix:
if logged in as normie see
10.00 crossed out and 5.00 in red <-- correct
if logged in as wholesalie
show 8.00 crossed out and 5.00 in red <-- correct
I did not add additional checking for greater or less than.. its up to you to put items on sale for less than the price
Re: Special discounts not showing for wholesale customers
Posted: Thu Jan 27, 2011 6:43 am
by jcgadgets
Hey thanks a lot!
I really appreciate this!
Jared
Re: Special discounts not showing for wholesale customers
Posted: Thu Jan 27, 2011 8:48 am
by Qphoria
actually after rethinking this, perhaps I should check which is lower. If there is a qty discount for $5 each if you buy 10, the special will force $8 each instead of $5 each
Re: Special discounts not showing for wholesale customers
Posted: Thu Jan 27, 2011 9:03 am
by Xsecrets
Qphoria wrote:actually after rethinking this, perhaps I should check which is lower. If there is a qty discount for $5 each if you buy 10, the special will force $8 each instead of $5 each
wow took a while for that light bulb to come on

Re: Special discounts not showing for wholesale customers
Posted: Thu Jan 27, 2011 9:14 am
by Qphoria
Xsecrets wrote:Qphoria wrote:actually after rethinking this, perhaps I should check which is lower. If there is a qty discount for $5 each if you buy 10, the special will force $8 each instead of $5 each
wow took a while for that light bulb to come on

I'm just happy it comes on at all anymore

Re: Special discounts not showing for wholesale customers
Posted: Thu Jan 27, 2011 2:36 pm
by jcgadgets
Hey Q,
I've got this extra line in there:
Code: Select all
$this->data['productInfoData'] = $this->request->get['product_id'];
So the block appears like this:
Code: Select all
$discount = $this->model_catalog_product->getProductDiscount($this->request->get['product_id']);
$this->data['productInfoData'] = $this->request->get['product_id'];
if ($discount) {
$this->data['price'] = $this->currency->format($this->tax->calculate($discount, $product_info['tax_class_id'], $this->config->get('config_tax')));
$this->data['special'] = FALSE;
} else {
$this->data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
$special = $this->model_catalog_product->getProductSpecial($this->request->get['product_id']);
if ($special) {
$this->data['special'] = $this->currency->format($this->tax->calculate($special, $product_info['tax_class_id'], $this->config->get('config_tax')));
} else {
$this->data['special'] = FALSE;
}
}
Do you know what that means? Should I just leave it there and make the other edits?
Thank you,
Jared
Re: Special discounts not showing for wholesale customers
Posted: Thu Jan 27, 2011 9:31 pm
by Xsecrets
that line simply exposes the product_id to the template file with the variable $productInfoData it's been added by someone, so I imagine it should stay there. you can just make the other changes that line is irrelevant to them. or if you wanted to make things easier you could move that line above the discount line then you can just use copy paste.
Re: Special discounts not showing for wholesale customers
Posted: Thu Jan 27, 2011 11:00 pm
by Qphoria
its just bad code to be honest.. the variable doesn't even properly describe its contents
"data" assumes array or some additional data.. but it's just a product_id which is already available at the view level so i'd tell the modder to do a bit better. At any rate, it shouldn't be in that block of code anyway. It should be moved elsewhere outside of the pricing changes section
Re: Special discounts not showing for wholesale customers
Posted: Fri Jan 28, 2011 7:12 am
by jcgadgets
Hey thanks for the help guys. Any suggestions on what exactly it might be better changed to?
Thank you,
Jared
Re: Special discounts not showing for wholesale customers
Posted: Sat Jan 29, 2011 8:06 am
by jcgadgets
Hi,
After this had been posted, I just assumed it would work. However, I was just now testing to make sure...and it doesn't seem as if it is
For wholesale, I've got a product "dicounted" for 1 unit to be $929.00. It is on special for $909.00. When logged in to a wholesale account, the price is $929.00. If I go to the "Specials" page, there is nothing there.
Here is my code in the catalog/controller/product/product.php file (including a little before and a little after what we have been discussing, just for good measure):
Code: Select all
$this->data['popup'] = $this->model_tool_image->resize($image, $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
$this->data['thumb'] = $this->model_tool_image->resize($image, $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'));
$this->data['product_info'] = $product_info;
$this->data['productInfoData'] = $this->request->get['product_id'];
$discount = $this->model_catalog_product->getProductDiscount($this->request->get['product_id']);
if ($discount) {
$this->data['price'] = $this->currency->format($this->tax->calculate($discount, $product_info['tax_class_id'], $this->config->get('config_tax')));
$this->data['special'] = FALSE;
} else {
$this->data['price'] = $this->currency->format($this->tax->calculate($product_info['price'], $product_info['tax_class_id'], $this->config->get('config_tax')));
}
$special = $this->model_catalog_product->getProductSpecial($this->request->get['product_id']);
if ($special) {
$this->data['special'] = $this->currency->format($this->tax->calculate($special, $product_info['tax_class_id'], $this->config->get('config_tax')));
} else {
$this->data['special'] = FALSE;
}
$discounts = $this->model_catalog_product->getProductDiscounts($this->request->get['product_id']);
$this->data['discounts'] = array();
foreach ($discounts as $discount) {
$this->data['discounts'][] = array(
'quantity' => $discount['quantity'],
'price' => $this->currency->format($this->tax->calculate($discount['price'], $product_info['tax_class_id'], $this->config->get('config_tax')))
);
}
(updated 01/31/2011)
Any idears?
Thank you again,
Jared
Re: Special discounts not showing for wholesale customers
Posted: Tue Feb 01, 2011 10:03 am
by jcgadgets
Hello again,
I just wanted to give this a gentle bump, since it seems we just about have it figured out as it seems to be working great for everyone else. I just can't seem to get it to work. In my previous post, I have pasted the relevant code as well as a few lines above and a few lines below in case that helps anything.
If anyone can spot what is going on and point it out, that'd be great! I've compared my code with the given code time and time again and I can't seem to find any discrepancies :S
Thank you,
Jared
Re: Special discounts not showing for wholesale customers
Posted: Thu Feb 17, 2011 3:21 am
by jcgadgets
Hi,
Wanted to bump this again. I feel like I'm so close! But it still does not work? Can someone please look this over to see what the situation is? I've tried, but I don't know that well how everything works.
Thank you again,
Jared
Re: Special discounts not showing for wholesale customers
Posted: Tue May 17, 2011 8:04 am
by alexmbra
Qphoria wrote:actually after rethinking this, perhaps I should check which is lower. If there is a qty discount for $5 each if you buy 10, the special will force $8 each instead of $5 each
Sorry to bring this back, but perhaps the special price should be set as percentage, not a value. And opencart should apply that special percentage to the final price, with or without discounts.
Something like this:
Code: Select all
$special = $this->model_catalog_product->getProductSpecial($result['product_id']);
$discount = $this->model_catalog_product->getProductDiscount($result['product_id']);
if ($special)
{
if ($discount)
{
$price = $this->currency->format($this->tax->calculate($discount - ($discount * $special) / 100, $result['tax_class_id'], $this->config->get('config_tax')));
}
else
{
$price = $this->currency->format($this->tax->calculate($result['price'] - ($result['price'] * $special) / 100, $result['tax_class_id'], $this->config->get('config_tax')));
}
}
else
{
if ($discount)
{
$price = $this->currency->format($this->tax->calculate($discount, $result['tax_class_id'], $this->config->get('config_tax')));
}
else
{
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
}
}
But of course we would need to change the "model_catalog_product->getProductSpecials" and "model_catalog_product->getTotalProductSpecials" functions and remove the select part that query for product that don't have discount only.
Also, we would need to change the product array to have this:
Code: Select all
'price' => $result['price'],
'special' => $price,
Re: Special discounts not showing for wholesale customers
Posted: Fri Jul 01, 2011 4:53 pm
by ulyssesnz
Hi Qphoria,
I have a customer that I have have implemented with your Options Plus module. It appears that the Specials no longer work after the installation of the module. Specials have been setup correctly and enabled,, etc. While the Specials box appears on the site, it does not display the product marked/priced for the special.
Any suggestions where I should be looking for the reason.
Thanks
UlyssesNZ
Re: Special discounts not showing for wholesale customers
Posted: Sat Jul 02, 2011 8:09 am
by Klimskady
ulyssesnz wrote:Hi Qphoria,
I have a customer that I have have implemented with your Options Plus module. It appears that the Specials no longer work after the installation of the module. Specials have been setup correctly and enabled,, etc. While the Specials box appears on the site, it does not display the product marked/priced for the special.
Any suggestions where I should be looking for the reason.
Thanks
UlyssesNZ
Qphoria is away on vacation at the moment, I am sure when he gets back and sees this he will respond when he can.
Re: Special discounts not showing for wholesale customers
Posted: Fri May 17, 2013 3:07 pm
by Jacqueline
how do i get discount to precede over special for default customers?
what are the codes to replace in opencart 1.5.4.1?
thanks