Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Quantity Price Breaks


jpweber

Recommended Posts

theres code missing from the instructions but if you look in the supplied admin/categories.php you will find the missing code - cant remeber off hand where it is but its between some <tr> tags

Thanks for that. My next step was to upload the supplied admin/categories file and see if it worked, then do a compare between mine and theirs.

I have header tags and SEO urls installed so i had some merging to do already.

 

Tim

Link to comment
Share on other sites

theres code missing from the instructions but if you look in the supplied admin/categories.php you will find the missing code - cant remeber off hand where it is but its between some <tr> tags

Thanks again to Julian and also beyond compare.

There were 2 blocks of code missing from the install instructions and one query with a typo. beyond compare showed them to me and fixed it up right.

 

Now when i get time i will sort out the file that was never updated for 2.3.1

 

Tim

Link to comment
Share on other sites

@@knifeman Can you please update the package on addons.oscommerce.com if you do manage to sort everything out? I can't make head or tails out of everything in it.

That job really needs to be done, but I am afraid I do not have time right now. I empathize with anyone that is new to oscommerce trying to install this one.

The biggest issues I saw were:

In admin/categories.php there are several mistakes. Best option is to use a compare program like beyond compare to put your file and the new one included in the add on side by side. The compare program can move blocks of code from one file to the other with a single click.

 

In admin discount_categories.php

This file is not 2.3.1 ready. You need to remove the call for header.php and column left. Insert calls for template_top and template_bottom. Also i reduced the table width of the body so it would fit beside the boxes in admin rather than get pushed under them.

 

I would be happy to upload my categories.php here, but it is modified for header tags and seo urls. I had to merge a few pieces of price break code so all 3 would work.

 

Tim

Link to comment
Share on other sites

Hello,

 

I have a problem displaying special prices on product_info.php page. There must be a strike through on the original price if the item is on special offer. However, if I go into the product info page, I can only see the original price. To setup special prices I'm using "easy advanced specials admin" addon. Please help...

 

Here is the code from my includes/classes/PriceFormatter.php:

<?php
/*
 $Id: PriceFormatter.php,v 1.6 2003/06/25 08:29:26 petri Exp $
 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;
if($prices)
  $this->parse($prices);
 }
 function encode() {
 $str = $this->productsID . ":"
	 . (($this->hasQuantityPrice == true) ? "1" : "0") . ":"
	 . (($this->hasSpecialPrice == true) ? "1" : "0") . ":"
	 . $this->quantity[1] . ":"
	 . $this->quantity[2] . ":"
	 . $this->quantity[3] . ":"
	 . $this->quantity[4] . ":"
   . $this->quantity[5] . ":"
   . $this->quantity[6] . ":"
   . $this->quantity[7] . ":"
	 . $this->quantity[8] . ":"
	 . $this->price[1] . ":"
	 . $this->price[2] . ":"
	 . $this->price[3] . ":"
	 . $this->price[4] . ":"
   . $this->price[5] . ":"
   . $this->price[6] . ":"
   . $this->price[7] . ":"
	 . $this->price[8] . ":"
	 . $this->thePrice . ":"
	 . $this->specialPrice . ":"
	 . $this->qtyBlocks . ":"
	 . $this->taxClass;
 return $str;
 }
 function decode($str) {
 list($this->productsID,
   $this->hasQuantityPrice,
   $this->hasSpecialPrice,
   $this->quantity[1],
   $this->quantity[2],
   $this->quantity[3],
   $this->quantity[4],
   $this->quantity[5],
   $this->quantity[6],
   $this->quantity[7],
   $this->quantity[8],
   $this->price[1],
   $this->price[2],
   $this->price[3],
   $this->price[4],
   $this->price[5],
   $this->price[6],
   $this->price[7],
   $this->price[8],
   $this->thePrice,
   $this->specialPrice,
   $this->qtyBlocks,
   $this->taxClass) = explode(":", $str);
 $this->hasQuantityPrice = (($this->hasQuantityPrice == 1) ? true : false);
 $this->hasSpecialPrice = (($this->hasSpecialPrice == 1) ? true : false);
 }
 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=tep_get_products_special_price($prices['products_id']);
$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'];

 /*
   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];
}
 }
  }
}
 }
 function loadProduct($product_id, $language_id=1)
 {
$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_length, p.products_width, p.products_height, p.products_ready_to_ship," .
	" 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_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);
$this->parse($product_info);
return $product_info;
 }
 function computePrice($qty)
 {
 $qty = $this->adjustQty($qty);
 $price = $this->thePrice;
 //if ($this->hasSpecialPrice == true)
 //  $price = $this->specialPrice;
 //else
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 getDiscountSaving($original_price, $discount_price) {

$difference = $original_price - $discount_price;
$saving = round (($difference / $original_price) * 100) . '%';

 return $saving;
 }
 function getPriceString($style='productPriceInBox') {
global $currencies;
 //Change support special prices
 //don't display special prices.....
if (false == 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 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) {
 $lc_text = '<table border="0" cellspacing="0" cellpadding="0" class="infoBox" align="center">
	<tr valign="top">
	<td>
	<table border="0" cellspacing="1" cellpadding="5" class="infobox">';
	$lc_text .= '<tr valign="top"><td width="100" class="infoBoxHeading">Qty. Discount</td>'
//		   . $currencies->display_price($this->thePrice,
//			 tep_get_tax_rate($this->taxClass))
		   . '</td>';
  //begin mod
if($this->quantity[1] > 0 && ($this->quantity[2] > 0)) {$lc_text .= '<td align="center" width="65" class="infoBoxHeading">'. $this->quantity[1] . ' - ' . ($this->quantity[2]-1) . ' ' . '</td>';}
if($this->quantity[1] > 0 && ($this->quantity[2] < 1)) {$lc_text .= '<td align="center" width="65" class="infoBoxHeading">'. $this->quantity[1] . ' + ' . '</td>';}
if($this->quantity[2] > 0 && ($this->quantity[3] > 0)) {$lc_text .= '<td align="center" width="65" class="infoBoxHeading">'. $this->quantity[2] . ' - ' . ($this->quantity[3]-1) . ' ' . '</td>';}
if($this->quantity[2] > 0 && ($this->quantity[3] < 1 )) {$lc_text .= '<td align="center" width="65" class="infoBoxHeading">'. $this->quantity[2] . ' + ' . '</td>';}
if($this->quantity[3] > 0 && ($this->quantity[4] > 0)) {$lc_text .= '<td align="center" width="65" class="infoBoxHeading">'. $this->quantity[3] . ' - ' . ($this->quantity[4]-1) . ' ' . '</td>';}
if($this->quantity[3] > 0 && ($this->quantity[4] < 1)) {$lc_text .= '<td align="center" width="65" class="infoBoxHeading">'. $this->quantity[3] . ' + ' . '</td>';}
if($this->quantity[4] > 0 && ($this->quantity[5] > 0)) {$lc_text .= '<td align="center" width="65" class="infoBoxHeading">'. $this->quantity[4] . ' - ' . ($this->quantity[5]-1) . ' ' . '</td>';}
if($this->quantity[4] > 0 && ($this->quantity[5] < 1)) {$lc_text .= '<td align="center" width="65" class="infoBoxHeading">'. $this->quantity[4] . ' + ' . '</td>';}
if($this->quantity[5] > 0 && ($this->quantity[6] > 0)) {$lc_text .= '<td align="center" width="65" class="infoBoxHeading">'. $this->quantity[5] . ' - ' . ($this->quantity[6]-1) . ' ' . '</td>';}
if($this->quantity[5] > 0 && ($this->quantity[6] < 1)) {$lc_text .= '<td align="center" width="65" class="infoBoxHeading">'. $this->quantity[5] . ' + ' . '</td>';}
if($this->quantity[6] > 0 && ($this->quantity[7] > 0)) {$lc_text .= '<td align="center" width="65" class="infoBoxHeading">'. $this->quantity[6] . ' - ' . ($this->quantity[7]-1) . ' ' . '</td>';}
if($this->quantity[6] > 0 && ($this->quantity[7] < 1)) {$lc_text .= '<td align="center" width="65" class="infoBoxHeading">'. $this->quantity[6] . ' + ' . '</td>';}
if($this->quantity[7] > 0 && ($this->quantity[8] > 0 )) {$lc_text .= '<td align="center" width="65" class="infoBoxHeading">'. $this->quantity[7] . ' - ' . ($this->quantity[8]-1) . ' ' . '</td>';}
if($this->quantity[7] > 0 && ($this->quantity[8] < 1)) {$lc_text .= '<td align="center" width="65" class="infoBoxHeading">'. $this->quantity[7] . ' + ' . '</td>';}
if($this->quantity[8] > 0) {$lc_text .= '<td align="center" width="50" class="infoBoxHeading">'. $this->$this->quantity[8] . ' + </td>';
}
//end mod
//	  <tr valign="top"><td width="150" class="infoBoxContents">M1P102</td><td align="center" width="65" class="infoBoxContents">'
//		. $currencies->display_price($this->price[$i],
//			 tep_get_tax_rate($this->taxClass))
  $lc_text .= '<tr valign="top"><td width="100" class="infoBoxContents">Price each</td>';
 for($i=1; $i<=8; $i++) {
if($this->quantity[$i] > 0) {
  $lc_text .= '<td align="center" width="65" class="infoBoxContents">'
	. $currencies->display_price($this->price[$i],
		 tep_get_tax_rate($this->taxClass))
		.'</td>';
}
 }
 $lc_text .= '</tr>';
 // Begin saving calculation
 $lc_text .= '<tr valign="top"><td width="100" class="infoBoxContents">Saving %</td>';
 for($i=1; $i<=8; $i++) {
if($this->quantity[$i] > 0) {
  $lc_text .= '<td align="center" width="65" class="infoBoxContents">'
	. $this->getDiscountSaving($this->price[1], $this->price[$i])
		.'</td>';
}
 }
 $lc_text .= '</tr></table></td></tr></table>';
  }
  else {
 $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><br/>  <span class="productSpecialPrice">'
. $currencies->display_price($this->specialPrice,
tep_get_tax_rate($this->taxClass))
. '</span> ';
}
else {
if($this->hasQuantityPrice == true) {
$lc_text = '<font size="1">As low as</font><br>' .
$currencies->display_price($this->lowPrice, tep_get_tax_rate($this->taxClass));
}
else {
$lc_text = ' '
. $currencies->display_price($this->thePrice,
tep_get_tax_rate($this->taxClass))
. ' ';
}
}
return $lc_text;
 }
}
?>

Thanks in advance.

Link to comment
Share on other sites

i have this installed on osc 2.3 with SPPC. everything seems to working after making multitudes of fixes (since this is NOT 2.3 ready by far) , but when a product is added to the permanent cart and then they log out and back in it removes the item from the cart. i have narrowed the issue to the contribution. seems that when logging back in it is passing a empty quantity in which the cleanup function of shopping_cart.php then removes it becasue it has no quantity. i can see in the database as have quantity, so it has to be a conversion error somewhere. any ideas?

Edited by ecco
Link to comment
Share on other sites

problem fixed. was missing the following line that was omitted because of contribution overlap

 

$this->contents[$_products['products_id']] = array('qty' => $_products['customers_basket_quantity'], 'discount_categories_id' => $_products['discount_categories_id']);

Link to comment
Share on other sites

problem fixed. was missing the following line that was omitted because of contribution overlap

 

$this->contents[$_products['products_id']] = array('qty' => $_products['customers_basket_quantity'], 'discount_categories_id' => $_products['discount_categories_id']);

 

Now the problem has been fixed are you planning on releasing this as an addon so others can use it.

REMEMBER BACKUP, BACKUP AND BACKUP

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...

for oscommerce 2.3.1 dont use the instructions for the manual installation, there are many errors in this one.

The best way is to compare your files with those givens with the module, you should remplace all lines commented by "BOF qpbpp 2.0" search for it.

 

and finally open the file "discount_categories.php" delete all the code and copy the code bellow and everything should work fine...

 

<?php
/*
 $Id: catalog/admin/discount_categories.php v1.0 2007/12/02
 for a modification of Quantity Price Breaks Per Product (http://addons.oscommerce.com/info/1242)
 parts used of Quick Price Updates (http://addons.oscommerce.com/info/122)

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

 Copyright (c) 2007 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');


 if (isset($_GET['row_by_page'])) {
  $row_by_page = (int)$_GET['row_by_page'];
  }
 if (isset($_GET['manufacturer'])) {
  $manufacturer = (int)$_GET['manufacturer'];
 }
 if (isset($_GET['dcID']) && is_numeric($_GET['dcID'])) {
  $dcID = (int)$_GET['dcID'];
 } elseif (isset($_GET['dcID']) && $_GET['dcID'] == 'all') {
  $dcID = 'all';
 }
 if (isset($_GET['cPath'])) {
$current_category_id = (int)$_GET['cPath'];
 } else {
$current_category_id = 0;
 }

// Displays the list of manufacturers
 function manufacturers_list(){
	global $manufacturer;

	$manufacturers_query = tep_db_query("select m.manufacturers_id, m.manufacturers_name from " . TABLE_MANUFACTURERS . " m order by m.manufacturers_name ASC");
	$return_string = '<select name="manufacturer" onChange="this.form.submit();">';
	$return_string .= '<option value="' . 0 . '">' . TEXT_ALL_MANUFACTURERS . '</option>';
	while($manufacturers = tep_db_fetch_array($manufacturers_query)){
			$return_string .= '<option value="' . $manufacturers['manufacturers_id'] . '"';
			if($manufacturer && $manufacturers['manufacturers_id'] == $manufacturer) $return_string .= ' SELECTED';
			$return_string .= '>' . $manufacturers['manufacturers_name'] . '</option>';
	}
	$return_string .= '</select>';
	return $return_string;
 }

 function discount_categories_list() {
	global $dcID;

	$discount_categories_query = tep_db_query("select * from " . TABLE_DISCOUNT_CATEGORIES . "  order by discount_categories_id");

	$return_string = '<select name="dcID" onChange="this.form.submit();">';
	$return_string .= '<option value="all" ' . ($dcID == "all" ? " SELECTED" : "") . '>' . TEXT_ALL_DISCOUNT_CATEGORIES . '</option>';
	$return_string .= '<option value="0" ' . ($dcID == "0" ? " SELECTED" : "") . '>' . TEXT_NONE . '</option>';		
	while ($discount_categories = tep_db_fetch_array($discount_categories_query)) {
			$return_string .= '<option value="' . $discount_categories['discount_categories_id'] . '"';
			if($dcID && $discount_categories['discount_categories_id'] == $dcID) $return_string .= ' SELECTED';
			$return_string .= '>' . (strlen($discount_categories['discount_categories_name']) > 70 ? substr($discount_categories['discount_categories_name'], 0, 69) . '...': $discount_categories['discount_categories_name']) . '</option>';
	}
	$return_string .= '</select>';
	return $return_string;
}

 function discount_categories_drop_down($discount_categories, $p_dcID = 0, $pid) {

	$return_string = '<select name="pdcID[' . $pid . ']">';
	$return_string .= '<option value="0" ' . ((int)$p_dcID == 0 ? " SELECTED" : "") . '>' . TEXT_NONE . '</option>';		
	foreach ($discount_categories as $key => $name) {
			$return_string .= '<option value="' . $key . '"';
			if($key == $p_dcID) $return_string .= ' SELECTED';
			$return_string .= '>' . (strlen($name) > 70 ? substr($name, 0, 69) . '...': $name) . '</option>';
	}
	$return_string .= '</select>';
	return $return_string;
 }

 $action = (isset($_GET['action']) ? $_GET['action'] : '');

 if (tep_not_null($action)) {
switch ($action) {

  case 'update':
	$error = false;
  	   $discount_categories_id = (int)$_GET['dcID'];
   	 $discount_categories_name = tep_db_prepare_input($_POST['discount_categories_name']);

	tep_db_query("update " . TABLE_DISCOUNT_CATEGORIES . " set discount_categories_name='" . tep_db_input($discount_categories_name) . "' where discount_categories_id = '" . $discount_categories_id ."'");
	tep_redirect(tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('dcID', 'action')) . 'dcID=' . $discount_categories_id));
	break;

  case 'deleteconfirm':
	$discount_categories_id = (int)$_GET['dcID'];
	tep_db_query("delete from " . TABLE_DISCOUNT_CATEGORIES . " where discount_categories_id = '" . $discount_categories_id ."'");
	tep_db_query("delete from " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " where discount_categories_id = '" . $discount_categories_id ."'");  
	tep_redirect(tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('dcID', 'action'))));
	break;

  case 'newconfirm' :
	$discount_categories_name = tep_db_prepare_input($_POST['discount_categories_name']);

	$last_id_query = tep_db_query("select MAX(discount_categories_id) as last_dc_id from " . TABLE_DISCOUNT_CATEGORIES . "");
	$last_dc_id_inserted = tep_db_fetch_array($last_id_query);
	$new_dc_id = $last_dc_id_inserted['last_dc_id'] +1;
	tep_db_query("insert into " . TABLE_DISCOUNT_CATEGORIES . " set discount_categories_id = '" . $new_dc_id . "', discount_categories_name = '" . tep_db_input($discount_categories_name) . "'");
	tep_redirect(tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('action'))));
	break;
}
 }

 $do = (isset($_GET['do']) ? $_GET['do'] : '');

 if (tep_not_null($do)) {
switch ($do) {

  case 'update':
	foreach ($_POST['pdcID'] as $pid => $new_discount_category) {
	  if (isset($_POST['pdcID_old'][$pid])) {
		$discount_category_result = qpbpp_insert_update_discount_cats($pid, (int)$_POST['pdcID_old'][$pid], $new_discount_category);
		if ($discount_category_result == false) {
		$messageStack->add(ERROR_UPDATE_INSERT_DISCOUNT_CATEGORY, 'error');
		}
	  }
	} // end foreach ($_POST['pdcID'] as $pid => $new_discount_category)
	break;
}
 }

require(DIR_WS_INCLUDES . 'template_top.php');
?>
<table border="0" width="100%" cellspacing="2" cellpadding="2">
 <tr>
<!-- body_text //-->
<td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">

<?php
 if ($_GET['action'] == 'edit') {
$discount_categories_query = tep_db_query("select * from " . TABLE_DISCOUNT_CATEGORIES . "  where discount_categories_id = '" . $_GET['dcID'] . "'");
$discount_categories = tep_db_fetch_array($discount_categories_query);
$cInfo = new objectInfo($discount_categories);
?>

<script language="javascript" type="text/javascript"><!--
function check_form() {
 var error = 0;

 var discount_categories_name = document.discount_categories.discount_categories_name.value;

 if (discount_categories_name == "") {
error_message = "<?php echo ERROR_DISCOUNT_CATEGORIES_NAME; ?>";
error = 1;
 }

 if (error == 1) {
alert(error_message);
return false;
 } else {
return true;
 }
}
//--></script>

  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
		<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>

  <tr><?php echo tep_draw_form('discount_categories', FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('action')) . 'action=update', 'post', 'onsubmit="return check_form();"'); ?>
	<td class="main"><?php echo ENTRY_DISCOUNT_CATEGORIES_NAME; ?></td>
  </tr>
  <tr>
	<td class="formArea"><table border="0" cellspacing="2" cellpadding="2">
	  <tr>
		<td class="main"><?php echo TABLE_HEADING_DISCOUNT_CATEGORIES_ID; ?></td>
		<td class="main"><?php echo '<b>' . TABLE_HEADING_DISCOUNT_CATEGORIES_NAME . '</b>' . ENTRY_DISCOUNT_CATEGORIES_NAME_MAX_LENGTH; ?></td>
	  </tr>
	  <tr>
		<td class="main"><?php echo '<b>' . $cInfo->discount_categories_id . '</b>'; ?></td>
		<td class="main"><?php echo tep_draw_input_field('discount_categories_name', $cInfo->discount_categories_name, 'maxlength="255" size="70"', false); ?></td>
	  </tr>
   </table></td>
  </tr>
  <tr>
	<td style="padding-top: 10px;" align="right" class="main"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('action','dcID'))) .'">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
  </tr>
  </form>

  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '70'); ?></td>
  </tr>

<?php
 } elseif ($_GET['action'] == 'new') {  
?>
<script language="javascript" type="text/javascript"><!--
function check_form() {
 var error = 0;

 var discount_categories_name = document.discount_categories.discount_categories_name.value;

 if (discount_categories_name == "") {
error_message = "<?php echo ERROR_DISCOUNT_CATEGORIES_NAME; ?>";
error = 1;
 }

 if (error == 1) {
alert(error_message);
return false;
 } else {
return true;
 }
}
//--></script>

  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
		<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
  </tr>
  <tr><?php echo tep_draw_form('discount_categories', FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('action')) . 'action=newconfirm', 'post', 'onsubmit="return check_form();"'); ?>
	<td class="main"><?php echo HEADING_TITLE_NEW_DISCOUNT_CATEGORIES_NAME; ?></td>
  </tr>
  <tr>
	<td class="formArea"><table border="0" cellspacing="2" cellpadding="2">
	  <tr>
		<td class="main"><?php echo '<b>' . TABLE_HEADING_NEW_DISCOUNT_CATEGORIES_NAME . '</b>' . ENTRY_DISCOUNT_CATEGORIES_NAME_MAX_LENGTH; ?></td>
	  </tr>
	  <tr>
		<td class="main"><?php echo tep_draw_input_field('discount_categories_name', '', 'maxlength="255" size="70"', false); ?></td>
	  </tr>
   </table></td>
  </tr>
  <tr>
	<td style="padding-top: 10px;" align="right" class="main"><?php echo tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('action','dcID'))) .'">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>'; ?></td>
  </tr>
  </form>
<?php
 } elseif ($_GET['action'] == 'show_products') {  // end action=new

($row_by_page) ? define('MAX_DISPLAY_ROW_BY_PAGE' , $row_by_page ) : $row_by_page = MAX_DISPLAY_SEARCH_RESULTS; define('MAX_DISPLAY_ROW_BY_PAGE' , MAX_DISPLAY_SEARCH_RESULTS );

// define the steps for the dropdown menu max rows per page
  for ($i = 10; $i <= 100 ; $i = $i+5) {
 if ($row_by_page < 10 && $i == 10) {
   $row_bypage_array[] = array('id' => $row_by_page, 'text' => $row_by_page);
 }
  $row_bypage_array[] = array('id' => $i, 'text' => $i);
 if ($row_by_page > 10 && $row_by_page%5 !== 0) {
   if (($i < $row_by_page) && ($i+5 > $row_by_page)) {
	 $row_bypage_array[] = array('id' => $row_by_page, 'text' => $row_by_page);
   }
 }	
  } // end for ($i = 10; $i <= 100 ; $i = $i+5)

// populate array of discount categories for each with dropdowns in products
 $get_discount_categories_query = tep_db_query("select discount_categories_id, discount_categories_name from " . TABLE_DISCOUNT_CATEGORIES . "  order by discount_categories_name");
 $get_discount_categories = array();
 while ($_get_discount_categories = tep_db_fetch_array($get_discount_categories_query)) {
$get_discount_categories[$_get_discount_categories['discount_categories_id']] = $_get_discount_categories['discount_categories_name'];
 }
?>
  <tr style="margin-bottom: 10px">
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td class="pageHeading"><?php echo HEADING_TITLE_PRODUCTS_TO_DISCOUNT_CATEGORIES; ?></td>
		<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><table width="100%" cellspacing="0" cellpadding="0" border="0">
	<tr class="formArea" align="center" style="margin-top: 6px; margin-bottom: 6px;">
	  <td class="smalltext" style="padding-left: 2px; padding-right: 2px; padding-top: 6px; padding-bottom: 6px; border-left: 1px solid #7b9ebd; border-top: 1px solid #7b9ebd"><?php echo TEXT_MAXI_ROW_BY_PAGE; ?></td>
	  <td class="smalltext" style="border-top: 1px solid #7b9ebd"><?php echo DISPLAY_CATEGORIES; ?></td>
	  <td class="smalltext" style="border-top: 1px solid #7b9ebd"><?php echo DISPLAY_MANUFACTURERS; ?></td>
	  <td class="smalltext" style="border-top: 1px solid #7b9ebd; border-right: 1px solid #7b9ebd"><?php echo DISPLAY_DISCOUNT_CATEGORIES; ?></td>		
	</tr>
<tr class="formArea" align="center">
 <td class="smallText" style="border-left: 1px solid #7b9ebd"><?php echo tep_draw_form('row_by_page', FILENAME_DISCOUNT_CATEGORIES, '', 'get');
 echo tep_draw_hidden_field( 'action', 'show_products');
 echo tep_draw_hidden_field( 'dcID', $dcID);
 echo tep_draw_hidden_field( 'manufacturer', $manufacturer);
 echo tep_draw_hidden_field( 'cPath', $current_category_id) . tep_draw_pull_down_menu('row_by_page', $row_bypage_array, $row_by_page, 'onChange="this.form.submit();"'); ?><?php echo tep_hide_session_id(); ?></form></td>
  <td class="smallText" align="center" valign="top"><?php echo tep_draw_form('categorie', FILENAME_DISCOUNT_CATEGORIES, '', 'get');
  echo tep_draw_hidden_field( 'action', 'show_products');
  echo tep_draw_hidden_field( 'dcID', $dcID);
  echo tep_draw_hidden_field( 'row_by_page', $row_by_page);
  echo tep_draw_hidden_field( 'manufacturer', $manufacturer);
  echo tep_draw_pull_down_menu('cPath', tep_get_category_tree(), $current_category_id, 'onChange="this.form.submit();"'); ?><?php echo tep_hide_session_id(); ?></form></td>
 <td class="smallText" align="center" valign="top"><?php echo tep_draw_form('manufacturers', FILENAME_DISCOUNT_CATEGORIES, '', 'get');
 echo tep_draw_hidden_field( 'action', 'show_products');
 echo tep_draw_hidden_field( 'dcID', $dcID);
 echo tep_draw_hidden_field( 'row_by_page', $row_by_page);
 echo tep_draw_hidden_field( 'cPath', $current_category_id);
 echo manufacturers_list(); ?><?php echo tep_hide_session_id(); ?></form></td>
 <td class="smallText" align="center" valign="top" style="border-right: 1px solid #7b9ebd;"><?php echo tep_draw_form('discount_categorie', FILENAME_DISCOUNT_CATEGORIES, '', 'get');
 echo tep_draw_hidden_field( 'action', 'show_products');
 echo tep_draw_hidden_field( 'row_by_page', $row_by_page);
 echo tep_draw_hidden_field( 'manufacturer', $manufacturer);
 echo tep_draw_hidden_field( 'cPath', $current_category_id);
 echo discount_categories_list(); ?><?php echo tep_hide_session_id(); ?></form></td>
</tr>
<tr class="formArea"><td colspan="4" style="border-left: 1px solid #7b9ebd; border-right: 1px solid #7b9ebd; border-bottom: 1px solid #7b9ebd"><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td></tr>
   </table>
 </td>
  </tr>
<?php  // control rows per page
 $split_page = (int)$_GET['page'];
 if ($split_page > 1) $rows = $split_page * MAX_DISPLAY_ROW_BY_PAGE - MAX_DISPLAY_ROW_BY_PAGE;

//  select categories
 if (is_int($dcID) && $dcID > 0) {
$select_dcID = " and ptdc.discount_categories_id = '" . $dcID . "' ";
 } elseif (is_int($dcID) && $dcID == 0) {
 $select_dcID = " and ptdc.discount_categories_id IS NULL ";
 } elseif ($dcID == "all") {
 $select_dcID = " "; // all discount categories
 }

// control string sort page
 if (isset($_GET['sort_by']) && !ereg('order by', $_GET['sort_by'])) {
	  switch ($_GET['sort_by']) {
		  case "pid":
		  $order = " order by p.products_id";
		  break;
		  case "pid-desc":
		  $order = " order by p.products_id DESC";
		  break;
		  case "model":
		  $order = " order by p.products_model";
		  break;
		  case "model-desc":
		  $order = " order by p.products_model DESC";
		  break;
		  case "name":
		  $order = " order by pd.products_name";
		  break;
		  case "name-desc":
		  $order = " order by pd.products_name DESC";
		  break;
		  default:
		  $order = " order by p.products_id";
	  }
 }

 if ($current_category_id == 0) {
	  if($manufacturer != 0){
		$products_query_raw = "select p.products_id, p.products_model, pd.products_name, p.products_status, p.manufacturers_id, ptdc.discount_categories_id from  " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION .  " pd left join " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " ptdc using(products_id) where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = '" . $manufacturer . "' $select_dcID $order";
	  } else {
		$products_query_raw = "select p.products_id, p.products_model, pd.products_name, p.products_status, p.manufacturers_id, ptdc.discount_categories_id from  " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION .  " pd left join " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " ptdc using(products_id) where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' $select_dcID $order";
	}
 } // end if ($current_category_id == 0)
 else {
	 if ($manufacturer != 0) {
			 $products_query_raw = "select p.products_id, p.products_model, pd.products_name, p.products_status, p.manufacturers_id, ptdc.discount_categories_id from  " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION .  " pd left join " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " ptdc using(products_id), " . TABLE_PRODUCTS_TO_CATEGORIES . " pc where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = pc.products_id and pc.categories_id = '" . $current_category_id . "' and p.manufacturers_id = '" . $manufacturer . "' $select_dcID $order";
	  } else {
			$products_query_raw = "select p.products_id, p.products_image, p.products_model, pd.products_name, p.products_status, p.manufacturers_id, ptdc.discount_categories_id from  " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION .  " pd left join " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " ptdc using(products_id), " . TABLE_PRODUCTS_TO_CATEGORIES . " pc where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = pc.products_id and pc.categories_id = '" . $current_category_id . "' $select_dcID $order";
	}
 }

//// page splitter and display each products info
 $products_split = new splitPageResults($split_page, MAX_DISPLAY_ROW_BY_PAGE, $products_query_raw, $products_query_numrows);
 $products_query = tep_db_query($products_query_raw);

 if ($products_query_numrows > 0) {
?>
<!-- table products to discount categories -->
  <tr>
	<td valign="top"><?php echo tep_draw_form('ptodcats', FILENAME_DISCOUNT_CATEGORIES, 'page=' . $split_page . '&row_by_page=' . $row_by_page . '&manufacturer=' . $manufacturer . '&dcID=' . $dcID . '&action=show_products&cPath=' . $current_category_id . '&do=update', 'post') . "\n"; ?>
	<table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr class="dataTableHeadingRow">
		<td class="dataTableHeadingContent"><a href="<?php echo tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('sort_by','do')) . 'sort_by=pid'); ?>"><?php echo tep_image(DIR_WS_IMAGES . 'icon_up.gif', SORT_BY_PRODUCTS_ID_ASC); ?></a> <a href="<?php echo tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('sort_by','do')) . 'sort_by=pid-desc'); ?>"><?php echo tep_image(DIR_WS_IMAGES . 'icon_down.gif', SORT_BY_PRODUCTS_ID_DESC); ?></a><br><?php echo TABLE_HEADING_PRODUCTS_ID; ?></td>
		<td class="dataTableHeadingContent"><a href="<?php echo tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('sort_by','do')) . 'sort_by=model'); ?>"><?php echo tep_image(DIR_WS_IMAGES . 'icon_up.gif', SORT_BY_PRODUCTS_MODEL_ASC); ?></a> <a href="<?php echo tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('sort_by')) . 'sort_by=model-desc'); ?>"><?php echo tep_image(DIR_WS_IMAGES . 'icon_down.gif', SORT_BY_PRODUCTS_MODEL_DESC); ?></a><br><?php echo TABLE_HEADING_MODEL; ?></td>
		<td class="dataTableHeadingContent"><a href="<?php echo tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('sort_by','do')) . 'sort_by=name'); ?>"><?php echo tep_image(DIR_WS_IMAGES . 'icon_up.gif', SORT_BY_PRODUCTS_NAME_ASC); ?></a> <a href="<?php echo tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('sort_by','do')) . 'sort_by=name-desc'); ?>"><?php echo tep_image(DIR_WS_IMAGES . 'icon_down.gif', SORT_BY_PRODUCTS_NAME_DESC); ?></a><br><?php echo TABLE_HEADING_NAME; ?></td>
		<td class="dataTableHeadingContent" align="center" valign="bottom"><?php echo TABLE_HEADING_STATUS; ?></td>
		<td class="dataTableHeadingContent" valign="bottom"><?php echo TABLE_HEADING_DISCOUNT_CATEGORY; ?></td>
		<td class="dataTableHeadingContent" valign="bottom"><?php echo TABLE_HEADING_ACTION; ?></td>
	  </tr>

<?php
while ($products = tep_db_fetch_array($products_query)) {
  echo '		<tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">' . "\n";
  echo '		 <td class="dataTableContent">' . $products['products_id'] . tep_draw_hidden_field('pdcID_old['. $products['products_id'] .']', (int)$products['discount_categories_id']) . '</td>' . "\n";
  echo '		 <td class="dataTableContent">' . $products['products_model'] . '</td>' . "\n";
  echo '		 <td class="dataTableContent">' . $products['products_name'] . '</td>' . "\n";
  echo '		 <td class="dataTableContent" align="center">';
  if ($products['products_status'] == '1') {
	echo tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', DC_ICON_STATUS_GREEN_LIGHT, 10, 10);
  } else {
	echo tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', DC_ICON_STATUS_RED_LIGHT, 10, 10);
  }
  echo '</td>' . "\n";
  echo '		 <td class="dataTableContent">' . discount_categories_drop_down($get_discount_categories, $products['discount_categories_id'], $products['products_id']) . '</td>' . "\n";
 echo '		 <td class="dataTableContent" align="right"><a href="' . tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products['products_id'] . '&action=new_product') . '">' . tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', TEXT_IMAGE_SWITCH_EDIT) . '</a></td>' . "\n";
  echo '		</tr>' . "\n";
} // end while ($products = tep_db_fetch_array($products_query))
?>
  <tr>
	<td colspan="3" align="left" style="padding-top: 6px;" class="smallText"><a href="<?php echo tep_href_link(FILENAME_DISCOUNT_CATEGORIES) . '">';
	echo TEXT_BACK_TO_DISCOUNT_CATEGORIES; ?></a></td>
	<td colspan="3" align="right" style="padding-top: 6px;">
<?php
// display bottom page buttons
		  echo tep_image_submit('button_update.gif', IMAGE_UPDATE);
		  echo '  <a href="' . tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('action','do','x','y')) . 'action=show_products') . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>';
?></td>
  </tr>
	</table>
   </form></td>
  </tr><!-- end table products to discount categories/begin navigation to other result pages -->
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		 <td class="smallText" valign="top"><?php echo $products_split->display_count($products_query_numrows, MAX_DISPLAY_ROW_BY_PAGE, $split_page, TEXT_DISPLAY_NUMBER_OF_PRODUCTS);  ?></td>
			<td class="smallText" align="right"><?php echo $products_split->display_links($products_query_numrows, MAX_DISPLAY_ROW_BY_PAGE, MAX_DISPLAY_PAGE_LINKS, $split_page, tep_get_all_get_params(array('page', 'do', 'x', 'y'))); ?></td>
		  </tr>
		</table></td>
   </tr>
<?php
 } else { // end if ($products_query_numrows > 0)
?>
  <tr>
  <td class="main" style="margin-top: 6px;"><?php echo TEXT_NO_PRODUCTS; ?></td>
 </tr>
<?php	
 } // if/else ($products_query_numrows > 0)
 } else { // end action=show_products
?>

  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr><?php echo tep_draw_form('search', FILENAME_DISCOUNT_CATEGORIES, '', 'get'); ?>
		<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
		<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
		<td class="smallText" align="right"><?php echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('search'); ?></td>
	  </form></tr>
	</table></td>
  </tr>
  <tr>

	  <?php
	  switch ($_GET['listing']) {
		  case "dc":
		  $order = "dc.discount_categories_name";
		  break;
		  case "dc-desc":
		  $order = "dc.discount_categories_name DESC";
		  break;
		  case "id":
		  $order = "dc.discount_categories_id";
		  break;
		  case "id-desc":
		  $order = "dc.discount_categories_id DESC";
		  break;
		  default:
		  $order = "dc.discount_categories_name ASC";
	  }
	  ?>
  	 <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
		   <tr class="dataTableHeadingRow">
  		<td class="dataTableHeadingContent" width="10%"><a href="<?php echo basename($_SERVER['PHP_SELF']) . '?listing=id'; ?>"><?php echo tep_image(DIR_WS_IMAGES . 'icon_up.gif', ' Sort ' . TABLE_HEADING_ID . ' --> 1-2-3 From Top '); ?></a> <a href="<?php echo basename($_SERVER['PHP_SELF']) . '?listing=id-desc'; ?>"><?php echo tep_image(DIR_WS_IMAGES . 'icon_down.gif', ' Sort ' . TABLE_HEADING_ID . ' --> 3-2-1 From Top '); ?></a><br><?php echo TABLE_HEADING_ID; ?></td>
  		<td class="dataTableHeadingContent"><a href="<?php echo basename($_SERVER['PHP_SELF']) . '?listing=dc'; ?>"><?php echo tep_image(DIR_WS_IMAGES . 'icon_up.gif', ' Sort ' . TABLE_HEADING_NAME . ' --> A-B-C From Top '); ?></a> <a href="<?php echo basename($_SERVER['PHP_SELF']) . '?listing=dc-desc'; ?>"><?php echo tep_image(DIR_WS_IMAGES . 'icon_down.gif', ' Sort ' . TABLE_HEADING_NAME . ' --> Z-X-Y From Top '); ?></a><br><?php echo TABLE_HEADING_NAME; ?></td>
			   <td class="dataTableHeadingContent" align="right" valign="bottom"><?php echo TABLE_HEADING_ACTION; ?> </td>
		   </tr>

<?php
$search = '';
if ( ($_GET['search']) && (tep_not_null($_GET['search'])) ) {
  $keywords = tep_db_input(tep_db_prepare_input($_GET['search']));
  $search = "where dc.discount_categories_name like '%" . $keywords . "%'";
}

$discount_categories_query_raw = "select dc.discount_categories_id, dc.discount_categories_name from " . TABLE_DISCOUNT_CATEGORIES . " dc  " . $search . " order by $order";
$discount_categories_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $discount_categories_query_raw, $discount_categories_query_numrows);
$discount_categories_query = tep_db_query($discount_categories_query_raw);

while ($discount_categories = tep_db_fetch_array($discount_categories_query)) {
  if ((!isset($_GET['dcID']) || (@$_GET['dcID'] == $discount_categories['discount_categories_id'])) && (!$cInfo)) {
	$cInfo = new objectInfo($discount_categories);
  }

  if ( (is_object($cInfo)) && isset($_GET['dcID']) && ($discount_categories['discount_categories_id'] == $cInfo->discount_categories_id) ) {
	echo '		  <tr class="dataTableRowSelected" onmouseover="this.style.cursor=\'hand\'" onclick="document.location.href=\'' . tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('dcID', 'action')) . 'dcID=' . $cInfo->discount_categories_id . '&action=edit') . '\'">' . "\n";
  } else {
	echo '		  <tr class="dataTableRow" onmouseover="this.className=\'dataTableRowOver\';this.style.cursor=\'hand\'" onmouseout="this.className=\'dataTableRow\'" onclick="document.location.href=\'' . tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('dcID')) . 'dcID=' . $discount_categories['discount_categories_id']) . '\'">' . "\n";
  }
?>
			<td class="dataTableContent"><?php echo $discount_categories['discount_categories_id']; ?></td>
			<td class="dataTableContent"><?php echo $discount_categories['discount_categories_name']; ?></td>
			<td class="dataTableContent" align="right"><?php if ( (is_object($cInfo)) && isset($_GET['dcID']) && ($discount_categories['discount_categories_id'] == $cInfo->discount_categories_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('dcID')) . 'dcID=' . $discount_categories['discount_categories_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>
		  </tr>
<?php
} // end while ($discount_categories = tep_db_fetch_array($discount_categories_query))
?>
		  <tr>
			<td colspan="4"><table border="0" width="100%" cellspacing="0" cellpadding="2">
			  <tr>
				<td class="smallText" valign="top"><?php echo $discount_categories_split->display_count($discount_categories_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_DISCOUNT_CATEGORIES); ?></td>
				<td class="smallText" align="right"><?php echo $discount_categories_split->display_links($discount_categories_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y', 'dcID'))); ?></td>
			  </tr>
<?php
if (tep_not_null($_GET['search'])) {
?>
			  <tr>
				<td align="right" colspan="2"><?php echo '<a href="' . tep_href_link(FILENAME_DISCOUNT_CATEGORIES) . '">' . tep_image_button('button_reset.gif', IMAGE_RESET) . '</a>'; ?></td>
			  </tr>
<?php
} else {
?>
	   	   <tr>
				<td align="right" colspan="2" class="smallText"><?php echo '<a href="' . tep_href_link(FILENAME_DISCOUNT_CATEGORIES, 'page=' . $_GET['page'] . '&action=new') . '">' . tep_image_button('button_insert.gif', IMAGE_INSERT) . '</a>'; ?></td>
			  </tr>
<?php
}
?>
			</table></td>
		  </tr>
		</table></td>
<?php
 $heading = array();
 $contents = array();
 switch ($_GET['action']) {
case 'confirm':
	if ($_GET['dcID'] != '0') {
		$heading[] = array('text' => ''. tep_draw_separator('pixel_trans.gif', '11', '12') .' <br><b>' . TEXT_INFO_HEADING_DELETE_DISCOUNT_CATEGORY . '</b>');
		$contents = array('form' => tep_draw_form('discount_categories', FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('dcID', 'action')) . 'dcID=' . $cInfo->discount_categories_id . '&action=deleteconfirm'));
		$contents[] = array('text' => TEXT_DELETE_INTRO . '<br><br><b>' . $cInfo->discount_categories_name . ' </b>');
	/*	if ($cInfo->number_of_reviews > 0) $contents[] = array('text' => '<br>' . tep_draw_checkbox_field('delete_reviews', 'on', true) . ' ' . sprintf(TEXT_DELETE_REVIEWS, $cInfo->number_of_reviews)); */
		$contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('dcID', 'action')) . 'dcID=' . $cInfo->discount_categories_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
	} else {
		$heading[] = array('text' => ''. tep_draw_separator('pixel_trans.gif', '11', '12') .' <br><b>' . TEXT_INFO_HEADING_DELETE_DISCOUNT_CATEGORY . '</b>');
		$contents[] = array('text' => ERROR_DISCOUNT_CATEGORIES_ID . '<br><br><b>' . $cInfo->discount_categories_name . ' </b>');
	}
  break;
default:
  if (is_object($cInfo) && isset($_GET['dcID'])) {
	$heading[] = array('text' => ''. tep_draw_separator('pixel_trans.gif', '11', '12') .' <br><b>' . $cInfo->discount_categories_name . '</b>');
	$contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('dcID', 'action')) . 'dcID=' . $cInfo->discount_categories_id . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('dcID', 'action')) . 'dcID=' . $cInfo->discount_categories_id . '&action=confirm') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
	$contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_DISCOUNT_CATEGORIES, tep_get_all_get_params(array('dcID', 'action', 'page')) . 'dcID=' . $cInfo->discount_categories_id . '&action=show_products') . '">' . tep_image_button('button_show_products.gif', IMAGE_SHOW_PRODUCTS) . '</a>');

  }
  break;
 }

 if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
echo '			<td width="25%" valign="top">' . "\n";

$box = new box;
echo $box->infoBox($heading, $contents);

echo '			</td>' . "\n";
 }
?>
	  </tr>
	</table></td>
  </tr>
<?php
 }
?>
</table></td>
<!-- body_text_eof //-->
 </tr>
</table>
<!-- body_eof //-->

<?php
 require(DIR_WS_INCLUDES . 'template_bottom.php');
 require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

 

and THANKS for this module that works fine for me !

