A powerful feature in DotNetMushroom RAD is the facility to build an e-shop 'out of the box'. Since RAD is a development tool, this means that you can build the e-shop customised to your needs. To build an e-shop you need to follow the following steps:
- Create the nescessary table for the Items which will be sold throught the e-shop
- Create the nescessary tables for the Cart which will contain the order of the client. The cart is divided into 2 tables: the cart header, which will contain information such as delivery address, etc; and the cart lines, which will contain the actual items that are being ordered.
The basic fields for the Items table are:
|Code||Optional. The code of the item.|
|Description||The description of the item. This is required so that the user know what is being ordered in the cart.|
|Price||The price of the item.|
The basic fields for the Cart Header are:
The basic fields for the Cart Lines are:
|dnm_HeaderFk||A field of type Relation (Foreign Key) which will contain a link to the Cart Header Table's primary key.|
|dnm_ItemFk||A field of type Relation (Foreign Key) which will contain a link to the Items Table's primary key.|
|Qty||Will contain the quantity of the items being ordered in this transaction|
|Description||Will contain a copy of the description of the item being ordered. While we are keeping a foreign key to the Items table we are still copying the description of that item, to be faster when displaying the cart as well as to keep history of the actual item description at the time of order - should it be changed in the future.|
|Price||The price of the item, kept since the item's price may change in the future.|
After creating the nescessary form by which the user will add the items in the table, the next form that we need to create is the item list which the user will use to add items to the cart. So create a form, set the datasource as the items table. Save the form, and then generate a View Form Template. Add a button, say, let's name it btnAddToCart.
The item list form template
In the form properties, set the 'Form Cart & Wish List Data' section with the following values:
|Cart Data Source||Select the cart lines table|
|Cart Header Data Source||Select the cart header table|
|Items Data Source||Select the items table|
|Cart Quantity Field||Select the name of the quantity field in the cart lines table|
Form Cart Section
Set also the properties for the following controls:
|Control Name/Type||Property Name||Value||Description|
|Description Control||Cart Source||Description field||We are instructing the Add To Cart control to get the description value from items list and save it to the description field in the cart lines.|
|Price Control||Cart Source||Price field||We are instructing the Add To Cart control to get the price value from items list and save it to the price field in the cart lines.|
Set the 'Button Event' of the btnAddToCart button to 'Add to Cart'. Set the 'Button Text' to 'Add to Cart'.
Running The Form
If you now run the form you will get a list of items in the database. If you click the 'Add to Cart' button RAD will add the selected item into the cart.
Add to cart...
Check manually by checking the SQL table 'Cart Lines', which in SQL will be named something like tb_DNM_X_CartLines, where X is your application id.
Checking the cart lines in the database table
The next steps will be to display the cart and then use the check out button.