addItemWithSku
Deprecated
This method is no longer recommended.
The addItemWithSku() method adds a product to the cart.
Syntax
[builder addItemWithSku:@"productSKU"
name:@"productName"
category:@"productCategory"
price:@(productPrice)
quantity:@(productQuantity)];
Parameters
productSKU (string, required)
The stock-keeping unit of the added product.
productName (string, optional)
The name of the added product.
productCategory (string | array, optional)
The category of the added product. It can be an array of up to 5 categories.
productPrice (number, optional)
The price of the added product.
productQuantity (number, optional)
The number of added items.
Examples
To track a confirmed order:
[[PiwikTracker sharedInstance] sendTransaction:[PiwikTransaction transactionWithBlock:^(PiwikTransactionBuilder *builder) {
builder.identifier = @"43967392";
builder.grandTotal = @525000;
builder.subTotal = @520000;
builder.tax = @97000;
builder.shippingCost = @15000;
builder.discount = @10000;
[builder addItemWithSku:@"584340"
name:@"Specialized Stumpjumper"
category:@"Mountain bike"
price:@500000
quantity:@1];
[builder addItemWithSku:@"460923"
name:@"Specialized Chamonix"
category:@"Helmets"
price:@20000
quantity:@1];
}]];
Notes
- The cart with added items is not stored in local storage. Make sure to add all items again after the page reloads.
- This method doesn't send any data to Piwik PRO. It just creates a cart. You can use the track().order() method to send cart data to Piwik PRO.
Related methods
Updated 2 days ago