MPProduct Class Reference
| Inherits from | NSObject |
|---|---|
| Conforms to | NSCopying NSSecureCoding |
| Declared in | MPProduct.h |
Overview
This class is used to describe a product used in a commerce event. Since this class behaves similarly to an NSMutableDictionary, custom key/value pairs can be specified, in addition to the ones listed as class properties.
For example:
Swift
let product = MPProduct(name:"Product Name", sku:"s1k2u3", quantity:1, price:1.23)
product["Custom Key"] = "Custom Value"
Objective-C
MPProduct *product = [[MPProduct alloc] initWithName:@"Product Name" sku:@"s1k2u3" quantity:@1 price:@1.23];
product[@"Custom Key"] = @"Custom Value";
brand
The product brand
@property (nonatomic, strong, nullable) NSString *brandDiscussion
The product brand
Declared In
MPProduct.h
category
A category to which the product belongs
@property (nonatomic, strong, nullable) NSString *categoryDiscussion
A category to which the product belongs
Declared In
MPProduct.h
couponCode
The coupon associated with the product
@property (nonatomic, strong, nullable) NSString *couponCodeDiscussion
The coupon associated with the product
Declared In
MPProduct.h
name
The name of the product
@property (nonatomic, strong, nonnull) NSString *nameDiscussion
The name of the product
Declared In
MPProduct.h
price
The price of a product. If product is free or price is non-applicable use nil. Default value is nil
@property (nonatomic, strong, nullable) NSNumber *priceDiscussion
The price of a product. If product is free or price is non-applicable use nil. Default value is nil
Declared In
MPProduct.h
sku
SKU of a product. This is the product id
@property (nonatomic, strong, nonnull) NSString *skuDiscussion
SKU of a product. This is the product id
Declared In
MPProduct.h
variant
The variant of the product
@property (nonatomic, strong, nullable) NSString *variantDiscussion
The variant of the product
Declared In
MPProduct.h
position
The prosition of the product on the screen or impression list
@property (nonatomic) NSUInteger positionDiscussion
The prosition of the product on the screen or impression list
Declared In
MPProduct.h
quantity
The quantity of the product. Default value is 1
@property (nonatomic, strong, nonnull) NSNumber *quantityDiscussion
The quantity of the product. Default value is 1
Declared In
MPProduct.h
– initWithName:sku:quantity:price:
Initializes an instance of MPProduct.
- (nonnull instancetype)initWithName:(nonnull NSString *)name sku:(nonnull NSString *)sku quantity:(nonnull NSNumber *)quantity price:(nullable NSNumber *)priceParameters
name |
The name of the product |
|---|---|
sku |
The SKU or Product Id |
quantity |
The quantity of the product. If non-applicable use 0 |
price |
The unit price of the product. If the product is free or if non-applicable pass 0 |
Return Value
An instance of MPProduct, or nil if it could not be created
Swift
let product = MPProduct(name:"Product Name", sku:"s1k2u3", quantity:1, price:1.23)
Objective-C
MPProduct *product = [[MPProduct alloc] initWithName:@"Product Name" sku:@"s1k2u3" quantity:@1 price:@1.23];
Discussion
Initializes an instance of MPProduct.
Declared In
MPProduct.h
– allKeys
Returns an array with all keys in the MPProduct dictionary
- (nonnull NSArray *)allKeysReturn Value
An array with all dictionary keys
Discussion
Returns an array with all keys in the MPProduct dictionary
Declared In
MPProduct.h
– count
Number of entries in the MPProduct dictionary
- (NSUInteger)countReturn Value
The number of entries in the dictionary
Discussion
Number of entries in the MPProduct dictionary
Declared In
MPProduct.h
affiliation
An entity with which the transaction should be affiliated (e.g. a particular store). If nil, mParticle will use an empty string (Deprecated: use MPTransactionAttributes.affiliation instead)
@property (nonatomic, strong, nullable) NSString *affiliationDiscussion
An entity with which the transaction should be affiliated (e.g. a particular store). If nil, mParticle will use an empty string
Declared In
MPProduct.h
currency
The currency of a transaction. If not specified, mParticle will use “USD” (Deprecated: use MPCommerceEvent.currency instead)
@property (nonatomic, strong, nullable) NSString *currencyDiscussion
The currency of a transaction. If not specified, mParticle will use “USD”
Declared In
MPProduct.h
transactionId
A unique ID representing the transaction. This ID should not collide with other transaction IDs. If not specified, mParticle will generate a random id with 20 characters (Deprecated: use MPTransactionAttributes.transactionId instead)
@property (nonatomic, strong, nullable) NSString *transactionIdDiscussion
A unique ID representing the transaction. This ID should not collide with other transaction IDs. If not specified, mParticle will generate a random id with 20 characters
Declared In
MPProduct.h
revenueAmount
use MPTransactionAttributes.revenue instead (Deprecated: use MPTransactionAttributes.revenue instead)
@property (nonatomic, readwrite) double revenueAmountDeclared In
MPProduct.h
shippingAmount
The total cost of shipping for a transaction. If free or non-applicable use 0. Default value is zero (Deprecated: use MPTransactionAttributes.shipping instead)
@property (nonatomic, readwrite) double shippingAmountDiscussion
The total cost of shipping for a transaction. If free or non-applicable use 0. Default value is zero
Declared In
MPProduct.h
taxAmount
The total tax for a transaction. If free or non-applicable use 0. Default value is zero (Deprecated: use MPTransactionAttributes.tax instead)
@property (nonatomic, readwrite) double taxAmountDiscussion
The total tax for a transaction. If free or non-applicable use 0. Default value is zero
Declared In
MPProduct.h
totalAmount
The total value of a transaction, including tax and shipping. If free or non-applicable use 0. Default value is zero (Deprecated: use MPTransactionAttributes.revenue instead)
@property (nonatomic, readwrite) double totalAmountDiscussion
The total value of a transaction, including tax and shipping. If free or non-applicable use 0. Default value is zero
Declared In
MPProduct.h
unitPrice
The price of a product. If product is free or price is non-applicable use 0. Default value is zero (Deprecated: use the price property instead)
@property (nonatomic, readwrite) double unitPriceDiscussion
The price of a product. If product is free or price is non-applicable use 0. Default value is zero
Declared In
MPProduct.h
– initWithName:category:quantity:totalAmount:
use initWithName:sku:quantity:price: instead (Deprecated: use initWithName:sku:quantity:price: instead)
- (nonnull instancetype)initWithName:(nonnull NSString *)name category:(nullable NSString *)category quantity:(NSInteger)quantity totalAmount:(double)totalAmountDeclared In
MPProduct.h
– initWithName:category:quantity:revenueAmount:
use initWithName:sku:quantity:price: instead (Deprecated: use initWithName:sku:quantity:price: instead)
- (nonnull instancetype)initWithName:(nonnull NSString *)name category:(nullable NSString *)category quantity:(NSInteger)quantity revenueAmount:(double)revenueAmountDeclared In
MPProduct.h