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 asstring
or{ Name: string, Value: string }
. In case of juststring
the same text becomesLocalizedHtmlString.Name
andLocalizedHtmlString.Value
too.
Executes after the shopping cart data is prepared, but before the shapes are rendered.
- Input:
ShoppingCartDisplayingEventContext
object containing the current shopping cart's headers and lines. - Outputs: either outputs are optional.
- Headers:
LocalizedHtmlString
array. The shopping cart header labels in order. If you have to support multiple locales, make sure to use the object format mentioned above, becauseLocalizedHtmlString.Name
is used to generate the template name for the corresponding shopping cart column's cells. - Lines:
ShoppingCartLineViewModel
array. 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:
ShoppingCartItem
object. - Outputs:
- Error:
LocalizedHtmlString
ornull
. 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:
ShoppingCart
object. - Outputs:
- ShoppingCart:
ShoppingCart
object. 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, becauseShoppingCart
has custom JSON converters inside that will ony 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:
ShoppingCartItem
object.
- LineItem:
Executes when an order is created on the frontend.
- Inputs:
- ContentItem:
ContentItem
object of theOrder
content item that has just been created.
- ContentItem: