Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,475
    Plugin Contributions
    88

    Default *[Done v1.6.0] Incorrect comparison in ot_cod_fee.php

    The file /includes/modules/order_totals/ot_cod_fee.php begins with
    Code:
     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;
    While this code magically operates, it is semantically incorrect. The function ot_cod_fee sets the enabled flag to either binary true or false, based on the text-based value in the database. The function process then proceeds to test whether it should process based on the text-based value. This only works because (binary)true == EVERYTHING and (binary)false == NOTHING.

    Just to reduce confusion in the future, I suggest that the code be changed to
    Code:
     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) {
            //Will become true, if cod can be processed.
            $cod_country = false;

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

    Default Re: Incorrect comparison in ot_cod_fee.php

    Fix committed to v1.6.0
    .

    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.

 

 

Similar Threads

  1. v151 incorrect weight + shipping cost comparison
    By greenman161 in forum Managing Customers and Orders
    Replies: 2
    Last Post: 1 Nov 2013, 05:32 PM
  2. Replies: 1
    Last Post: 10 Jun 2013, 08:33 PM
  3. [Done v2.0] Incorrect Language Validation
    By glenara in forum Bug Reports
    Replies: 7
    Last Post: 30 Jul 2010, 04:08 PM
  4. How to add a new shipping module to ot_cod_fee.php?
    By ellivir in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 18 Oct 2009, 03:39 PM
  5. Replies: 1
    Last Post: 25 Jul 2007, 01:32 AM

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