Support » Plugin: WooCommerce » External / Affiliate Product URL

  • Resolved aplusr



    When adding an External / Affiliate Product WooCommerce states to enter the product URL and it even gets you started with an ‘http://’. But my affiliate links start with <script> (javascript) or ‘<a ‘ (HTML). I can choose between one or the other. I didn’t really expect the javascript one to work out of the box but I’m surprised that the HTML link with the <a> tag isn’t working correctly.

    I’ve tried cutting just the http://"URL" link from both but this doesn’t work.

    Is there any way I can get the External / Affiliate Product URL to work with the <a> tag? This is also useful for opening a link in a new tab or window.

    When I use the <a> tag in the Product URL field clicking the ‘Buy Now’ button on the front end stays on my website and adds all of the code to the end of my website URL which results in a ‘page not found’. I think I may need the <a> tag because there is a href="", img style="" and an src="" all in the <a> tag.



Viewing 13 replies - 1 through 13 (of 13 total)
  • Can you post the link code? <a> and <script>.
    And the resulting link from your website.

    If you can code a bit, adjust the template and use PREG_REPLACE functions.
    Look here for info:


    Thanks for responding.

    An example of the HTML (<a>) code is:

    <a target="_self" href=""></a><img style="text-decoration:none;border:0;padding:0;margin:0;" src="[CACHEBUSTER]">


    <script>document.write('<a target="_self" href=""></a><img style="text-decoration:none;border:0;padding:0;margin:0;" src="'+Math.floor(Math.random()*999999999)+'">');</script><noscript><a target="_self" href=""></a><img style="text-decoration:none;border:0;padding:0;margin:0;" src="[CACHEBUSTER]"></noscript>

    URL from website when the HTML <a> link fails:;border:0;padding:0;margin:0;%22%20src=%22

    I have just tested this.
    I copied you code to a .txt file on my local pc and renamed it afterwards to a .htm file so i would get a link when i open it.
    Once i click that link i’ll go to the ebay store (front page). If i manually copy your link into my browser i’m redirected to the same page on ebay (front page).

    This mean that the campaign no longer exists or it is just for ebays front page.

    Just take the HREF portion of the link

    I used the eBay front page, but I guess that was a bad example because there is not as much information in the URL. When I link to an actual product using only the HREF portion of the link it doesn’t go to the correct location. I compared the three in a .htm file (the original non affiliate link, the full affiliate link in <a> tags and the affiliate link using only the HREF portion.

    The original and the full affiliate link go to where I want it to go but the one with only the HREF portion isn’t going to the custom location that I chose. The HREF one also doesn’t open in a new tab or window from my website because it’s just what’s in the first set of quotes I think.

    I managed to find a plugin that allows me to open the external link in a new tab: WooCommerce Improved External Products

    But still no luck using the full <a> tag code.

    Does anyone have the code I could use to adjust the template with the PREG_REPLACE functions? Could I just copy and paste this?

    Hey aplusr, Thanks for the email! I figured I’d respond to your questions here and see if I can help. Can you post a couple more active sample links here? I’d like to be able to trouble shoot a bit.

    Hey guys,

    I am having a similar problem with trying to get my affiliate link (woo commerce affiliate/external product) to display as a button.

    The linking function won’t work when I amend the php file to insert a button.

    Below is the raw code I tried to amend:

    <?php do_action('woocommerce_before_add_to_cart_button'); ?>
    <p class="cart"><a href="<?php echo $product_url; ?>" rel="nofollow" class="single_add_to_cart_button button alt" target="_blank"><?php echo apply_filters('single_add_to_cart_text', $button_text, 'external'); ?></a></p>
    <?php do_action('woocommerce_after_add_to_cart_button'); ?>


    I am joining this thread to see what you guys come up with. I have about 450 banner affiliate links to add to my site. So i get ready-made HTML code to insert in body of site. Template wont read it and place banner there, perhaps because of a href in code. Should I be using text links instead of banner links. I want banner to show on site.

    Seems to me, a Plug-in that allows for block insertion/design anywhere in the site is the way to go. Drop and drag so to speak.

    I run a charity that raises funds thru an affiliate mall. Built the site with Website Tonight from GoDaddy only to learn that it will not transfer to dedicated server when traffic increases beyond certain point. So i am trying Wp and so far its a nightmare without support. You can see what I have to duplicate in Wp at

    Active Sample Links:

    Original Link:

    Affiliate Link:

    <a target="_self" href=""></a><img style="text-decoration:none;border:0;padding:0;margin:0;" src="[CACHEBUSTER]">

    Okay never-mind, it looks like WooCommerce already has the ‘ <a target=”_blank” href=” ‘ I just needed to add all of the unique code in between. (without the a tags).

    i.e.: href=""></a><img style="text-decoration:none;border:0;padding:0;margin:0;" src="[CACHEBUSTER]"

    That last post was incorrect.

    Example solution is:"></a><img style="text-decoration:none;border:0;padding:0;margin:0;" src="[CACHEBUSTER]"

    ( without the href=” )

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘External / Affiliate Product URL’ is closed to new replies.