If statement based on HTML class

lucasrantzau
New Member
2 0 0

Hello!

I have a few simple lines of code on the product page that show two texts based on if a product is in stock or not. If a product is in stock it shows a delivery time of 1-2 days and if it is not it shows 2-5 days. For products that have delays and can first be delivered in future months I use an app called Pre-Order Now. This app allows me to display shipping information text on the product page as well, just for months instead of days.

Here is the problem: when a product is active in the app both shipping texts display at the same time. (For example both 2-5 days text and delivery in september text, see attached image) I need a simple if statement so that the shipping information based on stock levels only executes if the app text is not active on a product.

How could I achieve this? Is there a way to make an if statement based on if a HTML class is active on the page? This way only execute the code if that class is lacking?

This is the code for the stock based shipping text:

{% if product.variants.first.inventory_quantity > 0 %}
<div class="custom-on-stock-text">På lager: 1-2 hverdage</div>
{% else %}
<div class="custom-not-in-stock-text">Fjernlager: 2-5 hverdage*</div>
{% endif %}

Thank you!

Skærmbillede 2021-09-24 kl. 15.16.12.png

0 Likes

It won't be done with the command, you need to contact app.

Because app will work on its own, you can't if/else it with liquid statements, you need to contact app, they will send you separate commands.

Hope it helps!

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!
0 Likes