Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2008
    Location
    Rimini, Italy, Italy
    Posts
    67
    Plugin Contributions
    0

    Default Disabling COD payment for certain customers

    Hello everybody,
    I have to disable COD payment for some customers.

    I obtained a first one result with the following code:

    $cod_excluded_customers_ids=array(15,391);
    if (in_array($_SESSION['customer_id'], $cod_excluded_customers_ids, false)) {
    $this->enabled = false

    that's fine because removes COD payment method from checkout_payment page.
    but I'd rather show a message like "Sorry, you can't use COD payment (because of previuous troubles with your orders delivery)"

    Something similar to the "Shipping method not available to the selected country" message used in shipping modules

    please, has someone some pointers to help me in this implementation?

    Many thanks
    Bye
    Francesco

  2. #2
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,731
    Plugin Contributions
    27

    Default Re: Disabling COD payment for certain customers

    You said this switch is working:
    $cod_excluded_customers_ids=array(15,391);
    if (in_array($_SESSION['customer_id'], $cod_excluded_customers_ids, false)) {
    $this->enabled = false

    So add this:
    $cod_excluded_customers_ids=array(15,391);
    if (in_array($_SESSION['customer_id'], $cod_excluded_customers_ids, false)) {
    $this->enabled = false
    // Explain error to customer
    echo 'Sorry, COD payment is no longer available with this account';
    }
    Twitch.
    https://www.twitchtoo.com Do you work for free? Please donate.
    June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

  3. #3
    Join Date
    Dec 2008
    Location
    Rimini, Italy, Italy
    Posts
    67
    Plugin Contributions
    0

    Default Re: Disabling COD payment for certain customers

    Sorry, I forgot to say I already tried with a simple echo, but the message is printed on top of page, not in payment methods list.

  4. #4
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,731
    Plugin Contributions
    27

    Default Re: Disabling COD payment for certain customers

    Okay, you'll need to put the notification on the payment page. It sees the switch then displays the message.

    I prefer to shut the code off in the module pages/header as it seems you have :) then look for the switch and display something if it returns false on the payment page.

    Something like:
    if ($cod_excluded_customers_ids = false) {
    // Explain error to customer
    echo 'Sorry, COD payment is no longer available with this account';
    }
    Twitch.
    https://www.twitchtoo.com Do you work for free? Please donate.
    June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

  5. #5
    Join Date
    Dec 2008
    Location
    Rimini, Italy, Italy
    Posts
    67
    Plugin Contributions
    0

    Default [SOLVED] Re: Disabling COD payment for certain customers

    Here's the smart (I hope) solution:

    in includes/modules/payment/cod.php:

    PHP Code:
    $cod_excluded_customers_ids=array(15,391);
          if (in_array($_SESSION['customer_id'], $cod_excluded_customers_ids, false)) { ?>
          <?php
                $messageStack
    ->add_session('disabled_cod'MY_CUSTOMERS_DISABLED_COD 'warning');
                
    $this->enabled false;
          }
    in templates/MY_TEMPLATE/templates/tpl_checkout_payment_default.php change:

    PHP Code:
    <?php
      $radio_buttons 
    0;
      for (
    $i=0$n=sizeof($selection); $i<$n$i++) {
    ?>
    to:

    PHP Code:
    <?php if ($messageStack->size('disabled_cod') > 0) echo $messageStack->output('disabled_cod'); ?>
    </br>
    <?php
      $radio_buttons 
    0;
      for (
    $i=0$n=sizeof($selection); $i<$n$i++) {
    ?>

    in includes/languages/MY_TEMPLATE/english.php add:

    PHP Code:
    define('MY_CUSTOMERS_DISABLED_COD''Sorry but COD payment for this account has been disabled'); 
    So finally we have this:

    Name:  nocod.jpg
Views: 703
Size:  17.2 KB

  6. #6
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,731
    Plugin Contributions
    27

    Default Re: [SOLVED] Re: Disabling COD payment for certain customers

    nice work.
    Twitch.
    https://www.twitchtoo.com Do you work for free? Please donate.
    June 7.2026 - NOW AVAILABLE - Twitch Base8 - Obsidian

 

 

Similar Threads

  1. Replies: 6
    Last Post: 16 Jul 2015, 04:29 AM
  2. v139h Hide COD payment method from certain customers?
    By TroyC in forum General Questions
    Replies: 3
    Last Post: 5 Apr 2013, 04:19 PM
  3. Disabling UPS for certain categories
    By getyler2 in forum Addon Shipping Modules
    Replies: 14
    Last Post: 30 Aug 2011, 11:57 PM
  4. block payment method for certain customers
    By tcl01 in forum General Questions
    Replies: 0
    Last Post: 8 Feb 2010, 08:38 PM
  5. COD assigned to certain customers
    By mattallam in forum Addon Payment Modules
    Replies: 2
    Last Post: 24 Feb 2007, 06:42 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