mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-02 12:02:25 +08:00
https://stackoverflow.com/questions/75791680/disable-add-to-cart-button-when-product-is-on-backorder-on-woocommerce-category
7 lines
223 B
Text
7 lines
223 B
Text
add_filter('woocommerce_is_purchasable', 'disable_add_to_cart', 10, 2);
|
|
|
|
function disable_add_to_cart($purchasable, $product) {
|
|
if ($product->is_on_backorder(1))
|
|
$purchasable = false;
|
|
return $purchasable;
|
|
}
|