Skip to main content

Developer hooks

Add these to your theme's functions.php or a small plugin.

Filters​

FilterArgumentsUse
wcbs_should_split_orderbool $split, int $order_id, WC_Order $orderReturn false to skip an order
wcbs_backorder_itemsarray $items, int $order_id, WC_Order $orderChange which items and quantities move
wcbs_backorder_statusstring $status, int $order_id, WC_Order $orderThe new order's status (default backordered)
wcbs_copy_charges_to_backorderbool $copy, WC_Order $order, WC_Order $backorderReturn true to copy shipping costs, fees and coupons in full (the behaviour before 2.4.0)
wcbs_meta_fields_to_copyarray $keysOrder meta keys copied to the backorder order
wcbs_disable_emails_on_splitbool $disable, WC_Order $orderReturn false to let WooCommerce send emails during the split

Actions​

ActionArgumentsWhen
wcbs_before_split_orderint $order_id, WC_Order $orderBefore the split
wcbs_backorder_createdint $backorder_id, int $order_id, WC_Order $backorder, WC_Order $orderAfter the backorder order is saved
wcbs_after_split_orderint $order_id, WC_Order $orderAfter the split
wcbs_split_order_errorint $order_id, string $messageWhen 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' );