When to send an email for order awaiting approval

Hi,

We are building a flow where certain people should be notified when there is an order that is awaiting approval. When would be the best time to find such orders?

I’m thinking we could either listen to the OrderCreated event and check if it has the tag AwaitOrderApproval, or listen to the event TagAdded and check if the tag was indeed AwaitOrderApproval. Would these work, or should we do it another way?

            // Will the order have the tag here, or could we be to quick on it?
            _eventBroker.Subscribe<OrderCreated>(x =>
            {
                if (_taggingService.GetAll<Order>(x.SystemId)?.Contains(OrderTaggingConstants.AwaitOrderApproval) ?? false)
                    SendOrderApprovalEmail(x.SystemId);
            });
            // Not sure what the events actually contains here
            _eventBroker.Subscribe<TagAdded>(x =>
            {
                if (x.Item == OrderTaggingConstants.AwaitOrderApproval)
                    SendOrderApprovalEmail(x.SystemId);
            });

I have looked at the order approval flow on docs but I am unsure in which order things happen under the hood.

Litium version: 8.17

subscribe to the TagAdded event.

For a more exact AwaitOrderApproval state, it is good to do following:

  • subscribe to the TagAdded event,
  • and then, before sending “SendOrderApprovalEmail”, double-check whether the order status is not “Confirmed”

Thank you, that is how we decided to do. Good to know that it should work that way!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.