I have an old order system in symfony that has the In-Cart array something like this:
    Array
(
    [333] => Array
        (
            [product] => Product Object (...)
            [qty] = 1
            [criteria]
        )
)
Where 333 is the product id thats already in the cart + its characteristics.
Now the problem comes when lets say the user adds into the cart the same product but with a different criteria.
I made something like this to differentiate:
if((array_key_exists($product->getId(), $products)) AND ($products[$product->getId()]['criteria'] == $criteria))  
     {
       $products[$product->getId()]['qty'] = $products[$product->getId()]['qty'] + $qty;  
     }else{
 // todo == I can't find any solution to this :(
}
What above does is:
- checks for the product id already being in the cart 
- checks if criteria sent matches with the one already in the cart 
- if true true => adds quantity to the In-Cart product 
As you can probably already tell , if the user would add THE SAME product with different criterias , it would end up in the else.
Resume: How can I have a key with the same ID in the same array but with different values?
Any ideas would be appreciated.
Thank you!
 
    