Jump to content
jpweber

Quantity Price Breaks

Recommended Posts

Hello,

 

Is there anybody who has tried and succeeded to show retail prices along wholesale prices

in the product listing pages ( not product_info.php, that works great with Show list Prices),

when a SPPC wholesale customer is logged in.

 

I tried to get it to work by playing with the getPriceStringShort() function in the PriceFormatter.php

but retail prices just keep showing 0.00.

 

I guess the function are called differently in product_listing.php and in product_info.php but as

I m really not a very advanced php user,

 

Any hint would be much appreciated

 

David


david

Share this post


Link to post
Share on other sites

Is there anybody who has tried and succeeded to show retail prices along wholesale prices

in the product listing pages ( not product_info.php, that works great with Show list Prices),

when a SPPC wholesale customer is logged in.

 

I tried to get it to work by playing with the getPriceStringShort() function in the PriceFormatter.php

but retail prices just keep showing 0.00.

 

I guess the function are called differently in product_listing.php and in product_info.php but as

I assume you use the Quantity Price Break version for SPPC? As far as I can remember the retail price is always available at first and is then replaced with the customer_group one. You could store it somewhere as a variabel retail_price that at first the same the products_price. You are probably best of by adding a separate function in PriceFormatter for getting that retail_price and then call that instead of getPriceStringShort().

Share this post


Link to post
Share on other sites

I assume you use the Quantity Price Break version for SPPC? As far as I can remember the retail price is always available at first and is then replaced with the customer_group one. You could store it somewhere as a variabel retail_price that at first the same the products_price. You are probably best of by adding a separate function in PriceFormatter for getting that retail_price and then call that instead of getPriceStringShort().

 

Hello Jan,

 

I thought of that indeed but also that I could maybe ... use the variable that allready appears

throughout my Show Price List QPB version PriceFormatter.php as:

 

$this->listPrice = $prices['list_price'];

 

Really I have no clue why if I, for example, just change getPriceStringShort() to getPriceString()

in product_listing I cant get the retail price to show up.

 

As I said getPriceStringShort() is called differently in product_listsing.php than getPriceString()

in product_info.php.

 

Could you have a look at this file if you have time?

 

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  $sql = "select pd.products_name, p.products_model, p.products_image, p.products_id," .
      " p.products_price, p.products_weight," .
      " p.products_price1,p.products_price2,p.products_price3,p.products_price4, p.products_price5,p.products_price6,p.products_price7,p.products_price8," .
      " p.products_price1_qty,p.products_price2_qty,p.products_price3_qty,p.products_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," .
      " NULL as specials_new_products_price" .
      " from " . TABLE_PRODUCTS_DESCRIPTION . " pd," .
      "      " . TABLE_PRODUCTS . " p" .
      " where p.products_status = '1'" .
      "   and p.products_id = '" . (int)$product_id . "'" .
      "   and pd.products_id = '" . (int)$product_id . "'" .
      "   and pd.language_id = '". (int)$language_id ."'";

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

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

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

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

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

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

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

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

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

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

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

return $price;
}

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

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

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

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

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

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

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

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

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

function getDiscountSaving($original_price, $discount_price) {

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

   return $saving;
 }

function getDiscountSpecialSaving($original_price, $discount_price) {

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

   return $specialsaving;
 }

function getPriceString($style='productPriceInBox') {
  global $currencies;
// BOF "Hide Price if $0 for "Quantity Price Breaks for SPPC 4.1.1" modification
if ($this->thePrice > 0 ) {
// EOF "Hide Price if $0 for "Quantity Price Breaks for SPPC 4.1.1" modification

// 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 = '
               <tr valign="top">
               <td>

<div><table border="0" cellspacing="1" cellpadding="4">';
       $lc_text .= '<tr valign="top"><td class="price_format" width="100">' . JD_PRIX_QTY . ' </td><td class="price_format" align="center" width="50" >1+'
              . '</td>';

   for($i=1; $i<=8; $i++) {
     if($this->quantity[$i] > 0) {
       $lc_text .= '<td class="price_format" align="center" width="50">'
         . $this->quantity[$i]
         .'+ </td>';
     }
   }
$lc_text .= '</tr>';
// TEST RETAIL PRICES
if ($this->cg_id > 0 && $this->listPrice > 0) {
               $lc_text .= '<tr><td class="price_format" width="110">' . SHOW_PRICE_LIST . ' </td><td align="center" width="80" class="boxText">'
               . $currencies->display_price2($this->listPrice,
                       tep_get_tax_rate($this->taxClass))
               . '</td>';
/*
   for($i=1; $i<=8; $i++) {
     if($this->quantity[$i] > 0) {
       $lc_text .= '<td align="center" width="80" class="boxText">';
       $lc_text .= $currencies->display_price2($this->listPrice[$i],
                      tep_get_tax_rate($this->taxClass))
                 .'</td>';
     }
   }
// Eof TEST RETAIL PRICES
*/
}
$lc_text .= '<!-- </tr> --><tr>';
$lc_text .= '<td class="price_format" width="100">';
if ($this->cg_id > 0) {
$lc_text .= SHOW_YOUR_PRICE ;
} else {
$lc_text .= JD_SHOW_PRICE_LIST ; }
$lc_text .= '</td><td align="center" width="80" class="boxText">'
               . $currencies->display_price2($this->thePrice,
                       tep_get_tax_rate($this->taxClass))
               . '</td>';

   for($i=1; $i<=8; $i++) {
     if($this->quantity[$i] > 0) {
       $lc_text .= '<td align="center" width="80" class="boxText">'
         . $currencies->display_price2($this->price[$i],
                      tep_get_tax_rate($this->taxClass))
                 .'</td>';
     }
   }
   $lc_text .= '</tr>';

   // Begin saving calculation
   $lc_text .= '<tr valign="center"><td class="price_format" width="100">'. JD_SAVE_QPB .' </td>';
   if ($this->hasSpecialPrice == true) {
$lc_text .= '<td align="center" width="50" class="infoBoxContents">     '
         . $this->getDiscountSpecialSaving($this->thePrice, $this->specialPrice)
                 .'</td>';
}
else {

$lc_text .= '<td align="center" width="50" class="infoBoxContents"> - </td>';
}
   for($i=1; $i<=8; $i++) {
     if($this->quantity[$i] > 0) {
       $lc_text .= '<td align="center" width="50" class="infoBoxContents">'
         . $this->getDiscountSaving($this->thePrice, $this->price[$i])
                 .'</td>';
     }
   }
   $lc_text .= '</tr></table></div>';

if ($this->hasSpecialPrice == true) {
if ($this->cg_id > 0 && $this->listPrice > 0) {
$lc_text .= '<div>';

$lc_text .= '<span class="smallText">' . JD_SPECIAL_PRICE.'  ' ;
$lc_text .= $currencies->display_price2($this->specialPrice,
tep_get_tax_rate($this->taxClass));

$lc_text .= ' </div>';


}
elseif  ($this->cg_id == 0 && $this->listPrice > 0) {
$lc_text .= '<div>';

$lc_text .= '<span class="smallText">' . JD_SPECIAL_PRICE.'  ' ;
$lc_text .= $currencies->display_price2($this->specialPrice,
tep_get_tax_rate($this->taxClass));

$lc_text .= ' </div>';
}

}
    }

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

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

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

// BOF "Hide Price if $0 for "Quantity Price Breaks for SPPC 4.1.1" modification
  } else {
      $lc_text = HIDE_PRICE_INFO ;
  }
// EOF "Hide Price if $0 for "Quantity Price Breaks for SPPC 4.1.1" modification
  return $lc_text;
}


