Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function getProductDefaultTemplateData(ProductInterface $product)
 {
     $shippingMethodCosts = $this->shippingMethodProvider->getShippingMethodCostsCollection($product);
     $productAttributes = $product->getAttributes();
     $groups = $this->productAttributeHelper->getAttributeGroups($productAttributes);
     $attributes = $this->productAttributeHelper->getAttributes($productAttributes);
     return ['product' => $product, 'shippingCosts' => $shippingMethodCosts, 'attributeGroups' => $groups, 'attributes' => json_encode($attributes)];
 }
Ejemplo n.º 2
0
 /**
  * Adds shipping method options to select
  *
  * @param RadioGroup    $radioGroup
  * @param CartInterface $cart
  */
 protected function addShippingOptions(RadioGroup $radioGroup, CartInterface $cart)
 {
     $collection = $this->shippingMethodProvider->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->shippingMethodProvider->getShippingMethodCostsCollection($cart);
 }