Home Forums WoodMart support forum Product archiv buttons Reply To: Product archiv buttons

#557584

Hello,

Define the code below in the functions.php file in your child theme.

// Change "Add to Cart" button to "Read More" for products without variants
function change_add_to_cart_button( $button, $product ) {
    // Check if the product has variants
    if ( ! $product->is_type( 'variable' ) ) {
        // If no variants, change button text to "Read More" and link to product page
        $button_text = __("Read More", "woocommerce");
        $button = sprintf(
            '<a href="%s" class="button">%s</a>',
            esc_url( $product->get_permalink() ),
            esc_html( $button_text )
        );
    }
    return $button;
}
add_filter( 'woocommerce_loop_add_to_cart_link', 'change_add_to_cart_button', 10, 2 );
?>

Best Regards.