• Hi,

    i put in function.php a snippet to force the checkout only if the product quantity is an amount (6 for exemple)

    This is the code:

    // Set a minimum number of products requirement before checking out
    add_action( 'woocommerce_check_cart_items', 'pnl_set_min_num_products' );
    function pnl_set_min_num_products() {
        // Only run in the Cart or Checkout pages
        if( is_cart() || is_checkout() ) {
            global $woocommerce;
    
            // Set the minimum number of products before checking out
            $minimum_num_products = 6;
            // Get the Cart's total number of products
            $cart_num_products = WC()->cart->cart_contents_count;
     
            // Compare values and add an error is Cart's total number of products
            // happens to be less than the minimum required before checking out.
            // Will display a message along the lines of
            // A Minimum of 20 products is required before checking out. (Cont. below)
            // Current number of items in the cart: 6
            if( $cart_num_products < $minimum_num_products ) {
                // Display our error message
                wc_add_notice( sprintf( '<strong>è richiesto un minimo di %s prodotti prima del checkout.</strong>'
                    . '<br />Attualmente hai %s prodotti nel carrello.',
                    $minimum_num_products,
                    $cart_num_products ),
                    'error' );
            }
        }
    }
    

    But i want to make an exception for a single catefgory (Gift cards).

    Someone can help me to write this exception?

    thank you

    simone

    • This topic was modified 4 years, 4 months ago by simocasti.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Minimum quantity order for checkout except one category’ is closed to new replies.