Create Customer Group Discounts

Applies to: Catalog APICatalog API | Customer Groups APICustomer Groups API | Customers APICustomers API

Learn how to use a pricing rule to make customers in selected customer groups eligible to receive specified discounts to matched products.

Link to section

Overview

In addition to using CatalogPricingRuleCatalogPricingRule to have a discount automatically applied to specified products sold to any buyer, you can use it to have the discount automatically applied to customers belonging to one or more customer groups. This second use case is referred to as customer group discounts.

To set up customer group discounts, you must provide a means to accept input from the seller to determine which groups of customers can receive what type of discounts to which product sets. When the decision is finalized, you can proceed to create or update a pricing rule to configure the discount and eligibility of specific customers.

In general, the programming workflow involves the following steps:

Link to section

Retrieve or create a customer group

If the targeted customers are already members of an existing customer group, you can call the ListCustomerGroupsListCustomerGroups endpoint of the Customer Groups API to retrieve available groups, examine the result to extract the customer group of interest, and obtain the group ID.

Link to section

Example to retrieve a customer group

List customer groups

Copy

The successful response might look similar to the following:

Copy
Expand
{ "groups":[ { "id":"6B8DE9B3-9AF2-4CDA-9938-D1A5BC5D87E0", "name":"Students", "created_at":"2021-02-24T14:32:07.334Z", "updated_at":"2021-02-24T14:35:45Z" } ] }

In this example, the seller has only one customer group named Students. The group ID is 6B8DE9B3-9AF2-4CDA-9938-D1A5BC5D87E0. Make note of the group ID. You need it later to configure customer group discounts.

If the targeted customers don't belong to any known customer group, you can call the Customer Groups API CreateCustomerGroupCreateCustomerGroup endpoint to create a new customer group and then call AddGroupToCustomerAddGroupToCustomer to make selected customers members of the group. Make sure to note the group ID before proceeding.

Link to section

Create or retrieve a discount

For a new promotional campaign, you must create a new discount as represented by a CatalogDiscountCatalogDiscount object. To do so, call the UpsertCatalogObjectUpsertCatalogObject endpoint, or its batched version, of the Catalog API.

Link to section

Example to create a discount

Upsert catalog object

Copy

The successful response is similar to the following output:

Copy
Expand

In this example, the newly created CatalogDiscount object encapsulates a discount off the sale price by 10%. Make note of the returned CatalogDiscount object ID (BY676RE3HE5UWOUDCM6ISM5Z). You need it to configure the pricing rule later.

If you want to use an existing discount object, you can call the SearchCatalogObjectsSearchCatalogObjects endpoint to retrieve the discount object. In any case, make note of the ID of the returned CatalogDiscount object.

Link to section

Create or retrieve a product set

The following example shows how to create a new product set to apply a discount to. The product set includes any product for sale by the seller.

Link to section

Example to create a product set

Upsert catalog object

Copy

The "all_products": true attribute makes the resulting product set to include all products in the seller's catalog.

The successful response looks similar to the following output:

Copy
Expand

Make note of the returned CatalogProductSet object ID (MRNVLLYM77NZJNP3FMIJMGCX). You need it to configure the pricing rule later.

Link to section

Create or update a pricing rule to apply customer group discounts

With the discount, product sets, and customer groups in hand (as referenced by their respective IDs), it's time to set up a pricing rule to automatically apply the discount to the products sold to the members of a customer group. You can do so by creating a new CatalogPricingRule object or updating an existing one.

The following example shows creating a pricing rule object to apply a fixed discount to any product sold to customers in any of the specified customer groups.

Link to section

Example to create a pricing rule to configure a customer group discount

To create a pricing rule, call the UpsertCatalogObject endpoint to create a CatalogPricingRule object, with a rule to have a specific discount applied to a specified product set purchased by members of specified customer groups.

Upsert catalog object

Copy

The discount, product set, and customer groups are all referenced by their respective IDs.

The successful REST API response is similar to the following output:

Copy
Expand

The resulting pricing rule is automatically applied to itemized products in a shopping cart when a matched customer places an order of any of the seller's product. For example, when an eligible customer orders a $5.00 latte, this pricing rule reduces the charge by $0.50. The customer pays only $4.50 for the drink at the cash register or checkout.