/**
  * @param $orderNumber
  * @param $sku
  * @param $name
  * @param $price
  * @param int $quantity
  * @internal param null $trackerName
  *
  * @return Item
  */
 public function createAnalyticsItem($orderNumber, $sku, $name, $price, $quantity = 1)
 {
     $item = new Item();
     $item->setOrderNumber($orderNumber);
     $item->setName($name);
     $item->setPrice($price);
     $item->setQuantity($quantity);
     $item->setSku($sku);
     $this->getAnalytics()->addItem($item);
     return $item;
 }
Example #2
0
 public function testToArrayFromArray()
 {
     $item = new Item();
     $item->setId('id');
     $item->setSku('zzzz');
     $item->setTitle('Product X');
     $item->setCategory('Category A');
     $item->setBrand('Brand A');
     $item->setCoupon('COUPONA');
     $item->setOrderNumber('orderNumberA');
     $item->setPrice(50.0);
     $item->setQuantity(1);
     $item->setPosition(1);
     $item->setVariant('Black');
     $toArray = $item->toArray();
     $item2 = new Item();
     $item2->fromArray($toArray);
     $this->assertEquals($item, $item2);
 }
 public function testAddGetItems()
 {
     $item = new Item();
     $item->setOrderNumber('xxxx');
     $item->setSku('zzzz');
     $item->setName('Product X');
     $item->setCategory('Category A');
     $item->setPrice(50.0);
     $item->setQuantity(1);
     $this->analytics->addItem($item);
     $this->assertTrue($this->analytics->hasItem($item));
     $item = new Item();
     $item->setOrderNumber('bbbb');
     $item->setSku('jjjj');
     $item->setName('Product Y');
     $item->setCategory('Category B');
     $item->setPrice(25.0);
     $item->setQuantity(2);
     $this->analytics->addItem($item);
     $this->assertTrue($this->analytics->hasItem($item));
     $this->assertTrue($this->analytics->hasItems());
     $this->assertEquals(2, count($this->analytics->getItems()));
 }