MPCommerce Class Reference

Inherits from NSObject
Declared in MPCommerce.h
MPCommerce.m

Overview

This class is a convenience wrapper to using the e-commerce methods. It contains a reference to the cart singleton (MPCart), which should be used to log adding and removing products to the shopping cart.

Using the methods and properties of this class should be done through the instance provided in the mParticle singleton.

Note that all operations provided here can be accomplished through the logCommerceEvent: method.

Usage:

Swift


let commerce = MParticle.sharedInstance().commerce

commerce.cart.addProduct(product)

commerce.purchaseWithTransactionAttributes(transactionAttributes, clearCart:true)

Objective-C


MPCommerce *commerce = [MParticle sharedInstance].commerce;

[commerce.cart addProduct:product];

[commerce purchaseWithTransactionAttributes:transactionAttributes clearCart:YES];

  cart

A reference to the MPCart singleton.

@property (nonatomic, strong, readonly, nonnull) MPCart *cart

Discussion

A reference to the MPCart singleton.

See Also

Declared In

MPCommerce.h

  currency

The currency used in the commerce event.

@property (nonatomic, strong, nullable) NSString *currency

Discussion

The currency used in the commerce event.

Declared In

MPCommerce.h

– checkout

Logs a checkout commerce event with the products contained in the shopping cart.

- (void)checkout

Discussion

Logs a checkout commerce event with the products contained in the shopping cart.

Declared In

MPCommerce.h

– checkoutWithOptions:step:

Logs a checkout with options commerce event with the products contained in the shopping cart.

- (void)checkoutWithOptions:(nullable NSString *)options step:(NSInteger)step

Parameters

options

A string describing what the options are

step

The step number, within the chain of commerce event transactions, corresponding to the checkout

Discussion

Logs a checkout with options commerce event with the products contained in the shopping cart.

Declared In

MPCommerce.h

– clearCart

Clears the contents of the shopping cart.

- (void)clearCart

Discussion

Clears the contents of the shopping cart.

This method is equivalent to calling the MPCart’s clear method.

Declared In

MPCommerce.h

– purchaseWithTransactionAttributes:clearCart:

Logs a purchase commerce event with the products contained in the shopping cart.

- (void)purchaseWithTransactionAttributes:(nonnull MPTransactionAttributes *)transactionAttributes clearCart:(BOOL)clearCart

Parameters

transactionAttributes

The attributes of the transaction, such as: transactionId, tax, affiliation, shipping, etc.

clearCart

A flag indicating whether the shopping cart should be cleared after logging this commerce event.

Discussion

Logs a purchase commerce event with the products contained in the shopping cart.

Declared In

MPCommerce.h

– refundTransactionAttributes:clearCart:

Logs a refund commerce event with the products contained in the shopping cart.

- (void)refundTransactionAttributes:(nonnull MPTransactionAttributes *)transactionAttributes clearCart:(BOOL)clearCart

Parameters

transactionAttributes

The attributes of the transaction, such as: transactionId, tax, affiliation, shipping, etc.

clearCart

A flag indicating whether the shopping cart should be cleared after logging this commerce event.

Discussion

Logs a refund commerce event with the products contained in the shopping cart.

Declared In

MPCommerce.h