Вопрос

I create two tax rule name rule1 and disability tax ,check below images enter image description here

Now I want to display these two tax rule names on the product page. any help will be appreciated. enter image description here

Нет правильного решения

Другие советы

Create Module with the following code, this will give you exactly that you are looking for :D

=> app/code/Vendor/Module/registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Vendor_Module',
    __DIR__
);

=> app/code/Vendor/Module/etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Vendor_Module" setup_version="0.0.1">
    </module>
</config>

=> app/code/Vendor/Module/view/frontend/layout/catalog_product_view.xml

<?xml version="1.0"?>

<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <referenceContainer name="product.info.main">
                <block class="Vendor\Module\Block\TexRuleNames" name="tex.rule.names" template="Vendor_Module::product/view/text_rule_names.phtml" after="product.info.price" />
            </referenceContainer>
        </referenceContainer>
    </body>
</page>

=> app/code/Vendor/Module/Block/TexRuleNames.php

<?php
namespace Vendor\Module\Block;

class TexRuleNames extends \Magento\Framework\View\Element\Template
{
    public function __construct
    (
        \Magento\Tax\Model\TaxRuleCollection $taxRuleCollection,
        \Magento\Framework\View\Element\Template\Context $context
    )
    {
        $this->_taxRuleCollection = $taxRuleCollection;

        parent::__construct($context);
    }

    public function getTextRuleNames()
    {
        return $this->_taxRuleCollection->getColumnValues('code');
    }
}

=> app/code/Vendor/Module/view/frontend/templates/product/view/text_rule_names.phtml

<?php $TextRuleName = $block->getTextRuleNames(); ?>

<div class="text-rules">
    <?php foreach ($TextRuleName as $rule): ?>
        <h1><?php echo $rule; ?></h1>
    <?php endforeach; ?>
</div>

@hiren: yes it's working thank you.enter image description here

Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top