Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Additional information about each item in shopping cart View modes: 
User avatar
Member
Member
devex++ - 2/20/2011 11:01:47 AM
   
Additional information about each item in shopping cart
Good evening,

I´m creating webpage with sport prizes. I have done all about e-commerce, but one thing is remaining. I have founded about that for one week but found only informations, which I don´t understand very vell. (http://devnet.kentico.com/docs/ecommerceguide/index.html?developing_custom_dialogs_for_checkout.htm).

My problem: I would like to create one more ShoppingCart step. In this step will be showed all items from shopping cart. And foreach item will be user able to write a specific note.

I really need this, becouse on the sportcups are plates with informations and these informations I need to reach from our customers!

Thank you for answers!
Phil

User avatar
Kentico Support
Kentico Support
kentico_radekm - 3/24/2011 11:04:39 AM
   
RE:Additional information about each item in shopping cart
Hello.

At first, we will support this in upcoming version 6.0, so there will be no need of customization then.

Currently, you would need to customize it to reach this behavior. You can develop a custom shopping cart step, according to link you already know, or modify existing step, add this TextBox into given template and ensure logic in code-behind. For example, you can add it into existing \CMSModules\Ecommerce\Controls\ShoppingCart\ShoppingCartContent.ascx step.

Currently, you can see „Units“ TextBox in “Add some products to the shopping cart“ step, allowing you to add number of items and update shopping cart. You can do something similar, just for another TextBox, called e.g. „Custom text. “

It will behave as „Units“ TextBox and it will save value, inserted within, into a OrderItemCustomData of given OrderItemInfo object.

This can be ensured in ShoppingCartContent.ascx.cs, in btnUpdate method, and you can take an inspiration from following code (used for other TextBox – Units):

// Get number of units
int itemUnits = ValidationHelper.GetInteger(((TextBox)(row.Cells[6].Controls[1])).Text.Trim(), 0);
if ((itemUnits > 0) && (cartItem.CartItemUnits != itemUnits))
{
// Update units of the parent product
cartItem.CartItemUnits = itemUnits;
if (!this.ShoppingCartControl.IsInternalOrder)
{
ShoppingCartItemInfoProvider.SetShoppingCartItemInfo(cartItem);
}
}


You will have string variable, instead of integer, and you will use „GetString“ method instead of „GetInteger, “ like

string sCustomText = ValidationHelper.GetString(((TextBox)(row.Cells[6].Controls[1])).Text.Trim(), 0);


Also, you need to use proper cell number (not 6), so you will need to debug it to see what is the correct number of the given cell.

Also, you need to update given OrderItemCustomData instead of cartItem.CartItemUnits.

Second thing is how to show what has been added. You can put it into invoice via macro, or you can add additional column into given template. This can be done on ShoppingCartContent.ascx directly, where template is defined.

You can add a new template like:

<asp:TemplateField HeaderStyle-Wrap="false">
<ItemStyle HorizontalAlign="Right" />
<HeaderStyle HorizontalAlign="Right" Width="80" />
<ItemTemplate>
<asp:Label ID="lblCustomText" runat="server" Text='<%# MyCustomData()%>' EnableViewState="false" />
</ItemTemplate>
</asp:TemplateField>


Where MyCustomData is method, defined in your code-behind, which will return proper value from OrderItemCustomData. You can define this method in code-behind like:

  protected static string MyCustomData(object parameter)
{
// return ... ;
}


You can take an inspiration from IsProductOption method.

Please note this customization is up to you, as it is not currently supported in standard solution. Other option is to wait for version 6.0, like I mentioned. Thank you.

Best Regards,
Radek Macalik