First of all I want to give some screen shots to understand my issue.
Now I want to add related code here.
etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Checkout\Model\CompositeConfigProvider">
<arguments>
<argument name="configProviders" xsi:type="array">
<item name="checkout_deliverysign_block" xsi:type="object">Kensium\DeliverySign\Model\DeliverySignConfigProvider</item>
</argument>
</arguments>
</type>
</config>
DeliverySignConfigProvider
<?php
namespace Kensium\DeliverySign\Model;
use Magento\Checkout\Model\ConfigProviderInterface;
use Magento\Store\Model\ScopeInterface;
class DeliverySignConfigProvider implements ConfigProviderInterface
{
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
protected $scopeConfiguration;
protected $checkoutSession;
protected $logger;
/**
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfiguration
* @codeCoverageIgnore
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfiguration,
\Magento\Checkout\Model\Session $checkoutSession,
\Psr\Log\LoggerInterface $logger
)
{
$this->scopeConfiguration = $scopeConfiguration;
$this->checkoutSession=$checkoutSession;
$this->logger=$logger;
}
/**
* {@inheritdoc}
*/
public function getConfig()
{
$deliverySignConfig = [];
$enabled = $this->scopeConfiguration->getValue('deliverysign/deliverysign/status', ScopeInterface::SCOPE_STORE);
$minimumOrderAmount = $this->scopeConfiguration->getValue('deliverysign/deliverysign/minimum_order_amount', ScopeInterface::SCOPE_STORE);
$quote=$this->checkoutSession->getQuote();
$subtotal=$quote->getSubtotal();
$this->logger->addDebug($subtotal);
$deliverySignConfig['delivery_sign_amount'] = $this->scopeConfiguration->getValue('deliverysign/deliverysign/deliverysign_amount', ScopeInterface::SCOPE_STORE);
$deliverySignConfig['show_hide_deliverysign_block'] = ($enabled && ($minimumOrderAmount<$subtotal) && $quote->getFee()) ? true : false;
$deliverySignConfig['show_hide_deliverysign_shipblock'] = ($enabled && ($minimumOrderAmount<$subtotal)) ? true : false;
return $deliverySignConfig;
}
}
Please find below for more details
https://github.com/sivajik34/Delivery-Signature-Magento2
My observation is DeliverySignConfigProvider
object is not calling when you click next button,only its calling when you are reloading the page.
Can you anyone help me on this?
Best Answer
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
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
Check
isDisplayed()
function:Kensium/DeliverySign/view/frontend/web/js/view/checkout/cart/totals/fee.js
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.