Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / enable a payment option when condition is meet

enable a payment option when condition is meet

Views: 1,145

Results 1 to 8 of 8
17 Mar 2015, 6:50 PM
#1
diptimoy avatar

diptimoy

Zen Follower

Join Date:
Apr 2012
Location:
Bardhaman , Bharat
Posts:
217
Plugin Contributions:
1

enable a payment option when condition is meet

I want to enable the online-bank payment option only when admin orders as customer via place order button .

IS IT possible ? IF it is , then what is the process /logic ?

Please Advice ,

Thanks in advance

Regards
Diptimoy

17 Mar 2015, 11:16 PM
#2
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: enable a payment option when condition is meet

Modify the payment module to only be enabled when the IP address is that of the admin.

As a quick fix you can hard code it directly into the module...

As a better more flexible version
I add a new key to the module to hold a list of admin IP addresses```php
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Admin IP's to allow access', 'MODULE_PAYMENT_PHONEORDER_ADMINIP', '123.123.123.123', 'Enter the Admin IP's that are allowed to access this module.<br />Separate multiple IP's with a comma.<br />No Spaces.', '6', '60', now());");

Then I add something like this to the module to disable if not from an admin IP
```php
// disable if NOT accessed from an ADMIN IP address
      if (!in_array($_SESSION['customers_ip_address'], explode(',',MODULE_PAYMENT_PHONEORDER_ADMINIP))) {
        $this->enabled = false;
      }

nb: You need to edit the code to suit your module, cannot use as it

18 Mar 2015, 4:07 AM
#3
diptimoy avatar

diptimoy

Zen Follower

Join Date:
Apr 2012
Location:
Bardhaman , Bharat
Posts:
217
Plugin Contributions:
1

Re: enable a payment option when condition is meet

gilby:

Modify the payment module to only be enabled when the IP address is that of the admin.

As a quick fix you can hard code it directly into the module...

As a better more flexible version
I add a new key to the module to hold a list of admin IP addresses```php
$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Admin IP's to allow access', 'MODULE_PAYMENT_PHONEORDER_ADMINIP', '123.123.123.123', 'Enter the Admin IP's that are allowed to access this module.<br />Separate multiple IP's with a comma.<br />No Spaces.', '6', '60', now());");

> Then I add something like this to the module to disable if not from an admin IP
> ```php
// disable if NOT accessed from an ADMIN IP address
      if (!in_array($_SESSION['customers_ip_address'], explode(',',MODULE_PAYMENT_PHONEORDER_ADMINIP))) {
        $this->enabled = false;
      }

nb: You need to edit the code to suit your module, cannot use as it

Thank you very much . want to know will this logic be same if admin has dynamic IP or it has nothing to do with IP being static or dynamic

18 Mar 2015, 5:11 AM
#4
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: enable a payment option when condition is meet

diptimoy:

Thank you very much . want to know will this logic be same if admin has dynamic IP or it has nothing to do with IP being static or dynamic

Well the admin users IP has to be listed in the mod for it to work

Dynamic IP suggests you get a different IP each time you connect to the internet
That would be difficult to work with.

I have an ADSL line that is listed as a Dynamic IP
It has never altered in the 10 years I have had it

Whereas my mobile phone get different IP addresses all the time

19 Mar 2015, 1:08 AM
#5
navido avatar

navido

Zen Follower

Join Date:
Sep 2008
Posts:
221
Plugin Contributions:
0

Re: enable a payment option when condition is meet

gilby:

Well the admin users IP has to be listed in the mod for it to work

Dynamic IP suggests you get a different IP each time you connect to the internet
That would be difficult to work with.

I have an ADSL line that is listed as a Dynamic IP
It has never altered in the 10 years I have had it

Whereas my mobile phone get different IP addresses all the time

is this solution to the problem only by checking IP adress? Because if the IP changes, then i have to change my ip before making this work. Isnt there any other solutions?

19 Mar 2015, 1:42 AM
#6
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: enable a payment option when condition is meet

navido:

is this solution to the problem only by checking IP adress? Because if the IP changes, then i have to change my ip before making this work. Isnt there any other solutions?There could be other solutions, but A bit more context will help us.
How are you mainly accessing the admin?
Is it via an ADSL connection?
or a mobile phone (sim) connection?
via Fixed computer, hand held device?
from the same location? or are you constantly mobile?

19 Mar 2015, 1:47 AM
#7
navido avatar

navido

Zen Follower

Join Date:
Sep 2008
Posts:
221
Plugin Contributions:
0

Re: enable a payment option when condition is meet

I access admin allways from my laptop.
it is from an ADSL connection yes. Not a mobile phone. It is a fixed computer.

Mostly two locations..but when i am abroad on a trip i need it there also.

19 Mar 2015, 2:40 AM
#8
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: enable a payment option when condition is meet

navido:

I access admin allways from my laptop.
it is from an ADSL connection yes. Not a mobile phone. It is a fixed computer.

Mostly two locations..but when i am abroad on a trip i need it there also.OK, thanks
I use the IP address as I want to "confine" access to specific computers in a specific room.
You could still use this while you are "home"
While "away" you would need to change the IP address for the mod. Takes about 30 seconds as it is visible in the admin header, so you could cut and paste this IP address and paste it into the payment module via the admin.

Otherwise I would suggest setting a session variable in the "login as customer" mod
So when you use this mod this session variable is "set"
and then this can be checked against a set value in the payment module, similar to the code above.
This ties the payment module to the use of the login as customer module (anywhere)

It is do-able but I have NOT tried this as I don't require it.