Shipping Plugin

1 Introduction

This document is a guide for developers to the shipping plugins of GrandNode.

Before you start reading this, I advise to look upon ShippingPoint Plugin and notice yourself major differences in plugin structure before I explicitly figure them out beneath.

The easiest/fastest way to make new Shipping Plugin, is to get already working ShippingPoint Plugin, and modify some parts* of it (that need to be changed in order to get target effect).

Besides Controller, the rest of classes inside plugin is pretty typical for plugins, so you should focus only on Controller and its Views.

2 The Admin Part

You can make Shipping Plugin by inheriting BasePluginController.


The main change is here. All shipping plugins will need implement


Controller will implement basic CRUD operations and custom Actions and Methods depending on your logic.

I hope  below picture will make Controller structure more clear.


The first place where you should start writing your own code is admin configuration panel and GET Configure() Action Method.


Configure() can return one prepared ViewModel or, if you have many shipping options – a List<SelectListItem> for DropDownList.

In this case (many shipping options), Configure() returns Confiugre.cshtm


And then, inside Configure.cshtml, a script (kendo grid) calls the Controller.List() which renders table


The GUI effect, rendered table


3 The User Part

Checkout: 3 section

After installation and enabling plugin, in 3. Shipping Method section will appear new Shipping Method

GetFormPartialView() can return one or more shipping options and FormComboBox.cshtml (you can name it Form.cshtml If there is no DropDownList but only one Shipping Option)


The effect


In this case GetFormPartialView returns List<SelectListItem> and options are rendered inside <select> html tag. Any change in selection will fire function renderShippingOptionInfo()


That will fire ajax request for GetShippingOptionPartialView() that will return one shipping option with matching id

RenderPartialViewToString makes it easy to render model of any type without having to explicitly declare Action’s return type (just declare generic JsonResult)


It is worth to notice, that many essential for user information (look at price) are assigned inside GetShippingOptionPartialView()


Shipping Option will be displayed in simple manner (only provide basic information)


The  GUI effect


You may notice that GetShippingOptionPartialView() isn’t declared in BaseShippingController, because plugins may vary – some plugin can have only one Shipping Option, other will have plenty of them.

It doesn’t make sense to impose many-shipping-options structure.

To clarify it

  •                 one Shipping Option - use only GetFormPartialView() and return directly requested Shipping Option
  •                 many Shipping Options - additionally GetShippingOptionPartialView

GetFormPartialView and ValidateShippingForm are a necessity.

GetShippingOptionPartialView is helpful when you have many Shipping Options.


Checkout: 3 section continue


After submit, the OpcSaveShippingMethod() will be called


The vital piece in CheckoutController.cs is here


ValidateShippingForm() is important method that makes this mechanism work (saving values to database)


‘warnings’ is a collection that contains warning messages – one warning will block plugin’s code from executing


Id is equal to 0? Let’s tell customer that he needs to choose any Shipping Option (it will be displayed to endcustomer)


If collection count is equal to 0, there is nothing wrong with input and Checkout can proceed further


Now, customer’s GenericAttributes needs to be assigned with new values

  •                 SystemCustomerAttributeNames.OfferedShippingOptions,                                  //only if there is more than 1 shipping option
  •                 SystemCustomerAttributeNames.ShippingOptionAttributeDescription,                 //value: customer friendly html string
  •                 SystemCustomerAttributeNames.ShippingOptionAttributeXml,                             //value: serialized xml


If you have more than one shipping option, then OfferedShippingOptions attribute has to be overridden with small change – you need to override your Shipping Method inside OfferedShippingOptions (yes, name inconsistency) with new price of chosenShippingOption.PickupFee


Checkout: 6 section

In 6. Confirm Order information about shipping should be visible and valid for enduser



4 Appendix

*mentioned parts:

  •                                GET Configure()
  •                                POST Configure()                                       //optional, if you have one shipping option
  •                                POST List()                                                 //kendo grid, many shipping options
  •                                CRUD Actions
  •                                GetFormPartialView()                                  //get directly one or indirectly many shipping options
  •                                GetShippingOptionPartialView()                  //when you have more than 1 shipping option
  •                                ValidateShippingForm()                               //validate and then assign Customer.GenericAttribute

In case of many shipping options, View folder can look like this



back to top