Advertisement
michaellevelup

View cart if already in cart

Apr 29th, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 0 0
  1. function king_replace_loop_add_to_cart_button( $button, $product  ){
  2.  
  3.     // Not needed for variable products
  4.     if( $product->is_type( 'variable' ) )
  5.         return $button;
  6.  
  7.     if ( is_shop() && $product->is_purchasable() && $product->is_in_stock() ){
  8.  
  9.         // Button text here
  10.         $button_text = __( "View product", "woocommerce" );
  11.  
  12.         return '<a class="button" href="' . $product->get_permalink() . '">' . $button_text . '</a>';
  13.     }
  14. }
  15.  
  16. add_filter( 'woocommerce_loop_add_to_cart_link', 'king_replace_loop_add_to_cart_button', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement