Eamo Posted July 31, 2007 Share Posted July 31, 2007 Hi Im currently customising a oscommerce install for use as a wine merchant. The way I need the ordering to work is that a order is not possible to make unless its a minimum of 12 bottles (a full case of wine). And any additional wine purchased must also make a full case (i.e be a multiple of 12). So a order of 12,24 or even 36 bottles is fine but a order for 18 for example would be rejected. Ive been looking for contributions to carry this out but have no had any luck. Im reasonably handy with PHP and wouldnt mind making the modifications myself. However its my first time using oscommerce and I'm not to sure of where to start. Was hoping somebody could point me in the direction of a suitable contribution that does the job or could be easily customised. Failing that even if somebody could explain how the order is handled I might be able to create the contribution myself. Any feedback appreciated Thanks Eamo Link to comment Share on other sites More sharing options...
germ Posted July 31, 2007 Share Posted July 31, 2007 Minimum Order Contribution: Minimum Order Amount When you look at that link, there is a "fix" dated 6 March 2006 that reads: if ($cart->show_total() <= MIN_ORDER_AMOUNT) should be: if ($cart->show_total() < MIN_ORDER_AMOUNT) I was thinking if you wrote it as such: if ($cart->show_total() <= MIN_ORDER_AMOUNT) should be: if ($cart->show_total() % MIN_ORDER_AMOUNT) The "%" is PHP for "modulus" or remainder. So, you've changed the statement to read: If the remainder of $cart->show_total()/MIN_ORDER_AMOUNT is not Zero And if you set the MIN_ORDER_AMOUNT to 12, with the alteration of the statement as above, you've not made it a "minimun order amount" contribution, but a contribution that says you must buy in even quantities of MIN_ORDER_AMOUNT. Does that make sense to you? :unsure: If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
germ Posted August 1, 2007 Share Posted August 1, 2007 OK. That contribution was for a minimum order dollar amount. So let's ad lib. This modification is based on this contribution: Minimum Order Amount But because I don't know squat about MYSQL, I've done something similar without a DB modification. If I have stepped on any toes, or overstepped my boundries, may I offer my humblest apologies in advance. :blush: Step 1: Backup all files involved. Step 2: In these files: /includes/configure.php /catalog/includes/configure.php Add this line: define('TOTAL_ORDER_QUANTITY_MULTIPLE','12'); Just above this line: // define our database connection The numer 12 is for this individual requirement. It can be modified to whatever order quantity multiple is desired. Step 3: Add to catalog/includes/languages/{LANGUAGE}/shopping_cart.php /////ADD//// define('TEXT_ORDER_NOT_EVEN_MULTIPLE', 'The total order quantity must be an even multiple of %s in order to checkout.'); //////////// If your store is "multilingual", add the equivilant phrase to each language file you support. Step 4: Add to catalog/shopping_cart.php /////BELOW/// } else { ?> <tr> <td class="stockWarning" align="center"><br><?php echo OUT_OF_STOCK_CANT_CHECKOUT; ?></td> </tr> <?php } } //////////// /////ADD//// //bof check minimum total order multiple if ($cart->count_contents() % TOTAL_ORDER_QUANTITY_MULTIPLE) { ?> <tr> <td class="stockWarning" align="center"><br><?php echo sprintf(TEXT_ORDER_NOT_EVEN_MULTIPLE, TOTAL_ORDER_QUANTITY_MULTIPLE); ?></td> </tr> <?php } //eof //////////// Step 5: Add to these files: catalog/checkout_shipping.php catalog/checkout_process.php catalog/checkout_payment.php catalog/checkout_confirmation.php /////BELOW/// require(DIR_WS_CLASSES . 'order.php'); $order = new order; //////////// /////ADD//// //bof check minimum total order multiple if ($cart->count_contents() % TOTAL_ORDER_QUANTITY_MULTIPLE) { tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, '', 'SSL')); } //eof //////////// This is the first time I've done this, so please backup your files before beginning. We may need to do a little modification to get it right. :blush: I have a "test" page on a website that I ran that simulated this code as best I could, and it worked. :) If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
Eamo Posted August 2, 2007 Author Share Posted August 2, 2007 That worked perfectly. Your a gentleman. :) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.