1: | <?php
2: | namespace Opencart\Catalog\Model\Extension\Opencart\Shipping;
3: | /**
4: | * Class Item
5: | *
6: | * @package Opencart\Catalog\Model\Extension\Opencart\Shipping
7: | */
8: | class Item extends \Opencart\System\Engine\Model {
9: | /**
10: | * Get Quote
11: | *
12: | * @param array<string, mixed> $address
13: | *
14: | * @return array<string, mixed>
15: | */
16: | public function getQuote(array $address): array {
17: | $this->load->language('extension/opencart/shipping/item');
18: |
19: | $this->load->model('localisation/geo_zone');
20: |
21: | $results = $this->model_localisation_geo_zone->getGeoZone((int)$this->config->get('shipping_item_geo_zone_id'), (int)$address['country_id'], (int)$address['zone_id']);
22: |
23: | if (!$this->config->get('shipping_item_geo_zone_id')) {
24: | $status = true;
25: | } elseif ($results) {
26: | $status = true;
27: | } else {
28: | $status = false;
29: | }
30: |
31: | $method_data = [];
32: |
33: | if ($status) {
34: | $items = 0;
35: |
36: | foreach ($this->cart->getProducts() as $product) {
37: | if ($product['shipping']) {
38: | $items += $product['quantity'];
39: | }
40: | }
41: |
42: | $cost = (float)$this->config->get('shipping_item_cost');
43: | $tax_class_id = (int)$this->config->get('shipping_item_tax_class_id');
44: |
45: | $quote_data = [];
46: |
47: | $quote_data['item'] = [
48: | 'code' => 'item.item',
49: | 'name' => $this->language->get('text_description'),
50: | 'cost' => $cost * $items,
51: | 'tax_class_id' => $tax_class_id,
52: | 'text' => $this->currency->format($this->tax->calculate($cost * $items, $tax_class_id, $this->config->get('config_tax')), $this->session->data['currency'])
53: | ];
54: |
55: | $method_data = [
56: | 'code' => 'item',
57: | 'name' => $this->language->get('heading_title'),
58: | 'quote' => $quote_data,
59: | 'sort_order' => $this->config->get('shipping_item_sort_order'),
60: | 'error' => false
61: | ];
62: | }
63: |
64: | return $method_data;
65: | }
66: | }
67: |

OpenCart API API documentation generated by ApiGen dev-master