Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Is It Possible To Combine Product Options Quantity For Qpbpp?


Recommended Posts

Posted

I have installed the Contribution Quantity Price Breaks Per Product v1.2 and it offers tiered column pricing for product quantities.

 

Example.. Product T-Shirt #5000 is $10 each for 12, $9 each for 24, $8 each for 48, $7 each for 72, $6 each for 144, etc...

 

What I would like to do is combine the total of the buyers' selected product options into a product Total Quantity.

 

Example.. A buyer orders an assortment of the T-Shirt #5000 in Red - Small: 12, Red - Medium: 12, Red - Large: 12, Blue - Small: 12, Blue - Medium: 12, Blue - Large: 12

 

Currently, the system sets the price at $10 each because the buyers has selected product options in packs of 12. But I would like to be able to combine the product options for a single product ID into something that works like this:

 

T-Shirt #5000

 

Red - Small: 12

Red - Medium: 12

Red - Large: 12

Blue - Small: 12

Blue - Medium: 12

Blue - Large: 12

 

TOTAL QNTY: 72

UNIT PRICE: $7.00

TOTAL PRICE: $504.00

 

 

Is there is a contribution that handles this?

 

If not, which files should I try to edit to accomplish this?

 

Thanks!

Posted

Thanks to JanZ for pointing out the solution!

 

There is a file in the download for QPBPP v1.2 called price_breaks_per_product_id that explains how to do this.

 

Here are the instructions for anyone else who wants to know:

 

These are the instructions for manually adding a modification to Quantity Price Breaks v 1.2 to aggregate the number of products with the same "base" products_id and ignore attributes.

Example, you have a price break for a product when 5 items are bought but it also has an attribute say color (red or blue). Without this modification when someone buys 3 products of the color red and 2 of the color blue he/she will not get the price break for 5 items (because red has e.g. a products_id of 225{3}3 and blue 225{3}4). 

With this mod, the number of products in the shopping cart with the same base products_id (225 in the above example) is determined first and those numbers are used to calculate the price break. So when 1 red product and 4 blue products are bought, prices of the red products and the blue product would be as if 5 items from each were bought.

The modified class files: shopping_cart.php and PriceFormatter.php for this mod can be found in the package, named shopping_cart_pb_base_id.php and PriceFormatter_pb_base_id.php. Upload and rename them to shopping_cart.php and PriceFormatter.php respectively.

Note: line numbers refer to the original line numbers in the files modified for Quantity Price Breaks Per Product 1.2.0  for which the August 17, 2006 update of osC 2.2 Milestone 2 was used..
------------------------------------------
catalog/includes/classes/shopping_cart.php

Line 4

**REPLACE** 
 adapted for QPBPP 2006/12/23

**WITH**
 adapted for QPBPP, per "base products_id" 2007/01/05

Line 50-51

**REPLACE**
  while ($products = tep_db_fetch_array($products_query)) {
	$this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']);

**WITH**

// BOF QPBPP, price break per per base products_id
  while ($products = tep_db_fetch_array($products_query)) {
	$this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity'], 'base_pid' => (int)$products['products_id']);
// EOF QPBPP, price break per base products_id

Line 85-87 (this is line 5-7 in the function add_cart)

**AFTER**
  $pf = new PriceFormatter;
  $pf->loadProduct($products_id, $languages_id);
  $qty = $pf->adjustQty($qty);

**ADD**
  $base_pid = $pf->get_base_pid();

Line 113-116

**REPLACE**

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

**WITH**

// BOF QPBPP, price break per base products_id
	  if ($this->in_cart($products_id_string)) {
		$this->update_quantity($products_id_string, $qty, $attributes, $base_pid); //added base products_id
	  } else {
		$this->contents[$products_id_string] = array('qty' => $qty, 'base_pid' => $base_pid); //added base products_id
// EOF QPBPP, price break per base products_id

Line 144

**REPLACE**
function update_quantity($products_id, $quantity = '', $attributes = '') {

**WITH**

	// update_quantity modified for QPBPP, price break per base products_id
function update_quantity($products_id, $quantity = '', $attributes = '', $base_pid = '') {

Line 163

**REPLACE**

	$this->contents[$products_id_string] = array('qty' => $quantity);

**WITH**

  $this->contents[$products_id_string] = array('qty' => $quantity, 'base_pid' => $base_pid); //added base products_id

Line 255

**AFTER** (this is line 4 in the function calculate)

  if (!is_array($this->contents)) return 0;

**ADD**

// BOF QPBPP, price break per base products_id
 $base_pid_quantity = array(); // calculates no of items per category in shopping basket
  foreach ($this->contents as $products_id => $contents_array) {
	  if (!isset($base_pid_quantity[$contents_array['base_pid']])) {
	 $base_pid_quantity[$contents_array['base_pid']] = $contents_array['qty'];
	  } else {
	 $base_pid_quantity[$contents_array['base_pid']] += $contents_array['qty'];
	  }
  } // end foreach
//   EOF QPBPP, price break per base products_id


Line 269-270

**AFTER**
  while (list($products_id, ) = each($this->contents)) {
	$qty = $this->contents[$products_id]['qty'];

**ADD**

			$number_of_items_in_cart_same_base_pid = $base_pid_quantity[$this->contents[$products_id]['base_pid']];
			$no_of_other_items_in_cart_with_same_base_pid = $number_of_items_in_cart_same_base_pid - $qty;

Line 279

**REPLACE**
	  $products_price = $pf->computePrice($qty);

**WITH**
	 $products_price = $pf->computePrice($qty, $no_of_other_items_in_cart_with_same_base_pid);


Line 330 (this is line 4 in function get_products)

**AFTER**

  if (!is_array($this->contents)) return false;

**ADD**

//   BOF QPBPP, price break per base products_id	
  $base_pid_quantity = array();
  foreach ($this->contents as $products_id => $contents_array) {
	  if (!isset($base_pid_quantity[$contents_array['base_pid']])) {
	 $base_pid_quantity[$contents_array['base_pid']] = $contents_array['qty'];
	  } else {
	 $base_pid_quantity[$contents_array['base_pid']] += $contents_array['qty'];
	  }
  } // end foreach
//   EOF QPBPP, price break per base products_id	  


Line 346-347

**REPLACE**
	if ($products = $pf->loadProduct($products_id, $languages_id)) {
	  $products_price = $pf->computePrice($this->contents[$products_id]['qty']);

**WITH**
  if ($products = $pf->loadProduct($products_id, $languages_id)) {
	  $qty = $this->contents[$products_id]['qty'];
	$number_of_items_in_cart_same_base_pid = $base_pid_quantity[$this->contents[$products_id]['base_pid']];
	$no_of_other_items_in_cart_with_same_base_pid = $number_of_items_in_cart_same_base_pid - $qty;

	$products_price = $pf->computePrice($this->contents[$products_id]['qty'], $no_of_other_items_in_cart_with_same_base_pid);

Line 353-357

**AFTER**
	  $products_array[] = array('id' => $products_id,
								'name' => $products['products_name'],
								'model' => $products['products_model'],
								'image' => $products['products_image'],
**ADD**
//   BOF QPBPP, price break per base products_id
								'base_pid' => $this->contents[$products_id]['base_pid'],
//   EOF QPBPP, price break per base products_id

------------------------------------------
catalog/includes/classes/PriceFormatter.php

Line 3

**REPLACE**
 $Id: PriceFormatter.php,v 1.7 2006/12/23 JanZ Exp $

**WITH**
 $Id: PriceFormatter.php, adapted for price break per "base products_id" 2007/01/04 JanZ Exp $

Line 27-28

**AFTER**
 function PriceFormatter($prices=NULL) {
$this->productsID = -1;

**ADD**
//   BOF QPBPP, price break per base products_id
$this->base_pid = '';
//   EOF QPBPP, price break per base products_id

Line 106-107

**AFTER**

 function parse($prices) {
$this->productsID = $prices['products_id'];

**ADD**

//   BOF QPBPP, price break per base products_id
$this->base_pid = tep_get_prid($prices['products_id']); // (int)$prices['products_id'] works also
//   EOF QPBPP, price break per base products_id

Line 205-207

**REPLACE**

 function computePrice($qty)
 {
$qty = $this->adjustQty($qty);

**WITH**

 function computePrice($qty, $no_of_other_items_in_cart_with_same_base_pid = 0)
 {
$qty = $this->adjustQty($qty);
$qty += $no_of_other_items_in_cart_with_same_base_pid;

Line 237-238

**AFTER**
 function getQtyBlocks() {
return $this->qtyBlocks;
 }

**ADD**

//   BOF QPBPP, price break per base products_id
 function get_base_pid() {
return $this->base_pid;
 }
//   EOF QPBPP, price break per base products_id

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...