• Hi for my add to cart button i use this code

    add_filter( 'woocommerce_loop_add_to_cart_link', 'test_replace_add_to_cart_with_quickview', 10, 2 );
    
    function test_replace_add_to_cart_with_quickview( $html, $product ) {
    
      if ( method_exists( $product, 'get_id' ) ) {
        $product_id = $product->get_id();
      } else {
        $product_id = $product->id;
      }
    
    // Set HERE your button link
      $link = get_permalink($product_id);
      $html = '<a rel="nofollow" qv-id = "'.$product_id.'" class="woocommerce-LoopProduct-link quickview-button button">'.esc_html__('Select', 'test-plugin').'</a>';
    
      return $html;
    }

    and works ok.
    But i want to replace it with the quick view button. How could i do this?

    Thanks a lot

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hi there,

    thanks for contact us!
    We are sorry to inform you that this is a feature of premium version of quick view plugin and you can do it with the free one.

    However, try to add this code to use the quick view button instead of add to cart and to remove the default one:

    add_filter( 'woocommerce_loop_add_to_cart_link', 'test_replace_add_to_cart_with_quickview', 10, 2 );
    
    function test_replace_add_to_cart_with_quickview( $html, $product ) {
    
      if ( method_exists( $product, 'get_id' ) ) {
        $product_id = $product->get_id();
      } else {
        $product_id = $product->id;
      }
    
    // Set HERE your button link
      $link = get_permalink($product_id);
      $html = '<a rel="nofollow" data-product_id = "'.$product_id.'" class="woocommerce-LoopProduct-link yith-wcqv-button button">'.esc_html__('Select', 'test-plugin').'</a>';
    
      return $html;
    }
    
    if( function_exists( 'YITH_WCQV_Frontend' ) ){
        remove_action( 'woocommerce_after_shop_loop_item', array( YITH_WCQV_Frontend(), 'yith_add_quick_view_button' ), 15 );
    }

    Let us know if works.

    Thread Starter mariodts

    (@mariodts)

    Thanks for your reply. I didnt know that was on pro. Worked perfectly.

    Thread Starter mariodts

    (@mariodts)

    one last question if possible. How to exclude this from yith wishlist page?
    Because i dont want there to enable the popup when i press the add to cart.

    Thanks

    Plugin Author YITHEMES

    (@yithemes)

    Hi,
    if you want to show the add-to-cart button in the wishlist page, you could simply add a check in your function to check if the current page is the wishlist one, through this code snippet:
    function_exists( 'yith_wcwl_is_wishlist' ) && yith_wcwl_is_wishlist()

    So, your should simply edit your code as follows:

    add_filter( 'woocommerce_loop_add_to_cart_link', 'test_replace_add_to_cart_with_quickview', 10, 2 );
    
    function test_replace_add_to_cart_with_quickview( $html, $product ) {
    
    	if ( function_exists( 'yith_wcwl_is_wishlist' ) && yith_wcwl_is_wishlist() ) {
    		return $html;
    	}
    	
    	if ( method_exists( $product, 'get_id' ) ) {
    		$product_id = $product->get_id();
    	} else {
    		$product_id = $product->id;
    	}
    
    	// Set HERE your button link
    	$link = get_permalink($product_id);
    	$html = '<a rel="nofollow" data-product_id = "'.$product_id.'" class="woocommerce-LoopProduct-link yith-wcqv-button button">'.esc_html__('Select', 'test-plugin').'</a>';
    
    	return $html;
    }
    
    if( function_exists( 'YITH_WCQV_Frontend' ) ){
    	remove_action( 'woocommerce_after_shop_loop_item', array( YITH_WCQV_Frontend(), 'yith_add_quick_view_button' ), 15 );
    }

    Please try this solution and let us know if everything works fine!

    Hi can we add variation images in qucik view please help

    • This reply was modified 3 years, 11 months ago by prinka.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Replace add to cart button’ is closed to new replies.