Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Restricting payment methods to only certain categories

    I've had 2 clients request the ability to limit payment methods to only certain categories. For example, one has products that he is not allowed to take payments from paypal but can accept payments thru authorize.net for the same productsl. These products are in one category only.

    I would assume that you could add in a switch to the specific payment method itself not to allow for certain categories (haven't considered that thru yet so I could be wrong) but would it be possible to add this as a switch for all payment methods rather than do one at a time?
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Restricting payment methods to only certain categories

    If you wanted to disable PayPal Express for Products in categories_id 12, where categories_id 12 is the master_categories_id for these Products ... then you can customize the code in RED:
    /includes/modules/payment/paypalwpp.php

    Code:
        $this->enabled = (MODULE_PAYMENT_PAYPALWPP_STATUS == 'True');
    
    // bof: do not show for categories_id 12 based on master_categories_id
        if (!IS_ADMIN_FLAG) {
          global $cart;
          $chk_cat = $_SESSION['cart']->in_cart_check('master_categories_id','12');
          if ($chk_cat > 0) {
            $this->enabled = false;
          }
        }
    // eof: do not show for categories_id 12 based on master_categories_id
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    May 2006
    Location
    Gardiner, Maine
    Posts
    2,371
    Plugin Contributions
    23

    Default Re: Restricting payment methods to only certain categories

    wow, you must have answered during my server changes. Just saw this - now got to remember who was asking for it!

    Thanks once again!
    The full-time Zen Cart Guru. WizTech4ZC.com
    New template for 2.0 viewable here: 2.0 Demo

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Restricting payment methods to only certain categories

    You are most welcome ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Aug 2012
    Posts
    331
    Plugin Contributions
    0

    Default Re: Restricting payment methods to only certain categories

    Quote Originally Posted by Ajeh View Post
    If you wanted to disable PayPal Express for Products in categories_id 12, where categories_id 12 is the master_categories_id for these Products ... then you can customize the code in RED:
    /includes/modules/payment/paypalwpp.php

    Code:
        $this->enabled = (MODULE_PAYMENT_PAYPALWPP_STATUS == 'True');
    
    // bof: do not show for categories_id 12 based on master_categories_id
        if (!IS_ADMIN_FLAG) {
          global $cart;
          $chk_cat = $_SESSION['cart']->in_cart_check('master_categories_id','12');
          if ($chk_cat > 0) {
            $this->enabled = false;
          }
        }
    // eof: do not show for categories_id 12 based on master_categories_id
    Hi,
    Can i add restrictions for product ID s as well (in addition to blocking categories)
    TIA

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Restricting payment methods to only certain categories

    Let's say you want to add products_id 33 and another categories_id 45 just to show you how those would work:
    $this->enabled = (MODULE_PAYMENT_PAYPALWPP_STATUS == 'True');

    Code:
    // bof: do not show for categories_id 12 and 45 based on master_categories_id and products_id 33
        if (!IS_ADMIN_FLAG) {
          global $cart;
          $chk_cat = $_SESSION['cart']->in_cart_check('master_categories_id','12');
          $chk_cat += $_SESSION['cart']->in_cart_check('master_categories_id','45');
          $chk_cat += $_SESSION['cart']->in_cart_check('products_id','33');
          if ($chk_cat > 0) {
            $this->enabled = false;
          }
        }
    // eof: do not show for categories_id 12 and 45 based on master_categories_id and products_id 33
    
    the += keeps adding on to the count for $chk_cat for each categories_id where master_categories_id matches and for specific products_id where the products_id matches ...

    The $_SESSION['cart']->in_cart_check can check cart content based on many things, and only on occasion is there any reason to touch the actual shopping_cart.php class file to obtain matches for various types of checks regarding what is in the shopping_cart ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  7. #7
    Join Date
    Aug 2012
    Posts
    331
    Plugin Contributions
    0

    Default Re: Restricting payment methods to only certain categories

    Thanks so much!

 

 

Similar Threads

  1. Replies: 6
    Last Post: 16 Jul 2015, 04:29 AM
  2. v138a Limitlimited order methods only for certain product or sub-categories
    By kobra8 in forum Managing Customers and Orders
    Replies: 7
    Last Post: 12 Dec 2012, 02:05 AM
  3. Can I restrict certain payment methods for certain products?
    By one tall man in forum Built-in Shipping and Payment Modules
    Replies: 27
    Last Post: 6 Apr 2011, 08:40 PM
  4. limited payment methods only with one categories
    By thenax in forum Built-in Shipping and Payment Modules
    Replies: 15
    Last Post: 17 Oct 2009, 08:01 PM
  5. How to disable certain payment methods for certain products?
    By AccurateOptics in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 29 Mar 2007, 06:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg