Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Quantity Price Breaks


jpweber

Recommended Posts

Thank you JanZ..

 

I applied your fix in your last post to my store, and ran into a few problems with MySQL errors, but I was able to muddle my way through the errors, and I was finally able to get it to work. Boy its one heck of an improvement.

 

After I applied the fix, I repeated my test of adding 10 products to my shopping cart, and by the end of the 10th product, MySQL queries was at 43 queries, and the page loaded at 15.42 seconds. For each product I added, it added only 2 MySQL queries.

 

When compared with the previous test where each product I added to my shopping cart added 6 new MySQL queries it's great.

 

In summary:

 

MySQL queries decreased by 52% (From 91 to 43 queries)

Page load time decreased by 88% (From 133 to 15.42 seconds)

Number of MySQL queries added per product added to the shopping cart decreased by 66% (From 6 to 2 queries)

 

I uploaded a new copy of the QUERY DEBUG OUTPUT report in my profile under interest for your reference.

 

As far as the MySQL errors I was getting with your fix, the error was in your changes to the loadProduct function in PriceFormatter.php

 

I'm not great with PHP, so I don't know exactly what I did to get it to work, but essentially what I did was incrementally revert the loadProduct function back to it's original state (before your fix) until it worked. Like throwing pasta against the wall until you find one that sticks.

 

Anyways, here's a copy of the LoadProduct function I got to work:

 

 

 function loadProduct($product_id, $language_id=1)
 {
global $pfs;

$pricebreak = $pfs->getPriceBreak($product_id);
// returns false if the price break information is not yet stored
if ($pricebreak != false) {
	$product_info = $pricebreak;
} else {		
  $sql="select pd.products_name, p.products_model, p.products_image, p.products_id," .
  " p.manufacturers_id, p.products_price, p.products_weight," .
  " p.products_price1,p.products_price2,p.products_price3,p.products_price4, p.products_price5,p.products_price6,p.products_price7,p.products_price8," .
  " p.products_price1_qty,p.products_price2_qty,p.products_price3_qty,p.products_pri
ce4_qty, p.products_price5_qty,p.products_price6_qty,p.products_price7_qty,p.products_pri
ce8_qty," .
  " p.products_qty_blocks," .
  " p.products_tax_class_id," .
  " IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price," .
  " IF(s.status, s.specials_new_products_price, p.products_price) as final_price" .
  " from " . TABLE_PRODUCTS_DESCRIPTION . " pd," .
	"	  " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id," .
	"	  " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id" .
	" where p.products_status = '1'" .
	"   and p.products_id = '" . (int)$product_id . "'" .
	"   and pd.products_id = '" . (int)$product_id . "'" .
	"   and pd.language_id = '". (int)$language_id ."'";

  $product_info_query = tep_db_query($sql);
  $product_info = tep_db_fetch_array($product_info_query);
 $pfs->addPriceBreakData(tep_get_prid($product_id), $product_info);
}
$this->parse($product_info);

return $product_info;
}

 

Thank you once again for your help.

 

Best Regards,

Wayne

Link to comment
Share on other sites

I applied your fix in your last post to my store, and ran into a few problems with MySQL errors
I used the PriceBreak for SPPC so I did not test this query really. My fault. I see I left a comma in (in the line with specials) and I forgot to remove one line. Replacing this part should work better:

   " IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price " .
  " from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " using(products_id), " .
  " " . TABLE_PRODUCTS_DESCRIPTION . " pd " .
  " where p.products_status = '1'" .
  " and pd.products_id = p.products_id " .
  " and p.products_id = '" . (int)$product_id . "'" .
  " and pd.language_id = '". (int)$language_id ."'";

After I applied the fix, I repeated my test of adding 10 products to my shopping cart, and by the end of the 10th product, MySQL queries was at 43 queries, and the page loaded at 15.42 seconds. For each product I added, it added only 2 MySQL queries.
And no double ones: one for the quantity and one for the PriceFormatter. The last one is by far the slowest in the queries (1-2 seconds). Therefore the interest to speed up this particular query by removing the joints to tables from which no information is queried (products_to_categories and manufacturers).
Link to comment
Share on other sites

OMFG Janz, that's incredible!

 

Pages are loading incredibly fast now. Under 3 seconds 98% of the time, and mostly under 1 or 2 seconds regardless of the number of products added to the shopping cart.

 

Testing it out, I added 42 products to the shopping cart, and page parse time came in at 1.397 seconds. Blazing fast compared to the 133 seconds I was getting with only 10 products added to the cart just a few days ago.

 

I've included the latest query debug report in my profile under interests.

 

As far as the code you provided I had to make a small change because MySQL was complaining about an "Unknown table 's' in field list". Turns out it was this field

 

 

TABLE_SPECIALS . " using(products_id), " .[quote]

I just replaced it with:

[/quote]TABLE_SPECIALS . " s on p.products_id = s.products_id, " .

 

The final loadProduct function in PriceFormatter.php I used looks like this:

 

function loadProduct($product_id, $language_id=1)
 {
global $pfs;

$pricebreak = $pfs->getPriceBreak($product_id);
// returns false if the price break information is not yet stored
if ($pricebreak != false) {
	$product_info = $pricebreak;
} else {		
  $sql="select pd.products_name, p.products_model, p.products_image, p.products_id," .
  " p.manufacturers_id, p.products_price, p.products_weight," .
  " p.products_price1,p.products_price2,p.products_price3,p.products_price4, p.products_price5,p.products_price6,p.products_price7,p.products_price8," .
  " p.products_price1_qty,p.products_price2_qty,p.products_price3_qty,p.products_pri
ce4_qty, p.products_price5_qty,p.products_price6_qty,p.products_price7_qty,p.products_pri
ce8_qty," .
  " p.products_qty_blocks," .
  " p.products_tax_class_id," .
  " IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price " .
  " from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " .
  " " . TABLE_PRODUCTS_DESCRIPTION . " pd " .
  " where p.products_status = '1'" .
  " and pd.products_id = p.products_id " .
  " and p.products_id = '" . (int)$product_id . "'" .
  " and pd.language_id = '". (int)$language_id ."'";

  $product_info_query = tep_db_query($sql);
  $product_info = tep_db_fetch_array($product_info_query);
 $pfs->addPriceBreakData(tep_get_prid($product_id), $product_info);
}
$this->parse($product_info);

return $product_info;
}

 

Thanks you so much for your help. I can't even express how grateful I am. I'm ecstatic about how fast everything is loading now...

 

Best Regards,

Wayne

Link to comment
Share on other sites

I'm ecstatic about how fast everything is loading now...
OK, sorry about the foul-up with specials s, I'm testing this on a SPPC installation so can't test the actual query.

 

Let's take it one more step further, to bring it down to 1 query for all products in the shopping cart instead of (number of products) * 2. For this we add products_quantity to the loadProduct function and add the function PriceFormatterStore to the class PriceFormatterStore and change tep_get_tep_get_products_stock.

 

The new class PriceFormatterStore:

<?php
/* $Id: PriceFormatterStore.php v 1.0 2006/12/10
  an object to store the price breaks and products_quantity of a product once queried by the 
 class PriceFormatter.php to avoid it being queried more than once and tep_get_stock to be executed
 for each product on the page shopping_cart.php

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2006 osCommerce

 Released under the GNU General Public License
*/

