-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Create base event. * CartLoadedEvent view and driver. * Upgrade HL. * Use new workflow manager extension methods. * bug fix * Update HL and add other events. * Add WorkflowShoppingCartEvents scaffolding. * Update HL again. * Eliminate driver display boilerplate. * Pass workflow output. * Invoke LoadedAsync * Amount can be parsed from string. * Update HL version. * Fix bug where LocalizedHtmlString won't serialize. * Refactor ShoppingCartSerializer.PostProcessAttributes. * Refactor for JSON compatibility. * Fix bug where product display breaks if you have predefined attributes but no variants. * Export JSON rather than base the raw object. * Organize code. * Fix deserialization problem with raw attributes after JS event. * Update HL nuget for NRE bug fix. * JSON and NRE fixes. * fix unit test constructor * Add "product" Liquid filter. * Export as content item instead. * Add samples. * Fix bug where if no default value is provided and nothing is selected before clicking the add button you get an IndexOutOfRangeException. * Move the activities into a separate Startup class. * Add `Workflows` documentation. * Add new doc link in Readme and mkdocs. * Add workflow unit tests. * Spelling. * Member 'GetSkuFromJsonObject' does not access instance data and can be marked as static * Update docs/features/workflows.md Co-authored-by: Szabolcs Deme <[email protected]> * Update docs/features/workflows.md Co-authored-by: Szabolcs Deme <[email protected]> * Add solution item. * Documentation cleanup. * don't use single letter variable name * Simplify. * Remove GetUniqueCartId from IShoppingCartPersistence. * Add ShoppingCartPersistenceBase and scope caching. * Serialization bug fix. * Use AutoMocker to instantiate ShoppingCartController more safely. * Instantiate ControllerContext too. * spelling * Pattern simplification and code cleanup. * typo * Fix mistaken use of Where instead of WhereNot. --------- Co-authored-by: Szabolcs Deme <[email protected]>
- Loading branch information
1 parent
defdc92
commit 9d3aa13
Showing
69 changed files
with
1,244 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ node_modules/ | |
*.placeholder | ||
/.editorconfig | ||
.ps1-analyzer-stamp | ||
*.orig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Workflows | ||
|
||
## Shopping Cart Event Workflow Events | ||
|
||
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 as `string` or `{ Name: string, Value: string }`. In case of just `string` the same text becomes `LocalizedHtmlString.Name` and `LocalizedHtmlString.Value` too. | ||
### "Cart displaying" Event | ||
|
||
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, because `LocalizedHtmlString.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. | ||
|
||
### "Verifying cart item" Event | ||
|
||
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` or `null`. 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. | ||
|
||
### "Cart loaded" Event | ||
|
||
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 use `input('JSON')` as mentioned above, because `ShoppingCart` has custom JSON converters inside that will ony correctly serialize in .NET code. | ||
|
||
## Other Workflow Events | ||
|
||
These events are triggered without an expectation of an output. They can be used for other automation. | ||
|
||
### "Product added to cart" Event | ||
|
||
Executes when a product is added to the shopping cart. | ||
|
||
- Inputs: | ||
- LineItem: `ShoppingCartItem` object. | ||
|
||
### "Order was created" Event | ||
|
||
Executes when an order is created on the frontend. | ||
|
||
- Inputs: | ||
- ContentItem: `ContentItem` object of the `Order` content item that has just been created. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/Modules/OrchardCore.Commerce/Activities/CartDisplayingEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Microsoft.Extensions.Localization; | ||
|
||
namespace OrchardCore.Commerce.Activities; | ||
|
||
public class CartDisplayingEvent : CommerceEventActivityBase | ||
{ | ||
public override LocalizedString DisplayText => T["Cart displaying"]; | ||
|
||
public CartDisplayingEvent(IStringLocalizer<CartLoadedEvent> localizer) | ||
: base(localizer) | ||
{ | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Modules/OrchardCore.Commerce/Activities/CartLoadedEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Microsoft.Extensions.Localization; | ||
|
||
namespace OrchardCore.Commerce.Activities; | ||
|
||
public class CartLoadedEvent : CommerceEventActivityBase | ||
{ | ||
public override LocalizedString DisplayText => T["Cart loaded"]; | ||
|
||
public CartLoadedEvent(IStringLocalizer<CartLoadedEvent> localizer) | ||
: base(localizer) | ||
{ | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/Modules/OrchardCore.Commerce/Activities/CartVerifyingItemEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Microsoft.Extensions.Localization; | ||
|
||
namespace OrchardCore.Commerce.Activities; | ||
|
||
public class CartVerifyingItemEvent : CommerceEventActivityBase | ||
{ | ||
public override LocalizedString DisplayText => T["Verifying cart item"]; | ||
|
||
public CartVerifyingItemEvent(IStringLocalizer<CartLoadedEvent> localizer) | ||
: base(localizer) | ||
{ | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Modules/OrchardCore.Commerce/Activities/CommerceEventActivityBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Lombiq.HelpfulLibraries.OrchardCore.Workflow; | ||
using Microsoft.Extensions.Localization; | ||
|
||
namespace OrchardCore.Commerce.Activities; | ||
|
||
public abstract class CommerceEventActivityBase : SimpleEventActivityBase | ||
{ | ||
public override LocalizedString Category => T["Commerce"]; | ||
|
||
protected CommerceEventActivityBase(IStringLocalizer stringLocalizer) | ||
: base(stringLocalizer) | ||
{ | ||
} | ||
} |
28 changes: 5 additions & 23 deletions
28
src/Modules/OrchardCore.Commerce/Activities/OrderCreatedEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,13 @@ | ||
using Microsoft.Extensions.Localization; | ||
using OrchardCore.Workflows.Abstractions.Models; | ||
using OrchardCore.Workflows.Activities; | ||
using OrchardCore.Workflows.Models; | ||
using System.Collections.Generic; | ||
|
||
namespace OrchardCore.Commerce.Activities; | ||
|
||
public class OrderCreatedEvent : EventActivity | ||
public class OrderCreatedEvent : CommerceEventActivityBase | ||
{ | ||
private readonly IStringLocalizer<OrderCreatedEvent> T; | ||
|
||
public OrderCreatedEvent(IStringLocalizer<OrderCreatedEvent> localizer) => | ||
T = localizer; | ||
|
||
public override string Name => nameof(OrderCreatedEvent); | ||
public OrderCreatedEvent(IStringLocalizer<OrderCreatedEvent> localizer) | ||
: base(localizer) | ||
{ | ||
} | ||
|
||
public override LocalizedString DisplayText => T["Order was created"]; | ||
|
||
public override LocalizedString Category => T["Commerce"]; | ||
|
||
public override IEnumerable<Outcome> GetPossibleOutcomes( | ||
WorkflowExecutionContext workflowContext, | ||
ActivityContext activityContext) => | ||
new[] { new Outcome(T["Done"]) }; | ||
|
||
public override ActivityExecutionResult Resume( | ||
WorkflowExecutionContext workflowContext, | ||
ActivityContext activityContext) => | ||
Outcomes("Done"); | ||
} |
Oops, something went wrong.