Zen Cart Logo
Forums / Addon Payment Modules / How do I make Invoice-Only Customers not see PayPal as a payment choice?

How do I make Invoice-Only Customers not see PayPal as a payment choice?

Views: 2,061

Results 1 to 13 of 13
19 Feb 2013, 10:59 AM
#1
scottmcclean avatar

scottmcclean

Zen Follower

Join Date:
Mar 2009
Location:
Trowbridge, Wiltshire
Posts:
121
Plugin Contributions:
0

How do I make Invoice-Only Customers not see PayPal as a payment choice?

Dear all,

I use two types of payment method - Invoice Only and PayPal Express.

I would like customers who belong to the "Invoice" group just to get the option of "invoice". Currently Invoice customers are getting the additional option of using paypal and I dont want this.

Is there a way of being able to not show paypal as a payment method for Invoice only customers? I am not a coder so if there is a possible solution to this I would really appreciate the help.

Many thanks

19 Feb 2013, 4:58 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: How do I make Invoice-Only Customers not see PayPal as a payment choice?

scottmcclean:

I would like customers who belong to the "Invoice" group just to get the option of "invoice".
How are you telling Zen Cart that these customers are "invoice only"?

20 Feb 2013, 12:36 PM
#3
scottmcclean avatar

scottmcclean

Zen Follower

Join Date:
Mar 2009
Location:
Trowbridge, Wiltshire
Posts:
121
Plugin Contributions:
0

Re: How do I make Invoice-Only Customers not see PayPal as a payment choice?

Hi DrByte,
I use the Invoice Payment Module for ZenCart 1.3 in conjunction with the Group Pricing Per Item Module. All the elements working brilliantly I just dont want the customers who are assigned to the Invoice group to see the paypal option.

I have attached some images to better illustrate.
Attachment 11975

20 Feb 2013, 3:37 PM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,709
Plugin Contributions:
56

Re: How do I make Invoice-Only Customers not see PayPal as a payment choice?

The invoice payment module has logic in it to only enable it for customers in a group whose name starts with "invoice". Copy this logic to paypal and invert it so that paypal only appears to customers who are NOT in a group whose name starts with invoice.

20 Feb 2013, 4:46 PM
#5
scottmcclean avatar

scottmcclean

Zen Follower

Join Date:
Mar 2009
Location:
Trowbridge, Wiltshire
Posts:
121
Plugin Contributions:
0

Re: How do I make Invoice-Only Customers not see PayPal as a payment choice?

Hi - what you say makes sense, but I have no idea what I would need to do to make it happen.

could i get some help with the code?

26 Mar 2013, 1:14 PM
#6
scottmcclean avatar

scottmcclean

Zen Follower

Join Date:
Mar 2009
Location:
Trowbridge, Wiltshire
Posts:
121
Plugin Contributions:
0

Re: How do I make Invoice-Only Customers not see PayPal as a payment choice?

Hi is anyone able to assist with this?

26 Mar 2013, 8:06 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: How do I make Invoice-Only Customers not see PayPal as a payment choice?

Simple to do:
a) I downloaded the invoice plugin
b) I looked at the update_status() code
c) I copied the code there that handles the group detection
d) I changed the final check for false to true, since you're looking for the opposite effect
e) the end result when added to the PayPal EC module is:

  function update_status() {
    global $order, $db;
    if ($this->enabled && (int)$this->zone > 0) {
      $check_flag = false;
      $sql = "SELECT zone_id
              FROM " . TABLE_ZONES_TO_GEO_ZONES . "
              WHERE geo_zone_id = :zoneId
              AND zone_country_id = :countryId
              ORDER BY zone_id";
      $sql = $db->bindVars($sql, ':zoneId', $this->zone, 'integer');
      $sql = $db->bindVars($sql, ':countryId', $order->billing['country']['id'], 'integer');
      $check = $db->Execute($sql);
      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) {
        $this->enabled = false;
      }

      // module cannot be used for purchase > $10,000 USD
      $order_amount = $this->calc_order_amount($order->info['total'], 'USD');
      if ($order_amount > 10000) $this->enabled = false;
      if ($order->info['total'] == 0) $this->enabled = false;
      
      // disable for invoice-only customers
      $group_query = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
      if ($this->enabled == true) {
        $check_flag_group = false;
        $check = $db->Execute("select group_name from " . TABLE_GROUP_PRICING . " where group_id = '" . $group_query->fields['customers_group_pricing'] . "'");
        if ($check->RecordCount() ==  1) {
          $invoice_prefix = "invoice";
          $check_prefix = substr($check->fields['group_name'], 0, strlen($invoice_prefix));
          if (strcasecmp($check_prefix, $invoice_prefix) == 0) {
            $check_flag_group = true;
          }
        }
        if ($check_flag_group == true) {
          $this->enabled = false;
        }
      }
      
    }
  }

Shameless reminder: Donations always welcome: www.zen-cart.com/donate

27 Mar 2013, 4:08 PM
#8
scottmcclean avatar

scottmcclean

Zen Follower

Join Date:
Mar 2009
Location:
Trowbridge, Wiltshire
Posts:
121
Plugin Contributions:
0

Re: How do I make Invoice-Only Customers not see PayPal as a payment choice?

Dr Byte, thank you very much for taking the time to help, much appreciated.

I have copied this code to the paypalwpp.php and paypaldp.php pages which were the only ones I could find with the code: ( // module cannot be used for purchase > $10,000 USD). I have uploaded the pages but I am still getting the paypal payment option.

Clearly I am doing somthing wrong. Are the 2 pages I updated the correct ones?

29 Apr 2013, 7:02 PM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: How do I make Invoice-Only Customers not see PayPal as a payment choice?

The code I quoted was tested successfully in, and copied-and-posted-from the paypalwpp.php file (which is the express checkout module).

And the paypaldp.php file (payments pro) should work by making the same change.

2 May 2013, 12:17 PM
#10
scottmcclean avatar

scottmcclean

Zen Follower

Join Date:
Mar 2009
Location:
Trowbridge, Wiltshire
Posts:
121
Plugin Contributions:
0

Re: How do I make Invoice-Only Customers not see PayPal as a payment choice?

Hi Dr Byte,
thanks for your reply. I have zero doubts that you are right it, I just cant figure out what I may have done wrong.

I have attached the code I have added in to the paypalwpp.php file Attachment 12443 - I just copied/paste. I would appreciate your thoughts - could it be a difference in a database field name or something like that?

2 May 2013, 9:37 PM
#11
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: How do I make Invoice-Only Customers not see PayPal as a payment choice?

I've not tested this, because I no longer have a 1.3.9 test site handy. (Shameless plug encouraging you to upgrade to a current version ;) )

paypaldp.php file (payments pro)

      if ($order_amount > 10000) $this->enabled = false;
    }
      // disable for invoice-only customers
      $group_query = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
      if ($this->enabled == true) {
        $check_flag_group = false;
        $check = $db->Execute("select group_name from " . TABLE_GROUP_PRICING . " where group_id = '" . $group_query->fields['customers_group_pricing'] . "'");
        if ($check->RecordCount() ==  1) {
          $invoice_prefix = "invoice";
          $check_prefix = substr($check->fields['group_name'], 0, strlen($invoice_prefix));
          if (strcasecmp($check_prefix, $invoice_prefix) == 0) {
            $check_flag_group = true;
          }
        }
        if ($check_flag_group == true) {
          $this->enabled = false;
        }
      }
  }
21 May 2013, 12:17 PM
#12
scottmcclean avatar

scottmcclean

Zen Follower

Join Date:
Mar 2009
Location:
Trowbridge, Wiltshire
Posts:
121
Plugin Contributions:
0

Re: How do I make Invoice-Only Customers not see PayPal as a payment choice?

Hi there,
I have re-stepped through the lines of code and they match. I am not sure what to do now. Is there anything else I can try to make this work? Could I add something similar to the checkout_payment.php file as well?

Any help greatly appreciated.

21 May 2013, 8:13 PM
#13
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: How do I make Invoice-Only Customers not see PayPal as a payment choice?

No, there are no other changes to make.
I just put up a new 1.3.9h site, added a discount-group named "invoice", created a customer and added them to that group, and added the code change exactly as I posted above, and it works just fine (prevents the Pro fields for credit-cards from appearing during checkout, since the customer is invoice-only). Also tested with the group being named "invoice-only" and "Invoice-Only", and it operates correctly either way. Also tested taking the customer out of that group, and the CC fields show up correctly as expected.