You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently, the OrderInterceptor allows implementors to run checks before order mutations are committed. However, the willAddItemToOrder function does not have visibility into the Order nor OrderLine.
Describe the solution you'd like
Introduce a new function, similar to willAddItemToOrder, that runs at a later stage of the process, after an item has been added to the order (but not yet committed). This function should:
Provide access to the OrderLine with a valid id within the current context.
Allow implementors to reject the mutation by returning a string, throwing an error, or using a similar mechanism.
Trigger a rollback of the transaction if the mutation is rejected.
This additional functionality would enable more complex validations and use cases by allowing checks based on the newly added OrderLine.
Describe alternatives you've considered
We initially implemented a bundle-like concept by overriding Shop API mutations. This approach gave us access to the Order (via activeOrder) and the bundle's OrderLine, allowing us to manage relationships between bundle products and their child items. However, this solution is limited to the Shop API and does not leverage OrderInterceptor functionality.
We also considered extending this approach to the Admin API by overriding draft mutations, aiming for a solution where both Shop API and Admin API would implicitly handle child items. However, after learning about OrderInterceptors, we paused our implementation to explore whether they could provide an alternative.
Additional context
In our current implementation of bundles:
We tie child items to their parent (the bundle product).
The relative quantities of child items are maintained by noting how many are required for a single bundle and scaling accordingly (e.g., after add, adjust, or remove operations).
We reject shop-api attempts to mutate the child items directly.
The proposed enhancement to OrderInterceptor could make our implementation more clear and maintainable.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Currently, the
OrderInterceptor
allows implementors to run checks before order mutations are committed. However, thewillAddItemToOrder
function does not have visibility into theOrder
norOrderLine
.Describe the solution you'd like
Introduce a new function, similar to
willAddItemToOrder
, that runs at a later stage of the process, after an item has been added to the order (but not yet committed). This function should:OrderLine
with a validid
within the current context.This additional functionality would enable more complex validations and use cases by allowing checks based on the newly added
OrderLine
.Describe alternatives you've considered
We initially implemented a bundle-like concept by overriding Shop API mutations. This approach gave us access to the
Order
(viaactiveOrder
) and the bundle'sOrderLine
, allowing us to manage relationships between bundle products and their child items. However, this solution is limited to the Shop API and does not leverageOrderInterceptor
functionality.We also considered extending this approach to the Admin API by overriding draft mutations, aiming for a solution where both Shop API and Admin API would implicitly handle child items. However, after learning about
OrderInterceptor
s, we paused our implementation to explore whether they could provide an alternative.Additional context
In our current implementation of bundles:
add
,adjust
, orremove
operations).OrderInterceptor
could make our implementation more clear and maintainable.The text was updated successfully, but these errors were encountered: