• Resolved kevrex

    (@kevrex)


    Hi. I am trying to build a store with a configurator. The customer can buy 10 objects in total. If he adds 5 of object A, he should be able to add maximum 5 units of object B, C and D.

    How can I achieve this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @kevrex

    Please try adding the code below – I would recommend using a plugin like Code Snippets to add the snippet to your site.

    /**
     * Set a maximum order amount for checkout
     */
    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 = 10;
    
        if ( WC()->cart->total > $maximum ) {
    
            if( is_cart() ) {
    
                wc_print_notice( 
                    sprintf( 'Your current order total is %s — you must have an order with a maximum of %s to place your order ' , 
                        wc_price( WC()->cart->total ), 
                        wc_price( $maximum )
                    ), 'error' 
                );
    
            } else {
    
                wc_add_notice( 
                    sprintf( 'Your current order total is %s — you must have an order with a maximum of %s to place your order' , 
                        wc_price( WC()->cart->total ), 
                        wc_price( $maximum )
                    ), 'error' 
                );
    
            }
        }
    }

    We’ve not heard back from you in a while, so I’m marking this thread as resolved. Hopefully, the above info was helpful.

    If you have further questions, please feel free to open a new topic.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Customized Configurator’ is closed to new replies.