Stop People Checking Out? Huh?

By | December 11, 2008

Interesting question posed at the osCommerce forum;

All my products are 5lbs each. Is there a way to set a minimum order of 10lbs. This would mean they have to purchase a minimum of two items (2 of the same product or 2 different products).

Is there a way in the USPS shipping module or any other file to set a minimum order of 10lbs or 2 products?

Easiest way is to do it on the 2 product minimum purchase, as I have already covered this in a previous post. cart->count_contents() is the code to use in this case…

So here is my answer to the question…

Add this in checkout_shipping.php, underneath require(‘includes/application_top.php’);

[php]if ($cart->count_contents() < 2 ) tep_redirect(tep_href_link(FILENAME_SHOPPING_CART, 'error_message=' . urlencode(ERROR_NOT_ENOUGH_IN_CART)));[/php] How simple was that? The line of code basically says:

IF the number of products in the cart at checkout time is LESS THAN 2, then REDIRECT the user back to the Shopping Cart and DISPLAY an error message to tell him/her so.

Obviously you also need to make the define in the language file (includes/languages{your language}/shopping_cart.php):

[php]define(‘ERROR_NOT_ENOUGH_IN_CART’, ‘You have not purchased enough stuff. Buy more you fool.’);[/php]

Nice, quick and easy solution – always best to keep things as simple as possible in case you ever want to change it in the future.

Leave a Reply

Your email address will not be published. Required fields are marked *