Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005
    Location
    Italy
    Posts
    199
    Plugin Contributions
    0

    Default Conditional enable for payment method

    Hi, first forgive my english :)

    Well, I've been asked to evaluate a method to enable specific payment method depending on the customer which is doing the checkout.

    Moreover, the parameter to check is not a default customer data.

    Another thing for a complete description: this parameter is the number of days for which the customer is allowed to delay the payment. The payment itslef will be accomplished through bank (something similar bank wire transfer, but not completely, here is named Ricevuta Bancaria, that stands for Bank Receipt and usually has this temporal expiration: 30 days, 60 days, 90 days, 120 days...

    This means that the customer receive a communication from his bank saying that he'll must pay the amount due at expiration date and he reply with his authorization to make the payment).

    Ok all this just to explain, it doesn't involve Zen Cart.

    So, now, before starting to work on it, I'd just like to hear from you if what I thought is right.

    Well, I'll create a new table where to store customer ID and the value of this parameter (30 or 60 or 90 ...).

    For my need this table will not be managed inside Zen Cart administration, but with an external bridge with the client software (once again, this is not important, I could easily create a managent tool in ZC admin, but the client asked for first solution).

    Ok, here comes the core of my question:

    In the payment method (that I'll create specifically) is ok to write, after

    Code:
    $this->enabled = ((MODULE_PAYMENT_MONEYORDER_STATUS == 'True') ? true : false);
    a code that query my new table and if find a match with user who is checking out, then enable the method (and after will retrieve the parameter value to print the right expiration time), otherwise disable the method?

    Another question is, in this point of the payment method file, it should be available the customer id (in the session, I believe), no?

    Thanks.
    Paolo De Dionigi
    Co-maintainer of Zen Cart Italia

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Conditional enable for payment method

    You should probably put your logic for detecting the customer's eligibility into the update_status() function, since that area is used to verify that the customer's address fits within a qualifying zone. It would be logical to include your additional check inside that section.

    Since you're using the money-order module as an example, you'd put it in this section of code:
    Code:
        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();
            }
    
    // add new code here
     // do lookup customer using $_SESSION['customer_id']
     if (customer is qualified) {
        $check_flag = true;
        $this->allowed_days = [number of days retrieved from lookup]
     }  else  {
        $check_flag = false
     }
    // end of added code
    
            if ($check_flag == false) {
              $this->enabled = false;
            }
          }
        }
    Then use $this->allowed_days later in the module when asking for the customers commitment to pay within the required timeline.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Feb 2005
    Location
    Italy
    Posts
    199
    Plugin Contributions
    0

    Default Re: Conditional enable for payment method

    Great, Doc!

    Thank you very much.
    Paolo De Dionigi
    Co-maintainer of Zen Cart Italia

 

 

Similar Threads

  1. v154 Enable Shipping Method on Schedule
    By PatClay in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 24 Oct 2015, 02:20 PM
  2. Replies: 6
    Last Post: 16 Jul 2015, 04:29 AM
  3. v151 Disable a payment method for a chosen shipping method?
    By chowyungunz in forum Built-in Shipping and Payment Modules
    Replies: 7
    Last Post: 12 Jun 2015, 12:56 PM
  4. Is it possible to enable a shipping method for only a certain customer group?
    By sacotechnology in forum Built-in Shipping and Payment Modules
    Replies: 37
    Last Post: 26 Dec 2010, 06:52 PM
  5. How to Enable Payment Method when Total is Zero?
    By Decostyle in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 26 Oct 2009, 06:09 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