Question

I am importing affiliate products via XML into Woocommerce. Due to products having variations if I use the External/Affiliate product type I get repetition of product on my front end (eg. same product with different location/colour). To avoid this I am attempting to import these products as variable products, this solves the problem, except now I need to Change the add to cart to behave like an external product (i.e. a Button that links to another website).

I've created a Custom Value associated with each product called "Buy_Link", now what?

I have searched and searched, but unable to find a solution for something I thought would be relatively simple for someone with php knowledge.

I know that I should be able to retrieve the link doing something like this:

<?php echo get_post_meta($post->ID, 'Buy_Link', true); ?>

(After some help and a bit more searching) I believe I will need to place code: ID, 'Buy_Link', true); ?>

into single-product/add-to-cart/variable.php, but I am still unsure where it would go in that template.

I would like the link to replace some of the functionality of the original add to cart button.

Obviously, I am not too familiar with php code, so please be specific about how and where in the template I can put the code. Much appreciated.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top