function addToCart(&$cart, $ASIN, $mode)
{
    if (isset($cart[$ASIN])) {
        $cart[$ASIN]['quantity'] += 1;
    } else {
        // check that the ASIN is valid and look up the price
        $ars = new AmazonResultSet();
        $product = $ars->ASINSearch($ASIN, $mode);
        if ($product->valid()) {
            $cart[$ASIN] = array('price' => $product->ourPrice(), 'name' => $product->productName(), 'quantity' => 1);
        }
    }
}
Example #2
0
function getARS($type, $parameters)
{
    $cache = cached($type, $parameters);
    if ($cache) {
        return $cache;
    } else {
        $ars = new AmazonResultSet();
        if ($type == 'asin') {
            $ars->ASINSearch(padASIN($parameters['asin']), $parameters['mode']);
        }
        if ($type == 'browse') {
            $ars->browseNodeSearch($parameters['browsenode'], $parameters['page'], $parameters['mode']);
        }
        if ($type == 'search') {
            $ars->keywordSearch($parameters['search'], $parameters['page'], $parameters['mode']);
        }
        cache($type, $parameters, $ars);
    }
    return $ars;
}