I'm working on a twig template for use with a commerce product. Each product has a term applied to it like "Green Ball", "Yellow Ball", "Red Block", and "Purple Block".
I'm trying to take the variable that holds the term, check if it has a string in it, and then use that as the basis for a label. For example if its a Green Ball it would say "Order Ball" and if it was "Red Block" it would say "Order Block".
I'm marking this up based on examples but it always returns false.
{% if 'Ball' in product.field_myproduct_type|field_value %} Order Ball {% endif %}
{% if 'Block' in product.field_myproduct_type|field_value %} Order Block {% endif %}
I've both tried outputting the variable on its own to confirm the variable is correct and also tried replacing the variable from the conditional with a string to make sure the conditional is the proper syntax and both work as expected. I just can't seem to check in the variable.
I'm doing this from within a twig template that is a variant on commerce-product.twig
{% if 'ball' in product.field_myproduct_type|field_value|raw|lower %} Order Ball {% endif %}