Hesistant about adding this here because I'm not 100% sure if this issue is by design, an issue with customizable products or with Drupal Commerce. Feel free to close or move if not relevant
Problem: Updates to custom line item fields and removing custom line items from the order during the execution of rules on events "Calculating product sell price" and "After updating an existing line item" are overwritten after the rule is executed, despite the fact that no further rules are executed and there are no custom hooks.
Versions: Drupal 7.20, Rules 7.x-2.2, Drupal Commerce 7.x-1.5
Steps to reproduce:
- Create a custom line item with a custom integer field
- Create a rule that executes on "Calculate sell price" and updates the custom field value using "set data value" (include entity has field condition)
- Update the shopping cart view to show the custom field (or use php eval to echo the field value before and after)
- Add custom line item to cart
Result: If you exit() immediately after rule execution you will see that the update has occurred and the new value is saved in the database. By the time the page has finished loading the value has reverted to the old value, despite there not being any additional code/rules referring to this field.
Also:
- Create a custom line item with a custom integer field
- Create a rule that executes on "After updating an existing line item" and removes the line item from the line-item:order:commerce-line-items list and the site:current-cart-order:commerce-line-items lists (include entity-has-field condition)
- Add custom line item to cart
Result: When the cart loads, if the only line item in the cart was the line item that was removed, the cart will show as empty, but on refreshing the page the line item is back in the cart. If there are multiple products in the cart, the line item will not be removed at all.
I have checked rules debugging and ensured these rules are the last to be executed, so no other process is interfering.
Also: If I try to delete the custom line item entity on either of these events I received an entity metadata wrapper exception about the parent data structure not existing when trying to calculate the cart total.
Can anyone help, or at least let me know what might be happening? I understand that using a debugger would help but they are very difficult to get working properly in my environment. Happy to provide any additional info required.
Comments
Comment #1
crustovich CreditAttribution: crustovich commentedI can confirm that this seems to be a bug with the "set data value" for a custom Field.
With a "show a message on site", I can confirm that the correct value has been set, but the checkout cart shows the default value for the custom field.
I have tried setting the custom field as an integer, a text field and a decimal number, all with the same result.
Comment #2
maxplus CreditAttribution: maxplus commentedHi,
I have the same issue, custom fields in line items that are set during a price calculation rule are not saved of overwritten...