Skip to content

Instantly share code, notes, and snippets.

@finalwebsites
Created July 10, 2025 08:10
Show Gist options
  • Select an option

  • Save finalwebsites/3efcc80b18055c4560bff16fcb4bc2fc to your computer and use it in GitHub Desktop.

Select an option

Save finalwebsites/3efcc80b18055c4560bff16fcb4bc2fc to your computer and use it in GitHub Desktop.
Add a minimum order message to the cart page in WooCommerce
<?php
// add this code to the functions.php file from your child theme
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
function wc_minimum_order_amount() {
// Set this variable to specify a minimum order value
$minimum = 250;
$min_passed = true;
$subtotal = WC()->cart->get_subtotal();
if ( $subtotal < $minimum ) {
$min_passed = false;
$text = sprintf(
__('The minimum order amount of %s has not yet been reached. Your total is currently %s.', 'bootscore-sp'),
wc_price( $minimum ),
wc_price( $subtotal )
);
}
if (!$min_passed) {
if( is_cart() ) {
wc_print_notice( $text , 'notice' );
} else {
wc_add_notice( $text, 'notice' );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment