Manipulate the order status (completed, delivered, etc.) in code.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
Hi.

I have a payment plugin that periodically checks if payment has been made by using a task. If it detects that a payment has been made I want it to be able to change the status of a specific order. How would I go about doing that?

In the OrderController I see this:
order.OrderStatusId = model.OrderStatusId;
_orderService.UpdateOrder(order);


Will that run all the code that follows changing the status. Like sending emails and such?
4 years ago
check this one

_orderProcessingService.MarkOrderAsPaid(order);
4 years ago
New York wrote:
check this one

_orderProcessingService.MarkOrderAsPaid(order);


Yes exactly.
Found it just now.
Thanks for the answer though.
I should have looked a tiny bit harder. :)
4 years ago
New York wrote:
check this one

_orderProcessingService.MarkOrderAsPaid(order);


Seems like this does not do anything else than mark the order as paid with a little bit of checking if it can be marked paid or not. I need it to do everything that happens when you mark it manually.

Where is that done?
4 years ago
You should debug, set breakpoint, step through code.

That method will call other methods that should do email, etc. but there are conditions (e.g. order amount > $0)
4 years ago
New York wrote:
You should debug, set breakpoint, step through code.

That method will call other methods that should do email, etc. but there are conditions (e.g. order amount > $0)


I did just that and I found that in the OrderProcessingService.cs CheckOrderStatus method there is a method that is called depending on the status of the order. Method name is SetOrderStatus and it takes a parameter that is called NotifyCustomer. The thing is, it is hard coded to false. But I think I did get a notification when I manually set the order to paid. This is getting weird.
4 years ago
Okay. I think I found what was wrong.
At least it looks like the method is trying to send notifications in the last part of the MarkOrderAsPaid method where it calls ProcessOrderPaid method. But you have to have the Message Templates for those notifications active for it to send it, of course. I did not have them active (those default to inactive for some reason).

Regards
4 years ago
They are not enabled because normally you send an email when the order is placed. Then another email when the order is completed i.e. paid and then shipped.

You can enable the order paid email but depends how how many emails you want to send the customer. If paying by credit card then they will get the placed and paid emails at the same time (hence Paid is Disabled)

The normal workflow for the status and hence when the emails are sent is:
Order in Placed Status -> Pending
Order is Paid (Marked as Paid) Status -> Processing
Order is shipped and Delivered (Or shipping not required) Status -> Completed
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.