Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Minimum Products Allowed To checkout

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 06-25-2007, 10:50 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default Minimum Products Allowed To checkout

Again another simple but useful option

We already have an option for the following

Minimum allowed order subtotal:
Maximum allowed order subtotal (0 means no maximum limit):
Maximum allowed total quantity of products in an order (0 means no maximum limit):

It would be useful to complete the set and add the following option too

Minimum allowed total quantity of products in an order (0 means no maximum limit):

Im working on a store now that wishes to set a minimum quantity ordered before you can checkout
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #2  
Old 06-25-2007, 02:32 PM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default Re: Minimum Products Allowed To checkout

As I had to do this anyway if anyone needs it heres how it can be done ...

this is done for 4.1.8 but it should not be too hard to adjust it for other versions. Its basically a rehash of the max amount setting.

for starters put this into the config table

Code:
INSERT INTO `xcart_config` ( `name` , `comment` , `value` , `category` , `orderby` , `type` , `defvalue` , `variants` ) VALUES ( 'minimum_order_items', 'Minimum allowed total quantity of products in an order (0 means no maximum limit)', '3', 'General', '320', 'numeric', '0', '' );

Then edit cart.php and find ...


Code:
if ($mode == "checkout" && !$func_is_cart_empty && $config["General"]["maximum_order_items"] > 0 && func_cart_count_items($cart) > $config["General"]["maximum_order_items"]) { # # ERROR: Cart total must not exceeds the maximum total quantity of products in an order (defined in General settings) # func_header_location("error_message.php?error_max_items"); }

and just after it add this

Code:
# # SHAN ADDED TO SET MIN AMOUNT OF PRODUCTS BEFORE CHECKOUT # if ($mode == "checkout" && !$func_is_cart_empty && $config["General"]["minimum_order_items"] > 0 && func_cart_count_items($cart) < $config["General"]["minimum_order_items"]) { # # ERROR: Cart total must not exceeds the minimum total quantity of products in an order (defined in General settings) # func_header_location("error_message.php?error_min_items"); }

Next up add the following language variable via the languages section
Code:
topic - errors code - err_checkout_min_items_msg text - The quantity of products in one order must exceed {{quantity}} items.<br /> Please review your cart and add more items before you can checkout.

next up edit skin1/customer/home_main.tpl

find
Code:
{elseif $main eq "error_max_items"} {include file="main/error_max_items.tpl"}

and just after it add this ..
Code:
{elseif $main eq "error_min_items"} {include file="main/error_min_items.tpl"}


finally make a new tpl file (you can make a copy of error_max_itemps.tpl)

skin1/main/error_min_items.tpl

this is the code for the template file

Code:
{* $Id: error_min_items.tpl,v 1.2 2005/11/17 06:55:39 max Exp $ *} <font class="ErrorMessage"> {$lng.err_checkout_min_items_msg|substitute:"quantity":$config.General.minimum_order_items} <br /><br /> {include file="buttons/go_back.tpl"} </font>

you should now be able to set the minimum amount of items that need to be added to the cart before someone can checkout. If you leave this as zero then it will be ignored
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:53 PM.

   

 
X-Cart forums © 2001-2020