Reputation: 323
This function generate_cart_id()
not working. Oscommerce after updating PHP version 5.6 to 7.2.
File: catalog/includes/classes/shopping_cart.php
function generate_cart_id($length = 5) {
return tep_create_random_value($length, 'digits');
}
Upvotes: 0
Views: 54
Reputation: 3
try this function, we use it for our oscoommerce templates on php 5.4 - 7.4:
function tep_create_random_value($length, $type='mixed') {
if (($type!='mixed') && ($type!='chars') && ($type!='digits'))
return false;
$rand_value='';
while (strlen($rand_value) < $length) {
if ($type=='digits') {
$char=tep_rand(0, 9);
}else {
$char=chr(tep_rand(0, 255));
}
if ($type=='mixed') {
if (preg_match('/^[a-z0-9]$/i', $char))
$rand_value.=$char;
}elseif ($type=='chars') {
if (preg_match('/^[a-z]$/i', $char))
$rand_value.=$char;
}elseif ($type=='digits') {
if (preg_match('/^[0-9]$/', $char))
$rand_value.=$char;
}
}
return $rand_value;
}
Upvotes: 0