123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Sales\Block\Adminhtml\Order;
- use Magento\Sales\Model\Order;
- /**
- * Adminhtml order abstract block
- *
- * @api
- * @author Magento Core Team <core@magentocommerce.com>
- * @since 100.0.2
- */
- class AbstractOrder extends \Magento\Backend\Block\Widget
- {
- /**
- * Core registry
- *
- * @var \Magento\Framework\Registry
- */
- protected $_coreRegistry = null;
- /**
- * Admin helper
- *
- * @var \Magento\Sales\Helper\Admin
- */
- protected $_adminHelper;
- /**
- * @param \Magento\Backend\Block\Template\Context $context
- * @param \Magento\Framework\Registry $registry
- * @param \Magento\Sales\Helper\Admin $adminHelper
- * @param array $data
- */
- public function __construct(
- \Magento\Backend\Block\Template\Context $context,
- \Magento\Framework\Registry $registry,
- \Magento\Sales\Helper\Admin $adminHelper,
- array $data = []
- ) {
- $this->_adminHelper = $adminHelper;
- $this->_coreRegistry = $registry;
- parent::__construct($context, $data);
- }
- /**
- * Retrieve available order
- *
- * @return Order
- * @throws \Magento\Framework\Exception\LocalizedException
- */
- public function getOrder()
- {
- if ($this->hasOrder()) {
- return $this->getData('order');
- }
- if ($this->_coreRegistry->registry('current_order')) {
- return $this->_coreRegistry->registry('current_order');
- }
- if ($this->_coreRegistry->registry('order')) {
- return $this->_coreRegistry->registry('order');
- }
- throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t get the order instance right now.'));
- }
- /**
- * Get price data object
- *
- * @return Order|mixed
- */
- public function getPriceDataObject()
- {
- $obj = $this->getData('price_data_object');
- if ($obj === null) {
- return $this->getOrder();
- }
- return $obj;
- }
- /**
- * Display price attribute
- *
- * @param string $code
- * @param bool $strong
- * @param string $separator
- * @return string
- */
- public function displayPriceAttribute($code, $strong = false, $separator = '<br/>')
- {
- return $this->_adminHelper->displayPriceAttribute($this->getPriceDataObject(), $code, $strong, $separator);
- }
- /**
- * Display prices
- *
- * @param float $basePrice
- * @param float $price
- * @param bool $strong
- * @param string $separator
- * @return string
- */
- public function displayPrices($basePrice, $price, $strong = false, $separator = '<br/>')
- {
- return $this->_adminHelper->displayPrices(
- $this->getPriceDataObject(),
- $basePrice,
- $price,
- $strong,
- $separator
- );
- }
- /**
- * Retrieve order totals block settings
- *
- * @return array
- */
- public function getOrderTotalData()
- {
- return [];
- }
- /**
- * Retrieve order info block settings
- *
- * @return array
- */
- public function getOrderInfoData()
- {
- return [];
- }
- /**
- * Retrieve subtotal price include tax html formatted content
- *
- * @param \Magento\Framework\DataObject $order
- * @return string
- */
- public function displayShippingPriceInclTax($order)
- {
- $shipping = $order->getShippingInclTax();
- if ($shipping) {
- $baseShipping = $order->getBaseShippingInclTax();
- } else {
- $shipping = $order->getShippingAmount() + $order->getShippingTaxAmount();
- $baseShipping = $order->getBaseShippingAmount() + $order->getBaseShippingTaxAmount();
- }
- return $this->displayPrices($baseShipping, $shipping, false, ' ');
- }
- }
|