stephaniezara Posted March 5, 2004 Share Posted March 5, 2004 (edited) 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 March 5, 2004 by stephaniezara Quote Link to comment Share on other sites More sharing options...
stephaniezara Posted March 6, 2004 Author Share Posted March 6, 2004 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 Quote Link to comment Share on other sites More sharing options...
stephaniezara Posted March 8, 2004 Author Share Posted March 8, 2004 Tried installing mod again...no luck. Any ideas? Quite frustrating! Quote Link to comment Share on other sites More sharing options...
korsh Posted March 9, 2004 Share Posted March 9, 2004 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 Quote Link to comment Share on other sites More sharing options...
Guest Posted March 9, 2004 Share Posted March 9, 2004 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 Quote Link to comment Share on other sites More sharing options...
stephaniezara Posted March 10, 2004 Author Share Posted March 10, 2004 Coolness! I'll give it a try! Now why is that line there? What possible purpose could it serve to add one instead of zero?? Ah well...I'll give it a shot, thanks! Quote Link to comment Share on other sites More sharing options...
stephaniezara Posted March 10, 2004 Author Share Posted March 10, 2004 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!* Quote Link to comment Share on other sites More sharing options...
stephaniezara Posted March 10, 2004 Author Share Posted March 10, 2004 Oh yeah...Korsh... I found what you were talking about and changed the 1 to a 0. Didnt seem to affect anything at all either. :( Quote Link to comment Share on other sites More sharing options...
korsh Posted March 10, 2004 Share Posted March 10, 2004 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. Quote Link to comment Share on other sites More sharing options...
stephaniezara Posted March 10, 2004 Author Share Posted March 10, 2004 I'm afraid I don't know enough about php coding to fully understand exactly what is going on between these two files but if you see a problem there then I believe you. :) Any ideas on a possible solution? Quote Link to comment Share on other sites More sharing options...
stephaniezara Posted March 16, 2004 Author Share Posted March 16, 2004 :( I guess I have to give up and remove the volume discounts. Waaahhh! If anyone has an answer PLEASE lemme know! Thanks!! Quote Link to comment Share on other sites More sharing options...
edtiger Posted April 21, 2004 Share Posted April 21, 2004 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. Quote Link to comment Share on other sites More sharing options...
korsh Posted April 21, 2004 Share Posted April 21, 2004 Hi Ed, Thank you for your help with the adjustQty function. Finally we have a solution! James Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.