class PriceFormatterStore {
var $pricebreaks = array();

function PriceFormatterStore() {
	global $cart;
	if (isset($_SESSION['languages_id'])) {
	$language_id = $_SESSION['languages_id'];
	} else {
		$language_id = 1;
	}
	if (is_object($cart)) {
		$product_id_list = $cart->get_product_id_list();
		if (tep_not_null($product_id_list)) {
			// get rid of attributes first
			$product_id_list_array = array();
			$product_id_list_temp_array = explode(",", $product_id_list);
			foreach ($product_id_list_temp_array as $key => $value) {
				$product_id_list_array[] = tep_get_prid($value);
			}
			unset($product_id_list);
			$product_id_list = implode(",", $product_id_list_array);
			// now do one query for all products in the shopping basket
  $sql="select pd.products_name, p.products_model, p.products_image, p.products_id," .
  " p.manufacturers_id, p.products_price, p.products_weight, p.products_quantity, " .
  " p.products_price1,p.products_price2,p.products_price3,p.products_price4, p.products_price5,p.products_price6,p.products_price7,p.products_price8," .
  " p.products_price1_qty,p.products_price2_qty,p.products_price3_qty,p.products_pri
ce4_qty, p.products_price5_qty,p.products_price6_qty,p.products_price7_qty,p.products_pri
ce8_qty," .
  " p.products_qty_blocks," .
  " p.products_tax_class_id," .
  " IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price " .
  " from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " .
  " " . TABLE_PRODUCTS_DESCRIPTION . " pd " .
  " where p.products_status = '1'" .
  " and pd.products_id = p.products_id " .
  "   and p.products_id in (" . $product_id_list . ")" .
  " and pd.language_id = '". (int)$language_id ."'";
				$product_info_query = tep_db_query($sql);
					while ($product_info = tep_db_fetch_array($product_info_query)) {
						$this->addPriceBreakData($product_info['products_id'], $product_info);
					}
		} // end if tep_not_null($product_id_list)
	} // end if (is_object($cart)
}

function addPriceBreakData ($products_id, $productinfo) {
		$this->pricebreaks[$products_id] = array('products_id' => tep_get_prid($productinfo['products_id']),
			'products_price' => $productinfo['products_price'],
			'products_name' => $productinfo['products_name'],
			'products_model' => $productinfo['products_model'],
			'products_weight' => $productinfo['products_weight'],
			'products_quantity' => $productinfo['products_quantity'],
			'products_tax_class_id' => $productinfo['products_tax_class_id'],
			'products_image' => $productinfo['products_image'],
			'products_qty_blocks' => $productinfo['products_qty_blocks'],
			'specials_new_products_price' => $productinfo['specials_new_products_price'],
			'products_price1_qty' => $productinfo['products_price1_qty'],
			'products_price2_qty' => $productinfo['products_price2_qty'],
			'products_price3_qty' => $productinfo['products_price3_qty'],
			'products_price4_qty'=> $productinfo['products_price4_qty'],
			'products_price5_qty'=> $productinfo['products_price5_qty'],
			'products_price6_qty'=> $productinfo['products_price6_qty'],
			'products_price7_qty' => $productinfo['products_price7_qty'],
			'products_price8_qty' => $productinfo['products_price8_qty'],
			'products_price1' => $productinfo['products_price1'],
			'products_price2' => $productinfo['products_price2'],
			'products_price3'=> $productinfo['products_price3'],
			'products_price4' => $productinfo['products_price4'],
			'products_price5'=> $productinfo['products_price5'],
			'products_price6' => $productinfo['products_price6'],
			'products_price7' => $productinfo['products_price7'],
			'products_price8' => $productinfo['products_price8']);
}

 function getPriceBreak($product_id) {
	$products_id = tep_get_prid($product_id);
	if(isset($this->pricebreaks[$products_id]) && tep_not_null($this->pricebreaks[$products_id])) {
		return $this->pricebreaks[$products_id];
		}	else {
			return false;
	}
}

 function getStock($product_id) {
	$products_id = tep_get_prid($product_id);
	if(isset($this->pricebreaks[$products_id]) && tep_not_null($this->pricebreaks[$products_id])) {
		return $this->pricebreaks[$products_id]['products_quantity'];
		}	else {
			return false;
	}
}
}
?>

In application_top.php it is still:

  // include the price formatter for the price breaks contribution
 require(DIR_WS_CLASSES . 'PriceFormatter.php');
 $pf = new PriceFormatter;
require(DIR_WS_CLASSES . 'PriceFormatterStore.php');
 $pfs = new PriceFormatterStore;

In the function loadProduct in PriceFormatter.php products_quantity is added to the sql:

function loadProduct($product_id, $language_id=1)
 {
global $pfs;

$pricebreak = $pfs->getPriceBreak($product_id);
// returns false if the price break information is not yet stored
if ($pricebreak != false) {
	$product_info = $pricebreak;
} else {		
  $sql="select pd.products_name, p.products_model, p.products_image, p.products_id," .
  " p.manufacturers_id, p.products_price, p.products_weight, p.products_quantity, " .
  " p.products_price1,p.products_price2,p.products_price3,p.products_price4, p.products_price5,p.products_price6,p.products_price7,p.products_price8," .
  " p.products_price1_qty,p.products_price2_qty,p.products_price3_qty,p.products_pri
ce4_qty, p.products_price5_qty,p.products_price6_qty,p.products_price7_qty,p.products_pri
ce8_qty," .
  " p.products_qty_blocks," .
  " p.products_tax_class_id," .
  " IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price " .
  " from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " .
  " " . TABLE_PRODUCTS_DESCRIPTION . " pd " .
  " where p.products_status = '1'" .
  " and pd.products_id = p.products_id " .
  " and p.products_id = '" . (int)$product_id . "'" .
  " and pd.language_id = '". (int)$language_id ."'";

  $product_info_query = tep_db_query($sql);
  $product_info = tep_db_fetch_array($product_info_query);
 $pfs->addPriceBreakData(tep_get_prid($product_id), $product_info);
}
$this->parse($product_info);

return $product_info;
}

And last, the function tep_get_products_stock (somewhere around line 124 or there about in includes/functions/general.php) is changed to:

// Return a product's stock
// TABLES: products
// adapted to take advantage of $pfs (instance of PriceFormatterStore)
 function tep_get_products_stock($products_id) {
	global $pfs;
	$stock = false;
	if (is_object($pfs)) {
		$stock = $pfs->getStock($products_id); 
	}
	if ($stock !== false) {
		return $stock;
	} else {
$products_id = tep_get_prid($products_id);
$stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
$stock_values = tep_db_fetch_array($stock_query);
return $stock_values['products_quantity'];
	} // end if/else $stock !== false
 }

Link to comment
Share on other sites

Correction regarding the language id: (should be global $languages_id)

 

The corrected class PriceFormatterStore:

<?php
/* $Id: PriceFormatterStore.php v 1.0 2006/12/16
  an object to store the price breaks and products_quantity of a product once queried by the 
 class PriceFormatter.php to avoid it being queried more than once and tep_get_stock to be executed
 for each product on the page shopping_cart.php

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2006 osCommerce

 Released under the GNU General Public License
*/

