3. Open the project in Visual Studio, you will see that the project contains a class MyService which inherited from RazorCart.Core.ActionPipeline.OnCheckoutComplete and implementing the interface RazorCart.Core.ActionPipeline.IRunAfterAction, that means this MyService method will be triggered just after the Action OnCheckoutComplete finished.
4. The two interfaces IRunAfterAction and IRunBeforeAction both require to have the configuration method of the extension settings implemented: public void Config(List<ExtensionSetting> settings), in this method we can add the extension admin settings page when activating the extension from Admin Console. The extension class properties are pretty similar to the PipelineAction properties:
- ActionID: an integer identity value for the action method, this value will be shown in the Event Viewer if your code throw an exception.
- ActionName: a string value to describe your action name, this will be also display in the Event Viewer if your code throw an exception.
- Execute: this is where you will have your code that to be executed, the parameter context will be passed from the Workflow Actions so you can get the values which were initialized/updated during the workflow.
5. Pipelines that can implement the Extension methods:
- CartPipeline: The cart operation workflow actions, get called when you add an item to the shopping cart.
- CalculatorPipeline: The cart totals calculation workflow actions, get called when calculating the cart totals.
- CheckoutPipeline: The checkout operation workflow actions, get called when the user proceed with the checkout.
6. ExtensionSetting class:
- SettingType: used to determine the setting field type, value can be (Label, TextBox, DropdownList, RadioButtons, CheckBox, MultiLineTextBox, Information, Error, Warning, Hidden, Html)
- SettingLabel: the setting label/title that will be displayed in the front-end.
- SettingName: the setting key/name value as it will be saved, this name shall be used to get the setting value for.
- SettingOptions: a Dictionary<string, string> type, applies only to certain setting types (DropdownList, RadioButtons).
- SettingValue: the default/initials setting value, when using the types (Information, Error, Warning, Label or Html) this well be permanent as the user cannot change the value.
- Required: a Boolean (true/false) type that will set the required HTML field attribute if set to true.
We have included an example with the above project that adds a radio button options and credentials textboxes, those credentials will be used in the example extension to calls a web service:
Building & Deploying
After you build your extension assembly and deploy it to your DNN\bin folder, you will need to activate it from the Store setup, go to the RazorCart Admin-Console > Store Setup > Extensions, check the activate box next to the namespace you have chosen ("Extension.Example.MyService" if you haven't change it) and click save, a configuration icon will appear to setup the extension.
To access the Extensibility Setup page click on the Admin Menu in your DNN portal, then select RazorCart Admin Console:
DNN ≤ 8
From the left-side menu go to Store Setup > Extensions
Activate the Extension and click on the gear icon, this will open a extension settings page that we implemented in the config method, the admin can now save the settings values, and when executing the extension all these values can be retrieved by accessing "context.ExtensionConfig".
Now you have successfully build a RazorCart Extension.Plugin! If you have any questions, please Contact Us.