spree_flexi_variants icon indicating copy to clipboard operation
spree_flexi_variants copied to clipboard

Order Line Item Adhoc items are mutable

Open nostopbutton opened this issue 11 years ago • 1 comments

I've discovered, what I believe to be, a flaw in the logic for how the adhoc option values for Order line items are stored in the data model (AdHocOptionValuesLineItem).

I plan to look at whether I am able to implement a change in this area, but would appreciate the views of anyone who works with this extension regularly.

The current implementation works by creating a reference link between the order line item and the reference table that stores the adhoc option values. My concern is that the Order, once placed should be self-contained and immutable (unless deliberately adjusted). Unfortunately, the effect of referencing the adhoc option values means that if anyone changes those values in future, the old orders will be affected by the changes.

Screenshot_10_3_13_9_18_PM

e.g.

  • imagine a product with an adhoc "colour" option with values of "01-red" "02-blue" "03-green"
  • an order is placed for a green version of this product, the line item links to "03-green" via references in AdHocOptionValuesLineItem
  • a few day later, someone change the adhoc options for colour -> "03-light green" and "04-dark green" - now if you go to look at the order, it says that the customer chose "light green" which was not even an option.
  • the change / impact could be even more drastic - someone could add a $20 change for light green,
  • deleting values in AdHocOptionValue would break the orders referencing them
  • for old orders, the impact is basically just messing up your historical record - not the end of the world one might say
  • more worrying is if someone changes an option just after an order is place, but before fulfilment takes place - in this case, the customer would likely get something different to the order they think they placed.

A solution to this should be to copy the adhoc option values into a table (such as AdHocOptionValuesLineItem) to make the value immutable to changes reference data in the AdHocOptionValue table.

nostopbutton avatar Mar 10 '13 13:03 nostopbutton

@nostopbutton - Very sorry for the long-delayed response. did you ever come up with a solution? happy to integrate it if you have one.

jsqu99 avatar Nov 08 '13 17:11 jsqu99