_adminHelper = $adminHelper; parent::__construct($context, $registry, $data); } /** * Format total value based on order currency * * @param \Magento\Framework\DataObject $total * @return string */ public function formatValue($total) { if (!$total->getIsFormated()) { return $this->_adminHelper->displayPrices($this->getOrder(), $total->getBaseValue(), $total->getValue()); } return $total->getValue(); } /** * Initialize order totals array * * @return $this */ protected function _initTotals() { $this->_totals = []; $this->_totals['subtotal'] = new \Magento\Framework\DataObject( [ 'code' => 'subtotal', 'value' => $this->getSource()->getSubtotal(), 'base_value' => $this->getSource()->getBaseSubtotal(), 'label' => __('Subtotal'), ] ); /** * Add shipping */ if (!$this->getSource()->getIsVirtual() && ((double)$this->getSource()->getShippingAmount() || $this->getSource()->getShippingDescription()) ) { $this->_totals['shipping'] = new \Magento\Framework\DataObject( [ 'code' => 'shipping', 'value' => $this->getSource()->getShippingAmount(), 'base_value' => $this->getSource()->getBaseShippingAmount(), 'label' => __('Shipping & Handling'), ] ); } /** * Add discount */ if ((double)$this->getSource()->getDiscountAmount() != 0) { if ($this->getSource()->getDiscountDescription()) { $discountLabel = __('Discount (%1)', $this->getSource()->getDiscountDescription()); } else { $discountLabel = __('Discount'); } $this->_totals['discount'] = new \Magento\Framework\DataObject( [ 'code' => 'discount', 'value' => $this->getSource()->getDiscountAmount(), 'base_value' => $this->getSource()->getBaseDiscountAmount(), 'label' => $discountLabel, ] ); } $this->_totals['grand_total'] = new \Magento\Framework\DataObject( [ 'code' => 'grand_total', 'strong' => true, 'value' => $this->getSource()->getGrandTotal(), 'base_value' => $this->getSource()->getBaseGrandTotal(), 'label' => __('Grand Total'), 'area' => 'footer', ] ); return $this; } }