Developer forum

Forum » Ecommerce - Standard features » Recurring orders admin

Recurring orders admin

Martin Grønbekk Moen
Martin Grønbekk Moen
Reply

I'm trying to create recurring orders using the API, and not sure if it is the code or the administration interface that is not working as expected.
The version of DW i'm using is 9.6.12.

Look at the attached image, there are no recurring orders in the list, and the "Order status" drop down is disabled, and preset on "Completed orders".
If I look into the DB (see other attachment) there are many recurring orders there, but I can not see any of them in the admin interface.

I create the orders in the same way as described here:
https://doc.dynamicweb.com/forum/ecommerce-standard-features/ecommerce-standard-features/reccuring-orders-using-the-api

Dont know if this way is deprecated, since it is a few years old?

2019-08-01_1053.png 2019-08-01_1055.png

Replies

 
Nicolai Pedersen
Reply

Maybe post your code so we can see how you do it. And try placing a recurring order from the frontend and compare the order table records for the order placed from the frontend and the one created using the API

BR Nicolai

 
Martin Grønbekk Moen
Martin Grønbekk Moen
Reply

We have not setup the scheduled task runner yet, could it be the reason maybe?

 
Martin Grønbekk Moen
Martin Grønbekk Moen
Reply

Found out the problem. The code example I linked to above is not complete.
You have to make sure that you save the "BaseOrderId" on the recurring order after both the recurring order and order is saved.

Like this:

// order is my order object with lots of more info, which is irrelevant for this example
var recurringOrder = new RecurringOrder();
recurringOrder.UserId = userId;
recurringOrder.Interval = interval;
recurringOrder.IntervalUnit = RecurringIntervalUnitType.Months;
recurringOrder.StartDate = DateTime.Now;
recurringOrder.EndDate = DateTime.Now.AddYears(10);
recurringOrder.Save();

order.IsRecurringOrderTemplate = true;
order.RecurringOrderId = recurringOrder.ID;
orderService.Save(order); // Use order service, not order.Save()

// This is the important part, the order.Id has to be written back to the recurring order 
recurringOrder.BaseOrderId = order.Id;
recurringOrder.Save();

Like this it is working :)

 
Nicolai Pedersen
Reply

Good find! Thank you for sharing.

 

You must be logged in to post in the forum