Okay
  Public Ticket #3695673
Allow Vendor to cancel orders
Closed

Comments

  •  6
    Eana started the conversation

    We noticed that vendors can only change the order status to "processing", "on hold", and "completed".

    Is there a way that vendors can cancel orders?


    Kind Regards,

  •  2,212
    WebWizards replied

    Hello Eana,

    By default, the plugin only allows certain statuses for vendors, but certainly, we can allow all, or add specific statuses, with a code snippet.


    It is possible to allow the same statuses as the admin has, by adding the following PHP code snippet to your site:

    add_filter('marketking_modifiable_statuses', function($statuses){
        return array('processing','completed','on-hold', 'cancelled', 'pending', 'refunded', 'failed');
    }, 10, 1);
    add_filter('marketking_vendor_can_all_order_statuses','__return_true');
    

    A PHP snippet can be added to functions.php, or by following our guide here: https://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/


    This will result in vendors having the same statuses as the admin:


    5271208589.png

    Kind regards,

    Stefan

  •  6
    Eana replied

    Hi WebWizard,

    Thank you for this!

    It is now working


    Kind Regards,

  •  6
    Eana replied

    Hi,


    I would like to have a follow-up on this one.

    The other statuses are now showing on the dropdown.

    However, when making an update, the changes do not reflect.

    For example, a pending payment was changed to canceled, when a vendor updates it, the order returns to pending payment status.

    Unless the vendor changes the order status to "processing" or "completed", this works.

  •  2,212
    WebWizards replied

    Hi again,

    I tested that now locally but I cannot seem to reproduce that issue: https://www.loom.com/share/0f79373c5ddd40a6b62a58512139eeff?sid=eb3bff04-7722-44ed-9660-49570a92c610

    I can check this directly on your site if you'd like. For that, I'd need a backend login to the site, or a staging clone site,


    Kind regards,

    Stefan

  •  6
    Eana replied

    Sorry, I just realized that our caching plugin caused it.

    After I excluded the vendor dashboard, it now works.


    Kind Regards

  •  6
    Eana replied

    Hi,


    We added a custom Woocommerce order status using these codes:

    function register_preparing_shipment_order_status() {
       register_post_status( 'wc-preparing-shipment', array(
           'label'                     => 'Preparing Shipment',
           'public'                    => true,
           'show_in_admin_status_list' => true,
           'show_in_admin_all_list'    => true,
           'exclude_from_search'       => false,
           'label_count'               => _n_noop( 'Preparing Shipment <span class="count">(%s)</span>', 'Preparing Shipment <span class="count">(%s)</span>' )
       ) );
    }
    add_action( 'init', 'register_preparing_shipment_order_status', 10 );

    function add_preparing_shipment_to_order_statuses( $order_statuses ) {
       $new_order_statuses = array();
       foreach ( $order_statuses as $key => $status ) {
           $new_order_statuses[ $key ] = $status;
       if ( 'wc-processing' === $key ) {
                $new_order_statuses['wc-preparing-shipment'] = 'Preparing Shipment';
            }
       }
       return $new_order_statuses;
    }
    add_filter( 'wc_order_statuses', 'add_preparing_shipment_to_order_statuses', 10 );

    We also added it to the code you gave us:

    add_filter('marketking_modifiable_statuses', function($statuses){
        return array('processing', 'completed',' on-hold', 'cancelled', 'pending', 'refunded', 'failed', 'wc-preparing-shipment');
    }, 10, 1);
    add_filter('marketking_vendor_can_all_order_statuses','__return_true');

    It is showing correctly for admin, but it is not for vendors.
    Are custom statuses allowed for vendors? or did we miss something?

    Please see the attached file.

    Thanks



    Attached files:  admin_custom.png
      vendor_custom.png

  •  2,212
    WebWizards replied

    Hi there,

    Generally to add a custom order status to MarketKing, you can add the following code, in addition to what you already have:

    https://pastecode.io/s/2kcnfhx8

    It should add it as follows:

    9992873697.png



    I tested your code but on my end actually it does not work for some reason (in the backend when saving the order). It shows the status in the backend, but if I save the order the status is not saved. I don't know if it's a problem on my test site, or a problem with the code.