Address.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Block\Adminhtml\Order\Create\Shipping;
  7. /**
  8. * Adminhtml sales order create shipping address block
  9. *
  10. * @api
  11. * @author Magento Core Team <core@magentocommerce.com>
  12. * @SuppressWarnings(PHPMD.DepthOfInheritance)
  13. * @since 100.0.2
  14. */
  15. class Address extends \Magento\Sales\Block\Adminhtml\Order\Create\Form\Address
  16. {
  17. /**
  18. * Return header text
  19. *
  20. * @return \Magento\Framework\Phrase
  21. */
  22. public function getHeaderText()
  23. {
  24. return __('Shipping Address');
  25. }
  26. /**
  27. * Return Header CSS Class
  28. *
  29. * @return string
  30. */
  31. public function getHeaderCssClass()
  32. {
  33. return 'head-shipping-address';
  34. }
  35. /**
  36. * Prepare Form and add elements to form
  37. *
  38. * @return $this
  39. */
  40. protected function _prepareForm()
  41. {
  42. $this->setJsVariablePrefix('shippingAddress');
  43. parent::_prepareForm();
  44. $this->_form->addFieldNameSuffix('order[shipping_address]');
  45. $this->_form->setHtmlNamePrefix('order[shipping_address]');
  46. $this->_form->setHtmlIdPrefix('order-shipping_address_');
  47. return $this;
  48. }
  49. /**
  50. * Return is shipping address flag
  51. *
  52. * @return true
  53. */
  54. public function getIsShipping()
  55. {
  56. return true;
  57. }
  58. /**
  59. * Same as billing address flag
  60. *
  61. * @return bool
  62. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  63. */
  64. public function getIsAsBilling()
  65. {
  66. return $this->getCreateOrderModel()->getShippingAddress()->getSameAsBilling();
  67. }
  68. /**
  69. * Saving shipping address must be turned off, when it is the same as billing
  70. *
  71. * @return bool
  72. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  73. */
  74. public function getDontSaveInAddressBook()
  75. {
  76. return $this->getIsAsBilling();
  77. }
  78. /**
  79. * Return Form Elements values
  80. *
  81. * @return array
  82. */
  83. public function getFormValues()
  84. {
  85. return $this->getAddress()->getData();
  86. }
  87. /**
  88. * Return customer address id
  89. *
  90. * @return int|bool
  91. */
  92. public function getAddressId()
  93. {
  94. return $this->getAddress()->getCustomerAddressId();
  95. }
  96. /**
  97. * Return address object
  98. *
  99. * @return \Magento\Quote\Model\Quote\Address
  100. */
  101. public function getAddress()
  102. {
  103. if ($this->getIsAsBilling()) {
  104. $address = $this->getCreateOrderModel()->getBillingAddress();
  105. } else {
  106. $address = $this->getCreateOrderModel()->getShippingAddress();
  107. }
  108. return $address;
  109. }
  110. /**
  111. * Return is address disabled flag
  112. * Return true is the quote is virtual
  113. *
  114. * @return bool
  115. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  116. */
  117. public function getIsDisabled()
  118. {
  119. return $this->getQuote()->isVirtual();
  120. }
  121. }