Suborders not completing

Theme and Plugin Support

Suborders not completing Resolved

Tagged: ,

Viewing 4 reply threads
  • Author
    Posts
    • #104418
      goran.pavles
      Participant

      Hi, I have the problem that when customers buy products, suborders never get set to completed. I always have to do it manually, so the vendors can withdraw commissions.
      I have not added custom code or made any modifications to the plugin.

      Is there a setting to set suborders to autocomplete?

      Thanks

    • #104440
      abhirup
      Moderator

      Hi,
      Let me help you out with our default flow :

      – 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', 'wcmp_order_status_completed' );
       function wcmp_order_status_completed( $order_id ) { 
        global $WCMp;
          $suborder_details = get_wcmp_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', 'wcmp_suborder_status_change_to_cancel' ); 
         function wcmp_suborder_status_change_to_cancel( $order_id ) { 
          global $WCMp;  
          $suborder_details = get_wcmp_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', 'wcmp_suborder_status_change_to_processing' ); 
       function wcmp_suborder_status_change_to_processing( $order_id ) {  
          global $WCMp;   
          $suborder_details = get_wcmp_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 );    
          } 
      }
      Copy
    • #104442
      goran.pavles
      Participant

      Thanks a lot for the fast reply. Where do I add this code to?

    • #104445
      Fantastic Kuhu
      Keymaster

      You may add the code on your active theme’s(preferably child theme) functions.php file.

    • #110068

      We have not received any update from you for a long. Hope this ticket is already been resolved.

      We are now closing this ticket. Kindly create a new one if you need any further help.

Viewing 4 reply threads

The topic ‘Suborders not completing’ is closed to new replies.

Buy all Marketplace addons together, check out our Bundle

Buy at Slashed Price