_jsonEncoder = $jsonEncoder; $this->_customerFormFactory = $customerFormFactory; $this->customerRepository = $customerRepository; $this->_localeCurrency = $localeCurrency; $this->addressMapper = $addressMapper; parent::__construct($context, $sessionQuote, $orderCreate, $priceCurrency, $data); } /** * Constructor * * @return void */ protected function _construct() { parent::_construct(); $this->setId('sales_order_create_form'); } /** * Retrieve url for loading blocks * * @return string */ public function getLoadBlockUrl() { return $this->getUrl('sales/*/loadBlock'); } /** * Retrieve url for form submitting * * @return string */ public function getSaveUrl() { return $this->getUrl('sales/*/save'); } /** * Get customer selector display * * @return string */ public function getCustomerSelectorDisplay() { $customerId = $this->getCustomerId(); if ($customerId === null) { return 'block'; } return 'none'; } /** * Get store selector display * * @return string */ public function getStoreSelectorDisplay() { $storeId = $this->getStoreId(); $customerId = $this->getCustomerId(); if ($customerId !== null && !$storeId) { return 'block'; } return 'none'; } /** * Get data selector display * * @return string */ public function getDataSelectorDisplay() { $storeId = $this->getStoreId(); $customerId = $this->getCustomerId(); if ($customerId !== null && $storeId) { return 'block'; } return 'none'; } /** * Get order data jason * * @return string */ public function getOrderDataJson() { $data = []; $this->_storeManager->setCurrentStore($this->getStoreId()); if ($this->getCustomerId()) { $data['customer_id'] = $this->getCustomerId(); $data['addresses'] = []; $addresses = $this->customerRepository->getById($this->getCustomerId())->getAddresses(); foreach ($addresses as $address) { $addressForm = $this->_customerFormFactory->create( 'customer_address', 'adminhtml_customer_address', $this->addressMapper->toFlatArray($address) ); $data['addresses'][$address->getId()] = $addressForm->outputData( \Magento\Eav\Model\AttributeDataFactory::OUTPUT_FORMAT_JSON ); } } if ($this->getStoreId() !== null) { $data['store_id'] = $this->getStoreId(); $currency = $this->_localeCurrency->getCurrency($this->getStore()->getCurrentCurrencyCode()); $symbol = $currency->getSymbol() ? $currency->getSymbol() : $currency->getShortName(); $data['currency_symbol'] = $symbol; $data['shipping_method_reseted'] = !(bool)$this->getQuote()->getShippingAddress()->getShippingMethod(); $data['payment_method'] = $this->getQuote()->getPayment()->getMethod(); } $data['quote_id'] = $this->_sessionQuote->getQuoteId(); return $this->_jsonEncoder->encode($data); } }