Skip to content

[SalesRule] Extend Applied SalesRule stored in Order with additional values #4675

@Hanmac

Description

@Hanmac

Is there an existing issue for this?

  • I have searched the existing issues

Description

Problem:
sales/order->appliedRuleIds and sales/order_item->appliedRuleIds
might store the rules ids, but not enough info for me to use.
discount_description only has full names, but i need separate data.

I need for each applied rule:

  • Name (StoreLabel)
  • Amount
  • If percent based, I need the Percent and the BaseAmount
  • (Tax? If they are based on one Order Item? Should be the same?)
  • Possible Extra fields that can be extended later (I would like to add a DiscountReasonCode)

For this to work, i would need to rewrite some of Mage_SalesRule_Model_Validator,
it is too deep in the process function, so i can't just extend it.
salesrule_validator_process is too much before the correct values are calculated/rounded and the correct percent is used.

I need the same info for shipment too. (for shipment-tax, I will make an extra issue)

I think in a first attempt, I could try to add just a simple Event inside the each-rule-loop?

Expected Behavior

I would like to have on the OrderItem a serialized, or JSON data array
And on the Order for Shipping too

I would need the Data to be persistent, even if the SalesRule gets deleted

Benefits

If the Code gets updated, more events could be added

Anything else?

I would like this Data for EN16931

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions