checkout page refresh issue
I think we don't need to reload the total summary. Because, when click the Next button, Magento will make a request(API) V1/carts/mine/shipping-information
to re-calculate the totals and output the totals data to our templates.
So, if we want to check the fee, we should check the response total_segments
When click Next to the payment step, there is a request to set shipping information vendor/magento/module-checkout/view/frontend/web/js/view/shipping.js
/**
* Set shipping information handler
*/
setShippingInformation: function () {
if (this.validateShippingInformation()) {
setShippingInformationAction().done(
function () {
stepNavigator.next();
}
);
}
}
This request will re-calculate the totals.
In your case, in our html template, it should have a isDisplayed()
function:
Kensium/DeliverySign/view/frontend/web/template/checkout/cart/totals/fee.html
<!-- ko if: isDisplayed() -->
<tr class="totals fee excl" data-bind="visible: canVisibleDeliverySignBlock">
<th class="mark" colspan="1" scope="row" data-bind="text: title"></th>
<td class="amount">
<span class="price" data-bind="text: getValue()"></span>
</td>
</tr>
<!-- /ko -->
Check isDisplayed()
function:
Kensium/DeliverySign/view/frontend/web/js/view/checkout/cart/totals/fee.js
define([
'ko',
'uiComponent',
'Magento_Checkout/js/model/quote',
'Magento_Catalog/js/price-utils',
'Magento_Checkout/js/model/totals'
], function (ko, Component, quote, priceUtils, totals) {
'use strict';
var show_hide_deliverysign_blockConfig = window.checkoutConfig.show_hide_deliverysign_block;
var delivery_sign_amount = window.checkoutConfig.delivery_sign_amount;
return Component.extend({
totals: quote.getTotals(),
canVisibleDeliverySignBlock: show_hide_deliverysign_blockConfig,
getFormattedPrice: ko.observable(priceUtils.formatPrice(delivery_sign_amount, quote.getPriceFormat())),
isDisplayed: function () {
return this.getValue() != 0;
},
getValue: function() {
var price = 0;
if (this.totals() && totals.getSegment('fee')) {
price = totals.getSegment('fee').value;
}
return this.getFormattedPrice(price);
}
});
});
This function will check the totals fee
segment from the response.
I make a git pull here.
NOTE: Make sure your fee is calculated right way. On the payment step, please check the response has our fee.