Developer forum

Forum » Ecommerce - Standard features » Recurring order with future start date takes order time

Recurring order with future start date takes order time

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

When creating a recurring order with a future start date, the start date takes the current time (of placing the order) into account:

if (DateTime.TryParse(Context.Current.Request["EcomOrderRecurringStartDate"], out dateValue) && dateValue.Year != 2999)
{
  startDate = dateValue.Add(DateTime.Now.TimeOfDay);
}

So, when I create an order at 23:15 today to start tomorrow, the order won't be created until tomorrow 23:15, regardless of the time set in the start date parametyer. This then only sends it to the ERP at that time which means it can be far too late to be processed that day.

Is there a way to force the time to midnight of the start date or to some other time? And if not, could that be added? The simplest approach seems to let the variable EcomOrderRecurringStartDate define the time which is then used as-is. Or maybe on the Place Recurring Orders scheduled task we can have an option to include all orders for today regardless of their time of day? I guess that last option would also mean changes to GetFutureDeliveriesList somehow to ignore the time portion there when calculating future deliveries,

Thanks!

Imar

 


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

I am not keen on changing calculation of the next delivery date as that could cause change in behavior.

But we could do like this which should only set the time if not specified in the EcomOrderRecurringStartDate

if (DateTime.TryParse(Context.Current.Request["EcomOrderRecurringStartDate"], out dateValue) && dateValue.Year != 2999)
                        {
                            if (dateValue.Hour == 0 && dateValue.Minute == 0)
                                startDate = dateValue.Add(DateTime.Now.TimeOfDay);
                        }

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Yes please!

 

You must be logged in to post in the forum