Trying to wrap my head around Order and Delivery states

Hi,

I’m trying to wrap my head around the state manager.
Using default Litium, when:
waitingconfirmation => confirmed
the email about the order is sent. (default).

Then init is set in delivery
there we want to run an integration to TA system that if success it will go to processing and await deliverystart

Init => processing seems to never trigger for delivery when I use Directpay.

Do i need to add related state? I tried to do with related against orderconfirmed and the delivery state did change to processing for however the init => processing was never executed.

Do I only use relations on the statemanager to trigger said states between order and delivery or can I trigger specific state from one and other?

I have checked the documentation regarding states:

But still cannot seem to wrap the idea on how it should be done.

Litium version: 7.4.2

When Order is created and it is in “init” mode then you need to set the Deliverystatus to Processing in order to change the orderstatus to Processing and when Order is delivered then you can choose to set the Deliverystatus to “Delivered/Canceled or ReadyToShip”. So you will need to handle the statuses with changing DeliveryStatus.

Yeah I understand the basic flow as you explain it, but how can I do it automatically, right now it needs someone in BO to set processing status for delivery.

How can I automatically trigger the init => processing step when the order is confirmed? Do I have to define the related state in StateTransitionBuilder?

stateManager.DeliveryStateMachine.AddRelatedState((short) OrderState.Confirmed, FiniteStateMachineType.Delivery, (short) DeliveryState.Processing)

This seemed to set the Delivery for the order automatically to processing. However it did not execute

 stateMachine.AddStateTransition(
                new State<DeliveryCarrier>((short)DeliveryState.Init, DeliveryState.Init.ToString()), processing,
                (deliveryCarrier, startState, endState, token) =>
                {

You can try to create and a call a method like this:

private void ChangeDeliveryStatus(short status, Order order)
		{
			foreach (var delivery in order.Deliveries)
			{
				delivery.SetDeliveryStatus(status, Solution.Instance.SystemToken);
			}
		}

This should change the related statuses also for the other entities.

Yes, but adjust your related state so that it connects to the OrderStateMachine:

-stateManager.DeliveryStateMachine.AddRelatedState((short) OrderState.Confirmed, FiniteStateMachineType.Delivery, (short) DeliveryState.Processing)
+stateManager.OrderStateMachine.AddRelatedState((short) OrderState.Confirmed, FiniteStateMachineType.Delivery, (short) DeliveryState.Processing);

Thank you this one worked perfectly!

1 Like

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