Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Index.php
Go to the documentation of this file.
1 <?php
7 
12 
14 {
18  protected $result;
19 
23  protected $checkoutSession;
24 
30  public function __construct(
31  Context $context,
32  \Magento\Checkout\Model\Session $session
33  ) {
34  $this->checkoutSession = $session;
35  parent::__construct($context);
36  }
37 
44  public function execute()
45  {
46  $quote = $this->checkoutSession->getQuote();
47  $address = $quote->getShippingAddress();
48  $address->collectShippingRates()->save();
49  $rates = $address->getGroupedAllShippingRates();
50  $result = $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_JSON);
51  $result->setData($rates);
52  return $result;
53  }
54 }
$quote
$rates
Definition: tax.phtml:35
$address
Definition: customer.php:38
__construct(Context $context, \Magento\Checkout\Model\Session $session)
Definition: Index.php:30