Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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