function getPriceStringShort() {

  global $currencies;
// BOF "Hide Price if $0 for "Quantity Price Breaks for SPPC 4.1.1" modification
if ($this->thePrice > 0 ) {
// EOF "Hide Price if $0 for "Quantity Price Breaks for SPPC 4.1.1" modification

  if ($this->hasSpecialPrice == true) {
    $lc_text = ' <s>'
. $currencies->display_price2($this->thePrice,
       tep_get_tax_rate($this->taxClass))
. '</s>  <span class="productSpecialPrice">'
. $currencies->display_price($this->specialPrice,
       tep_get_tax_rate($this->taxClass))
. '</span> ';
  }
  else {
    if($this->hasQuantityPrice == true) {
$lc_text = ' '
 . $currencies->display_price($this->lowPrice,
         tep_get_tax_rate($this->taxClass))
 . ' - '
 . $currencies->display_price($this->hiPrice,
         tep_get_tax_rate($this->taxClass))
 . ' ';
    }
    else {
$lc_text = ' '
 . $currencies->display_price($this->thePrice,
         tep_get_tax_rate($this->taxClass))
 . ' ';
    }
  }
// BOF "Hide Price if $0 for "Quantity Price Breaks for SPPC 4.1.1" modification
  } else {
      $lc_text = HIDE_PRICE_INFO ;
  }
// EOF "Hide Price if $0 for "Quantity Price Breaks for SPPC 4.1.1" modification
  return $lc_text;
} // EOF function getPriceStringShort
}
?>


david

Share this post


Link to post
Share on other sites

I thought of that indeed but also that I could maybe ... use the variable that allready appears

throughout my Show Price List QPB version PriceFormatter.php as:

 

$this->listPrice = $prices['list_price'];

 

Really I have no clue why if I, for example, just change getPriceStringShort() to getPriceString()

in product_listing I cant get the retail price to show up.

 

As I said getPriceStringShort() is called differently in product_listsing.php than getPriceString()

in product_info.php.

The code looks fine to me so I can't fathom why you shouldn't be able to use $this->listPrice in the function getPriceStringShort() (you don't show the use of it in the code you posted).

Share this post


Link to post
Share on other sites

Hello everyone,

 

I just installed Quantity Price Breaks Per Product v1.3.6. But some of my osc files are old (2003 due to an old template).

 

Everything works good except the fact that TEXT_PRODUCTS_QTY doesn't appear on the product's file.(price for each and saving appear)

 

Does anyone have a solution?

 

Thanks

Share this post


Link to post
Share on other sites

Hi,

 

I have just installed Quantity Price Breaks Per Product for Separate Pricing Per Customer v2.0. It works fine but with one big problem:

 

- I have 7 different customer groups and products with price breaks and without

 

If I have a product with price breaks and different prices for customer, the shop shows me the right prices on product listing page like new_products, search...

 

But if I have a product without price breaks but with different prices for customer, it shows me the price for the first customer group in product listing, regardless of the customer group. If I go to the product page it shows me the right price.

 

Any solution?

Share this post


Link to post
Share on other sites

Everything works good except the fact that TEXT_PRODUCTS_QTY doesn't appear on the product's file.(price for each and saving appear)

Somewhere the define for that is missing. Try adding it to where price for each and saving are also defined.

Share this post


Link to post
Share on other sites

- I have 7 different customer groups and products with price breaks and without

 

If I have a product with price breaks and different prices for customer, the shop shows me the right prices on product listing page like new_products, search...

 

But if I have a product without price breaks but with different prices for customer, it shows me the price for the first customer group in product listing, regardless of the customer group. If I go to the product page it shows me the right price.

I couldn't fathom why this would be happening but after some detective work I found that a query for the group prices doesn't return any results where there should be. I found that in e.g. includes/modules/product_listing it says in the query and customers_group_price !=null.

For some reason (I suppose this was working in the past, but I have upgraded MySQL to version 5 somewhere in time) this is not working properly. If I change it to and customers_group_price is not null it works again. I think more modules need adapting like the new products module on the front page.

 

The "is not null" is needed in the QPBPP version because there might be cases where you want to set quantity blocks etcetera for a group but not change the group price.

Share this post


Link to post
Share on other sites

I couldn't fathom why this would be happening but after some detective work I found that a query for the group prices doesn't return any results where there should be. I found that in e.g. includes/modules/product_listing it says in the query and customers_group_price !=null.

For some reason (I suppose this was working in the past, but I have upgraded MySQL to version 5 somewhere in time) this is not working properly. If I change it to and customers_group_price is not null it works again. I think more modules need adapting like the new products module on the front page.

 

The "is not null" is needed in the QPBPP version because there might be cases where you want to set quantity blocks etcetera for a group but not change the group price.

 

Hi Jan,

 

many thanks, this was the right solution. ;-)

Share this post


Link to post
Share on other sites

hello,

 

i just installed QBC, and while i can get the price break to work for individual items (item A when they buy four, its 10 bucks) but i want them to be able to buy items a, b, c, d, and get those for four.

 

am i doing something wrong, the documentation says it should work, but im not getting it.

Share this post


Link to post
Share on other sites

I have been installing this contribution and it almost works. The problem is that when adding a product to the cart you can enter any quantity regardless of the minimum of the bundle. When I define the bundle to be 22 and I add a product entering 12 in the quantity box it will add 12 instead of the nearest bundle amount of 22. However when updating the product (when there already is a quantity in the cart) it works like a charm and calculates the correct amount including the bundle quantity.

 

Anyone knows what the problem might be? I have been working on it for hours and it seems that the following line does not use the qpbpp qty of the product:

 

$this->contents[$products_id_string] = array('qty' => (int)$qty, 'discount_categories_id' => $product_info['discount_categories_id']);

 

This line, when updating the quanity of the cart does work:

 

$this->update_quantity($products_id_string, $qty, $attributes, $product_info['discount_categories_id']);

 

Help would be very much appreciated!

Share this post


Link to post
Share on other sites

I have been installing this contribution and it almost works. The problem is that when adding a product to the cart you can enter any quantity regardless of the minimum of the bundle. When I define the bundle to be 22 and I add a product entering 12 in the quantity box it will add 12 instead of the nearest bundle amount of 22. However when updating the product (when there already is a quantity in the cart) it works like a charm and calculates the correct amount including the bundle quantity.

 

Anyone knows what the problem might be? I have been working on it for hours and it seems that the following line does not use the qpbpp qty of the product:

 

$this->contents[$products_id_string] = array('qty' => (int)$qty, 'discount_categories_id' => $product_info['discount_categories_id']);

 

This line, when updating the quanity of the cart does work:

 

$this->update_quantity($products_id_string, $qty, $attributes, $product_info['discount_categories_id']);

 

Help would be very much appreciated!

 

Well. Finally figured it out. For some reason the $qty was not calculated to the nearest products_qty_blocks in the adding to cart. Therefore I rewrote the script slightly. I already know it wasnt working because of another contribution because the contribution worked like a charm on a fresh installation but I have no idea which contribution caused this error.

 

Anyone with the same problems try in includes/classes/shopping_cart.php to change:

 

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

 

into:

 

