Developer forum

Forum » Development » Reccuring orders questions

Reccuring orders questions

Alexandru Aliu
Reply

Hey guys,

I have a customer that uses Recurring orders feature and I need to add some functionality. Wonder if anyone knows what is the purpose of "RecurringOrderLastDelivery" field in the table [dbo].[EcomRecurringOrder] 

I know the name is explinatory, but I would like to know a little bit more about how the field is used by the core functionality. Does this field affect somehow the generation of new orders ?


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply
This post has been marked as an answer

I looked in the source code and it seems it's set by RecurringOrdersScheduledTaskAddIn, the scheduled task that creates recurring orders:

foreach (RecurringOrder recurring in RecurringOrder.GetRecurringOrdersForScheduling())
{
    try
    {
        Order order = Ecommerce.Services.Orders.GetById(recurring.BaseOrderId);
        if (order is object)
        {
            //Logger.LogGeneral("Recurring Order", "Creating recurring order based on orderID: " + order.Id)  'TODO: Fix logging in general
            OrderManager oManager = OrderManager.GetFor(order);
            oManager.Recurring();
            recurring.LastDelivery = recurring.NextDelivery;
            recurring.Save();
            //Logger.LogGeneral("Recurring Order", String.Format("Recurring order process succeeded for order with orderID: {0}. Delivery date is {1}, next delivery {2}", order.Id, recurring.LastDelivery, recurring.NextDelivery))  'TODO: Fix logging in general
        }
        else
        {
            //Logger.LogGeneral("Recurring Order", String.Format("Creating recurring order based on orderID: {0} is failed - order was deleted.", recurring.BaseOrderID))  'TODO: Fix logging in general
            result = false;
        }
    }

 

It's also used to calculate the next and future delivery dates inside RecurringOrder which are then shown in the UI for a recurring order:

So yes, it seems it's being used to determine when the next order is placed, based on that date and the recurence frequency and unit (i.e. ever 7 days, 1 month and so on).

 

Imar

 

Votes for this answer: 1
 
Alexandru Aliu
Reply

Thank you, after some more investigation I realized that the field that I have to use is OrderShippingDate

 

You must be logged in to post in the forum