Hi,
The error is based on "$element->characteristics" not on the variants, my apologize.
Can you try to replace the code:
foreach($element->characteristics as $k2 => $characteristic2){
if(!empty($variant->characteristics)){
foreach($variant->characteristics as $k3 => $characteristic3){
if($k2==$k3){
$temp[$k3]=$characteristic3;
break;
}
}
}
}
To:
if(is_array($element->characteristics){
foreach($element->characteristics as $k2 => $characteristic2){
if(!empty($variant->characteristics)){
foreach($variant->characteristics as $k3 => $characteristic3){
if($k2==$k3){
$temp[$k3]=$characteristic3;
break;
}
}
}
}
}