1: <?php
2: namespace Opencart\Catalog\Model\Extension\Opencart\Shipping;
3: /**
4: * Class Free
5: *
6: * @package Opencart\Catalog\Model\Extension\Opencart\Shipping
7: */
8: class Free 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/free');
18:
19: $this->load->model('localisation/geo_zone');
20:
21: $results = $this->model_localisation_geo_zone->getGeoZone((int)$this->config->get('shipping_free_geo_zone_id'), (int)$address['country_id'], (int)$address['zone_id']);
22:
23: if (!$this->config->get('shipping_free_geo_zone_id')) {
24: $status = true;
25: } elseif ($results) {
26: $status = true;
27: } else {
28: $status = false;
29: }
30:
31: if ($this->cart->getSubTotal() < $this->config->get('shipping_free_total')) {
32: $status = false;
33: }
34:
35: $method_data = [];
36:
37: if ($status) {
38: $quote_data = [];
39:
40: $quote_data['free'] = [
41: 'code' => 'free.free',
42: 'name' => $this->language->get('text_description'),
43: 'cost' => 0.00,
44: 'tax_class_id' => 0,
45: 'text' => $this->currency->format(0.00, $this->session->data['currency'])
46: ];
47:
48: $method_data = [
49: 'code' => 'free',
50: 'name' => $this->language->get('heading_title'),
51: 'quote' => $quote_data,
52: 'sort_order' => $this->config->get('shipping_free_sort_order'),
53: 'error' => false
54: ];
55: }
56:
57: return $method_data;
58: }
59: }
60: