Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Onepage Class Reference

Public Member Functions

 __construct (\Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Checkout\Helper\Data $helper, \Magento\Customer\Model\Url $customerUrl, \Psr\Log\LoggerInterface $logger, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Customer\Model\Session $customerSession, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\App\RequestInterface $request, \Magento\Customer\Model\AddressFactory $customrAddrFactory, \Magento\Customer\Model\FormFactory $customerFormFactory, \Magento\Customer\Model\CustomerFactory $customerFactory, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Framework\DataObject\Copy $objectCopyService, \Magento\Framework\Message\ManagerInterface $messageManager, \Magento\Customer\Model\Metadata\FormFactory $formFactory, CustomerDataFactory $customerDataFactory, \Magento\Framework\Math\Random $mathRandom, \Magento\Framework\Encryption\EncryptorInterface $encryptor, AddressRepositoryInterface $addressRepository, AccountManagementInterface $accountManagement, OrderSender $orderSender, CustomerRepositoryInterface $customerRepository, \Magento\Quote\Api\CartRepositoryInterface $quoteRepository, \Magento\Framework\Api\ExtensibleDataObjectConverter $extensibleDataObjectConverter, \Magento\Quote\Api\CartManagementInterface $quoteManagement, \Magento\Framework\Api\DataObjectHelper $dataObjectHelper, \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector)
 
 getCheckout ()
 
 getQuote ()
 
 setQuote (\Magento\Quote\Model\Quote $quote)
 
 getCustomerSession ()
 
 initCheckout ()
 
 getCheckoutMethod ()
 
 saveCheckoutMethod ($method)
 
 saveShipping ($data, $customerAddressId)
 
 saveShippingMethod ($shippingMethod)
 
 savePayment ($data)
 
 saveOrder ()
 
 getLastOrderId ()
 

Data Fields

const METHOD_GUEST = 'guest'
 
const METHOD_REGISTER = 'register'
 
const METHOD_CUSTOMER = 'customer'
 
const USE_FOR_SHIPPING = 1
 
const NOT_USE_FOR_SHIPPING = 0
 

Protected Member Functions

 isCheckoutMethodRegister ()
 
 validate ()
 
 _prepareGuestQuote ()
 
 _prepareNewCustomerQuote ()
 
 _prepareCustomerQuote ()
 
 _involveNewCustomer ()
 
 _customerEmailExists ($email, $websiteId=null)
 

Protected Attributes

 $_customerSession
 
 $_checkoutSession
 
 $_quote = null
 
 $_helper
 
 $_logger
 
 $_customerUrl
 
 $_eventManager = null
 
 $_storeManager
 
 $_request
 
 $_customrAddrFactory
 
 $_customerFormFactory
 
 $_customerFactory
 
 $_orderFactory
 
 $_objectCopyService
 
 $messageManager
 
 $_formFactory
 
 $customerDataFactory
 
 $mathRandom
 
 $addressRepository
 
 $accountManagement
 
 $orderSender
 
 $quoteRepository
 
 $customerRepository
 
 $extensibleDataObjectConverter
 
 $quoteManagement
 
 $dataObjectHelper
 
 $totalsCollector
 

Detailed Description

@SuppressWarnings(PHPMD.TooManyFields) @SuppressWarnings(PHPMD.ExcessiveClassComplexity) @SuppressWarnings(PHPMD.CouplingBetweenObjects)

Definition at line 22 of file Onepage.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( \Magento\Framework\Event\ManagerInterface  $eventManager,
\Magento\Checkout\Helper\Data  $helper,
\Magento\Customer\Model\Url  $customerUrl,
\Psr\Log\LoggerInterface  $logger,
\Magento\Checkout\Model\Session  $checkoutSession,
\Magento\Customer\Model\Session  $customerSession,
\Magento\Store\Model\StoreManagerInterface  $storeManager,
\Magento\Framework\App\RequestInterface  $request,
\Magento\Customer\Model\AddressFactory  $customrAddrFactory,
\Magento\Customer\Model\FormFactory  $customerFormFactory,
\Magento\Customer\Model\CustomerFactory  $customerFactory,
\Magento\Sales\Model\OrderFactory  $orderFactory,
\Magento\Framework\DataObject\Copy  $objectCopyService,
\Magento\Framework\Message\ManagerInterface  $messageManager,
\Magento\Customer\Model\Metadata\FormFactory  $formFactory,
CustomerDataFactory  $customerDataFactory,
\Magento\Framework\Math\Random  $mathRandom,
\Magento\Framework\Encryption\EncryptorInterface  $encryptor,
AddressRepositoryInterface  $addressRepository,
AccountManagementInterface  $accountManagement,
OrderSender  $orderSender,
CustomerRepositoryInterface  $customerRepository,
\Magento\Quote\Api\CartRepositoryInterface  $quoteRepository,
\Magento\Framework\Api\ExtensibleDataObjectConverter  $extensibleDataObjectConverter,
\Magento\Quote\Api\CartManagementInterface  $quoteManagement,
\Magento\Framework\Api\DataObjectHelper  $dataObjectHelper,
\Magento\Quote\Model\Quote\TotalsCollector  $totalsCollector 
)
Parameters
\Magento\Framework\Event\ManagerInterface$eventManager
\Magento\Checkout\Helper\Data$helper
\Magento\Customer\Model\Url$customerUrl
\Psr\Log\LoggerInterface$logger
\Magento\Checkout\Model\Session$checkoutSession
\Magento\Customer\Model\Session$customerSession
\Magento\Store\Model\StoreManagerInterface$storeManager
\Magento\Framework\App\RequestInterface$request
\Magento\Customer\Model\AddressFactory$customrAddrFactory
\Magento\Customer\Model\FormFactory$customerFormFactory
\Magento\Customer\Model\CustomerFactory$customerFactory
\Magento\Sales\Model\OrderFactory$orderFactory
\Magento\Framework\DataObject\Copy$objectCopyService
\Magento\Framework\Message\ManagerInterface$messageManager
\Magento\Customer\Model\Metadata\FormFactory$formFactory
CustomerDataFactory$customerDataFactory
\Magento\Framework\Math\Random$mathRandom
\Magento\Framework\Encryption\EncryptorInterface$encryptor
AddressRepositoryInterface$addressRepository
AccountManagementInterface$accountManagement
OrderSender$orderSender
CustomerRepositoryInterface$customerRepository
\Magento\Quote\Api\CartRepositoryInterface$quoteRepository
\Magento\Framework\Api\ExtensibleDataObjectConverter$extensibleDataObjectConverter
\Magento\Quote\Api\CartManagementInterface$quoteManagement
\Magento\Framework\Api\DataObjectHelper$dataObjectHelper
\Magento\Quote\Model\Quote\TotalsCollector$totalsCollector@codeCoverageIgnore @SuppressWarnings(PHPMD.ExcessiveParameterList)

Definition at line 203 of file Onepage.php.

231  {
232  $this->_eventManager = $eventManager;
233  $this->_customerUrl = $customerUrl;
234  $this->_helper = $helper;
235  $this->_checkoutSession = $checkoutSession;
236  $this->_customerSession = $customerSession;
237  $this->_logger = $logger;
238  $this->_storeManager = $storeManager;
239  $this->_request = $request;
240  $this->_customrAddrFactory = $customrAddrFactory;
241  $this->_customerFormFactory = $customerFormFactory;
242  $this->_customerFactory = $customerFactory;
243  $this->_orderFactory = $orderFactory;
244  $this->_objectCopyService = $objectCopyService;
245  $this->messageManager = $messageManager;
246  $this->_formFactory = $formFactory;
247  $this->customerDataFactory = $customerDataFactory;
248  $this->mathRandom = $mathRandom;
249  $this->_encryptor = $encryptor;
250  $this->addressRepository = $addressRepository;
251  $this->accountManagement = $accountManagement;
252  $this->orderSender = $orderSender;
253  $this->customerRepository = $customerRepository;
254  $this->quoteRepository = $quoteRepository;
255  $this->extensibleDataObjectConverter = $extensibleDataObjectConverter;
256  $this->quoteManagement = $quoteManagement;
257  $this->dataObjectHelper = $dataObjectHelper;
258  $this->totalsCollector = $totalsCollector;
259  }
$helper
Definition: iframe.phtml:13
$customerUrl
Definition: info.phtml:28
$storeManager
$logger

Member Function Documentation

◆ _customerEmailExists()

_customerEmailExists (   $email,
  $websiteId = null 
)
protected

Check if customer email exists

Parameters
string$email
int$websiteId
Returns
false|\Magento\Customer\Model\Customer @codeCoverageIgnore

Definition at line 764 of file Onepage.php.

765  {
766  return !$this->accountManagement->isEmailAvailable($email, $websiteId);
767  }
$email
Definition: details.phtml:13

◆ _involveNewCustomer()

_involveNewCustomer ( )
protected

Involve new customer to system

Returns
$this

Definition at line 663 of file Onepage.php.

664  {
665  $customer = $this->getQuote()->getCustomer();
666  $confirmationStatus = $this->accountManagement->getConfirmationStatus($customer->getId());
667  if ($confirmationStatus === \Magento\Customer\Model\AccountManagement::ACCOUNT_CONFIRMATION_REQUIRED) {
668  $url = $this->_customerUrl->getEmailConfirmationUrl($customer->getEmail());
669  $this->messageManager->addSuccessMessage(
670  // @codingStandardsIgnoreStart
671  __(
672  'You must confirm your account. Please check your email for the confirmation link or <a href="%1">click here</a> for a new link.',
673  $url
674  )
675  // @codingStandardsIgnoreEnd
676  );
677  } else {
678  $this->getCustomerSession()->loginById($customer->getId());
679  }
680  return $this;
681  }
$customer
Definition: customers.php:11
__()
Definition: __.php:13

◆ _prepareCustomerQuote()

_prepareCustomerQuote ( )
protected

Prepare quote for customer order submit

Returns
void @SuppressWarnings(PHPMD.CyclomaticComplexity)

Definition at line 620 of file Onepage.php.

621  {
622  $quote = $this->getQuote();
623  $billing = $quote->getBillingAddress();
624  $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
625 
626  $customer = $this->customerRepository->getById($this->getCustomerSession()->getCustomerId());
627  $hasDefaultBilling = (bool)$customer->getDefaultBilling();
628  $hasDefaultShipping = (bool)$customer->getDefaultShipping();
629 
630  if ($shipping && !$shipping->getSameAsBilling() &&
631  (!$shipping->getCustomerId() || $shipping->getSaveInAddressBook())
632  ) {
633  $shippingAddress = $shipping->exportCustomerAddress();
634  if (!$hasDefaultShipping) {
635  //Make provided address as default shipping address
636  $shippingAddress->setIsDefaultShipping(true);
637  $hasDefaultShipping = true;
638  }
639  $quote->addCustomerAddress($shippingAddress);
640  $shipping->setCustomerAddressData($shippingAddress);
641  }
642 
643  if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) {
644  $billingAddress = $billing->exportCustomerAddress();
645  if (!$hasDefaultBilling) {
646  //Make provided address as default shipping address
647  if (!$hasDefaultShipping) {
648  //Make provided address as default shipping address
649  $billingAddress->setIsDefaultShipping(true);
650  }
651  $billingAddress->setIsDefaultBilling(true);
652  }
653  $quote->addCustomerAddress($billingAddress);
654  $billing->setCustomerAddressData($billingAddress);
655  }
656  }
$billingAddress
Definition: order.php:25
$customer
Definition: customers.php:11
$quote
$shippingAddress
Definition: order.php:40

◆ _prepareGuestQuote()

_prepareGuestQuote ( )
protected

Prepare quote for guest checkout order submit

Returns
$this

Definition at line 561 of file Onepage.php.

562  {
563  $quote = $this->getQuote();
564  $quote->setCustomerId(null)
565  ->setCustomerEmail($quote->getBillingAddress()->getEmail())
566  ->setCustomerIsGuest(true)
567  ->setCustomerGroupId(GroupInterface::NOT_LOGGED_IN_ID);
568  return $this;
569  }
$quote

◆ _prepareNewCustomerQuote()

_prepareNewCustomerQuote ( )
protected

Prepare quote for customer registration and customer order submit

Returns
void

Definition at line 576 of file Onepage.php.

577  {
578  $quote = $this->getQuote();
579  $billing = $quote->getBillingAddress();
580  $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
581 
582  $customer = $quote->getCustomer();
583  $customerBillingData = $billing->exportCustomerAddress();
584  $dataArray = $this->_objectCopyService->getDataFromFieldset('checkout_onepage_quote', 'to_customer', $quote);
585  $this->dataObjectHelper->populateWithArray(
586  $customer,
587  $dataArray,
588  \Magento\Customer\Api\Data\CustomerInterface::class
589  );
590  $quote->setCustomer($customer)->setCustomerId(true);
591 
592  $customerBillingData->setIsDefaultBilling(true);
593 
594  if ($shipping) {
595  if (!$shipping->getSameAsBilling()) {
596  $customerShippingData = $shipping->exportCustomerAddress();
597  $customerShippingData->setIsDefaultShipping(true);
598  $shipping->setCustomerAddressData($customerShippingData);
599  // Add shipping address to quote since customer Data Object does not hold address information
600  $quote->addCustomerAddress($customerShippingData);
601  } else {
602  $shipping->setCustomerAddressData($customerBillingData);
603  $customerBillingData->setIsDefaultShipping(true);
604  }
605  } else {
606  $customerBillingData->setIsDefaultShipping(true);
607  }
608  $billing->setCustomerAddressData($customerBillingData);
609  // TODO : Eventually need to remove this legacy hack
610  // Add billing address to quote since customer Data Object does not hold address information
611  $quote->addCustomerAddress($customerBillingData);
612  }
$customer
Definition: customers.php:11
$quote

◆ getCheckout()

getCheckout ( )

Get frontend checkout session object

Returns
\Magento\Checkout\Model\Session @codeCoverageIgnore

Definition at line 267 of file Onepage.php.

268  {
270  }

◆ getCheckoutMethod()

getCheckoutMethod ( )

Get quote checkout method

Returns
string

Definition at line 349 of file Onepage.php.

350  {
351  if ($this->getCustomerSession()->isLoggedIn()) {
352  return self::METHOD_CUSTOMER;
353  }
354  if (!$this->getQuote()->getCheckoutMethod()) {
355  if ($this->_helper->isAllowedGuestCheckout($this->getQuote())) {
356  $this->getQuote()->setCheckoutMethod(self::METHOD_GUEST);
357  } else {
358  $this->getQuote()->setCheckoutMethod(self::METHOD_REGISTER);
359  }
360  }
361  return $this->getQuote()->getCheckoutMethod();
362  }

◆ getCustomerSession()

getCustomerSession ( )

Get customer session object

Returns
\Magento\Customer\Model\Session @codeCoverageIgnore

Definition at line 304 of file Onepage.php.

305  {
307  }

◆ getLastOrderId()

getLastOrderId ( )

Get last order increment id by order id

Returns
string

Definition at line 774 of file Onepage.php.

775  {
776  $lastId = $this->getCheckout()->getLastOrderId();
777  $orderId = false;
778  if ($lastId) {
779  $order = $this->_orderFactory->create();
780  $order->load($lastId);
781  $orderId = $order->getIncrementId();
782  }
783  return $orderId;
784  }
$order
Definition: order.php:55

◆ getQuote()

getQuote ( )

Quote object getter

Returns
\Magento\Quote\Model\Quote

Definition at line 277 of file Onepage.php.

278  {
279  if ($this->_quote === null) {
280  return $this->_checkoutSession->getQuote();
281  }
282  return $this->_quote;
283  }

◆ initCheckout()

initCheckout ( )

Initialize quote state to be valid for one page checkout

Returns
$this @SuppressWarnings(PHPMD.UnusedLocalVariable)

Definition at line 315 of file Onepage.php.

316  {
317  $checkout = $this->getCheckout();
318  $customerSession = $this->getCustomerSession();
319  if (is_array($checkout->getStepData())) {
320  foreach ($checkout->getStepData() as $step => $data) {
321  if (!($step === 'login' || $customerSession->isLoggedIn() && $step === 'billing')) {
322  $checkout->setStepData($step, 'allow', false);
323  }
324  }
325  }
326 
327  $quote = $this->getQuote();
328  if ($quote->isMultipleShippingAddresses()) {
329  $quote->removeAllAddresses();
330  $this->quoteRepository->save($quote);
331  }
332 
333  /*
334  * want to load the correct customer information by assigning to address
335  * instead of just loading from sales/quote_address
336  */
337  $customer = $customerSession->getCustomerDataObject();
338  if ($customer) {
339  $quote->assignCustomer($customer);
340  }
341  return $this;
342  }
$customer
Definition: customers.php:11
$quote

◆ isCheckoutMethodRegister()

isCheckoutMethodRegister ( )
protected

Check whether checkout method is "register"

Returns
bool

Definition at line 386 of file Onepage.php.

387  {
388  return $this->getQuote()->getCheckoutMethod() == self::METHOD_REGISTER;
389  }

◆ saveCheckoutMethod()

saveCheckoutMethod (   $method)

Specify checkout method

Parameters
string$method
Returns
array

Definition at line 370 of file Onepage.php.

371  {
372  if (empty($method)) {
373  return ['error' => -1, 'message' => __('Invalid data')];
374  }
375 
376  $this->quoteRepository->save($this->getQuote()->setCheckoutMethod($method));
377  $this->getCheckout()->setStepData('billing', 'allow', true);
378  return [];
379  }
__()
Definition: __.php:13
$method
Definition: info.phtml:13

◆ saveOrder()

saveOrder ( )

Create order based on checkout type. Create customer if necessary.

Returns
$this

a flag to set that there will be redirect to third party after confirmation

we only want to send to customer about new order when there is no redirect to third party

Definition at line 688 of file Onepage.php.

689  {
690  $this->validate();
691  $isNewCustomer = false;
692  switch ($this->getCheckoutMethod()) {
693  case self::METHOD_GUEST:
694  $this->_prepareGuestQuote();
695  break;
697  $this->_prepareNewCustomerQuote();
698  $isNewCustomer = true;
699  break;
700  default:
701  $this->_prepareCustomerQuote();
702  break;
703  }
704  $order = $this->quoteManagement->submit($this->getQuote());
705  if ($isNewCustomer) {
706  try {
707  $this->_involveNewCustomer();
708  } catch (\Exception $e) {
709  $this->_logger->critical($e);
710  }
711  }
712  $this->_checkoutSession
713  ->setLastQuoteId($this->getQuote()->getId())
714  ->setLastSuccessQuoteId($this->getQuote()->getId())
715  ->clearHelperData();
716 
717  if ($order) {
718  $this->_eventManager->dispatch(
719  'checkout_type_onepage_save_order_after',
720  ['order' => $order, 'quote' => $this->getQuote()]
721  );
722 
726  $redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl();
730  if (!$redirectUrl && $order->getCanSendNewEmailFlag()) {
731  try {
732  $this->orderSender->send($order);
733  } catch (\Exception $e) {
734  $this->_logger->critical($e);
735  }
736  }
737 
738  // add order information to the session
739  $this->_checkoutSession
740  ->setLastOrderId($order->getId())
741  ->setRedirectUrl($redirectUrl)
742  ->setLastRealOrderId($order->getIncrementId())
743  ->setLastOrderStatus($order->getStatus());
744  }
745 
746  $this->_eventManager->dispatch(
747  'checkout_submit_all_after',
748  [
749  'order' => $order,
750  'quote' => $this->getQuote()
751  ]
752  );
753  return $this;
754  }
$order
Definition: order.php:55

◆ savePayment()

savePayment (   $data)

Specify quote payment method

Parameters
array$data
Returns
array

Definition at line 505 of file Onepage.php.

506  {
507  if (empty($data)) {
508  return ['error' => -1, 'message' => __('Invalid data')];
509  }
510  $quote = $this->getQuote();
511 
512  // shipping totals may be affected by payment method
513  if (!$quote->isVirtual() && $quote->getShippingAddress()) {
514  $quote->getShippingAddress()->setCollectShippingRates(true);
515  }
516 
517  $data['checks'] = [
523  ];
524 
525  $payment = $quote->getPayment();
526  $payment->importData($data);
527 
528  $this->quoteRepository->save($quote);
529 
530  $this->getCheckout()->setStepData('payment', 'complete', true)->setStepData('review', 'allow', true);
531 
532  return [];
533  }
$quote
__()
Definition: __.php:13
$payment
Definition: order.php:17

◆ saveShipping()

saveShipping (   $data,
  $customerAddressId 
)

Save checkout shipping address

Parameters
array$data
int$customerAddressId
Returns
array @SuppressWarnings(PHPMD.CyclomaticComplexity) @SuppressWarnings(PHPMD.NPathComplexity)

