I have make some change in file to make it selected but i don't think this is the right to make it working like this.so i just want to know from the master that is there any other way to do it using magento standard code

I have rewrite the checkout controller estimatepostaction.

Here is below code.

public function estimatePostAction()
     * if the quantity in the cart is updated, then the estimate address is updated
     * to the changed address
     * if the quantity is not updated, then the estimate address is set to the default
     * one available
    $country = (string) $this->getRequest()->getParam('country_id');
    $postcode = (string) $this->getRequest()->getParam('estimate_postcode');
    $city = (string) $this->getRequest()->getParam('estimate_city');
    $regionId = (string) $this->getRequest()->getParam('region_id');
    $region = (string) $this->getRequest()->getParam('region');

    $quote = $this->_getCart()->getQuote();


    $cartShippings = [];
    $allRates = $quote->getShippingAddress()
    foreach ($allRates as $carrier) {
        foreach ($carrier as $rate) {
            $cartShippings[] = $rate->getData();

    // This code calculates the lowest shipping amount and the shipping code associated
    // with it.

    $totalShippingMethods = count($cartShippings);
    $minValue = (float) 999999;
    $lowestShipingCode = '';
    for ($smallVal = 0; $smallVal < $totalShippingMethods; $smallVal ++) {
        $current_rate = (float) $cartShippings[$smallVal]['price'];
        if ($current_rate < $minValue) {
            $minValue = $cartShippings[$smallVal]['price'];
            $lowestShipingCode = $cartShippings[$smallVal]['code'];

    $leastShippingCode = (string) $lowestShipingCode;

    // setting the shipping code to the quote.
    if (! empty($leastShippingCode)) {

Your Answer

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

Browse other questions tagged or ask your own question.