Blog

Tutorial: Amazon.com Search API

Posted on

7a. Product Pricing

Product Pricing Code

// Item Price
      var li3 = cel('p');
      li3.style.cssText = "font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #000000; font-weight:normal; text-decoration:none;";
      var a3 = cel('a');
      a3.style.cssText = "cursor:hand; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #990000; font-weight: bold; text-decoration:none;";
      if(tmpItem.lowestnewprice)
      {
         a3.setAttribute("href", "javascript:amazonSearch('" + tmpItem.asin + "', 'price&Condition=New', '" + tmpData.ItemSet.category + "');");
         a3.appendChild(ctn(tmpItem.lowestnewprice + " (" + tmpItem.totalnew + ")"));
         li3.appendChild(ctn("From: "));
         li3.appendChild(a3);
      }
      else if(tmpItem.price)
      {
         li3.appendChild(ctn("Price: " + tmpItem.price));
      }
      else if(tmpItem.lowestusedprice)
      {
         li3.appendChild(ctn("From: " + tmpItem.lowestusedprice + " (" + tmpItem.totalused + ") used"));
      }

Amazon has several values for product pricing, including: Price, Lowest New Price and Lowest Used Price. In the above code for pricing, the conditional statement accounts for which pricing option value is in the response. The order of precedence is artbitrary, so The Lowest Used Price could be prioritized as the first condition instead.