There are a few places where Ubercart assumes that cart items or ordered products have options from uc_attribute.module. These are usually for display purposes, but other modules ought to be able to inject their own data like this. In other words, uc_attribute should behave like a contrib module, even if it is distributed with core.

hook_add_to_cart_data() feels like a step in the right direction, but we didn't follow through all the way.

Comments

Island Usurper’s picture

Status: Active » Needs review
StatusFileSize
new10.81 KB

This patch handles uc_cart so that uc_attribute data is handled more anonymously. uc_order will need some more work.

The patch adds a new hook:

function hook_cart_item_description($item);

$item is an individual item in the cart as returned by uc_cart_get_contents(). It's the same mechanism as hook_cart_display(), since that's where the hook should be invoked. (I was going to put it elsewhere, like the cart block, or the cart pane, but things got hairy and didn't look consistent.)

I set this to review so it would be reviewed. I'll think more about handling uc_order. I think there might need to be a reverse hook_add_to_cart_data() or something.

Island Usurper’s picture

StatusFileSize
new13.17 KB

cha0s made the point that the CSS class for this data should be semantic, and we are not necessarily showing product options any more. So this patch changes .product-options to .product-description.

Island Usurper’s picture

Status: Needs review » Fixed
StatusFileSize
new14.27 KB

The new hook needed some documentation in the hooks.php file, so I've added that in. I'm going to commit it since it won't hurt, even though it might become outdated before too long. We'll see.

Island Usurper’s picture

Status: Fixed » Active

And since that spot in uc_order still needs to be taken care of, this issue is still active.

Island Usurper’s picture

Title: Abstract the use of uc_attribute data out of uc_cart and uc_order » Abstract the use of uc_attribute data out of uc_order
rszrama’s picture

Assigned: Unassigned » Island Usurper
Island Usurper’s picture

Status: Active » Needs review
StatusFileSize
new4.71 KB

Yay! I think I got something that works. And as an added bonus, it fixes a bug that keeps that page from adding the option you want to manually added products.

rszrama’s picture

Status: Needs review » Needs work

There are debug messages in here, including a dpm() call... not even gonna try to test it since I don't have devel. ; )

Island Usurper’s picture

Status: Needs work » Needs review
StatusFileSize
new4.63 KB

I get excited sometimes and forget to clean up my patches. :P

rszrama’s picture

Status: Needs review » Needs work

Patch did not work on the 2.x Livetest - failed to consider attributes at all. Also, need to remove the check module_exists('uc_attribute') from the attribute module.

Island Usurper’s picture

Status: Needs work » Needs review
StatusFileSize
new4.52 KB

Removed the (now silly) module_exists() call, and let attributes that use select elements to be chosen instead of just radio buttons. >_<

Island Usurper’s picture

StatusFileSize
new4.52 KB

One more time, for great justice!

Island Usurper’s picture

Status: Needs review » Fixed

Ryan gave his approval, after it (finally) worked on the livetest site, so it's committed.

Macronomicus’s picture

Yes it works wonderfully, and fixes the bugs I had with the order form attributes behaving very badly! >_<
But what did you commit it to?
I dont see a new beta or dev?
Do I need to look in CVS for the freshest bits?
I applied the patch so I guess I dont need it, but im just curious; where is the latest build is usually lurking? ^_^

Island Usurper’s picture

We usually commit to the Bazaar repository we have first, and then push a bunch of changes to CVS here every so often. Instructions for accessing the Bazaar repo can be found at http://www.ubercart.org/bazaar.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.