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);
}
}