0

I want to reload total section when checkbox checked/unchecked.

Here is the code I am trying to implement.

etc/frontend/sections.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
    <action name="extrafee/update/updatesession">
        <section name="cart"/>
    </action>
</config>

Trying to call the line in my phtml file.

<script>
    require(['jquery'], function ($) {
        $("#installation").change(function() {
            require('Magento_Customer/js/customer-data').reload(['checkout-data'], false)
        });
    });
</script>

If I reload page manually, it is okay. the total is updating.

0

Try to add

<section name="checkout-data"/>

to your sections.xml like this

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
    <action name="extrafee/update/updatesession">
        <section name="cart"/>
        <section name="checkout-data"/>
    </action>
</config>

and also request your action when you checked/unchecked

<script>
    require(['jquery'], function ($) {
        $("#installation").change(function() {
            var url = "<?php echo $this->getUrl('extrafee/update/updatesession', array('_secure'=>true)) ?>";
            $.ajax({
            url: url,
            type: "POST",
            data: {checked:your_value_here},
            showLoader: true,
            cache: false,
            success: function(response){
                console.log("success");
            }
        });

        });
    });
</script>

Don't forget to replace (your_value_here) with your checkbox value in this line

data: {checked:your_value_here},
1
  • I want to reload it after success my ajax call. b'coz here extrafee/update/updatesession I have some logic to implement fee on cart. So after calculation, i want to reload cart total – Dharmesh Hariyani Apr 11 '18 at 2:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.