/** * {@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)]; }
/** * 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->orderContext->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.order_total.shipping')])); $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.addresses')])); $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.street', 'label' => $this->trans('client.label.address.street')])); $billingAddress->addChild($this->getElement('text_field', ['name' => 'billingAddress.streetNo', 'label' => $this->trans('client.label.address.street_no')])); $billingAddress->addChild($this->getElement('text_field', ['name' => 'billingAddress.flatNo', 'label' => $this->trans('client.label.address.flat_no')])); $billingAddress->addChild($this->getElement('text_field', ['name' => 'billingAddress.postCode', 'label' => $this->trans('client.label.address.post_code')])); $billingAddress->addChild($this->getElement('text_field', ['name' => 'billingAddress.province', 'label' => $this->trans('client.label.address.province')])); $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])); $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.street', 'label' => $this->trans('client.label.address.street')])); $shippingAddress->addChild($this->getElement('text_field', ['name' => 'shippingAddress.streetNo', 'label' => $this->trans('client.label.address.street_no')])); $shippingAddress->addChild($this->getElement('text_field', ['name' => 'shippingAddress.flatNo', 'label' => $this->trans('client.label.address.flat_no')])); $shippingAddress->addChild($this->getElement('text_field', ['name' => 'shippingAddress.postCode', 'label' => $this->trans('client.label.address.post_code')])); $shippingAddress->addChild($this->getElement('text_field', ['name' => 'shippingAddress.province', 'label' => $this->trans('client.label.address.province')])); $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); }