X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Minimum Products Allowed To checkout (https://forum.x-cart.com/showthread.php?t=32071)

shan 06-25-2007 10:50 AM

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

shan 06-25-2007 02:32 PM

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


All times are GMT -8. The time now is 04:22 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.