Jump to content
jpweber

Quantity Price Breaks

Recommended Posts

Should:

 

 function calculate() {
  $this->total = 0;
  $this->weight = 0;
	  global $currencies, $languages_id, $pfs; // for qpbpp added: $languages_id, $pfs

 

not be:

 

 function calculate() {
  $this->total = 0;
  $this->weight = 0;
	  global $currencies, $languages_id, $pfs; } // for qpbpp added: $languages_id, $pfs

 

with a clossing } ?

 

 

edit:

 

I have changed the script from currencies.php with:

 

 function calculate() {
  $this->total = 0;
  $this->weight = 0;
	  global $currencies, $languages_id, $pfs; } // for qpbpp added: $languages_id, $pfs

 

but I still get this error:

 

Fatal error: Call to a member function getPriceFormatterData() on a non-object in /home/bajafl01/domains/bajaflightcases.nl/public_html/catalog/includes/classes/shopping_cart.php on line 365

 

 

Is there maybe a Chage that somebody make this script working for me, I'm willing to pay for it, dutch scripters only.

Edited by J.S. Coolen

Share this post


Link to post
Share on other sites
Should:

 

 function calculate() {
  $this->total = 0;
  $this->weight = 0;
	  global $currencies, $languages_id, $pfs; // for qpbpp added: $languages_id, $pfs

 

not be:

 

 function calculate() {
  $this->total = 0;
  $this->weight = 0;
	  global $currencies, $languages_id, $pfs; } // for qpbpp added: $languages_id, $pfs

 

with a clossing } ?

No.

 

Asking for commercial help is not allowed on the forums by the way. Better get a beginners book on PHP for that money :)

Share this post


Link to post
Share on other sites

Ok On the dutch forums it was allowed. I can't change my answer anymore.

 

I can't get this mod to work, there are a lot of errors And I don't have the knowlege or the time to learn al of that. I know a little something about PHP, but not enough to understand those functions.

 

for now I just replace the shop with the old files.

 

Anyway, thanks for your help.

Edited by J.S. Coolen

Share this post


Link to post
Share on other sites

I just installed a clean version of oscommerce and de qpbpp, but now I get an error:

 

1146 - Table 'bajafl01_shop.administrators' doesn't exist

 

select id from administrators limit 1

 

[TEP STOP]

Share this post


Link to post
Share on other sites
I just installed a clean version of oscommerce and de qpbpp, but now I get an error:

 

1146 - Table 'bajafl01_shop.administrators' doesn't exist

 

select id from administrators limit 1

 

[TEP STOP]

Then you installed a new version of osC but your backup that was from an old osC. Try adding that table with this sql command:

CREATE TABLE administrators (
 id int NOT NULL auto_increment,
 user_name varchar(32) binary NOT NULL,
 user_password varchar(40) NOT NULL,
 PRIMARY KEY (id)
);

Share this post


Link to post
Share on other sites
Add a discount category and only add that product to that particular price break category. With products assigned to a price break categories the attributes issue doesn't exist.

 

Hi Jan,

 

I added a price break category and only added that particular product to it exclusively, but it still doesn't seem to register the total numbers in my shopping cart.

For example: I have added a price break for 5 items or more on the fishing lures. I add 2 lures, then another 2 and then another 1. My shopping basket doesn't register the total and doens't give me any discounts.

 

Please visit my site to see what I mean.

 

I really appreciate any help you can give me.

 

http://www.mcgrafix.com/ibuy

Share this post


Link to post
Share on other sites

First off, love the contribution. I keep getting an error with my cart and subtotal.

 

http://providertackle.com/error.jpg

 

The total in the table comes up correctly, but the sub-total's math is off, using the non-discounted price.

 

However, when I do check out, the price for the Total is right? Any help is most definitely appreciated. I searched on here and through google for an answer, but I've been unable to find anything so far.

 

Thanks again.

 

 

I left out this piece of code, because when I have it in, I lose my the right column, and when I hit checkout, I get a blank page.

 

This is where it was supposed to be replacing other code - Find (around line 259-263 [293-297]): The top is the code I replaced with the code from the bottom.

 

		$product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
	if ($product = tep_db_fetch_array($product_query)) {
	  $prid = $product['products_id'];
	  $products_tax = tep_get_tax_rate($product['products_tax_class_id']);
	  $products_price = $product['products_price'];

 

// BOF qpbpp
   $pf->loadProduct($products_id, $languages_id);
	if ($product = $pfs->getPriceFormatterData($products_id)) {
	  $prid = $product['products_id'];
	  $products_tax = tep_get_tax_rate($product['products_tax_class_id']);
	  $products_price = $pf->computePrice($qty, $nof_other_items_in_cart_same_cat);
// EOF qpbpp

 

Here is my entire shopping_cart.php file from catalog/includes/classes

 

<?php
/*
 $Id: shopping_cart.php,v 1.35 2003/06/25 21:14:33 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class shoppingCart {
var $contents, $total, $weight, $cartID, $content_type;

function shoppingCart() {
  $this->reset();
}

function restore_contents() {
  global $customer_id;

  if (!tep_session_is_registered('customer_id')) return false;

// insert current cart contents in database
  if (is_array($this->contents)) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  $qty = $this->contents[$products_id]['qty'];
	  $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
	  if (!tep_db_num_rows($product_query)) {
		tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");
		if (isset($this->contents[$products_id]['attributes'])) {
		  reset($this->contents[$products_id]['attributes']);
		  while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
			tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");
		  }
		}
	  } else {
		tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
	  }
	}
  }

// reset per-session cart contents, but not the database contents
  $this->reset(false);

// BOF qpbpp
  $products_query = tep_db_query("select cb.products_id, ptdc.discount_categories_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " cb left join " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " ptdc using(products_id) where customers_id = '" . (int)$customer_id . "'");
  while ($products = tep_db_fetch_array($products_query)) {
	$this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity'], 'discount_categories_id' => $products['discount_categories_id']);
// EOF qpbpp
// attributes
	$attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'");
	while ($attributes = tep_db_fetch_array($attributes_query)) {
	  $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];
	}
  }

  $this->cleanup();
}

function reset($reset_database = false) {
  global $customer_id;

  $this->contents = array();
  $this->total = 0;
  $this->weight = 0;
  $this->content_type = false;

  if (tep_session_is_registered('customer_id') && ($reset_database == true)) {
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'");
  }

  unset($this->cartID);
  if (tep_session_is_registered('cartID')) tep_session_unregister('cartID');
}

function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {
  global $new_products_id_in_cart, $customer_id;
// BOF qpbpp
  $pf = new PriceFormatter;
  $pf->loadProduct($products_id);
  $qty = $pf->adjustQty($qty);
  $discount_category = $pf->get_discount_category();
// EOF qpbpp

  $products_id_string = tep_get_uprid($products_id, $attributes);
  $products_id = tep_get_prid($products_id_string);

  $attributes_pass_check = true;

  if (is_array($attributes)) {
	reset($attributes);
	while (list($option, $value) = each($attributes)) {
	  if (!is_numeric($option) || !is_numeric($value)) {
		$attributes_pass_check = false;
		break;
	  }
	}
  }

  if (is_numeric($products_id) && is_numeric($qty) && ($attributes_pass_check == true)) {
	$check_product_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
	$check_product = tep_db_fetch_array($check_product_query);

	if (($check_product !== false) && ($check_product['products_status'] == '1')) {
	  if ($notify == true) {
		$new_products_id_in_cart = $products_id;
		tep_session_register('new_products_id_in_cart');
	  }

// 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
// insert into database
		if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$qty . "', '" . date('Ymd') . "')");

		if (is_array($attributes)) {
		  reset($attributes);
		  while (list($option, $value) = each($attributes)) {
			$this->contents[$products_id_string]['attributes'][$option] = $value;
// insert into database
			if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id_string) . "', '" . (int)$option . "', '" . (int)$value . "')");
		  }
		}
	  }

	  $this->cleanup();

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
	  $this->cartID = $this->generate_cart_id();
	}
  }
}

// BOF qpboo
function update_quantity($products_id, $quantity = '', $attributes = '', $discount_categories_id = NULL) {
// EOF qpbpp

  global $customer_id;

  $products_id_string = tep_get_uprid($products_id, $attributes);
  $products_id = tep_get_prid($products_id_string);

  $attributes_pass_check = true;

  if (is_array($attributes)) {
	reset($attributes);
	while (list($option, $value) = each($attributes)) {
	  if (!is_numeric($option) || !is_numeric($value)) {
		$attributes_pass_check = false;
		break;
	  }
	}
  }

  if (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity) && ($attributes_pass_check == true)) {
	//$this->contents[$products_id_string] = array('qty' => $quantity);
// BOF qpbpp
	$this->contents[$products_id_string] = array('qty' => (int)$quantity, 'discount_categories_id' => $discount_categories_id);
// EOF qpbpp
// update database
	if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . (int)$quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id_string) . "'");

	if (is_array($attributes)) {
	  reset($attributes);
	  while (list($option, $value) = each($attributes)) {
		$this->contents[$products_id_string]['attributes'][$option] = $value;
// update database
		if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id_string) . "' and products_options_id = '" . (int)$option . "'");
	  }
	}
  }
}

function cleanup() {
  global $customer_id;

  reset($this->contents);
  while (list($key,) = each($this->contents)) {
	if ($this->contents[$key]['qty'] < 1) {
	  unset($this->contents[$key]);
// remove from database
	  if (tep_session_is_registered('customer_id')) {
		tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
		tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
	  }
	}
  }
}

function count_contents() {  // get total number of items in cart 
  $total_items = 0;
  if (is_array($this->contents)) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  $total_items += $this->get_quantity($products_id);
	}
  }

  return $total_items;
}

function get_quantity($products_id) {
  if (isset($this->contents[$products_id])) {
	return $this->contents[$products_id]['qty'];
  } else {
	return 0;
  }
}

function in_cart($products_id) {
  if (isset($this->contents[$products_id])) {
	return true;
  } else {
	return false;
  }
}

function remove($products_id) {
  global $customer_id;

  unset($this->contents[$products_id]);
// remove from database
  if (tep_session_is_registered('customer_id')) {
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
  }

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
  $this->cartID = $this->generate_cart_id();
}

function remove_all() {
  $this->reset();
}

function get_product_id_list() {
  $product_id_list = '';
  if (is_array($this->contents)) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  $product_id_list .= ', ' . $products_id;
	}
  }

  return substr($product_id_list, 2);
}

function calculate() {
  $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

  reset($this->contents);
  while (list($products_id, ) = each($this->contents)) {
	$qty = $this->contents[$products_id]['qty'];
// BOF qpbpp		
  if (tep_not_null($this->contents[$products_id]['discount_categories_id'])) {
	$nof_items_in_cart_same_cat = $discount_category_quantity[$this->contents[$products_id]['discount_categories_id']];
	$nof_other_items_in_cart_same_cat = $nof_items_in_cart_same_cat - $qty;
  } else {
	  $nof_other_items_in_cart_same_cat = 0;
  }
// EOF qpbpp

// products price
	$product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
	if ($product = tep_db_fetch_array($product_query)) {
	  $prid = $product['products_id'];
	  $products_tax = tep_get_tax_rate($product['products_tax_class_id']);
	  $products_price = $product['products_price'];
	  $products_weight = $product['products_weight'];

// BOF qpbpp
	 /* $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows ($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  } */
// EOF qpbpp

	  $this->total += tep_add_tax($products_price, $products_tax) * $qty;
	  $this->weight += ($qty * $products_weight);
	}

// attributes price
	if (isset($this->contents[$products_id]['attributes'])) {
	  reset($this->contents[$products_id]['attributes']);
	  while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
		$attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
		$attribute_price = tep_db_fetch_array($attribute_price_query);
		if ($attribute_price['price_prefix'] == '+') {
		  $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
		} else {
		  $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
		}
	  }
	}
  }
}

