Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Category Trees Minimum Order Quantity boxtel 14 Apr 2006

 

This very simple package enables you to set a minimum order quantity for multiple category trees.

 

You enter the top category id's and the minimum order quantities, all products residing under those top categories are counted.

 

At checkout those conditions are checked and if not ok, redirection is forced back to the shopping cart with a message.

 

there is no admin control but that extention should be straightforward.

---

 

 

I am trying to run this with STS and master products - does anyone have any experience with this contribution and those contributions?

Posted (edited)

from the install instructions:

2) add the possible message code for the message stack to shopping_cart.php (see login.php for location example)

 

<?php if ($messageStack->size('shopping_cart') > 0) { ?>

<tr>

<td><?php echo $messageStack->output('shopping_cart'); ?></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php } ?>

 

Parse error: syntax error, unexpected '<' in /home/mpmorg/public_html/shop/shopping_cart.php on line 19

 

when I moved it to resemble the message stack position in login.php I get this error

 

Parse error: syntax error, unexpected $end in /home/mpmorg/public_html/shop/shopping_cart.php on line 431

Edited by mpm
Posted
from the install instructions:

2) add the possible message code for the message stack to shopping_cart.php (see login.php for location example)

 

<?php if ($messageStack->size('shopping_cart') > 0) { ?>

<tr>

<td><?php echo $messageStack->output('shopping_cart'); ?></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php } ?>

 

Parse error: syntax error, unexpected '<' in /home/mpmorg/public_html/shop/shopping_cart.php on line 19

 

when I moved it to resemble the message stack position in login.php I get this error

 

Parse error: syntax error, unexpected $end in /home/mpmorg/public_html/shop/shopping_cart.php on line 431

 

that is a <?php ?> issue.

 

in login.php you see this code:

 

<?php

if ($messageStack->size('login') > 0) {

?>

<tr>

<td><?php echo $messageStack->output('login'); ?></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php

}

 

if ($cart->count_contents() > 0) {

?>

 

 

so be aware of not closing php with ?> if the next code expects it to be still open.

 

 

so in shopping_cart.php put this code:

 

<?php if ($messageStack->size('shopping_cart') > 0) { ?>

<tr>

<td><?php echo $messageStack->output('shopping_cart'); ?></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php } ?>

 

just after this code:

 

<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

<td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_cart.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

</tr>

</table></td>

</tr>

Treasurer MFC

Posted
that is a <?php ?> issue.

 

in login.php you see this code:

 

<?php

if ($messageStack->size('login') > 0) {

?>

<tr>

<td><?php echo $messageStack->output('login'); ?></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php

}

 

if ($cart->count_contents() > 0) {

?>

so be aware of not closing php with ?> if the next code expects it to be still open.

so in shopping_cart.php put this code:

 

<?php if ($messageStack->size('shopping_cart') > 0) { ?>

<tr>

<td><?php echo $messageStack->output('shopping_cart'); ?></td>

</tr>

<tr>

<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>

</tr>

<?php } ?>

 

just after this code:

 

<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

<td class="pageHeading" align="right"><?php echo tep_image(DIR_WS_IMAGES . 'table_background_cart.gif', HEADING_TITLE, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

</tr>

</table></td>

</tr>

 

 

and in the function cat_min_order_ok :

 

 

change this code:

 

$messageStack->add('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');

 

 

to this code:

 

$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');

 

so add -> add_session

to make it display right

Treasurer MFC

Posted (edited)

Hi Boxtel,

 

Thanks for your help so far. I'm working through it slowly.

 

Currently I have this error:

 

 

Fatal error: Call to undefined function: tep_get_cat_path() in /home/mpmorg/public_html/shop/includes/functions/general.php on line 46

Edited by mpm
Posted
Hi Boxtel,

 

Thanks for your help so far. I'm working through it slowly.

 

Currently I have this error:

Fatal error: Call to undefined function: tep_get_cat_path() in /home/mpmorg/public_html/shop/includes/functions/general.php on line 46

 

ok, then add this function to general.php

 

function tep_get_cat_path ($current_category_id = '') {

$last_category['parent_id'] = 1;

$cat_string = $current_category_id;

while ($last_category['parent_id'] != 0) {

$last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . $current_category_id . "'");

$last_category = tep_db_fetch_array($last_category_query);

if ($last_category['parent_id'] != 0) $cat_string = $last_category['parent_id'] . '_' . $cat_string;

$current_category_id = $last_category['parent_id'];

}

return $cat_string;

}

Treasurer MFC

Posted

Thank you Boxtel you've been a saint!

 

It works a charm!

 

This contribution is officially indispensible!

Posted

This is a very promising add-on for my shop. I have one issue that I can't work out...

 

The contrib works well up to the point that it catches a below minimum order at the checkout_shipping and returns customer to the cart. Should the customer update the Quantity from within the cart and proceed with checkout, the new quantity is not recognized so the customer cannot checkout.

 

Can someone help?

Posted
This is a very promising add-on for my shop. I have one issue that I can't work out...

 

The contrib works well up to the point that it catches a below minimum order at the checkout_shipping and returns customer to the cart. Should the customer update the Quantity from within the cart and proceed with checkout, the new quantity is not recognized so the customer cannot checkout.

 

Can someone help?

 

it will if you update your cart first.

Treasurer MFC

Posted

Thanks boxtel -- turned out to be a dumb typo in the cat_val array on my part! (put the minimum in cart => :blush: ) So that all works great :)

 

However, if a product with available options is placed in the cart and the min. is not met it is still passed to checkout.

Posted
Thanks boxtel -- turned out to be a dumb typo in the cat_val array on my part! (put the minimum in cart => :blush: ) So that all works great :)

 

However, if a product with available options is placed in the cart and the min. is not met it is still passed to checkout.

 

no it isn't.

Treasurer MFC

Posted
It is on my test site -- sending you log in info via PM

 

yes, I see that but I cannot see why.

 

the function takes the bare products_id via

$t_prid = tep_get_prid($products[$p]['id']);

 

which means regardless of attributes.

 

you could put this code :

error_log(tep_get_prid($products[$p]['id']).'->'.$t_prid);

 

after that statement.

then try to checkout with products that have attributes and tell me what your error log says.

Treasurer MFC

Posted

Excellent Contrib Boxtel, ive been waiting for this for awhile now :) Thank you

 

Installed, works great... but ofcorse i have one question. Its more of a php question then it is for your contrib.

 

How can i add color, different from that of the normal text on the shopping_cart.php for the Error Msg ? The msg that is displayed if they dont have the quanity right for the category.

 

$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');

 

I know where to change it, again just not sure of the php code, and i dont imagine html color tag will work.

 

Thank you

 

Frik

Posted
Excellent Contrib Boxtel, ive been waiting for this for awhile now :) Thank you

 

Installed, works great... but ofcorse i have one question. Its more of a php question then it is for your contrib.

 

How can i add color, different from that of the normal text on the shopping_cart.php for the Error Msg ? The msg that is displayed if they dont have the quanity right for the category.

 

$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');

 

I know where to change it, again just not sure of the php code, and i dont imagine html color tag will work.

 

Thank you

 

Frik

 

not using that messagestack anymore but html should be ok in there.

Treasurer MFC

Posted
not using that messagestack anymore but html should be ok in there.

 

huh... well i'll be

 

Thanks again, guess i never knew how to exactly do that, but after a lil playing around. You were right.

 

Again, thank you for sharing this contrib :)

 

Frik

Posted
huh... well i'll be

 

Thanks again, guess i never knew how to exactly do that, but after a lil playing around. You were right.

 

Again, thank you for sharing this contrib :)

 

Frik

 

you can look in the messagestack class where the different message types are controlled.

You will see that it uses some css definitions as well.

 

But as I said, I don't use it anymore as new message implementation is cumbersome and I do not need/want a facility which was designed to spit out a truckload of messages in one go.

So in most contributions I have to put it back in which is not always easy as I can only barely test that part.

Treasurer MFC

Posted
I know where to change it, again just not sure of the php code, and i dont imagine html color tag will work.

 

Thank you

 

Frik

 

You can change the color, font, etc. from the stylsheet.css but that will change for all error messages not just this one...

 

.messageBox { font-family: Verdana, Arial, sans-serif; font-size: 10px; }
.messageStackError, .messageStackWarning { font-family: Verdana, Arial, sans-serif; font-size: 10px; background-color: #ffb3b5; }
.messageStackSuccess { font-family: Verdana, Arial, sans-serif; font-size: 10px; background-color: #99ff00; }

Posted
after that statement.

then try to checkout with products that have attributes and tell me what your error log says.

 

Thanks -- I will check it this afternoon and get back to you

Posted (edited)
yes, I see that but I cannot see why.

 

the function takes the bare products_id via

$t_prid = tep_get_prid($products[$p]['id']);

 

which means regardless of attributes.

 

you could put this code :

error_log(tep_get_prid($products[$p]['id']).'->'.$t_prid);

 

after that statement.

then try to checkout with products that have attributes and tell me what your error log says.

 

Script doesn't generate an error, it is reading the product_id string - ie. 26{3}8 - as the product ID; the function is not removing from {

 

I changed to use the function tep_get_uprid and have it working without problem so far.

 

Changed in includes/functions/general.php:

 $t_prid = tep_get_prid($products[$p]['id']);

 

to:

 $t_prid = tep_get_uprid($products[$p]['id'], $attributes);

Edited by Maureen
Posted

Hello

 

I've just installed the Category Trees Minimum Order Quantity mod, and as I'm not that proficient with php, I can't figure out:

 

how you select the categories to apply the mod to

how to set the minimum order amount

 

Can anyone help please - thanks

Posted
Hello

 

I've just installed the Category Trees Minimum Order Quantity mod, and as I'm not that proficient with php, I can't figure out:

 

how you select the categories to apply the mod to

how to set the minimum order amount

 

Can anyone help please - thanks

 

Darren,

 

The author has this coded in the changes you made to includes/functions/general.php

 

function cat_min_order_ok () {
global $cart, $messageStack;
$result = true;
$cat_val = array();
// top category id's with minimum quantities, might later put these in an admin section
//$cat_val[] = array('id' => 102, 'min' => 10, 'cart' => 0);
//$cat_val[] = array('id' => 158, 'min' => 10, 'cart' => 0);

 

The two lines from above the begin //$cat_val[] are the lines you change/add to select your category and minimum order. Replace the number following 'id' => to your category id and the 'min' => to your minimum. Remove the two forward slashes from the front of the statement. So if your parent categories are category id 1 and 100 with minimum of 5/10 items, your code would look like this:

 

function cat_min_order_ok () {
global $cart, $messageStack;
$result = true;
$cat_val = array();
// top category id's with minimum quantities, might later put these in an admin section
$cat_val[] = array('id' => 1, 'min' => 5, 'cart' => 0);
$cat_val[] = array('id' => 100, 'min' => 10, 'cart' => 0);

 

If you don't know your category ID numbers you can either look in the link path in admin or check your database.

  • 2 weeks later...
Posted

Thanks for the reply

 

I've now edited includes/functionsgeneral.php to this:

 

$cat_val[] = array('id' => 33, 'min' => 10, 'cart' => 0);

$cat_val[] = array('id' => 32, 'min' => 10, 'cart' => 0);

$cat_val[] = array('id' => 31, 'min' => 10, 'cart' => 0);

$cat_val[] = array('id' => 30, 'min' => 10, 'cart' => 0);

 

After uploading it and attempting to checkout I get this message:

 

Fatal error: Call to undefined function: tep_get_cat_path() in /home/virtual/site62/fst/var/www/html/iden_shop/includes/functions/general.php on line 1334

 

Can you help please?

 

Thanks

  • 2 months later...
Posted

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-

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.

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