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?
{
"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"
}
}
]
}
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‘.