Forums / Addon Payment Modules / CC Module based on a "product" not address zone

CC Module based on a "product" not address zone

Views: 738

Results 1 to 3 of 3
27 Apr 2011, 1:06 PM
#1
sbbemn avatar

sbbemn

Zen Follower

Join Date:
Jan 2010
Posts:
182
Plugin Contributions:
0

CC Module based on a "product" not address zone

So - here's a good one.

Since the CC module really should not be used, we now strictly use Authorize.net and PayPal for all credit/debit transactions. AVS gets in the way sometimes and to have the old feature of the CC Module in our back pocket would be nice.

I would like to set it up so that if a certain product is in the cart, the CC module is triggered. (I'd set a product up for example "add this to your cart for special credit card processing")

Here's the existing code:

/**

  • calculate zone matches and flag settings to determine whether this module should display to customers or not

*/
function update_status() {
global $order, $db;

if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_CC_ZONE > 0) ) {
  $check_flag = false;
  $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_CC_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
  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 == false) {
    $this->enabled = false;
  }
}

}

I would assume if ($check->fields['zone_id'] < 1) { should be the check->cart['product_id, but I'm a little clouded on the rest as far as the code triggered from the cart/product.

POSSIBLE?!:lookaroun

29 Apr 2011, 8:31 PM
#2
sbbemn avatar

sbbemn

Zen Follower

Join Date:
Jan 2010
Posts:
182
Plugin Contributions:
0

Re: CC Module based on a "product" not address zone

Answer: YES!

//Begin Enable if products_id 6867 is in the cart
if ($_SESSION['cart']->in_cart_check('products_id','6867') > 0) {
$this->enabled = true;
}
//End new Enable code

This was inserted after line 88 in the cc.php module - before the last }

Replace 6867 with your product ID

2 May 2011, 5:20 PM
#3
sbbemn avatar

sbbemn

Zen Follower

Join Date:
Jan 2010
Posts:
182
Plugin Contributions:
0

Re: CC Module based on a "product" not address zone

Although it works, a major setback results:

When searching up an old order that used the old cc.php, this reads:

Fatal error: Call to a member function in_cart_check() on a non-object in ....includes/modules/payment/cc.php on line 91

What can be done about that???