I've been trying to add a text attribute inline with the price unsuccessfully. I have been able to add a text attribute directly under the price but unable to get the text inline like so.
Is there a way to get a text attribute on vendor/magento/module-catalog/view/base/templates/product/price/amount/default.phtml
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<?php /** @var \Magento\Framework\Pricing\Render\Amount $block */ ?>
<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; ?>
<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>
/* ADDING CODE HERE IT FALLS INLINE */
<?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>Adding text directly where i placed the comment gets the desired output, however when I try to place the text attribute here it fails.
Is there any to add a text attribute to vendor/magento/module-catalog/view/base/layout/catalog_product_prices.xml
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
<block class="Magento\Framework\Pricing\Render\RendererPool" name="render.product.prices">
<arguments>
<argument name="default" xsi:type="array">
<item name="default_render_class" xsi:type="string">Magento\Catalog\Pricing\Render\PriceBox</item>
<item name="default_render_template" xsi:type="string">Magento_Catalog::product/price/default.phtml</item>
<item name="default_amount_render_class" xsi:type="string">Magento\Framework\Pricing\Render\Amount</item>
<item name="default_amount_render_template" xsi:type="string">Magento_Catalog::product/price/amount/default.phtml</item>
<item name="prices" xsi:type="array">
<item name="special_price" xsi:type="array">
<item name="render_template" xsi:type="string">Magento_Catalog::product/price/special_price.phtml</item>
</item>
<item name="tier_price" xsi:type="array">
<item name="render_template" xsi:type="string">Magento_Catalog::product/price/tier_prices.phtml</item>
</item>
<item name="final_price" xsi:type="array">
<item name="render_class" xsi:type="string">Magento\Catalog\Pricing\Render\FinalPriceBox</item>
<item name="render_template" xsi:type="string">Magento_Catalog::product/price/final_price.phtml</item>
</item>
<item name="custom_option_price" xsi:type="array">
<item name="amount_render_template" xsi:type="string">Magento_Catalog::product/price/amount/default.phtml</item>
</item>
<item name="configured_price" xsi:type="array">
<item name="render_class" xsi:type="string">Magento\Catalog\Pricing\Render\ConfiguredPriceBox</item>
<item name="render_template" xsi:type="string">Magento_Catalog::product/price/configured_price.phtml</item>
</item>
</item>
<!--<item name="adjustments" xsi:type="array"></item>-->
</argument>
</arguments>
</block>
</layout>I've added a text attribute on catalog_product_view.xml using this code
<referenceContainer name="content">
<container name="my.container" as="myContainer" label="my Container" htmlTag="div" htmlClass="my-container" />
</referenceContainer>
<referenceContainer name="my.container">
<block class="Magento\Catalog\Block\Product\View\Description" name="product.info.bn" template="product/view/customattribute.phtml" after="product.info.addtocart">
<arguments>
<argument name="at_call" xsi:type="string">indhdwe_shipping_time_frame</argument>
<argument name="at_code" xsi:type="string">indhdwe_shipping_time_frame</argument>
<argument name="css_class" xsi:type="string">indhdwe_shipping_time_frame</argument>
<argument name="at_label" xsi:type="string">indhdwe_shipping_time_frame</argument>
<argument name="add_attribute" xsi:type="string">itemprop="indhdwe_shipping_time_frame"</argument>
</arguments>
</block>
</referenceContainer>
<move element="my.container" destination="product.info.price" after="product.info.price" />But it renders the output like this
When I try to use the code on vendor/magento/module-catalog/view/base/layout/catalog_product_prices.xml it fails. Anyone know how I can do this. Its driving me bonkers. I've seen extensions that get this functionality but they don't have an upload option. I have upward of 50000 products on this site I can't do this 1 by 1