Archive for the ‘Amazon’ Category

Amazon Plugin Ported to WP 1.5

February 24th, 2005 by daryl

I’ve updated the Amazon plugin to work with WordPress 1.5. The plugin uses a class called “Snoopy” to connect to Amazon, and this, it turns out, as been added as a class in the core WordPress code. So when I redefined it in my plugin, it was causing a problem with the Dashboard, which was trying to reinclude the class. The fix (thanks to George for beating me to the punch on diagnosing the problem and sending in a fix) can be downloaded here. The changes included deleting the Snoopy class definition and requiring snoopy-class.php from wp-includes.

Amazon Wishlist Plugin Updated

September 20th, 2004 by daryl

Tomi Junnila was kind enough to submit two edits to the Amazon Wishlist plugin. They include the ability to search non-US Amazon stores and an enhancement to the way multiple pages of results are fetched. (Formerly, it had been one page or all pages, with a request sent per batch of ten. So if you had 600 items in your wish list, you were sending 60 requests in order to print a single random item. Tomi’s change allows you to specify the number of pages of results to return, affording you more than the default ten results without blackholing you into request hell. Thanks, Tomi!

Download from the usual link in the nav bar.

Amazon Wishlist — Now with CD Artists

September 3rd, 2004 by daryl

Courtesy of Ken Scott, the Amazon Wishlist plugin now displays artists for CDs appearing in your wish list. You can download the plugin from the usual place. Thanks for this, Ken.

Amazon Wishlist Updated Again

August 17th, 2004 by daryl

I’ve added some functionality to the Amazon Wishlist plugin that allows the user to define where to display the output. As in the initial version, the output can be displayed immediately after the category listing. This option will be best for those not inclined to edit their templates in any way. The second option is to invoke a function named “get_amazon_wishlist()” within any template to display the information.

In order to display the book information as a coda to the category listing, one need only edit the plugin’s first line of uncommented code:

[php]
$aw_show_after_cats = 0;
[/php]

Setting this variable to 1 causes the book to be displayed automatically after the category listing.

Leaving the variable set to 0 suppresses the automatic display of the book. If you wish to apply the plugin to your templates manually, you’ll need to edit wp-includes/template-functions-general.php to add the following function:

[php]
function get_amazon_wishlist(){
echo amazon_wishlist(”");
}
[/php]

Optionally, you could also just add the following inline within your template:

[php]
echo amazon_wishlist(”");
[/php]

Both methods simply call the plugin function.

The revised plugin can be downloaded from the original url, here.

Amazon Wishlist Updated

August 16th, 2004 by daryl

A user reported that the Amazon Wishlist plugin wasn’t returning results from any but the first ten books on her list. Sure enough, I checked, and Amazon’s API returns only ten results at a time. So I’ve extended the functionality. You can now set an option that tells the code whether to check the whole list or whether to check just the first ten books. In order to check beyond the first ten results, multiple requests have to be made. So if your list is 50 pages long (500 books), that’s 50 requests that have to be made to the Amazon Web service in order to display one random book on your site. If you’ve got a lot of books, you might want to opt for selecting from the short list, which I believe will usually represent your most recent additions. In any case, the additional option you can change is at the bottom of all the other variables you can set near the top of the script and looks like this:

[php]
$aw_search_all = 0; //Set to 1 to return all wishlist results rather than first 10 (requires additional requests, so longer processing)
[/php]

It’s set to 0 by default, just to be safe.

I’ve also updated a bug that was causing an occasional error when the author block was being displayed. You’ll definitely want to download the new version (same location as the old version) to get this fixed or you’ll have “invalid argument passed to foreach” errors displayed sporadically on your page.

The next planned update is to allow you to display your book anywhere on the page. Currently, I just piggyback it on top of the category listing. No telling when I’ll get to that update. If there’s any demand, I may also add code that allows you to set a page threshold so that if you have 500 books on your list but want to display from more than the first 10 (but not all 500), you can set a maximum number of requests.

Amazon Wishlist

August 9th, 2004 by daryl

Another Update (Sept. 3, 2004): I’ve added a category for the amazon plugin that’ll list all relevant posts so I don’t have to keep going back and adding these stupid updates. Be sure to read all posts in the category for complete details.

Update (Aug. 16, 2004): I’ve added some functionality and fixed a bug. Check here for details.

I’ve just written my first WordPress plugin. Actually, I had previously modified the acronym plugin to allow me to specify some common words that should always be associated with links (only later did I notice that the author of the original plugin had already done just this). Amazon Wishlist is my first original plugin, though, and even at that, the bulk of the code isn’t mine. I found a fairly concise script that interfaces with the Amazon API and another that actually handles making the connection, and I wrapped some code around the results to make it all into a nice configurable plugin for WordPress. Incidentally, there is another Amazon plugin here that allows you very easily to browse books and insert them into your entries. Very nifty, but it serves a different purpose.

Installation
You have only to download the plugin, stick it in your wp-content/plugins directory, edit a few variables, optionally add some style sheet definitions, and activate the plugin using your control panel. Straight from the code itself:

[php]
$aw_dev_token=”; //Get this from http://www.amazon.com/gp/aws/landing.html.
$aw_associates_id=”; //Optional; set to empty string if not applicable.
$aw_type=’lite’; //could also be heavy, though it doesn’t seem to make a difference in the search results.
$aw_wishlist_id=”; //The id of the wish list you wish to search. Hint: Search for (don’t simply go to) your wish list and copy the id from the end of the URL.

$aw_header=’Amazon Wish List’; //Used to label the box.
$aw_show_author = 1; //Set to 0 to suppress.
$aw_image_size = ‘Medium’; //’Small,’ ‘Medium,’ or ‘Large’
$aw_show_price = 1; //Set to 0 to suppress.
[/php]

Here’s hoping it’s not buggy and that it helps somebody out. You can see it in action in my sidebar.