Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Using Quantity Price Breaks WITH Add Multi Product


Recommended Posts

Howdy.

I have http://www.oscommerce.com/community/contributions,1129 Add Multi Products installed. Worked swimmingly and it's REALLY important to my site.

I want to add http://www.oscommerce.com/community/contributions,1242 Quantity Discounts Per Product.

Didn't seem like a difficult mod to install but when I did it caused a problem for me. When I'd go into a category and add a product to the shopping cart it would add one of each product in the category to the cart. Lovely! I doubt it is a problem with the mod as I havent seen anyone else have this problem The problem is detailed here: http://www.oscommerce.com/forums/index.php?showtopic=81926&hl=

 

I'm not sure but I THINK this is what the problem is. Quantity discounts asks me to make the following alteration to catalog/includes/modules/product_listing.php

? ? ? ?  case 'PRODUCT_LIST_PRICE':

? ? ? ? ? ? $lc_align = 'right';

 

Add after the above:

 

? ? ? ? ? ? $pf->parse($listing);

? ? ? ? ? ? $lc_text = $pf->getPriceStringShort();

 

But The Add Multi Products mod has me change all references to /product_listing.php to point to /product_listing_multi.php and

? ? ? ?  case 'PRODUCT_LIST_PRICE':

? ? ? ? ? ? $lc_align = 'right';

Is nowhere to be found in that document.

The closest I came was finding

$lc_text = PRICE;

? ? $lc_align = 'right';

? ?  $list_box_contents[$cur_row][] = array('align' => $lc_align,

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'params' => 'class="productListing-data"',

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text'? => $lc_text);

 

Which I tried changing to

? ? $lc_text = PRICE;

? ? $lc_align = 'right';

? ? $pf->parse($listing);

? ? ? ? ? ? $lc_text = $pf->getPriceStringShort();

? ?  $list_box_contents[$cur_row][] = array('align' => $lc_align,

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'params' => 'class="productListing-data"',

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'text'? => $lc_text);

Which seemed logical. No dice though...same problem.

 

Anyway...since products_listsings_multi.php is such a radically different document from the original products_listing.php is it even possible to add Quantity Discounts when you are using Add Multi Products?

These are both really really important mods for my site and I really need them both to work together.

I hope I laid this out clearly enough. I really hope someone can advise me and tell me if what I'm trying to do is even possible or if I'm just wasting time. I've sunk a lot of time so far into making these two mods work together and I'd really like it to work out. Thanks a million!!!

Edited by stephaniezara
Link to comment
Share on other sites

Upon further review I have decided that I think catalog/includes/classes/shopping_cart.php is the offending file.

 

I removed the Price Breaks mod completely and ran a test session to make sure everything worked correctly.

I then reinstalled Price Breaks. Withh all pages changed except catalog/includes/classes/shopping_cart.php the shop works perfectly except that the quanitity discounts are not applied. But I dont have the problem with it adding products that were not ordered. As soon as I upload the catalog/includes/classes/shopping_cart.php file it applies the discount but also adds every product in the category (only when ordered from the product listing...it works fine when ordering is done from the product's individual page).

Could someone kindly take a look at this and possibly tell me what's wrong?

This is the unaltered shopping_cart.php: Original

And this is with Price Breaks changes made: Altered

These are the instructions for that page: Instructions

 

I really hope that some kind soul out there will lend me a hand. This is SO important!

I feel like I've almost got this problem licked. There's something there that one of you smart folks can spot, I'm sure of it! Thanks a million!!! :D

Link to comment
Share on other sites

Hi Stephaniezara,

 

I posted a reply to your other querie and I wanted to add this as well that in Priceformatter.php this is possibly where the quantity is set to 1

line 169-173

 

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

 

James

Link to comment
Share on other sites

Did you do this? In includes/classes/shopping_cart.php find the line.

 

if ($qty == '') $qty = '1'; // if no quantity is supplied, then add '1' to the customers basket

 

this should be about line 90

 

comment the line out

 

// if ($qty == '') $qty = '1'; // if no quantity is supplied, then add '1' to the customers basket

Link to comment
Share on other sites

Ack! I couldn't find that line anywhere in shopping_cart.php

The closest I could find was line 78

 

function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {

 

I changed it to

 

function add_cart($products_id, $qty = '0', $attributes = '', $notify = true) {

 

but it didn't make any difference. :( *sob!*

Link to comment
Share on other sites

Hi Stephaniezara

 

Price breaks altered the shopping cart.php here

 

diff -Naur storems2/catalog/includes/classes/shopping_cart.php store/catalog/includes/classes/shopping_cart.php
--- storems2/catalog/includes/classes/shopping_cart.php	Wed Jun 25 21:14:33 2003
+++ store/catalog/includes/classes/shopping_cart.php	Sun Aug 17 15:44:32 2003
@@ -78,6 +78,10 @@
    function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {
      global $new_products_id_in_cart, $customer_id;

+      $pf = new PriceFormatter;
+      $pf->loadProduct($products_id);
+      $qty = $pf->adjustQty($qty);
+
      $products_id = tep_get_uprid($products_id, $attributes);
      if ($notify == true) {
        $new_products_id_in_cart = $products_id;

 

 

and added these three lines

 

+      $pf = new PriceFormatter;
+      $pf->loadProduct($products_id);
+      $qty = $pf->adjustQty($qty);

 

In Priceformatter.php possibly changing the quantity.

 

 

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;
 }

 

I think the problem lies here.

Link to comment
Share on other sites

  • 1 month later...

the solution that worked for me to prevent all products in the list from being added is below:

 

change /catalog/includes/classes/Priceformatter.php around line 168 from this:

 

  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;

  }

 

 

to this

  function adjustQty($qty) {

// Force QTY_BLOCKS granularity

$qb = $this->getQtyBlocks();

/* if ($qty < 1)

  $qty = 1;*/

 

if ($qb >= 1)

{

  if ($qty < 1)

  $qty = 0;

  elseif ($qty < $qb)

  $qty = $qb;

 

  if (($qty % $qb) != 0)

  $qty += ($qb - ($qty % $qb));

}

return $qty;

  }

 

basic reasoning is as follows (just for kicks and giggles):

In the old version a quantity value of "0" causes $qty(the quantity entered) <(to be less than) $qb(minimum quantity in the pricebreak module) so $qty becomes the value for $qb. This means any value entered (including zero) which is less than the minimum amount required for purchase automagically becomes the minimum amount for purchase so every product is added to the shopping cart.

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