• I already found this for minimum order amount:

    
    add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
    add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
     
    function wc_minimum_order_amount() {
        // Set this variable to specify a minimum order value
        $minimum = 1;
    
        if ( WC()->cart->total < $minimum ) {
    
            if( is_cart() ) {
    
                wc_print_notice( 
                    sprintf( 'You must have an order with a minimum of %s to place your order, your current order total is %s.' , 
                        wc_price( $minimum ), 
                        wc_price( WC()->cart->total )
                    ), 'error' 
                );
    
            } else {
    
                wc_add_notice( 
                    sprintf( 'You must have an order with a minimum of %s to place your order, your current order total is %s.' , 
                        wc_price( $minimum ), 
                        wc_price( WC()->cart->total )
                    ), 'error' 
                );
    
            }
        }
    
    }

    Just copy the above scrtpt changing “minimum” by “maximum” and setting $maximum=104 didn’t work.

    But I want as well a minimum as a maximum order amount. So what do I add?

Viewing 1 replies (of 1 total)
  • add_action( 'woocommerce_checkout_process', 'wc_maximum_order_amount' );
    add_action( 'woocommerce_before_cart' , 'wc_maximum_order_amount' );
     
    function wc_maximum_order_amount() {
        // Set this variable to specify a maximum order value
        $maximum = 104;
    
        if ( WC()->cart->total > $maximum ) {
    
            if( is_cart() ) {
    
                wc_print_notice( 
                    sprintf( 'You must have an order with a maximum of %s to place your order, your current order total is %s.' , 
                        wc_price( $maximum ), 
                        wc_price( WC()->cart->total )
                    ), 'error' 
                );
    
            } else {
    
                wc_add_notice( 
                    sprintf( 'You must have an order with a maximum of %s to place your order, your current order total is %s.' , 
                        wc_price( $maximum ), 
                        wc_price( WC()->cart->total )
                    ), 'error' 
                );
    
            }
        }
    
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Maximum order amount’ is closed to new replies.