jeśli chcesz dodać niestandardowy atrybut do podsumowania zamówienia, musisz zastąpić: (Układy) 1) checkout_cart_index:
<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="processingfee" xsi:type="array">
<item name="component" xsi:type="string">Dedicated_Processingfee/js/view/checkout/cart/totals/processingfee</item>
<item name="sortOrder" xsi:type="string">20</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Dedicated_Processingfee/checkout/cart/totals/processingfee</item>
<item name="title" xsi:type="string" translate="true">Processing Fee</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
2) checkout_index_index:
<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="children" xsi:type="array">
<item name="totals" xsi:type="array">
<item name="children" xsi:type="array">
<item name="processingfee" xsi:type="array">
<item name="component" xsi:type="string">Dedicated_Processingfee/js/view/checkout/cart/totals/processingfee</item>
<item name="sortOrder" xsi:type="string">20</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Dedicated_Processingfee/checkout/cart/totals/processingfee</item>
<item name="title" xsi:type="string" translate="true">Processing Fee</item>
</item>
</item>
</item>
</item>
<item name="cart_items" xsi:type="array">
<item name="children" xsi:type="array">
<item name="details" xsi:type="array">
<item name="children" xsi:type="array">
<item name="subtotal" xsi:type="array">
<item name="component" xsi:type="string">Magento_Tax/js/view/checkout/summary/item/details/subtotal</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
3) Sales_order_view:
<referenceContainer name="order_totals">
<block class="Dedicated\Processingfee\Block\Sales\Order\ProcessingFee" name="processingfee"/>
</referenceContainer>
następnie dodaj niestandardowy plik js, aby uzyskać niestandardową wartość atrybutu w następujący sposób: w /view/frontend/web/js/view/checkout/cart/totals/processingfee.js:
define(
[
'Dedicated_Processingfee/js/view/checkout/summary/processingfee'
],
function (Component) {
'use strict';
return Component.extend({
/**
* @override
*/
isDisplayed: function () {
return true;
}
});
}
);
dodaj kolejny js, aby obliczyć wartość z całkowitą kwotą rozliczeniową w: /view/frontend/web/js/view/checkout/summary/processingfee.js
define(
[
'Magento_Checkout/js/view/summary/abstract-total',
'Magento_Checkout/js/model/quote',
'Magento_Catalog/js/price-utils',
'Magento_Checkout/js/model/totals'
],
function (Component, quote, priceUtils, totals) {
"use strict";
return Component.extend({
defaults: {
isFullTaxSummaryDisplayed: window.checkoutConfig.isFullTaxSummaryDisplayed || false,
template: 'Dedicated_Processingfee/checkout/summary/processingfee'
},
totals: quote.getTotals(),
isTaxDisplayedInGrandTotal: window.checkoutConfig.includeTaxInGrandTotal || false,
isDisplayed: function() {
return this.isFullMode();
},
getValue: function() {
var price = 0;
if (this.totals()) {
price = totals.getSegment('processingfee').value;
}
return this.getFormattedPrice(price);
},
getBaseValue: function() {
var price = 0;
if (this.totals()) {
price = this.totals().base_fee;
}
return priceUtils.formatPrice(price, quote.getBasePriceFormat());
}
});
}
);
Ten zestaw znajdziesz w atrybucie o wartości Dzięki :)