Forums / Addon Payment Modules / Binding a payment module to more than one country zone ID

Binding a payment module to more than one country zone ID

Locked

Views: 1,341

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
10 May 2010, 3:43 AM
#1
scott_c avatar

scott_c

Zen Follower

Join Date:
Dec 2009
Posts:
236
Plugin Contributions:
0

Binding a payment module to more than one country zone ID

Hi, Im using the eway payment module for credit card, it has an option in the admin to set it to function for one zone - or none at all.

Id like to make a small change to the file for it to work within two country zones.

If Im reading the code correctly, its checking the ‘geo zones’ against the db and deciding whether to allow the module based on what country is chosen in the admin. (and as mentioned above, the option in the admin only lets you chose one country or none at all)

Could someone please help me rewrite this to allow the module to be based on one or more zones?

// class methods

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

      if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_EWAY_ZONE > 0) ) {
        $check_flag = false;
        $check = $db->Execute("SELECT zone_id FROM " . TABLE_ZONES_TO_GEO_ZONES . " WHERE geo_zone_id = '" . MODULE_PAYMENT_EWAY_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;
        }
      }
    }

Cheers,

Scott.

Donation made. Enjoy those donuts! :-)

10 May 2010, 6:02 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Binding a payment module to more than one country zone ID

Simply create another zone definition that contains both sets of zones you want it to work for. Then set that new zone in the payment module's zone restrictions.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

10 May 2010, 8:35 AM
#3
scott_c avatar

scott_c

Zen Follower

Join Date:
Dec 2009
Posts:
236
Plugin Contributions:
0

Re: Binding a payment module to more than one country zone ID

Hi DrByte, I wasnt aware that zones could actually be manipulated in that way. I'll give it a go thanks!

Donation made. Enjoy those donuts! :-)

10 May 2010, 11:33 AM
#4
scott_c avatar

scott_c

Zen Follower

Join Date:
Dec 2009
Posts:
236
Plugin Contributions:
0

Re: Binding a payment module to more than one country zone ID

Thanks Dr Byte, that did the trick.

Just one interesting thing.. when there is only one shipping method available to a user it has a pre-selected radio button next to that one shipping option.

For the payment module, in my case Im only allowing Paypal for certain countries - the payment module was visible as I was checking out but not 'selected' by way of a radio button or checkbox.

I know that doesnt stop me from checking out, but I must admit, it really threw me for a few minutes - I could see the payment method and thought (incorrectly) that I had no way of selecting it.

Just my 2c :smile:

Donation made. Enjoy those donuts! :-)