I am using Ubercart in a very perverse fashion. I am building a product registry database where suppliers post products and add multiple environmental/sustainability claims to that product. The product are not what's going into Ubercart. We are using Ubercart to store 3 assessment fees, a base fee for the product, a fee to assess each claim, and a renewal fee for claims already investigated.

So we're using Ubercart in reverse to its design. I am modifying the shopping cart and checkout views to display the product/attributes being served rather than the services, which is of more interest to the suppliers who are paying for them. I am modifying the shopping cart view to tap into an external table, when I realized to my dismay there is no way to link a shopping cart item to individual product/attributes.

I also have to sort the cart items with attributes under their parent product.

I'm going to modify the table, probably adding a column to link to the external table we are managing. But I realized it would be insanely useful if you can add a primary key to your cart, so that other tables may link to line items, and people can unobtrusively use Ubercart in perverse fashion as well.

Sound like a good idea?

Thank you.
Paul Wolborsky
paul.wolborsky@gmail.com

Comments

rszrama’s picture

Status: Active » Postponed (maintainer needs more info)

Hey Paul,

Thanks for your explanation and idea. I'm having a little difficulty conceptualizing your problem / solution. It seems like you need the product in the shopping cart to be linked to data in an outside table that will actually be used for display in the cart? Is this data that needs to be in an external table? For example, could it be made a part of the product's data array through hook_add_to_cart_data()?

Something I've done before is stored in the data array the key that links the product to other data and used hook_cart_item() with the load $op to grab the data when the cart is loaded. Obviously, for direct queries this is a little difficult, since I guess you'd be joining based on a value in a string... not the most helpful.

Anyways, as far as adding a primary key goes... I'm not sure what that would look like. It probably won't happen in D5, due to the nature of the request, which is why I'm exploring alternatives with you. I wouldn't be opposed to it in principle for D6 as we're still in development. I'd just want to see if that's really the way to go.

rszrama’s picture

Version: 5.x-1.6 » 6.x-2.x-dev
Status: Postponed (maintainer needs more info) » Postponed
rfay’s picture

Status: Postponed » Needs review
StatusFileSize
new2.79 KB

Here is a patch that adds the primary key (requires update.php to be run). It also adds functions to get a single item from the cart and to update a single item in the cart.

Please don't forget to run update.php after installing this patch

rfay’s picture

StatusFileSize
new2.85 KB

Here's an improved patch that checks in uc_cart_get_item() to make sure the item was found in the table, returning NULL if it didn't.

Island Usurper’s picture

Status: Needs review » Fixed

I was a little concerned that the columns wouldn't be populated correctly when it was added, but now that I see it does work, it makes sense that it does.

Thanks, Randy. Committed.

Status: Fixed » Closed (fixed)

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