function attributes_price($products_id) {
  $attributes_price = 0;

  if (isset($this->contents[$products_id]['attributes'])) {
	reset($this->contents[$products_id]['attributes']);
	while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
	  $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
	  $attribute_price = tep_db_fetch_array($attribute_price_query);
	  if ($attribute_price['price_prefix'] == '+') {
		$attributes_price += $attribute_price['options_values_price'];
	  } else {
		$attributes_price -= $attribute_price['options_values_price'];
	  }
	}
  }

  return $attributes_price;
}

function get_products() {
  global $languages_id, $pfs;

  if (!is_array($this->contents)) return false;
// BOF qpbpp
  $discount_category_quantity = array();
  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

  $products_array = array();
  reset($this->contents);
  while (list($products_id, ) = each($this->contents)) {
// BOF qpbpp
  $pf->loadProduct($products_id, $languages_id); // does query if necessary and adds to 
  // PriceFormatterStore or gets info from it next
  if ($products = $pfs->getPriceFormatterData($products_id)) {
   if (tep_not_null($this->contents[$products_id]['discount_categories_id'])) {
	  $nof_items_in_cart_same_cat =  $discount_category_quantity[$this->contents[$products_id]['discount_categories_id']];
	  $nof_other_items_in_cart_same_cat = $nof_items_in_cart_same_cat - $this->contents[$products_id]['qty'];
	} else {
	  $nof_other_items_in_cart_same_cat = 0;
	}
	  $products_price = $pf->computePrice($this->contents[$products_id]['qty'], $nof_other_items_in_cart_same_cat);
// EOF qpbpp

	  $products_array[] = array('id' => $products_id,
								'name' => $products['products_name'],
								'model' => $products['products_model'],
								'image' => $products['products_image'],
								'price' => $products_price,
								'quantity' => $this->contents[$products_id]['qty'],
								'weight' => $products['products_weight'],
								'final_price' => ($products_price + $this->attributes_price($products_id)),
								'tax_class_id' => $products['products_tax_class_id'],
								'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));
	}
  }

  return $products_array;
}

function show_total() {
  $this->calculate();

  return $this->total;
}

function show_weight() {
  $this->calculate();

  return $this->weight;
}

function generate_cart_id($length = 5) {
  return tep_create_random_value($length, 'digits');
}

function get_content_type() {
  $this->content_type = false;

  if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  if (isset($this->contents[$products_id]['attributes'])) {
		reset($this->contents[$products_id]['attributes']);
		while (list(, $value) = each($this->contents[$products_id]['attributes'])) {
		  $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$value . "' and pa.products_attributes_id = pad.products_attributes_id");
		  $virtual_check = tep_db_fetch_array($virtual_check_query);

		  if ($virtual_check['total'] > 0) {
			switch ($this->content_type) {
			  case 'physical':
				$this->content_type = 'mixed';

				return $this->content_type;
				break;
			  default:
				$this->content_type = 'virtual';
				break;
			}
		  } else {
			switch ($this->content_type) {
			  case 'virtual':
				$this->content_type = 'mixed';

				return $this->content_type;
				break;
			  default:
				$this->content_type = 'physical';
				break;
			}
		  }
		}
	  } else {
		switch ($this->content_type) {
		  case 'virtual':
			$this->content_type = 'mixed';

			return $this->content_type;
			break;
		  default:
			$this->content_type = 'physical';
			break;
		}
	  }
	}
  } else {
	$this->content_type = 'physical';
  }

  return $this->content_type;
}

