Support forum login

©2006-2010 IAAI Software

Contact Us

Amazon API

Submitted by support on Fri, 2009-07-24 15:01.

Hi everyone,

As a very popular addition to Price Tapestry, and with the requirement for Amazon Web Services (AWS) API requests to be authenticated by 15th August 2009, i've updated the script and consolidated the various Amazon related threads into this single page to make it much easier for new users to find the relevant info.

If you are a member of the Amazon Associate Program (.co.uk / .com (US) / .de / .jp) you can complement your Price Tapestry generated product pages and/or search results with live Amazon results via Amazon Web Services. To use the web services, in addition to an associate account you will also need an AWS account.

Download and Installation

Click here to download, and unzip amazon.php to your local computer.

Open the file, and edit the following lines at the top of the script to contain your AWS access key ID, secret access key, and your associate tag where indicated. When logged in to AWS, your access key ID and secret access key can be found on this page.

  $amazonAWSAccessKeyId = "YOUR_ACCESS_KEY_ID";
  $amazonSecretAccessKey = "YOUR_SECRET_ACCESS_KEY";
  $amazonAssociateTag = "YOUR_ASSOCIATE_TAG";

To install, simply upload the modified amazon.php to your main Price Tapestry installation folder (probably the top level folder of your site unless you have installed Price Tapestry into a sub-directory).

Usage

Amazon results can be added to both search.php and products.php. In both files, to include Amazon results at the end of the page, look for the the following code towards the end of the script:

  require("html/footer.php");

...and REPLACE this with:

  require("amazon.php");
  require("html/footer.php");

Customisation for non-UK Locales

If you are not an amazon.co.uk associate you will need to edit line 122 as appropriate, for example by replacing .co.uk with .com (US associates).

Customisation for Niche Sites

One of the parameters in the AWS request generated by the script is "SearchIndex". A value of "Blended" is used by default, which searches all categories. If you are using the script on a niche site, it may be worthwhile using a more appropriate value based on the subject matter of your site. A complete list of SearchIndex values available per locale can be found here. The SearchIndex value can be changed on line 128 of the script.

IMPORTANT: At time of writing, the AWS ECommerce Service is free of charge, but make sure that you are checking the email address associated with your AWS account in case this situation changes in the future.

Submitted by jmsobe on Thu, 2009-08-20 13:59.

Thanks for releasing this. When I search for products I am only seeing 4 items from amazon. At the top of the search results screen it says that no items have been found oddly enough. Any ideas?

Submitted by support on Thu, 2009-08-20 14:18.

Hi,

Regarding the number of Amazon results; this is limited to 4 in the script, but you can change this to whatever value you wish by modifying the following code on line 7 of amazon.php:

  $amazonItemMax = 4;

As Amazon results are API based and not from the local database, it is certainly possible that a query might not return any local results (I presume that search is working correctly for products that are in your database); but for there to be results from Amazon.

What may be worth doing because of this; would be to add some kind of text or more indication that the following results are from parter sites; for example where you have added the code:

  require("amazon.php");

...you could instead use:

  print "<p>Results from Amazon.com...</p>";
  require("amazon.php");

Hope this helps!

Cheers,
David.

Submitted by jmsobe on Fri, 2009-08-21 19:42.

Thanks a bunch, can other data be returned from amazon like product reviews or even just review star rating?

Submitted by jmsobe on Fri, 2009-08-21 19:52.

Another quick question I hope anyway. If I wanted to return a larger image in the feed can this be done easily? The medium image would be preferred. Thanks for your help

Submitted by daem0n on Mon, 2009-08-24 02:38.

Hi David,

Is there a way that if no results are found that I can return something like:

<p>Sorry, no results from Amazon were found! </p>

Thanks a lot! -Joe

Submitted by support on Mon, 2009-08-24 08:33.

Hi Joe,

Sure - at the very end of the script simply add the following code:

  if (!$amazonItemCount)
  {
    print "<p>Sorry, no results from Amazon were found!</p>";
  }

Cheers,
David.

Submitted by daem0n on Mon, 2009-08-24 23:44.

Thanks as always!

-Joe

Submitted by Deanh01 on Fri, 2009-08-28 16:29.

Hi David
Is there a way to add that message to the ebay code?

Thank You
Dean

Submitted by support on Fri, 2009-08-28 16:32.

Hi Dean,

It should be exactly the same, but using:

$ebayItemCount

...in place of

$amazonItemCount

...for example:

  if (!$ebayItemCount)
  {
    print "<p>Sorry, no results from eBay were found!</p>";
  }

Cheers,
David.

Submitted by Deanh01 on Fri, 2009-08-28 16:53.

Ok Works great
Thank You
Dean

Submitted by crounauer on Wed, 2009-09-09 17:40.

Hi David,

I went down the route of using OOP with the amazon API along with the neat little encrypton script you kindly wrote for us all.

$response = simplexml_load_file($awsUrl);

I am however getting this error message and I can't seem to figure out what is causing it. Could you perhaps point me in the right direction please?

An error occurred in script '/var/www/vhosts/xxxx.co.uk/httpdocs/electricals/modules/amazon/searchAM.php' on line 19: simplexml_load_file(http://webservices.amazon.co.uk/onca/xml?Service=AWSECommerceService&amp;AssociateTag=xxxxx&amp;AWSAccessKeyId=xxxxx&amp;Operation=ItemSearch&amp;ResponseGroup=Medium,EditorialReview&amp;BrowseNode=560798&amp;MerchantId=All&amp;Condition=All&amp;Availability=Available&amp;SearchIndex=Electronics&amp;Keywords=electricalsHEWLETPACK+2015TONER+Q7553A&amp;Sort=salesrank&amp;Version=2009-01-06&amp;Timestamp=2009-09-08T22:38:56Z&amp;Signature=xxxxxxxxxxxxxx) [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: failed to open stream: HTTP request failed! HTTP/1.1 503 Service Temporarily Unavailable

Thanks,
Simon

Prices Compare

Submitted by support on Wed, 2009-09-09 17:50.

Hi Simon,

That's indicating that an HTTP 503 error occurred during the request. The first thing to do is to debug the request by printing out the URL being constructed by your script and then requesting it manually in your web browser.

If it seems to be OK, double-check HTTP requests in general as it might be something caused by the local network, for example:

<?php
  $response 
file_get_contents("http://www.example.com/");
?>

If that generates the same error; it might be worth giving CURL a try as an alternative. The following block of code should be equivalent to the line of code in your post:

$ch = curl_init($awsUrl);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$xml = curl_exec($ch);
$response = simplexml_load_string($xml);

Hope this helps!

Cheers,
David.

Submitted by babrees on Thu, 2009-09-10 13:31.

Just putting this on my site and I'm getting products with 0.00 value. Is there anyway we can exclude anything with no price?

Also, I have managed to change the layout (through trial and error ) but I haven't been able to make the price bold - is there a way to do this?

I have the price in a column on it's own, so the line is:

print $config_currencyHTML.tapestry_decimalise($item["OFFERSUMMARY/LOWESTNEWPRICE/FORMATTEDPRICE"]);

---------
Jill

Submitted by support on Thu, 2009-09-10 13:44.

Hi Jill,

Products with a zero price can be excluded by adding a check/return at the top of the myAmazonRecordHandler function in amazon.php. If you look for the following code:

  function myAmazonRecordHandler($item)
  {

...and then INSERT on the next line:

  if (tapestry_decimalise($item["OFFERSUMMARY/LOWESTNEWPRICE/FORMATTEDPRICE"])==0.00) return;

The best way to bold the price is probably a style attribute on the table cell. To do this, look for the following code around line 32:

    print "<td valign='middle' align='center'>";

...and REPLACE this with:

    print "<td valign='middle' align='center' style='font-weight:bold;'>";

Cheers,
David.

Submitted by KGP on Tue, 2009-10-13 16:24.

what is the delay when fetching results from both amazon and local db (price tapestry db i mean)?

cause i was having problems all the time i had amazon api on cause the request and results would delay the whole search results page and/or product page (in case i did both or either of search results or product)

Submitted by support on Tue, 2009-10-13 16:29.

Hi,

There will be a slight delay caused by the round-trip to the API server; however what you could do, if Amazon products are being displayed at the end of the page; would be to issue a flush() statement immediately before the call to require("amazon.php"); for example:

  flush();
  require("amazon.php");

Bear in mind that if you are using a table design the browser may actually hold back displaying cell contents until the closing table tag has been received...

Hope this helps!

Cheers,
David.

Submitted by Rocket32 on Sat, 2009-10-17 17:17.

I am having products displayed with prices $0.00. When I click on the product, it has a price on the Amazon Site.
Is there a reason that the prices are not showing correctly for some products?

Submitted by support on Mon, 2009-10-19 09:40.

Hi,

That's interesting that a different price is displayed on the destination that is returned in the API. See this comment above regarding suppressing zero prices as shown in the API; but if you could let me know what search index you are using (if not "Blended"), and the keywords being used in the query I'll run them through my test installation and look at the XML response to see if there is something we should be doing slightly differently (such as looking at a different price field in this instance...)

Cheers,
David.

Submitted by moggiex on Sat, 2009-11-07 15:18.

For anyone else having problems working out why this isn't working for them see the post below from http://www.pricetapestry.com/node/2972


Hi Keeop,

Did you upgrade to the authenticated version from this thread?

As a simple debug exercise to see what is being returned from Amazon (which will normally indicate the problem), look for the following code on line 131:

$url = amazonSign($url,$amazonSecretAccessKey);
...and then ADD the following code on the next line:

$xml = file_get_contents($url);
print $xml;exit();
Cheers,
David.

Submitted by moggiex on Sat, 2009-11-07 15:35.

Bingo, I found the issue!

The clocks moved a few weeks back, my server was still running an hour behind, I updated the time on it and it works fine!

Set Date/Time from the command line/SSH:
http://www.cyberciti.biz/faq/howto-set-date-time-from-linux-command-prompt/

Matt

Submitted by support on Sat, 2009-11-07 19:23.

Subtle!

Thanks for pointing that out, Matt!

Cheers,
David.

Submitted by philstone on Tue, 2009-11-17 14:40.

Hi David

hope your well

was wondering if you could help me, products appearing in the amazon part of the script that cost over £1000 appear wrong

eg: Amazon Price of a product - £1,493.84 - but £1.49 shows

would appreciate your knowledge in fixing this
thanks

Phil Stone
www.buy24-7.net

Submitted by support on Tue, 2009-11-17 15:02.

Hi Phil,

This is happening because Price Tapestry is by default set-up to handle the comma as a decimal point; as it common in some product feeds (particularly in the currencies of countries where a comma is used like a decimal point).

To fix this, look for the following code on line 33:

    print $config_currencyHTML.tapestry_decimalise($item["OFFERSUMMARY/LOWESTNEWPRICE/FORMATTEDPRICE"])."<br />";

...and REPLACE this with:

    $item["OFFERSUMMARY/LOWESTNEWPRICE/FORMATTEDPRICE"] =
      str_replace(",","",$item["OFFERSUMMARY/LOWESTNEWPRICE/FORMATTEDPRICE"]);
    print $config_currencyHTML.tapestry_decimalise($item["OFFERSUMMARY/LOWESTNEWPRICE/FORMATTEDPRICE"])."<br />";

Cheers,
David.

Submitted by philstone on Tue, 2009-11-17 15:16.

thanks so much dave!!

Best support I've ever had with any product!!!

thanks

Phil Stone
www.buy24-7.net

Submitted by jim on Mon, 2009-11-23 10:26.

Hi David,

Got this mod working nicely... but is it possible if there isn't an image, for a spacer.gif to be used instead?

Submitted by support on Mon, 2009-11-23 10:36.

Hi Jim,

Sure - on line 24 of amazon.php you will find:

print "<img width='80' src='".$item["SMALLIMAGE/URL"]."' />";

...REPLACE this with:

if (!$item["SMALLIMAGE/URL"]) $item["SMALLIMAGE/URL"] = "/images/spacer.gif";
print "<img width='80' src='".$item["SMALLIMAGE/URL"]."' />";

(i've used /images/ infront of spacer.gif; but if it's in the top level folder just use /spacer.gif)

Cheers,
David.

Submitted by jim on Tue, 2009-11-24 00:01.

perfect. thanks David!

Submitted by jim on Mon, 2009-11-30 04:43.

Hi David, I'm encountering a small problem whilst trying getting my page to validate (XHTML 1.0 Transitional) using the Amazon API mod.

The site was tripping up when the title of an item contained an apostrophe...
To try and fix that I tried to use some hacky code below (eg title=\"".) but now I also have problems when the item title contains a quote (eg. Kiss With a Fist [7" VINYL])

    print "<tr>";
    print "<td width='40'>";
if (!$item["SMALLIMAGE/URL"]) $item["SMALLIMAGE/URL"] = "/pt/images/spacer-40x40.gif";
    print "<a title=\"".$item["ITEMATTRIBUTES/TITLE"]."\" target='_blank' href='".$item["DETAILPAGEURL"]."'><img width='40' height='40' src='".$item["SMALLIMAGE/URL"]."' alt=\"".$item["ITEMATTRIBUTES/TITLE"]."\" /></a>";
    print "</td>";
    print "<td width='30' valign='middle' align='center'>";
    print "<b><a title=\"".$item["ITEMATTRIBUTES/TITLE"]."\" class='bandlink' target='_blank' href='".$item["DETAILPAGEURL"]."'>".$config_currencyHTML.tapestry_decimalise($item["OFFERSUMMARY/LOWESTNEWPRICE/FORMATTEDPRICE"])."</a></b>";
    print "</td>";
    print "<td width='224' valign='middle'>";
    print "<b><a title=\"".$item["ITEMATTRIBUTES/TITLE"]."\" target='_blank' href='".$item["DETAILPAGEURL"]."'>".$item["ITEMATTRIBUTES/TITLE"]."</a></b>";
    print "</td>";
    print "</tr>";

Is there a way to make the title 'safe' ?
(I assume the Amazon API doesn't render ampersands as & either - is it easy to replace space&space with space&space ?)

thanks :)

Submitted by support on Mon, 2009-11-30 09:43.

Hi Jim,

Where adding "unknown" data into an XHTML attribute; use htmlentities(), for example:

title='".htmlentities($item["ITEMATTRIBUTES/TITLE"],ENT_QUOTES)."'

The ENT_QUOTES constant makes sure that both ' and " are encoded.

Hope this helps!

Cheers,
David.

Submitted by jim on Mon, 2009-11-30 11:07.

Thanks David :)

Submitted by philstone on Wed, 2009-12-09 11:25.

Hi David

trying to tweak the amazon.php script, on some of my site i have specialized products into sub categories eg video games, the problem is on the ds pages, amazon results show xbox and playstation games also, is there anyway i could add text after the keywords eg ds, so that when it searches amazons database it returns the results keywords DS?

regards

Phil Stone
www.buy24-7.net

Submitted by support on Wed, 2009-12-09 15:11.

Hello Phil,

Sure - simply replace the code to require amazon.php with the following, edited as required for each installation:

  $q .= " DS";
  require("amazon.php");

Note the space in front of the keywords to append to $q!

Cheers,
David.

Submitted by urmyworld on Sat, 2009-12-26 22:37.

Hello David,

I have installed this script on my website but I am not getting any results whatsoever from Amazon.co.uk

The website is television related and I would imagine there is plenty of related content on Amazon.

I have checked my website search with the same search in Amazon and products do show in Amazon.

My access keys are correct

any ideas?

best regards

David S S

Submitted by support on Sun, 2009-12-27 15:41.

Hi David,

If you're sure everything is correct, the thing to do is to print the response from Amazon to the screen, which will normaly indicate the reason for there being no results. To do this, in place of the following code starting at line 131:

    $url = amazonSign($url,$amazonSecretAccessKey);
    // fetch the response and parse the results
    MagicParser_parse($url,"myAmazonRecordHandler","xml|ITEMSEARCHRESPONSE/ITEMS/ITEM/");

Use:

    $url = amazonSign($url,$amazonSecretAccessKey);
    $xml = file_get_contents($url);
    // fetch the response and parse the results
    print "<textarea cols='80' rows='4'>".htmlentities($xml)."</textarea>";
    MagicParser_parse("string://".$xml,"myAmazonRecordHandler","xml|ITEMSEARCHRESPONSE/ITEMS/ITEM/");

Cheers,
David.

Submitted by urmyworld on Thu, 2010-01-07 10:55.

Hello David,

I did as you suggested above and the error messages onscreen are as follows:

Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /home/XXXXXXX/public_html/amazon.php on line 132

Warning: file_get_contents(http://webservices.amazon.co.uk/onca/xml?Service=AWSECommerceService&Version=2009-03-01&Operation=ItemSearch&AWSAccessKeyId=XXXXXXXXXXXXXX&AssociateTag=XXXXXXXXX-21&ResponseGroup=Medium&SearchIndex=Electronics&Keywords=Sony+KDL+52V4000&Timestamp=2010-01-07T10:48:49Z&Signature=18CC%2FPRK5QPI%2FzNh33FukoJyUEJLQPm7JKPwSJEdB6k%3D) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /home/XXXXXXX/public_html/amazon.php on line 132

any ideas?

best regards

David S S

Submitted by support on Thu, 2010-01-07 11:00.

Hi David,

That indicates the fopen()'ing URLs is disabled on your PHP configuration. Now, before contacting your host to see if they would be happy to enable this for you account (I assume that you are running on a shared hosting account rather than VPS / Dedicated server) it's worth trying CURL as an alternative method for retrieving the remote URL. To do this, in place of the original code:

    $url = amazonSign($url,$amazonSecretAccessKey);
    // fetch the response and parse the results
    MagicParser_parse($url,"myAmazonRecordHandler","xml|ITEMSEARCHRESPONSE/ITEMS/ITEM/");

Have a go with:

    $url = amazonSign($url,$amazonSecretAccessKey);
    // fetch the response and parse the results
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $xml = curl_exec($ch);
    MagicParser_parse("string://".$xml,"myAmazonRecordHandler","xml|ITEMSEARCHRESPONSE/ITEMS/ITEM/");

Hope this helps!

Cheers,
David.

Submitted by urmyworld on Thu, 2010-01-07 11:12.

Hello David,

I tried that and now I am getting

Parse error: syntax error, unexpected T_STRING in /home/xxxxxxx/public_html/amazon.php on line 137

best regards

David S S

Submitted by support on Thu, 2010-01-07 11:17.

Hi David,

Sorry - there was a semi-colon missing from...

    $xml = curl_exec($ch);

I've corrected the code above also.

Cheers,
David.

Submitted by urmyworld on Thu, 2010-01-07 12:23.

Hello David,

Happy New Year!!

All fixed, thank you for your help once again.

Although I have just noticed that the Amazon links do not open in a new window.

Can this be changed?

best regards

David S S

Submitted by support on Thu, 2010-01-07 12:38.

Hi David,

Sure - the link is generated by this code (line 34):

    print "<nobr><a href='".$item["DETAILPAGEURL"]."'>More Information</a></nobr>";

...simply replace with:

    print "<nobr><a target='_BLANK' href='".$item["DETAILPAGEURL"]."'>More Information</a></nobr>";

Cheers,
David.

Submitted by rsachoc on Sun, 2010-05-16 18:53.

Hi David

Is there a way to search across multiple "SearchIndex" - for my site its not ideal to use blended, but more beneficial to use two or three of the categories.

Thanks

Submitted by support on Mon, 2010-05-17 10:17.

Hi,

Sure - you can specify a comma separated list as the value for searchIndex, e.g.

    $url .= "&SearchIndex=Books,DVD,Electronics";

Cheers,
David.

Submitted by rsachoc on Mon, 2010-05-17 20:09.

Hi David

That didn't seem to work, but I tried

$url .= "&SearchIndex=Books&DVD&Electronics";

Which oddly enough works for certain combinations of 2 of the 3 searchindexes, but not for all 3 at the same time (and the order which you enter them also seems to matter)?

Submitted by support on Tue, 2010-05-18 08:14.

Hi,

& is actually significant within a URL - it might be worth trying %20 which url decodes to a space...

$url .= "&SearchIndex=Books%20DVD%20Electronics";

Cheers,
David.

Submitted by jim on Sat, 2010-05-22 09:02.

Hi David, I have a couple of questions if you have a moment:

I'm trying to implement Amazon results on a new small (~100 products) niche site (powered by Wordpress), alongside PT price comparison results.
Can this Amazon mod be used in conjunction with the pricesExternal.php mod?

I tried putting an extra line in:

require($common_path."amazon.php");

but the q value isn't going to be the same?

Would it be an idea to use the Amazon ASIN as a value instead? (although sometimes there may be multiple ASINs I'd like to pull in)

I guess I could do this another way by using a Custom Field to specify a query that exactly matches Amazon's title - or stick the ASIN(s) into a Custom Field(s)

Do you have any suggestions?

thank you!
Jim

Submitted by support on Sat, 2010-05-22 18:53.

Hi Jim,

The only reason why it won't be working is because of the line to include MagicParser.php in amazon.php. To fix this, in your amazon.php look for the following code at around line 6:

  require("includes/MagicParser.php");

...and REPLACE that with:

  require($common_path."includes/MagicParser.php");

(this won't stop it working on your main site as $common_path will be empty)

That should be all it is!

Cheers,
David.

Submitted by mattwalker on Mon, 2010-07-12 03:27.

Hi David,

I'm having a bit of trouble getting amazon results to show on my wordpress site. Though results come up fine within PT I seem to be getting this in wordpress:

Fatal error: Cannot redeclare myamazonrecordhandler() (previously declared in /home/xxxxxxx/public_html/buyvuvuzela.org.uk/price_tapestry/amazon.php:9) in /home/xxxxxxx/public_html/buyvuvuzela.org.uk/price_tapestry/amazon.php on line 39

I've placed require($common_path."amazon.php"); at the end of the PricesExternal.php script. Prior to this nothing from amazon.php was appearing in wordpress.

Thanks,
Matt

Submitted by support on Mon, 2010-07-12 05:40.

Hi Mat,

According to that error, amazon.php has already been included - which could happen if you have already called pricesExternal.php on that page. To fix that particular issue; change the require() line in pricesExternal.php to the following:

require($common_path."amazon.php");

...however, there is one more change required within amazon.php itself which is the call to include MagicParser.php. Look for the following code at line 6:

require("includes/MagicParser.php");

...and REPALCE with:

require($common_path."includes/MagicParser.php");

Hope this helps!

Cheers,
David.

Submitted by paullas on Thu, 2010-07-15 11:34.

hi

can anyone tell me where i find my $amazonAssociateTag ?

paul

Submitted by support on Thu, 2010-07-15 11:48.

Hi Paul,

If you login to your associate account (.co.uk / .com (US) / .de / .jp) at the top left you will see your "Tracking ID" displayed in a box - that's what you need to use for $amazonAssociateTag...

Cheers,
David.

Submitted by mattwalker on Fri, 2010-07-16 05:07.

Hi David

I've placed require($common_path."amazon.php"); in pricesExternal.php and changed line 6 in amazon.php though I'm still getting the same result. I've also tried other possible solutions from the ebay thread but to no avail. Could there be something else interfering in the process?

Thanks,
Matt

Submitted by support on Fri, 2010-07-16 08:01.

Hi Matt,

If including via pricesExternal.php, in addition replace the following code in amazon.php

  require("includes/MagicParser.php");

...with:

  require($common_path."includes/MagicParser.php");

(that won't affect running within the normal Price Tapestry installation as $common_path will be empty)

Cheers,
David.

Submitted by mattwalker on Fri, 2010-07-16 14:46.

Hi David,

Yes, I've done this already but it still produces the same result:

Fatal error: Cannot redeclare myamazonrecordhandler() (previously declared in /home/wildhike/xxxxxxxxx/buyvuvuzela.org.uk/shopping/amazon.php:9) in /home/xxxxxxxx/public_html/buyvuvuzela.org.uk/shopping/amazon.php on line 39

It works fine within PT itself. Just doesn't come though to Wordpress.

Thanks,
Matt

Submitted by support on Fri, 2010-07-16 14:55.

Hi Matt,

It sounds like amazon.php is being included more than once...

Can you post the calling code you are using on the page that is displaying the error?

Cheers,
David.

Submitted by mattwalker on Fri, 2010-07-16 15:00.

Hi David,

Sure,

<?php
  $common_baseHREF 
"http://buyvuvuzela.org.uk/shopping/";
  
$common_path "/home/wildhike/public_html/buyvuvuzela.org.uk/shopping/";
  
$_GET["q"] = "ALLI 60MG WEIGHT LOSS AID - 42 CAPSULES";
  require(
$common_path."pricesExternal.php");
?>

Cheers,
Matt

Submitted by support on Fri, 2010-07-16 15:30.

Hi Matt,

Could you email me your pricesExternal.php and amazon.php and if possible a link to the page where the above calling code is running, and I'll check it out...

Cheers,
David.

Submitted by mattwalker on Thu, 2010-07-22 14:40.

Hi David,

How can I add an Amazon logo to the amazon table? I've tried to direct a link to the logos directory from amazon.php but cannot get it to pick up the image.

Thanks,
Matt

Submitted by support on Thu, 2010-07-22 14:51.

Hi Matt,

Bear in mind that if you have amazon.php included on Product Pages (or externally) you will need to use the fully qualified path to your logo image - in other words, it must start with "/" so that the browser knows exactly where to find the image. In other words, instead of

<img src='logos/amazon.gif' />

...it would need to be:

<img src='/path/to/logos/amazon.gif' />

If you're not quite sure; it will be fine using the URL also, for example:

<img src='http://www.yoursite.com/logos/amazon.gif' />

Hope this helps!

Cheers,
David.

Submitted by mattwalker on Thu, 2010-07-22 15:05.

Cheers, David.

Submitted by mattwalker on Fri, 2010-07-23 13:51.

Hi David,

One last Amazon question...

I've placed a heading within the amazon.php table but i've noticed it doesn't disappear along with the rest of the table when there are no amazon results.

I've tried placing this and other variations at line 126 in amazon.php:

if ($item==("myAmazonRecordHandler")) print "Amazon.co.uk / Amazon Marketplace";

but still the remains. How do I make it act like the rest of the table?

Cheers,
Matt

Submitted by support on Fri, 2010-07-23 13:57.

Hi Matt,

Best thing to do is actually to put the code inside the myAmazonRecordHandler function, it is only on the first call to that function that you know that you actually have products!

Add this code immediately inside the function:

global $amazon_first;
if (!$amazon_first)
{
  print "<tr><td>Amazon.co.uk / Amazon Marketplace</td></tr>";
  $amazon_first = true;
}

(the table HTML is necessary because you are inside the table structure at this point)

Finally, at the very top of the script (line after the opening PHP tag) add:

  $amazon_first = false;

Cheers,
David.

Submitted by mattwalker on Mon, 2010-07-26 13:57.

Hi David,

I've placed the code in but it's not quite working. Its probably the wordpress Thesis theme playing up again as it works fine in PT itself.

Within wordpress Thesis theme the command works on the front page but not on any of the posts. Is there any way of making this command run more than once, so it works in the posts too?

Cheers,
Matt

Submitted by support on Mon, 2010-07-26 14:13.

Hello Matt,

That sounds like it's being included multiple times, and therefore the require() statements and the amazon_ functions themselves will be failing because they already exist / have been included.

Can you email me your amazon.php and I'll modify it to use require_once() and function_exists() to ensure that it can be called multiple times on one page...

Cheers,
David.

Submitted by discountdriven on Fri, 2010-08-13 21:29.

Hi David,

Is there a way to incorporate the Amazon products into the pricing tables to show a direct product comparison with other merchants? I was hoping to also be able to do product mapping for Amazon products and filtering like I'd be able to do with any other merchant. Any of this possible?

Thanks,
Stacy

Submitted by support on Sat, 2010-08-14 08:07.

Hi Stacy,

The main problem with this is not knowing whether a product return from the Amazon API is definitely the same product as is being featured on the page, so you could end up not comparing like for like. If you could email me with links to your existing Amazon API implementation i'll have a look at how it's working and see if it would be possible, maybe using the SKU/ISBN lookup...

Cheers,
David.
--
PriceTapestry.com