In Reaction, the
Order schemas are similar but with several key differences. But there are often calculations for taxes, shipping, and such that need to happen for both types of entities, and it can be overly complex to write such calculation functions in a way that takes into account all of the differences between carts and orders.
To solve this problem, we introduced a third entity type, the
CommonOrder, as well as transformations that can convert carts and orders to one or more
The best way to fully understand what a
CommonOrder looks like is to examine its schema. But here's a brief summary:
- Carts and Orders can contain multiple fulfillment groups and items from multiple shops, but a
CommonOrderis limited to just a single fulfillment for a single shop. Roughly speaking, each fulfillment group on a cart or order is converted to one
- Carts have a single list of items while Orders have an item list per fulfillment group. Since a
CommonOrderrepresents just one fulfillment group, it has just one list of items.
CommonOrderhas a limited subset of fields, focusing on order properties that are useful for calculations.
originAddressproperties, if each is known.
CommonOrder.sourceTypeis set to either "cart" or "order", allowing you to check what entity was converted into the
CommonOrderwhen it truly matters. The
orderIdproperties on it, providing a link back to the source entities. (
nullwhen created from a cart and
nullwhen created from an order, if the order was not placed from a cart.)