Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Category Trees Minimum Order Quantity


Guest

Recommended Posts

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;

}

Treasurer MFC

Link to comment
Share on other sites

  • 2 months later...

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 by phantompressents
Link to comment
Share on other sites

  • 2 weeks later...

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

Link to comment
Share on other sites

  • 2 weeks later...
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-

Link to comment
Share on other sites

  • 4 months later...

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?

Link to comment
Share on other sites

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;

}

Link to comment
Share on other sites

  • 4 years later...

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.

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