// BOF qpbpp
         if ($this->in_cart($products_id_string)) {
           $this->update_quantity($products_id_string, $qty, $attributes, $product_info['discount_categories_id']);
         } else {
// Berekening van aantal producten gaat niet goed zonder onderstaande code. Deze berekend de dichstbijzijnde minimale bundel afname bij het toevoegen van een product. Er word naar beneden afgerond.
$min_order_query = tep_db_query("select p.products_qty_blocks as min_quant FROM " . TABLE_PRODUCTS . " p where p.products_id = '".$products_id_string."'");
while ($min_order = tep_db_fetch_array($min_order_query))  
{
  if ($qty < $min_order['min_quant']) 
  {
	  $qty = $min_order['min_quant'];
  }
  if ($qty > $min_order['min_quant'])
  {	
	  $qty = ($qty - ($qty % $min_order['min_quant']));
  }
}

           $this->contents[$products_id_string] = array('qty' => (int)$qty, 'discount_categories_id' => $product_info['discount_categories_id']);
// EOF qpbpp

 

It will however round the final $qty down to the nearest products_qty_blocks rather then up. Math was not my best subject and I couldnt figure out how to do that.

Share this post


Link to post
Share on other sites

Hello,

 

I am using the most recent version of QPBPP. We are selling DVD & CD duplications and would like customers to order a minimum amount which varies depending on the particular type of duplication offered. Once they satisfy the minimum they can order any quantity they want with no required block increment. The more they buy the better the discount. Here is a link to the shop. Right now the only items with the pricing included are the first 2 products in the DVDs category.

 

http://graphicbydesign.net/osc/index.php

Share this post


Link to post
Share on other sites

Help me please...

 

I used QPBPP v136 on my website, its work well in my laptop (offline), but when I tried it on my website (online) its give an error when I clicked on the category list, this is the error message:

Fatal error: Call to a member function loadProduct() on a non-object in /{mywebdir}/includes/modules/product_listing.php on line 193

 

and then I try to click directly to my product, the error message displayed like this:

Fatal error: Call to a member function loadProduct() on a non-object in /{mywebdir}/product_info.php on line 251

 

help me please... what should I do?

Share this post


Link to post
Share on other sites

Help me please...

 

I used QPBPP v136 on my website, its work well in my laptop (offline), but when I tried it on my website (online) its give an error when I clicked on the category list, this is the error message:

 

 

and then I try to click directly to my product, the error message displayed like this:

 

 

help me please... what should I do?

 

I tried to re-publish (re-upload) my webstore, and... it fixed now!! :) I still confused what wrong with it before...

Share this post


Link to post
Share on other sites

I tried to re-publish (re-upload) my webstore, and... it fixed now!! :) I still confused what wrong with it before...

 

