Magento custom development is a core part of any Ecommerce project to fulfill business needs, because at any stage if the store owner wants to integrate or want your own functionality in your existing Magento store custom extension development is key to success. And shipping is one of the powerful factors that may make or break the business in multiple ways. Because selling different types of products from light to heavy, shipping methods and charges vary depending on product size, type, and shipping location.

That’s the reason why after developing your own custom shipping related action or event, you have to reload the Shipping Methods and cart summary of Magento 2 shopping cart page. Default, Magento 2 provides the functionality to reload the cart shipping method by using knockout JS. So, considering the above situation for our extension, here is code that allows you to call your custom Ajax on the shopping cart page through which you can update shipping method according to your logic.

To do the same, first we need to create ‘checkout_cart_index.xml’ inside our extension folder at this path.

Using the above code we have added our custom field in our shopping cart page before payment list.
Now, we have to create one more ‘cart.phtml’ at this path using below code.

As shown in the above example, we have submitted our data using AJAX call to the server and to respond to that we have reloaded the shipping area of the Magento shopping cart page.

That’s it for today! If you found this blog helpful, don’t forget to share it with your colleagues and Magento Friends.

And, Let us know if you are facing an issue while implementing this code.

Happy Reloading!

Click to rate this post!
[Total: 10 Average: 4.2]