• Resolved trde

    (@trde)


    Is it possible to make each product variation as different link? Fo example I have t-shirts: black, red, blue and I want to set them (colors) as variations, but with unique URL like:

    mywebsite.com/shop/t-shirt-black
    mywebsite.com/shop/t-shirt-red
    mywebsite.com/shop/t-shirt-blue

    Can I do it in WooCommerce without plugin? Any simple PHP solution, or core settings?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support AW a11n

    (@slash1andy)

    Automattic Happiness Engineer

    Hey there!

    To be completely honest, it sounds like you are far better off with just using Simple Products instead of variable, as these sound like separate products. This would also give you unique URLS that you are wanting.

    The only other way I can think of doing this would be using a rewrite rule to handle this. You would rewrite so that mywebsite.com/shop/t-shirt-black rewrites to website.com/product/t-shirt/?attribute_pa_size=large&attribute_pa_color=black (for example).

    Again, I would highly recommend just using Simple Products for this.

    Thread Starter trde

    (@trde)

    Thanks for reply.
    I have this code now in my functions.php:

    add_action( 'woocommerce_product_after_variable_attributes', 'gdy_add_wc_varition_permalink', 100, 3 ); 
    
    function gdy_add_wc_varition_permalink( $loop, $variation_data, $variation ) {
    
        echo '<a href="' . get_permalink( $variation->ID ) . '" target="_blank">' . __( 'Permalink for this variation' ) . '</a>';
    
    }

    It shows permalink of each variations in my admin dashboard. Now I just need something similar but on product page to redirect user always when he select different variation. Maybe some JS could help here?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Product variations with different links’ is closed to new replies.