WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] External / Affiliate Product URL (14 posts)

  1. aplusr
    Member
    Posted 1 year ago #

    Hi,

    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.

    Thanks,

    Andrew

    http://wordpress.org/extend/plugins/woocommerce/

  2. jochemdu
    Member
    Posted 1 year ago #

    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: http://php.net/manual/en/function.preg-replace.php

  3. aplusr
    Member
    Posted 1 year ago #

    Hi,

    Thanks for responding.

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

    <a target="_self" href="http://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=1&pub=5575033840&toolid=10001&campid=5337240729&customid=&ipn=psmain&icep_vectorid=229466&kwid=902099&mtid=824&kw=lg">http://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=1&pub=5575033840&toolid=10001&campid=5337240729&customid=&ipn=psmain&icep_vectorid=229466&kwid=902099&mtid=824&kw=lg</a><img style="text-decoration:none;border:0;padding:0;margin:0;" src="http://rover.ebay.com/roverimp/1/711-53200-19255-0/1?ff3=1&pub=5575033840&toolid=10001&campid=5337240729&customid=&mpt=[CACHEBUSTER]">

    Javascript:

    <script>document.write('<a target="_self" href="http://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=1&pub=5575033840&toolid=10001&campid=5337240729&customid=&ipn=psmain&icep_vectorid=229466&kwid=902099&mtid=824&kw=lg">http://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=1&pub=5575033840&toolid=10001&campid=5337240729&customid=&ipn=psmain&icep_vectorid=229466&kwid=902099&mtid=824&kw=lg</a><img style="text-decoration:none;border:0;padding:0;margin:0;" src="http://rover.ebay.com/roverimp/1/711-53200-19255-0/1?ff3=1&pub=5575033840&toolid=10001&campid=5337240729&customid=&mpt='+Math.floor(Math.random()*999999999)+'">');</script><noscript><a target="_self" href="http://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=1&pub=5575033840&toolid=10001&campid=5337240729&customid=&ipn=psmain&icep_vectorid=229466&kwid=902099&mtid=824&kw=lg">http://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=1&pub=5575033840&toolid=10001&campid=5337240729&customid=&ipn=psmain&icep_vectorid=229466&kwid=902099&mtid=824&kw=lg</a><img style="text-decoration:none;border:0;padding:0;margin:0;" src="http://rover.ebay.com/roverimp/1/711-53200-19255-0/1?ff3=1&pub=5575033840&toolid=10001&campid=5337240729&customid=&mpt=[CACHEBUSTER]"></noscript>

    URL from website when the HTML <a> link fails:

    http://www.laptopdealscentral.com/shop/dell-latitude-d620/%3Ca%20target=%22_self%22%20href=%22http:/rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=1&pub=5575033840&toolid=10001&campid=5337240729&customid=&ipn=psmain&icep_vectorid=229466&kwid=902099&mtid=824&kw=lg%22%3Ehttp://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=1&pub=5575033840&toolid=10001&campid=5337240729&customid=&ipn=psmain&icep_vectorid=229466&kwid=902099&mtid=824&kw=lg%3C/a%3E%3Cimg%20style=%22text-decoration:none;border:0;padding:0;margin:0;%22%20src=%22http://rover.ebay.com/roverimp/1/711-53200-19255-0/1?ff3=1&pub=5575033840&toolid=10001&campid=5337240729&customid=&mpt=CACHEBUSTER%22%3E
  4. jochemdu
    Member
    Posted 1 year ago #

    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 http://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=1&pub=5575033840&toolid=10001&campid=5337240729&customid=&ipn=psmain&icep_vectorid=229466&kwid=902099&mtid=824&kw=lg

  5. aplusr
    Member
    Posted 1 year ago #

    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.

  6. aplusr
    Member
    Posted 1 year ago #

    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.

  7. aplusr
    Member
    Posted 1 year ago #

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

  8. Jeremiah
    Member
    Posted 1 year ago #

    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.

  9. cassim56
    Member
    Posted 1 year ago #

    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'); ?>

    Cheers

  10. zzzlumber
    Member
    Posted 1 year ago #

    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 http://www.spiderwebmall.com

  11. aplusr
    Member
    Posted 1 year ago #

    Active Sample Links:

    Original Link:

    http://www.ebay.com/sch/PC-Laptops-Netbooks-/177/i.html?_stpos=11213&_sop=15&gbr=1&_fcid=1&_localstpos=11213&_from=R40&_clu=2&_nkw=d620&_pppn=r1&_dcat=177&LH_ItemCondition=1000%7C1500%7C2000

    Affiliate Link:

    <a target="_self" href="http://rover.ebay.com/rover/1/711-53200-19255-0/1?ff3=4&pub=5575033840&toolid=10001&campid=5337240729&customid=&mpre=http%3A%2F%2Fwww.ebay.com%2Fsch%2FPC-Laptops-Netbooks-%2F177%2Fi.html%3F_stpos%3D11213%26_sop%3D15%26gbr%3D1%26_fcid%3D1%26_localstpos%3D11213%26_from%3DR40%26_clu%3D2%26_nkw%3Dd620%26_pppn%3Dr1%26_dcat%3D177%26LH_ItemCondition%3D1000%257C1500%257C2000">http://rover.ebay.com/rover/1/711-53200-19255-0/1?ff3=4&pub=5575033840&toolid=10001&campid=5337240729&customid=&mpre=http%3A%2F%2Fwww.ebay.com%2Fsch%2FPC-Laptops-Netbooks-%2F177%2Fi.html%3F_stpos%3D11213%26_sop%3D15%26gbr%3D1%26_fcid%3D1%26_localstpos%3D11213%26_from%3DR40%26_clu%3D2%26_nkw%3Dd620%26_pppn%3Dr1%26_dcat%3D177%26LH_ItemCondition%3D1000%257C1500%257C2000</a><img style="text-decoration:none;border:0;padding:0;margin:0;" src="http://rover.ebay.com/roverimp/1/711-53200-19255-0/1?ff3=4&pub=5575033840&toolid=10001&campid=5337240729&customid=&mpt=[CACHEBUSTER]">
  12. aplusr
    Member
    Posted 1 year ago #

    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).

  13. aplusr
    Member
    Posted 1 year ago #

    i.e.: href="http://rover.ebay.com/rover/1/711-53200-19255-0/1?ff3=4&pub=5575033840&toolid=10001&campid=5337240729&customid=&mpre=http%3A%2F%2Fwww.ebay.com%2Fsch%2FPC-Laptops-Netbooks-%2F177%2Fi.html%3F_stpos%3D11213%26_sop%3D15%26gbr%3D1%26_fcid%3D1%26_localstpos%3D11213%26_from%3DR40%26_clu%3D2%26_nkw%3Dd620%26_pppn%3Dr1%26_dcat%3D177%26LH_ItemCondition%3D1000%257C1500%257C2000">http://rover.ebay.com/rover/1/711-53200-19255-0/1?ff3=4&pub=5575033840&toolid=10001&campid=5337240729&customid=&mpre=http%3A%2F%2Fwww.ebay.com%2Fsch%2FPC-Laptops-Netbooks-%2F177%2Fi.html%3F_stpos%3D11213%26_sop%3D15%26gbr%3D1%26_fcid%3D1%26_localstpos%3D11213%26_from%3DR40%26_clu%3D2%26_nkw%3Dd620%26_pppn%3Dr1%26_dcat%3D177%26LH_ItemCondition%3D1000%257C1500%257C2000</a><img style="text-decoration:none;border:0;padding:0;margin:0;" src="http://rover.ebay.com/roverimp/1/711-53200-19255-0/1?ff3=4&pub=5575033840&toolid=10001&campid=5337240729&customid=&mpt=[CACHEBUSTER]"

  14. aplusr
    Member
    Posted 1 year ago #

    That last post was incorrect.

    ...

    Example solution is: http://rover.ebay.com/rover/1/711-53200-19255-0/1?ff3=4&pub=5575033840&toolid=10001&campid=5337240729&customid=&mpre=http%3A%2F%2Fwww.ebay.com%2Fsch%2FPC-Laptops-Netbooks-%2F177%2Fi.html%3F_stpos%3D11213%26_sop%3D15%26gbr%3D1%26_fcid%3D1%26_localstpos%3D11213%26_from%3DR40%26_clu%3D2%26_nkw%3Dd620%26_pppn%3Dr1%26_dcat%3D177%26LH_ItemCondition%3D1000%257C1500%257C2000">http://rover.ebay.com/rover/1/711-53200-19255-0/1?ff3=4&pub=5575033840&toolid=10001&campid=5337240729&customid=&mpre=http%3A%2F%2Fwww.ebay.com%2Fsch%2FPC-Laptops-Netbooks-%2F177%2Fi.html%3F_stpos%3D11213%26_sop%3D15%26gbr%3D1%26_fcid%3D1%26_localstpos%3D11213%26_from%3DR40%26_clu%3D2%26_nkw%3Dd620%26_pppn%3Dr1%26_dcat%3D177%26LH_ItemCondition%3D1000%257C1500%257C2000</a><img style="text-decoration:none;border:0;padding:0;margin:0;" src="http://rover.ebay.com/roverimp/1/711-53200-19255-0/1?ff3=4&pub=5575033840&toolid=10001&campid=5337240729&customid=&mpt=[CACHEBUSTER]"

    ( without the href=" )

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.