Shopify themes, liquid, logos, and UX
Hello, I want to achive something like in the photo below on my Dawn theme. Anyone knows how to code / implement this? Or maybe there is a special app for that? (Been looking in app store and found nothing)
To add the "In Stock" text and icon to product pages on the Dawn theme, you can follow these steps:
Code:
{% if product.price %} <span class="product-price"> {{ product.price | money }} </span> {% endif %}
phpCopy code
{% if product.available %} <p class="product-stock"> In Stock <svg class="icon icon--check" viewBox="0 0 20 20"> <path d="M18.3 3.7c-.4-.4-1-.4-1.4 0L8 12.6 3.1 7.7c-.4-.4-1-.4-1.4 0s-.4 1 0 1.4l5 5c.2.2.5.3.7.3s.5-.1.7-.3l10-10c.4-.4.4-1 0-1.4z"></path> </svg> </p> {% else %} <p class="product-stock out-of-stock"> Out of Stock </p> {% endif %}
This will add an "In Stock" message and checkmark icon to product pages if the product is available. If the product is not available, it will display an "Out of Stock" message instead.
You can customize the "In Stock" text and icon by editing the relevant HTML and SVG code in the above example.
Thanks for your help. The code works but only for the variant that loaded first. The text doesn't change when choosing other variants. Do you have a different code that show the stock status of a variant and changes accordingly? I think it may need a use of a javescript but I couldn't figure it out.
User | RANK |
---|---|
191 | |
172 | |
84 | |
57 | |
45 |
Transform this holiday season into a shopping spree. Plus, learn how to effortlessly open ...
By Jasonh Dec 8, 2023Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023