WebPixie Posted December 21, 2004 Posted December 21, 2004 (edited) I am using Quantity Price Breaks Per Product http://www.oscommerce.com/community/contributions,1242 I love this contrib, it's perfectly suited for my needs, but I would also like to add a minimum amount to a product. I tried using Quantity controller, but I have so many contribs installed already and trying to pull the code out of the already altered files for install was impossible for me, I didn't even know where to begin :( So basicly I want to be able to say "Minimum order 25 in blocks of 10". So a buyer must buy atleast 25 but after 25 he can buy in blocks of 10. I would also like to be able to just say minimum order of 20 and then have anything over that be ok. I've search for 2 days reading every post without an answer to this problem, and I noticed a LOT of people asking for the same addition without reply. I know this is available from Quantity Control, but like I said, with all my other additions I couldn't just over-write the files with changes and I couldn't pull out all the changes to add to my store. I would really like to be able to add this to QPBPP though. So what's the best way to go about this? I can add a DB field for minimum amount in products, fill it in at the admin side in new product, and pull it to the product_info. But after that intergrating it into Price break is hard. If I just want minimum that would be ok, but when Price break sells in blocks it's harder. So if I set it to "in blocks of 10" and add 15 to my cart it automaticly makes the cart show 20 (2 blocks of 10). So how do I overide this if the minimum is 15 with blocks of 10 after? Would it be: if ($qty < $minimum) { //if less than minimum $qty = $minimum; // bump it up to minimum } else { then do the sell block stuff? //normal price break stuff } (^ not real code just my brain thinking out loud) Only problem I see with that is if I set it to minimum 15 and blocks of 10, and they add 15 and try to add 10 more the script would force them to 30 since 25 (15+10) is not in a set of 10... make sense? Did I lose anyone? :P I need a way to make 15 be the base price if a minimum is set. I really need help thinking this out. I read a few folks wrote to the author of the price break mod asking for something like this but he answered he didn't have time to add this, so I would really like to get this working and give back to the community :) Any ideas? Anyone get something close to this going? Thanks for the help :) Edited December 21, 2004 by WebPixie Quote
WebPixie Posted December 21, 2004 Author Posted December 21, 2004 Couldn't edit.... so posting again. Here is the code that figures out the quantity that should be in the cart: 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; } so we need something like this: function adjustQty($qty) { // Force QTY_BLOCKS granularity & Minimum $qb = $this->getQtyBlocks(); $min = $this->getMinimum(); if ($qty < 1) $qty = 1; if ($qb >= 1) { if (($min > 1) && ($qty < $min)) { $qty = $min; } if ($min == 1) { if ($qty < $qb) $qty = $qb; if (($qty % $qb) != 0) $qty += ($qb - ($qty % $qb)); } } elseif ($min > 1) { if ((($qty % $qb)-$min) != 0) $qty2 = ($qty - $min); $qty += ($qb - ($qty2 % $qb)); } } return $qty; } My brain is fried, think I have too much going on in this snippet. Has to be a way to make it simplier.... Any thoughts? Quote
WebPixie Posted January 2, 2005 Author Posted January 2, 2005 Ok, I still can't get this. It has to be worked into the sets and price break functions and I just can't get it right. I can make it require a minimum amount, but I can't get it to work with the "buy in sets of". Can anyone help me please add minimum quantity to the Quantity price breaks per items mod so it works with the buy in sets part. Pretty please, I'm pulling my hair out. :( Quote
WebPixie Posted January 6, 2005 Author Posted January 6, 2005 Ok, I still can't get this. It has to be worked into the sets and price break functions and I just can't get it right. I can make it require a minimum amount, but I can't get it to work with the "buy in sets of". Can anyone help me please add minimum quantity to the Quantity price breaks per items mod so it works with the buy in sets part. Pretty please, I'm pulling my hair out. :( <{POST_SNAPBACK}> Finally got it! Sat down last night and figured I would give it one last go.... DUH! I was over thinking it a LOT. I had a burst of inspiration and did it in 3 lines of code :P PriceFormatter.php is not as bad as I thought. So now I have a minimum quantity along with the Quantity Price Breaks Per Product contrib and it's "buy in blocks" feature. It was so easy I almost smacked myself for thinking it was more than it was -lol- I just really needed to make some of my items minimum quantity without making the user buy in blocks. Sometimes buying anything over 10 is all I need not blocks of 10 like 10,20,30. Works out perfectly and now I can even do minimum 10 (or 5 or 8 or whatever) and sell in blocks over that.... such as buy minimum of 10 in sets of 2 :) Cheers! Quote
Singularity Posted February 4, 2005 Posted February 4, 2005 Finally got it! Sat down last night and figured I would give it one last go.... DUH! I was over thinking it a LOT. I had a burst of inspiration and did it in 3 lines of code :P PriceFormatter.php is not as bad as I thought. So now I have a minimum quantity along with the Quantity Price Breaks Per Product contrib and it's "buy in blocks" feature. It was so easy I almost smacked myself for thinking it was more than it was -lol- I just really needed to make some of my items minimum quantity without making the user buy in blocks. Sometimes buying anything over 10 is all I need not blocks of 10 like 10,20,30. Works out perfectly and now I can even do minimum 10 (or 5 or 8 or whatever) and sell in blocks over that.... such as buy minimum of 10 in sets of 2 :) Cheers! <{POST_SNAPBACK}> WebPixie, Any chance you could post your code on this? Quote ----------------------------------------------------------------------------- Adam Get your osc documentation here: http://www.oscommerce.info/
michaellee Posted March 15, 2005 Posted March 15, 2005 Finally got it! Sat down last night and figured I would give it one last go.... DUH! I was over thinking it a LOT. I had a burst of inspiration and did it in 3 lines of code :P PriceFormatter.php is not as bad as I thought. So now I have a minimum quantity along with the Quantity Price Breaks Per Product contrib and it's "buy in blocks" feature. It was so easy I almost smacked myself for thinking it was more than it was -lol- I just really needed to make some of my items minimum quantity without making the user buy in blocks. Sometimes buying anything over 10 is all I need not blocks of 10 like 10,20,30. Works out perfectly and now I can even do minimum 10 (or 5 or 8 or whatever) and sell in blocks over that.... such as buy minimum of 10 in sets of 2 :) Cheers! <{POST_SNAPBACK}> Dear Webpix: I have the same need and same problem. I am not a programmer so that I tried to slove it for a long time but still failed. Finally, I searched the forum and saw your post that you have worked it out. May I have your help? I do need to set a minimum amount together with QPBPP. Thanks a lot. Michael Lee Quote
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.
Note: Your post will require moderator approval before it will be visible.