I am using Woocommerce with WCMP (WC Markeplace), however vendors are not allowed to update the order status (i.e.: from 'processing' to 'completed').

There's no option in their backend, so I tryed to add a custom button to handle that!

Any help would be amazing! Here's my code (I found it somewhere around here):

<form method="post">
<input type="hidden" name="mark_as_received" value="true">
<input type="hidden" name="order_id" value="<?php echo esc_attr($order_id);?>">
<?php wp_nonce_field( 'so_38792085_nonce_action', '_so_38792085_nonce_field' ); ?> 
<input type="submit" value="I Got It!">

And to handle the form:

add_action( 'wp_loaded', 'custom_button_to_update' );
function custom_button_to_update(){
    // not a "mark as received" form submission
    if ( ! isset( $_POST['mark_as_received'] ) ){

    // basic security check
    if ( ! isset( $_POST['_so_38792085_nonce_field'] ) || ! wp_verify_nonce( $_POST['_so_38792085_nonce_field'], 'so_38792085_nonce_action' ) ) {   

    // make sure order id is submitted
    if ( ! isset( $_POST['order_id'] ) ){
        $order_id = intval( $_POST['order_id'] );
        $order = wc_get_order( $order_id );
        $order->update_status( "completed" );
    else {
        echo "failed";

Thank you for your help in advance!


Thank you all, I did found the answer HERE.

I adapt a bit the code to my needs and added a button.


  <form method="post" name="update_status">             
    <button type="submit" name="marked_as_completed">Mark as Completed</button>


        if (isset($_POST["marked_as_completed"])) 
        $completed_status = $order->get_id();
        $order = new WC_Order($completed_status);
        $order->update_status('completed', 'order_note');
        echo '<h2 style="color:green;">Completato &check;</h2>';  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.