Esempio n. 1
0
 /**
  * Adds a single item into the wishlist.
  * You can specify an amount. Please mind, that an amount > 1 will result in #amount basket positions.
  * So if you read out the basket again later, it's your job to merge the positions again.
  *
  * It is highly recommend to use the basket update method, to manage your items.
  *
  * @param string $sessionId
  * @param integer $variantId
  * @param integer $amount
  *
  * @return Basket
  *
  * @throws \InvalidArgumentException
  */
 public function addItemToWishList($sessionId, $variantId, $amount = 1)
 {
     if (!is_long($variantId)) {
         if (is_string($variantId) && ctype_digit($variantId)) {
             $variantId = intval($variantId);
         } else {
             throw new \InvalidArgumentException('the variant id must be an integer or string with digits');
         }
     }
     $wishList = new WishList();
     for ($i = 0; $i < $amount; $i++) {
         $item = new WishList\WishListItem(null, $variantId);
         $wishList->updateItem($item);
     }
     return $this->updateWishList($sessionId, $wishList);
 }
 public function testAddOneItemToWishListWithAppId()
 {
     $api = $this->getAY();
     $item = new WishList\WishListItem('1234', $this->getVariantId(1), array('description' => 'test', 'image_url' => 'http://www.google.de', 'foo' => 'bar'), 200);
     $WishList = new WishList();
     $WishList->updateItem($item);
     $WishList = $api->updateWishList($this->getSessionId(), $WishList);
     $item = $WishList->getItem('1234');
     $this->assertEquals(1, $WishList->getTotalAmount());
     $this->assertEquals(200, $item->getAppId());
     $this->assertInstanceOf('\\AboutYou\\SDK\\Model\\WishList\\WishListItem', $item);
     $data = $item->getAdditionalData();
     $this->assertEquals('test', $data['description']);
     $this->assertEquals('http://www.google.de', $data['image_url']);
     $this->assertEquals('bar', $data['foo']);
     $WishList->deleteAllItems();
     $api->updateWishList($this->getSessionId(), $WishList);
 }