Zen Cart Logo
Forums / Built-in Shipping and Payment Modules / Can I restrict certain payment methods for certain products?

Can I restrict certain payment methods for certain products?

Locked

Views: 17,250

Results 21 to 28 of 28
This thread is locked. New replies are disabled.
5 Apr 2011, 5:22 PM
#21
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Can I restrict certain payment methods for certain products?

Thanks for the update that this is working for you ...

6 Apr 2011, 2:02 PM
#22
dropbop avatar

dropbop

Zen Follower

Join Date:
Apr 2008
Location:
Athlone, Ireland
Posts:
177
Plugin Contributions:
1

Re: Can I restrict certain payment methods for certain products?

ok, i know this is an old thread, but it may be exactly the thing I need.

I have test the above code and it works like a charm, but the way it is, its not really any use to me. (not on this project anyway, but will be for others)

What I am wondering is, instead of setting it for one product ID, is it possible to set it for a range of product IDs.

So instead of this:

if ($_SESSION['cart']->in_cart_check('products_id','12') > 0) {
          $this->enabled = false;

is it possible to do soemthing like this

if ($_SESSION['cart']->in_cart_check('products_id','1 - 1000') > 0) {
          $this->enabled = false;

I know thats not the way its done, but thought by givig a visual it might help someone to understand what im looking for, because I know im really bad at explaining things. lol

Thanks

DB

6 Apr 2011, 2:10 PM
#23
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Can I restrict certain payment methods for certain products?

$_SESSION['cart']->in_cart_check will check for information from the products table ...

You can check for the master_categories_id which is useful for a Category of Products where all Products are using the same Category ...

Can you give more details about what you are trying to do? :unsure:

6 Apr 2011, 2:55 PM
#24
dropbop avatar

dropbop

Zen Follower

Join Date:
Apr 2008
Location:
Athlone, Ireland
Posts:
177
Plugin Contributions:
1

Re: Can I restrict certain payment methods for certain products?

Ajeh:

$_SESSION['cart']->in_cart_check will check for information from the products table ...

You can check for the master_categories_id which is useful for a Category of Products where all Products are using the same Category ...

Can you give more details about what you are trying to do? :unsure:

Disabling a payment module using the master category id has done the trick.

This is what I have done using the check/money order module as a test point:

// disable if categories  1, 2, 3, 4 if in the cart
      if ($_SESSION['cart']->in_cart_check('master_categories_id',"1") > 0) {
          $this->enabled = false;
      }
	  
	  if ($_SESSION['cart']->in_cart_check('master_categories_id',"2") > 0) {
          $this->enabled = false;
      }
	  
	  if ($_SESSION['cart']->in_cart_check('master_categories_id',"3") > 0) {
          $this->enabled = false;
      }
	  
	  if ($_SESSION['cart']->in_cart_check('master_categories_id',"4") > 0) {
          $this->enabled = false;
      }

    }

It seems to work, but not sure if its a bit long-winded.

6 Apr 2011, 3:05 PM
#25
dropbop avatar

dropbop

Zen Follower

Join Date:
Apr 2008
Location:
Athlone, Ireland
Posts:
177
Plugin Contributions:
1

Re: Can I restrict certain payment methods for certain products?

Just tried it on the Alertpay payment module and it doesnt work :(

6 Apr 2011, 3:46 PM
#26
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Can I restrict certain payment methods for certain products?

Where do you have the code?

You are showing an extra closing bracket but not what it is balanced against ...

Have you checked your Products to ensure what categories_id is used for the master_categories_id?

Do you have a:
global $cart;

above the testing? :unsure:

6 Apr 2011, 5:01 PM
#27
dropbop avatar

dropbop

Zen Follower

Join Date:
Apr 2008
Location:
Athlone, Ireland
Posts:
177
Plugin Contributions:
1

Re: Can I restrict certain payment methods for certain products?

Thanks for the reply Linda, much appreciated.

I have it working now. I prefer to use the older Alertpay 1.1 payment module because its the only one that doesnt usually through up any problems. But I popped the 1.3 version over to the cart and added the code to it and it worked just fine.. must be just the old module that didnt want to play nice with me. Although, I have looked through it a good bit and still cant see how it would not disable because everything seemd to look just as most other payment modules do for the first part up to about here --if ($check_flag == false) {--.

Anyway, its working just the way I want now, so big thanks for posting the code back in early 2009. Im sure there are many people who have benifited from it. :)

All the best, and thanks again for your replies.

DB

6 Apr 2011, 7:40 PM
#28
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Can I restrict certain payment methods for certain products?

Thanks for the update that you have this working now ...