• Resolved stranyer

    (@stranyer)


    Hi!

    I want to set up a limit qty of single products you can add from funnel to cart.

    Is there a snippet or indication of where you inspect to make such modification?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support angelagrey

    (@angelagrey)

    Hi,

    Thank you for reaching out to us.

    Yes, we have an option “Products quantity limit”, it is available in the pro version only.

    Best regards.

    Thread Starter stranyer

    (@stranyer)

    My client has the pro version, and I see the Products Quantity Limit, but that only affects how many of a specific product you can add to your cart.

    What I need, is for ex: I have a funnel with 5 unique products to select, I want to limit the users to only be able to select 2 out of the 5. And it shouldn’t let you select a 3rd product.

    What I did for a workaround is to modify function viwcuf_us_woocommerce_add_to_cart_quantity for:

    if ( isset( $_REQUEST['viwcuf_us_product_id'] ) ) {
    
                $qty = isset($_REQUEST['quantity']) ? floatval(sanitize_text_field($_REQUEST['quantity'])): 1;
    
                // Determine the total number of upsell products already in the cart
    
                $current_upsell_products_in_cart = 0;
    
                foreach ( WC()->cart->get_cart() as $cart_item ) {
    
                    if ( isset($cart_item['viwcuf_us_product']) ) {
    
                        $current_upsell_products_in_cart += $cart_item['quantity'];
    
                    }
    
                }
    
                // Check if adding the new products will exceed the limit of 2
    
                if ($current_upsell_products_in_cart + $qty > 2) {
    
                    wc_add_notice( __( 'Solo puedes agregar un máximo de 2 productos.', 'woocommerce-checkout-upsell-funnel' ), 'error' );
    
                    return 0;  // Do not add the product to the cart
    
                }
    
                return $qty;  // Allow the product to be added to the cart
    
            }
    • This reply was modified 1 year, 5 months ago by stranyer.
    Plugin Support angelagrey

    (@angelagrey)

    It’s that option. You can set Products limit to be 5 and Products quantity limit to be 2 >> So customer can only add 2 items to cart

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Limit products you can add to cart’ is closed to new replies.