PHP Code:
<?php
if (!defined('TABLE_CUSTOMERS')) {
define('TABLE_CUSTOMERS', 'zen_customers');
}
if (!defined('TABLE_GROUP_PRICING')) {
define('TABLE_GROUP_PRICING', 'zen_group_pricing');
}
class purchaseorder extends base {
public $code;
public $title;
public $description;
public $enabled;
public $sort_order;
public $order_status;
public function __construct() {
global $order;
$this->code = 'purchaseorder';
$this->title = MODULE_PAYMENT_PURCHASEORDER_TEXT_TITLE;
$this->description = MODULE_PAYMENT_PURCHASEORDER_TEXT_DESCRIPTION;
$this->sort_order = defined('MODULE_PAYMENT_PURCHASEORDER_SORT_ORDER') ? MODULE_PAYMENT_PURCHASEORDER_SORT_ORDER : 0;
$this->enabled = (defined('MODULE_PAYMENT_PURCHASEORDER_STATUS') && MODULE_PAYMENT_PURCHASEORDER_STATUS == 'True');
if ((int)MODULE_PAYMENT_PURCHASEORDER_ORDER_STATUS_ID > 0) {
$this->order_status = MODULE_PAYMENT_PURCHASEORDER_ORDER_STATUS_ID;
}
}
public function update_status() {
global $order;
if (($this->enabled == true) && ((int)MODULE_PAYMENT_PURCHASEORDER_ZONE > 0)) {
$check_flag = false;
$check_query = zen_db_query("SELECT zone_id FROM " . TABLE_ZONES_TO_GEO_ZONES . " WHERE geo_zone_id = '" . MODULE_PAYMENT_PURCHASEORDER_ZONE . "' AND zone_country_id = '" . $order->billing['country']['id'] . "' ORDER BY zone_id");
while ($check = zen_db_fetch_array($check_query)) {
if ($check['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check['zone_id'] == $order->billing['zone_id']) {
$check_flag = true;
break;
}
}
if ($check_flag == false) {
$this->enabled = false;
}
}
}
public function javascript_validation() {
return false;
}
public function selection() {
return array('id' => $this->code,
'module' => $this->title);
}
public function pre_confirmation_check() {
return false;
}
public function confirmation() {
return array('title' => $this->title);
}
public function process_button() {
return false;
}
public function before_process() {
return false;
}
public function after_process() {
return false;
}
public function get_error() {
return false;
}
public function check() {
if (!isset($this->_check)) {
$check_query = zen_db_query("SELECT configuration_value FROM " . TABLE_CONFIGURATION . " WHERE configuration_key = 'MODULE_PAYMENT_PURCHASEORDER_STATUS'");
$this->_check = zen_db_num_rows($check_query);
}
return $this->_check;
}
public function install() {
zen_db_query("INSERT INTO " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Purchase Order Module', 'MODULE_PAYMENT_PURCHASEORDER_STATUS', 'True', 'Do you want to accept purchase order payments?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
zen_db_query("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_PURCHASEORDER_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
zen_db_query("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_PURCHASEORDER_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())");
zen_db_query("INSERT INTO " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) VALUES ('Set Order Status', 'MODULE_PAYMENT_PURCHASEORDER_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'zen_get_order_status_name', 'zen_cfg_pull_down_order_statuses(', now())");
}
public function remove() {
zen_db_query("DELETE FROM " . TABLE_CONFIGURATION . " WHERE configuration_key in ('MODULE_PAYMENT_PURCHASEORDER_STATUS', 'MODULE_PAYMENT_PURCHASEORDER_SORT_ORDER', 'MODULE_PAYMENT_PURCHASEORDER_ZONE', 'MODULE_PAYMENT_PURCHASEORDER_ORDER_STATUS_ID')");
}
public function keys() {
return array('MODULE_PAYMENT_PURCHASEORDER_STATUS', 'MODULE_PAYMENT_PURCHASEORDER_SORT_ORDER', 'MODULE_PAYMENT_PURCHASEORDER_ZONE', 'MODULE_PAYMENT_PURCHASEORDER_ORDER_STATUS_ID');
}
}
When I uploaded it to the test store and logged in to the admin area - 'modules/payments' does not show the plugin, so I am unable to install it. Any suggestions on how to fix the code would be greatly appreciated. I would like to get this plugin upgraded to v2.1 for all.
Bookmarks