Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Shipping.php
Go to the documentation of this file.
1 <?php
7 
8 class Shipping extends \Magento\Sales\Model\Order\Pdf\Total\DefaultTotal
9 {
13  protected $_taxConfig;
14 
22  public function __construct(
23  \Magento\Tax\Helper\Data $taxHelper,
24  \Magento\Tax\Model\Calculation $taxCalculation,
25  \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory $ordersFactory,
26  \Magento\Tax\Model\Config $taxConfig,
27  array $data = []
28  ) {
29  $this->_taxConfig = $taxConfig;
30  parent::__construct($taxHelper, $taxCalculation, $ordersFactory, $data);
31  }
32 
44  public function getTotalsForDisplay()
45  {
46  $store = $this->getOrder()->getStore();
47  $amount = $this->getOrder()->formatPriceTxt($this->getAmount());
48  $amountInclTax = $this->getSource()->getShippingInclTax();
49  if (!$amountInclTax) {
50  $amountInclTax = $this->getAmount() + $this->getSource()->getShippingTaxAmount();
51  }
52  $amountInclTax = $this->getOrder()->formatPriceTxt($amountInclTax);
53  $fontSize = $this->getFontSize() ? $this->getFontSize() : 7;
54 
55  if ($this->_taxConfig->displaySalesShippingBoth($store)) {
56  $totals = [
57  [
58  'amount' => $this->getAmountPrefix() . $amount,
59  'label' => __('Shipping (Excl. Tax)') . ':',
60  'font_size' => $fontSize,
61  ],
62  [
63  'amount' => $this->getAmountPrefix() . $amountInclTax,
64  'label' => __('Shipping (Incl. Tax)') . ':',
65  'font_size' => $fontSize
66  ],
67  ];
68  } elseif ($this->_taxConfig->displaySalesShippingInclTax($store)) {
69  $totals = [
70  [
71  'amount' => $this->getAmountPrefix() . $amountInclTax,
72  'label' => __($this->getTitle()) . ':',
73  'font_size' => $fontSize,
74  ],
75  ];
76  } else {
77  $totals = [
78  [
79  'amount' => $this->getAmountPrefix() . $amount,
80  'label' => __($this->getTitle()) . ':',
81  'font_size' => $fontSize,
82  ],
83  ];
84  }
85 
86  return $totals;
87  }
88 }
__construct(\Magento\Tax\Helper\Data $taxHelper, \Magento\Tax\Model\Calculation $taxCalculation, \Magento\Tax\Model\ResourceModel\Sales\Order\Tax\CollectionFactory $ordersFactory, \Magento\Tax\Model\Config $taxConfig, array $data=[])
Definition: Shipping.php:22
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
__()
Definition: __.php:13
$amount
Definition: order.php:14
$totals
Definition: totalbar.phtml:10