Jump to content
jpweber

Quantity Price Breaks

Recommended Posts

Thanks for your responses - didn't realize anyone had responded. Suhy - I looked at your site and tried plugging in various quantities, but an additional "2 or 4" would add to the quantity I entered. (i.e., entered quantity of 22, checkout displayed 24). I tried clearing quantity and updating, but that didn't work. Do you have it working, or was it just a model? What osCommerce no. did you use and what feature?

Share this post


Link to post
Share on other sites
Is it possible to only use the block function?

Don't think I tried it but I can't think of why it shouldn't either.

Share this post


Link to post
Share on other sites

I have only one product, but it comes in different colors which I have set up through the product attributes in the admin controls. I have set a price discount if a person buys more than one of this product, but it only works if the person has selected the same color. I need it to work regardless of color choice. Does anyone have an idea of what I need to do to make this work?


No Links To My Website Here!

Share this post


Link to post
Share on other sites
I have only one product, but it comes in different colors which I have set up through the product attributes in the admin controls. I have set a price discount if a person buys more than one of this product, but it only works if the person has selected the same color. I need it to work regardless of color choice. Does anyone have an idea of what I need to do to make this work?

Make a discount category and add the product to that discount category. That is the fastest way.

Share this post


Link to post
Share on other sites
Make a discount category and add the product to that discount category. That is the fastest way.

 

I have added the product to the discount category, and selected this discount category in the product setup, but the discount is not coming through. Please take a look at "dice" on www.michellibackgammon.com


No Links To My Website Here!

Share this post


Link to post
Share on other sites
I have added the product to the discount category, and selected this discount category in the product setup, but the discount is not coming through. Please take a look at "dice"

Obviously something goes wrong. Start with looking at $pfs where the discount categories id is stored by adding something like this in the footer (or wherever).

echo '<pre>';
print_r($pfs);

Share this post


Link to post
Share on other sites
Obviously something goes wrong. Start with looking at $pfs where the discount categories id is stored by adding something like this in the footer (or wherever).

echo '<pre>';
print_r($pfs);

 

PriceFormatterStore Object
(
[priceFormatterData] => Array
	(
		[5] => Array
			(
				[products_name] => Dice
				[products_model] => 
				[products_image] => dice.jpg
				[products_id] => 5
				[manufacturers_id] => 0
				[products_price] => 12.5000
				[products_weight] => 0.25
				[products_quantity] => 99999
				[products_qty_blocks] => 1
				[products_tax_class_id] => 0
				[specials_new_products_price] => 
				[discount_categories_id] => 1
				[price_breaks] => Array
					(
						[0] => Array
							(
								[products_price] => 10.0000
								[products_qty] => 2
							)

					)

			)

	)

)


No Links To My Website Here!

Share this post


