POST /api/v{version}/_action/order/{orderId}/state/{transition} NOT available in shopware 6.0

Hi,

I was looking thru the shopware 6.0 docs and found the action routes in order to update an order’s state ( Shopware 6: Action Routes ), but the routes are not available in our shopware 6.0 instance, yet the routes are available on our shopware 6.1 instance.

Any idea why, or how I can access or update order status in shopware 6.0?

 

Hello @raduiosif‍ I am trying to edit the order status, too.

I‍t was working, but now it doesn’t. I used that route.

Patch:

api/v2/order/ddeee183fa2d46559f41d7b846386fcb?_response=true

Json: 

{
    "stateId":"268EDC7D41334099AD1D456338526C20"
}

But currently I am getting this error.

{
    "errors": [
        {
            "code": "FRAMEWORK__WRITE_CONSTRAINT_VIOLATION",
            "status": "400",
            "detail": "Changing the state-machine-state of this entity is not allowed for scope crud. Either change the state-machine-state via a state-transition or use a different scope.",
            "template": "Changing the state-machine-state of this entity is not allowed for scope {{ scope }}. Either change the state-machine-state via a state-transition or use a different scope.",
            "meta": {
                "parameters": {
                    "{{ scope }}": "crud"
                }
            },
            "source": {
                "pointer": "/0/stateId"
            }
        }
    ]
}

Does anyone have an idea?

Hi @CallMeAlex‍,

If you are using Shopware 6.1 or above, use the action routes to update the order status (you can find the link above) and not by patching the order’s state. The error that you’re getting might be related to the fact that you can’t change the order state from ‘cancel’ for example to ‘done’, first you need to ‘reopen’ the order in order to mark it as ‘done’. Try using another state.

Hi @CallMeAlex ,
thank you for the hint.
I got the same error and was able to solve it.

What I found a little strange, may be it is just a typo is the following:
I have set the request to:
$this->request(’_action/order/’ . $orderId . ‚/state/‘ . $status, , ‚POST‘);
Where $status = ‚completed‘.

But I got this error:
„Illegal transition „completed“ from state „d6749533b7e84257a7b5f5f07aefc247“. Possible transitions are: cancel, complete“

When I replace $status witch ‚complete‘ like here:
$this->request(’_action/order/’ . $orderId . ‚/state/complete‘ , , ‚POST‘);
It is working.

But in the doku it is said:
The transition parameter can be one of the transitions defined in \Core\Checkout\Order\OrderStates.
Here it is said:

public const STATE_MACHINE = ‚order.state‘;
public const STATE_OPEN = ‚open‘;
public const STATE_IN_PROGRESS = ‚in_progress‘;
public const STATE_COMPLETED = ‚completed‘;
public const STATE_CANCELLED = ‚cancelled‘;

Also in the database in the table ‚state_machine_state‘ the ‚technical_name‘ is ‚completed‘ and not ‚complete‘.

Should that not be identical?

Status should be „progress“ or „cancel“ not "in_progress. Hope it could help :slight_smile:

Looking at the state_machine_transition table, I think „progress“ is wrong too. Instead it should be „process“:


action_name from_state_technical_name to_state_technical_name
cancel => open cancelled
complete => in_progress completed
reopen => cancelled open
process => open in_progress
reopen => completed open
cancel => in_progress cancelled