Results 1 to 10 of 10
  1. #1
    Join Date
    Sep 2008
    Posts
    108
    Plugin Contributions
    0

    Default Cod fee for groups?

    Is there any way I can make certain customer groups have cod as an option, while ordinary customers don't?

    I've found the invoice add on (haven't installed it yet, though), but it would be great to have one for cod aswell. :)

  2. #2
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Cod fee for groups?

    I don't believe this is available without some coding but I may be wrong and someone may have done it before. it isn't a major change. You need to edit :

    modules/payment/cod.php

    and insert some of the code from swguys invoice mod.

    the function you are going to alter is :

    Code:
            function update_status() {
          global $order, $db;
    
          if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_COD_ZONE > 0) ) {
            $check_flag = false;
            $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_COD_ZONE . "' and zone_country_id = '" . $order->delivery['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->delivery['zone_id']) {
                $check_flag = true;
                break;
              }
              $check->MoveNext();
            }
    
            if ($check_flag == false) {
              $this->enabled = false;
            }
          }
    
    // disable the module if the order only contains virtual products
          if ($this->enabled == true) {
            if ($order->content_type != 'physical') {
              $this->enabled = false;
            }
          }
        }
    And of the top of my head you are going to change it to:

    Code:
        function update_status() {
          global $order, $db;
    
          if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_COD_ZONE > 0) ) {
            $check_flag = false;
            $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_COD_ZONE . "' and zone_country_id = '" . $order->delivery['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->delivery['zone_id']) {
                $check_flag = true;
                break;
              }
              $check->MoveNext();
            }
    
          $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 == false || $check_flag_group == false) {
              $this->enabled = false;
            }
          }
    
    // disable the module if the order only contains virtual products
          if ($this->enabled == true) {
            if ($order->content_type != 'physical') {
              $this->enabled = false;
            }
          }
        }
    When I say ' off the top of my head' I mean Ihaven't checked this in any way, shape or form
    Last edited by niccol; 12 Jul 2010 at 08:31 AM. Reason: cut and paste error

  3. #3
    Join Date
    Sep 2008
    Posts
    108
    Plugin Contributions
    0

    Default Re: Cod fee for groups?

    Thanks! :)

    How do I link this code to the actual group? Let's say I called the group "COD" for the sake of simplicity. I suppose I would right "COD" in the code somewhere, but where..? *ponders*

  4. #4
    Join Date
    Sep 2008
    Posts
    108
    Plugin Contributions
    0

    Default Re: Cod fee for groups?

    Update:

    I tried replacing "invoice" with "COD", in $invoice_prefix =, but no luck so far... :)

  5. #5
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Cod fee for groups?

    My understanding is that:

    If you leave the code as it is then any group whose group name starts with 'invoice' will be able to use this payment type.

    So you need to name your group appropriately.

    If you change the prefix to 'COD' any group whose group name starts with COD should be able to use this payment type.

    What is the name of the group that you are trying to enable?

  6. #6
    Join Date
    Sep 2008
    Posts
    108
    Plugin Contributions
    0

    Default Re: Cod fee for groups?

    Quote Originally Posted by niccol View Post
    My understanding is that:

    If you leave the code as it is then any group whose group name starts with 'invoice' will be able to use this payment type.

    So you need to name your group appropriately.

    If you change the prefix to 'COD' any group whose group name starts with COD should be able to use this payment type.

    What is the name of the group that you are trying to enable?
    I tried COD... And I tried putting that in 'group_name' too.

    But it didn't matter where I'd put it, as the cod option didn't come up either way. I'm guessing that's half a good thing, though, since everybody was excluded even when activated...

  7. #7
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Cod fee for groups?

    I think that you are misunderstanding. You need to create a group in admin first. Then you add individual customers to that group. If you have done that then what is the name of that group?

  8. #8
    Join Date
    Sep 2008
    Posts
    108
    Plugin Contributions
    0

    Default Re: Cod fee for groups?

    Quote Originally Posted by niccol View Post
    I think that you are misunderstanding. You need to create a group in admin first. Then you add individual customers to that group. If you have done that then what is the name of that group?

    And so I did. I created a group, named that group "COD", and added myself to that group to test. No dice.

  9. #9
    Join Date
    Apr 2009
    Posts
    2,134
    Plugin Contributions
    3

    Default Re: Cod fee for groups?

    My apologies. When I said 'off the top of my head' earlier it meant that I wasn't testing it. Below is a tested version of that function:

    Code:
        function update_status() {
          global $order, $db;
    
          if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_COD_ZONE > 0) ) {
            $check_flag = false;
            $check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_COD_ZONE . "' and zone_country_id = '" . $order->delivery['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->delivery['zone_id']) {
                $check_flag = true;
                break;
              }
              $check->MoveNext();
            }
    
            if ($check_flag == false) {
              $this->enabled = false;
            }
          }
    
          $group_query = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$_SESSION['customer_id'] . "'");
            $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 = "COD"; 
              $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 == false) {
              $this->enabled = false;
              }
    
    // disable the module if the order only contains virtual products
          if ($this->enabled == true) {
            if ($order->content_type != 'physical') {
              $this->enabled = false;
            }
          }
        }
    Your group should be called 'COD' or you can change that in the code.

  10. #10
    Join Date
    Sep 2008
    Posts
    108
    Plugin Contributions
    0

    Default Re: Cod fee for groups?

    Yay!!! It works!! Thank you!! :)

 

 

Similar Threads

  1. v150 Need some Help in COD. COD fee depending on order price
    By bratsangels in forum Built-in Shipping and Payment Modules
    Replies: 20
    Last Post: 16 Sep 2012, 12:53 PM
  2. Add fee percentage for COD payment
    By avotecnica in forum Built-in Shipping and Payment Modules
    Replies: 4
    Last Post: 8 Feb 2010, 10:55 PM
  3. COD fee for Canada help
    By sjgarg in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 13 Jan 2008, 06:25 AM
  4. COD fee
    By nomadrw in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 22 Oct 2007, 08:27 PM
  5. Handling fee for COD payment
    By Stoned-6 in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 20 Oct 2007, 06:23 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