Automated Status Change

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
michaewa
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Tue Nov 10, 2009 9:22 pm

Automated Status Change

Post by michaewa » Wed Jul 21, 2010 11:07 am

I've done a bit of digging here on this topic and not come up with anything beyond a modification (which looks great) by AbleMods that is what I would call the super deluxe version of what I'm after.

I created a new status called 'Shipped + 7 Days' and an associated email to go along with it. It sends a note to the customer thanking them for their order, and saying 'by now you should have received your package, etc.'

I know I can't just have a scheduled job change the status in the database as that won't fire the trigger.

Is there any way programatically to update an order's status so that the trigger would be fired? I can't see adding this as a manual task - e.g. having someone log in, find the orders that shipped one week ago, changing their status.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Automated Status Change

Post by mazhar » Wed Jul 21, 2010 11:25 am

Simply call UpdateOrderStatus method on order object by providing it the order status id for your desired order status.

Code: Select all

order.UpdateOrderStatus(1);
Also read following topic it can help you about custom timed events
http://wiki.ablecommerce.com/index.php/ ... med_Events

michaewa
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Tue Nov 10, 2009 9:22 pm

Re: Automated Status Change

Post by michaewa » Wed Jul 21, 2010 8:36 pm

Mazhar -

Thank you very much for the quick reply. I'm not terribly familar with the innerworkings of Able.

If I wanted to query the DB and pull out all order IDs where the shipping status had been set to shipped 7 days prior and then process those orders using the UpdateOrderStatus method, would that be possible? I'm comfortable pulling the data out, I'm just not sure how you would call the routine N times, where N was the number of order records that were returned by the query.

Thanks again,

Andy

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Automated Status Change

Post by mazhar » Fri Jul 23, 2010 5:38 am

It could be something like below, where orderStatusId will be the integer id assigned to your shipped 7 days prior status in ac_OrderStatuses table. Similarly newOrderStatusId will be order status id which you want to assign to your order. You can find this integer value by looking on ac_OrderStatuses table.

Code: Select all

 OrderCollection orders = OrderDataSource.LoadForOrderStatus(orderStatusId);//load by order status id of "shipped 7 days prior"
        
        //ITERATE ON ALL RETURNED ORDERS
        foreach (Order order in orders)
        {
            //UPDATE ORDER STATUS OF EVERY ORDER TO NEW STATUS
            order.UpdateOrderStatus(newOrderStatusId);
            order.Save();
        }

Post Reply