oooo no... the problem comes again... :(

 

I really confused.... please help....

Share this post


Link to post
Share on other sites

Hello,

 

I've installed osCommerce v2.2 RC2.

I installed Quantity Price Breaks Per Product 1.3.5 Jan Zonjee (7 Sep 2008)

using Autoinstaller 2.13.

 

Also installed

Show Subcategories when Category has Products

21 Feb 2003 Initial release by Anthony Capobianco (CyberDog, Inc.)

 

What I need are products with quantity based prices (volume discounts)

as well as most products will have options such as sizes and colors.

Not sure how all that is going to work out yet.

 

Right now with qpbpp I can add a "rule" which indicates the price will

be different for various quatities. This works. The quantity blocks works great.

 

When changing a product in admin I see a table showing price discounts

and the quantities at which they are effective. The problem is that this

table does not show up when viewing the product detail in product_info.php

I see only one price. I notice throughout the documentation that the

price discount table will appear on a product which has been configured

for quantity based pricing. I thought I was doing that when I set prices

and quantities on the edit product page.

 

Is there something wrong or am I just not doing something right?

 

 

Larry

Edited by larkat

Share this post


Link to post
Share on other sites

The code looks fine to me so I can't fathom why you shouldn't be able to use $this->listPrice in the function getPriceStringShort() (you don't show the use of it in the code you posted).

 

Hello Jan,

 

First of all, thank you for all your support and Happy new Year too!

 

I was indeed very slow ... and forgot to say I did not use QBPP latest version,

but eventually found a way out, modified getPriceStringShort() and

called it differently in product_listing.php not using the PriceFormatter parse():

 

$pf->loadProduct($listing[$x]['products_id'], $languages_id);
           $lc_text = $pf->getPriceStringShort();

 

And this is the getPriceStringShort()

 

function getPriceStringShort() {

  global $currencies;

// BOF "Hide Price if $0 for "Quantity Price Breaks for SPPC 4.1.1" modification
if ($this->thePrice > 0 ) {
// EOF "Hide Price if $0 for "Quantity Price Breaks for SPPC 4.1.1" modification

       if($this->cg_id == 0) {

               if($this->hasQuantityPrice == true) {

       $lc_text = ' <span class="productSpecialPrice">' . STAFFEL_PRICE_AB . '</span>'
         . $currencies->display_price($this->lowPrice,
                                      tep_get_tax_rate($this->taxClass))
                 . ' <br>';
     }

   else {
   if ($this->hasSpecialPrice == true) {
     $lc_text = ' <span class="productSpecialPrice">' . SPECIAL_PRICE . ': </span><s>'
       . $currencies->display_price($this->thePrice,
                                    tep_get_tax_rate($this->taxClass))
       . '</s>  '
       . $currencies->display_price($this->specialPrice,
                                    tep_get_tax_rate($this->taxClass))
       . ' <br>';
   }

           else { // Product has no special price and no quantita price breaks
       $lc_text = ' '
         . $currencies->display_price($this->thePrice,
                                      tep_get_tax_rate($this->taxClass))
         . ' <br>';
     }
   }
} else { // Eof Customers group is retail


// test WHOLESALE Customers Groups

       if($this->cg_id > 0 && $this->listPrice >=0) {

  if ($this->hasSpecialPrice == true) {

       $lc_text .= 'Endkunden: '
                       . $currencies->display_price2($this->listPrice * 1.19,'0')
                       .'<br />Inkl. MwSt<br />';
       $lc_text .='Händler:  <s>'
                       . $currencies->display_price2($this->thePrice,
                               tep_get_tax_rate($this->taxClass)).'</s>'
                       . '<br />Sonderpreis:<span class="productSpecialPrice">'
                       . $currencies->display_price2($this->specialPrice,
                               tep_get_tax_rate($this->taxClass))
                       . '</span><br />Exkl. MwSt ';
}

  else { // EOF Product has special price

       if($this->hasQuantityPrice == true) {

       $lc_text = 'Endkunden: '
               . $currencies->display_price2($this->listPrice * 1.19,'0') .'<br />Inkl. MwSt<br />Händler:  '

               . $currencies->display_price2($this->lowPrice, tep_get_tax_rate($this->taxClass))
               . ' - '
               . $currencies->display_price($this->hiPrice, tep_get_tax_rate($this->taxClass))
               . ' ';
    }
    else { // EOF Customers group > 0 and Product has special price or quantity price breaks in products listing!

       $lc_text = 'Endkunden: '
               . $currencies->display_price2($this->listPrice * 1.19,'0') .'<br />Inkl. MwSt<br />Händler:  '
               . $currencies->display_price($this->thePrice, tep_get_tax_rate($this->taxClass))
               . ' ';
    }
  }
}
}
// BOF "Hide Price if $0 for "Quantity Price Breaks for SPPC 4.1.1" modification
  } else {
      $lc_text = HIDE_PRICE_INFO ;
  }
// EOF "Hide Price if $0 for "Quantity Price Breaks for SPPC 4.1.1" modification
  return $lc_text;
} // EOF function getPriceStringShort

 

I hope not using the parse() does not affect the shop otherwise.

I was also asked to change the tax displays in some occurences but that is another subject.

 

Again many thanks and best regards


david

Share this post


Link to post
Share on other sites

Hello,

 

I've installed osCommerce v2.2 RC2.

I installed Quantity Price Breaks Per Product 1.3.5 Jan Zonjee (7 Sep 2008)

using Autoinstaller 2.13.

 

Also installed

Show Subcategories when Category has Products

21 Feb 2003 Initial release by Anthony Capobianco (CyberDog, Inc.)

 

What I need are products with quantity based prices (volume discounts)

as well as most products will have options such as sizes and colors.

Not sure how all that is going to work out yet.

 

Right now with qpbpp I can add a "rule" which indicates the price will

be different for various quatities. This works. The quantity blocks works great.

 

When changing a product in admin I see a table showing price discounts

and the quantities at which they are effective. The problem is that this

table does not show up when viewing the product detail in product_info.php

I see only one price. I notice throughout the documentation that the

price discount table will appear on a product which has been configured

for quantity based pricing. I thought I was doing that when I set prices

and quantities on the edit product page.

 

Is there something wrong or am I just not doing something right?

 

 

Larry

 

I finally found the problem!

In product_info.php the product_price variable is set to the

regular price or the quantity based price. Immediately following in

an IF/ELSE block. This sets the price variable to the special price

if one exists. If there is no special price then the ELSE clause

sets the price to what I believe is the regular price.

My solution was to comment out the else portion of the

IF/ELSE block. I've tested regular, special and quantity prices

and they all seem to work correctly.

 

// EOF 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>   <b class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</b>';

}

else

{

// $products_price = '<b class="productSpecialPrice">'.$currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])).'</b>';

}

 

 

The shopping cart already calculates the correct price.

 

 

Larry

Share this post


Link to post
Share on other sites

Does anyone know why my store search results and product listings show nothing?

 

10788b5.jpg

 

I followed the Manual installation instructions very carefully and I think I did everything right.

 

The product_info page and everything else works well.

 

347xldd.jpg

 

Can anyone help me? What did I mess up on?

Edited by dOoBiX

Share this post


Link to post
Share on other sites

Does anyone know why my store search results and product listings show nothing?

Both use the module product_listing.php.

 

I followed the Manual installation instructions very carefully and I think I did everything right.

From the looks of it (button details) you are using a template. They often use non-standard osC code so adding QPBPP to it is different than for a standard osC listing module.

 

Do you really need to show the "price from" in your listings? You can leave out QPBPP from the product listing module and still have a good working price break.

Share this post


Link to post
Share on other sites

Thanks Jan Zonjee, I just changed my products_listing.php back to the original (from the template i bought) and it's working fine now!

Share this post


Link to post
Share on other sites

I am trying to show 'Contact us' when the price is set to 0 or some value. I know this should be a quick change. Can someone point me to the right direction?

 

Ideally, link to the contact us page will be even better.

 

I found one contribution there which does that but it applies to older version of the QPB contribution only, not the new version.

Share this post


Link to post
Share on other sites

Hi,

 

I have installed the contribution, which is working and I think it is great.

 

I am trying to change the format of the product_info page to move the Quantity Price Break table from the top of the page to below the product descriptions, above any featured products/other customers bought these product/etc boxes.

 

I have (what appears to be) successfully changed the price at the top of the page from the table to "From price" by changing

 

$pf->loadProduct((int)$_GET['products_id'], (int)$languages_id);

$products_price=$pf->getPriceString();

 

to

 

$pf->loadProduct((int)$_GET['products_id'], (int)$languages_id);

$products_price=$pf->getPriceStringShort();

 

But I can't get the table to move down the page and think it is because I have missed some code somewhere and was hoping somebody could give me a pointer please.

 

At the moment I have

 

<p><?php echo stripslashes($product_info['products_description']); ?></p>

<?php

 

// START Quantity Price Breaks Per Product - My adaption to move the price box down the page

// Need to do a if statement. If there are price breaks, then show the price box here

?>

<table border="0" width="100%" cellspacing="0" cellpadding="2">

<td class="main" align="left" >

This is where i would like to add the price box for in there are price breaks

<?php //Want to add in the price somewhere around here

$pf->loadProduct((int)$_GET['products_id'], (int)$languages_id);

$products_price=$pf->getPriceString();?>

</td></tr>

<tr>

<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>

<?php

// END Quantity Price Breaks Per Product

 

My only thought is there must be some code I have missed that used to call up the price break table at the top of the page.

 

Can anyone help me please??

 

Ali

Share this post


Link to post
Share on other sites

My only thought is there must be some code I have missed that used to call up the price break table at the top of the page.

You need to move the echo'ing (display) of the $products_price to the place you want it to show:

<?php echo $products_price; ?>

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

×