Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'woocommerce_check_cart_items', 'min_amount_of_order' );
- // add_action( 'woocommerce_checkout_process', 'min_amount_of_order');
- // add_action( 'woocommerce_before_cart' , 'min_amount_of_order');
- function min_amount_of_order() {
- if(is_checkout() || is_cart()) {
- global $woocommerce;
- $minimum = 45; //for state 1
- $state = array('BG-23');
- $cart_total_order = WC()->cart->total;
- if( $cart_total_order < $minimum && in_array(WC()->customer->get_shipping_state(), $state ) ) {
- wc_print_notice(
- sprintf( 'You must place an order for at least %s in your cart. Your order is currently worth %s' ,
- wc_price( $minimum ),
- wc_price( WC()->cart->subtotal )
- ), 'error'
- );
- }
- }
- if (is_checkout() || is_cart()){
- global $woocommerce;
- $minimum = 30; //for state 2
- $state = array('BG-22');
- $cart_total_order = WC()->cart->total;
- if( $cart_total_order < $minimum && in_array(WC()->customer->get_shipping_state(), $state )) {
- wc_print_notice(
- sprintf( 'You must place an order for at least %s in your cart. Your order is currently worth %ss' ,
- wc_price( $minimum ),
- wc_price( WC()->cart->subtotal )
- ), 'error'
- );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement