Item.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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\Totals;
  7. /**
  8. * Totals item block
  9. *
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Item extends \Magento\Sales\Block\Adminhtml\Order\Totals
  14. {
  15. /**
  16. * Determine display parameters before rendering HTML
  17. *
  18. * @return $this
  19. */
  20. protected function _beforeToHtml()
  21. {
  22. parent::_beforeToHtml();
  23. $this->setCanDisplayTotalPaid($this->getParentBlock()->getCanDisplayTotalPaid());
  24. $this->setCanDisplayTotalRefunded($this->getParentBlock()->getCanDisplayTotalRefunded());
  25. $this->setCanDisplayTotalDue($this->getParentBlock()->getCanDisplayTotalDue());
  26. return $this;
  27. }
  28. /**
  29. * Initialize totals object
  30. *
  31. * @return $this
  32. */
  33. public function initTotals()
  34. {
  35. $total = new \Magento\Framework\DataObject(
  36. [
  37. 'code' => $this->getNameInLayout(),
  38. 'block_name' => $this->getNameInLayout(),
  39. 'area' => $this->getDisplayArea(),
  40. 'strong' => $this->getStrong(),
  41. ]
  42. );
  43. if ($this->getBeforeCondition()) {
  44. $this->getParentBlock()->addTotalBefore($total, $this->getBeforeCondition());
  45. } else {
  46. $this->getParentBlock()->addTotal($total, $this->getAfterCondition());
  47. }
  48. return $this;
  49. }
  50. /**
  51. * Price HTML getter
  52. *
  53. * @param float $baseAmount
  54. * @param float $amount
  55. * @return string
  56. */
  57. public function displayPrices($baseAmount, $amount)
  58. {
  59. return $this->_adminHelper->displayPrices($this->getOrder(), $baseAmount, $amount);
  60. }
  61. /**
  62. * Price attribute HTML getter
  63. *
  64. * @param string $code
  65. * @param bool $strong
  66. * @param string $separator
  67. * @return string
  68. */
  69. public function displayPriceAttribute($code, $strong = false, $separator = '<br/>')
  70. {
  71. return $this->_adminHelper->displayPriceAttribute($this->getSource(), $code, $strong, $separator);
  72. }
  73. /**
  74. * Source order getter
  75. *
  76. * @return \Magento\Sales\Model\Order
  77. */
  78. public function getSource()
  79. {
  80. return $this->getParentBlock()->getSource();
  81. }
  82. }