• Resolved indrabhusanroy

    (@indrabhusanroy)


    Hi, I want to replace add to cart button with a View Details Button which will link to the product single page. I have used this code below to remove add to cart button and replace it only on the shop page of my site. But I have products on other pages of my site where add to cart button still exists, so how to replace it everywhere in my site.

    add_filter( ‘woocommerce_loop_add_to_cart_link’, ‘replacing_add_to_cart_button’, 10, 2 );
    function replacing_add_to_cart_button( $button, $product ) {
    $button_text = __(“View product”, “woocommerce”);
    $button = ‘get_permalink() . ‘”>’ . $button_text . ‘‘;

    return $button;
    }

Viewing 5 replies - 1 through 5 (of 5 total)
  • Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Thread Starter indrabhusanroy

    (@indrabhusanroy)

    The problem with this plugin is that it only changes the button label.

    When users visits your online shop, they intend to view the single product product page to view detailed info about the product. But In my site a add to cart button hovers over the product image at shop page. So I first used this code to change add to cart button and replaced it with single product page link. It worked well for shop page but not for other pages of my site where products are listed. here is the code again I have used…

    add_filter( ‘woocommerce_loop_add_to_cart_link’, ‘replacing_add_to_cart_button’, 10, 2 );
    function replacing_add_to_cart_button( $button, $product ) {
    $button_text = __(“View product”, “woocommerce”);
    $button = ‘get_permalink() . ‘”>’ . $button_text . ‘‘;

    return $button;
    }

    Now you recommended the plugin which does changes the button name but when I click on the buttton it shows “adding to cart” and then it goes to the single product page. This can be confusing for users.

    did you tried “Woocommerce Booster” plugin?

    Thread Starter indrabhusanroy

    (@indrabhusanroy)

    Yes, I have tried but of no use to me. It replaces add to cart button by product single page only on shop page and not on other pages of my site where products are also listed.

    Thread Starter indrabhusanroy

    (@indrabhusanroy)

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Replace Add To Cart Everywhere in site’ is closed to new replies.