While products are in cart, attribute information is stored in the $product->data['attributes'] in the form of: '$aid':'value' where $aid is the Attribute Id and 'value' is the currently selected option value.

When creating the uc_order_product, the Attribute Module (uc_attribute_uc_order_product_alter in uc_attribute.module) completely unlinks the attribute information from the original attribute by just storing the label + selected value of attribute.

This is done to make this data persistent and independant form the original attribute configuration (OK!) but information about the original attribute configuration or options are completely lost.

I believe it would be good to preserve detailed information of the original attribute information:

- To allow custom modules to perform complex logic for a specific attribute Name or $aid, this can now be done while product is in cart (a reference to $aid is still available) but not after "uc_attribute_uc_order_product_alter " in uc_attribute.module has executed.

- To have backtrace on what was that attribute's configuration when the customer made the purchase. An attribute can have effect on final price and other things and this information is also lost.

Path attached, sorry for format I still need to get some training on formal contributions.

This aditional data is stored independantly from original data, so the impact on current module's way of working is not impacted.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

longwave’s picture

Status: Active » Needs review

This is the underlying problem in #1880868: "Order has a product with a particular attribute option" is unreliable and comment #8 there describes the findings above. This approach is perhaps a workable alternative to breaking backward compatibility, but it is a shame we can't use the same $data['attributes'] format in both cart products and ordered products.

Status: Needs review » Needs work

The last submitted patch, uc_attribute.module.patch, failed testing.

david_garcia’s picture

Status: Needs work » Needs review
FileSize
1.59 KB

it is a shame we can't use the same $data['attributes'] format in both cart products and ordered products.

Would require too much work + would be backwards incompatible. At least with the provided patch you keep an internal copy of "real" attribute data instead of just "labels".