Home / Admin / Set a minimum order amount in WooCommerce – No Plugin used
Duplicate Snippet

Embed Snippet on Your Site

Set a minimum order amount in WooCommerce – No Plugin used

Post More Detail
Learn how to Set a minimum order amount in WooCommerce. Customer will not be able to checkout if minimum amount isn’t reached. No plugin used, just code snippets.
To set a minimum order amount you can use woocommerce_check_cart_items action hook this way:

Code Preview
php
<?php
add_action( 'woocommerce_check_cart_items', 'required_min_cart_subtotal_amount' );
function required_min_cart_subtotal_amount() {
    // HERE Set minimum cart total amount
    $minimum_amount = 250;
    // Total (before taxes and shipping charges)
    $cart_subtotal = WC()->cart->subtotal;
    // Add an error notice is cart total is less than the minimum required
    if( $cart_subtotal < $minimum_amount  ) {
        // Display an error message
        wc_add_notice( '<strong>' . sprintf( __("A minimum total purchase amount of %s is required to checkout."), wc_price($minimum_amount) ) . '</strong>', 'error' );
    }
}

Comments

Add a Comment