Setting a Minimum Order Amount in Woocommerce

[et_pb_section fb_built=”1″ admin_label=”section” _builder_version=”4.16″ da_disable_devices=”off|off|off” global_colors_info=”{}” da_is_popup=”off” da_exit_intent=”off” da_has_close=”on” da_alt_close=”off” da_dark_close=”off” da_not_modal=”on” da_is_singular=”off” da_with_loader=”off” da_has_shadow=”on”][et_pb_row admin_label=”row” _builder_version=”4.22.1″ background_size=”initial” background_position=”top_left” background_repeat=”repeat” custom_margin=”|0px||0px|false|false” custom_padding=”|0px||0px|false|false” global_colors_info=”{}”][et_pb_column type=”4_4″ _builder_version=”4.16″ custom_padding=”|||” global_colors_info=”{}” custom_padding__hover=”|||”][et_pb_text _builder_version=”4.22.1″ _module_preset=”default” global_colors_info=”{}”]If you want to set a minimum order amount in Woocommerce, there is a simple fix that can be added to functions.php in your website theme.[/et_pb_text][et_pb_code _builder_version=”4.22.1″ _module_preset=”default” global_colors_info=”{}”]
function w321_set_minimum_order_amount() {    // Set the minimum order amount    $minimum = 30;    // Get the Cart's total    $cart_total = WC()->cart->total;    // If the Cart's total is less than the minimum amount, display an error    if ($cart_total < $minimum) {        wc_add_notice(            sprintf('Your current order total is %s — you must have an order with a minimum of %s to place your order.',                 wc_price($cart_total),                 wc_price($minimum)            ),             'error'        );    }}add_action('woocommerce_check_cart_items', 'w321_set_minimum_order_amount');
[/et_pb_code][et_pb_text _builder_version=”4.22.1″ _module_preset=”default” hover_enabled=”0″ global_colors_info=”{}” sticky_enabled=”0″]

Here’s a step-by-step guide to implement this:

  1. Backup your WordPress site: Always take a backup before making any changes. This way, you can easily revert back if something goes wrong.
  2. Add the code: You can add the above PHP code in one of the following places:
    • Child Theme’s functions.php file: If you are using a child theme, you can add the code to your child theme’s functions.php file. This ensures that your changes aren’t overwritten when the parent theme updates.
    • Custom Plugin: If you prefer to keep your customizations separate from your theme, you can create a simple custom plugin and add the code there.
  3. Test: After adding the code, try adding items to your cart and checking out with less than $30 to see if the error message appears.
  4. Adjust the minimum value: If in the future you want to change the minimum order amount, just adjust the $minimum value in the code.

Remember that while this method sets a minimum transaction amount, there may be additional configurations or plugins on your WooCommerce site that could conflict with this. Always test thoroughly after making changes.

[/et_pb_text][/et_pb_column][/et_pb_row][/et_pb_section]

We’ll take good care of your website.

Copyright © 2025 – Web321 | All Right Reserved