ASPX templates
Version 5.x > ASPX templates > Required Date field in Shopping Cart View modes: 
User avatar
Member
Member
James Darlow - 5/17/2011 10:55:41 PM
   
Required Date field in Shopping Cart
Hey Guys!

I need to show a required Date field in the Shopping Cart.

The step is: ShoppingCartPaymentShipping.ascx

.cs code file -
this.SetValue("DateforOrder", txtCardNumber.SelectedDate);

.ascx -

<asp:Label ID="lbltime" runat="server" EnableViewState="false" />
<asp:Calendar ID="txtCardNumber" runat="server" CssClass="TextBoxField" MaxLength="100"
EnableViewState="false" />

User avatar
Member
Member
James Darlow - 5/17/2011 10:57:56 PM
   
RE:Required Date field in Shopping Cart
I have added the field to the System Table - Order

Attribute (DateforOrder)
Type: DateTime

FieldType: Calendar

User avatar
Kentico Support
Kentico Support
kentico_radekm - 5/31/2011 1:23:47 AM
   
RE:Required Date field in Shopping Cart
Hello.

We solved it via e-mail, however I will post the solution here, so it can be used by someone else as well.

This is what I wrote:

In 5.5R2 (or older), you can accomplish it like this.

At first, you need to add custom column in Site Manager / Development / System tables / CMS_Order system table.

Then, you need to save value of your Calendar control into session, so you can get it from within later, when order is created, and save it into DB. This can be done in \CMSModules\Ecommerce\Controls\ShoppingCart\ShoppingCartPaymentShipping.ascx.cs, ProcessStep() method. You can access calendar´s day value via this.CustomCalendar.SelectedDate.Date.ToString(), where CustomCalendar is ID of my calendar control and save it into session via CMS.GlobalHelper.SessionHelper.SetValue(String, Object) method.

Then, you can get in from session via SessionHelper.GetValue(String). You can call this method in /CMSModules/Ecommerce/Controls/ShoppingCart/ShoppingCartPreview.ascx.cs (ProcessStep() method), after order is created.

Then, you need to get proper OrderInfo object via CMS.CMSEcommerce.OrderInfoProvider.GetOrderInfo(int OrderID) method, and use SetValue(“columnName”, value) on it. Like order.SetValue(“columnName”,value), where order is given OrderInfo object, and value is taken from session via SessionHelper.GetValue method.

If someone wants a code example, I can provide it. In this case, please send a message to support@kentico.com and refer to this forum post. Thank you.

Best Regards,
Radek Macalik