Definition at line 400 of file Onepage.php.

401  {
402  if (empty($data)) {
403  return ['error' => -1, 'message' => __('Invalid data')];
404  }
405  $address = $this->getQuote()->getShippingAddress();
406 
407  $addressForm = $this->_formFactory->create(
408  \customer_address::class,
409  'customer_address_edit',
410  [],
411  $this->_request->isAjax(),
413  []
414  );
415 
416  if (!empty($customerAddressId)) {
417  $addressData = null;
418  try {
419  $addressData = $this->addressRepository->getById($customerAddressId);
420  } catch (NoSuchEntityException $e) {
421  // do nothing if customer is not found by id
422  }
423 
424  if ($addressData->getCustomerId() != $this->getQuote()->getCustomerId()) {
425  return ['error' => 1, 'message' => __('The customer address is not valid.')];
426  }
427 
428  $address->importCustomerAddressData($addressData)->setSaveInAddressBook(0);
429  $addressErrors = $addressForm->validateData($address->getData());
430  if ($addressErrors !== true) {
431  return ['error' => 1, 'message' => $addressErrors];
432  }
433  } else {
434  // emulate request object
435  $addressData = $addressForm->extractData($addressForm->prepareRequest($data));
436  $addressErrors = $addressForm->validateData($addressData);
437  if ($addressErrors !== true) {
438  return ['error' => 1, 'message' => $addressErrors];
439  }
440  $compactedData = $addressForm->compactData($addressData);
441  // unset shipping address attributes which were not shown in form
442  foreach ($addressForm->getAttributes() as $attribute) {
443  $attributeCode = $attribute->getAttributeCode();
444  if (!isset($data[$attributeCode])) {
445  $address->setData($attributeCode, null);
446  } else {
447  if (isset($compactedData[$attributeCode])) {
448  $address->setDataUsingMethod($attributeCode, $compactedData[$attributeCode]);
449  }
450  }
451  }
452 
453  $address->setCustomerAddressId(null);
454  // Additional form data, not fetched by extractData (as it fetches only attributes)
455  $address->setSaveInAddressBook(empty($data['save_in_address_book']) ? 0 : 1);
456  $address->setSameAsBilling(empty($data['same_as_billing']) ? 0 : 1);
457  }
458 
459  $address->setCollectShippingRates(true);
460 
461  if (($validateRes = $address->validate()) !== true) {
462  return ['error' => 1, 'message' => $validateRes];
463  }
464 
465  $this->totalsCollector->collectAddressTotals($this->getQuote(), $address);
466  $address->save();
467 
468  $this->getCheckout()->setStepData('shipping', 'complete', true)->setStepData('shipping_method', 'allow', true);
469 
470  return [];
471  }
__()
Definition: __.php:13
$address
Definition: customer.php:38
$addressData
Definition: order.php:19
$attributeCode
Definition: extend.phtml:12

◆ saveShippingMethod()

saveShippingMethod (   $shippingMethod)

Specify quote shipping method

Parameters
string$shippingMethod
Returns
array

Definition at line 479 of file Onepage.php.

480  {
481  if (empty($shippingMethod)) {
482  return ['error' => -1, 'message' => __('Invalid shipping method')];
483  }
484  $shippingAddress = $this->getQuote()->getShippingAddress();
485  $rate = $shippingAddress->getShippingRateByCode($shippingMethod);
486  if (!$rate) {
487  return ['error' => -1, 'message' => __('Invalid shipping method')];
488  } else {
489  $shippingDescription = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle();
490  $shippingAddress->setShippingDescription(trim($shippingDescription, ' -'));
491  }
492  $shippingAddress->setShippingMethod($shippingMethod)->save();
493 
494  $this->getCheckout()->setStepData('shipping_method', 'complete', true)->setStepData('payment', 'allow', true);
495 
496  return [];
497  }
$shippingAddress
Definition: order.php:40
__()
Definition: __.php:13
$shippingMethod
Definition: popup.phtml:12

◆ setQuote()

setQuote ( \Magento\Quote\Model\Quote  $quote)

Declare checkout quote instance

Parameters
\Magento\Quote\Model\Quote$quote
Returns
$this @codeCoverageIgnore

Definition at line 292 of file Onepage.php.

293  {
294  $this->_quote = $quote;
295  return $this;
296  }
$quote

◆ validate()

validate ( )
protected

Validate quote state to be integrated with one page checkout process

Returns
void
Exceptions

Definition at line 541 of file Onepage.php.

542  {
543  $quote = $this->getQuote();
544 
545  if ($quote->isMultipleShippingAddresses()) {
546  throw new \Magento\Framework\Exception\LocalizedException(
547  __('There are more than one shipping addresses.')
548  );
549  }
550 
551  if ($quote->getCheckoutMethod() == self::METHOD_GUEST && !$this->_helper->isAllowedGuestCheckout($quote)) {
552  throw new \Magento\Framework\Exception\LocalizedException(__('Sorry, guest checkout is not available.'));
553  }
554  }
$quote
__()
Definition: __.php:13

Field Documentation

◆ $_checkoutSession

$_checkoutSession
protected

Definition at line 41 of file Onepage.php.

◆ $_customerFactory

$_customerFactory
protected

Definition at line 95 of file Onepage.php.

◆ $_customerFormFactory

$_customerFormFactory
protected

Definition at line 90 of file Onepage.php.

◆ $_customerSession

$_customerSession
protected

Definition at line 36 of file Onepage.php.

◆ $_customerUrl

$_customerUrl
protected

Definition at line 63 of file Onepage.php.

◆ $_customrAddrFactory

$_customrAddrFactory
protected

Definition at line 85 of file Onepage.php.

◆ $_eventManager

$_eventManager = null
protected

Definition at line 70 of file Onepage.php.

◆ $_formFactory

$_formFactory
protected

Definition at line 115 of file Onepage.php.

◆ $_helper

$_helper
protected

Definition at line 51 of file Onepage.php.

◆ $_logger

$_logger
protected

Definition at line 56 of file Onepage.php.

◆ $_objectCopyService

$_objectCopyService
protected

Definition at line 105 of file Onepage.php.

◆ $_orderFactory

$_orderFactory
protected

Definition at line 100 of file Onepage.php.

◆ $_quote

$_quote = null
protected

Definition at line 46 of file Onepage.php.

◆ $_request

$_request
protected

Definition at line 80 of file Onepage.php.

◆ $_storeManager

$_storeManager
protected

Definition at line 75 of file Onepage.php.

◆ $accountManagement

$accountManagement
protected

Definition at line 135 of file Onepage.php.

◆ $addressRepository

$addressRepository
protected

Definition at line 130 of file Onepage.php.

◆ $customerDataFactory

$customerDataFactory
protected

Definition at line 120 of file Onepage.php.

◆ $customerRepository

$customerRepository
protected

Definition at line 150 of file Onepage.php.

◆ $dataObjectHelper

$dataObjectHelper
protected

Definition at line 165 of file Onepage.php.

◆ $extensibleDataObjectConverter

$extensibleDataObjectConverter
protected

Definition at line 155 of file Onepage.php.

◆ $mathRandom

$mathRandom
protected

Definition at line 125 of file Onepage.php.

◆ $messageManager

$messageManager
protected

Definition at line 110 of file Onepage.php.

◆ $orderSender

$orderSender
protected

Definition at line 140 of file Onepage.php.

◆ $quoteManagement

$quoteManagement
protected

Definition at line 160 of file Onepage.php.

◆ $quoteRepository

$quoteRepository
protected

Definition at line 145 of file Onepage.php.

◆ $totalsCollector

$totalsCollector
protected

Definition at line 170 of file Onepage.php.

◆ METHOD_CUSTOMER

const METHOD_CUSTOMER = 'customer'

Definition at line 29 of file Onepage.php.

◆ METHOD_GUEST

const METHOD_GUEST = 'guest'

Checkout types: Checkout as Guest, Register, Logged In Customer

Definition at line 27 of file Onepage.php.

◆ METHOD_REGISTER

const METHOD_REGISTER = 'register'

Definition at line 28 of file Onepage.php.

◆ NOT_USE_FOR_SHIPPING

const NOT_USE_FOR_SHIPPING = 0

Definition at line 31 of file Onepage.php.

◆ USE_FOR_SHIPPING

const USE_FOR_SHIPPING = 1

Definition at line 30 of file Onepage.php.


The documentation for this class was generated from the following file: