• Resolved n0ran89

    (@n0ran89)


    hello there,
    i was wondering if i can redirect the product to another page
    i have all my products already done in normal pages
    so I need to set attributes and picture and then open the page I already have instead of the product page

    can this be done???

    i tried to insert php snippets but didn’t have a chance

    thanks in advance ??

    much appreciated

Viewing 2 replies - 1 through 2 (of 2 total)
  • create the product and select affiliate as the product type and you will see the field to link the product to any page within your website or any other website

    Thread Starter n0ran89

    (@n0ran89)

    thanks for your reply

    I tried this but didn’t work
    and then found in https://www.ads-software.com/support/topic/product-image-linked-to-external-url-with-relnofollow/

    So far, I came to a solution in which I can redirect them to the affiliate external links adding this piece of code to 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;
    }
    }

    when I tried it it worked!

    the only problem now is when we hover on the product it display in the footer tip the original product link and not the external link
    if you have something to work around this I’d really appreciate it

    thank you in advance

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘can i redirect product to other page?’ is closed to new replies.