Skip to content

Instantly share code, notes, and snippets.

@aslamahamed13
Last active January 11, 2019 15:30
Show Gist options
  • Save aslamahamed13/9fd04b2a7ce6ce1d4fcfc08317e5dd66 to your computer and use it in GitHub Desktop.
Save aslamahamed13/9fd04b2a7ce6ce1d4fcfc08317e5dd66 to your computer and use it in GitHub Desktop.
Pizzaro - minimum order amount
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
function wc_minimum_order_amount() {
$minimum = 50;
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 place your order ' ,
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 place your order' ,
wc_price( WC()->cart->total ),
wc_price( $minimum )
), 'error'
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment