Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractOrder.php
Go to the documentation of this file.
1 <?php
7 
9 
18 {
24  protected $_coreRegistry = null;
25 
31  protected $_adminHelper;
32 
39  public function __construct(
40  \Magento\Backend\Block\Template\Context $context,
41  \Magento\Framework\Registry $registry,
42  \Magento\Sales\Helper\Admin $adminHelper,
43  array $data = []
44  ) {
45  $this->_adminHelper = $adminHelper;
46  $this->_coreRegistry = $registry;
47  parent::__construct($context, $data);
48  }
49 
56  public function getOrder()
57  {
58  if ($this->hasOrder()) {
59  return $this->getData('order');
60  }
61  if ($this->_coreRegistry->registry('current_order')) {
62  return $this->_coreRegistry->registry('current_order');
63  }
64  if ($this->_coreRegistry->registry('order')) {
65  return $this->_coreRegistry->registry('order');
66  }
67  throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t get the order instance right now.'));
68  }
69 
75  public function getPriceDataObject()
76  {
77  $obj = $this->getData('price_data_object');
78  if ($obj === null) {
79  return $this->getOrder();
80  }
81  return $obj;
82  }
83 
92  public function displayPriceAttribute($code, $strong = false, $separator = '<br/>')
93  {
94  return $this->_adminHelper->displayPriceAttribute($this->getPriceDataObject(), $code, $strong, $separator);
95  }
96 
106  public function displayPrices($basePrice, $price, $strong = false, $separator = '<br/>')
107  {
108  return $this->_adminHelper->displayPrices(
109  $this->getPriceDataObject(),
110  $basePrice,
111  $price,
112  $strong,
113  $separator
114  );
115  }
116 
122  public function getOrderTotalData()
123  {
124  return [];
125  }
126 
132  public function getOrderInfoData()
133  {
134  return [];
135  }
136 
144  {
145  $shipping = $order->getShippingInclTax();
146  if ($shipping) {
147  $baseShipping = $order->getBaseShippingInclTax();
148  } else {
149  $shipping = $order->getShippingAmount() + $order->getShippingTaxAmount();
150  $baseShipping = $order->getBaseShippingAmount() + $order->getBaseShippingTaxAmount();
151  }
152  return $this->displayPrices($baseShipping, $shipping, false, ' ');
153  }
154 }
getData($key='', $index=null)
Definition: DataObject.php:119
$order
Definition: order.php:55
__()
Definition: __.php:13
$price
displayPriceAttribute($code, $strong=false, $separator='< br/>')
displayPrices($basePrice, $price, $strong=false, $separator='< br/>')
$code
Definition: info.phtml:12
__construct(\Magento\Backend\Block\Template\Context $context, \Magento\Framework\Registry $registry, \Magento\Sales\Helper\Admin $adminHelper, array $data=[])