Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Potential zen_has_product_attributes_values() error

    I noticed that in /includes/functions/functions_lookups.php, this function could apparently return a false negative if there were two or more attributes with equal and opposite total values (e.g. one adds $5.00 to base price and the other subtracts $5.00 from base).
    PHP Code:
    /*
     *  Check if product has attributes values
     */
      
    function zen_has_product_attributes_values($products_id) {
        global 
    $db;
        
    $attributes_query "select sum(options_values_price) as total
                             from " 
    TABLE_PRODUCTS_ATTRIBUTES "
                             where products_id = '" 
    . (int)$products_id "'";

        
    $attributes $db->Execute($attributes_query);

        if (
    $attributes->fields['total'] != 0) {
          return 
    true;
        } else {
          return 
    false;
        }
      } 
    It would appear that taking the absolute values of the prices before summing them would correct this.
    "select sum(options_values_price)
    "select sum((abs)options_values_price) or whatever is correct syntax for mysql.

  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Potential zen_has_product_attributes_values() error

    Another possibility would be to test in the query:
    PHP Code:
        $attributes_query "select options_values_price
                             from " 
    TABLE_PRODUCTS_ATTRIBUTES "
                             where products_id = '" 
    . (int)$products_id "'"
                             
    and options_values_price != 0
                             limit 1

    then return true if there is a value for the field.

  3. #3
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Potential zen_has_product_attributes_values() error

    Could you give a real world example of where this is producing a problem?
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  4. #4
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Potential zen_has_product_attributes_values() error

    No, I haven't tested it, but if you had
    (e.g. one adds $5.00 to base price and the other subtracts $5.00 from base)
    would this not trigger it, acting as if there were no attribute price values?

    I presume the value returned from this function matters in some situation, or else why have it at all?

    /includes/templates/template_default/templates/tpl_product_info_display.php

    Line #70 : echo $one_time . ((zen_has_product_attributes_values((int)$_GET['products_id']) and $flag_show_product_info_starting_at == 1) ? TEXT_BASE_PRICE : '') . zen_get_products_display_price((int)$_GET['products_id']);
    Last edited by gjh42; 5 Apr 2011 at 12:34 AM.

  5. #5
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Potential zen_has_product_attributes_values() error

    So presumably in the case above, you would not get the TEXT_BASE_PRICE text when it should appear.

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Potential zen_has_product_attributes_values() error

    I am trying to come up with a real world example where this can happen ... and so far, that only works if I have one Color Red for 5.00 and Size Small for -5.00 and no other choices ...

    If you come up with a good test example let us know ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today: v1.5.5]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

 

 

Similar Threads

  1. Potential?
    By DieuxSoldat_04 in forum General Questions
    Replies: 1
    Last Post: 30 Jan 2008, 10:28 AM
  2. Potential store
    By stevehare in forum General Questions
    Replies: 2
    Last Post: 5 Apr 2007, 10:23 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