hook_cart_item modify value of attribute

Posts: 73
Joined: 12/10/2007

Hi
I want to use hook_cart_item to modify the value of a couple attributes when the item is added to the cart.
hook_cart_item is passed $item, but I can't figure out how to get to the attributes of the item and change a couple of them.

Any help would be appreciated.
Eric

Posts: 9
Joined: 08/27/2007

Are you looking for $item->data['attributes'] ?

Posts: 73
Joined: 12/10/2007

Well I came up with a workable solution, I hooked into add_to_cart_data. Not sure if it is the best way.

It didn't seem like hook_cart_item allowed me to actually change the value of attributes.

Posts: 20
Joined: 01/20/2008

Hi,

I'm developing a module that needs to add a customized item to the cart.

I can get it to add the item and quantity with uc_cart_add_item but I'm not sure how to pass in selected attributes.

Any advice?

Thanks alot!

-Calvin

--

"I've had this birthmark since I was born." --JB

Posts: 21
Joined: 01/06/2008
Uber Donor

Hi Calvin,

You should look into Cart Links as this will allow you to add attributes.

Quinton

Posts: 20
Joined: 01/20/2008

Thanks for the idea, but this isn't quite what I was looking for. My module creates custom attributes on the fly for a specific product called "custom" based on user input. I was able to get my module to add the "custom" product to the cart but wasn't able to include a list of customized attributes.

I have figured that out as of yesterday. It was a matter of passing the correct array to uc_cart_add_item(). To figure that out I waded through a lot of uc core modules to see how they did things.

All is right in the world once again.

--

"I've had this birthmark since I was born." --JB

Posts: 82
Joined: 08/12/2007
Uber DonorBug FinderInternationalizationizer

Hey sleepingmonk.

I'm really interested in your module, cause I'm planning sth similar. Could you contribute it? Would be really nice.

Thanks.
Mic

Posts: 20
Joined: 01/20/2008

Hi Mic,

Unfortunately, at this time the module is written for very specific client needs. I'd have to generalize it and add Admin functions so you could configure it to generate the type of attributes you want. There are currently no Admin Functions, everything is hard coded into the module.

I'm not sure when I'll be able to contribute it but I'll put it on my list of things to do.

-sleepingmonk

--

"I've had this birthmark since I was born." --JB