Created
January 18, 2023 12:01
-
-
Save jjmontalban/5d913e146293be3c3ad57fa65f0de11a to your computer and use it in GitHub Desktop.
restringe con un importe de pedido minimo en Woo
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
/** | |
* @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