Edited by thinkbig
Link to comment
Share on other sites

  • 1 month later...

Problem with implementing Canada Post to QPBPP due to modifications in shopping_cart.php.

What I need to insert is the following:

 

(from Canada Post module upgrade notes applied to shopping_cart.php) Find:

 

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

 

(from Canada Post module upgrade notes applied to shopping_cart.php) Replace with (added bits are underlined):

 

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_length, p.products_width, p.products_height, p.products_ready_to_ship, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

 

However, QPBPP has changed the first section to:

 

$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);

 

and I am at a loss how to insert the needed dimensions (these are passed to Canada Post so it can figure out the correct box size) of 'length, width, height', and it also appears that this QPBPP breaks the 'ready_to_ship' (used by Fedex and UPS modules).

 

I have been using this short log script to see what is saved: (I put it at the end of the $products_array coding):

 

file_put_contents('log.txt', print_r($products_array, true)); (saves the variable $xxx values in the text file - handy!)

 

And I am getting the following log:

 

Array

(

[0] => Array

(

[id] => 43

[name] => Addams Family Ramp

[model] => Ramp_TAF_Clear

 => Ramp_TAF_Clear

[image] => ramps/taf1s.jpg

[discount_categories_id] =>

[price] => 149.0000

[quantity] => 1

[weight] => 0.800

[length] =>

[width] =>

[height] =>

[ready_to_ship] =>

[final_price] => 149

[tax_class_id] => 1

[products_ship_price] =>

[products_ship_price_two] =>

[products_ship_zip] =>

[attributes] =>

)

 

)[/b]

 

Note the blank values for length, width, etc.

 

If I use the default version of shopping_cart.php (2.3.1) and insert the above section then I get the correct log file:

 

[b]Array

(

[0] => Array

(

[id] => 43

[name] => Addams Family Ramp

[model] => Ramp_TAF_Clear

[image] => ramps/taf1s.jpg

[price] => 149.0000

[quantity] => 1

[weight] => 0.800

[length] => 61.00

[width] => 30.00

[height] => 15.00

[ready_to_ship] => 0

[final_price] => 149

[tax_class_id] => 1

[attributes] =>

)

 

)[/b]

 

Anyone have a suggestion how I can integrate those essential values into QPBPP?

 

Thanks!

Edited by Pinball
Link to comment
Share on other sites

  • 1 month later...

Hi everyone, I'm trying to combine SPPC and QPBPP in a fresh install of 2.3.3 and I'm having a few issues in modules/product_listing and admin/categories... Hoping someone can help.

 

In product_listing I can't get pricing to show... I'm having problems merging these lines:

 

2.3.3

         case 'PRODUCT_LIST_PRICE':
           if (tep_not_null($listing[$x]['specials_new_products_price'])) {
             $prod_list_contents .= '        <td align="right"><del>' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</del>  <span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span></td>';
           } else {
             $prod_list_contents .= '        <td align="right">' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</td>';
           }

 

SPPC QPBPP code... Obviously its not right... However, I'm no coder, and just don't understand the syntax... So I'm a bit lost....

 

// BOF QPBPP for SPPC
           $price_breaks_from_listing = array();
           if (isset($price_breaks_array[$listing[$x]['products_id']])) {
             $price_breaks_from_listing = $price_breaks_array[$listing[$x]['products_id']];
           }
           $pf->loadProduct($listing[$x]['products_id'], $languages_id, $listing[$x], $price_breaks_from_listing);
           $lc_text = $pf->getPriceStringShort();
// EOF QPBPP for SPPC

 

If anyone can help merge these 2 lines I would greatly appreciate it...

 

Then in admin/categories I get the following error...

 

Warning: reset() function.reset]: Passed variable is not an array or object in /public_html/something/admin_directory/includes/classes/object_info.php on line 17

 

Warning: Variable passed to each() is not an array or object in /public_html/something/admin_directory/includes/classes/object_info.php on line 18

 

I see objectinfo called at least 6 times in admin/categories... but have no idea where to start. Funny... The admin/categories still seems to work, when I go to edit a product the error disappears and only comes back when I click on categores/products in column left (or whatever its called now).

 

Scott

Edited by Jan Zonjee
Link to comment
Share on other sites

  • 1 month later...

I successfully installed the Quantity Price Break on my site, and a couple of interesting things happened that I want to fix.

 

As a default, it's letting me leave pricing for 1 item+. I'd like to omit the price of the item at 1, and then just go to my table, how do I do this?

 

Also, when I've been testing, it randomly changes the number of actual products in the shopping cart, for instance, I typed in 100, and it put 105. Why is it doing this and how can I fix it?

 

Lastly, which might be the easiest question, ha, how do I change the positioning of this table from being at the top of the product listing?

 

 

 

Thanks for all of your help, I am relatively new and any help would be most appreciated!

Link to comment
Share on other sites

Hello all,

 

I have downloaded this add-on ready to use and have one question about it..

 

Is there a way to have the discount as a set number rather than a percentage?

 

Example - If someone buys more than 3 items take off 20p per item rather than whatever percent?

 

Cheers,

Link to comment
Share on other sites

I've been running QPBB with success, but also have the ability for text attributes. Here's what happens:

 

Example:

Customer can enter text option of "names" into a text box. If they enter them with spaces, separated by an ampersand, etc. all goes well. If they enter them separated by a comma, ERROR. I get a 1054 column not found error. I thought it might be caused by the joins and needing to edit those for PHP 5, but still cannot get it to work.

 

For some reason, it's taking the second name (that follows the comma) and combining it with product_id.

 

Original select code in includes/classes/PriceFormatter.php:

 $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_qty_blocks, p.products_tax_class_id," .
" IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price," .
" ptdc.discount_categories_id from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on " .
" p.products_id = s.products_id left join " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " ptdc on " .
" p.products_id = ptdc.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 ."'";

 

 

Here's a sample error - note that "mary" which was the second name the customer entered is combined with product_id (see end section of code):

1054 - Unknown column 'mary' in 'where clause'
select pd.products_name, pd.products_packaged_components, p.products_model, p.products_image, p.products_id, p.manufacturers_id, p.products_price, p.products_weight, p.products_quantity, p.products_qty_blocks, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, ptdc.discount_categories_id
from products p left join specials s on p.products_id = s.products_id left join products_to_discount_categories ptdc on p.products_id = ptdc.products_id, products_description pd
where p.products_status = '1' and pd.products_id = p.products_id and p.products_id in (3612, mary) and pd.language_id = '1'

 

 

Interesting thing too is that if instead of something like tom, mary being entered and you enter tom, 3 there is no problem. If a number follows the comma, no problem. If a letter follows, there's a problem. It still seems related to the handling of that comma, but I can't figure why.

 

I tried editing the join as follows which inserts parentheses to help with PHP 5 without luck:

 $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_qty_blocks, p.products_tax_class_id," .
" IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price," .
" ptdc.discount_categories_id from ((" . TABLE_PRODUCTS . " p ) left join " . TABLE_SPECIALS . " s on " .
" p.products_id = s.products_id ) left join " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " ptdc on " .
" p.products_id = ptdc.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 ."'";

 

Can anyone offer some insight?

 

Thank you!

Edited by smartwork
Link to comment
Share on other sites

If you are using 2.3 version of oscommerce look here http://addons.oscommerce.com/info/8040/v,23

 

Thanks for that, downloaded and got it working. Next problem is... The products I'm using the add-on for are weighed items (in kilos) rather than individual items, sometimes we get orders through for 500g and other decimal figures. I've tested this with the QPB add-on and it changes the ordered quantity back to the nearest 1..

 

Is there a way to change this at all?

Link to comment
Share on other sites

  • 2 months later...

Hi Matt,

 

I just spent DAYS < <_<> wrestling with moving the price break box from above (what a silly place to put a large box) to just above the "Add to Cart" box. UNFORTUNATELY, unlike the previous version which used a call to "$products_price_qpbpp;", the latest version uses the original "$products_price;". So that means moving the price box to the bottom of the page will also now move the product price (that is originally in the upper right of the screen) to the bottom of the page too. This has been such a headache that, personally, I'm thinking of just trashing the install and doing without it rather than spending who knows how much more time on something that should be super simple. Anyhow, if you still want to move the box to the bottom of the page before the "add to Cart" box, take a look at my table below. It centers the price break box so you won't have to struggle with trying to get the darn thing to align someplace other than right. It's only a short bit but I added more code rather than less to give you a good idea of exactly where the code was placed in catalog/product_info.php. Good luck!

 

In catalog/product_info.php :

   if ($product_info['products_date_available'] > date('Y-m-d H:i:s')) {
?>
  <tr>
    <td align="center" class="smallText"><?php echo sprintf(TEXT_DATE_AVAILABLE, tep_date_long($product_info['products_date_available'])); ?></td>
  </tr>
<?php
   } else {
?>
  <tr>
    <td align="center" class="smallText"><?php echo sprintf(TEXT_DATE_ADDED, tep_date_long($product_info['products_date_added'])); ?></td>
  </tr>
<?php
   }
?>
 <!-- BEGIN EDIT TO MOVE PRICE BREAK BOX TO BOTTOM OF SCREEN-->
 <tr align="center">
	    <td style="text-align: center;">
	    <table style="width: 75%; text-align: left; margin-left: auto; margin-right: auto;" border="0" cellpadding="2" cellspacing="2">
		  <tbody>
		    <tr>
			  <td
style="text-align: center; vertical-align: middle;"><?php echo $products_price; ?></td>
		    </tr>
		  </tbody>
	    </table>
	    </td>
	  </tr>
<!-- END EDIT TO MOVE PRICE BREAK BOX TO BOTTOM OF SCREEN-->
  <tr>
    <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
    <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
	    <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
		    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		    <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
		    <td <?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 ?>

 

 

I successfully installed the Quantity Price Break on my site, and a couple of interesting things happened that I want to fix.

 

As a default, it's letting me leave pricing for 1 item+. I'd like to omit the price of the item at 1, and then just go to my table, how do I do this?

 

Also, when I've been testing, it randomly changes the number of actual products in the shopping cart, for instance, I typed in 100, and it put 105. Why is it doing this and how can I fix it?

 

Lastly, which might be the easiest question, ha, how do I change the positioning of this table from being at the top of the product listing?

 

 

 

Thanks for all of your help, I am relatively new and any help would be most appreciated!

Link to comment
Share on other sites

OK, I found some cheese for my whine. NOW to help anyone else out who has struggled with moving the dang Price Break box to the bottom of the page, I have a SEMI fix. I'm running 2.2RC2A. To move the Price Break box to the bottom of the page above the Add to Cart bar AND keep the price in the upper right of the page where it should be, I did the following.

 

In catalog/product_info.php I changed this:

// BOF qpbpp
   /*
   if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
  $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
   } else {
  $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
   }
   */
   $pf->loadProduct((int)$_GET['products_id'], (int)$languages_id);
   $products_price=$pf->getPriceString();
   // EOF qpbpp

 

to this

// BOF qpbpp

   if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
  $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
   } else {
  $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
   }

   $pf->loadProduct((int)$_GET['products_id'], (int)$languages_id);
   $products_price_qpbpp = $pf->getPriceString();
   // EOF qpbpp

 

In the same file, in order to move the PriceBreak box to the bottom of the page, around line 235 I changed this:

<tr>
    <td align="center" class="smallText"><?php echo sprintf(TEXT_DATE_ADDED, tep_date_long($product_info['products_date_added'])); ?></td>
  </tr>
<?php
   }
?>
  <tr>
    <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
    <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
	    <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
		    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		    <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
		    <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>
		    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

 

to this:

 <tr>
    <td align="center" class="smallText"><?php echo sprintf(TEXT_DATE_ADDED, tep_date_long($product_info['products_date_added'])); ?></td>
  </tr>
<?php
   }
?>
 <!-- BEGIN EDIT TO MOVE PRICE BREAK BOX TO BOTTOM OF SCREEN-->
       <tr align="center">
	    <td style="text-align: center;">
	    <table style="width: 75%; text-align: left; margin-left: auto; margin-right: auto;" border="0" cellpadding="2" cellspacing="2">
		  <tbody>
		    <tr>
			  <td
style="text-align: center; vertical-align: middle;"><?php echo $products_price_qpbpp ?></td>
		    </tr>
		  </tbody>
	    </table>
	    </td>
	  </tr>
   <!-- END EDIT TO MOVE PRICE BREAK BOX TO BOTTOM OF SCREEN-->
  <tr>
    <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
  <tr>
    <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
	  <tr class="infoBoxContents">
	    <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
		    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		    <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?></td>
		    <td <?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 ?>
		    <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

 

The only problem left is the product price STILL shows up at the bottom of the product page whether it has a price break or not. I'm sure what I need to do (when I get some more time) is to find the file that information is being called from and add a statement saying to NOT include a price if the product does not have a price break. I hope this helps someone. Luck!

 

 

Hi Matt,

 

I just spent DAYS < <_<> wrestling with moving the price break box from above (what a silly place to put a large box) to just above the "Add to Cart" box. UNFORTUNATELY, unlike the previous version which used a call to "$products_price_qpbpp;", the latest version uses the original "$products_price;". So that means moving the price box to the bottom of the page will also now move the product price (that is originally in the upper right of the screen) to the bottom of the page too. This has been such a headache that, personally, I'm thinking of just trashing the install and doing without it rather than spending who knows how much more time on something that should be super simple. Anyhow, if you still want to move the box to the bottom of the page before the "add to Cart" box, take a look at my table below. It centers the price break box so you won't have to struggle with trying to get the darn thing to align someplace other than right. It's only a short bit but I added more code rather than less to give you a good idea of exactly where the code was placed in catalog/product_info.php. Good luck!

 

Link to comment
Share on other sites

  • 3 weeks later...

I've added this contribution to my 2.3.3 oscommerce store but have a problem or two. I've got numerous other contributions installed along with this one. The plugin seems to work as expected, followed the install instructions and even compared the files provided to make sure it was right but I just can't seem to get the price break input boxes for the product in admin to appear on the edit product page. Neither can I see the actual price breaks on the product info page. It simply displays the default single price.

 

I've set up new discount categories (not entirely sure what they actually do tbh) and added products to this but when I go to edit the product and set the price blocks, there's no price break option on the product edit page. Can anyone shed any light on this?

 

Is there any other price break contributions that will work with OSC 2.3.3 if this one is not the answer?

Ah, the world wide web. What a wonderful place.

Link to comment
Share on other sites

  • 3 weeks later...

Just installed this on an almost clean version, and I've broken my site! The price break is there, and I can add to my product, however, if you click on a product (as a customer) you get 1146 - Table 'bramaker_brastock.TABLE_PRODUCTS_PRICE_BREAK' doesn't exist

 

select products_id, products_price, products_qty from TABLE_PRODUCTS_PRICE_BREAK where products_id in (28) order by products_id, products_qty

 

[TEP STOP] if the customer clciks on the product already in the cart then I get this: Fatal error: Call to a member function loadProduct() on a non-object in /home/bramaker/public_html/catalog/product_info.php on line 50 sorry about the set out here, the return doesn't respond for some reason! my site - no products yet is at www.bramaker.co.uk/catalog desperately need help, cos only got 1 week to have it up and running!

Running a botched up version of  osCommerce Online Merchant v2.3.4 bootstrap with the dresscode theme installed, numerous add-ons, terrible coding, terrible website, but will have to make do until I have made up for my losses and can risk shutting down for a couple of weeks while I start all over again. - I did not install my program but am endeavouring to fix it with your help.

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