class PriceFormatterStore {
var $pricebreaks = array();

function PriceFormatterStore() {
	global $cart, $languages_id;

	if (is_object($cart)) {
		$product_id_list = $cart->get_product_id_list();
		if (tep_not_null($product_id_list)) {
			// get rid of attributes first
			$product_id_list_array = array();
			$product_id_list_temp_array = explode(",", $product_id_list);
			foreach ($product_id_list_temp_array as $key => $value) {
				$product_id_list_array[] = tep_get_prid($value);
			}
			unset($product_id_list);
			$product_id_list = implode(",", $product_id_list_array);
			// now do one query for all products in the shopping basket
  $sql="select pd.products_name, p.products_model, p.products_image, p.products_id," .
  " p.manufacturers_id, p.products_price, p.products_weight, p.products_quantity, " .
  " p.products_price1,p.products_price2,p.products_price3,p.products_price4, p.products_price5,p.products_price6,p.products_price7,p.products_price8," .
  " p.products_price1_qty,p.products_price2_qty,p.products_price3_qty,p.products_pri
ce4_qty, p.products_price5_qty,p.products_price6_qty,p.products_price7_qty,p.products_pri
ce8_qty," .
  " p.products_qty_blocks," .
  " p.products_tax_class_id," .
  " IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price " .
  " from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " .
  " " . TABLE_PRODUCTS_DESCRIPTION . " pd " .
  " where p.products_status = '1'" .
  " and pd.products_id = p.products_id " .
  "   and p.products_id in (" . $product_id_list . ")" .
  " and pd.language_id = '". (int)$languages_id ."'";
				$product_info_query = tep_db_query($sql);
					while ($product_info = tep_db_fetch_array($product_info_query)) {
						$this->addPriceBreakData($product_info['products_id'], $product_info);
					}
		} // end if tep_not_null($product_id_list)
	} // end if (is_object($cart)
}

function addPriceBreakData ($products_id, $productinfo) {
		$this->pricebreaks[$products_id] = array('products_id' => tep_get_prid($productinfo['products_id']),
			'products_price' => $productinfo['products_price'],
			'products_name' => $productinfo['products_name'],
			'products_model' => $productinfo['products_model'],
			'products_weight' => $productinfo['products_weight'],
			'products_quantity' => $productinfo['products_quantity'],
			'products_tax_class_id' => $productinfo['products_tax_class_id'],
			'products_image' => $productinfo['products_image'],
			'products_qty_blocks' => $productinfo['products_qty_blocks'],
			'specials_new_products_price' => $productinfo['specials_new_products_price'],
			'products_price1_qty' => $productinfo['products_price1_qty'],
			'products_price2_qty' => $productinfo['products_price2_qty'],
			'products_price3_qty' => $productinfo['products_price3_qty'],
			'products_price4_qty'=> $productinfo['products_price4_qty'],
			'products_price5_qty'=> $productinfo['products_price5_qty'],
			'products_price6_qty'=> $productinfo['products_price6_qty'],
			'products_price7_qty' => $productinfo['products_price7_qty'],
			'products_price8_qty' => $productinfo['products_price8_qty'],
			'products_price1' => $productinfo['products_price1'],
			'products_price2' => $productinfo['products_price2'],
			'products_price3'=> $productinfo['products_price3'],
			'products_price4' => $productinfo['products_price4'],
			'products_price5'=> $productinfo['products_price5'],
			'products_price6' => $productinfo['products_price6'],
			'products_price7' => $productinfo['products_price7'],
			'products_price8' => $productinfo['products_price8']);
}

 function getPriceBreak($product_id) {
	$products_id = tep_get_prid($product_id);
	if(isset($this->pricebreaks[$products_id]) && tep_not_null($this->pricebreaks[$products_id])) {
		return $this->pricebreaks[$products_id];
		}	else {
			return false;
	}
}

 function getStock($product_id) {
	$products_id = tep_get_prid($product_id);
	if(isset($this->pricebreaks[$products_id]) && tep_not_null($this->pricebreaks[$products_id])) {
		return $this->pricebreaks[$products_id]['products_quantity'];
		}	else {
			return false;
	}
}
}
?>

Link to comment
Share on other sites

I am currently trying to install this contrib, However I also have MRSP installed. I have managed to edit most of it to still incorporate the MRSP contrib. I am now having problems with one of the changes in catalog\product_info.php which is

From instructions in Quantity Price Breaks

 

First, a warning - I know jack about coding, but I logiced it through. I skipped this step and modified the priceformatter.php file to put the MSRP into the table that contains the QPB for SPPC. I've added cells to neaten up the table and used the MSRP style for the table. Note that I also have Show Price List on this install. It's nice and neat and works on all SPPC levels with QPB and specials. I still have to add rows and labels for 'Regular Price' and 'Special Price'. Here is my priceformatter.php:

 

<?php
/*
$Id: PriceFormatter.php,v 1.6 2003/06/25 08:29:26 petri Exp $
adapted for Separate Pricing Per Customer v4 2005/03/20
including an optimization to avoid double queries for the same info
adapted for SPPC v4 to show price list 2006/03/04
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
*/

/*
  PriceFormatter.php - module to support quantity pricing
  Created 2003, Beezle Software based on some code mods by WasaLab Oy (Thanks!)
*/

class PriceFormatter {
var $hiPrice;
var $lowPrice;
var $quantity;
var $hasQuantityPrice;

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

  $this->hasQuantityPrice=false;
  $this->hasSpecialPrice=false;

  $this->hiPrice=-1;
  $this->lowPrice=-1;

  for ($i=1; $i<=8; $i++){
  $this->quantity[$i] = -1;
  $this->prices[$i] = -1;
  }
  $this->thePrice = -1;
  $this->specialPrice = -1;
  $this->qtyBlocks = 1;

// add list price:
  $this->listPrice = '';
  $this->cg_id = '0'; // customer_group_id

  if($prices)
  $this->parse($prices);
}

// function encode and decode omitted, probably not used anyway;-)

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

  $this->quantity[1]=$prices['products_price1_qty'];
  $this->quantity[2]=$prices['products_price2_qty'];
  $this->quantity[3]=$prices['products_price3_qty'];
  $this->quantity[4]=$prices['products_price4_qty'];
  $this->quantity[5]=$prices['products_price5_qty'];
  $this->quantity[6]=$prices['products_price6_qty'];
  $this->quantity[7]=$prices['products_price7_qty'];
  $this->quantity[8]=$prices['products_price8_qty'];

  $this->thePrice=$prices['products_price'];
  $this->specialPrice=$prices['specials_new_products_price'];
  $this->hasSpecialPrice=tep_not_null($this->specialPrice);

  $this->price[1]=$prices['products_price1'];
  $this->price[2]=$prices['products_price2'];
  $this->price[3]=$prices['products_price3'];
  $this->price[4]=$prices['products_price4'];
  $this->price[5]=$prices['products_price5'];
  $this->price[6]=$prices['products_price6'];
  $this->price[7]=$prices['products_price7'];
  $this->price[8]=$prices['products_price8'];

  $this->msrp=$prices['products_msrp'];

/*
  Change support special prices
  If any price level has a price greater than the special
  price lower it to the special price
*/

if ($this->hasSpecialPrice == true) {
for($i=1; $i<=8; $i++) {
 if ($this->price[$i] > $this->specialPrice)
  $this->price[$i] = $this->specialPrice;
}
}
//end changes to support special prices

  $this->qtyBlocks=$prices['products_qty_blocks'];

  $this->taxClass=$prices['products_tax_class_id'];

  if ($this->quantity[1] > 0) {
 $this->hasQuantityPrice = true;
 $this->hiPrice = $this->thePrice;
 $this->lowPrice = $this->thePrice;

 for($i=1; $i<=8; $i++) {
if($this->quantity[$i] > 0) {
 if ($this->price[$i] > $this->hiPrice) {
$this->hiPrice = $this->price[$i];
 }
 if ($this->price[$i] < $this->lowPrice) {
$this->lowPrice = $this->price[$i];
 }
}
 }
  }

// BOF add customer_group_id/list price
 global $sppc_customer_group_id;