Link to post
Share on other sites
PriceFormatterStore Object
(
[priceFormatterData] => Array
	(
		[5] => Array
			(
				[discount_categories_id] => 1
				[price_breaks] => Array
					(
						[0] => Array
							(
								[products_price] => 10.0000
								[products_qty] => 2

So far so good.

The actual calculation is done in includes/classes/shopping_cart.php, function calculate():

	function calculate() {
  global $currencies, $languages_id, $pfs; // for qpbpp added: $languages_id, $pfs

  $this->total = 0;
  $this->weight = 0;
  if (!is_array($this->contents)) return 0;
// BOF qpbpp
	$discount_category_quantity = array(); // calculates no of items per discount category in shopping basket
  foreach ($this->contents as $products_id => $contents_array) {
	  if(tep_not_null($contents_array['discount_categories_id'])) {
		if (!isset($discount_category_quantity[$contents_array['discount_categories_id']])) {
			$discount_category_quantity[$contents_array['discount_categories_id']] = $contents_array['qty'];
		} else {
			$discount_category_quantity[$contents_array['discount_categories_id']] += $contents_array['qty'];
		}
	  }
  } // end foreach

  $pf = new PriceFormatter;
// EOF qpbpp
etcetera

If you do the same trick echo'ing $discount_category_quantity right before $pf = new PriceFormatter; you should see if the other dice within the same discount category are included.

Share this post


Link to post
Share on other sites
So far so good....

 

If you do the same trick echo'ing $discount_category_quantity right before $pf = new PriceFormatter; you should see if the other dice within the same discount category are included.

 

This discount_category_quantity array is empty. One thing I noticed too, is that if I print_r($this->contents) before the foreach loop, discount_categories_id is also empty for each item in the shopping cart.


No Links To My Website Here!

Share this post


Link to post
Share on other sites

It turns out that the manual installation instructions that came in the zip for this contribution were wrong, and it was this that was creating the error.

 

Check out the instructions for manually editing \catalog\includes\classes\shopping_cart.php

 

Find (around line 110 [around line 119 in edited file]):

if ($this->in_cart($products_id_string)) { $this->update_quantity($products_id_string, $qty, $attributes); } else { $this->contents[$products_id_string] = array('qty' => (int)$qty);

Replace with:

// BOF qpbpp if ($this->in_cart($products_id_string)) { $this->update_quantity($products_id_string, $qty, $attributes, $product_info['discount_categories_id']); } else { $this->contents[$products_id_string] = array('qty' => (int)$qty, 'discount_categories_id' => $product_info['discount_categories_id']); // EOF qpbpp

 

I decided to take a look at the \catalog\includes\classes\shopping_cart.php that came with the zip, and noticed that this file was different in respect to this code replacement. This is the way it should be:

 

// BOF qpbpp
	  if ($this->in_cart($products_id_string)) {
		$this->update_quantity($products_id_string, $qty, $attributes, $discount_category);
	  } else {
		$this->contents[$products_id_string] = array('qty' => (int)$qty, 'discount_categories_id' => $discount_category);
// EOF qpbpp

 

Once I made this switch, everything works perfectly.


No Links To My Website Here!

Share this post


Link to post
Share on other sites
It turns out that the manual installation instructions that came in the zip for this contribution were wrong, and it was this that was creating the error.

You are obviously working on Windows because of the way you write the separators between directories with backslashes instead of slashes.

The code is exactly the same but the browser or program you use to copy and paste instructions from ignores the Unix line feeds. As you might know Windows uses a kind of double line feed as a line ending (\r\n) where Unix (and Mac OSX, Linux) uses \n.

 

Occasionally that is a problem. Notepad is or was a good example. It would show black squares for \n instead of ending the line.

 

With text files and using a PHP editor there is no problem (unless you use Notepad of course) because they all recognize a line feed if it is not a Windows one. But HTML instructions are clearer in the separation of instructions and code (plus you can add links inside the document). I noticed recently someone adding the instructions in a text file (add this to...) to his PHP files too and was constantly having errors...

 

A basic knowledge of PHP is very, very helpful if you are adding contributions.

Share this post


Link to post
Share on other sites
You are obviously working on Windows because of the way you write the separators between directories with backslashes instead of slashes.

The code is exactly the same but the browser or program you use to copy and paste instructions from ignores the Unix line feeds. As you might know Windows uses a kind of double line feed as a line ending (\r\n) where Unix (and Mac OSX, Linux) uses \n.

 

Occasionally that is a problem. Notepad is or was a good example. It would show black squares for \n instead of ending the line.

 

With text files and using a PHP editor there is no problem (unless you use Notepad of course) because they all recognize a line feed if it is not a Windows one. But HTML instructions are clearer in the separation of instructions and code (plus you can add links inside the document). I noticed recently someone adding the instructions in a text file (add this to...) to his PHP files too and was constantly having errors...

 

A basic knowledge of PHP is very, very helpful if you are adding contributions.

 

I do work on Windows, but the server is Linux. I'm not sure if that matters. All I did was copy and paste your code from the manual install instructions to the existing file. I use Notepad++ for text editing, and the format for this file's line endings is already Unix. It's odd that I could copy and paste all of the code from the manual install instructions, and this is the only part that wouldn't work (considering that the code IS different, and did work after I changed it). If I have this problem, I'm sure other people will too.

 

Thanks for your help.


No Links To My Website Here!

Share this post


Link to post
Share on other sites
If I have this problem, I'm sure other people will too.

Yes, I have seen it with people using the install instructions for SPPC too but only on one or a few places. I couldn't see anything strange with those parts. Totally stumped about why that happens (sometimes).

Share this post


Link to post
Share on other sites

Hi, Jan:

Would you please help to confirm whether this module will support Speical Price product?

Now I find it seems not work on my site.

 

Best Regards,

Share this post


Link to post
Share on other sites
Hi, Jan:

Would you please help to confirm whether this module will support Speical Price product?

Now I find it seems not work on my site.

 

Best Regards,

From PriceFormatter.php have Special Price product process, but my site's specail can't work , I don't setup this special product QPBPP price.

Any advice?

 

Best Regards,

Share this post


Link to post
Share on other sites
From PriceFormatter.php have Special Price product process, but my site's specail can't work , I don't setup this special product QPBPP price.

Any advice?

 

Best Regards,

 

Hi Jan:

Please ignore it. I find new version have fixed this issue.

 

Best Regards,

Edited by sunrise99

Share this post


Link to post
Share on other sites

Hi all!

 

I setup this code but need it to work for a swimsuit site - I need this code to work for the same bathing suit style, same bathing suit color but different sizes.

 

I read a previous post where a person had a similar request but the response to that was "create a discount category" I didn't understand that.

 

Also, would anyone know how to setup the code so the discount amount is displayed during the checkout & the invoice that is e-mailed to the customer?

 

Can someone help me?

 

Regards,

 

Jane

Share this post


Link to post
Share on other sites
I read a previous post where a person had a similar request but the response to that was "create a discount category" I didn't understand that.

admin/discount_categories.php

 

For this it would actually make more sense to use what was in a previous version of this modification. For a product a discount category of p concatenated with the products_id was always used. For a "real" discount category dc concatenated with the discount category id. Then all products with attributes are automatically grouped for a discount. For that you would need to amend the code in PriceFormatter.php and PriceFormatterStore.php

Share this post


Link to post
Share on other sites
admin/discount_categories.php

 

For this it would actually make more sense to use what was in a previous version of this modification. For a product a discount category of p concatenated with the products_id was always used. For a "real" discount category dc concatenated with the discount category id. Then all products with attributes are automatically grouped for a discount. For that you would need to amend the code in PriceFormatter.php and PriceFormatterStore.php

 

 

Thank you very much for your response, greatly appreciated.

 

Would you suggest I install the latest files (Quantity Price Breaks Per Product v1.3.5)?

 

Regards,

 

Jane

Share this post


Link to post
Share on other sites
Would you suggest I install the latest files (Quantity Price Breaks Per Product v1.3.5)?

Yes. It has proven stable/bug free over the last months.

Share this post


Link to post
Share on other sites
Yes. It has proven stable/bug free over the last months.

 

Thanks for your response.

 

Unfortunately I am having too many problems installing this contribution.

 

I installed the latest one and soo many error messages were popping up; I then installed version 1_2_3 (it worked) and removed the product sizes and just added a text box in place of it for customers to enter in the size they would like.

 

I would have loved to use this contribution but sometimes you don't always get what you want.

 

Can you at least point me to the version that contains the files for the discount information to appear in the shopping cart and in the invoice that is e-mailed to the customer and I?

 

Thank you again!

 

Jane

Share this post


Link to post
Share on other sites
Can you at least point me to the version that contains the files for the discount information to appear in the shopping cart and in the invoice that is e-mailed to the customer and I?

There isn't such a version. It is something that you would need to custom code.

Share this post


Link to post
Share on other sites

Hello,

 

I just finished installing this contribution, and when I try to go into Catalog I get a parse error:

Parse error: syntax error, unexpected $end in... /store/admin/categories.php on line 1896

 

I'm confused because line 1896 is just <!-- body_text_eof //-->

 

I'm not sure what to do or how to try to fix this. Can someone help me please?

 

TIA

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×