/**
  * @param string $wishListId
  * @param WishList $wishList
  *
  * @return $this
  */
 public function updateWishList($wishListId, WishList $wishList)
 {
     $this->checkWishListId($wishListId);
     $wishListQuery = array('session_id' => $wishListId);
     if ($wishList->isClearedOnUpdate()) {
         $wishListQuery['clear'] = true;
     }
     $orderLines = $wishList->getOrderLinesArray();
     if (!empty($orderLines)) {
         $wishListQuery['order_lines'] = $orderLines;
     }
     $this->query[] = array('wishlist' => $wishListQuery);
     return $this;
 }
 /**
  * {@inheritdoc}
  *
  * @return WishList
  */
 public function createWishList(stdClass $jsonObject)
 {
     return WishList::createFromJson($jsonObject, $this);
 }
Esempio n. 3
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 testAddItemSetToWishListWithProductID()
 {
     $ay = $this->getAY();
     $WishList = new WishList();
     $set = new WishList\WishListSet('A123567', array('description' => 'test', 'image_url' => 'http://img-url'));
     $item = new WishList\WishListSetItem($this->getProductId(1));
     $set->addItem($item);
     $WishList->updateItemSet($set);
     $result = $ay->updateWishList($this->getSessionId(), $WishList);
     $this->assertTrue($result->hasErrors());
 }