diff --git a/includes/modules/payment/cop.php b/includes/modules/payment/cop.php index b90a818..dc1f43f 100644 --- a/includes/modules/payment/cop.php +++ b/includes/modules/payment/cop.php @@ -1,19 +1,14 @@ enabled = ((MODULE_PAYMENT_COP_STATUS == 'True') ? true : false); $check_flag = false; - $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_COP_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); + $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_COP_ZONE . "' and zone_country_id = '" . (int)$order->delivery['country']['id'] . "' order by zone_id"); while (!$check->EOF) { if ($check->fields['zone_id'] < 1) { $check_flag = true; @@ -68,6 +63,11 @@ function update_status() { $this->enabled = false; } } + + // other status checks? + if ($this->enabled) { + // other checks here + } } function javascript_validation() { @@ -113,7 +113,12 @@ function check() { } function install() { - global $db; + global $db, $messageStack; + if (defined('MODULE_PAYMENT_COP_STATUS')) { + $messageStack->add_session('COP module already installed.', 'error'); + zen_redirect(zen_href_link(FILENAME_MODULES, 'set=payment&module=cop', 'NONSSL')); + return 'failed'; + } $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Cash On Delivery Module', 'MODULE_PAYMENT_COP_STATUS', 'True', 'Do you want to accept Cash On Pickup payments?', '6', '1', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_COP_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())"); $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_COP_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");