getMethod($address); // Only return the method if it actually has data if ($method_data) { return $method_data; } return []; } public function getMethod(array $address = []): array { $this->load->language('extension/hutko/payment/hutko'); $allowed_currencies = ['UAH', 'USD', 'EUR', 'GBP', 'CZK']; if (!in_array(strtoupper($this->session->data['currency']), $allowed_currencies)) { $status = false; } // 1. Validate Address (Safeguard against undefined keys) $country_id = isset($address['country_id']) ? (int)$address['country_id'] : 0; $zone_id = isset($address['zone_id']) ? (int)$address['zone_id'] : 0; $status = true; // 2. Check Geo Zone if ($this->config->get('payment_hutko_geo_zone_id')) { $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payment_hutko_geo_zone_id') . "' AND country_id = '" . $country_id . "' AND (zone_id = '" . $zone_id . "' OR zone_id = '0')"); if (!$query->num_rows) { $status = false; } } // 3. Check Order Total if ($this->config->get('payment_hutko_total') > 0 && $this->config->get('payment_hutko_total') > $this->cart->getTotal()) { $status = false; } // 4. Return Data $method_data = []; if ($status && $this->config->get('payment_hutko_status')) { $option_data = []; $option_data['hutko'] = [ 'code' => 'hutko.hutko', 'name' => $this->language->get('text_title') ]; // FORCE (int) casting and default value to prevent "Undefined array key" error $sort_order = (int)$this->config->get('payment_hutko_sort_order') ?? 1; $method_data = [ 'code' => 'hutko', 'name' => $this->language->get('text_title'), 'option' => $option_data, 'sort_order' => $sort_order ]; } return $method_data; } public function addHutkoOrder($order_id, $ref) { $this->db->query("INSERT INTO `" . DB_PREFIX . "hutko_order` SET `order_id` = '" . (int)$order_id . "', `hutko_transaction_ref` = '" . $this->db->escape($ref) . "', `date_added` = NOW() ON DUPLICATE KEY UPDATE `hutko_transaction_ref` = '" . $this->db->escape($ref) . "'"); } }