Change Buy Now button to link to least expensive item in Comparison Set

When you are displaying a Comparison Set for an External/Affiliate WooCommerce product, by default, the [Buy Now] button for the WooCommerce product will link to the URL specified when the product was created.

The following code dynamically modifies the [Buy Now] URL so that it links to the cheapest item found in the Comparison Set.


Create a custom plugin

If you haven't done so already, create a custom plugin.


Add custom code

Add the following code to your custom plugin.



Save your changes

Now your products' [Buy Now] buttons should link to the cheapest product found in your Comparison Sets.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us