Magento2 Добавьте пользовательский html-код перед итогами на странице корзины


Как мы можем добавить пользовательский HTML-код перед тем, как сделать общий заказ на странице корзины с нокаутом JS, как показано на скриншоте ниже.

Скриншот:

enter image description here

Author: Vishwas Soni, 2017-12-06

2 answers

1. Создать checkout_cart_index.xml в

App/code/Vendor/Module/view/frontend/layout/checkout_cart_index.xml

<?xml version="1.0"?>
<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.totals">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="block-totals" xsi:type="array">
                            <item name="children" xsi:type="array">
                                <item name="fee" xsi:type="array">
                                    <item name="component" xsi:type="string">Vendor_Module/js/view/checkout/cart/totals/fee</item>
                                    <item name="sortOrder" xsi:type="string">20</item>
                                    <item name="config" xsi:type="array">
                                        <item name="template" xsi:type="string">Vendor_Module/checkout/cart/totals/fee</item>
                                    </item>
                                </item>

                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

2. Теперь создайте fee.html в

App/code/Vendor/Module/view/frontend/web/template/checkout/cart/totals/fee.html

<!-- ko -->
<div>Here You can do your html</div>
<!-- /ko -->

3. Создать fee.js в (Здесь Вы можете создавать функции для html)

App/code/Vendor/Module/view/frontend/web/js/view/checkout/cart/totals/fee.js

define(
    [
        'Vendor_Module/js/view/checkout/summary/fee'
    ],
    function (Component) {
        'use strict';

        return Component.extend({
            //Create function
        });
    }
);

Я добавил пользовательский итог в этом месте вы можете выбрать мой модуль для получения более подробной информации: https://github.com/mageprince/magento2-extrafee

 1
Author: Prince Patel, 2017-12-06 10:58:57

Вы можете добавить свой пользовательский html-контент в этот файл:

/приложение/код/дизайн/your_package/your_theme/magento_checkout/шаблоны/корзина/итоги.phtml

<div id="cart-totals" class="cart-totals" data-bind="scope:'block-totals'">
    <div class="custom-html">Custom Html Before Totals</div>
    <!-- ko template: getTemplate() --><!-- /ko -->
    <script type="text/x-magento-init">
            {
                "#cart-totals": {
                    "Magento_Ui/js/core/app": <?php /* @escapeNotVerified */ echo $block->getJsLayout();?>
                }
            }
    </script>
</div>

Я надеюсь, что это сработает для вас.

enter image description here

 0
Author: Kishor Thummar, 2017-12-06 10:21:35