Forums / Bug Reports / [Done v1.3.9] Incorrect calculation of uprid (unique product ID with attributes)

[Done v1.3.9] Incorrect calculation of uprid (unique product ID with attributes)

Locked

Started by more_solutions on 22 Jan 2009, 11:25 AM · Views: 2,031

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
22 Jan 2009, 11:25 AM
#1
more_solutions avatar

more_solutions

New Zenner

Join Date:
May 2006
Posts:
23
Plugin Contributions:
0

[Done v1.3.9] Incorrect calculation of uprid (unique product ID with attributes)

ZenCart 1.3.8

The function zen_get_uprid (includes/functions/functions_general.php) should create a unique product ID for a given set of attributes. It is the MD% hash of a string similar to this:
1234{31}2890{357}2897{txt_328}Test2{txt_329}{11}75
.. where 1234 is the product ID, followed by {attribute_ID}attribute_value pairs.

The problem comes when the attribute is specified as an array (I haven't explored when this happens). The code which handles the array differently then breaks out of the main loop preventing any further attributes from being affecting the uprid.

The problem code is:

       while (list($option, $value) = each($params)) {
        if (is_array($value)) {
          while (list($opt, $val) = each($value)) {
            $uprid = $uprid . '{' . $option . '}' . trim($opt);
          }
          break;
        }
        //CLR 030714 Add processing around $value. This is needed for text attributes.
        $uprid = $uprid . '{' . $option . '}' . trim($value);
      }

The fixed code is:

      while (list($option, $value) = each($params)) {
        if (is_array($value)) {
          while (list($opt, $val) = each($value)) {
            $uprid = $uprid . '{' . $option . '}' . trim($opt);
          }
        } else {
        //CLR 030714 Add processing around $value. This is needed for text attributes.
	        $uprid = $uprid . '{' . $option . '}' . trim($value);
	    }
      }
22 Aug 2009, 7:12 PM
#2
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,933
Plugin Contributions:
3

Re: [Done v1.3.9] Incorrect calculation of uprid (unique product ID with attributes)

Hi

Thanks for posting. This looks like it fixes a bug involving upload attributes and checkboxes.

see http://www.zen-cart.com/forum/showthread.php?t=135364

Ajeh is currently testing this.

Once again, thanks for the heads up.