How do I add a custom attribute in amount/default.phtml?
I need to add in a couple of statements using some custom attributes for the Pricing. I am trying to figure out how to allow this to work. Right now I have this:
<?php
$helper = $this->helper('MagentoCatalogBlockProductView');
$_product = $helper->$block->getProduct();
?>
<?php if($_product->getData('show_price')): ?>
<?php if($_product->getPriceInfo()->getPrice('final_price')->getValue() == 0): ?>
<div class="price-box price-regular"><span class="price"><a href="tel:+1<?php echo $storeInfo->getPhone(); ?>">Call for Price!</a></span></div>
<?php else: ?>
<span class="price-container <?= /* @escapeNotVerified */ $block->getAdjustmentCssClasses() ?>"
<?= $block->getSchema() ? ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"' : '' ?>>
<?php if ($block->getDisplayLabel()): ?>
<span class="price-label"><?= /* @escapeNotVerified */ $block->getDisplayLabel() ?></span>
<?php endif; ?>
<?php if($_product->getData('priced_starting_at')): ?>
<div class="price-starting-at">Starting at:</div>
<?php else: ?>
<div class="price-regular">Our Price:</div>
<?php endif; ?>
<span <?php if ($block->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()) ?></span>
<?php if ($block->hasAdjustmentsHtml()): ?>
<?= $block->getAdjustmentsHtml() ?>
<?php endif; ?>
<?php if ($block->getSchema()): ?>
<meta itemprop="price" content="<?= /* @escapeNotVerified */ $block->getDisplayValue() ?>" />
<meta itemprop="priceCurrency" content="<?= /* @escapeNotVerified */ $block->getDisplayCurrencyCode() ?>" />
<?php endif; ?>
</span>
<?php endif; ?>
<?php endif; ?>
This is the error I am getting as of now:
1 exception(s):
Exception #0 (LogicException): MagentoCatalogBlockProductView doesn't extends MagentoFrameworkAppHelperAbstractHelper
magento2 magento2.2.6
New contributor
|
show 3 more comments
I need to add in a couple of statements using some custom attributes for the Pricing. I am trying to figure out how to allow this to work. Right now I have this:
<?php
$helper = $this->helper('MagentoCatalogBlockProductView');
$_product = $helper->$block->getProduct();
?>
<?php if($_product->getData('show_price')): ?>
<?php if($_product->getPriceInfo()->getPrice('final_price')->getValue() == 0): ?>
<div class="price-box price-regular"><span class="price"><a href="tel:+1<?php echo $storeInfo->getPhone(); ?>">Call for Price!</a></span></div>
<?php else: ?>
<span class="price-container <?= /* @escapeNotVerified */ $block->getAdjustmentCssClasses() ?>"
<?= $block->getSchema() ? ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"' : '' ?>>
<?php if ($block->getDisplayLabel()): ?>
<span class="price-label"><?= /* @escapeNotVerified */ $block->getDisplayLabel() ?></span>
<?php endif; ?>
<?php if($_product->getData('priced_starting_at')): ?>
<div class="price-starting-at">Starting at:</div>
<?php else: ?>
<div class="price-regular">Our Price:</div>
<?php endif; ?>
<span <?php if ($block->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()) ?></span>
<?php if ($block->hasAdjustmentsHtml()): ?>
<?= $block->getAdjustmentsHtml() ?>
<?php endif; ?>
<?php if ($block->getSchema()): ?>
<meta itemprop="price" content="<?= /* @escapeNotVerified */ $block->getDisplayValue() ?>" />
<meta itemprop="priceCurrency" content="<?= /* @escapeNotVerified */ $block->getDisplayCurrencyCode() ?>" />
<?php endif; ?>
</span>
<?php endif; ?>
<?php endif; ?>
This is the error I am getting as of now:
1 exception(s):
Exception #0 (LogicException): MagentoCatalogBlockProductView doesn't extends MagentoFrameworkAppHelperAbstractHelper
magento2 magento2.2.6
New contributor
Can you please share full path of your file?
– Abhishek Panchal
Jan 14 at 20:31
appdesignfrontendFreshleyultimo_childMagento_Catalogtemplatesproductpriceamountdefault.phtml
– user12555
Jan 14 at 20:35
Its obvious to get this error because you try to call block function using helper.
– Abhishek Panchal
Jan 14 at 20:43
Okay, so what do I need to do in order to get this working?
– user12555
Jan 14 at 20:46
You want show your detail on product detail page or category listing page as well?
– Abhishek Panchal
Jan 14 at 20:49
|
show 3 more comments
I need to add in a couple of statements using some custom attributes for the Pricing. I am trying to figure out how to allow this to work. Right now I have this:
<?php
$helper = $this->helper('MagentoCatalogBlockProductView');
$_product = $helper->$block->getProduct();
?>
<?php if($_product->getData('show_price')): ?>
<?php if($_product->getPriceInfo()->getPrice('final_price')->getValue() == 0): ?>
<div class="price-box price-regular"><span class="price"><a href="tel:+1<?php echo $storeInfo->getPhone(); ?>">Call for Price!</a></span></div>
<?php else: ?>
<span class="price-container <?= /* @escapeNotVerified */ $block->getAdjustmentCssClasses() ?>"
<?= $block->getSchema() ? ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"' : '' ?>>
<?php if ($block->getDisplayLabel()): ?>
<span class="price-label"><?= /* @escapeNotVerified */ $block->getDisplayLabel() ?></span>
<?php endif; ?>
<?php if($_product->getData('priced_starting_at')): ?>
<div class="price-starting-at">Starting at:</div>
<?php else: ?>
<div class="price-regular">Our Price:</div>
<?php endif; ?>
<span <?php if ($block->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()) ?></span>
<?php if ($block->hasAdjustmentsHtml()): ?>
<?= $block->getAdjustmentsHtml() ?>
<?php endif; ?>
<?php if ($block->getSchema()): ?>
<meta itemprop="price" content="<?= /* @escapeNotVerified */ $block->getDisplayValue() ?>" />
<meta itemprop="priceCurrency" content="<?= /* @escapeNotVerified */ $block->getDisplayCurrencyCode() ?>" />
<?php endif; ?>
</span>
<?php endif; ?>
<?php endif; ?>
This is the error I am getting as of now:
1 exception(s):
Exception #0 (LogicException): MagentoCatalogBlockProductView doesn't extends MagentoFrameworkAppHelperAbstractHelper
magento2 magento2.2.6
New contributor
I need to add in a couple of statements using some custom attributes for the Pricing. I am trying to figure out how to allow this to work. Right now I have this:
<?php
$helper = $this->helper('MagentoCatalogBlockProductView');
$_product = $helper->$block->getProduct();
?>
<?php if($_product->getData('show_price')): ?>
<?php if($_product->getPriceInfo()->getPrice('final_price')->getValue() == 0): ?>
<div class="price-box price-regular"><span class="price"><a href="tel:+1<?php echo $storeInfo->getPhone(); ?>">Call for Price!</a></span></div>
<?php else: ?>
<span class="price-container <?= /* @escapeNotVerified */ $block->getAdjustmentCssClasses() ?>"
<?= $block->getSchema() ? ' itemprop="offers" itemscope itemtype="http://schema.org/Offer"' : '' ?>>
<?php if ($block->getDisplayLabel()): ?>
<span class="price-label"><?= /* @escapeNotVerified */ $block->getDisplayLabel() ?></span>
<?php endif; ?>
<?php if($_product->getData('priced_starting_at')): ?>
<div class="price-starting-at">Starting at:</div>
<?php else: ?>
<div class="price-regular">Our Price:</div>
<?php endif; ?>
<span <?php if ($block->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()) ?></span>
<?php if ($block->hasAdjustmentsHtml()): ?>
<?= $block->getAdjustmentsHtml() ?>
<?php endif; ?>
<?php if ($block->getSchema()): ?>
<meta itemprop="price" content="<?= /* @escapeNotVerified */ $block->getDisplayValue() ?>" />
<meta itemprop="priceCurrency" content="<?= /* @escapeNotVerified */ $block->getDisplayCurrencyCode() ?>" />
<?php endif; ?>
</span>
<?php endif; ?>
<?php endif; ?>
This is the error I am getting as of now:
1 exception(s):
Exception #0 (LogicException): MagentoCatalogBlockProductView doesn't extends MagentoFrameworkAppHelperAbstractHelper
magento2 magento2.2.6
magento2 magento2.2.6
New contributor
New contributor
New contributor
asked Jan 14 at 20:13
user12555user12555
11
11
New contributor
New contributor
Can you please share full path of your file?
– Abhishek Panchal
Jan 14 at 20:31
appdesignfrontendFreshleyultimo_childMagento_Catalogtemplatesproductpriceamountdefault.phtml
– user12555
Jan 14 at 20:35
Its obvious to get this error because you try to call block function using helper.
– Abhishek Panchal
Jan 14 at 20:43
Okay, so what do I need to do in order to get this working?
– user12555
Jan 14 at 20:46
You want show your detail on product detail page or category listing page as well?
– Abhishek Panchal
Jan 14 at 20:49
|
show 3 more comments
Can you please share full path of your file?
– Abhishek Panchal
Jan 14 at 20:31
appdesignfrontendFreshleyultimo_childMagento_Catalogtemplatesproductpriceamountdefault.phtml
– user12555
Jan 14 at 20:35
Its obvious to get this error because you try to call block function using helper.
– Abhishek Panchal
Jan 14 at 20:43
Okay, so what do I need to do in order to get this working?
– user12555
Jan 14 at 20:46
You want show your detail on product detail page or category listing page as well?
– Abhishek Panchal
Jan 14 at 20:49
Can you please share full path of your file?
– Abhishek Panchal
Jan 14 at 20:31
Can you please share full path of your file?
– Abhishek Panchal
Jan 14 at 20:31
appdesignfrontendFreshleyultimo_childMagento_Catalogtemplatesproductpriceamountdefault.phtml
– user12555
Jan 14 at 20:35
appdesignfrontendFreshleyultimo_childMagento_Catalogtemplatesproductpriceamountdefault.phtml
– user12555
Jan 14 at 20:35
Its obvious to get this error because you try to call block function using helper.
– Abhishek Panchal
Jan 14 at 20:43
Its obvious to get this error because you try to call block function using helper.
– Abhishek Panchal
Jan 14 at 20:43
Okay, so what do I need to do in order to get this working?
– user12555
Jan 14 at 20:46
Okay, so what do I need to do in order to get this working?
– user12555
Jan 14 at 20:46
You want show your detail on product detail page or category listing page as well?
– Abhishek Panchal
Jan 14 at 20:49
You want show your detail on product detail page or category listing page as well?
– Abhishek Panchal
Jan 14 at 20:49
|
show 3 more comments
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
user12555 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f257751%2fhow-do-i-add-a-custom-attribute-in-amount-default-phtml%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
user12555 is a new contributor. Be nice, and check out our Code of Conduct.
user12555 is a new contributor. Be nice, and check out our Code of Conduct.
user12555 is a new contributor. Be nice, and check out our Code of Conduct.
user12555 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f257751%2fhow-do-i-add-a-custom-attribute-in-amount-default-phtml%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you please share full path of your file?
– Abhishek Panchal
Jan 14 at 20:31
appdesignfrontendFreshleyultimo_childMagento_Catalogtemplatesproductpriceamountdefault.phtml
– user12555
Jan 14 at 20:35
Its obvious to get this error because you try to call block function using helper.
– Abhishek Panchal
Jan 14 at 20:43
Okay, so what do I need to do in order to get this working?
– user12555
Jan 14 at 20:46
You want show your detail on product detail page or category listing page as well?
– Abhishek Panchal
Jan 14 at 20:49