Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

    Default Unknown constant (ATTRIBUTES_PRICE_FACTOR_FROM_SPECIAL) in functions_prices.php

    The function zen_get_attributes_price_factor in /includes/functions/functions_prices.php uses an unknown constant (highlighted):
    Code:
    ////
    // return attributes_price_factor
      function zen_get_attributes_price_factor($price, $special, $factor, $offset) {
        if (ATTRIBUTES_PRICE_FACTOR_FROM_SPECIAL =='1' and $special) {
          // calculate from specials_new_products_price
          $calculated_price = $special * ($factor - $offset);
        } else {
          // calculate from products_price
          $calculated_price = $price * ($factor - $offset);
        }
    //    return '$price ' . $price . ' $special ' . $special . ' $factor ' . $factor . ' $offset ' . $offset;
        return $calculated_price;
      }
    I've used the Developers Tool Kit to no avail; it's not defined in the database, either.

  2. #2
    Join Date
    Feb 2012
    Location
    mostly harmless
    Posts
    1,809
    Plugin Contributions
    8

    Default Re: Unknown constant (ATTRIBUTES_PRICE_FACTOR_FROM_SPECIAL) in functions_prices.php

    Yup, I cannot find it in the code (or database) for 1.5.1 either. It is however set in the 1.5.2 release candidate ("/includes/classes/shopping_cart.php"). Looks to be an "override" of sorts... Maybe it would be better to just to see if the constant is defined rather then checking the value? Or refactoring the function and related code? Maybe another will have some additional insight for us :)
    The glass is not half full. The glass is not half empty. The glass is simply too big!
    Where are the Zen Cart Debug Logs? Where are the HTTP 500 / Server Error Logs?
    Zen Cart related projects maintained by lhûngîl : Plugin / Module Tracker

  3. #3
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

    Default Undefined constant ATTRIBUTES_PRICE_FACTOR_FROM_SPECIAL

    There's an undefined constant (ATTRIBUTES_PRICE_FACTOR_FROM_SPECIAL), used in /includes/functions/functions_prices.php (ca. line 1024); it exists neither in language files nor in the database:
    Code:
      function zen_get_attributes_price_factor($price, $special, $factor, $offset) {
        if (ATTRIBUTES_PRICE_FACTOR_FROM_SPECIAL =='1' and $special) {
          // calculate from specials_new_products_price
          $calculated_price = $special * ($factor - $offset);
        } else {
          // calculate from products_price
          $calculated_price = $price * ($factor - $offset);
        }
    //    return '$price ' . $price . ' $special ' . $special . ' $factor ' . $factor . ' $offset ' . $offset;
        return $calculated_price;
      }
    In the same file, there's also an uninitialized value in zen_get_attributes_price_final_onetime (line 1122); suggest changing
    Code:
    ////
    // attributes final price onetime
      function zen_get_attributes_price_final_onetime($attribute, $qty= 1, $pre_selected_onetime) {
        global $db;
        global $cart;
    
        if ($pre_selected_onetime == '' or $attribute != $pre_selected_onetime->fields["products_attributes_id"]) {
          $pre_selected_onetime = $db->Execute("select pa.* from " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_attributes_id= '" . (int)$attribute . "'");
        } else {
          // use existing select
        }
    
    // one time charges
        // onetime charge
          $attributes_price_final_onetime += $pre_selected_onetime->fields["attributes_price_onetime"];
    
        // price factor
        $display_normal_price = zen_get_products_actual_price($pre_selected_onetime->fields["products_id"]);
        $display_special_price = zen_get_products_special_price($pre_selected_onetime->fields["products_id"]);
    to
    Code:
    ////
    // attributes final price onetime
      function zen_get_attributes_price_final_onetime($attribute, $qty= 1, $pre_selected_onetime) {
        global $db;
        global $cart;
    
        if ($pre_selected_onetime == '' or $attribute != $pre_selected_onetime->fields["products_attributes_id"]) {
          $pre_selected_onetime = $db->Execute("select pa.* from " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_attributes_id= '" . (int)$attribute . "'");
        } else {
          // use existing select
        }
    
    // one time charges
        // onetime charge
          $attributes_price_final_onetime = $pre_selected_onetime->fields["attributes_price_onetime"];
    
        // price factor
        $display_normal_price = zen_get_products_actual_price($pre_selected_onetime->fields["products_id"]);
        $display_special_price = zen_get_products_special_price($pre_selected_onetime->fields["products_id"]);
    Last edited by lat9; 2 Feb 2014 at 03:01 PM. Reason: Added uninitialized variable

  4. #4
    Join Date
    Aug 2007
    Location
    Gijón, Asturias, Spain
    Posts
    2,571
    Plugin Contributions
    30

    Default Re: Undefined constant ATTRIBUTES_PRICE_FACTOR_FROM_SPECIAL

    ZC155e
    While doing a "Report All Errors" for some heads-up on potential future errors, I get this error flagged on a product page, nothing in cart, not logged in, php 7.1.8.

    PHP Notice: Use of undefined constant ATTRIBUTES_PRICE_FACTOR_FROM_SPECIAL - assumed 'ATTRIBUTES_PRICE_FACTOR_FROM_SPECIAL' in .....\includes\functions\functions_prices.php on line 1024
    So I find this thread.

    ATTRIBUTES_PRICE_FACTOR_FROM_SPECIAL is defined on the fly in classes/shopping_cart, but evidently this is not soon enough in the process.
    Steve
    github.com/torvista: Spanish Language Pack, Google reCaptcha, Structured Data, Multiple Copy-Move-Delete, Image Checker, BackupMySQL Admin/Auto...

 

 

Similar Threads

  1. Replies: 1
    Last Post: 2 Feb 2014, 04:45 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