1: | <?php
2: | namespace Opencart\Catalog\Model\Extension\Opencart\Total;
3: | /**
4: | * Class Shipping
5: | *
6: | * @package Opencart\Catalog\Model\Extension\Opencart\Total
7: | */
8: | class Shipping extends \Opencart\System\Engine\Model {
9: | /**
10: | * Get Total
11: | *
12: | * @param array<int, array<string, mixed>> $totals
13: | * @param array<int, float> $taxes
14: | * @param float $total
15: | *
16: | * @return void
17: | */
18: | public function getTotal(array &$totals, array &$taxes, float &$total): void {
19: | if ($this->cart->hasShipping() && isset($this->session->data['shipping_method'])) {
20: | $totals[] = [
21: | 'extension' => 'opencart',
22: | 'code' => 'shipping',
23: | 'title' => $this->session->data['shipping_method']['name'],
24: | 'value' => $this->session->data['shipping_method']['cost'],
25: | 'sort_order' => (int)$this->config->get('total_shipping_sort_order')
26: | ];
27: |
28: | if (isset($this->session->data['shipping_method']['tax_class_id'])) {
29: | $tax_rates = $this->tax->getRates($this->session->data['shipping_method']['cost'], $this->session->data['shipping_method']['tax_class_id']);
30: |
31: | foreach ($tax_rates as $tax_rate) {
32: | if (!isset($taxes[$tax_rate['tax_rate_id']])) {
33: | $taxes[$tax_rate['tax_rate_id']] = $tax_rate['amount'];
34: | } else {
35: | $taxes[$tax_rate['tax_rate_id']] += $tax_rate['amount'];
36: | }
37: | }
38: | }
39: |
40: | $total += $this->session->data['shipping_method']['cost'];
41: | }
42: | }
43: | }
44: |

OpenCart API API documentation generated by ApiGen dev-master