Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Overview.php
Go to the documentation of this file.
1 <?php
7 
10 
19 {
23  const DEFAULT_TYPE = 'default';
24 
28  protected $_multishipping;
29 
33  protected $_taxHelper;
34 
38  protected $priceCurrency;
39 
43  protected $totalsCollector;
44 
48  protected $totalsReader;
49 
59  public function __construct(
60  \Magento\Framework\View\Element\Template\Context $context,
61  \Magento\Multishipping\Model\Checkout\Type\Multishipping $multishipping,
62  \Magento\Tax\Helper\Data $taxHelper,
66  array $data = []
67  ) {
68  $this->_taxHelper = $taxHelper;
69  $this->_multishipping = $multishipping;
70  $this->priceCurrency = $priceCurrency;
71  parent::__construct($context, $data);
72  $this->_isScopePrivate = true;
73  $this->totalsCollector = $totalsCollector;
74  $this->totalsReader = $totalsReader;
75  }
76 
82  protected function _prepareLayout()
83  {
84  $this->pageConfig->getTitle()->set(
85  __('Review Order - %1', $this->pageConfig->getTitle()->getDefault())
86  );
87  return parent::_prepareLayout();
88  }
89 
95  public function getCheckout()
96  {
97  return $this->_multishipping;
98  }
99 
103  public function getBillingAddress()
104  {
105  return $this->getCheckout()->getQuote()->getBillingAddress();
106  }
107 
111  public function getPaymentHtml()
112  {
113  return $this->getChildHtml('payment_info');
114  }
115 
121  public function getPayment()
122  {
123  return $this->getCheckout()->getQuote()->getPayment();
124  }
125 
129  public function getShippingAddresses()
130  {
131  return $this->getCheckout()->getQuote()->getAllShippingAddresses();
132  }
133 
137  public function getShippingAddressCount()
138  {
139  $count = $this->getData('shipping_address_count');
140  if ($count === null) {
141  $count = count($this->getShippingAddresses());
142  $this->setData('shipping_address_count', $count);
143  }
144  return $count;
145  }
146 
153  {
154  $rate = $address->getShippingRateByCode($address->getShippingMethod());
155  if ($rate) {
156  return $rate;
157  }
158  return false;
159  }
160 
166  {
167  $exclTax = $address->getShippingAmount();
168  $taxAmount = $address->getShippingTaxAmount();
169  return $this->formatPrice($exclTax + $taxAmount);
170  }
171 
177  {
178  return $this->formatPrice($address->getShippingAmount());
179  }
180 
187  public function formatPrice($price)
188  {
189  return $this->priceCurrency->format(
190  $price,
191  true,
193  $this->getQuote()->getStore()
194  );
195  }
196 
201  public function getShippingAddressItems($address): array
202  {
203  return $address->getAllVisibleItems();
204  }
205 
211  {
212  $totals = $address->getTotals();
213  foreach ($totals as $total) {
214  if ($total->getCode() == 'grand_total') {
215  if ($address->getAddressType() == Address::TYPE_BILLING) {
216  $total->setTitle(__('Total'));
217  } else {
218  $total->setTitle(__('Total for this address'));
219  }
220  }
221  }
222  return $totals;
223  }
224 
228  public function getTotal()
229  {
230  return $this->getCheckout()->getQuote()->getGrandTotal();
231  }
232 
236  public function getAddressesEditUrl()
237  {
238  return $this->getUrl('*/*/backtoaddresses');
239  }
240 
246  {
247  return $this->getUrl('*/checkout_address/editShipping', ['id' => $address->getCustomerAddressId()]);
248  }
249 
255  {
256  return $this->getUrl('*/checkout_address/editBilling', ['id' => $address->getCustomerAddressId()]);
257  }
258 
262  public function getEditShippingUrl()
263  {
264  return $this->getUrl('*/*/backtoshipping');
265  }
266 
270  public function getPostActionUrl()
271  {
272  return $this->getUrl('*/*/overviewPost');
273  }
274 
278  public function getEditBillingUrl()
279  {
280  return $this->getUrl('*/*/backtobilling');
281  }
282 
286  public function getBackUrl()
287  {
288  return $this->getUrl('*/*/backtobilling');
289  }
290 
296  public function getVirtualProductEditUrl()
297  {
298  return $this->getUrl('checkout/cart');
299  }
300 
306  public function getVirtualItems()
307  {
308  return $this->getBillingAddress()->getAllVisibleItems();
309  }
310 
316  public function getQuote()
317  {
318  return $this->getCheckout()->getQuote();
319  }
320 
326  public function getBillinAddressTotals()
327  {
328  return $this->getBillingAddressTotals();
329  }
330 
335  public function getBillingAddressTotals()
336  {
337  $address = $this->getQuote()->getBillingAddress();
338  return $this->getShippingAddressTotals($address);
339  }
340 
346  public function renderTotals($totals, $colspan = null)
347  {
348  if ($colspan === null) {
349  $colspan = 3;
350  }
351  $totals = $this->getChildBlock(
352  'totals'
353  )->setTotals(
354  $totals
355  )->renderTotals(
356  '',
357  $colspan
358  ) . $this->getChildBlock(
359  'totals'
360  )->setTotals(
361  $totals
362  )->renderTotals(
363  'footer',
364  $colspan
365  );
366  return $totals;
367  }
368 
375  public function getRowItemHtml(\Magento\Framework\DataObject $item)
376  {
377  $type = $this->_getItemType($item);
378  $renderer = $this->_getRowItemRenderer($type)->setItem($item);
379  $this->_prepareItem($renderer);
380  return $renderer->toHtml();
381  }
382 
389  protected function _getRowItemRenderer($type)
390  {
391  $renderer = $this->getItemRenderer($type);
392  if ($renderer !== $this->getItemRenderer(self::DEFAULT_TYPE)) {
393  $renderer->setTemplate($this->getRowRendererTemplate());
394  }
395  return $renderer;
396  }
397 }
if( $_rate=$block->getShippingAddressRate( $address))( $_rate->getCarrierTitle()) ?>(<? $exclTax
Definition: overview.phtml:99
_prepareItem(\Magento\Framework\View\Element\AbstractBlock $renderer)
getRowItemHtml(\Magento\Framework\DataObject $item)
Definition: Overview.php:375
getData($key='', $index=null)
Definition: DataObject.php:119
$count
Definition: recent.phtml:13
__()
Definition: __.php:13
$price
$address
Definition: customer.php:38
$type
Definition: item.phtml:13
$totals
Definition: totalbar.phtml:10
_getItemType(\Magento\Framework\DataObject $item)
setData($key, $value=null)
Definition: DataObject.php:72
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Multishipping\Model\Checkout\Type\Multishipping $multishipping, \Magento\Tax\Helper\Data $taxHelper, PriceCurrencyInterface $priceCurrency, \Magento\Quote\Model\Quote\TotalsCollector $totalsCollector, \Magento\Quote\Model\Quote\TotalsReader $totalsReader, array $data=[])
Definition: Overview.php:59