Hi @danie1234
When a product is un-purchasable, WooCommerce will hide the add to cart form by default.
You can display your message by adding the below code to current-theme (or child-theme) / functions.php
add_action( 'woocommerce_single_product_summary', 'woopt_single_product_summary', 25 );
function woopt_single_product_summary() {
global $product;
if ( ! $product->is_purchasable() ) {
echo '<span style="color: red">Your message here!</span>';
}
}
And the result https://www.screencast.com/t/38lxgZFbRMV
This is not working for me in Astra theme… Button is removed, but no message is displayed on its place.
The button wrapper section remains on the screen, but is empty – nothing is output by this function.
-
This reply was modified 5 years, 2 months ago by
espermedia.