• Resolved iak3

    (@iak3)


    Good morning,

    Hope you can help me.

    I have about 5000 products and all of theme are imported and uptadated through an xml generated by my management software (including the attributes of the products).

    One of this attributes (already set and shown on woocommerce product page) is about the minimum order.

    Is there a way to set the Minimum step quantity of the products using this attributes?

    Thank you

    • This topic was modified 1 year, 6 months ago by iak3.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @iak3

    Yes, you can set the minimum order quantity using the attributes in your XML file. However, this requires custom coding, which involves hooking into the woocommerce_quantity_input_args filter and adjust the min_value based on your attributes.

    Please note that this is a complex process and might require the assistance of a developer if you’re not familiar with coding.

    Alternatively, you can use the Min/Max Quantities plugin, which allows you to specify minimum and maximum quantity limits per product, variation, orders, categories, etc.

    I hope this helps! If you have any other questions, feel free to ask.

    Thread Starter iak3

    (@iak3)

    First of all, thank you for your explanation and help.

    I am not a developer but i am familiar with coding, so i think i will try.

    Do you have any advices? ??

    The code inside the Function.php file, right?

    /** * Adjust the quantity input values */ add_filter( 'woocommerce_quantity_input_args', 'jk_woocommerce_quantity_input_args', 10, 2 ); // Simple products function jk_woocommerce_quantity_input_args( $args, $product ) { if ( is_singular( 'product' ) ) { $args['input_value'] = 2; // Starting value (we only want to affect product pages, not cart) } $args['max_value'] = 80; // Maximum value $args['min_value'] = 2; // Minimum value $args['step'] = 2; // Quantity steps return $args; } add_filter( 'woocommerce_available_variation', 'jk_woocommerce_available_variation' ); // Variations function jk_woocommerce_available_variation( $args ) { $args['max_qty'] = 80; // Maximum value (variations) $args['min_qty'] = 2; // Minimum value (variations) return $args; }

    Right now, i am using Min/Max Quantities, but i have too many products to follow and the data i need is already imported through my management software.

    Thank you

    • This reply was modified 1 year, 5 months ago by iak3.
    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @iak3

    Yes, you’re correct, the code you’ve shared should be placed in your theme’s functions.php file. However, please make sure to use a child theme to avoid losing your changes when the theme updates.

    Your code looks fine; it sets the minimum and maximum quantities for both simple and variable products. However, please note that the input_value only affects the product pages and not the cart.

    If you have too many products and you’re managing them through your software, you might want to consider using a custom function that pulls the min/max values from your product attributes or custom fields. This way, you can manage the quantities directly from your software and the changes will be reflected on your website.

    Best of luck with your coding!

    Thread Starter iak3

    (@iak3)

    Perfect, thank you.

    Yes, this is exactly what I want to do. But I need to do it for the cart too, so I’ll bother you again.

    Thank you ??

    Plugin Support Shameem R. a11n

    (@shameemreza)

    Hi @iak3

    I’m glad we were able to help!

    I’ll be marking the thread as solved for now, but feel free to create a new topic if you need further help with WooCommerce core.

    Also, if it isn’t too much to ask for – would you mind leaving us a review here?

    It only takes a couple of minutes but helps us tremendously. It would mean so much to us and would go a really long way.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Minimum step quantity product based on attribute’ is closed to new replies.