Jump to content

limit product-quantity selection to available


amorxoigel

Recommended Posts

I guys!
i was wondering if i could set a limit to product-quantity selection on the product-add-to-cart.tpl page.

 

            <div class="product-quantity">
                <div class="qty">
                    <span class="control-label">{l s='Quantity:' d='Shop.Theme.Catalog'}</span>
                    <input
                        type="text"
                        name="qty"
                        id="quantity_wanted"
                        value="{$product.quantity_wanted}"
                        class="input-group"
                        min="{$product.minimal_quantity}"
                        />
                </div>
                <div class="add">
				{if $product.add_to_cart_url}
                    <button onclick="return validateSelection();" class="btn btn-primary add-to-cart" data-button-action="add-to-cart" type="submit">
                        <i class="fa fa-shopping-basket">{l s=' BUY NOW!' d='Shop.Theme.Catalog'}</i>
                    </button>      
				{/if}
				{if !$product.add_to_cart_url}
                    <button class="btn btn-primary add-to-cart" data-button-action="add-to-cart" type="submit" disabled="">
                        <i class="fa fa-shopping-basket"> {l s=' SOLD OUT' d='Shop.Theme.Catalog'}</i>
                    </button>      
				{/if}				
                    {hook h='displayProductListFunctionalButtons' product=$product}
                    {hook h='displayCompareButton' product=$product}
                </div>
            </div>

This is the parte of the code i think i've to change.
What i'm trying to achieve is this:
image.png.a1404869ed105c4696947830cf715f82.png
i dont want to be able to add 800 item when there's only like 10 available. I would like i could only choose as max the number of items that are available.
I'm on prestashop 1.7.6
If anyone could help me it would be nice

Edited by amorxoigel (see edit history)
Link to comment
Share on other sites

My idea is to edit here:
 

<input
                        type="text"
                        name="qty"
                        id="quantity_wanted"
                        value="{$product.quantity_wanted}"
                        class="input-group"
                        min="{$product.minimal_quantity}"
       					max="{MAXIMUM QUANTITY FOR THE PRODUCT SELECTED}"
/>

Do you know what variable should i use?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...