I have a custom attribute I need to check and if its ‘Catalog’ then I want to hide the price as its not available on the site. If its one of the others then it should display. Originally I did this with if($block->getDisplayValue() != 0.00)
but now I am adding custom stuff that starts at a 0 cost and the price depends on options chosen. if the item can be purchased but doesnt have a price I would still like 0.00 to display.
I have used the attribute in other places starting from $_product
but that is not working here. How do I start at the $block
and get to my custom attribute within this file?
my default.phtml:
<
?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
< ?php /** @var MagentoFrameworkPricingRenderAmount $block */ ?>
< ?php if($block->getDisplayValue() != 0.00){ ?>
getSchema() ? ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"' : '' ?>>
< ?php if ($block->getDisplayLabel()): ?>
< ?= /* @escapeNotVerified */ $block->getDisplayLabel() ?>
< ?php endif; ?>
getPriceId()): ?> id="< ?= /* @escapeNotVerified */ $block->getPriceId() ?>"< ?php endif;?>
< ?= ($block->getPriceDisplayLabel()) ? 'data-label="' . $block->getPriceDisplayLabel() . $block->getPriceDisplayInclExclTaxes() . '"' : '' ?>
data-price-amount="< ?= /* @escapeNotVerified */ $block->getDisplayValue() ?>"
data-price-type="< ?= /* @escapeNotVerified */ $block->getPriceType() ?>"
class="price-wrapper < ?= /* @escapeNotVerified */ $block->getPriceWrapperCss() ?>"
>< ?= /* @escapeNotVerified */ $block->formatCurrency($block->getDisplayValue(), (bool)$block->getIncludeContainer()) ?>
< ?php if ($block->hasAdjustmentsHtml()): ?>
< ?= $block->getAdjustmentsHtml() ?>
< ?php endif; ?>
< ?php if ($block->getSchema()): ?>
< ?php endif; ?>
< ?php } ?>