/** * {@inheritdoc} */ public function getProductDefaultTemplateData(ProductInterface $product) : array { $shippingMethodCosts = $this->shippingMethodProvider->getCosts(new ProductContext($product)); $variants = $this->variantHelper->getVariants($product); $attributes = $this->variantHelper->getAttributes($product); return ['product' => $product, 'shippingCosts' => $shippingMethodCosts, 'variants' => json_encode($variants), 'attributes' => $attributes]; }
/** * {@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)]; }
public function getShippingCostForCurrentOrder() { if ($this->hasCurrentOrder()) { $shippingCosts = $this->shippingMethodProvider->getCosts(new OrderContext($this->getCurrentOrder())); if ($shippingCosts->count()) { return $shippingCosts->first(); } } return null; }
/** * 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); }); }
/** * {@inheritdoc} */ public function buildForm(FormInterface $form) { $currentOrder = $this->orderProvider->getCurrentOrder(); $shippingMethods = $this->shippingMethodProvider->getShippingMethodOptions($currentOrder); $paymentMethods = $this->shippingMethodProvider->getShippingMethodsPaymentOptions($currentOrder); $countries = $this->get('country.repository')->all(); $requiredData = $form->addChild($this->getElement('nested_fieldset', ['name' => 'required_data', 'label' => $this->trans('order.form.fieldset.products')])); $requiredData->addChild($this->getElement('order_editor', ['name' => 'products', 'label' => $this->trans('order.heading.products'), 'repeat_min' => 1, 'repeat_max' => ElementInterface::INFINITE, 'load_products_route' => 'admin.product.grid', 'on_change' => 'OnProductListChange', 'on_before_change' => 'OnProductListBeforeChange', 'transformer' => $this->getRepositoryTransformer('order_product_collection', $this->get('order_product.repository'))])); $orderDetails = $form->addChild($this->getElement('columns', ['name' => 'orderMethodsDetails', 'label' => $this->trans('order.heading.order_methods_details')])); $paymentShippingData = $orderDetails->addChild($this->getElement('nested_fieldset', ['name' => 'methods', 'label' => $this->trans('client.heading.billing_address')])); $paymentShippingData->addChild($this->getElement('select', ['name' => 'shippingMethod', 'label' => $this->trans('order.label.shipping_method'), 'options' => $shippingMethods, 'transformer' => $this->getRepositoryTransformer('entity', $this->get('shipping_method.repository'))])); $paymentShippingData->addChild($this->getElement('select', ['name' => 'paymentMethod', 'label' => $this->trans('order.label.payment_method'), 'options' => $paymentMethods, 'transformer' => $this->getRepositoryTransformer('entity', $this->get('payment_method.repository'))])); $orderTotalData = $orderDetails->addChild($this->getElement('nested_fieldset', ['name' => 'orderTotalData', 'label' => $this->trans('order.heading.order_total')])); $orderTotalData->addChild($this->getElement('text_field', ['name' => 'shippingTotal.grossAmount', 'label' => $this->trans('order.label.shipping_total')])); $contactDetails = $form->addChild($this->getElement('nested_fieldset', ['name' => 'contactDetails', 'label' => $this->trans('order.heading.contact_details')])); $contactDetails->addChild($this->getElement('text_field', ['name' => 'contactDetails.firstName', 'label' => $this->trans('client.label.contact_details.first_name')])); $contactDetails->addChild($this->getElement('text_field', ['name' => 'contactDetails.lastName', 'label' => $this->trans('client.label.contact_details.last_name')])); $contactDetails->addChild($this->getElement('text_field', ['name' => 'contactDetails.phone', 'label' => $this->trans('client.label.contact_details.phone')])); $contactDetails->addChild($this->getElement('text_field', ['name' => 'contactDetails.secondaryPhone', 'label' => $this->trans('client.label.contact_details.secondary_phone')])); $contactDetails->addChild($this->getElement('text_field', ['name' => 'contactDetails.email', 'label' => $this->trans('client.label.contact_details.email')])); $addresses = $form->addChild($this->getElement('columns', ['name' => 'addresses', 'label' => $this->trans('order.heading.address')])); $billingAddress = $addresses->addChild($this->getElement('nested_fieldset', ['name' => 'billingAddress', 'label' => $this->trans('client.heading.billing_address')])); $billingAddress->addChild($this->getElement('text_field', ['name' => 'billingAddress.firstName', 'label' => $this->trans('client.label.address.first_name')])); $billingAddress->addChild($this->getElement('text_field', ['name' => 'billingAddress.lastName', 'label' => $this->trans('client.label.address.last_name')])); $billingAddress->addChild($this->getElement('text_field', ['name' => 'billingAddress.line1', 'label' => $this->trans('client.label.address.line1')])); $billingAddress->addChild($this->getElement('text_field', ['name' => 'billingAddress.line2', 'label' => $this->trans('client.label.address.line2')])); $billingAddress->addChild($this->getElement('text_field', ['name' => 'billingAddress.postalCode', 'label' => $this->trans('client.label.address.postal_code')])); $billingAddress->addChild($this->getElement('text_field', ['name' => 'billingAddress.state', 'label' => $this->trans('client.label.address.state')])); $billingAddress->addChild($this->getElement('text_field', ['name' => 'billingAddress.city', 'label' => $this->trans('client.label.address.city')])); $billingAddress->addChild($this->getElement('select', ['name' => 'billingAddress.country', 'label' => $this->trans('client.label.address.country'), 'options' => $countries])); $billingAddress->addChild($this->getElement('text_field', ['name' => 'billingAddress.vatId', 'label' => $this->trans('client.label.address.vat_id')])); $billingAddress->addChild($this->getElement('text_field', ['name' => 'billingAddress.companyName', 'label' => $this->trans('client.label.address.company_name')])); $shippingAddress = $addresses->addChild($this->getElement('nested_fieldset', ['name' => 'shippingAddress', 'label' => $this->trans('client.heading.shipping_address')])); $shippingAddress->addChild($this->getElement('text_field', ['name' => 'shippingAddress.firstName', 'label' => $this->trans('client.label.address.first_name')])); $shippingAddress->addChild($this->getElement('text_field', ['name' => 'shippingAddress.lastName', 'label' => $this->trans('client.label.address.last_name')])); $shippingAddress->addChild($this->getElement('text_field', ['name' => 'shippingAddress.line1', 'label' => $this->trans('client.label.address.line1')])); $shippingAddress->addChild($this->getElement('text_field', ['name' => 'shippingAddress.line2', 'label' => $this->trans('client.label.address.line2')])); $shippingAddress->addChild($this->getElement('text_field', ['name' => 'shippingAddress.postalCode', 'label' => $this->trans('client.label.address.postal_code')])); $shippingAddress->addChild($this->getElement('text_field', ['name' => 'shippingAddress.state', 'label' => $this->trans('client.label.address.state')])); $shippingAddress->addChild($this->getElement('text_field', ['name' => 'shippingAddress.city', 'label' => $this->trans('client.label.address.city')])); $shippingAddress->addChild($this->getElement('select', ['name' => 'shippingAddress.country', 'label' => $this->trans('client.label.address.country'), 'options' => $countries])); $form->addFilter($this->getFilter('no_code')); $form->addFilter($this->getFilter('trim')); $form->addFilter($this->getFilter('secure')); }
protected function getShippingMethodCostCollection(CartInterface $cart) { return $this->shippingMethodProvider->getShippingMethodCostsCollection($cart); }