This is for a small company and so the workflow means that the store owners will fulfil the order setting the Shipment status to Shipped when they create the shipment. Because the status is set when the Shipment is created the ShipmentService.StatusChanged event is not fired and I get why that is. So, in order to get around this, I subscribed to the ShipmentService.Creating event and check the status there and if it says "Shipped" will trigger the ShipmentService.StatusChanged event. Unfortunately the ShipmentService.Creating doesn't seem to fire.
Am I missing something or does anyone have a different approach?
I remembered that I had a custom task in the OrderPreparationShipmentCreate taskchain and so I've amended it so that it triggers the notification as follows:
I need to spend some time looking at the Created and Creating events on some services - so this does not surprise me. I've found there are inconsistencies between services depending on whether on how things are initially persisted, meaning if the entity is created and then saved or one of the create with key methods are used without a save.
At least I got it to work by other means and to be honest I'm not sure of the advantages or disadvantages of doing this at the moment via an Event handler or using the task chain. The task chain is probably more in keeping with the Merchello way of doing things :)
I am having the same issue as Simon in that I need to be able to trigger the OrderShipped email when shipment is created if the shipment status is Shipped.
We don't have a custom task in the OrderPreparationShipmentCreate task change that I can amend.
Are you able to provide some sample code on how to create a custom task to trigger the notification?
This was pretty much what I adapted for my own purposes and then see the following extract from my class where I trigger the email:
// If we are creating a shipment with a status of Shipped from the outset we want to trigger the OrderShipped notification
if (value.ShipmentStatus.Key == Merchello.Core.Constants.DefaultKeys.ShipmentStatus.Shipped)
{
LogHelper.Info<UmbracoEventHandler>(string.Format("Raising notification trigger for shippment no. {0}", value.ShipmentNumber));
Notification.Trigger("OrderShipped", value, new[] { value.Email });
}
CreateShipment Event doesn't appear to be triggered
We have added an event handler to trigger an email notification when an order status is set to "Shipped".
This is for a small company and so the workflow means that the store owners will fulfil the order setting the Shipment status to
Shipped
when they create the shipment. Because the status is set when the Shipment is created theShipmentService.StatusChanged
event is not fired and I get why that is. So, in order to get around this, I subscribed to theShipmentService.Creating
event and check the status there and if it says "Shipped" will trigger theShipmentService.StatusChanged
event. Unfortunately theShipmentService.Creating
doesn't seem to fire.Am I missing something or does anyone have a different approach?
Thanks, Simon
I remembered that I had a custom task in the
OrderPreparationShipmentCreate
taskchain and so I've amended it so that it triggers the notification as follows:This achieves what I set out to do but would be interested to know why I couldn't do it via the
ShipmentService.Creating
event handler.Hey Simon,
I need to spend some time looking at the Created and Creating events on some services - so this does not surprise me. I've found there are inconsistencies between services depending on whether on how things are initially persisted, meaning if the entity is created and then saved or one of the create with key methods are used without a save.
At least I got it to work by other means and to be honest I'm not sure of the advantages or disadvantages of doing this at the moment via an Event handler or using the task chain. The task chain is probably more in keeping with the Merchello way of doing things :)
Hi Rusty,
I am having the same issue as Simon in that I need to be able to trigger the OrderShipped email when shipment is created if the shipment status is Shipped.
We don't have a custom task in the OrderPreparationShipmentCreate task change that I can amend.
Are you able to provide some sample code on how to create a custom task to trigger the notification?
Hi Lesley,
See the Merchello source for the
RemoveShipmentOrderItemsFromInventoryAndPersistShipmentTask
:https://github.com/Merchello/Merchello/blob/merchello-dev/src/Merchello.Core/Chains/ShipmentCreation/RemoveShipmentOrderItemsFromInventoryAndPersistShipmentTask.cs
This was pretty much what I adapted for my own purposes and then see the following extract from my class where I trigger the email:
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.