Skip to content

Instantly share code, notes, and snippets.

@jjmontalban
Created March 3, 2023 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjmontalban/cd3faccd96852c19d2d180e260d89ff2 to your computer and use it in GitHub Desktop.
Save jjmontalban/cd3faccd96852c19d2d180e260d89ff2 to your computer and use it in GitHub Desktop.
Importe de pedido minimo
/**
* @snippet Minimum Order Amount
* @author JJMontalban
*/
//woocommerce_check_cart_items will give the customer an warning when reaching the checkout unless purchase requirement is met.
add_action( 'woocommerce_check_cart_items', 'jj_minimum_order_amount' );
add_action( 'woocommerce_before_cart', 'jj_minimum_order_amount' );
function jj_minimum_order_amount() {
$minimum = 30; // change this to your minimum order amount
if ( WC()->cart->subtotal < $minimum ) {
if ( is_cart() ) {
wc_print_notice(
sprintf( 'Debe hacer un pedido mínimo de %s para finalizar su pedido. Su pedido actual es de %s.' , wc_price( $minimum ), wc_price( WC()->cart->subtotal ) ), 'error' );
} else {
wc_add_notice(
sprintf( 'Debe hacer un pedido mínimo de %s para finalizar su pedido. Su pedido actual es de %s.' , wc_price( $minimum ), wc_price( WC()->cart->subtotal ) ), 'error' );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment