Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2014
    Posts
    20
    Plugin Contributions
    0

    Default Disable a payment method for a chosen shipping method?

    For local pick up, I would like to restrict the payment method to just a cash payment. As of now on the payment page it shows the option to choose between my two installed payment modules, paypal standard or cash (COD). Is it possible to disable the paypal standard payment method for local pick up customers? Or vice versa, is it possible to disable the cash payment method (and show the paypal payment option only) for customers that choose shipping instead of local pick up? Any help would be greatly appreciated, thanks!

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

    Default Re: Disable a payment method for a chosen shipping method?

    Find the setting for the $this->enabled in the Payment module, such as, for example, PayPal Express:
    /includes/modules/payment/paypalwpp.php

    you would add the code in RED to disable the PayPal Express payment module when Store Pickup is selected ...
    Code:
        $this->enabled = (MODULE_PAYMENT_PAYPALWPP_STATUS == 'True');
        if (preg_match('#(storepickup)#i', $_SESSION['shipping']['id'])) {
          $this->enabled = false;
        }
    
    Note: PayPal Express is a much more reliable payment method than PayPal IPN ...
    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
    Oct 2014
    Posts
    20
    Plugin Contributions
    0

    Default Re: Disable a payment method for a chosen shipping method?

    Quote Originally Posted by Ajeh View Post
    Find the setting for the $this->enabled in the Payment module, such as, for example, PayPal Express:
    /includes/modules/payment/paypalwpp.php

    you would add the code in RED to disable the PayPal Express payment module when Store Pickup is selected ...
    Code:
        $this->enabled = (MODULE_PAYMENT_PAYPALWPP_STATUS == 'True');
        if (preg_match('#(storepickup)#i', $_SESSION['shipping']['id'])) {
          $this->enabled = false;
        }
    
    Note: PayPal Express is a much more reliable payment method than PayPal IPN ...
    THANKS SO MUCH!!! That worked beautifully... took less time to implement than I spent searching for the answer!

    On a side note, how is PayPal Express more reliable a payment method than PayPal Standard Payments? Standard has worked well for me so far. Maybe I should upgrade?

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

    Default Re: Disable a payment method for a chosen shipping method?

    You might read the FAQs on the different PayPal methods:
    http://www.zen-cart.com/content.php?...xpress-and-pro
    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
    May 2015
    Posts
    32
    Plugin Contributions
    0

    Default Re: Disable a payment method for a chosen shipping method?

    Quote Originally Posted by Ajeh View Post
    Find the setting for the $this->enabled in the Payment module, such as, for example, PayPal Express:
    /includes/modules/payment/paypalwpp.php

    you would add the code in RED to disable the PayPal Express payment module when Store Pickup is selected ...
    Code:
        $this->enabled = (MODULE_PAYMENT_PAYPALWPP_STATUS == 'True');
        if (preg_match('#(storepickup)#i', $_SESSION['shipping']['id'])) {
          $this->enabled = false;
        }
    
    Note: PayPal Express is a much more reliable payment method than PayPal IPN ...
    Please forgive me, I'm going to take a stab at reversing the logic for my needs... I would like to hide cod for all the shipping options, and ONLY show it when a local pickup is chosen.
    Would this be what I would do (I'm using 1.5.4 if that matters):
    /includes/modules/payment/cod.php
    Code:
        $this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
        if (preg_match('#(storepickup)#i', $_SESSION['shipping']['id'])) {
          $this->enabled = true;
        }
    
    I "Think" I'm reversing the logic since I'm putting the code into the cod module, and hopefully only enabling it if the storepickup is chosen... And I copied the $this statement from my current cod.php file (which looked a little different then the quoted one, I'm guessing changes for 1.5.4?). In any case before I go hacking away and screwing something up, the question is if the above "should" work?

  6. #6
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,495
    Plugin Contributions
    88

    Default Re: Disable a payment method for a chosen shipping method?

    Quote Originally Posted by tronage View Post
    Please forgive me, I'm going to take a stab at reversing the logic for my needs... I would like to hide cod for all the shipping options, and ONLY show it when a local pickup is chosen.
    Would this be what I would do (I'm using 1.5.4 if that matters):
    /includes/modules/payment/cod.php
    Code:
        $this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
        if (preg_match('#(storepickup)#i', $_SESSION['shipping']['id'])) {
          $this->enabled = true;
        }
    
    I "Think" I'm reversing the logic since I'm putting the code into the cod module, and hopefully only enabling it if the storepickup is chosen... And I copied the $this statement from my current cod.php file (which looked a little different then the quoted one, I'm guessing changes for 1.5.4?). In any case before I go hacking away and screwing something up, the question is if the above "should" work?
    You probably want:
    Code:
        $this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
        if ($this->enabled) {
          $this->enabled = (bool)preg_match('#(storepickup)#i', $_SESSION['shipping']['id']);
        }
    
    That teeny change does two things:
    1. It only enables the module if it's enabled in your admin
    2. If enabled in the admin, it's only enabled if the shipping method chosen is "Store Pickup". The value returned by preg_match is either 0 (no match), 1 (match) or false (error), so casting its return to a boolean value results in COD being enabled only if there is a match.

  7. #7
    Join Date
    May 2015
    Posts
    32
    Plugin Contributions
    0

    Default Re: Disable a payment method for a chosen shipping method?

    Quote Originally Posted by lat9 View Post
    You probably want:
    Code:
        $this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true : false);
        if ($this->enabled) {
          $this->enabled = (bool)preg_match('#(storepickup)#i', $_SESSION['shipping']['id']);
        }
    
    That teeny change does two things:
    1. It only enables the module if it's enabled in your admin
    2. If enabled in the admin, it's only enabled if the shipping method chosen is "Store Pickup". The value returned by preg_match is either 0 (no match), 1 (match) or false (error), so casting its return to a boolean value results in COD being enabled only if there is a match.
    GENIOUS!
    Popped in that code, and all works perfectly! And like you said, if I decide to turn off COD in the admin, I don't have to go back and remove the code!
    Thanks so much!!!

  8. #8
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,495
    Plugin Contributions
    88

    Default Re: Disable a payment method for a chosen shipping method?

    Happy to have helped!

 

 

Similar Threads

  1. Disable payment method for categories (with subcategories)
    By Tempesta48 in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 11 Apr 2014, 06:02 PM
  2. shipping method based on payment method?
    By psr racing in forum Built-in Shipping and Payment Modules
    Replies: 2
    Last Post: 27 Apr 2011, 01:25 PM
  3. Disable Credit Card Option on Payment Method
    By Ozwide in forum Built-in Shipping and Payment Modules
    Replies: 11
    Last Post: 30 Dec 2009, 04:43 PM
  4. disable shipping method
    By bhadz08 in forum Managing Customers and Orders
    Replies: 2
    Last Post: 20 Jul 2009, 06:14 PM
  5. Only show payment method when UPS shipping method chosen?
    By helen610 in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 28 Aug 2008, 03:04 AM

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