I am trying to check if an attribute is set to yes then show this block.

<?php if($_item->getAttributeText('free_shipping_toggle')=='1'): ?>      
<?php echo $this->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('free-shipping-list-marker')->toHtml();?>
<?php else: ?>
<!--Placeholder for other statement-->
<?php endif; ?>
  • Can you please add more detail which problem are you facing ? Commented Jul 27, 2016 at 18:12

1 Answer 1


If it's a boolean (Yes/No) attribute, then you can use:

if ($_item->getData('free_shipping_toggle'))

This will check if attribute exists and if yes what values it is.

Your Answer

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

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