/** * Retrieve payment method and assign additional template values * * @return $this */ protected function _beforeToHtml() { $methodInstance = $this->_quote->getPayment()->getMethodInstance(); $this->setPaymentMethodTitle($methodInstance->getTitle()); $this->setShippingRateRequired(true); if ($this->_quote->getIsVirtual()) { $this->setShippingRateRequired(false); } else { // prepare shipping rates $this->_address = $this->_quote->getShippingAddress(); $groups = $this->_address->getGroupedAllShippingRates(); if ($groups && $this->_address) { $this->setShippingRateGroups($groups); // determine current selected code & name foreach ($groups as $code => $rates) { foreach ($rates as $rate) { if ($this->_address->getShippingMethod() == $rate->getCode()) { $this->_currentShippingRate = $rate; break 2; } } } } $canEditShippingAddress = $this->_quote->getMayEditShippingAddress() && $this->_quote->getPayment()->getAdditionalInformation(\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_BUTTON) == 1; // misc shipping parameters $this->setShippingMethodSubmitUrl($this->getUrl("{$this->_controllerPath}/saveShippingMethod"))->setCanEditShippingAddress($canEditShippingAddress)->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod()); } $this->setEditUrl($this->getUrl("{$this->_controllerPath}/edit"))->setPlaceOrderUrl($this->getUrl("{$this->_controllerPath}/placeOrder")); return parent::_beforeToHtml(); }
/** * Make sure addresses will be saved without validation errors * * @return void */ private function _ignoreAddressValidation() { $this->_quote->getBillingAddress()->setShouldIgnoreValidation(true); if (!$this->_quote->getIsVirtual()) { $this->_quote->getShippingAddress()->setShouldIgnoreValidation(true); if (!$this->_config->getConfigValue('requireBillingAddress') && !$this->_quote->getBillingAddress()->getEmail()) { $this->_quote->getBillingAddress()->setSameAsBilling(1); } } }
/** * Fetch base quote data and map it to DTO fields * * @param Quote $quote * @return array */ public function map(Quote $quote) { return [Cart::ID => $quote->getId(), Cart::STORE_ID => $quote->getStoreId(), Cart::CREATED_AT => $quote->getCreatedAt(), Cart::UPDATED_AT => $quote->getUpdatedAt(), Cart::CONVERTED_AT => $quote->getConvertedAt(), Cart::IS_ACTIVE => $quote->getIsActive(), Cart::IS_VIRTUAL => $quote->getIsVirtual(), Cart::ITEMS_COUNT => $quote->getItemsCount(), Cart::ITEMS_QUANTITY => $quote->getItemsQty(), Cart::CHECKOUT_METHOD => $quote->getCheckoutMethod(), Cart::RESERVED_ORDER_ID => $quote->getReservedOrderId(), Cart::ORIG_ORDER_ID => $quote->getOrigOrderId()]; }
/** * {@inheritdoc} */ public function getTaxContainer() { return $this->_salesModel->getIsVirtual() ? $this->_salesModel->getBillingAddress() : $this->_salesModel->getShippingAddress(); }
/** * Fetch base quote data and map it to DTO fields * * @param Quote $quote * @return array */ public function map(Quote $quote) { $this->cartBuilder->populateWithArray([Cart::ID => $quote->getId(), Cart::STORE_ID => $quote->getStoreId(), Cart::CREATED_AT => $quote->getCreatedAt(), Cart::UPDATED_AT => $quote->getUpdatedAt(), Cart::CONVERTED_AT => $quote->getConvertedAt(), Cart::IS_ACTIVE => $quote->getIsActive(), Cart::IS_VIRTUAL => $quote->getIsVirtual(), Cart::ITEMS_COUNT => $quote->getItemsCount(), Cart::ITEMS_QUANTITY => $quote->getItemsQty(), Cart::CHECKOUT_METHOD => $quote->getCheckoutMethod(), Cart::RESERVED_ORDER_ID => $quote->getReservedOrderId(), Cart::ORIG_ORDER_ID => $quote->getOrigOrderId()]); $this->customerBuilder->populateWithArray($this->customerMapper->map($quote)); $this->totalsBuilder->populateWithArray($this->totalsMapper->map($quote)); $items = []; foreach ($quote->getAllItems() as $item) { $items[] = $this->itemTotalsMapper->extractDto($item); } $this->totalsBuilder->setItems($items); $this->cartBuilder->setCustomer($this->customerBuilder->create()); $this->cartBuilder->setTotals($this->totalsBuilder->create()); $this->cartBuilder->setCurrency($this->currencyMapper->extractDto($quote)); return $this->cartBuilder->create(); }