TheSmithsDoBusiness Posted April 12, 2021 Share Posted April 12, 2021 Hello, I need to add specific classes to various elements on the product page but only when the product is out of stock. I basically need the opposite of {if $product.availability == 'available'} CONTENT {/if} Any help is much appreciated. Thanks Link to comment Share on other sites More sharing options...
marketyellow3 Posted April 13, 2021 Share Posted April 13, 2021 This works for me: {block name='product_miniature_item'} {if $product.quantity > 0} <label class="label">{l s='availability: ' d='Shop.Theme.Catalog'} </label> <span class="availability-list-in-stock">On stock</span> {else} <label class="label">{l s='availability: ' d='Shop.Theme.Catalog'} </label> <span class="availability-list-in-stock">Out of stock</span> {/if} {/block} Link to comment Share on other sites More sharing options...
musicmaster Posted April 13, 2021 Share Posted April 13, 2021 23 hours ago, TheSmithsDoBusiness said: Hello, I need to add specific classes to various elements on the product page but only when the product is out of stock. I basically need the opposite of {if $product.availability == 'available'} CONTENT {/if} Any help is much appreciated. Thanks Availability is a flag for the product in the database that you can set. It is unrelated to the stock. Link to comment Share on other sites More sharing options...
TheSmithsDoBusiness Posted April 14, 2021 Author Share Posted April 14, 2021 16 hours ago, musicmaster said: Availability is a flag for the product in the database that you can set. It is unrelated to the stock. Thanks for your reply. I don't have the knowledge or skills to make this happen. What's the easiest way to do what I need (please see my first message)? Thanks 😊 Link to comment Share on other sites More sharing options...
TheSmithsDoBusiness Posted April 14, 2021 Author Share Posted April 14, 2021 On 4/13/2021 at 3:55 PM, marketyellow3 said: This works for me: {block name='product_miniature_item'} {if $product.quantity > 0} <label class="label">{l s='availability: ' d='Shop.Theme.Catalog'} </label> <span class="availability-list-in-stock">On stock</span> {else} <label class="label">{l s='availability: ' d='Shop.Theme.Catalog'} </label> <span class="availability-list-in-stock">Out of stock</span> {/if} {/block} Will give this a try tomorrow and see how it goes. Thanks 😊 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