Page 1 of 3 123 LastLast
Results 1 to 10 of 28
  1. #1
    Join Date
    Feb 2009
    Posts
    123
    Plugin Contributions
    0

    help question Can I restrict certain payment methods for certain products?

    For example, if I sell some products prohibited by Paypal, can I specify that Paypal cannot be selected as a method for those, but can for the rest of products?

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

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

    You could test if a Product is in the shopping cart and if so, disable the payment module by controlling the $this->enabled ...

    When set to false, the module will not show ...
    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: v1.5.5]
    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
    Feb 2009
    Posts
    123
    Plugin Contributions
    0

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

    That went over my head.

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

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

    Let's say you wanted to make the Check/Money Order payment module moneyorder.php hide or not show when products_id 27 was in the cart ...

    Currently, there is a line for the $this->enabled that reads:
    Code:
          $this->enabled = ((MODULE_PAYMENT_MONEYORDER_STATUS == 'True') ? true : false);
    Further down in the code, in the function update_status you will also see the $this->enabled referenced ...

    You could check to see if the products_id 12 was in the shopping cart and if so, make this false, so even if the payment module is installed, it will hide or be disabled when the product is there ...

    There is a function in the shopping_cart class to test values on what's in the cart ...

    Code:
       * $check_what is the fieldname example: 'products_is_free'
       * $check_value is the value being tested for - default is 1
       * Syntax: $_SESSION['cart']->in_cart_check('product_is_free','1');
       *
       * @param string product field to check
       * @param mixed value to check for
       * @return integer number of items matching restraint
       */
      function in_cart_check($check_what, $check_value='1') {
    So, using the following:
    Code:
    $_SESSION['cart']->in_cart_check('products_id','12')
    This can be done with the following code that changes the function update_status to read:
    Code:
    // class methods
        function update_status() {
          global $order, $db;
    
          if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_MONEYORDER_ZONE > 0) ) {
            $check_flag = false;
            $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_MONEYORDER_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;
            }
          }
    
    // disable if products_id 12 is in the cart
          if ($_SESSION['cart']->in_cart_check('products_id','12') > 0) {
              $this->enabled = false;
          }
    
        }
    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: v1.5.5]
    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
    Feb 2009
    Posts
    123
    Plugin Contributions
    0

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

    Oh, you meant altering the source code! Thanks, but no, thanks.

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

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

    Customizations requires custom code ...

    If you are not keen on coding you could always post for help in the Commercial Help Wanted ...
    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: v1.5.5]
    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
    Jun 2009
    Posts
    12
    Plugin Contributions
    0

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

    I hate to bump an old thread but this one closely relates to what i want. I have done the following suggested above and its working great, but i tried switching to 'categories_id' to limit the payment on an entire category in place of 'products_id'.

    When going through checkout with this switched i get:

    1054 Unknown column 'categories_id' in 'field list'
    in:
    [select categories_id as check_it from products where products_id='286' limit 1]
    not quite sure what this means so im hoping its a simple fix, otherwise i will be pumping in alot of product id's

    thanks in advance!

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

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

    The Master Categories ID field in the products table is called:
    master_categories_id

    This is the Product's categories_id ... if using Linked Product, then this will be the "main categories_id" or the "master categories_id" or the Category that "owns" the Product ...
    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: v1.5.5]
    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!

  9. #9
    Join Date
    Jun 2009
    Posts
    12
    Plugin Contributions
    0

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

    Brilliant!!! Thank you!!

    Works like a charm!

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

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

    Thanks for the update that you were just using the wrong field name in your select statement ... fussy the way the code works with MySQL ...
    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: v1.5.5]
    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!

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. v150 Restrict certain products to certain postcodes
    By mattys in forum General Questions
    Replies: 9
    Last Post: 20 Jul 2013, 07:27 PM
  2. v151 Can I restrict certain shipping modules for certain products?
    By gumboot in forum Built-in Shipping and Payment Modules
    Replies: 10
    Last Post: 13 Feb 2013, 05:26 AM
  3. Restrict Payment Types for certain products?
    By cjcraven in forum Managing Customers and Orders
    Replies: 3
    Last Post: 12 May 2011, 03:52 PM
  4. restrict shipping certain products to certain states?
    By airtime in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 18 Jan 2011, 05:11 AM
  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

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR