Claim your freedom to choose the perfect partner for your multi-vendor journey.

FREEDOM25

Celebrate the festive season by giving your marketplace a powerful lift!

FESTIVE20

5.0.0
Something big is coming for marketplace admins… MultiVendorX 5.0 is almost here. Are you ready?
Be the first to explore all the game-changing features!
Power your marketplace dreams with unbeatable Black Friday deals!

MVXBLACK30

Supercharge your marketplace vision with unstoppable Cyber Monday deals!

MVXCYBER30

Holiday cheer, bigger savings
Take 25% off-because your marketplace deserves a gift too.

happyholiday

View Categories

Parent Order and Sub order status sync

– When an order is created on the woocommerce end, we create the corresponding sub-order.
– Now, we check the initial order status of the order from woocommerce’s main order and set same order status for suborders too
– After that, each vendor/admin needs to change order status for each sub-order
– Therefore, apart from initial order status, if you change status of an order, this will not affect the sub order’s status
Now, you need to add some custom code to sync the parent order status with the sub orders:

// Auto complete sub orders
add_action( 'woocommerce_order_status_completed', 'mvx_order_status_completed' );
function mvx_order_status_completed( $order_id ) {
 global $WCMp;
 $suborder_details = get_mvx_suborders($order_id);
 foreach ($suborder_details as $key => $value) {
     $suborder_fetch = array(
         'ID'           => $value->get_id(),
         'post_status'   => 'wc-completed',
     );
     wp_update_post( $suborder_fetch );
 }
}

//Auto complete sub orders to cancelled
add_action( 'woocommerce_order_status_cancelled', 'mvx_suborder_status_change_to_cancel' );
function mvx_suborder_status_change_to_cancel( $order_id ) {
   global $WCMp;
   $suborder_details = get_mvx_suborders($order_id);
   foreach ($suborder_details as $key => $value) {
       $suborder_fetch = array(
           'ID'           => $value->get_id(),
           'post_status'   => 'wc-cancelled',
       );
       wp_update_post( $suborder_fetch );
   }
}

//Auto complete sub orders to processing
add_action( 'woocommerce_order_status_processing', 'mvx_suborder_status_change_to_processing' );
function mvx_suborder_status_change_to_processing( $order_id ) {
   global $WCMp;
   $suborder_details = get_mvx_suborders($order_id);
   foreach ($suborder_details as $key => $value) {
       $suborder_fetch = array(
           'ID'           => $value->get_id(),
           'post_status'   => 'wc-processing',
       );
       wp_update_post( $suborder_fetch );
   }
}

Leave a Reply

Shopping Cart
Scroll to Top