magento 2.3.2 оформить заказ на летний общий итог после добавления пользовательского текста


Я пытаюсь добавить пользовательский текст после общий раздел в сводке по порядку

Как

<tr class="custom-text">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged</p>
</tr>

enter image description here

Но как этого добиться?

Примечание: какой правильный способ.. с помощью переопределения файла модуля или поставщика?
Любая помощь будет признательна.

Спасибо.

Author: Rakesh Donga, 2019-12-09

1 answers

Вы можете создать собственный модуль или использовать свою собственную тему для реализации ваших требований.

Я предполагаю, что вы используете пользовательский модуль, и я также предполагаю, что ваше имя пользовательского модуля Company_CheckoutCustomtext

Вы можете выполнить действия, описанные ниже.

Шаг 1)

Создать checkout_index_index.xml под YOUR-MAGENTO-ROOT/app/code/Company/CheckoutCustomtext/view/frontend/layout

Файл : *app/code/Company/CheckoutCustomtext/view/frontend/layout/checkout_index_index.xml*

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<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.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="sidebar" xsi:type="array">                                        
                                        <item name="children" xsi:type="array">
                                            <item name="summary" xsi:type="array">
                                                <item name="component" xsi:type="string">Magento_Checkout/js/view/summary</item>
                                                <item name="displayArea" xsi:type="string">summary</item>
                                                <item name="config" xsi:type="array">
                                                    <item name="template" xsi:type="string">Magento_Checkout/summary</item>
                                                </item>
                                                <item name="children" xsi:type="array">                                                 
                                                    <item name="itemsBefore" xsi:type="array">
                                                        <item name="component" xsi:type="string">uiComponent</item>
                                                        <item name="children" xsi:type="array">
                                                            <!-- merge your components here -->
                                                            <item name="checkout-mycustomtext" xsi:type="array">
                                                                    <item name="component" xsi:type="string">Company_CheckoutCustomtext/js/view/checkout-mycustomtext</item>
                                                            </item>
                                                        </item>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

Шаг 2)

Создайте файл компонента js checkout-mycustomtext.js под YOUR-MAGENTO-ROOT/app/code/Company/CheckoutCustomtext/view/frontend/web/js/view/

Файл : /app/code/Company/CheckoutCustomtext/view/frontend/web/js/view/checkout-mycustomtext.js

/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */ 
define([
    'jquery',
    'ko',
    'uiComponent',
    'Magento_Checkout/js/model/quote',
    'Magento_Checkout/js/checkout-data',
    'Magento_Customer/js/customer-data',
    'mage/translate'],
function($, ko, Component, quote, checkoutData, customerData, $t){
     return Component.extend({
          defaults: {
            template: 'Company_CheckoutCustomtext/sales/checkout/mycustomtext'
        },
        getCustomText: function (){         
            var customText = $t('Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged');
            return customText;
        }
     });
});

Шаг 3)

Теперь создайте файл шаблона вашего пользовательского компонента js mycustomtext.html под YOUR-MAGENTO-ROOT/app/code/Company/CheckoutCustomtext/view/frontend/web/template/sales/checkout/

Файл : /app/code/Company/CheckoutCustomtext/view/frontend/web/template/sales/checkout/mycustomtext.html

<p data-bind="text: getCustomText()" style="font-weight:bold;"></p>

Шаг 4)

Теперь выполните команду ниже

sudo php bin/magento setup:upgrade
sudo php bin/magento setup:di:compile
sudo php bin/magento setup:static-content:deploy 

Демонстрация:

enter image description here

 2
Author: Pritam Info 24, 2019-12-09 12:50:09