function unserialize($broken) {
  for(reset($broken);$kv=each($broken);) {
	$key=$kv['key'];
	if (gettype($this->$key)!="user function")
	$this->$key=$kv['value'];
  }
}

 }
?>

 

 

Thanks again,

 

Craig

Share this post


Link to post
Share on other sites
I keep getting an error with my cart and subtotal.

 

The total in the table comes up correctly, but the sub-total's math is off, using the non-discounted price.

 

However, when I do check out, the price for the Total is right?

 

I left out this piece of code, because when I have it in, I lose my the right column, and when I hit checkout, I get a blank page.

 

This is where it was supposed to be replacing other code - Find (around line 259-263 [293-297]): The top is the code I replaced with the code from the bottom.

I see a lot of differences. One of them is that you are using an old version of osC apparently because I don't see any references to the function $currencies->display_price(). The class PriceFormatter is using that too so those two things (using old and new together) don't mix well.

 

Check contribution 6654 to see in which update of osC that new function was introduced and make at least those changes. Better to upgrade to RC2a and then use the QPBPP included shopping_cart file instead of trying to make those changes yourself.

 

Changing the class shopping_cart.php went wrong on several places. Leaving out that piece of code is one of the killers.

Share this post


Link to post
Share on other sites

Thanks for the advice.....I hate to do this, but I'll probably download the newest version and start from scratch. I'll now have to weigh my options on which contrib to upload, and which ones to add manually, as there is about 7 or 8 I want to include.

 

Thanks again.

Share this post


Link to post
Share on other sites

Hi. Thanks for a good contribution! My client has a problem with some pages show the price break:

 

If you go to a category from the main section of the page, you are directed to a listing of items in a table format. (see http://southerntoolky.com/stskystore/index.php?cPath=20_63 ). The problem is that the PRICE column lists the price for the quantity price break, rather than the single item price.

 

Any help? Thanks

Share this post


Link to post
Share on other sites
Hi. Thanks for a good contribution! My client has a problem with some pages show the price break:

 

If you go to a category from the main section of the page, you are directed to a listing of items in a table format. (see http://southerntoolky.com/stskystore/index.php?cPath=20_63 ). The problem is that the PRICE column lists the price for the quantity price break, rather than the single item price.

 

Any help? Thanks

If I am correct the changes that QPBPP will do to that is show the lowest price prefixed with "From " (in the English language). Here it says "For ". Either change that or remove the changes for QPBPP in includes/modules/product_listing.php so that is still shows the single item price.

Share this post


Link to post
Share on other sites

Hi,

 

thanks for the great contribution!!! It works great. Still a question came up to reformat the product_info.php part.

 

Now it shows the table with the discounts 1pcs 100$ | 3pcs 80$ each | 5 pcs 70$ each

 

New i would like to show a dropdown where one can choose 1, 3 or 5 pcs and the discount next to the name. Just like this:

 

<select name="Quantity" id="Quantity">

<option value="1">1 pcs: $100,00</option>

<option value="3">3 pcs (-10%): $80,00</option>

<option value="5">5 pcs (-12%): $70,00</option>

</select>

 

Here is also a print screen of what i want to do:

 

screen.gif

 

I do not want to reinvet a bicycle so before i start programming i was thinking of asking for some hints.

 

Is this possible with this contribution?

 

Thanks

caitanya

Share this post


Link to post
Share on other sites
I do not want to reinvet a bicycle so before i start programming i was thinking of asking for some hints.

 

Is this possible with this contribution?

It is already in the QPBPP version for SPPC

Here the function getPriceDropDown is used if the number of price breaks is larger than a set amount.

You can't use it as such because in that version also a minimum order quantity was added but I guess you can adapt around it. You would need add some defines etcetera and change it to your liking but this gives the generla idea:

  function getPriceDropDown() {
global $currencies;
$no_of_price_breaks = count($this->price_breaks);
$qtyBlocks = $this->getQtyBlocks();

  $dropdown_price_breaks = array();
  $i = 0;
  $pb_text = '';
  if ($this->price_breaks[0]['products_qty'] > $this->products_min_order_qty) {
	$pb_text = PB_DROPDOWN_BEFORE . $this->products_min_order_qty;
	if (($this->price_breaks[0]['products_qty'] - $this->products_min_order_qty) > $qtyBlocks) {
	  $pb_text .= '-' . ($this->price_breaks[0]['products_qty'] - $qtyBlocks);
	}
	$pb_text .= PB_DROPDOWN_BETWEEN . $currencies->display_price($this->hiPrice, tep_get_tax_rate($this->taxClass)) . PB_DROPDOWN_AFTER;
	$dropdown_price_breaks[] = array('id' => $i, 'text' => $pb_text);
	$i++;
  } // end if ($this->price_breaks[0]['products_qty'] > $this->products_min_order_qty)

 for ($z = 0; $z < $no_of_price_breaks; $z++) {
   $pb_text = PB_DROPDOWN_BEFORE . $this->price_breaks[$z]['products_qty']; // start again
   if ($z == $no_of_price_breaks -1) {
	 // last one
	 $pb_text .= '+';
   } else {
	 if (($this->price_breaks[$z + 1]['products_qty'] - $this->price_breaks[$z]['products_qty']) > $qtyBlocks) {
	   $pb_text .= '-' . ($this->price_breaks[$z + 1]['products_qty'] - $qtyBlocks);
	 }
   }
   $pb_text .= PB_DROPDOWN_BETWEEN . $currencies->display_price($this->price_breaks[$z]['products_price'], tep_get_tax_rate($this->taxClass)) . PB_DROPDOWN_AFTER;
   $dropdown_price_breaks[] = array('id' => $i, 'text' => $pb_text);
   $i++;
	 } // end for ($z = 0; $z < $no_of_price_breaks; $z++)
	 $dropdown = tep_draw_pull_down_menu('price_breaks', $dropdown_price_breaks, '0', 'style="font-weight: normal"');
 $dropdown .= ' <span class="smalltext">' . PB_FROM . '</span> ' . $currencies->display_price($this->lowPrice, tep_get_tax_rate($this->taxClass)) . "\n";

 return $dropdown;
 }

Share this post


Link to post
Share on other sites

First of all thanks for your great contrib. I'm using it and it works very good. But now the following question:

I want to show the lowest price on every page. So on the homepage and the category-page I want to show the 'discount-price'. Now on the homepage the original price is shown. What should I do to make this possible?

P.s. I'm using Quantity Price Breaks Per Product version 1.3.5 from september 7th 2008

 

The home is not showing the 'discount-price'

homet.th.jpg

 

The categorie page shows the price the right way

categorie.th.jpg

Edited by Elkana

Share this post


Link to post
Share on other sites

Hi, Great contribution. I got this to work with my site with STS and SPPC among others without any problem. I want to add a quantity box in my product info page and would like to know if there are any contributions that anyone can suggest which can be implemented into my site without issues. The ones I see don't take into account the quantity price break table. Any help??? Thanks in Advance.

 

Best Regards,

Jack

Share this post


Link to post
Share on other sites
I want to add a quantity box in my product info page and would like to know if there are any contributions that anyone can suggest which can be implemented into my site without issues. The ones I see don't take into account the quantity price break table.

Why should they? Instead of 1, the quantity put into the input field is added to the shopping cart. SPPC will do it's job, QPBPP will do it's job. I don't see any issues with it really.

I might misunderstand your question...

Share this post


Link to post
Share on other sites
First of all thanks for your great contrib. I'm using it and it works very good. But now the following question:

I want to show the lowest price on every page. So on the homepage and the category-page I want to show the 'discount-price'. Now on the homepage the original price is shown. What should I do to make this possible?

P.s. I'm using Quantity Price Breaks Per Product version 1.3.5 from september 7th 2008

 

The home is not showing the 'discount-price'

homet.th.jpg

 

The categorie page shows the price the right way

categorie.th.jpg

 

Does nobody know how I should do this?

Share this post


Link to post
Share on other sites

I had the old Tim Cartwright version of QPB installed and working fine, but then I added the Discount Coupons contribution, and quantity price breaks were no longer being applied. Has anyone gotten these two contribs to play nicely together? I have no problem updating to the newest version of QPB if it is known to work with Discount Coupons. Just wanted to see if anyone has run across this and can offer some advice. Thanks!

Share this post


Link to post
Share on other sites
Why should they? Instead of 1, the quantity put into the input field is added to the shopping cart. SPPC will do it's job, QPBPP will do it's job. I don't see any issues with it really.

I might misunderstand your question...

 

Hi Jan,

 

Thanks for the reply. I think I didn't state my question correctly previously. I also want to have a calculation displayed below (ie. $10.00 x 5 = $50.00 as the user changes the quantity). As of now, I just add the quantity box and it can pass the correct quantity to the cart but doesn't pass the product option. This is something with the quantity box and doesn't deal with Quantity Price Break but if you have a quick solution, please let me know.

 

Questions relating to this contribution:

You have posted in an old post ( http://forums.oscommerce.com/index.php?showtopic=296849 ) about hardcoding the login for larger quantity breaks. The code has changed so much since then so I'm unsure of what to add now. Can you shed some light on this? I'm using QPBPP v1.3.5 for SPPC.

Also, I would like to have a vertical table instead of a horizontal table. Is this possible without too much modification?

Thank you for sharing your expertise!!!

 

Best Regards,

Jack

Share this post


Link to post
Share on other sites
Thanks for the reply. I think I didn't state my question correctly previously. I also want to have a calculation displayed below (ie. $10.00 x 5 = $50.00 as the user changes the quantity). As of now, I just add the quantity box and it can pass the correct quantity to the cart but doesn't pass the product option. This is something with the quantity box and doesn't deal with Quantity Price Break but if you have a quick solution, please let me know.

I don't get it. On product_info.php there is a quantity box in QPBPP:

<?php // BOF qpbpp
			//<td class="main" align="right"><?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART);
?>
			<td class="main" align="right">
			  <table border="0" align="right">
				<tr><td align="center">
				  <?php echo TEXT_ENTER_QUANTITY . ":" . tep_draw_input_field('cart_quantity', $pf->adjustQty(1), 'size="6"'); ?>
				</td></tr>
				<tr><td align="center">
				  <?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?>
				</td></tr>
		  </table>
			</td>
<?php // EOF qpbpp ?>

Dynamically changing the total price on the basis of the number a customer enters would take some serious JavaScript coding.

Questions relating to this contribution:

You have posted in an old post ( http://forums.oscommerce.com/index.php?showtopic=296849 ) about hardcoding the login for larger quantity breaks. The code has changed so much since then so I'm unsure of what to add now. Can you shed some light on this? I'm using QPBPP v1.3.5 for SPPC.

Also, I would like to have a vertical table instead of a horizontal table. Is this possible without too much modification?

I think the vertical table (using the old code I believe) is still in the PriceFormatter.php, but commented out.

It would take time but in principle you can code that table any way you like.

Share this post


Link to post
Share on other sites

Any suggestion in this case:

I have a product that has two color options, price no change. First, customer add product with color A, and then customer add product color B. After that, we have two items in cart with different quantity. How can I group product quantity in this case in order to "Quantity Price Breaks" works.

 

Thanks for any help.

Share this post


Link to post
Share on other sites
Any suggestion in this case:

I have a product that has two color options, price no change. First, customer add product with color A, and then customer add product color B. After that, we have two items in cart with different quantity. How can I group product quantity in this case in order to "Quantity Price Breaks" works.

See this previous post for solutions.

Share this post


Link to post
Share on other sites
I'm using the plugin but I've got an question. Can I get the 'discount-price' on the homepage?

Bumping till you get an answer? Bumping is not allowed on the osC forum by the way. "the homepage" is vague. I guess you mean the new products. Sure you can as you already suspected but your next reply will be "I'm from Barcelona, I know nothing; can somebody do this for me?" And then I will not answer again, just that you know.

Share this post


Link to post
Share on other sites

Pfff, you don't have to be so rude. I'm trying to get an answer since March 12th (on the Dutch forum also) but nobody seems to know something about this or wont answer. So I'm very curious if anybody can help me, thats the reason why I'm 'bumping'. And no, I am NOT from Barcelona and I am NOT going to ask if anybody can do this for me but if anybody can help me to make this possible.

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

×