Advertisement
fahimmurshed

Change "Add to cart" to View Product

Feb 9th, 2022
1,181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. // changes the "select options" text. fahimm.com
  2. add_filter( 'woocommerce_product_add_to_cart_text', function( $text ) {
  3. global $product;
  4. if ( $product->is_type( 'variable' ) ) {
  5.     $text = $product->is_purchasable() ? __( 'More Options', 'woocommerce' ) : __( 'Read more', 'woocommerce' );
  6. }
  7. return $text;
  8. }, 10 );
  9.  
  10. /**
  11.  * remove add to cart buttons on the shop archive page
  12.  */
  13.  
  14. add_filter( 'woocommerce_loop_add_to_cart_link', 'replacing_add_to_cart_button', 10, 2 );
  15. function replacing_add_to_cart_button( $button, $product  ) {
  16. if ( $product->is_type( 'simple' ) ) {
  17. $button_text = __("View product", "woocommerce");
  18. $button = '<a class="button" href="' . $product->get_permalink() . '">' .
  19. $button_text . '</a>';
  20. }
  21. return $button;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement