Apropos this lovely wordpress plugin, which generates multiple purchase links for blogs in a pop-up format, I am reminded that I came up with a somewhat similar implementation for my website. You can see it in action on my bookshelf page, right under the heading for “This Wicked Gift.”
Goal: Have links to a number of different websites so that users can purchase books from the vendor of their choice, instead of funneling them into one or two options.
Here’s how you can use the same thing on your website. Caveats: You need a website that runs PHP. (If your website can run wordpress, it can run PHP. These days, almost everything can.)
Here’s what you need to do (after the jump).
1. Create a file. You might call it “isbngenerator.php” and the file should contain this:
<?php
  $isbn=rtrim($isbn);
  //make sure we have a properly formed isbn10 or isbn13   if (strlen($isbn)==13) {
     $isbnprefix=substr($isbn, 0, 3);      $isbnlast10=substr($isbn,3);      $isbn10first9=substr($isbn, 3, 9);
     //calculate isbn10 checkdigit from isbn13;
     $sum = ( (int)substr($isbnlast10,0,1)*10 + (int)substr($isbnlast10, 1, 1)*9 + (int)substr($isbnlast10, 2, 1)*8 + (int)substr($isbnlast10, 3, 1)*7 + (int)substr($isbnlast10, 4, 1)*6 + (int)substr($isbnlast10, 5, 1)*5 + (int)substr($isbnlast10, 6, 1)*4 + (int)substr($isbnlast10, 7, 1)*3 + (int)substr($isbnlast10, 8, 1)*2); $checkdigit = 11 - $sum % 11; if ($checkdigit==10) $checkdigit = 'X'; } else { exit("<h3>Buy this from your favorite bookstore!</h3>"); } ?>
 <b>ISBN-10</b>: <?php echo $isbn10first9 . $checkdigit; ?><br> <b>ISBN-13</b>: <?php echo $isbnprefix . '-' . $isbnlast10; ?> </p><p> <h3>Buy it Online</h3><hr><p> <a href="http://www.borders.com/online/store/TitleDetail?defaultSearchView=List&sku=<?=$isbn10first9?><?=$checkdigit?>">borders</a> | <a href="http://www.indiebound.org/book/<?=$isbn?>">indiebound</a> | <a href="http://www.booksamillion.com/product/<?=$isbn?>">b-a-m</a> <br> <a href="http://search.barnesandnoble.com/booksearch/isbninquiry.asp?ean=<?=$isbn?>">b & n</a> | <a href="http://www.amazon.com/exec/obidos/ISBN=<?=$isbn10first9?><?=$checkdigit?>">amazon</a> | <a href="http://www.powells.com/biblio?isbn=<?=$isbn?>">powell’s</a><br> <a href="http://www.bookdepository.co.uk/browse/book/isbn/<?=$isbn?>">book depository</a> | <a href="http://www.vromansbookstore.com/book/<?=$isbn?>">vroman’s</a><p>
I realize the blog formatting is cutting off the edge of those links, so you can download a .txt file containing the code here.
2. You need an ISBN. In fact, you need an ISBN-13, and so I’m really sorry to say that this is not going to work hugely well (at present) with people who have an older backlist. I’ll try to retrofit at some point but I have to admit that this was written very selfishly with the 2009 or 2010 debut author in mind. So let’s say you have your ISBN-13, and let’s say that it’s this: 978-0-373-77427-2.
Then, what you need to do is insert in the php webpage (if you don’t have php webpages, none of this is going to work!) where you want those links to appear is this:
<?php$isbn='9780373774272';include('isbngenerator.php');?>
Part of me is vaguely uneasy about the variable-scope thing, but whatever.
That will automagically generate this text:
ISBN-10: 0373774273
ISBN-13: 978-0373774272
Buy it Online
borders | indiebound | b-a-m
b & n | amazon | powell’s
Suitable for a sidebar. You can mess with the styling by adding it to the php file or styling with CSS. As you can see from mine, I’ve done a bit of additional styling beyond what I have.
If this is totally greek to you… you should send it to the person who does your web pages and ask them to play with it.
I lurve you
What Ilona said. This is fantastic. Thank you.
Thanks! Glad it’s useful.
Beyond Greek? Is that a real thing? ‘Cause I got nothing.
I am taking a beginning web design class, and then a post-beginning (not sure if it’s really intermediate) web design class after that, and I hope that when I’m done, I can put some of your wonderful information to use. I learn computer stuff fairly easily, so I’m willing to give it a go. And I wouldn’t have thought of doing it, had I not discovered your blog, so thanks!
Ooooh I like. Why is it that seeing code makes me smile. That’s the true test of a techno geek.
Wow.
I’m not messing with my website for a while, but I might try the wp plug-in.
I love you–see, I can say it without a pot of burned porridge in hand. 🙂