Reputation: 82
I tried allow backorders for certain products depending on a custom meta field with this way:
add_filter( 'woocommerce_product_backorders_allowed','filter_woocommerce_product_backorders_allowed', 10, 3 );
function filter_woocommerce_product_backorders_allowed( $allow_backorder, $product_id, $product ){
$custom_stock = get_post_meta( $product->id, '_custom_stock', true );
if ( ! empty ( $custom_stock ) ) {
$allow_backorder = true;
}
return $allow_backorder;
}
But this is not working. What I want, if the _custom_stock meta field has any value then set backorder true on that product. The _custom_stock is a custom meta field, added to woocommerce options. I can save, modify, etc. so the meta field is work.
What I am missing?
Upvotes: 0
Views: 342