# Replace Shop "Add to Cart" With "View Product"

> Swaps the Add to Cart buttons in shop listings for a "View product" button, so customers see the full details and options before buying.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, catalog, buttons, shop
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-loop-view-product-button/

## Code

```php
$wpide_view_button = 'View product'; // Button text.

add_filter( 'woocommerce_loop_add_to_cart_link', function ( $html, $product ) use ( $wpide_view_button ) {
    return sprintf(
        '<a href="%s" class="button wpide-view-product" aria-label="%s">%s</a>',
        esc_url( $product->get_permalink() ),
        esc_attr( sprintf( '%s: %s', $wpide_view_button, $product->get_name() ) ),
        esc_html( $wpide_view_button )
    );
}, 20, 2 );
```

## Notes

Product pages keep their normal Add to Cart button.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Replace Shop "Add to Cart" With "View Product"" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
