Skip to content
Advertisement

Disable add to cart button via custom checkbox in WooCommerce product settings

We want to prevent add to cart for certain upcoming products.

We want to have a checkbox to select the specific product on which we want to prevent add to cart. We have right now the checkbox and save code.

I also found this: Remove add cart button in Woocommerce for a specific product category and https://wisdmlabs.com/blog/the-right-way-to-hide-add-to-cart-button-in-woocommerce/

I’m not sure, what is the best way to prevent add to cart for specific products. Does anyone have a suggestion what the best way would be?

JavaScript

Advertisement

Answer

  • Explanation via comment tags added in the code

To add a checkbox to the inventory product options, use:

JavaScript

To disable the add to cart button for simple and variable products, use:

JavaScript

Note: There are several ways to disable/remove the add to cart button, so it depends on whether you want to hide or disable the button completely.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement