MPProduct Class Reference

Inherits from NSObject
Conforms to NSCopying
NSSecureCoding
Declared in MPProduct.h
MPProduct.mm

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";

Other Methods

– initWithName:sku:quantity:price:

Initializes an instance of MPProduct.

- (instancetype)initWithName:(NSString *)name sku:(NSString *)sku quantity:(NSNumber *)quantity price:(NSNumber *)price

Parameters

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

- (NSArray *)allKeys

Return 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)count

Return 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)

- (NSString *)affiliation

Discussion

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

– brand

The product brand

- (NSString *)brand

Discussion

The product brand

Declared In

MPProduct.h

– category

A category to which the product belongs

- (NSString *)category

Discussion

A category to which the product belongs

Declared In

MPProduct.h

– couponCode

The coupon associated with the product

- (NSString *)couponCode

Discussion

The coupon associated with the product

Declared In

MPProduct.h

– currency

The currency of a transaction. If not specified, mParticle will use “USD” (Deprecated: use MPCommerceEvent.currency instead)

- (NSString *)currency

Discussion

The currency of a transaction. If not specified, mParticle will use “USD”

Declared In

MPProduct.h

– name

The name of the product

- (NSString *)name

Discussion

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

- (NSNumber *)price

Discussion

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

- (NSString *)sku

Discussion

SKU of a product. This is the product id

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)

- (NSString *)transactionId

Discussion

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

– variant

The variant of the product

- (NSString *)variant

Discussion

The variant of the product

Declared 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)

- (double)shippingAmount

Discussion

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)

- (double)taxAmount

Discussion

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)

- (double)totalAmount

Discussion

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)

- (double)unitPrice

Discussion

The price of a product. If product is free or price is non-applicable use 0. Default value is zero

Declared In

MPProduct.h

– position

The prosition of the product on the screen or impression list

- (NSUInteger)position

Discussion

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

- (NSNumber *)quantity

Discussion

The quantity of the product. Default value is 1

Declared In

MPProduct.h

Other Methods

  revenueAmount

use MPTransactionAttributes.revenue instead (Deprecated: use MPTransactionAttributes.revenue instead)

@property (nonatomic, readwrite) double revenueAmount

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)totalAmount

Declared 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)revenueAmount

Declared In

MPProduct.h