AddressesPost.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Multishipping\Controller\Checkout;
  8. use Magento\Multishipping\Model\Checkout\Type\Multishipping\State;
  9. class AddressesPost extends \Magento\Multishipping\Controller\Checkout
  10. {
  11. /**
  12. * Multishipping checkout process posted addresses
  13. *
  14. * @return void
  15. */
  16. public function execute()
  17. {
  18. if (!$this->_getCheckout()->getCustomerDefaultShippingAddress()) {
  19. $this->_redirect('*/checkout_address/newShipping');
  20. return;
  21. }
  22. try {
  23. if ($this->getRequest()->getParam('continue', false)) {
  24. $this->_getCheckout()->setCollectRatesFlag(true);
  25. $this->_getState()->setActiveStep(State::STEP_SHIPPING);
  26. $this->_getState()->setCompleteStep(State::STEP_SELECT_ADDRESSES);
  27. $this->_redirect('*/*/shipping');
  28. } elseif ($this->getRequest()->getParam('new_address')) {
  29. $this->_redirect('*/checkout_address/newShipping');
  30. } else {
  31. $this->_redirect('*/*/addresses');
  32. }
  33. if ($shipToInfo = $this->getRequest()->getPost('ship')) {
  34. $this->_getCheckout()->setShippingItemsInformation($shipToInfo);
  35. }
  36. } catch (\Magento\Framework\Exception\LocalizedException $e) {
  37. $this->messageManager->addError($e->getMessage());
  38. $this->_redirect('*/*/addresses');
  39. } catch (\Exception $e) {
  40. $this->messageManager->addException($e, __('Data saving problem'));
  41. $this->_redirect('*/*/addresses');
  42. }
  43. }
  44. }