1
Answers
Vote up!
0
Vote down!

Access to the original version of a line item

Hi,

When a commerce order is changed, I can hook into hook_commerce_order_presave to see what happened. Say I want to do something when the line items change.

When a new line item is added, the hook gets called once with:
- an order without line items, and in ->original the old line items
- an order with all new line items

This is manageable.

However, when a line item itself is changed, like when pointing to a new product SKU, the order->original item also refers to the new line item SKU already! Therefore it is impossible to know what the old SKU was, which I also need for my code.

How can I find out the original line item product?

Best regards!

Asked by: Tom M
on September 3, 2014

1 Answer

Vote up!
1
Vote down!

Aha. Via the apparently undocumented hook_commerce_line_item_update($item) where $item->original points to the original.

Answer by: Tom M
Posted: Sep 3, 2014