show custom text field only when it's populated
-
30-10-2019 - |
Question
Having trouble with a custom field. It's a plain text field, called special_note.
<?php $specnote = $_product->getResource()->getAttribute('special_note');
if ($specnote) {
echo "<div id='specialnote'>".$specnote->getFrontend()->getValue($_product)."</div>";
}
?>
The specialnote div is always showing up, even when there's data. I've tried variations like if (!empty($specnote))
and if (!isnull($specnote))
to no avail.
How do I make is so that the div only shows up when it's been populated?
Additional info: this is in the file /app/design/frontend/mytheme/theme/template/catalog/product/view.phtml
Field is set up in magento as a 'text field' - and the settings "Visible on Product View Page on Front-end" and "Used in Product Listing" are both set to yes.
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange