Developer hooks
Add these to your theme's functions.php or a small plugin.
Filters
| Filter | Arguments | Use |
|---|---|---|
wcbs_should_split_order | bool $split, int $order_id, WC_Order $order | Return false to skip an order |
wcbs_backorder_items | array $items, int $order_id, WC_Order $order | Change which items and quantities move |
wcbs_backorder_status | string $status, int $order_id, WC_Order $order | The new order's status (default backordered) |
wcbs_copy_charges_to_backorder | bool $copy, WC_Order $order, WC_Order $backorder | Return true to copy shipping costs, fees and coupons in full (the behaviour before 2.4.0) |
wcbs_meta_fields_to_copy | array $keys | Order meta keys copied to the backorder order |
wcbs_disable_emails_on_split | bool $disable, WC_Order $order | Return false to let WooCommerce send emails during the split |
Actions
| Action | Arguments | When |
|---|---|---|
wcbs_before_split_order | int $order_id, WC_Order $order | Before the split |
wcbs_backorder_created | int $backorder_id, int $order_id, WC_Order $backorder, WC_Order $order | After the backorder order is saved |
wcbs_after_split_order | int $order_id, WC_Order $order | After the split |
wcbs_split_order_error | int $order_id, string $message | When a split fails |
Examples
Only split orders paid by card:
add_filter( 'wcbs_should_split_order', function ( $split, $order_id, $order ) {
return $split && 'cod' !== $order->get_payment_method();
}, 10, 3 );
Give backorder orders the On hold status:
add_filter( 'wcbs_backorder_status', function () {
return 'on-hold';
} );
Charge shipping on both orders, as before 2.4.0:
add_filter( 'wcbs_copy_charges_to_backorder', '__return_true' );