Skip to content

Instantly share code, notes, and snippets.

@mrkhoa99
Created September 5, 2016 02:26
Show Gist options
  • Save mrkhoa99/1a2ad6f06d589a63563f0c33338db254 to your computer and use it in GitHub Desktop.
Save mrkhoa99/1a2ad6f06d589a63563f0c33338db254 to your computer and use it in GitHub Desktop.
<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="before_grandtotal" xsi:type="array">
<item name="children" xsi:type="array">
<item name="paymentfee" xsi:type="array">
<item name="component" xsi:type="string">Boolfly_PaymentFee/js/view/cart/summary/charge</item>
<item name="config" xsi:type="array">
<item name="title" xsi:type="string" translate="true">Surcharge Fee</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
@mrkhoa99
Copy link
Author

mrkhoa99 commented Sep 5, 2016

/global define/
define(
[
'Magento_Checkout/js/view/summary/abstract-total',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/totals'
],
function (Component, quote, totals) {
"use strict";
return Component.extend({
defaults: {
template: 'Boolfly_PaymentFee/cart/summary/paymentfee'
},
totals: quote.getTotals(),
isDisplayed: function() {
return this.getPureValue() != 0;
},
getPaymentFee: function() {
if (!this.totals()) {
return null;
}
return totals.getSegment('payment_charge').value;
},
getPureValue: function() {
var price = 0;
if (this.totals() && totals.getSegment('payment_charge').value) {
price = parseFloat(totals.getSegment('payment_charge').value);
}
return price;
},
getValue: function() {
return this.getFormattedPrice(this.getPureValue());
}
});
}
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment