I basically need to be able to create multiple orders for every item in the cart but retain the default checkout process.
To the user, it would look like they are checking out with multiple items but in the backend, it would create multiple orders. I found an article which pretty much relates what I need to do.
I would assume I would need to remove the action that is triggered when clicking the pay now button, preventing the order from being created automatically and create the orders manually. I can access the cart information using the following filter, perhaps this would be a starting point?
add_filter( 'woocommerce_checkout_create_order', 'wp_handle_multiple_orders', 10, 1 );
function wp_handle_multiple_orders( $order ) {
global $woocommerce;
print_r(count(WC()->cart->get_cart()));
// Handle creation of multiple orders
}
Or perhaps I hook into the checkout_process:
add_action( 'woocommerce_checkout_process', 'wp_handle_multiple_orders' ) );
I am aware this process isn't ideal and there are many different things to consider but hopefully, there is an alternative way of achieving this. Any links would be appreciated!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…