We made a design decision early on to dynamically calculate things like price and weight for items in the shopping cart to avoid having stale data in cart items. Through an IRC conversation today it came to my attention that the attributes module doesn't follow this design when it comes to the storage of adjusted SKUs. The SKU is stuffed into $item->data when the item is added to the cart, and any time that item is loaded, $item->model will be updated to $item->data['model']. If the adjusted SKU for that product + options were to change, the change would not be reflected on that product.

Without rewriting our data model at this point, I propose the simplest solution I can imagine... add a nodeapi check when a node is saved to see if there are any uc_cart_products for that nid and update their data arrays accordingly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rszrama’s picture

Actually, duh, this would have to be on whatever form it is that updates adjusted SKUs or could cause them to be reset, not through hook_nodeapi(). Also, Damien Tournoud pointed out that we could alternately move the logic from uc_attribute_add_to_cart_data() to uc_attribute_cart_item() to calculate the current adjusted SKU. Per his advice, the performance hit of that extra query would be negligible since 1) we only really need to run the query when we know a cart item has attributes and 2) MySQL query cache will take care of repeated queries. This solution would be even less code intensive, and I should've picked up on it the first time. ; )

Island Usurper’s picture

Status: Active » Needs review
FileSize
3.21 KB

Yeah, I think the code makes more sense this way, too.

rszrama’s picture

Issue tags: +Release blocker
Island Usurper’s picture

Found a mistake where the adjusted model number wasn't being applied to the cart item correctly. Patch corrects this.

I've also noticed that the technique used here doesn't work for customers who are already at the checkout review step. If they complete checkout, their order will still have the old adjusted SKU. Considering that any old orders will also have the old model number as well, I don't see this that big of a problem. I also don't think customers spend a lot of time on the review page, so it's not like fixing this will solve that many problems.

Island Usurper’s picture

Status: Needs review » Fixed

Talked to Ryan about that limitation, and he agreed that it's not a big deal.

Committed.

Status: Fixed » Closed (fixed)
Issue tags: -Release blocker, -ubercamp sprint

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