| 1: | <?php
|
| 2: | namespace Opencart\Catalog\Model\Extension\Opencart\Payment;
|
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: |
|
| 8: | class COD extends \Opencart\System\Engine\Model {
|
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: |
|
| 16: | public function getMethods(array $address = []): array {
|
| 17: | $this->load->language('extension/opencart/payment/cod');
|
| 18: |
|
| 19: | if ($this->cart->hasSubscription()) {
|
| 20: | $status = false;
|
| 21: | } elseif (!$this->cart->hasShipping()) {
|
| 22: | $status = false;
|
| 23: | } elseif (!$this->config->get('config_checkout_payment_address')) {
|
| 24: | $status = true;
|
| 25: | } elseif (!$this->config->get('payment_cod_geo_zone_id')) {
|
| 26: | $status = true;
|
| 27: | } else {
|
| 28: | $this->load->model('localisation/geo_zone');
|
| 29: |
|
| 30: | $results = $this->model_localisation_geo_zone->getGeoZone((int)$this->config->get('payment_cod_geo_zone_id'), (int)$address['country_id'], (int)$address['zone_id']);
|
| 31: |
|
| 32: | if ($results) {
|
| 33: | $status = true;
|
| 34: | } else {
|
| 35: | $status = false;
|
| 36: | }
|
| 37: | }
|
| 38: |
|
| 39: | $method_data = [];
|
| 40: |
|
| 41: | if ($status) {
|
| 42: | $option_data['cod'] = [
|
| 43: | 'code' => 'cod.cod',
|
| 44: | 'name' => $this->language->get('heading_title')
|
| 45: | ];
|
| 46: |
|
| 47: | $method_data = [
|
| 48: | 'code' => 'cod',
|
| 49: | 'name' => $this->language->get('heading_title'),
|
| 50: | 'option' => $option_data,
|
| 51: | 'sort_order' => $this->config->get('payment_cod_sort_order')
|
| 52: | ];
|
| 53: | }
|
| 54: |
|
| 55: | return $method_data;
|
| 56: | }
|
| 57: | }
|
| 58: | |