Home Forums WoodMart support forum Product archiv buttons

Product archiv buttons

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #557434

    spyda67
    Participant

    Hello,
    I want to change the buttons in the product archive for products without variants. Currently, for products without a variant it says “Add to Cart,” and on hover, a cart icon appears. For products with a variant, it says “Read more.” I want “Read more” to appear for all products, and to be redirected to the product page when clicked. In Germany, it is legally prohibited to directly add a product to the cart so that the customer can be fully aware of all essential properties of the goods and other necessary information.

    How can I change the icon?

    Best regards

    #557435

    spyda67
    Participant

    Is there a specific template file I should modify, or do I need to use a certain hook in the functions.php of my child theme to change the “Add to Cart” button to a “Read More” button for all products, which will redirect customers to the product page?

    My idea is to change something like this:

    // Change this
    woocommerce_template_loop_add_to_cart();

    // to this
    echo ‘Weiterlesen‘;

    #557439

    spyda67
    Participant

    / Change this
    woocommerce_template_loop_add_to_cart();

    // to this
    echo '<a href="' . get_the_permalink() . '" class="button add_to_cart_button">Weiterlesen</a>';

    #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.

    #557789

    spyda67
    Participant

    Thank you!

    #557843

    Most Welcome!!!.

    Iā€™m so happy to hear you are pleased with the Theme and Support. XTEMOS strives to deliver the best customer experience, and it makes our day to hear we have accomplished that.

    We count ourselves lucky to have you as a customer. You can always reach us at any time. We are always here to help you.

    Thanks for contacting us.
    Have a great day.

    Topic Closed.
    Best Regards.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Product archiv buttons’ is closed to new replies.