if(!tep_session_is_registered('sppc_customer_group_id')) { 
$this->cg_id = '0';
} else {
 $this->cg_id = $sppc_customer_group_id;
}
$this->listPrice = $prices['list_price'];
// EOF add customer_group_id/list price

}
// function loadProductSppc is Separate Pricing Per Customer only
function loadProductSppc($product_id, $language_id=1, $product_info)
{

global $sppc_customer_group_id;
if(!tep_session_is_registered('sppc_customer_group_id')) { 
$customer_group_id = '0';
} else {
 $customer_group_id = $sppc_customer_group_id;
}

// BOF add List Price (retail price) to the product_info array +msrp
$product_info['list_price'] = $product_info['products_price'];
$product_info['msrp'] = $product_info['msrp'];
// EOF add List Price

if ($customer_group_id != '0') {
 $customer_group_price_query = tep_db_query("select customers_group_price, products_price1, products_price2, products_price3, products_price4, products_price5, products_price6, products_price7, products_price8, products_price1_qty, products_price2_qty, products_price3_qty, products_price4_qty, products_price5_qty, products_price6_qty, products_price7_qty, products_price8_qty, products_qty_blocks from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$product_id. "' and customers_group_id =  '" . $customer_group_id . "'");

   if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {
   $product_info['products_price']= $customer_group_price['customers_group_price'];
for ($i = 1; $i < 9; $i++) {
$product_info['products_price'.$i.''] = $customer_group_price['products_price'.$i.''];
$product_info['products_price'.$i.'_qty'] = $customer_group_price['products_price'.$i.'_qty'];
} 
// end if ($customer_group_price = tep_db_fetch_array($customer_group_price_query))
$product_info['products_qty_blocks'] = $customer_group_price['products_qty_blocks'];
} else { // there is no price for the item in products_groups: retail price breaks need to nulled
for ($i = 1; $i < 9; $i++) {
$product_info['products_price'.$i.''] = '0.0000';
$product_info['products_price'.$i.'_qty'] = '0';
} 
// end if ($customer_group_price = tep_db_fetch_array($customer_group_price_query))
$product_info['products_qty_blocks'] = '1';
}
} 
// end if ($customer_group_id != '0')
// now get the specials price for this customer_group and add it to product_info array
$special_price_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = " . (int)$product_id . " and status ='1' and customers_group_id = '" . $customer_group_id . "'");
if ($specials_price = tep_db_fetch_array($special_price_query)) {
 $product_info['specials_new_products_price'] = $specials_price['specials_new_products_price'];
}

  $this->parse($product_info);
  return $product_info;
}

  function loadProduct($product_id, $language_id=1)
{
global $sppc_customer_group_id;
if(!tep_session_is_registered('sppc_customer_group_id')) { 
$customer_group_id = '0';
} else {
 $customer_group_id = $sppc_customer_group_id;
}

  $sql = "select pd.products_name, p.products_model, p.products_image, p.products_id," .
   " p.products_price, p.products_weight," .
   " p.products_price1,p.products_price2,p.products_price3,p.products_price4, p.products_price5,p.products_price6,p.products_price7,p.products_price8," .
   " p.products_price1_qty,p.products_price2_qty,p.products_price3_qty,p.products_pri
ce4_qty, p.products_price5_qty,p.products_price6_qty,p.products_price7_qty,p.products_pri
ce8_qty," .
   " p.products_qty_blocks," .
   " p.products_tax_class_id," .
   " NULL as specials_new_products_price" .
   " from " . TABLE_PRODUCTS_DESCRIPTION . " pd," .
   "	  " . TABLE_PRODUCTS . " p" .
   " where p.products_status = '1'" .
   "   and p.products_id = '" . (int)$product_id . "'" .
   "   and pd.products_id = '" . (int)$product_id . "'" .
   "   and pd.language_id = '". (int)$language_id ."'";

  $product_info_query = tep_db_query($sql);
  $product_info = tep_db_fetch_array($product_info_query);

// BOF add List Price (retail price) to the product_info array +msrp
  $product_info['list_price'] = $product_info['products_price'];
  $product_info['msrp'] = $product_info['msrp'];
// EOF add List Price

if ($customer_group_id != '0') {
 $customer_group_price_query = tep_db_query("select customers_group_price, products_price1, products_price2, products_price3, products_price4, products_price5, products_price6, products_price7, products_price8, products_price1_qty, products_price2_qty, products_price3_qty, products_price4_qty, products_price5_qty, products_price6_qty, products_price7_qty, products_price8_qty, products_qty_blocks from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$product_id. "' and customers_group_id =  '" . $customer_group_id . "'");

   if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {
   $product_info['products_price']= $customer_group_price['customers_group_price'];
for ($i = 1; $i < 9; $i++) {
$product_info['products_price'.$i.''] = $customer_group_price['products_price'.$i.''];
$product_info['products_price'.$i.'_qty'] = $customer_group_price['products_price'.$i.'_qty'];
} 
// end if ($customer_group_price = tep_db_fetch_array($customer_group_price_query))

$product_info['products_qty_blocks'] = $customer_group_price['products_qty_blocks'];
} else { // there is no price for the item in products_groups: retail price breaks need to nulled
for ($i = 1; $i < 9; $i++) {
$product_info['products_price'.$i.''] = '0.0000';
$product_info['products_price'.$i.'_qty'] = '0';
} 
// end if ($customer_group_price = tep_db_fetch_array($customer_group_price_query))

$product_info['products_qty_blocks'] = '1';
}
} 
// end if ($customer_group_id != '0')

// now get the specials price for this customer_group and add it to product_info array
$special_price_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = " . (int)$product_id . " and status ='1' and customers_group_id = '" . $customer_group_id . "'");
if ($specials_price = tep_db_fetch_array($special_price_query)) {
 $product_info['specials_new_products_price'] = $specials_price['specials_new_products_price'];
}

  $this->parse($product_info);
  return $product_info;
}

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

// Compute base price, taking into account the possibility of a special
$price = ($this->hasSpecialPrice === TRUE) ? $this->specialPrice : $this->thePrice;

for ($i=1; $i<=8; $i++)
if (($this->quantity[$i] > 0) && ($qty >= $this->quantity[$i]))
 $price = $this->price[$i];

return $price;
}

function adjustQty($qty) {
// Force QTY_BLOCKS granularity
$qb = $this->getQtyBlocks();
if ($qty < 1)
$qty = 1;

if ($qb >= 1)
{
if ($qty < $qb)
 $qty = $qb;

if (($qty % $qb) != 0)
 $qty += ($qb - ($qty % $qb));
}
return $qty;
}

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

function getPrice() {
  return $this->thePrice;
}

function getLowPrice() {
  return $this->lowPrice;
}

function getHiPrice() {
  return $this->hiPrice;
}

function hasSpecialPrice() {
  return $this->hasSpecialPrice;
}

function hasQuantityPrice() {
  return $this->hasQuantityPrice;
}

function getPriceString($style='PriceList') {
  global $currencies;

  if ($this->hasSpecialPrice == true) {
$lc_text = '<table align="top" border="0" cellspacing="0" cellpadding="0">';


/////////////////////////////////// add msrp

$lc_text .= '<tr><td align="right" class=' . $style. ' colspan="2">' . SHOW_PRICE_MSRP . '</td><td align="right" class=' . $style. ' colspan="2"><s>'
. $currencies->display_price($this->msrp,
tep_get_tax_rate($this->taxClass))
. '</s></td></tr>';

//////////////////////

// BOF add list price NOTE : since only the special price for the customer group
// is queried, the retail special price is not known
if ($this->cg_id > 0 && $this->listPrice > 0) {
$lc_text .= '<tr><td align="right" class=' . $style. ' colspan="2">' . SHOW_PRICE_LIST . '</td><td align="right" class=' . $style. ' colspan="2">'
. $currencies->display_price($this->listPrice,
tep_get_tax_rate($this->taxClass))
. '</td></tr>';
} 
// end if ($this->cg_id > 0) 

 elseif ($this->cg_id > 0 && $this->listPrice == 0) {
  $lc_text .= '<tr><td align="right" class=' . $style. ' colspan="2">' . NOT_AVAILABLE_FOR_RETAIL_CUSTOMERS;
  $lc_text .= '</td></tr>';
  }
  $lc_text .= '<tr><td align="right" class=' . $style. ' colspan="2">';
  $lc_text .= ' <s>'

. $currencies->display_price($this->thePrice,
	tep_get_tax_rate($this->taxClass))
. '</s> </tr><td align="right" class=' . $style. ' colspan="2">
  <span class="productSpecialPrice">'
. $currencies->display_price($this->specialPrice,
	tep_get_tax_rate($this->taxClass))
. '</span>'
.'</td></tr>';
  }
  else
  {
$lc_text = '<table align="top" border="0" cellspacing="0" cellpadding="0">';

////////////////////////add msrp

$lc_text .= '<tr><td align="right" class=' . $style. ' colspan="2">' . SHOW_PRICE_MSRP . '</td><td align="right" class=' . $style. ' colspan="2"><s>'
. $currencies->display_price($this->msrp,
tep_get_tax_rate($this->taxClass))
. '</s></td></tr>';

///////////////////////////////

// BOF add list price
if ($this->cg_id > 0 && $this->listPrice > 0) {
$lc_text .= '<tr><td align="right" class=' . $style. ' colspan="2">' . SHOW_PRICE_LIST . '</td><td align="right" class=' . $style. ' colspan="2">'
. $currencies->display_price($this->listPrice,
tep_get_tax_rate($this->taxClass))
. '</td></tr>';
} 
// end if ($this->cg_id > 0)  

elseif ($this->cg_id > 0 && $this->listPrice == 0) {
$lc_text .= '<tr><td align="right" class=' . $style. ' colspan="2">' . NOT_AVAILABLE_FOR_RETAIL_CUSTOMERS;
$lc_text .= '</td></tr>';
  }
$lc_text .= '<tr><td align="right" class=' . $style. ' colspan="2">';
if ($this->cg_id > 0) {
 $lc_text .= SHOW_YOUR_PRICE;
}
$lc_text .= '</td><td align="right" class=' . $style. ' colspan="2">';
$lc_text .= $currencies->display_price($this->thePrice,
tep_get_tax_rate($this->taxClass))
. '</td></tr>';
// EOF add list price

  }

// If you want to change the format of the price/quantity table
// displayed on the product information page, here is where you do it.

  if($this->hasQuantityPrice == true) {
for($i=1; $i<=8; $i++) {
 if($this->quantity[$i] > 0) {
  $lc_text .= '<tr><td align="right" class='.$style.'>'
  . $this->quantity[$i]
  .'+ </td><td align="right" class='.$style.'></td><td align="right" class='.$style.'>'
  . $currencies->display_price($this->price[$i],
  tep_get_tax_rate($this->taxClass))
  .'</td></tr>';
 }
}

$lc_text .= '</table>';

 }

 else {
if ($this->hasSpecialPrice == true) {
 $lc_text = '';
 if ($this->cg_id > 0 && $this->listPrice > 0) {
 $lc_text .= '<span class="smallText">' . SHOW_PRICE_LIST;
 $lc_text .= $currencies->display_price($this->listPrice,
tep_get_tax_rate($this->taxClass));
 $lc_text .= '</span><BR>' . REGULAR_PRICE;
 $lc_text .= '</span><BR>' . MSRP;
 } 
// end if ($this->cg_id > 0)

elseif ($this->cg_id > 0 && $this->listPrice == 0) {
  $lc_text .= '<span class="smallText">' . NOT_AVAILABLE_FOR_RETAIL_CUSTOMERS;
  $lc_text .= '</span><br />' . SHOW_YOUR_PRICE;
 }
 $lc_text .= ' <s>'
. $currencies->display_price($this->thePrice, tep_get_tax_rate($this->taxClass))
. '<BR></s>  <span class="productSpecialPrice">'. SPECIAL_PRICE
. $currencies->display_price($this->specialPrice, tep_get_tax_rate($this->taxClass))
. '</span> ';
}
else {
 $lc_text = '';
 if ($this->cg_id > 0 && $this->listPrice > 0) {
 $lc_text .= '<span class="smallText">' . SHOW_PRICE_LIST;
 $lc_text .= $currencies->display_price($this->listPrice,
tep_get_tax_rate($this->taxClass));
 $lc_text .= '<span class="smallText">' . SHOW_PRICE_MSRP;
 $lc_text .= $currencies->display_price($this->msrp,
tep_get_tax_rate($this->taxClass));
 $lc_text .= '</span><BR><BR>' . SHOW_YOUR_PRICE;
 } 
// end if ($this->cg_id > 0)

 elseif ($this->cg_id > 0 && $this->listPrice == 0) {
  $lc_text .= '<span class="smallText">' . NOT_AVAILABLE_FOR_RETAIL_CUSTOMERS;
  $lc_text .= '</span><br />' . SHOW_YOUR_PRICE;
 }
 $lc_text .= ' '
. $currencies->display_price($this->thePrice,
	  tep_get_tax_rate($this->taxClass))
. ' ';
}
  }

  return $lc_text;
}

function getPriceStringShort() {

  global $currencies;

  if ($this->hasSpecialPrice == true) {
 $lc_text = ' <s>'
. $currencies->display_price($this->thePrice,
	tep_get_tax_rate($this->taxClass))
. '</s>  <span class="productSpecialPrice">'
. $currencies->display_price($this->specialPrice,
	tep_get_tax_rate($this->taxClass))
. '</span> ';
  }
  else {
 if($this->hasQuantityPrice == true) {
$lc_text = ' '
 . $currencies->display_price($this->lowPrice,
	  tep_get_tax_rate($this->taxClass))
 . ' - '
 . $currencies->display_price($this->hiPrice,
	  tep_get_tax_rate($this->taxClass))
 . ' ';
 }
 else {
$lc_text = ' '
 . $currencies->display_price($this->thePrice,
	  tep_get_tax_rate($this->taxClass))
 . ' ';
 }
  }
  return $lc_text;
}
}
?>

 

