Magento 2,如何删除发货步骤中的订单摘要?

Magento 2, how to remove the order-summary in shipping-step?

我正在尝试自定义 Magento 2 的结帐。目前,我想更改 "shipping" 步骤的外观。谁能给我提示如何删除侧边栏(包括订单摘要)?

它应该只在 "payment" 步可见,而不是在 "shipping"。

magento/module-checkout/view/frontend/layout/ 中的布局文件 checkout_index_index.xml 中添加了边栏。如果不对结帐进行大量修改,您实际上无法修改它以满足您的要求。

虽然 CSS 有一个更简单的解决方案。

将此行添加到您的样式中:.opc-summary-wrapper{display:none;} 并修改 magento/module-checkout/view/frontend/web/js/model/step-navigator.js 不要 编辑核心文件!在您的主题或模块中复制一份,并将以下代码添加到函数 getActiveItemIndex

if (activeIndex == 1) {
  $('.opc-summary-wrapper').css("display", "block");
} 
else {
  $('.opc-summary-wrapper').css("display", "none");
}

对我有用。虽然不是我的主意, 在 magento stackexchange 上找到了这个答案:https://magento.stackexchange.com/questions/229001/checkout-remove-sidebar-only-in-step-1

Magento 的文档在此处解释了如何禁用项目:https://devdocs.magento.com/guides/v2.4/howdoi/checkout/checkout_customize.html#disable

删除摘要(在这种情况下,在移动设备中)就像将以下内容添加到主题的 checkout_index_index.xml

一样简单
<item name="estimation" xsi:type="array">
      <item name="componentDisabled" xsi:type="boolean">true</item>
</item>

checkout_index_index.xml 应该看起来像这样

<?xml version="1.0" encoding="utf-8"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="checkout.root">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="checkout" xsi:type="array">
                            <item name="children" xsi:type="array">
                                <item name="estimation" xsi:type="array">
                                    <item name="componentDisabled" xsi:type="boolean">true</item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

复制

checkout_index_index.xml

来自

PROJECT_ROOT/vendor/magento/module-checkout/view/frontend/layout

文件夹并找到下面这行代码

<item name="sidebar" xsi:type="array">

然后替换此项目块下的代码行并放置以下代码行

<item name="disbaled" xsi:type="string">true</item>

它将在结帐页面的发货步骤中删除订单摘要以及包含订单摘要块的侧边栏

希望对您有所帮助。