0

I have created a dropdown attribute with the options of "yes" and "no" with the hope to show an element with yes is selected in the admin. I have a few of these dropdown attributes that all show different icons depending if the product needs them. Unfortunately I can not get it to work. Here is my code.

<ul class="safety-footwear-icons">
<?php if($product->getAttributeText('safety_basic')=='yes'){ ?>
    <li class="sb">
        <span class="tooltiptext">SAFETY BASIC - EN ISO 20345:2011 + 200 joules toe protection</span>
    </li>
<?php } ?>
2
  • Can you please explain your requirement into some more details Oct 19, 2021 at 5:01
  • @DhirenVasoya I'm trying to get the output form a dropdown attribute with the options of yes or no. If yes, then it will show the li with the span if no it will show nothing.
    – totneschap
    Oct 19, 2021 at 8:48

1 Answer 1

1

You need to do code like this :

<ul class="safety-footwear-icons">
<?php if($product->getSafetyBasic()){ ?>
    <li class="sb">
        <span class="tooltiptext">SAFETY BASIC - EN ISO 20345:2011 + 200 joules toe protection</span>
    </li>
<?php } ?>

NOTE: Just confirm product object is load before above code.

1
  • Thank you, big help
    – totneschap
    Oct 22, 2021 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.