Results 1 to 7 of 7
  1. #1
    Join Date
    Sep 2009
    Posts
    37
    Plugin Contributions
    0

    Default Two different COD fee amounts (depending on cart total)

    Hi.

    Is it possible to set 2 different COD fee amounts?

    example:

    if order amount <50 $ - COD: 3 $
    if order amount >50 $ - COD: 2 $


    Now I can only add one price to COD fee.

  2. #2
    Join Date
    Sep 2009
    Posts
    37
    Plugin Contributions
    0

    Default Re: Two different COD fee amounts (depending on cart total)

    I guess you cannot do it then? :)

  3. #3
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Two different COD fee amounts (depending on cart total)

    It's ZC, almost anything is possible.

    I don't have immediate access to the code, but there are two options that come to mind, though a third as a "combination" could be done.

    One way is to modify the existing COD code so that when or before the assignment of the COD fee to the return result to check the total cost of the purchase (how do taxes play into this?) if less than the desired total order, then the one value, else the other. Another way is to clone the module and make one inactive if it doesn't meet the desired dollar amount. The third method is to add install and operation criteria to the module so that all of the options can be controlled from the admin rather than the files... problem with this is or really any of them is that on upgrade the code will need to be duplicated to make this work on the upgraded system.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #4
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Two different COD fee amounts (depending on cart total)

    What shipping module are you using for COD? Can you post the code by pressing the # button on the message box toolbar and then pasting the code between the [code] and [/code] tags?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Sep 2009
    Posts
    37
    Plugin Contributions
    0

    Default Re: Two different COD fee amounts (depending on cart total)

    Thank you for your replies :)

    I will post the code as soon as you tell me where can I find "the message box toolbar" ? :)

    My Payment Modules:
    -cod (cash on delivery)
    -moneyorder (money order)

    My Shipping modules:
    -flat (GLS)
    -storepickup (Store pickup)
    -freeoptions (Total >= 40.01 - free shipping if order is over 40 $)

    My Order Total modules:
    -ot_cod_fee (Cash on Delivery Fee)

  6. #6
    Join Date
    Sep 2009
    Posts
    37
    Plugin Contributions
    0

    Default Re: Two different COD fee amounts (depending on cart total)

    and this is a full code of includes/modules/order_total/ot_cod_fee.php

    Code:
    <?php
    /**
     * ot_cod_fee order-total module
     *
     * @package orderTotal
     * @copyright Copyright 2003-2013 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @copyright Portions Copyright (c) 2002 Thomas Pl채nkers http://www.oscommerce.at
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version GIT: $Id: Author: DrByte  Fri Apr 5 19:06:27 2013 -0400 Modified in v1.5.2 $
     */
    /**
     * COD-FEE Order Totals Module
     *
     */
    
      class ot_cod_fee {
        var $title, $output;
    
        function ot_cod_fee() {
          $this->code = 'ot_cod_fee';
          $this->title = MODULE_ORDER_TOTAL_COD_TITLE;
          $this->description = MODULE_ORDER_TOTAL_COD_DESCRIPTION;
          $this->enabled = ((MODULE_ORDER_TOTAL_COD_STATUS == 'true') ? true : false);
          $this->sort_order = MODULE_ORDER_TOTAL_COD_SORT_ORDER;
    
          $this->output = array();
        }
    
        function process() {
          global $order, $currencies, $cod_cost, $cod_country, $shipping;
    
          if ($this->enabled == true) {
            //Will become true, if cod can be processed.
            $cod_country = false;
    
            //check if payment method is cod. If yes, check if cod is possible.
    
            if ($_SESSION['payment'] == 'cod') {
              //process installed shipping modules
              if (substr_count($_SESSION['shipping']['id'], 'flat') !=0) $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FLAT);
              if (substr_count($_SESSION['shipping']['id'], 'free') !=0) $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FREE);
              if (substr_count($_SESSION['shipping']['id'], 'freeshipper') !=0) $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FREESHIPPER);
              if (substr_count($_SESSION['shipping']['id'], 'freeoptions') !=0) $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FREEOPTIONS);
              if (substr_count($_SESSION['shipping']['id'], 'item') !=0) $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_ITEM);
              if (substr_count($_SESSION['shipping']['id'], 'perweightunit') !=0) $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_PERWEIGHTUNIT);
              if (substr_count($_SESSION['shipping']['id'], 'table') !=0) $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_TABLE);
              if (substr_count($_SESSION['shipping']['id'], 'ups') !=0) $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_UPS);
              if (substr_count($_SESSION['shipping']['id'], 'usps') !=0) $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_USPS);
              if (substr_count($_SESSION['shipping']['id'], 'fedex') !=0) $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FEDEX);
              if (substr_count($_SESSION['shipping']['id'], 'zones') !=0) $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_ZONES);
              if (substr_count($_SESSION['shipping']['id'], 'ap') !=0) $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_AP);
              if (substr_count($_SESSION['shipping']['id'], 'dp') !=0) $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DP);
    
              //satt inn av Pompel
              if (substr_count($_SESSION['shipping']['id'], 'servicepakke') !=0) $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_SERVICEPAKKE);
    
                for ($i = 0; $i < count($cod_zones); $i++) {
                  if ($cod_zones[$i] == $order->delivery['country']['iso_code_2']) {
                      $cod_cost = $cod_zones[$i + 1];
                      $cod_country = true;
                      //print('match' . $i . ': ' . $cod_cost);
                      break;
                    } elseif ($cod_zones[$i] == '00') {
                      $cod_cost = $cod_zones[$i + 1];
                      $cod_country = true;
                      //print('match' . $i . ': ' . $cod_cost);
                      break;
                    } else {
                      //print('no match');
                    }
                  $i++;
                }
              } else {
                //COD selected, but no shipping module which offers COD
              }
    
            if ($cod_country) {
              $cod_tax_address = zen_get_tax_locations();
              $tax = zen_get_tax_rate(MODULE_ORDER_TOTAL_COD_TAX_CLASS, $cod_tax_address['country_id'], $cod_tax_address['zone_id']);
              $order->info['total'] += $cod_cost;
              if ($tax > 0) {
                $tax_description = zen_get_tax_description(MODULE_ORDER_TOTAL_COD_TAX_CLASS, $cod_tax_address['country_id'], $cod_tax_address['zone_id']);
                $order->info['tax'] += zen_calculate_tax($cod_cost, $tax);
                $order->info['tax_groups'][$tax_description] += zen_calculate_tax($cod_cost, $tax);
                $order->info['total'] += zen_calculate_tax($cod_cost, $tax);
                if (DISPLAY_PRICE_WITH_TAX == 'true') {
                  $cod_cost += zen_calculate_tax($cod_cost, $tax);
                }
              }
    
              $this->output[] = array('title' => $this->title . ':',
                                      'text' => $currencies->format($cod_cost, true,  $order->info['currency'], $order->info['currency_value']),
                                      'value' => $cod_cost);
            } else {
    //Following code should be improved if we can't get the shipping modules disabled, who don't allow COD
    // as well as countries who do not have cod
    //          $this->output[] = array('title' => $this->title . ':',
    //                                  'text' => 'No COD for this module.',
    //                                  'value' => '');
            }
          }
        }
    
        function check() {
          global $db;
          if (!isset($this->_check)) {
            $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_COD_STATUS'");
            $this->_check = $check_query->RecordCount();
          }
    
          return $this->_check;
        }
    
        function keys() {
          return array('MODULE_ORDER_TOTAL_COD_STATUS', 'MODULE_ORDER_TOTAL_COD_SORT_ORDER', 'MODULE_ORDER_TOTAL_COD_FEE_FLAT', 'MODULE_ORDER_TOTAL_COD_FEE_FREE', 'MODULE_ORDER_TOTAL_COD_FEE_FREESHIPPER', 'MODULE_ORDER_TOTAL_COD_FEE_FREEOPTIONS', 'MODULE_ORDER_TOTAL_COD_FEE_PERWEIGHTUNIT', 'MODULE_ORDER_TOTAL_COD_FEE_ITEM', 'MODULE_ORDER_TOTAL_COD_FEE_TABLE', 'MODULE_ORDER_TOTAL_COD_FEE_UPS', 'MODULE_ORDER_TOTAL_COD_FEE_USPS', 'MODULE_ORDER_TOTAL_COD_FEE_ZONES', 'MODULE_ORDER_TOTAL_COD_FEE_AP', 'MODULE_ORDER_TOTAL_COD_FEE_DP', 'MODULE_ORDER_TOTAL_COD_FEE_SERVICEPAKKE', 'MODULE_ORDER_TOTAL_COD_FEE_FEDEX', 'MODULE_ORDER_TOTAL_COD_TAX_CLASS');
        }
    
        function install() {
          global $db;
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Display COD', 'MODULE_ORDER_TOTAL_COD_STATUS', 'true', 'Do you want this module to display?', '6', '1','zen_cfg_select_option(array(\'true\', \'false\'), ', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_ORDER_TOTAL_COD_SORT_ORDER', '950', 'Sort order of display.', '6', '2', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for FLAT', 'MODULE_ORDER_TOTAL_COD_FEE_FLAT', 'AT:3.00,DE:3.58,00:9.99', 'FLAT: &lt;Country code&gt;:&lt;COD price&gt;, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '3', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for Free Shipping by default', 'MODULE_ORDER_TOTAL_COD_FEE_FREE', 'US:3.00', 'Free by default: &lt;Country code&gt;:&lt;COD price&gt;, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '3', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for Free Shipping Module - (freeshipper)', 'MODULE_ORDER_TOTAL_COD_FEE_FREESHIPPER', 'CA:4.50,US:3.00,00:9.99', 'Free Module: &lt;Country code&gt;:&lt;COD price&gt;, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '3', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for Free-Options Shipping Module - (freeoptions)', 'MODULE_ORDER_TOTAL_COD_FEE_FREEOPTIONS', 'CA:4.50,US:3.00,00:9.99', 'Free+Options: &lt;Country code&gt;:&lt;COD price&gt;, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '3', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for Per Weight Unit Shipping Module - (perweightunit)', 'MODULE_ORDER_TOTAL_COD_FEE_PERWEIGHTUNIT', 'CA:4.50,US:3.00,00:9.99', 'Per Weight Unit: &lt;Country code&gt;:&lt;COD price&gt;, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '3', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for ITEM', 'MODULE_ORDER_TOTAL_COD_FEE_ITEM', 'AT:3.00,DE:3.58,00:9.99', 'ITEM: &lt;Country code&gt;:&lt;COD price&gt;, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '4', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for TABLE', 'MODULE_ORDER_TOTAL_COD_FEE_TABLE', 'AT:3.00,DE:3.58,00:9.99', 'TABLE: &lt;Country code&gt;:&lt;COD price&gt;, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '5', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for UPS', 'MODULE_ORDER_TOTAL_COD_FEE_UPS', 'CA:4.50,US:3.00,00:9.99', 'UPS: &lt;Country code&gt;:&lt;COD price&gt;, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '6', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for USPS', 'MODULE_ORDER_TOTAL_COD_FEE_USPS', 'CA:4.50,US:3.00,00:9.99', 'USPS: &lt;Country code&gt;:&lt;COD price&gt;, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '7', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for ZONES', 'MODULE_ORDER_TOTAL_COD_FEE_ZONES', 'CA:4.50,US:3.00,00:9.99', 'ZONES: &lt;Country code&gt;:&lt;COD price&gt;, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '8', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for Austrian Post', 'MODULE_ORDER_TOTAL_COD_FEE_AP', 'AT:3.63,00:9.99', 'Austrian Post: &lt;Country code&gt;:&lt;COD price&gt;, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '9', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for German Post', 'MODULE_ORDER_TOTAL_COD_FEE_DP', 'DE:3.58,00:9.99', 'German Post: &lt;Country code&gt;:&lt;COD price&gt;, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '10', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for Servicepakke', 'MODULE_ORDER_TOTAL_COD_FEE_SERVICEPAKKE', 'NO:69', 'Servicepakke: &lt;Country code&gt;:&lt;COD price&gt;, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '11', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('COD Fee for FedEx', 'MODULE_ORDER_TOTAL_COD_FEE_FEDEX', 'US:3.00', 'FedEx: &lt;Country code&gt;:&lt;COD price&gt;, .... 00 as country code applies for all countries. If country code is 00, it must be the last statement. If no 00:9.99 appears, COD shipping in foreign countries is not calculated (not possible)', '6', '12', now())");
          $db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_ORDER_TOTAL_COD_TAX_CLASS', '0', 'Use the following tax class on the COD fee.', '6', '25', 'zen_get_tax_class_title', 'zen_cfg_pull_down_tax_classes(', now())");
        }
    
    
        function remove() {
          global $db;
          $keys = '';
          $keys_array = $this->keys();
          $keys_size = sizeof($keys_array);
          for ($i=0; $i<$keys_size; $i++) {
            $keys .= "'" . $keys_array[$i] . "',";
          }
          $keys = substr($keys, 0, -1);
    
          $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in (" . $keys . ")");
        }
      }

  7. #7
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Two different COD fee amounts (depending on cart total)

    Are you wanting to consistently apply $1 additional regardless of the base shipping method and destination? Or is there to be some variation to be applied for either of those two factors?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. v139h cod fee not added to total on order confirm page
    By raj3396 in forum Built-in Shipping and Payment Modules
    Replies: 5
    Last Post: 8 Oct 2012, 07:09 PM
  2. 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
  3. COD Fee disabled if total is more than x?
    By flasmar in forum Built-in Shipping and Payment Modules
    Replies: 6
    Last Post: 18 Jan 2009, 11:14 PM
  4. Can shipping fee based on two different products with different shipping cost?
    By oavs in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 29 Oct 2008, 10:00 AM
  5. Two different COD fee amounts
    By TomCZ in forum General Questions
    Replies: 1
    Last Post: 11 Mar 2007, 06:36 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