Post by jcgadgets » Fri Jan 21, 2011 4:53 am

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

Active Member

Posts

Joined
Sun Oct 31, 2010 4:49 pm

Post by jcgadgets » Wed Jan 26, 2011 3:30 pm

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

Active Member

Posts

Joined
Sun Oct 31, 2010 4:49 pm

Post by Qphoria » Wed Jan 26, 2011 11:08 pm

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;
} 

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Xsecrets » Wed Jan 26, 2011 11:57 pm

honestly special should take precedence, but only if it is less than the discount.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Qphoria » Thu Jan 27, 2011 12:11 am

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

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by jcgadgets » Thu Jan 27, 2011 6:43 am

Hey thanks a lot!

I really appreciate this!


Jared

Active Member

Posts

Joined
Sun Oct 31, 2010 4:49 pm

Post by Qphoria » Thu Jan 27, 2011 8:48 am

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

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Xsecrets » Thu Jan 27, 2011 9:03 am

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 :laugh: :joker:

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Qphoria » Thu Jan 27, 2011 9:14 am

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 :laugh: :joker:
I'm just happy it comes on at all anymore :P

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by jcgadgets » Thu Jan 27, 2011 2:36 pm

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

Active Member

Posts

Joined
Sun Oct 31, 2010 4:49 pm

Post by Xsecrets » Thu Jan 27, 2011 9:31 pm

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.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by Qphoria » Thu Jan 27, 2011 11:00 pm

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

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by jcgadgets » Fri Jan 28, 2011 7:12 am

Hey thanks for the help guys. Any suggestions on what exactly it might be better changed to?


Thank you,
Jared

Active Member

Posts

Joined
Sun Oct 31, 2010 4:49 pm

Post by jcgadgets » Sat Jan 29, 2011 8:06 am

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

Active Member

Posts

Joined
Sun Oct 31, 2010 4:49 pm

Post by jcgadgets » Tue Feb 01, 2011 10:03 am

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

Active Member

Posts

Joined
Sun Oct 31, 2010 4:49 pm

Post by jcgadgets » Thu Feb 17, 2011 3:21 am

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

Active Member

Posts

Joined
Sun Oct 31, 2010 4:49 pm

Post by alexmbra » Tue May 17, 2011 8:04 am

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,

Flash Ctt Tracking V2
Animated Flash Header Banner V3
Animated Flash Banner V2
Rastreamento de envios pelo CTT correios
Flash Expandable Category Side Menu module
Flash Category Side Menu Module
Flash Cart Steps Module
Animated Flash Banner Module
Animated Flash HEADER Banner Module


New member

Posts

Joined
Wed Dec 15, 2010 3:52 am

Post by ulyssesnz » Fri Jul 01, 2011 4:53 pm

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

Newbie

Posts

Joined
Sat Feb 13, 2010 11:50 am

Post by Klimskady » Sat Jul 02, 2011 8:09 am

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.

Active Member

Posts

Joined
Tue Jun 07, 2011 7:57 am

Post by Jacqueline » Fri May 17, 2013 3:07 pm

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

New member

Posts

Joined
Sun Jun 03, 2012 12:05 am
Who is online

Users browsing this forum: Bing [Bot] and 77 guests