eCommerce tips and tricks part 1


David te Kloese

For one of my latest projects I needed to build an eCommerce site using as much out-of-the-box Kentico as possible. Here are some of my tips and tricks on how easy it is to customize the default Kentico solution.

Now I hear you say 'only out-of-the-box usually means: all standard except for this long list of extreme requirements'. Although I must admit I did have to open my Visual Studio a few times to write some custom code, most of my work indeed was 'configuring' Kentico. But even when using default Kentico you can get a long way.
 

Extending objects

There is always need of extra fields, I had to use a custom import for the products (did I mention only out-of-the-box features). But everything was stored in the default Kentico objects.


SKU

Since we had an external source we had to store things like External ID, but also had to add a few boolean flags for some special indications.
You can also alter the default fields. Be careful with changing default Kentico since upgrades could undo your changes. I disabled the price from editing (price is set during import), to be sure no accidental changes are made.


Disable SKU price


Or hide fields they don't use anyway.


Hide default SKU fields

 

Customer

That was just the easy part, now I had to alter the customers. Accounts could be of type Personal, Business or Student. Depending on the account type you needed to enter extra fields like student number or business name. But also fields like mobile phone number.

I created my own Alternative Form for display during the checkout in which I added the 'logic'.



Student Field Visible Condition

 

Address

Next addition was into the addresses, I needed to add extra fields to save house number and possible appendix in separate fields. Once again I created an Alternative Form.

Note: both Shipping and Billing use the same object but have different Alternative Forms.


Note 2: As soon as you complete your order the ShoppingCart object is transferred into the Order object. Same go's for Address which moves to OrderAddress. Kentico is smart enough to see extra fields and look for identical field names in the next object. If it is present Kentico pushes the data in the correct fields.
 

Display custom fields

The SKU fields meant for the Editor are displayed on the Form tab automatically, but if you need them on the website you have to do some more work. If you use the default Kentico Web Parts for displaying Shoppingcart Content you can create your own transformation (don't update the default). You can use a custom field in an ASCX transformation getting it via the SKU object.



Compare Sku Field



For the other objects you have to make sure the Web Parts use the corresponding Alternative Forms.



Setting custom form



Filters
So I used the default Kentico Web Parts for displaying and filtering my products:
  • Smart search dialog
  • Smart Search results
  • Smart Search filters (multiple)
These Web Parts work perfectly together. Hardest part can be to get the Filters working with custom fields. So although I'm filtering my product page types, they are representing SKU's. So the SKU properties will be indexed as well.

Make sure you first set your custom fields to be indexed. You can do this by going to the Modules application, selecting the SKU in the Classes tab. Next go to the search tab and configure by your needs. (I usually click the 'set automatically' button to see what Kentico advises based on the field type. Don't save, just refresh and only change the fields you need). Make sure to rebuild your search index and you're good to go.

So back to our filter Web Part. Now that the field is indexed you can add it to the Values field. This field may contain a record each line.
  • start with a + (plus sign) to ADD matching records to the results
  • start with a - (minus sign) to REMOVE matches to the results
Next you'll start with the field name, followed by the value (cast if needed). Finally you can enter a user friendly display name.



Filtering Condition Custom SKU value



In my next post I'll continue with status mails, Tax issue, conditional payment methods and translations. This might involve some minor (not-out-of-the-box) code!