Skip to content
  • Quick Ref
  • Contact
  • About
wpcanyon.com

wpcanyon.com

WooCommerce: Set a minimum order amount with a message

Posted on August 19, 2025 By Admin No Comments on WooCommerce: Set a minimum order amount with a message

WooCommerce: Set a Minimum Order Amount with a Message

If you run a WooCommerce store, you might want to enforce a minimum order amount to ensure profitability or cover shipping costs. This tutorial shows you how to set a minimum order amount and display a clear message to customers when their cart total doesn’t meet the requirement.

Quick Fix

  1. Add a custom PHP snippet to your theme’s functions.php file or a site-specific plugin.
  2. Set your desired minimum order amount in the code.
  3. Customize the message shown to customers if the minimum is not met.
  4. Test the checkout process to confirm the restriction and message appear correctly.

Why This Happens

WooCommerce by default does not restrict customers from placing orders below a certain amount. This can lead to unprofitable sales or increased shipping costs that erode margins. Setting a minimum order amount helps maintain business rules by preventing checkout until the cart total reaches the threshold.

Without this restriction, customers might place orders that are too small to process efficiently or economically. The custom code hooks into WooCommerce’s validation process to enforce this rule and provide user feedback.

Requirements

  • WooCommerce installed and active on your WordPress site.
  • Access to your theme’s functions.php file or ability to add custom PHP code via a plugin.
  • Basic familiarity with editing WordPress theme files or using a code snippet plugin.

Step-by-step: Set a Minimum Order Amount in WooCommerce

  1. Backup your site: Always create a backup before editing theme files.
  2. Open your theme’s functions.php file: Use FTP, cPanel File Manager, or the WordPress theme editor.
  3. Add the following code snippet at the end of the file:
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );

function wc_minimum_order_amount() {
    // Set minimum order amount
    $minimum = 50; // Change this value to your desired minimum order amount

    if ( WC()->cart->total < $minimum ) {
        if( is_cart() ) {
            wc_print_notice( 
                sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to proceed to checkout.', 
                    wc_price( WC()->cart->total ), 
                    wc_price( $minimum )
                ), 'error' 
            );
        } else {
            wc_add_notice( 
                sprintf( 'Your current order total is %s — you must have an order with a minimum of %s to proceed to checkout.', 
                    wc_price( WC()->cart->total ), 
                    wc_price( $minimum )
                ), 'error' 
            );
        }
    }
}
  1. Save the file.
  2. Test your store: Add products to your cart with a total below the minimum amount and try to proceed to checkout. You should see the error message preventing checkout.
  3. Adjust the $minimum value in the code snippet to your preferred minimum order amount.

Common Pitfalls

  • Editing the wrong file: Avoid editing WooCommerce plugin files directly. Use your child theme’s functions.php or a custom plugin.
  • Not backing up: Always back up before making changes to avoid site downtime.
  • Incorrect minimum value: Ensure the minimum amount is a numeric value and matches your currency format.
  • Cache issues: If changes don’t appear, clear your site and browser cache.
  • Theme conflicts: Some themes or plugins may override WooCommerce notices. Test with default themes if issues arise.

Works on

Environment Compatibility
Web Servers Apache, Nginx, LiteSpeed
Hosting Panels cPanel, Plesk, DirectAdmin
WooCommerce Versions WooCommerce 3.0 and above
WordPress Versions WordPress 5.0 and above

FAQ

Q: Can I set different minimum order amounts for different user roles?
A: Yes. You can modify the code to check the user role using current_user_can() or wp_get_current_user() and set different minimums accordingly.
Q: How do I change the minimum order amount currency?
A: The code uses wc_price() which automatically formats the amount based on your WooCommerce currency settings.
Q: Can I display the minimum order message on the cart page as well?
A: Yes. The provided code hooks into both the cart and checkout pages to show the message in both places.
Q: What if I want to set a minimum quantity instead of amount?
A: You would need to check WC()->cart->get_cart_contents_count() instead of WC()->cart->total and adjust the logic accordingly.
Q: Will this prevent orders below the minimum amount from being placed?
A: Yes. The code adds an error notice and prevents checkout submission until the minimum order amount is met.
WooCommerce How‑tos Tags:Cart, Validation, WooCommerce

Post navigation

Previous Post: Fix “Sorry, you are not allowed to access this page”
Next Post: Disable XML‑RPC in WordPress (and what breaks if you do)

Leave a Reply Cancel reply

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

Recent Posts

  • Top WordPress Themes for Blogs in 2025
  • WordPress Admin Panel Trick: Adding ID Field to the Posts Listing
  • Solution previous_posts_link and next_posts_link Not Working
  • Show Top Commentators in WordPress Without a Plugin
  • How to Style Admin Comments in WordPress

Recent Comments

    Archives

    • August 2025

    Categories

    • Admin & Blocks
    • Admin & UI
    • Automation
    • Automation & Plugins
    • Comments
    • Comparisons
    • Database & Revisions
    • Developer Snippets
    • Fixes & Errors
    • Media & Thumbnails
    • Queries & Pagination
    • Security
    • Speed & Security
    • Tips & Tricks
    • WooCommerce How‑tos
    • WordPress Snippets
    • WordPress Themes
    • Terms & Conditions
    • Affiliate Disclosure

    Copyright © 2025 wpcanyon.com.

    Powered by PressBook WordPress theme

    Also by the maker of MySurveyReviews.com