maladal Posted July 11, 2015 Share Posted July 11, 2015 Hello, I want to set 3 different infos for product quantity in product page: 1. If product has 1 pcs in stock: show "1 product" 2. If product has 2-3 pcs in stock: show "2-3 products" 3. If product has more than 3 pcs in stock: "More than 3" I try to set this in Product.tpl: <p id="pQuantityAvailable"{if $product->quantity <= 0} style="display: none;"{/if}> <span id="quantityAvailable">{$product->quantity|intval}</span> <span {if $product->quantity > 1} style="display: none;"{/if} id="quantityAvailableTxt">{l s='Item'}</span> <span {if $product->quantity == 1} style="display: none;"{/if} id="quantityAvailableTxtMultiple">{l s='Items'}</span> </p> to this new: <p id="pQuantityAvailable"{if $product->quantity <= 0} style="display: none;"{/if}> <span {if $product->quantity > 1} style="display: none;"{/if} id="quantityAvailableTxt">{l s='1 product'}</span> <span {if $product->quantity == 1 || $product->quantity >= 4} style="display: none;"{/if} id="quantityAvailableTxtMultiple">{l s='2-3 products'}</span> <span {if $product->quantity <= 3} style="display: none;"{/if} id="quantityAvailableTxtMultiple">{l s='More than 3'}</span> </p> But this don't work if I have product with more colors - first color has 5 pcs in stock, and other color has -4 pcs in stock for example (i allow order unavailable products). In this case, the first color shows "2-3 products" instead of "More than 3". Thank you Link to comment Share on other sites More sharing options...
shacker Posted July 18, 2015 Share Posted July 18, 2015 you have an error. YOu use {if $product->quantity > 1} and later $product->quantity >= 4} so have a double option here > 1 and > 4 you need to rethink this section so you can have only 1 option if the qty is > 1 Link to comment Share on other sites More sharing options...
maladal Posted July 28, 2015 Author Share Posted July 28, 2015 Thanks. My bad Link to comment Share on other sites More sharing options...
shacker Posted July 28, 2015 Share Posted July 28, 2015 Dont worry. regards Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now