ApaiIO\Operations\CartCreate::addItem PHP Method

addItem() public method

Adds an item to the Cart
public addItem ( string $id, integer $quantity, boolean $byAsin = true )
$id string The ASIN or OfferListingId Number of the item
$quantity integer How much you want to add
$byAsin boolean If False will use OfferListingId insted of ASIN
    public function addItem($id, $quantity, $byAsin = true)
    {
        $itemIdentifier = $byAsin ? '.ASIN' : '.OfferListingId';
        $this->parameters['Item.' . $this->itemCounter . $itemIdentifier] = $id;
        $this->parameters['Item.' . $this->itemCounter . '.Quantity'] = $quantity;
        $this->itemCounter++;
    }

Usage Example

Ejemplo n.º 1
0
 public function testAddItemIncrementsCounter()
 {
     $asin = __LINE__;
     $this->cartCreate->addItem($asin, 2);
     $this->cartCreate->addItem($asin, 2);
     $operationParameters = $this->cartCreate->getOperationParameter();
     $this->assertEquals($asin, $operationParameters["Item.2.ASIN"]);
     $this->assertEquals(2, $operationParameters["Item.2.Quantity"]);
 }
All Usage Examples Of ApaiIO\Operations\CartCreate::addItem