Magento2 礼品选项已从checkout\u cart\u item\u renderers.xml中删除
我现在已经安装了Amasty_GiftCard,这将创建一个虚拟GiftCard。现在,当我进入Magento2 礼品选项已从checkout\u cart\u item\u renderers.xml中删除,magento2,magento-2.3,Magento2,Magento 2.3,我现在已经安装了Amasty_GiftCard,这将创建一个虚拟GiftCard。现在,当我进入结帐/购物车时,我注意到礼品选项没有显示。我尝试调试并删除了Amasty\GiftCard\view\frontend\layout\checkout\u cart\u item\u renderers.xml中的checkout\u cart\u item\u renders.xml中的checkout\u item\u renders.xml当我尝试再次查看checkout/cart时,礼品选项现
结帐/购物车
时,我注意到礼品选项
没有显示。我尝试调试并删除了Amasty\GiftCard\view\frontend\layout\checkout\u cart\u item\u renderers.xml中的checkout\u cart\u item\u renders.xml中的checkout\u item\u renders.xml
当我尝试再次查看checkout/cart
时,礼品选项现在显示出来。现在我真的不明白当你查看文件时,这个布局是如何影响礼物选项的显示的。这是文件的定义
<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\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);
}
}
现在,当我看到这一点时,我不确定这是如何影响不显示礼物选项的
任何想法,或者有人能告诉我这个结帐购物车\u项目\u renderers.xml
的工作原理吗?TBH我不知道如何设置这个。如果您有任何关于如何设置和配置的有用教程,将不胜感激。但如果有人能解释为什么它没有显示礼品选项,我将不胜感激
注意:当我删除定义的checkout\u cart\u item\u renderers.xml时,此产品会显示礼品选项
,因此,这并不是因为我们没有设置允许礼品消息
,因为我们已经将其设置为true
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);
}
}