Public Ticket #3695673

Allow Vendor to cancel orders

Closed
Comments
15 Tickets 7
Eana started the conversation 2 years ago on July 30, 2024 at 5:34am

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,762
KingsPlugins replied 2 years ago on July 30, 2024 at 8:32am

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://b2bkingplugin.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

15 Tickets 7
Eana replied 2 years ago on September 5, 2024 at 4:55am

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.

15 Tickets 7
Eana replied 2 years ago on September 6, 2024 at 4:39am

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:

2,762
KingsPlugins replied 2 years ago on September 9, 2024 at 2:03pm

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.



Sign In