礼物选项已从checkout_cart_item_renderers.xml中删除

问题描述

我已经安装了Amasty_GiftCard,这将创建一个虚拟的礼品卡。现在,当我转到checkout/cart时,我注意到Gift Options没有显示。当尝试再次查看checkout_cart_item_renders.xml时,我尝试调试并删除Amasty\GiftCard\view\frontend\layout\checkout_cart_item_renderers.xml中的checkout/cart,现在显示的是Gift Options。现在,我真的不了解当您查看文件时,这种布局如何影响Gift Options显示,这就是文件的定义

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
   <body>
        <referenceBlock name="checkout.cart.item.renderers">
            <block class="Amasty\GiftCard\Block\Checkout\Cart\Item\Renderer" as="amgiftcard" template="Magento_Checkout::cart/item/default.phtml">
                <block class="Magento\Checkout\Block\Cart\Item\Renderer\Actions" name="checkout.cart.item.renderers.amgiftcard.actions" as="actions">
                    <block class="Magento\Checkout\Block\Cart\Item\Renderer\Actions\Edit" name="checkout.cart.item.renderers.amgiftcard.actions.edit" template="Magento_Checkout::cart/item/renderer/actions/edit.phtml"/>
                    <block class="Magento\Checkout\Block\Cart\Item\Renderer\Actions\Remove" name="checkout.cart.item.renderers.amgiftcard.actions.remove" template="Magento_Checkout::cart/item/renderer/actions/remove.phtml"/>
                </block>
            </block>
        </referenceBlock>
    </body>
</page>

现在,当我查看Amasty\GiftCard\Block\Checkout\Cart\Item\Renderer时,这就是定义

namespace Amasty\GiftCard\Block\Checkout\Cart\Item;

use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\View\Element\Message\InterpretationStrategyInterface;

class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer
{

    /**
     * @var \Amasty\GiftCard\Helper\Catalog\Product\Configuration
     */
    protected $configurationHelper;

    public function __construct(
        \Magento\Framework\View\Element\Template\Context $context,\Magento\Catalog\Helper\Product\Configuration $productConfig,\Magento\Checkout\Model\Session $checkoutSession,\Magento\Catalog\Block\Product\ImageBuilder $imageBuilder,\Magento\Framework\Url\Helper\Data $urlHelper,\Magento\Framework\Message\ManagerInterface $messageManager,PriceCurrencyInterface $priceCurrency,\Magento\Framework\Module\Manager $moduleManager,InterpretationStrategyInterface $messageInterpretationStrategy,\Amasty\GiftCard\Helper\Catalog\Product\Configuration $configurationHelper,array $data = []
    ) {
        parent::__construct(
            $context,$productConfig,$checkoutSession,$imageBuilder,$urlHelper,$messageManager,$priceCurrency,$moduleManager,$messageInterpretationStrategy,$data
        );
        $this->configurationHelper = $configurationHelper;
    }

    public function getoptionList()
    {
        return $this->configurationHelper->getoptions($this->getItem());
    }

}

这是\Amasty\GiftCard\Helper\Catalog\Product\Configuration

内容
namespace Amasty\GiftCard\Helper\Catalog\Product;

use Amasty\GiftCard\Model\GiftCard;
use Magento\Catalog\Helper\Product\Configuration\ConfigurationInterface;
use Magento\Catalog\Model\Product\Configuration\Item\ItemInterface;
use Magento\Framework\App\Helper\AbstractHelper;

class Configuration extends AbstractHelper implements ConfigurationInterface
{
    /**
     * @var \Magento\Catalog\Helper\Product\Configuration
     */
    protected $productConfig;

    public function __construct(
        \Magento\Framework\App\Helper\Context $context,\Magento\Catalog\Helper\Product\Configuration $productConfig
    ) {
        parent::__construct($context);
        $this->productConfig = $productConfig;
    }

    public function getoptions(ItemInterface $item)
    {
        return $this->productConfig->getCustomOptions($item);
    }
}

现在,在查看此内容时,我不确定这对Gift Options的“不显示”有什么影响吗?或者有人可以启发我checkout_cart_item_renderers.xml的工作原理吗? TBH我不熟悉如何设置。希望了解有关此设置和配置方式的任何有用的教程。但如果有人能解释为什么不显示Gift Options

,我们将不胜感激

注意:当我删除定义为Gift Options的产品时,该产品将显示checkout_cart_item_renderers.xml,这并不是因为我们已经将其设置为true而缺少设置Allow Gift Message的原因。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)