Don't ask me for support! I can hardly help myself!

Link to comment
Share on other sites

  • 2 weeks later...

Hello everyone

 

I am using the

New bug-fix version: price-break-1.11.2 (correction) Tim Cartwright (Berbee) 10 Nov 2004

version in which everything works fine except on our product info page in which when you try to add a different quanity in the box it only updates quanities by 1. If you do this through the shopping cart everything is fine though and updates to the amount you entered. Please test the QTY box at the bottom of this page to see the error only update 1 item no matter what qty you enter.

 

http://awardsplaquestrophies.com/awards/pr....php/........28

 

Could someone help me solve this. I seen another member asked this also before but nobody ever answered that thread also so I never found their solution.

 

Thanks again

Link to comment
Share on other sites

I am using the

version in which everything works fine except on our product info page in which when you try to add a different quanity in the box it only updates quanities by 1.

Check in application_top.php (around line 363) that you changed the code for the action=add_product to:

	  // customer adds a product from the products page, adapted for QPBPP
  case 'add_product' :	if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
							 $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);
						  }
						  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
						  break;
  // performed by the 'buy now' button in product listings and review page

Perhaps you have a register_globals problem, so change $HTTP_POST_VARS['cart_quantity'] in that piece of code to $_POST['cart_quantity'] to exclude that.

