Advertisement
michaellevelup

Replace add to cart button

Jun 24th, 2022
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.38 KB | None | 0 0
  1. add_filter( 'woocommerce_loop_add_to_cart_link', 'replacing_add_to_cart_button', 10, 3 );
  2.  
  3. function replacing_add_to_cart_button( $button, $product, $args = array()  ) {
  4.  
  5.     if(is_shop()){
  6.         $button_text = __("View product", "woocommerce");
  7.         $button = '<a href="' . $product->get_permalink() . '" class="button">' . $button_text . '</a>';
  8.     }
  9.  
  10.     return $button;
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement