Skip to content

Instantly share code, notes, and snippets.

@mi5t4n
Last active April 26, 2022 16:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mi5t4n/03d9c578707d8c8dfa9a251a1e2d0ae4 to your computer and use it in GitHub Desktop.
Save mi5t4n/03d9c578707d8c8dfa9a251a1e2d0ae4 to your computer and use it in GitHub Desktop.
Split orders when order containing products from multiple vendor is created from admin dashboard in Dokan plugin.
<?php
/**
* Split orders when order containing products from multiple vendor is created from admin dashboard.
*/
function sagar_order_creation_fix( $post_id, $post, $update ) {
// Bail early if not admin.
if( ! is_admin() ) {
return;
}
// Split the order if the order is created.
if ( 'draft' === get_post_status( $post_id ) ) {
remove_action( 'save_post_shop_order', 'sagar_order_creation_fix', 10 );
$order_manager = new Dokan_Order_Manager();
$order_manager->maybe_split_orders( $post_id );
add_action( 'save_post_shop_order', 'sagar_order_creation_fix', 10, 3 );
}
}
add_action( 'save_post_shop_order', 'sagar_order_creation_fix', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment