Example #1
0
 /**
  * Adds shipping method options to select
  *
  * @param RadioGroup    $radioGroup
  * @param CartInterface $cart
  */
 protected function addShippingOptions(RadioGroup $radioGroup, CartInterface $cart)
 {
     $collection = $this->cartShippingMethodProvider->getShippingMethodCostsCollection($cart);
     $collection->map(function (ShippingMethodCostInterface $shippingMethodCost) use($radioGroup) {
         $shippingMethod = $shippingMethodCost->getShippingMethod();
         $baseCurrency = $shippingMethod->getCurrency()->getCode();
         $grossAmount = $shippingMethodCost->getCost()->getGrossAmount();
         $label = ['name' => $shippingMethod->translate()->getName(), 'comment' => $this->getCurrencyHelper()->convertAndFormat($grossAmount, $baseCurrency)];
         $radioGroup->addOptionToSelect($shippingMethodCost->getId(), $label);
     });
 }
 protected function getShippingMethodCostCollection(CartInterface $cart)
 {
     return $this->cartShippingMethodProvider->getShippingMethodCostsCollection($cart);
 }