• Resolved presse2009

    (@presse2009)


    hi, by default the button on a single-product pages links to the cart. I wanted to change it to another site. I did it like so:

    function my_custom_add_to_cart_redirect( $url ) {
        $url = get_permalink( 68 ); // URL to redirect to (1 is the page ID here)
        return $url;
    }
    add_filter( 'woocommerce_add_to_cart_redirect', 'my_custom_add_to_cart_redirect' );

    Problem: When on the frontpage / startpage, all products are listed (Storefront Theme). It’s an archive page. The image-thumbnails links to the single products page. But the button beneath the image-thumbnails should also link to the single product.
    But It links to the in the above code-snipped page with the id 68. Which is not intended on the frontpage.

    I think I need an if statement. Like:
    if on frontpage:
    Link this way.
    I on single-product:
    link another way.

    But I can’t figure out how to link to the appropriate product page with button beneath the image.

    Cheers,

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to link from archive to single product AND link differently on single produc’ is closed to new replies.