Model/Api/ShippingMethods.php
public function getShippingMethods($cart, $shipping_address)
    {
        try {
//            $this->logHelper->addInfoLog($this->request->getContent());

            $this->preprocessHook();

            // get immutable quote id stored with transaction
            list(, $quoteId) = explode(' / ', $cart['display_id']);

            // Load quote from entity id
            $quote = $this->cartHelper->getQuoteById($quoteId);

            if (!$quote || !$quote->getId()) {
                $this->throwUnknownQuoteIdException($quoteId);
            }

            $this->checkCartItems($cart, $quote);

            // Load logged in customer checkout and customer sessions from cached session id.
            // Replace parent quote with immutable quote in checkout session.
            $this->sessionHelper->loadSession($quote);

            $addressData = $this->cartHelper->handleSpecialAddressCases($shipping_address);

            if (isset($addressData['email']) && $addressData['email'] !== null) {
                $this->validateAddressData($addressData);
            }

            $shippingOptionsModel = $this->shippingEstimation($quote, $addressData);

            if ($this->taxAdjusted) {
                $this->bugsnag->registerCallback(function ($report) use ($shippingOptionsModel) {
                    $report->setMetaData([
                        'SHIPPING OPTIONS' => [print_r($shippingOptionsModel, 1)]
                    ]);
                });
                $this->bugsnag->notifyError('Cart Totals Mismatch', "Totals adjusted.");
            }

            /** @var \Magento\Quote\Model\Quote $parentQuote */
            $parentQuote = $this->cartHelper->getQuoteById($cart['order_reference']);
            if ($this->couponInvalidForShippingAddress($parentQuote->getCouponCode(), $quote)){
                $address = $parentQuote->isVirtual() ? $parentQuote->getBillingAddress() : $parentQuote->getShippingAddress();
                $additionalAmount = abs($this->cartHelper->getRoundAmount($address->getDiscountAmount()));

                $shippingOptionsModel->addAmountToShippingOptions($additionalAmount);
            }

            return $shippingOptionsModel;
        } catch (\Magento\Framework\Webapi\Exception $e) {
            $this->catchExceptionAndSendError($e, $e->getMessage(), $e->getCode(), $e->getHttpCode());
        } catch (BoltException $e) {
            $this->catchExceptionAndSendError($e, $e->getMessage(), $e->getCode());
        } catch (\Exception $e) {
            $msg = __('Unprocessable Entity') . ': ' . $e->getMessage();
            $this->catchExceptionAndSendError($e, $msg, 6009, 422);
        }
    }
public function getShippingMethods($cart, $shipping_address)
    {
        try {
//            $this->logHelper->addInfoLog($this->request->getContent());

            $this->preprocessHook();

            // get immutable quote id stored with transaction
            list(, $quoteId) = explode(' / ', $cart['display_id']);

            // Load quote from entity id
            $quote = $this->cartHelper->getQuoteById($quoteId);

            if (!$quote || !$quote->getId()) {
                $this->throwUnknownQuoteIdException($quoteId);
            }

            $this->checkCartItems($cart, $quote);

            // Load logged in customer checkout and customer sessions from cached session id.
            // Replace parent quote with immutable quote in checkout session.
            $this->sessionHelper->loadSession($quote);

            $addressData = $this->cartHelper->handleSpecialAddressCases($shipping_address);

            if (isset($addressData['email']) && $addressData['email'] !== null) {
                $this->validateAddressData($addressData);
            }

            $shippingOptionsModel = $this->shippingEstimation($quote, $addressData);

            if ($this->taxAdjusted) {
                $this->bugsnag->registerCallback(function ($report) use ($shippingOptionsModel) {
                    $report->setMetaData([
                        'SHIPPING OPTIONS' => [print_r($shippingOptionsModel, 1)]
                    ]);
                });
                $this->bugsnag->notifyError('Cart Totals Mismatch', "Totals adjusted.");
            }

            /** @var \Magento\Quote\Model\Quote $parentQuote */
            $parentQuote = $this->cartHelper->getQuoteById($cart['order_reference']);
            if ($this->couponInvalidForShippingAddress($parentQuote->getCouponCode(), $quote)){
                $address = $parentQuote->isVirtual() ? $parentQuote->getBillingAddress() : $parentQuote->getShippingAddress();
                $additionalAmount = abs($this->cartHelper->getRoundAmount($address->getDiscountAmount()));

                $shippingOptionsModel->addAmountToShippingOptions($additionalAmount);
            }

            return $shippingOptionsModel;
        } catch (\Magento\Framework\Webapi\Exception $e) {
            $this->catchExceptionAndSendError($e, $e->getMessage(), $e->getCode(), $e->getHttpCode());
        } catch (BoltException $e) {
            $this->catchExceptionAndSendError($e, $e->getMessage(), $e->getCode());
        } catch (\Exception $e) {
            $msg = __('Unprocessable Entity') . ': ' . $e->getMessage();
            $this->catchExceptionAndSendError($e, $msg, 6009, 422);
        }
    }
