boxtel Posted August 4, 2006 Share Posted August 4, 2006 Hi Boxtel. This looks like a great contribution!I was wondering if it might not be too hard for me to modify it to be Category Trees Minimum Order Dollar Amount, or something like that? I want to enforce a minimum dollar amount for products from a particular vendor. Any suggestions on how I might do that? Or, would that be a totally different type of contribution? Thanks very much! Regards, -Lori- you can replace the function cat_min_order_ok () with this one which will allow you to set a quantity and a value minimum. function cat_min_order_ok () { global $cart, $messageStack, $currencies; $result = true; $cat_val = array(); // settings of the category trees // (top category id, minimum quantity, minimum value, cart quantity, cart value) // min qty of 10 and min value of 2000 for products under category 54 $cat_val[] = array('id' => 54, 'min' => 10, 'min_value' => 2000, 'cart' => 0, 'value' => 0); // min value of 100 for products under category 55 $cat_val[] = array('id' => 55, 'min' => 0, 'min_value' => 0, 'cart' => 0, 'value' => 0); $products = $cart->get_products(); for ($p=0; $p<sizeof($products); $p++) { $t_prid = tep_get_prid($products[$p]['id']); $cat_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $t_prid . "'"); $cat_result = tep_db_fetch_array($cat_query); for ($i=0; $i<sizeof($cat_val); $i++) { $cat_path = tep_get_cat_path($cat_result['categories_id']); $cat_path_array = split("_" , $cat_path); if (in_array ($cat_val[$i]["id"],$cat_path_array)) { $cat_val[$i]["cart"] = $cat_val[$i]["cart"] + $products[$p]['quantity']; $cat_val[$i]["value"] = $cat_val[$i]["value"] + $products[$p]['final_price']; } } } for ($i=0; $i<sizeof($cat_val); $i++) { if (($cat_val[$i]["cart"] > 0) and ($cat_val[$i]["cart"] < $cat_val[$i]["min"])) { $result = false; $messageStack->add_session('shopping_cart', 'Category '.get_cat_name($cat_val[$i]["id"]).' has a minimum order quantity of '.$cat_val[$i]["min"].' You currently have '.$cat_val[$i]["cart"].' in your basket'); break; } if (($cat_val[$i]["value"] > 0) and ($cat_val[$i]["value"] < $cat_val[$i]["min_value"])) { $result = false; $messageStack->add_session('shopping_cart', 'Category '.get_cat_name($cat_val[$i]["id"]).' has a minimum order amount of '.$currencies->format($cat_val[$i]["min_value"]).' You currently have '.$currencies->format($cat_val[$i]["value"]).' in your basket'); break; } } return $result; } Quote Treasurer MFC Link to comment Share on other sites More sharing options...
phantompressents Posted October 23, 2006 Share Posted October 23, 2006 (edited) Hi great contrib here just what i need. im hoping some of you could help me get it working fully. As far as I can see ive installed it correctly however when I select some items from the same category and click the checkout button I get a blank screeen. no errors or anything to give me a clue!! Im using the very latest oscommerce-2.2ms2-060817 Please help I would really like to utilize this contribution. thanks in advance. Edited October 23, 2006 by phantompressents Quote Link to comment Share on other sites More sharing options...
phantompressents Posted October 24, 2006 Share Posted October 24, 2006 Can anyone help me! Quote Link to comment Share on other sites More sharing options...
phantompressents Posted November 2, 2006 Share Posted November 2, 2006 Finally got this working except for one thing if there are not enough products in the basket it dosent show the message stack error just goes back to shopping basket. can anyone give suggestions as to what i might have done wrong Quote Link to comment Share on other sites More sharing options...
phantompressents Posted November 6, 2006 Share Posted November 6, 2006 Ok so here is the thing it works Hurrah! Great contrib. Only problem is that you have to click on checkout button twice before the error line pops up. For example. If I have 3 items in the basket and I need five when I go to checkout it doesn?t warn me just refreshes the basket when I click checkout again then the warning pops up if I click on checkout a third time the error box will disappear . Has anyone else experienced this problem? Would really appreciate some ideas and responses here please. Thanks in advance. have a look here www.beckdale.com and use tissue paper as the item Quote Link to comment Share on other sites More sharing options...
earth-friendly Posted November 15, 2006 Share Posted November 15, 2006 you can replace the function cat_min_order_ok () with this one which will allow you to set a quantity and a value minimum. ... Amanda, Thanks so much for all your help with this. I know it has been a while, but I have finally gotten this working, with your modifications, so that it is Category Trees Minimum Order Quantity Value. I can now specify either a minimum order quantity or a minimum order value for a category (or both). In another one of your contributions, Category QVB Discount, you had a way of specifying a teaser that would display when displaying the category and its products. I'd like to do something similar in this case. For example, I'd like to say: Minimum order for Case of Muffins: You must buy at least 3 or Minimum order for Case of Muffins: You must spend at least $25 For Category QVB Discount, there was a separate module in includes/modules/order_total/ot_qvb_discount.php, where the teaser could be defined. Can you recommend a clean way to do this for the Category Trees Minimum Order Quantity Value contribution? Thanks very much! Regards, -Lori- Quote Link to comment Share on other sites More sharing options...
MarcellaE Posted April 6, 2007 Share Posted April 6, 2007 Great contribution! Thanks for it! Is there also a way to set the maximum quantity along with the minimum? Say like, you must order a minimum of 15 but no more then 15. Can this be done with this contribution? Quote Link to comment Share on other sites More sharing options...
MarcellaE Posted April 6, 2007 Share Posted April 6, 2007 Great contribution! Thanks for it! Is there also a way to set the maximum quantity along with the minimum? Say like, you must order a minimum of 15 but no more then 15. Can this be done with this contribution? ok, I "think" I got what I wanted this contrib to do regarding meeting a min *and* max value. Amanda may want to go over it to see that there will be no problems since I'm no php coder. I simply added a ">" to the if statement: for ($i=0; $i<sizeof($cat_val); $i++) { if (($cat_val[$i]["cart"] > 0) and ($cat_val[$i]["cart"] <> $cat_val[$i]["min"])) { $result = false; // use message stack for the message in the shopping cart - make sure you add the message display code there $messageStack->add_session('shopping_cart', 'Category '.get_cat_name($cat_val[$i]["id"]).' has a minimum and maximum order quantity of '.$cat_val[$i]["min"].' You currently have '.$cat_val[$i]["cart"].' in your basket'); break; } } return $result; } Quote Link to comment Share on other sites More sharing options...
InternetKev Posted April 13, 2007 Share Posted April 13, 2007 Great contribution! Any idea on how to show the discount on the shopping_cart page, near the Sub Total? I'm at a loss as to how to do this :( Quote Link to comment Share on other sites More sharing options...
HarTechSoftworks Posted December 6, 2011 Share Posted December 6, 2011 Hi there, Does anybody know how to configure this plugin so that it will fit two criteria ? Minimum order of 3 items for one category (this has been done) or If any item outside of that category and at least 1 item from the category above has been selected, the order will be processed Any help would be awesome, thanks. 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.