function showDetail($ASIN, $mode) { $ars = getARS('asin', array('asin' => $ASIN, 'mode' => $mode)); if ($ars) { $product = $ars->getProduct(0); } else { echo "cannot get details for {$ASIN}"; } if (!$product) { echo 'No product to display'; return; } echo '<table border = 0 width = "100%" cellpadding = 4 cellspacing = 4>'; $imageFile = getImage($product->imageURLMedium()); echo "<tr><td valign = 'top' align = 'center'><a href='index.php?action=image&ASIN={$ASIN}&mode={$mode}'><img src= '{$imageFile}' alt = 'View book details' border = 0></a><br><br>"; echo "<a href = 'index.php?action=addtocart&ASIN={$ASIN}'><img src = 'images/addtocart.gif' alt = 'Add to Cart' border = 0></a>"; echo '</td><td>'; echo '<h1>' . $product->productName() . '</h1>'; echo displayAuthors($product->authors(), false) . '<br>'; if ($product->releaseDate()) { echo 'Published: ' . $product->releaseDate() . '<br>'; } if ($product->manufacturer()) { echo 'Publisher: ' . $product->manufacturer() . '<br>'; } echo 'Our Price: <span class="bookprice">$' . $product->ourPrice() . '</span><br>'; if ($product->ourPrice() != $product->listPrice()) { echo 'List price: $' . $product->listPrice(); } $saving = $product->listPrice() - $product->ourPrice(); if ($saving > 0.5) { $saving = number_format($saving, 2); echo " <span class='bookprice'>SAVE \${$saving}</span>"; } echo '<br>'; echo 'ISBN: ' . $ASIN . '<br>'; if ($product->avgCustomerRating()) { echo 'Customer Rating: ' . displayStars($product->avgCustomerRating()) . '<br>'; } if ($product->salesRank()) { echo 'Sales Rank: ' . $product->salesRank() . '<br>'; } if ($product->availability()) { echo 'Availability: ' . $product->availability() . '<br>'; } echo '</p>'; // remember that this section will be making up tp 5 extra calls to Amazon // remove it if it is too slow $similar = $product->similarProductCount(); if ($similar) { echo '<hr>'; echo '<h2>Similar Products</h2><ul>'; for ($i = 0; $i < $similar; $i++) { echo '<li>' . similarSummary($product->similarProduct($i), $mode); } echo '</ul>'; } $reviews = $product->customerReviewCount(); if ($reviews) { echo '<hr>'; echo '<h2>Customer Reviews</h2>'; for ($i = 0; $i < $reviews; $i++) { echo '<h3>' . displayStars($product->customerReviewRating($i)); echo ' ' . $product->customerReviewSummary($i) . '</h3>'; echo '<p>' . $product->customerReviewComment($i) . '</p>'; } } echo "</td></tr>"; echo '<tr><td colspan = 2><hr></td></tr>'; echo '</table>'; }
function showDetail($ASIN, $mode) { $ars = getARS('asin', array('asin' => $ASIN, 'mode' => $mode)); if ($ars) { $product = $ars->getProduct(0); } else { echo "<p>Cannot get details for " . $ASIN . "</p>"; } if (!$product) { echo "<p>No product to display.</p>"; return; } echo "<table border=\"0\" width=\"100%\" cellpadding=\"4\" cellspacing=\"4\">"; $imageFile = getImage($product->imageURLMedium()); echo "<tr>\n <td valign=\"top\" align=\"center\">\n <a href=\"index.php?action=image&ASIN=" . $ASIN . "&mode=" . $mode . "\"><img src=\"" . $imageFile . "\"\n alt=\"View book details\" border=\"0\"></a><br/><br/>\n <a href=\"index.php?action=addtocart&ASIN=" . $ASIN . "\">\n <img src=\"images/addtocart.gif\" alt=\"Add to Cart\"\n border=\"0\"></a></td>\n <td><h1>" . $product->productName() . "</h1>"; echo displayAuthors($product->authors(), false) . "<br/>"; if ($product->releaseDate()) { echo "Published: " . $product->releaseDate() . "<br/>"; } if ($product->manufacturer()) { echo "Publisher: " . $product->manufacturer() . "<br/>"; } echo "Our Price: <span class=\"bookprice\">\$" . $product->ourPrice() . "</span><br/>"; if ($product->ourPrice() != $product->listPrice()) { echo "List price: \$" . $product->listPrice(); } $saving = $product->listPrice() - $product->ourPrice(); if ($saving > 0.5) { $saving = number_format($saving, 2); echo " <span class=\"bookprice\">SAVE \$" . $saving . "</span>"; } echo "<br/>"; echo "ISBN: " . $ASIN . "<br/>"; if ($product->avgCustomerRating()) { echo "Customer Rating: " . displayStars($product->avgCustomerRating()) . "<br/>"; } if ($product->salesRank()) { echo "Sales Rank: " . $product->salesRank() . "<br/>"; } if ($product->availability()) { echo "Availability: " . $product->availability() . "<br/>"; } echo '</p>'; // remember that this section will be making up tp 5 extra calls to Amazon // remove it if it is too slow $similar = $product->similarProductCount(); if ($similar) { echo "<hr/>"; echo "<h2>Similar Products</h2><ul>"; for ($i = 0; $i < $similar; $i++) { echo "<li>" . similarSummary($product->similarProduct($i), $mode); } echo "</ul>"; } $reviews = $product->customerReviewCount(); if ($reviews) { echo "<hr/>"; echo "<h2>Customer Reviews</h2>"; for ($i = 0; $i < $reviews; $i++) { echo "<h3>" . displayStars($product->customerReviewRating($i)); echo " " . $product->customerReviewSummary($i) . "</h3>"; echo "<p>" . $product->customerReviewComment($i) . "</p>"; } } echo "</td></tr>"; echo "<tr><td colspan=\"2\"><hr/></td></tr>"; echo "</table>"; }