Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Grand.php
Go to the documentation of this file.
1 <?php
7 
8 class Grand extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
9 {
19  public function collect(
20  \Magento\Quote\Model\Quote $quote,
21  \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment,
23  ) {
24  $grandTotal = $total->getGrandTotal();
25  $baseGrandTotal = $total->getBaseGrandTotal();
26  $totals = array_sum($total->getAllTotalAmounts());
27  $baseTotals = array_sum($total->getAllBaseTotalAmounts());
28 
29  $total->setGrandTotal($grandTotal + $totals);
30  $total->setBaseGrandTotal($baseGrandTotal + $baseTotals);
31  return $this;
32  }
33 
42  public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
43  {
44  return [
45  'code' => $this->getCode(),
46  'title' => __('Grand Total'),
47  'value' => $total->getGrandTotal(),
48  'area' => 'footer',
49  ];
50  }
51 }
$quote
__()
Definition: __.php:13
$totals
Definition: totalbar.phtml:10
fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
Definition: Grand.php:42
collect(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment, \Magento\Quote\Model\Quote\Address\Total $total)
Definition: Grand.php:19