Simple to do:
a) I downloaded the invoice plugin
b) I looked at the update_status() code
c) I copied the code there that handles the group detection
d) I changed the final check for false to true, since you're looking for the opposite effect
e) the end result when added to the PayPal EC module is:
Code:
function update_status() {
global $order, $db;
if ($this->enabled && (int)$this->zone > 0) {
$check_flag = false;
$sql = "SELECT zone_id
FROM " . TABLE_ZONES_TO_GEO_ZONES . "
WHERE geo_zone_id = :zoneId
AND zone_country_id = :countryId
ORDER BY zone_id";
$sql = $db->bindVars($sql, ':zoneId', $this->zone, 'integer');
$sql = $db->bindVars($sql, ':countryId', $order->billing['country']['id'], 'integer');
$check = $db->Execute($sql);
while (!$check->EOF) {
if ($check->fields['zone_id'] < 1) {
$check_flag = true;
break;
} elseif ($check->fields['zone_id'] == $order->billing['zone_id']) {
$check_flag = true;
break;
}
$check->MoveNext();
}
if (!$check_flag) {
$this->enabled = false;
}
// module cannot be used for purchase > $10,000 USD
$order_amount = $this->calc_order_amount($order->info['total'], 'USD');
if ($order_amount > 10000) $this->enabled = false;
if ($order->info['total'] == 0) $this->enabled = false;
// disable for invoice-only customers
$group_query = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
if ($this->enabled == true) {
$check_flag_group = false;
$check = $db->Execute("select group_name from " . TABLE_GROUP_PRICING . " where group_id = '" . $group_query->fields['customers_group_pricing'] . "'");
if ($check->RecordCount() == 1) {
$invoice_prefix = "invoice";
$check_prefix = substr($check->fields['group_name'], 0, strlen($invoice_prefix));
if (strcasecmp($check_prefix, $invoice_prefix) == 0) {
$check_flag_group = true;
}
}
if ($check_flag_group == true) {
$this->enabled = false;
}
}
}
}
Shameless reminder: Donations always welcome: www.zen-cart.com/donate
Bookmarks