Amazon Associates WordPress Wishlist Plugin

One of the things that’s bugged me for a while whilst having a website is that at certain times of the year when people might actually like to buy me a gift they’re unable to find my wishlist. This is mainly because they’re simple folk who might not think to check amazon for my name. I’m also signed up with amazon associates, so I decided it could do me well to post my wishlist items along with my referral tag in the links in order to earn a bob or two on my own homepage. All this data is available on the web already its just a case of putting it together.

Some keen readers might of noticed the wishlist page I stuck up recently and want something similar on their own site and (like myself) either can’t be bothered or didn’t have the time to create a plugin to pull this data together. I’m putting up here my own quick and dirty plugin I built a few weeks ago to achieve this.

It uses amazon web services to look up a wishlist, stick in a specified associates id in each of my item links and replace where I put the text (without spaces) in a post with my wishlist items. The plugin regularly updates this (hourly) as a scheduled event in wordpress in case someone decides to actually buy me something. Of course you’ll need a services key to use it, which you can easily get by signing up with amazon at aws.amazon.com. Fill out your services id, your wishlist id (found by logging into amazon and heading to your wishlist page) and your locale (the bit after amazon. so mine is .co.uk) and press the fetch items to pull all the items in. If you don’t have an associates id, feel free to leave as my own : )

I used curl to get the remote data from amazon as the file_get_content methods generally aren’t enabled on normal web hosts. If you’d like the items to be fetched less regularly, then install the plugin with and updated wp_schedule_event method in the main wishlist.php to a value of your choice.

You can download it over here.

Double alliteration in a post title? Not sure I’ve attempted that before.

[Edit: You'll need to be running on PHP5 to make use of this plugin]
[Edit: I released an updated version based on Amazon's move to use of signitures, see the details here]

This entry was posted in Geek, PHP, Software, Web and tagged , , , , . Bookmark the permalink.

28 Responses to Amazon Associates WordPress Wishlist Plugin

  1. John says:

    Thanks Ian!
    A useful plug-in at last for WP. There is something similar (or used to be) on Aaron Gustafsson’s website.

    Cheers

    John

  2. Ian says:

    I’ve used a number of wishlist ones before but they all seemed to be a bit broken the last time I checked, especially when using associate ids and the like. I guess its Amazon changing the way queries are to be made that might contribute toward that.

  3. PuReWebDev says:

    Thanks this sweet wishlist plugin. I do some development myself with their e-commerce api and even started messing around with probably the first ever Amazon Associates Video Podcast http://www.youtube.com/user/PuReWebDev

    thanks,
    PuReWebDev

  4. Ian says:

    No probs. Glad you like it.

  5. Nicole says:

    Hi, thanks for this great plugin! I changed the css of the output in wishlist_view.php a little bit into divs instead of tables. You can see how it looks like on my blog’s wishpage


    <?php
    foreach($items as $item)
    {
        
    $link $wishlist_model-&gt;getItemLink($item);
        
    $str.= "".
            
    "".
            
    "<a href='".$link."' rel="nofollow">".
            
    "getItemImage($item)."'/&gt;".
            "</a>".
            "".
            "<a href='".$link." 
    rel="nofollow">".$item-&gt;title."</a>".
            "".$item-&gt;author.
            "".($item-&gt;price/100)." 
    &euro;".
            "";
    }

    ?>


    regards, nicole

  6. Ian says:

    Hey Nicole, that’s a nice mod – thanks for sharing. I think I wanted something that would be really minimal to install, but would definitely go with a tableless option on my own site.

  7. Nicole says:

    Hi jan, I forgot to add: I’m really a replace-tables-by-divs-freak ;-) So please don’t worry about the table – it’s fine to use tables in case of a quick hack. Thinking of the wishlist as a list of data you could even say that the wishlist is indeed worth a table. :-) I only changed it because I saw the table when I was looking for a hint in the code how to integrate the wishlist into my blog page. (I had searched in your correspondig post but I couldn’t figure it out and yes, I found the wordpress-wishlist-tag at the top of the view.php) And like I told you, I can’t resist changing tables into divs ;-) However, the code in my previous post is destroyed and won’t work, so if anybody wants the css-table-free mod just mail me.

  8. Thuy Lam says:

    Thanks for sharing.

  9. Thomas says:

    Very nice …

    But all of my Amazon US items are all linking to the .co.uk site and turning up 404s when clicked.

  10. Ian says:

    @Thomas, that’s correct – if you alter the locale to .com rather than .co.uk within the wishlist settings, that should remedy it.

  11. The theme is indeed very good,I am considering to change the theme of WP.

  12. I wish my family would check my wishlist on Amazon. Then I wouldn’t have to return all the clothes they buy me.

  13. Ian says:

    I take it this plugin is only compatible with WordPress v2. I get the error “Fatal error: Call to undefined function: register_activation_hook()” when trying to activate it.

  14. Ian says:

    @Ian I’ve not tested on anything less than v2, but v2+ is what I’m running on here. I’d imagine you’re right as it seems it was introduced in v2 in the official docs.

  15. Ian says:

    It’s the second time today I’ve come across this problem. Although ‘WordPress Automatic Upgrade’ is supposed to work with v1.5.2 it also fails on an undefined function (current_user_can) which was only introduced in v2.

    Looks like I’ll have to follow the long-winded manual upgrade process.

  16. Ian says:

    OK, now fully upgraded (manually) to 2.6.3 (via 2.0.11 and 2.3.3)

    I now get the error “Fatal error: Call to undefined function: simplexml_load_string()” when I try to fetch items.

  17. Ian says:

    Hey Ian, I’m taking a wild guess you’re not running PHP5 on your server. I should have put this in the requirements for the plugin. I’ve updated the post to reflect that.

  18. Ian says:

    yep, 4.4.2

  19. Travis says:

    This looks like a great plugin and is exactly what I’m looking for.. But, I’m getting an error.

    Fatal error: Call to undefined function: simplexml_load_string() in ….home/wp-content/plugins/amazon-associates-wordpress-wishlist-plugin/models/wishlist_model.php on line 170

    (I edited out the first part of the directory)

    Thanks,
    Travis

  20. Ian says:

    Hey Travis,Looks like that may be the same error that the previous commenter Ian experienced – are you using an elderly version of PHP (pre v5) ?

  21. Nadja says:

    Hi Ian,

    I just discovered the ” add to wishlist” addon for firefox.
    It only works with the .com page but thats fine. So I was delighted find your wordpress plugin.
    Unfortunately I can not get it to work. I am not getting an error message, but ” Wasn’t able to find any items using those settings. ”
    First I thought its because i splinted the wish list in subgroups and used the id for the overall group. But even after changing the id to a sub wishlist id, I get the same message.

    Any tip for me to get it work after all?

  22. Ian says:

    Hi Nadja,I’m assuming that you’ve met the initial requirements – i.e You’ve set up a associates account and are using your aws access/secret access key in the appropriate boxes?

  23. Nadja says:

    Hi Ian, yes i did fill in all boxes.. if it was correct, I only can hope so :P

  24. Jose says:

    Hi

    Many thanks for this plugin.

    Is there any way of limiting the number of items on display?

    And randomize them?

  25. Ian says:

    Not at the moment I’m afraid. It would be easy enough to customise to do that though

  26. hubs says:

    Will this plugin include items from the Amazon “Universal Wishlist”? Or does it only include items for purchase from the amazon site?

  27. Ian says:

    I built this for personal wishlists, so I’m not sure if the universal wishlist is somehow different in the way amazon deals with them. If it has an id that displays in the address bar, your best bet would be to try it with that and see what happens…

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">