- πΈπͺSweden cruze72
I've tried the following code in a views template file like this:
views-view-field--my_view--default--field-stock.html.twig {% if field_stock %} {% set stock = field_stock.0.value %} {% if stock >= 10 %} <span style="color: green">In stock</span> {% elseif stock > 0 and stock < 10 %} <span style="color: orange">Limited stock</span> {% else %} <span style="color: red">Out of stock</span> {% endif %} {% endif %}
but still can't get the view to show the text instead of stock level ....
- πΈπͺSweden cruze72
I've even tried injecting the above code directly as a custom views field rewrite. i can get a message printed but it shows 'out of stock' for all rows even when there is stock. I'm guessing that the issue lies with the field_stock.