• Hi everyone! I am setting up a landing page and using woocommerce to display the products. These products will be sold on a different page and I want to link the entire product to the affiliate/external link. I found a piece of code that I added to theme functions but only works on product image. I am not expert developer so I don’t know exactly how to modify this code or create a new one to work on the entire product. Does anyone know how to do the same with the product description? Code I used is below. Thanks!

    /* 
     *  Link Product to Affiliate Link
     */
    
    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">';
    }
    
  • The topic ‘Link Shop Page to External link’ is closed to new replies.