Link from external products directly to the page
-
I’m setting up a store with external/affiliate products and I need to click on the product on the store page to redirect it to the external product.
What is happening is that when clicking on the product image or title you are redirected to the single product page, but when clicking the button you are redirected to the external page (which is what I need).
I saw some threads here with the same problem but no solution.
Some of them suggest putting this code (code below) to redirect to the external page when clicking on the product.
<?php // Do not include this if already open! /** * Code goes in theme functions.php. */ add_action( 'template_redirect', 'redirect_external_products' ); function redirect_external_products() { global $post; if ( is_singular( 'product' ) && ! empty( $post ) && ( $product = wc_get_product( $post ) ) && $product->is_type( 'external' ) ) { wp_redirect( $product->get_product_url() ); exit; } }
But for SEO reasons, I don’t want to lose the store’s single product page and with this code, when you click on the link, eg: site/products/yourproduct it redirects you to the external link.
So what I need is basically to point the external product lik on the product page instead of redirecting it.
I don’t know how Woocommerce hasn’t made this modification yet or put an option for it, because the send button for a link and the image send for another one doesn’t make sense.
- The topic ‘Link from external products directly to the page’ is closed to new replies.