public function getShippingMethods ( $ cart , $ shipping_address ) { try { //            $this->logHelper->addInfoLog($this->request->getContent()); $ this -> preprocessHook ( ) ; // get immutable quote id stored with transaction list ( , $ quoteId ) = explode ( ' / ' , $ cart [ 'display_id' ] ) ; // Load quote from entity id $ quote = $ this -> cartHelper -> getQuoteById ( $ quoteId ) ; if ( ! $ quote || ! $ quote -> getId ( ) ) { $ this -> throwUnknownQuoteIdException ( $ quoteId ) ; } $ this -> checkCartItems ( $ cart , $ quote ) ; // Load logged in customer checkout and customer sessions from cached session id. // Replace parent quote with immutable quote in checkout session. $ this -> sessionHelper -> loadSession ( $ quote ) ; $ addressData = $ this -> cartHelper -> handleSpecialAddressCases ( $ shipping_address ) ; if ( isset ( $ addressData [ 'email' ] ) && $ addressData [ 'email' ] !== null ) { $ this -> validateAddressData ( $ addressData ) ; } $ shippingOptionsModel = $ this -> shippingEstimation ( $ quote , $ addressData ) ; if ( $ this -> taxAdjusted ) { $ this -> bugsnag -> registerCallback ( function ( $ report ) use ( $ shippingOptionsModel ) { $ report -> setMetaData ( [ 'SHIPPING OPTIONS' => [ print_r ( $ shippingOptionsModel , 1 ) ] ] ) ; } ) ; $ this -> bugsnag -> notifyError ( 'Cart Totals Mismatch' , "Totals adjusted." ) ; } /** @var \Magento\Quote\Model\Quote $parentQuote */ $ parentQuote = $ this -> cartHelper -> getQuoteById ( $ cart [ 'order_reference' ] ) ; if ( $ this -> couponInvalidForShippingAddress ( $ parentQuote -> getCouponCode ( ) , $ quote ) ) { $ address = $ parentQuote -> isVirtual ( ) ? $ parentQuote -> getBillingAddress ( ) : $ parentQuote -> getShippingAddress ( ) ; $ additionalAmount = abs ( $ this -> cartHelper -> getRoundAmount ( $ address -> getDiscountAmount ( ) ) ) ; $ shippingOptionsModel -> addAmountToShippingOptions ( $ additionalAmount ) ; } return $ shippingOptionsModel ; } catch ( \ Magento \ Framework \ Webapi \ Exception $ e ) { $ this -> catchExceptionAndSendError ( $ e , $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> getHttpCode ( ) ) ; } catch ( BoltException $ e ) { $ this -> catchExceptionAndSendError ( $ e , $ e -> getMessage ( ) , $ e -> getCode ( ) ) ; } catch ( \ Exception $ e ) { $ msg = __ ( 'Unprocessable Entity' ) . ': ' . $ e -> getMessage ( ) ; $ this -> catchExceptionAndSendError ( $ e , $ msg , 6009 , 422 ) ; } }
Get all available shipping methods and tax data.

@api

@param array $cart cart details
@param array $shipping_address shipping address

@return ShippingOptionsInterface
@throws \Exception
Get all available shipping methods and tax data .