[eluser]BnoL[/eluser]
Hello everyone,
I'm using CI Cart library for my shopping cart project and I findthis:
file: system/libraries/Cart.php
Code:
// We now need to create a unique identifier for the item being inserted into the cart.
// Every time something is added to the cart it is stored in the master cart array.
// Each row in the cart array, however, must have a unique index that identifies not only
// a particular product, but makes it possible to store identical products with different options.
// For example, what if someone buys two identical t-shirts (same product ID), but in
// different sizes? The product ID (and other attributes, like the name) will be identical for
// both sizes because it's the same shirt. The only difference will be the size.
// Internally, we need to treat identical submissions, but with different options, as a unique product.
// Our solution is to convert the options array to a string and MD5 it along with the product ID.
// This becomes the unique "row ID"
if (isset($items['options']) AND count($items['options']) > 0)
{
$rowid = md5($items['id'].implode('', $items['options']));
}
else
{
// No options were submitted so we simply MD5 the product ID.
// Technically, we don't need to MD5 the ID in this case, but it makes
// sense to standardize the format of array indexes for both conditions
$rowid = md5($items['id']);
}
So what happen if there is an array inside the
$items['options'] ->
error! ; $items['options'] cannot be an multi-dimensional array.
In my opinion, I find it very inconvenient because we can not implode() or md5() a multi-dimensional array; and it would be much useful if arrays are allowed to use.
Any solution for this?
Best regards,
BnoL