Created
November 23, 2017 11:53
-
-
Save fbmoises/fbf83129fef02b9c1a8730ad541dcef6 to your computer and use it in GitHub Desktop.
Establecer un importe de pedido mínimo para tu tienda online. Si el pedido es inferior a esa cantidad se mostrará un mensaje en el checkout.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Establecer un importe de pedido mínimo para tu tienda online. Si el pedido es inferior a esa cantidad se mostrará un mensaje en el checkout. | |
add_action( 'woocommerce_checkout_process', 'wcfb_minimum_order_amount' ); | |
add_action( 'woocommerce_before_cart' , 'wcfb_minimum_order_amount' ); | |
function wcfb_minimum_order_amount() { | |
// Cambiar este valor por el importe de pedido mínimo de tu tienda | |
$minimum = 20; | |
if ( WC()->cart->total < $minimum ) { | |
if( is_cart() ) { | |
wc_print_notice( | |
sprintf( 'El pedido mínimo es de %s impuestos incluidos, actualmente su pedido es de %s.' , | |
wc_price( $minimum ), | |
wc_price( WC()->cart->total ) | |
), 'error' | |
); | |
} else { | |
wc_add_notice( | |
sprintf( 'El pedido mínimo es de %s impuestos incluidos, actualmente su pedido es de %s.' , | |
wc_price( $minimum ), | |
wc_price( WC()->cart->total ) | |
), 'error' | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment