1. Sitecore Experience Commerce

Coupons actions, commands, and pipelines

Version:

The following table describes the coupons actions, commands, and pipelines:

Action/Command/PipelineDescription
AddCoupon

AddCouponCommand

AddCouponToCartPipeline
Adds a coupon to a cart using a coupon code.

It has the following parameters:

  • cartId: the identifier of the cart (string)
  • couponCode: the identifier of the coupon (string)


To add a coupon to a cart using a coupon code, this action, command and pipeline:

  1. Validates the coupon by loading the coupon based on the coupon code.
  2. Retrieves the CartCouponsComponent from the cart.
  3. Checks if this coupon code is already added.
  4. Creates a new CartCoupon object.
  5. Populates: IsValid = true, promotion = coupon.Promotion.
  6. Adds new CartCoupon object to CartCouponsComponent list property.
AddPrivateCoupon

AddPrivateCouponCommand

AddPrivateCouponPipeline
Generates a batch of private coupons, adding those coupons to a list of unallocated coupons associated to the promotion. Uses the prefix and suffix combined with a generated string to form a complete unique coupon code.

It has the following parameters:

  • PromotionId: the identifier of a promotion the coupon qualifies for (string)
  • Prefix : a prefix to apply to the generated codes (string)
  • Suffix: a Suffix to apply to the generated codes (string)
  • Total: the number of private coupons to generate (integer)
AddPublicCoupon

AddPublicCouponCommand

AddPublicCouponPipeline
Creates a public coupon to be associated with a promotion.

It has the following parameters:

  • PromotionId: the identifier of a promotion the coupon qualifies for (string)
  • CouponCode: the identifier of the coupon code (string)
NewAllocation

NewCouponAllocationCommand

NewCouponAllocationPipeline
Allocates a batch of coupons from a private coupon group associated with the promotion. This moves the list of coupons from the unallocated coupons list to the allocated coupons list. This returns a list of coupon codes that have been allocated.

It has the following parameters:

  • PromotionId: the identifier of a promotion to allocate from (string)
  • PrivateCouponGroupId: the identifier of the PrivateCouponGroup to allocate from (string)
  • Total: the number of private coupons to allocate (integer)
RemoveCoupon

RemoveCouponCommand

RemoveCouponFromCartPipeline
Removes a coupon from the cart.

It has the following parameters:

  • cartId: the identifier of the cart (string)
  • couponCode: the identifier of the coupon (string)
If you have suggestions for improving this article, let us know!