How to add an affiliate link to a product after removing the product detail page in WooCommerce

  divi, php, product, woocommerce, wordpress

I am making an affiliate website and I would like to remove the single product page, so that you only can see the product with the title and prices. And when you click on it, I want that the product is redirected to the affiliate page. However it does not work.

I have switched of the product detail page with the following code:

remove_action( 
  'woocommerce_before_shop_loop_item',
  'woocommerce_template_loop_product_link_open',
  10
);

remove_action(
  'woocommerce_after_shop_loop_item',
  'woocommerce_template_loop_product_link_close',
  5
);

But now I am unable to redirect my products to another site by using my affiliate link. Since the products are now linking to nothing. Can someone maybe help me?

Source: Ask PHP

LEAVE A COMMENT