Link to comment
Share on other sites

JanZ - Anything to look out when adding this contribution?

 

Quantity Price Breaks Per Product v1.2.0a

 

http://www.oscommerce.com/community/contri...antity+discount

 

i had problems when i implemented version 1.11.1 that was uploaded on Aug 2003 where the discount brackets weren't even supported...

Link to comment
Share on other sites

Hi JanZ (and all),

 

I have installed the v1_2_0, and seems to work fine, all BUT the "products name" in the admin section (thus efecting the catalog) - there is no Products Name text area.

 

The contribution that i have are: Ultimate SEO (I have added the values from the SEO contribution to the QaunPrBrk where needed), Article manager, Google XML sitemap, SiteMap 2.3a, InfoPages, HTC261 (have added the HTC info to the QaunPrBrk where needed).

 

And i guess all add some more...

 

Pls help since this is allmost my last stage b4 uploading the real thing to work <just need to add the products... and im done!!!>

 

Thanks,

Sharon.

Installed contributions:

Ultimate_SEO, Article Manager 1.5, Dynamic SiteMap 2.0, Infopages, Google SiteMap XMl w/admin 2.1, HeaderTagControler 2.6.1, FCKosc 2.21, X-sell 2.3, Google Analytics Modul, All Products, Page Cache 1.5, EasyPopulate2.7d, Multi Product Manager 2.5, Define Main Page, and probably few others...

Link to comment
Share on other sites

I have installed the v1_2_0, and seems to work fine, all BUT the "products name" in the admin section (thus efecting the catalog) - there is no Products Name text area.
Sounds like something went wrong when you added the code for the price breaks to the page categories.php.

 

If you are in a hurry you can rename the one from the package to say categories_pb.php and upload that to the server. When you go straight to that page by typing the link in your browser I assume everything will work fine (not sure if there are any hard-coded links to categories.php, might be). You then would have a page where you can edit the regular osC stuff and the price breaks, but of course not HTC etc.

 

There are tools like WinMerge that makes adding a contribution easier (so I have heard, I don't use them, but I do use kdiff3 occasionally to compare files.

Link to comment
Share on other sites

Sounds like something went wrong when you added the code for the price breaks to the page categories.php.

 

If you are in a hurry you can

 

Actually, I would rather fix it "from the root": I do use winmerge, which is a nice tool, and i went thru the instalation couldnt find anything wrong, i will go thru it again...

I went back to the contrib. and saw that there are few more small modifications needed ( category control, fix the bugs etc.) so I would work on it a bit, would rather it will be perfect b4 I upload all the crtitical stuff.

 

I would apriciate it if you can generaly point to a apecific area in the categories, as i went thru it allready.

BTW, if you think that there are other good contibutions that i would love to hear abt them.

 

Thanks a lot : thumbsup:

 

Sharon.

Installed contributions:

Ultimate_SEO, Article Manager 1.5, Dynamic SiteMap 2.0, Infopages, Google SiteMap XMl w/admin 2.1, HeaderTagControler 2.6.1, FCKosc 2.21, X-sell 2.3, Google Analytics Modul, All Products, Page Cache 1.5, EasyPopulate2.7d, Multi Product Manager 2.5, Define Main Page, and probably few others...

Link to comment
Share on other sites

Actually, I would rather fix it "from the root": I do use winmerge, which is a nice tool, and i went thru the instalation couldnt find anything wrong, i will go thru it again...
WinMerge is Windows only. kdiff3 has a Mac version, which I happen to use :)
I went back to the contrib. and saw that there are few more small modifications needed ( category control, fix the bugs etc.)
I have no idea what you are talking about but feel free to fix the bugs if you find any.
I would apriciate it if you can generaly point to a apecific area in the categories, as i went thru it allready.
The code for the products name is at the beginning and for the price break at the end of the page so I have a hard time believing that adding QPBPP did this.

 

Perhaps you can go back to your backup and try the diff file:

--- categories_orig.php	2007-01-02 20:29:26.000000000 +0100
+++ categories.php	2006-12-23 21:09:39.000000000 +0100
@@ -1,6 +1,7 @@
<?php
/*
  $Id: categories.php,v 1.146 2003/07/11 14:40:27 hpdl Exp $
+	adapted for QPBPP v1.2.0 2006/12/23

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com
@@ -13,6 +14,10 @@
  require('includes/application_top.php');

  require(DIR_WS_CLASSES . 'currencies.php');
+  // include the price formatter for the price breaks contribution
+  require(DIR_WS_CLASSES . 'PriceFormatter.php');
+  $pf = new PriceFormatter;
+  
  $currencies = new currencies();

  $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
@@ -215,6 +220,23 @@
	   $sql_data_array = array('products_quantity' => tep_db_prepare_input($HTTP_POST_VARS['products_quantity']),
							   'products_model' => tep_db_prepare_input($HTTP_POST_VARS['products_model']),
							   'products_price' => tep_db_prepare_input($HTTP_POST_VARS['products_price']),
+								   'products_price1' => tep_db_prepare_input($_POST['products_price1']),
+								   'products_price2' => tep_db_prepare_input($_POST['products_price2']),
+								   'products_price3' => tep_db_prepare_input($_POST['products_price3']),
+								   'products_price4' => tep_db_prepare_input($_POST['products_price4']),
+								   'products_price5' => tep_db_prepare_input($_POST['products_price5']),
+								   'products_price6' => tep_db_prepare_input($_POST['products_price6']),
+								   'products_price7' => tep_db_prepare_input($_POST['products_price7']),
+								   'products_price8' => tep_db_prepare_input($_POST['products_price8']),
+								   'products_price1_qty' => (($i=tep_db_prepare_input($_POST['products_price1_qty'])) < 0) ? 0 : $i,
+								   'products_price2_qty' => (($i=tep_db_prepare_input($_POST['products_price2_qty'])) < 0) ? 0 : $i,
+								   'products_price3_qty' => (($i=tep_db_prepare_input($_POST['products_price3_qty'])) < 0) ? 0 : $i,
+								   'products_price4_qty' => (($i=tep_db_prepare_input($_POST['products_price4_qty'])) < 0) ? 0 : $i,
+								   'products_price5_qty' => (($i=tep_db_prepare_input($_POST['products_price5_qty'])) < 0) ? 0 : $i,
+								   'products_price6_qty' => (($i=tep_db_prepare_input($_POST['products_price6_qty'])) < 0) ? 0 : $i,
+								   'products_price7_qty' => (($i=tep_db_prepare_input($_POST['products_price7_qty'])) < 0) ? 0 : $i,
+								   'products_price8_qty' => (($i=tep_db_prepare_input($_POST['products_price8_qty'])) < 0) ? 0 : $i,
+								   'products_qty_blocks' => (($i=tep_db_prepare_input($_POST['products_qty_blocks'])) < 1) ? 1 : $i,
							   'products_date_available' => $products_date_available,
							   'products_weight' => tep_db_prepare_input($HTTP_POST_VARS['products_weight']),
							   'products_status' => tep_db_prepare_input($HTTP_POST_VARS['products_status']),
@@ -286,10 +308,11 @@
		   $messageStack->add_session(ERROR_CANNOT_LINK_TO_SAME_CATEGORY, 'error');
		 }
	   } elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') {
-			$product_query = tep_db_query("select products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_tax_class_id, manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
+			$product_query = tep_db_query("select products_quantity, products_model, products_image, products_price, products_price1, products_price2, products_price3, products_price4, products_price5, products_price6, products_price7, products_price8, products_price1_qty, products_price2_qty, products_price3_qty, products_price4_qty, products_price5_qty, products_price6_qty, products_price7_qty, products_price8_qty, products_qty_blocks, products_date_available, products_weight, products_tax_class_id, manufacturers_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
+
		 $product = tep_db_fetch_array($product_query);

-			tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model,products_image, products_price, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "',  now(), " . (empty($product['products_date_available']) ? "null" : "'" . tep_db_input($product['products_date_available']) . "'") . ", '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "')");
+			tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model,products_image, products_price, products_price1, products_price2, products_price3, products_price4, products_price5, products_price6, products_price7, products_price8, products_price1_qty, products_price2_qty, products_price3_qty, products_price4_qty, products_price5_qty, products_price6_qty, products_price7_qty, products_price8_qty, products_qty_blocks, products_date_added, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "',  now(), " . (empty($product['products_date_available']) ? "null" : "'" . tep_db_input($product['products_date_available']) . "'") . ", '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "')");
		 $dup_products_id = tep_db_insert_id();

		 $description_query = tep_db_query("select language_id, products_name, products_description, products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$products_id . "'");
@@ -363,6 +386,23 @@
					'products_model' => '',
					'products_image' => '',
					'products_price' => '',
+					   'products_price1' => '',
+					   'products_price2' => '',
+					   'products_price3' => '',
+					   'products_price4' => '',
+					   'products_price5' => '',
+					   'products_price6' => '',
+					   'products_price7' => '',
+					   'products_price8' => '',
+					   'products_price1_qty' => '',
+					   'products_price2_qty' => '',
+					   'products_price3_qty' => '',
+					   'products_price4_qty' => '',
+					   'products_price5_qty' => '',
+					   'products_price6_qty' => '',
+					   'products_price7_qty' => '',
+					   'products_price8_qty' => '',
+					   'products_qty_blocks' => '',
					'products_weight' => '',
					'products_date_added' => '',
					'products_last_modified' => '',
@@ -374,7 +414,7 @@
 $pInfo = new objectInfo($parameters);

 if (isset($HTTP_GET_VARS['pID']) && empty($HTTP_POST_VARS)) {
-	  $product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
+	  $product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_price1, p.products_price2, p.products_price3, p.products_price4, p.products_price5, p.products_price6, p.products_price7, p.products_price8, p.products_price1_qty, p.products_price2_qty, p.products_price3_qty, p.products_price4_qty, p.products_price5_qty, p.products_price6_qty, p.products_price7_qty, p.products_price8_qty, p.products_qty_blocks, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
   $product = tep_db_fetch_array($product_query);

   $pInfo->objectInfo($product);
@@ -580,6 +620,78 @@
		 <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
	   </tr>
	   <tr>
+<!-- BOF QPBPP -->
+		   <td class="main"><?php echo TEXT_PRODUCTS_QTY_BLOCKS; ?></td>
+			  <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_qty_blocks', $pInfo->products_qty_blocks, 'size="10"') . ' ' . TEXT_PRODUCTS_QTY_BLOCKS_INFO ?></td>
+			</tr>
+			<tr>
+			  <td class="main"><?php echo TEXT_PRODUCTS_PRICE1; ?></td>
+			  <td colspan="3" align="left"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr>
+			  <td class="main" align="left"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_price1', $pInfo->products_price1, 'size="10"'); ?></td>
+			  <td class="main" align="right"><?php echo TEXT_PRODUCTS_PRICE1_QTY; ?></td>
+			  <td class="main" align="left"><?php echo tep_draw_input_field('products_price1_qty', $pInfo->products_price1_qty, 'size="10"'); ?></td>
+			  </tr></table></td>
+			</tr>
+			<tr>
+			  <td class="main"><?php echo TEXT_PRODUCTS_PRICE2; ?></td>
+			  <td colspan="3" align="left"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr>
+			  <td class="main" align="left"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_price2', $pInfo->products_price2, 'size="10"'); ?></td>
+			  <td class="main" align="right"><?php echo TEXT_PRODUCTS_PRICE2_QTY; ?></td>
+			  <td class="main" align="left"><?php echo tep_draw_input_field('products_price2_qty', $pInfo->products_price2_qty, 'size="10"'); ?></td>
+			  </tr></table></td>
+			</tr>
+			<tr>
+			  <td class="main"><?php echo TEXT_PRODUCTS_PRICE3; ?></td>
+			  <td colspan="3" align="left"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr>
+			  <td class="main" align="left"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_price3', $pInfo->products_price3, 'size="10"'); ?></td>
+			  <td class="main" align="right"><?php echo TEXT_PRODUCTS_PRICE3_QTY; ?></td>
+			  <td class="main" align="left"><?php echo tep_draw_input_field('products_price3_qty', $pInfo->products_price3_qty, 'size="10"'); ?></td>
+			  </tr></table></td>
+			</tr>
+			<tr>
+			  <td class="main"><?php echo TEXT_PRODUCTS_PRICE4; ?></td>
+			  <td colspan="3" align="left"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr>
+			  <td class="main" align="left"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_price4', $pInfo->products_price4, 'size="10"'); ?></td>
+			  <td class="main" align="right"><?php echo TEXT_PRODUCTS_PRICE4_QTY; ?></td>
+			  <td class="main" align="left"><?php echo tep_draw_input_field('products_price4_qty', $pInfo->products_price4_qty, 'size="10"'); ?></td>
+			  </tr></table></td>
+			</tr>
+			<tr>
+			  <td class="main"><?php echo TEXT_PRODUCTS_PRICE5; ?></td>
+			  <td colspan="3" align="left"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr>
+			  <td class="main" align="left"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_price5', $pInfo->products_price5, 'size="10"'); ?></td>
+			  <td class="main" align="right"><?php echo TEXT_PRODUCTS_PRICE5_QTY; ?></td>
+			  <td class="main" align="left"><?php echo tep_draw_input_field('products_price5_qty', $pInfo->products_price5_qty, 'size="10"'); ?></td>
+			  </tr></table></td>
+			</tr>
+			<tr>
+			  <td class="main"><?php echo TEXT_PRODUCTS_PRICE6; ?></td>
+			  <td colspan="3" align="left"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr>
+			  <td class="main" align="left"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_price6', $pInfo->products_price6, 'size="10"'); ?></td>
+			  <td class="main" align="right"><?php echo TEXT_PRODUCTS_PRICE6_QTY; ?></td>
+			  <td class="main" align="left"><?php echo tep_draw_input_field('products_price6_qty', $pInfo->products_price6_qty, 'size="10"'); ?></td>
+			  </tr></table></td>
+			</tr>
+			<tr>
+			  <td class="main"><?php echo TEXT_PRODUCTS_PRICE7; ?></td>
+			  <td colspan="3" align="left"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr>
+			  <td class="main" align="left"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_price7', $pInfo->products_price7, 'size="10"'); ?></td>
+			  <td class="main" align="right"><?php echo TEXT_PRODUCTS_PRICE7_QTY; ?></td>
+			  <td class="main" align="left"><?php echo tep_draw_input_field('products_price7_qty', $pInfo->products_price7_qty, 'size="10"'); ?></td>
+			  </tr></table></td>
+			</tr>
+			<tr>
+			  <td class="main"><?php echo TEXT_PRODUCTS_PRICE8; ?></td>
+			  <td colspan="3" align="left"><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr>
+			  <td class="main" align="left"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_price8', $pInfo->products_price8, 'size="10"'); ?></td>
+			  <td class="main" align="right"><?php echo TEXT_PRODUCTS_PRICE8_QTY; ?></td>
+			  <td class="main" align="left"><?php echo tep_draw_input_field('products_price8_qty', $pInfo->products_price8_qty, 'size="10"'); ?></td>
+			  </tr></table></td>
+			</tr>
+			<tr>
+			  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
+			</tr>
+			<tr><!-- EOF QPBPP -->					
		 <td class="main"><?php echo TEXT_PRODUCTS_WEIGHT; ?></td>
		 <td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_weight', $pInfo->products_weight); ?></td>
	   </tr>
@@ -600,7 +712,7 @@
   $products_description = $HTTP_POST_VARS['products_description'];
   $products_url = $HTTP_POST_VARS['products_url'];
 } else {
-	  $product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id  from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'");
+	  $product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_price1, p.products_price2, p.products_price3, p.products_price4, p.products_price5, p.products_price6, p.products_price7, p.products_price8, p.products_price1_qty, p.products_price2_qty, p.products_price3_qty, p.products_price4_qty, p.products_price5_qty, p.products_price6_qty, p.products_price7_qty, p.products_price8_qty, p.products_qty_blocks, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id  from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'");
   $product = tep_db_fetch_array($product_query);

   $pInfo = new objectInfo($product);
@@ -628,7 +740,10 @@
	 <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	   <tr>
		 <td class="pageHeading"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . ' ' . $pInfo->products_name; ?></td>
-			<td class="pageHeading" align="right"><?php echo $currencies->format($pInfo->products_price); ?></td>
+			<td class="pageHeading" align="right"><?php 
+			// BOF QPBPP
+			$pf->loadProduct((int)$HTTP_GET_VARS['pID'],(int)$languages[$i]['id']);
+echo $pf->getPriceString(); // EOF QPBPP ?></td>
	   </tr>
	 </table></td>
   </tr>
@@ -806,9 +921,9 @@

 $products_count = 0;
 if (isset($HTTP_GET_VARS['search'])) {
-	  $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . tep_db_input($search) . "%' order by pd.products_name");
+	  $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_price1, p.products_price2, p.products_price3, p.products_price4, p.products_price5, p.products_price6, p.products_price7, p.products_price8, p.products_price1_qty, p.products_price2_qty, p.products_price3_qty, p.products_price4_qty, p.products_price5_qty, p.products_price6_qty, p.products_price7_qty, p.products_price8_qty, p.products_qty_blocks, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . tep_db_input($search) . "%' order by pd.products_name");
 } else {
-	  $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by pd.products_name");
+	  $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_price1, p.products_price2, p.products_price3, p.products_price4, p.products_price5, p.products_price6, p.products_price7, p.products_price8, p.products_price1_qty, p.products_price2_qty, p.products_price3_qty, p.products_price4_qty, p.products_price5_qty, p.products_price6_qty, p.products_price7_qty, p.products_price8_qty, p.products_qty_blocks, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by pd.products_name");
 }
 while ($products = tep_db_fetch_array($products_query)) {
   $products_count++;

Link to comment
Share on other sites

Quantity Price Breaks Per Product v1.2.0a

i had problems when i implemented version 1.11.1 that was uploaded on Aug 2003 where the discount brackets weren't even supported...

I don't know what you mean but the code is OK and has all the info on the price. Displaying it a different way (like nafwa showed in the Dec 9, 2006 added files) is up to your imagination (and skills of course).
Link to comment
Share on other sites

WinMerge is Windows only. kdiff3 has a Mac version, which I happen to use :)

I have no idea what you are talking about but feel free to fix the bugs if you find any.

The code for the products name is at the beginning and for the price break at the end of the page so I have a hard time believing that adding QPBPP did this.

 

Perhaps you can go back to your backup and try the diff file:

 

 

I realy appriciate your time. You were right!!! the problem isnt with this contrb, I am investigating it now...

 

and once again, Thankssssss

Installed contributions:

Ultimate_SEO, Article Manager 1.5, Dynamic SiteMap 2.0, Infopages, Google SiteMap XMl w/admin 2.1, HeaderTagControler 2.6.1, FCKosc 2.21, X-sell 2.3, Google Analytics Modul, All Products, Page Cache 1.5, EasyPopulate2.7d, Multi Product Manager 2.5, Define Main Page, and probably few others...

Link to comment
Share on other sites

I installed "price-break-1.11.2" on my site. I have swimsuit with differents sizes on my site. I don’t want to give a quantity discount based on EVERYTHING they buy. Instead, I want a customer to select how many of each size of a swimsuit they want to buy and then give them a quantity discount based on how many TOTAL swimsuits they buy of a particular style. On our current website, even if a customer orders more than 12 swimsuits, they don’t get a discount unless all 12 are the same size.

Any idea/suggestion about this?

Link to comment
Share on other sites

I installed "price-break-1.11.2" on my site. I have swimsuit with differents sizes on my site. I don’t want to give a quantity discount based on EVERYTHING they buy. Instead, I want a customer to select how many of each size of a swimsuit they want to buy and then give them a quantity discount based on how many TOTAL swimsuits they buy of a particular style. On our current website, even if a customer orders more than 12 swimsuits, they don’t get a discount unless all 12 are the same size.

Any idea/suggestion about this?

I don't know if I'm completely clear on what you want. The thing is that the attributes make a product unique and so end up separately in the shopping cart. Say you have a swimsuit with products_id 225 and a size and a color attribute (say red, blue, black) and you want to have a discount on the number of red swimsuits, no matter the size... tricky, don't know if that can be done.

 

However, if you want all colors and sizes swimsuit with products id 225 to be grouped together for the discount... that has been done before. I think it is somewhere in the SPPC (Separate Pricing Per Customer) thread (and on my hard disk for sure). I remember someone who had that problem with candles that had the fragrant as an attribute.

Link to comment
Share on other sites

I just installed this contri, but i get an error.

I can't reach the site no more.

 

This is the error:

Fatal error: Cannot redeclare unserialize() in /home/mausmusi/public_html/includes/classes/shopping_cart.php on line 396

 

 

This is the code:

 

function unserialize($broken) {

for(reset($broken);$kv=each($broken)wink.gif {

$key=$kv['key'];

if (gettype($this->$key)!="user function")

$this->$key=$kv['value'];

}

}

 

}

?>

 

Can someone help me please?

 

 

Regards Maurice

Link to comment
Share on other sites

This is the error:

Fatal error: Cannot redeclare unserialize() in /home/mausmusi/public_html/includes/classes/shopping_cart.php on line 396

The error tells you that you have two instances of that function in your class or perhaps one in shopping_cart.php and the other in another file that is loaded. That error is often seen with shipping or payment classes when people upload the class to the directory for the language file by mistake.

 

I don't see how that can happen in this case. You have to search your files for the other instance of the function.

Link to comment
Share on other sites

Hi Guys,

 

Sorry if i'm slightly going off on a tangent here but does anyone know if this Contrib can be used in line with Easy Populate, i.e. Use EP to update products globaly?

 

Thanks to anyone who can help....i'm struggling to get anyones views or help on it :(

Link to comment
Share on other sites

  • 2 weeks later...

Hi ya,

 

I have recently tried to install Qunatity Price Break per Product but fallen at the last hurdle.

 

I have updated the database and all the files apart from admin\categories.php when i try and copy in the revised coding and save the file the file empties itself, (file size = 0 bytes) i have tried going through the file adding each part in turn but still it fails to save properly. Having given up for the evening i tried to copy in the original code from a backup copy and this time is saved properly!

 

Has anybody seen this problem before?

 

We currently have products in the shop, some of which have attributes set, is this possibly the problem?

 

My php knowledge is severely lacking unfortunately.

 

Cheers

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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...