cancel
Showing results for 
Search instead for 
Did you mean: 

Estimate shipping methods

Estimate shipping methods

I would like to know where the function is for :

rest/default/V1/guest-carts/numbers/estimate-shipping-methods

 

I found no function is called when postcode on cart is changed?

3 REPLIES

Re: Estimate shipping methods

Hello @tvgarden

 

There is define into webapi.xml file

 

https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Quote/etc/webapi.xml

 

 

<route url="/V1/carts/:cartId/estimate-shipping-methods" method="POST">
        <service class="Magento\Quote\Api\ShipmentEstimationInterface" method="estimateByExtendedAddress"/>
        <resources>
            <resource ref="Magento_Cart::manage" />
        </resources>
    </route>
    <route url="/V1/carts/:cartId/estimate-shipping-methods-by-address-id" method="POST">
        <service class="Magento\Quote\Api\ShippingMethodManagementInterface" method="estimateByAddressId"/>
        <resources>
            <resource ref="Magento_Cart::manage" />
        </resources>
    </route>

From there you can find Interface name and you can find which class implement that you need to check in di.xml file

https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/Quote/etc/di.xml

 

<preference for="Magento\Quote\Api\ShipmentEstimationInterface" type="Magento\Quote\Model\ShippingMethodManagement" />

So you need to find 

Magento\Quote\Model\ShippingMethodManagement.php with
estimateByAddressId or
estimateByExtendedAddress method from that class

Hope it will help you.

 

 

 

Re: Estimate shipping methods

Thanks, that's helpful.

 

However I need to find a function in front-end.

Which is calling    post: in storage.js ?

Re: Estimate shipping methods

You can find post function inside storage.js from magento2-base module.

Full path for post function is,

vendor/magento/magento2-base/lib/web/mage/storage.js

Open this file and you can check post function with below value,

/**
  * Perform asynchronous POST request to server.
         * @param {String} url
         * @param {String} data
         * @param {Boolean} global
         * @param {String} contentType
         * @returns {Deferred}
         */
        post: function (url, data, global, contentType) {
            global = global === undefined ? true : global;
            contentType = contentType || 'application/json';

            return $.ajax({
                url: urlBuilder.build(url),
                type: 'POST',
                data: data,
                global: global,
                contentType: contentType
            });
        },
If Issue Solved, Click Kudos/Accept As solutions.