Craft Commerce — Update order status from frontend? Following on from this question Commerce: How to update an order status via the frontend
We'd like to make it easy for delivery drivers to update the status of a craft commerce order, from a frontend page. Doing it via the CP on mobile is a bit cumbersome as it involves multiple steps.
We've created a user group call couriers.
{% extends '_layouts/_logistics' %}

{% block logistics %}
    {% if currentUser and currentUser.isInGroup('courier') %}
        {% include 'logistics/_orders' %}
    {% else %}
        {% redirect 'account' %}
    {% endif %}
{% endblock %}

In the _orders include we'd like to show a list of orders, each with a 'Mark as Delivered' button, which can be clicked as the orders are fullfilled.
&lt;dl&gt;
    {% if order.shippingAddress %}
        {% include 'shop/_includes/addresses/address' with { address: order.shippingAddress } %}
    {% endif %}
    &lt;dt&gt;{{ order.reference }}&lt;/dt&gt;
&lt;/dl&gt;
&lt;form method=&quot;POST&quot;&gt;
    &lt;input type=&quot;hidden&quot; name=&quot;action&quot; value=&quot;&quot;&gt;
    {{ redirectInput('logistics') }}
    {{ csrfInput() }}
    &lt;input type=&quot;hidden&quot; name=&quot;orderStatusId&quot; value=&quot;4&quot;&gt;
    &lt;input class=&quot;button button--primary&quot; type=&quot;submit&quot; value='Mark as Delivered'&gt;
&lt;/form&gt;

I'm wondering if this can be done, without the need to build a plugin or module? Else is there a plan to include the ability to do this in a future Craft Commerce release.
Many thanks,
Andrew
This feels a bit dirty, but you can actually do this directly in a Twig template like this:
{% set order = craft.orders.id(123).one() %}
{% do order.setAttributes({orderStatusId: 4}, false) %}
{% do craft.app.getElements().saveElement(order) %}

-- naturally you'd need a way to fetch which order you want to update, but you could easily grab that from your POST data or from the URL or localStorage or whatever.