I add birthlist functionnality to my woocommerce store. I would like to authorize the order of an out-of-stock product only if the product is purchased on the birthlist.

On my function to add a product to the shopping cart from the birthlist, I skip the stock availability check. The product is now added to the cart. I also add a meta to the item in the cart with the birthlist ID.

But I got an error on cart and checkout about stock.

How to deactivate the stock check of the shopping cart programmatically.

Actually woocommerce make this check on includes/class-wc-cart.php in check_cart_item_stock method

1 Answer 1


Finally, I did it like this:

function bo_disable_stock_check(){
        remove_action('woocommerce_check_cart_items', [WC()->cart, 'check_cart_items'], 1);
        add_filter("woocommerce_product_is_in_stock", "__return_true");
        add_filter("woocommerce_cart_item_required_stock_is_not_enough", "__return_false");

But maybe there are more specific hooks to call than "wp".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.