Example #1
0
 private static function addAnotherItemToBasket($bRaw = 0)
 {
     // Add another product to the already existing basket /rest/checkout/v4/baskets/{id}/{quantity}/{ipAddress} + sessionid
     // check if sessionid for basket is available
     if (self::checkSession()) {
         self::$apiClient->setSessionId($_SESSION['sessionid']);
         self::printValue('Adding product Pulp Fiction (1002004013540233) to the existing basket');
         self::printValue('----');
         $responseProduct = self::$apiClient->getProduct('1002004013540233');
         $product = new Product($responseProduct->products[0]);
         $offers = $product->getOffers();
         self::printValue('Add the bol.com offer id ' . $offer[0]->id . ' to the basket (first offer)');
         self::printValue('----');
         //Add offerid, quantity and clients IP to create and add a product to a basket
         $response = self::$apiClient->addToBasket($offers[0]->id, 1, $_SERVER['REMOTE_ADDR']);
         self::printValue("No JSON returned, returning http header");
         self::printValue($response);
         self::printValue(" ");
         //update the session lifetime with making this call
         self::setSession($_SESSION['sessionid']);
     } else {
         self::printValue("Create a basket first, no basket active");
         self::printValue(" ");
     }
 }