Hi
try to add this code in functions.php
// Remove "Read More" button and disable "Add to Cart" button when the product is out of stock
add_action('wp', 'customize_product_buttons');
function customize_product_buttons() {
global $product;
// Check if it's a single product page
if (is_product()) {
// Check if the product is out of stock
if (!$product->is_in_stock()) {
// Remove "Read More" button
remove_action('woocommerce_after_single_product', 'woocommerce_template_single_excerpt', 20);
// Disable "Add to Cart" button
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
add_action('woocommerce_single_product_summary', 'display_disabled_add_to_cart_button', 30);
}
}
}
// Display disabled "Add to Cart" button
function display_disabled_add_to_cart_button() {
global $product;
// Output the button with the 'disabled' attribute
echo '<button type="submit" class="single_add_to_cart_button button alt" disabled>Add to Cart</button>';
}