• Resolved joemosaic

    (@joemosaic)


    I am using external products created from the URL of a variant product so that all my colors are displayed in my product archive pages but still have the product description only in one place for SEO reasons, which is the variant product.

    My test category is here with mock products:
    https://181.224.144.19/~mosaicar/index.php/product-category/salamanders/

    The Buy Product button underneath these different colors links to the variant product as desired with image set to the right color and the full product description to read.

    The problem is that the link of the image & title of all these different colors on the archive page still point to their external products with their empty product descriptions.

    How would I change the link for the image & title to be same as the button?

Viewing 1 replies (of 1 total)
  • Thread Starter joemosaic

    (@joemosaic)

    This was solved easily by my employee.

    She just modified:
    /themes/storefront/woocommerce/templates/content-product.php

    // replaced:
    // 	<a href="<?php the_permalink(); ?>">
    // with the following:
    	<a href="<?php
    	global $product;
    	if ( !method_exists($product, get_product_url) )
    	{
    		echo the_permalink();
    	}
    	else
    	{
    		echo($product->get_product_url());
    	}
    // --end modification--

    I thought this was going to be more complicated. I didn’t think about the get_product_url() function being only for external products. I also thought it would return the url for the product and not the external URL from which it was built. It pays to read the API instead of assuming things at a glance.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: WooCommerce] Changing URL of External Product Variant on Archive Page’ is closed to new replies.