Last active
April 26, 2022 16:05
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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