Home Forums WoodMart support forum Set up a minimum order quantity of a product

Set up a minimum order quantity of a product

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #660582

    wautore
    Participant

    Hi, how can I set up a minimum order quantity of a product.
    So for example: the minimum order quantity is based on €100, so if the amount of product is less then 100€ people can’t buy products. How can I make this fiesable?

    #660637

    Hello,

    There is no option available for this in the theme settings. This requires customization, which is beyond our support policy.

    I have searched for a possible solution and found a custom function that you can add to your functions.php file. I have tested this code on our test site, and it is working fine.

    If the provided code does not work as expected, unfortunately, we are unable to modify it further.

    Add this to your theme’s functions.php file of the theme.

    add_action( 'woocommerce_checkout_process', 'pk_minimum_order_amount' );
    add_action( 'woocommerce_before_cart', 'pk_minimum_order_amount' );
    
    function pk_minimum_order_amount() {
        $minimum = 100; // Minimum order amount in Euros
    
        if ( WC()->cart->total < $minimum ) {
            if ( is_cart() ) {
                wc_print_notice(
                    sprintf( 'The minimum order amount is €%s. Your current order total is €%s.', $minimum, WC()->cart->total ),
                    'error'
                );
            } else {
                wc_add_notice(
                    sprintf( 'The minimum order amount is €%s. Your current order total is €%s.', $minimum, WC()->cart->total ),
                    'error'
                );
            }
        }
    }

    Best Regards,

Viewing 2 posts - 1 through 2 (of 2 total)