<p>This feels a bit dirty, but you can actually do this directly in a Twig template like this:</p>
<pre><code>{% set order = craft.orders.id(123).one() %}
{% do order.setAttributes({orderStatusId: 4}, false) %}
{% do craft.app.getElements().saveElement(order) %}
</code></pre>
<p>-- 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.</p>

CC BY-SA 4.0
2020-09-02T14:50:05.890Z
This is just what I was looking for. Obviously better to use a controller, however for our purposes this will work. Many thanks for providing a solution.
Andrew F
CC BY-SA 4.0
2020-09-01T15:18:37.547Z
2020-10-13T09:17:15.650Z
2020-10-13T09:17:15.650Z
James Smith
<p>Following on from this question <a href="https://craftcms.stackexchange.com/questions/35897/commerce-how-to-update-an-order-status-via-the-frontend">Commerce: How to update an order status via the frontend</a></p>
<p>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.</p>
<p>We've created a user group call couriers.</p>
<pre><code>{% extends '_layouts/_logistics' %}

{% block logistics %}
    {% if currentUser and currentUser.isInGroup('courier') %}
        {% include 'logistics/_orders' %}
    {% else %}
        {% redirect 'account' %}
    {% endif %}
{% endblock %}
</code></pre>
<p>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.</p>
<pre><code>&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;
</code></pre>
<p>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.</p>
<p>Many thanks,</p>
<p>Andrew</p>

<ecommerce><plugin-craftcommerce3><status>
Craft Commerce — Update order status from frontend?
# Craft Commerce — Update order status from frontend?

(Asked by: username_0 on 2020-08-31)

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.

    {% if order.shippingAddress %}
        {% include 'shop/_includes/addresses/address' with { address: order.shippingAddress } %}
    {% endif %}
    {{ order.reference }}


    
    {{ redirectInput('logistics') }}
    {{ csrfInput() }}
    
    


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

**Tags:** ecommerce, plugin-craftcommerce3, status


---

## 1 answers

### Answer by username_1 on 2020-09-01. Score: 2 | Accepted answer

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.

> **Comments:**
> **username_0**: This is just what I was looking for. Obviously better to use a controller, however for our purposes this will work. Many thanks for providing a solution.  

---

