Site maintenance: Sun 15 Nov, from 12:00 UTC, about 4–6 hours. Details

This cutover relies on some testing that is still incomplete so may be cancelled at short notice

Forums / General Questions / a question about shoppingCart->contents[$key] for products with attributes

a question about shoppingCart->contents[$key] for products with attributes

Locked

Started by brandan on 2 May 2008, 6:25 PM · Views: 867

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
2 May 2008, 6:25 PM
#1
brandan avatar

brandan

New Zenner

Join Date:
Aug 2007
Posts:
11
Plugin Contributions:
0

a question about shoppingCart->contents[$key] for products with attributes

i've noticed in the shoppingCart object that the key for products with attributes stored in they contents array seem to be the product id followed by what appears to be an md5 hash. it almost looks like a salted hash.

can anybody elaborate on the process to generate this information? i need to store some items in the shopping cart from a custom form, but it doesn't look like i'll be able to do it properly without this information.

thanks in advance.

2 May 2008, 9:31 PM
#2
brandan avatar

brandan

New Zenner

Join Date:
Aug 2007
Posts:
11
Plugin Contributions:
0

Re: a question about shoppingCart->contents[$key] for products with attributes

hmm, i guess the question i'm coming to form is do i really need the md5ed attributes if i simply create items that don't HAVE any attributes?

even if i discover that i do not, though, my curiosity is killing me. i've found references to zen_get_prid in shopping_cart.php, and the second argument for that function is $attributes, but the way $attributes is formed in add_cart() doesn't really illuminate anything for me.

i suppose the actual hash is arbitrary, so long as all the products have a good amount of detail in what is actually hashed. so if the attributes are, say, color and size, then i'd want to pull those attributes from the database, store them in an array with a consistent key => value scheme, and that will help to determine whether items with similar product ids should increment the quantity or be added the list separately because they have different attributes.

for the project i'm working on, i don't think i'll need to worry about the prid with the hashed attributes, but i'm still not satisfied. :(

3 May 2008, 9:42 AM
#3
chuck avatar

chuck

Totally Zenned

Join Date:
Jul 2005
Posts:
255
Plugin Contributions:
0

Re: a question about shoppingCart->contents[$key] for products with attributes

I've not studied the hash code, but I do know that the attribute details only store the numbers of the values selected when the product was added to the cart. The numbers correspond to the option names+option values pairs applicable to the product.
I would guess that any attribute information you add that's unrelated to already-defined option name/value details is gonna be lost during later stages unless you find some other way of storing something that those numbers could relate to?