These events get triggered by WorkflowShoppingCartEvents which implements the IShoppingCartEvents interface. For each you can access the input as a .NET object using the Context workflow input and the serialized version as the JSON workflow input. All of these workflows expect to return one or more outputs which is passed back to the invoking code.
⚠ If you want to return an altered version of the input as the output, please always use the JSON which is already serialized in the expected format used by OrchardCore.Commerce's converters. For example, you can use the JS expression
JSON.parse(input('JSON')).
ℹ When your output contains
LocalizedHtmlString, it can be represented in JS either asstringor{ Name: string, Value: string }. In case of juststringthe same text becomesLocalizedHtmlString.NameandLocalizedHtmlString.Valuetoo.
Executes after the shopping cart data is prepared, but before the shapes are rendered.
- Input:
ShoppingCartDisplayingEventContextobject containing the current shopping cart's headers and lines. - Outputs: either outputs are optional.
- Headers:
LocalizedHtmlStringarray. The shopping cart header labels in order. If you have to support multiple locales, make sure to use the object format mentioned above, becauseLocalizedHtmlString.Nameis used to generate the template name for the corresponding shopping cart column's cells. - Lines:
ShoppingCartLineViewModelarray. This is only for display, in most cases, you shouldn't have to return this output.
- Headers:
Executes before an item is added to the shopping cart to check whether it can be added based on inventory status.
- Input:
ShoppingCartItemobject. - Outputs:
- Error:
LocalizedHtmlStringornull. The error message to be displayed if the input item can't be added to the cart. You can simply not output anything if the validation passes.
- Error:
Executes after the shopping cart content is loaded from the store and before it's displayed or used for calculation.
- Input:
ShoppingCartobject. - Outputs:
- ShoppingCart:
ShoppingCartobject. An altered version of the input. If no changes are necessary, the output can be skipped. Here it's the most important to only useinput('JSON')as mentioned above, becauseShoppingCarthas custom JSON converters inside that will only correctly serialize in .NET code.
- ShoppingCart:
These events are triggered without an expectation of an output. They can be used for other automation.
Executes when a product is added to the shopping cart.
- Inputs:
- LineItem:
ShoppingCartItemobject.
- LineItem:
Executes when an order is created on the frontend.
- Inputs:
- ContentItem:
ContentItemobject of theOrdercontent item that has just been created.
- ContentItem: