Support » Plugin: WooCommerce » Woocommerce Product Image to External Link

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Mike Jolley

    (@mikejolley)

    Thread Starter Jon Doe

    (@panduanpria)

    Hy. Mike.

    Thanks for your code, i put that code in my child theme functions.php.

    But it’s not work. If i click on image in the shop page, the code make Too many redirects errors.

    https://i.imgsafe.org/2584c04223.png

    Thread Starter Jon Doe

    (@panduanpria)

    Hy again Mike.

    Your Code is Working. Thanks Again.

    Sorry I forget to change the external product URL from “#” to “http://domain.com”. Your Code is not working if the url is “#”

    I Will bookmark it.

    Mike Jolley’s code works great, but is there a way to open the external product link in a new tab?
    Thanks.

    • This reply was modified 4 years, 10 months ago by numpdog.

    For 2.6+ what I’ve done right now was:

    remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
    add_action( 'woocommerce_before_shop_loop_item', 'mycode_woocommerce_template_loop_product_link_open', 20 );
    function mycode_woocommerce_template_loop_product_link_open() {
        global $product;
        echo '<a rel="nofollow" href="' . esc_url( $product->add_to_cart_url() ) . '" class="woocommerce-LoopProduct-link" data-quantity="'.esc_attr( isset( $quantity ) ? $quantity : 1 ).'" data-product_id="'.esc_attr( $product->id ).'" data-product_sku="'.esc_attr( $product->get_sku() ).'" target="_blank">';
    }

    Thanks a lot Cassianotartari!!!

    I’ve been looking for this for hours and now I get this working fine!!!
    thanks 😀

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Woocommerce Product Image to External Link’ is closed to new replies.