Skip to content

Instantly share code, notes, and snippets.

@brandalismo
Created March 21, 2017 20:31
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 brandalismo/2403bc4b6fb26892b0fb79681676fcdc to your computer and use it in GitHub Desktop.
Save brandalismo/2403bc4b6fb26892b0fb79681676fcdc to your computer and use it in GitHub Desktop.
/*
* HABILITAR CANTIDAD MÍNIMA DE PEDIDO
*/
function woo_minimum_order_amount() {
$minimum = 10; //Establecer importe mínimo de compra
if ( WC()->cart->total < $minimum ) {
if( is_cart() ) {
wc_print_notice(
sprintf( 'Debes realizar un pedido mínimo de %s para finalizar tu compra.' , // Personalizar
wc_price( $minimum ),
wc_price( WC()->cart->total )
), 'error'
);
} else {
wc_add_notice(
sprintf( 'Debes realizar un pedido mínimo de %s para finalizar tu compra.' , // Personalizar
wc_price( $minimum ),
wc_price( WC()->cart->total )
), 'error'
);
}
}
}
add_action( 'woocommerce_checkout_process', 'woo_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'woo_minimum_order_amount' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment