WordPress.org

Ready to get started?Download WordPress

Forums

Amazon Link
[resolved] Data in Custom fields (14 posts)

  1. capbell
    Member
    Posted 1 year ago #

    hello,

    I've been playing around with this plugin and it looks very good and helpful. Thanks for making it.

    Currently my website has "product pages" where the list price appears and a button next to it says "check offers" and goes to Amazon.

    I want to use amazon affiliate to monetize it but after many emails, they more or less said that to have a "list price" i need to use the api.

    My question is, can I with some shortcode pull the number from the list price from a product, but in a custom field? So at the moment I add a price to a custom field called "price" and my theme grabs that custom field and displays it in the specific part of the product page. Therefore adding shortcode to the editor part of my posts won't work for me.

    Similarly, I would like to add a shortcode to the custom field for the amazon url.

    Is this possible?

    Thanks again

    http://wordpress.org/extend/plugins/amazon-link/

  2. paulstuttard
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    Not that familiar with custom fields but you can use the function amazon_shortcode to return the output of the Amazon Link plugin in your theme files, so adding some code along the lines of:

    $ASIN = get_post_meta($post->ID, 'asin', true);
    if (function_exists(amazon_shortcode)  {
       $list_price = amazon_shortcode('template=price&live=1&asin=' . $my_products);
    }

    Where the price template is set up to just return the item price i.e. contains %LIST_PRICE%, %OFFER_PRICE% or %PRICE%.

    Hope this helps,

    Paul

  3. capbell
    Member
    Posted 1 year ago #

    Thanks for your helpful post!

    The custom field is pulled like this in the template for the product page:

    $showprice = isset($custom["price"][0]) ? $custom["price"][0] : '';

    So i think using something along the lines of what you shared is possible. But i'm not 100% sure how. Would I need to

    $showprice has the shortcode data, so I need to execute it in the code to get the list price number using the ASIN i entered in the custom field ($showprice) and then pass it on to your code to then php echo the $listprice variable from your code?

    And would installing the location detector make this code get the price from the relevant Amazon to the user? Most of my visitors are from the USA and the UK so ideally I'd like to show them their own Amazon.com/.co.uk prices and links.

    And if all of this is running - On my homepage there are thumbnails with each product, they all list the price too, if I were to use the same code on each of these thumbnails on the homepage (So let's say the code is executed 30 times on the homepage) would that be bad? Would it slow everything down? Would it be wiser to not show prices on the homepage?

    Thanks so much again. Trying to stay within the rules of Amazon Associates is hard work!

  4. paulstuttard
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    If you install the ip2nation database and enable 'Localise Amazon Link' then the plugin will try and provide prices from the amazon site relevant to the site visitor.

    For the plugin to provide 'live' prices you need to have valid Amazon Web Service keys and registered with the Amazon Advertising API - I have added a page on this to my site at: http://www.houseindorset.co.uk/plugins/amazon-link/getting-started/.

    If you have a large number of prices on one page then the plugin will need to make 30 requests to AWS to serve the page (this would be very slow!). So its essential that you also enable the plugin's cache to limit the number of requests.

    Cheers,

    Paul

  5. capbell
    Member
    Posted 1 year ago #

    Hey there Paul,

    Thanks again, i've made progress with it but really stuck at the moment. Forgive me for troubling you please.

    1- Some products for some reason do not have a list price and show up as "-", is there a reason for this? For example this product: amazon.co.uk/Nosefrida-Nasal-Aspirator/dp/B00171WXII

    if i put the template to display both list price of the US and UK amazon, the us shows fine but not the uk. Other products show both. Is there a way to fix this? As, i'm sure you'll understand that no one ever wants to show a "-"!

    2- This is the code I am using to get the asin from a custom field:

    $asincf = isset($custom["amazoncf"][0]) ? $custom["amazoncf"][0] : '';
    
    if (function_exists(amazon_shortcode))  {
       $list_price = amazon_shortcode('template=price&live=1&asin=' . $asincf);
    }

    and I insert the asin into the custom field called "amazoncf". This works but if I try to put this into the custom field "asin[uk]=0340993782&asin[fr]=2020479893&asin[de]=3548602045" to override the specific location asin, it doesn't work. Do you know why?

    3- Silliest question of all... How do I just echo the url of the localised asin? I tried %LINK_START%Amazon Product%LINK_END% in a template and echoed it but it literally echos the code (no execution)

    4- Is there a way to show text before a localized template? For example i want to write "RRP:" before the price if it the localisation is the UK. I want to write "List Price" if the user is from America, etc. Is that possible in the template?
    Thanks ever so much. :-)

  6. capbell
    Member
    Posted 1 year ago #

    I also forgot to ask, the code you provided me only displays the price of the asin I use, it doesn't output the localised price. How can I set it to show localised price (only the local price, nothing else) Sorry to ask such basic questions, but i read through your faq and installation, and can't figure it out :-(

  7. paulstuttard
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    Got to dash but some quick answers to keep you going!

    1. Unfortunately this is a problem with the Amazon Web Service (a lot of non-US products do not include a list price). Need to think about this one a bit more...

    2. Your code would produce the following in the shortcode:
    When asincf=0340993782
    Shortcode contains 'asin=0340993782' which is valid.

    When asincf=asin[uk]=0340993782&asin[fr]=2020479893&asin[de]=3548602045
    Shortcode contains 'asin=asin[uk]=0340993782&asin[fr]=2020479893&asin[de]=3548602045' which is not valid.

    You need it to contain just 'asin[uk]=0340993782&asin[fr]=2020479893&asin[de]=3548602045'

    e.g. make asincf='asin=0340993782' or asin[uk]=0340993782&asin[fr]=2020479893&asin[de]=3548602045

    then in the shortcode: 'template=price&live=1&' . $asincf

    3. This should work, I'll try it on my test install you are doing something like this?

    if (function_exists(amazon_shortcode))  {
       $link = amazon_shortcode('template=link&live=1&asin=' . $asincf);
       echo $link;
    }

    4. Not tried this but you could do something like:

    amazon_shortcode('template=price&text[uk]=RRP:&text[us]=List Price&live=1&asin=' . $asincf);

    Then in the price template %TEXT% %LIST_PRICE%

    I think it might be possible to do this using the plugin filters if you really want it to be done in the backend without messing around in the shortcode.

    5. It should provide the localised price if that ASIN is available at that locale, otherwise it will fall back to the default locale price. If you specify ASIN's for each locale it should work correctly.

    Paul

  8. capbell
    Member
    Posted 1 year ago #

    Incredible helpful response. Thanks again!

    1- I thought so, my solution was to create a secondary template with only %price%, and using an if = '-' I made it show the price as a backup instead of ever showing the '-' in case no list price was set.

    2- I managed to fix everything and you were right, i used an if strlen > 15 statement to distinguish between a single asin and multiple and then set the output correctly (with asin= or without for multiple). Tested it through a US proxy and my UK connection and they show the right ASIN.

    :-)

    3- link_start doesn't work for me for some reason, but instead I did this - set up a template with http://www.amazon.%TLD%/dp/%asin%/?tag=%TAG% and simply echo'd that in the correct place.

    My only concern with this is that it will literally say amazon.com/dp/ASIN/?tag=something. Is amazon okay with that or do they expect to the see all the "creative=", etc tags in the url too?

    4- I decided to just show the price as I might not always show the list price (if not set up), but I am sure that would work.

    5- You're absolutely right, I realised that the asin I was testing was from amazon.com and didn't exist in amazon.co.uk. After adjusting the code to accept specific ASIN for cases like this, it is now fixed too.

    I will rate the plugin 5 stars, especially for your helpful support here.

    Thanks again.

  9. paulstuttard
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    In answer to question 3 - I just noticed it should be %LINK_OPEN% & %LINK_CLOSE% not START and END.

    I have seen lots of sites that just use links like you have created so it probably works fine. I just used the format that Amazon provided when I created a link using their link generator.

    You might want to click on one of the links loads of times then check the affiliate page after a day or two and check that they have been counted/tracked.

    Thanks for the rating!

    Paul

  10. aangsuwarjo
    Member
    Posted 1 year ago #

    Hi,

    Sorry am new member, can u give me video about this Tutorial ?

    i hope u can help me..

    Thanks

  11. paulstuttard
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    Sorry, I don't have any video tutorials, is there something in particular you are struggling with?

    Paul

  12. aangsuwarjo
    Member
    Posted 1 year ago #

    yes. I liked your plugin. but I am a bit confused still put the API and code for Amazon to call ASIN how? ... can you please help me to solve this problem?

    1. Where can I put Amazon API code?

    2. How to embed Amazon link with Custom fields?
    Custom fields Code

    $price = str_replace("$","",get_post_meta($post->ID, "price", $single = true));
    $price = (float)str_replace(",",".",$price);
    $list_price = str_replace("$","",get_post_meta($post->ID, "list_price", $single = true));
    $list_price = (float)str_replace(",",".",$list_price);
    $saving = number_format(round($list_price - $price,2),2);
    echo str_replace(".",",",$saving);

    3. How to call code ASIN?

    thanks, before ^_^

  13. paulstuttard
    Member
    Plugin Author

    Posted 1 year ago #

    Hi,

    I'm still a little confused as to what exactly you want to achieve?

    To use the plugin to get the 'list' price and the 'offer' price you would need code like capbel posted earlier:

    $asin = get_post_meta($post->ID, "asin", $single = true);
    if (function_exists(amazon_shortcode))  {
       $price = amazon_shortcode('template=price&live=1&asin=' .
       $list_price = amazon_shortcode('template=list_price&live=1&asin=' . $asin);
    }

    Where you have created a 'price' template on the Amazon Link settings page that just contains %PRICE%. As well as a 'list_price' template that contains just %LIST_PRICE%.

    To then inject your 'savings' value back into another template you would need to use one of the %TEXT% keywords, e.g.

    echo amazon_shortcode('template=savings&asin=' . $asin .'&text1='. $saving);

    Where you have created another template on the settings page that contains something like:

    %LINK_OPEN%%TITLE%%LINK_CLOSE%, List Price %LIST_PRICE%, On Offer at %PRICE% (A saving of %TEXT1%).

    Hope this helps!

    Paul

  14. aangsuwarjo
    Member
    Posted 1 year ago #

    home to many thanks for the help. Okay I will soon try it out ...

    one more question. This pulgin requires code Amazon API to Manually Post? if iy. where can I put Amazon API code?

    thanks again ^_^

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.