Link product image to merchant's website

If you want to have your product images on your category pages link directly to the merchants' pages, here's the custom code you need.

However, you may also find this article more useful: Link directly to merchant's site, bypass single product page

add_filter( 'woocommerce_loop_product_link', function ( $url, WC_Product $product ) {

   // If this product was not added by the DFRPSWC plugin, return default $post_link.
   if ( ! dfrpswc_is_dfrpswc_product( $product->get_id() ) ) {
      return $url;
   }

   // If WCCAL is activated, get WCCAL-generated URL, else use dfrapi_url to get $url.
   if ( class_exists( 'Wccal' ) ) {
      $url = $product->get_product_url();
   } else {
      $product = get_post_meta( $product->get_id(), '_dfrps_product', true );
      $url     = dfrapi_url( $product );
   }

   return $url;
}, 10, 2 );

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