Create Time-Based Discounts

Applies to: Catalog API

Learn how to create discounts that apply during a specific active time period, such as a holiday sale.

Link to section

Overview

Time-based discounts automatically apply during an active time period that you specify in your pricing rule. In this example, you learn how to define a Happy Hour discount to apply a 25% discount to all drinks purchased every day from 3 PM to 6 PM.

The local time is determined by the device running the Point of Sale application.

Important

Point of Sale applications must be version 5.15 or later to take advantage of pricing rules. For questions or feedback, contact Support.

Link to section

1. Create a Drinks category

You must have a Drinks category of the CatalogCategory type created in your catalog. To create the Drinks category, follow this example.

Link to section

2. Create a discount, product set, and time period for a time-based discount

Create a 25% discount that is applied during the Happy Hour sale. Create a product set and assign your Drink category as product_ids_any to include all available drinks. Create a time period of 1 PM – 7 PM for 50 weeks beginning May 23, 2019.

Link to section

Create a Happy Hour discount

The following cURL example shows how to call the Catalog API UpsertCatalogObject endpoint to create a 25% Off Happy Hour discount:

Link to section

Request

Upsert catalog object

Link to section

Response

If successful, the operation returns the configured CatalogDiscount object for the 25% off Happy Hour discount as the payload of a 200 OK response similar to the following:

Link to section

Create a Drinks product set

Link to section

Request

The following cURL example shows how to call the Catalog API UpsertCatalogObject endpoint to create a CatalogProductSet object containing the Drinks category. The category ID is GXFTT46M3RCBR6LV54HKALC6.

Upsert catalog object

Link to section

Response

If successful, the operation returns the created CatalogProductSet object for the Drinks category as the payload of a 200 OK response similar to the following:

You might want to make note of the object_id value (IAPA75F4ZUBMCF6IVIP7FC2E) for future references to this object.

Link to section

Create a Happy Hour time period

Link to section

Request

The following cURL example shows how to call the Catalog API UpsertCatalogObject endpoint to create a CatalogTimePeriod object containing the discount event time period:

Upsert catalog object

Link to section

Response

If successful, the operation returns the payload of a 200 OK response similar to the following:

Link to section

3. Configure a pricing rule for a time-based discount

Create a pricing rule that applies the 25% discount to your Drinks product set during an active time period of 1 PM – 7 PM for 50 weeks beginning May 23, 2019.

Link to section

Request

The following cURL example shows how to call the Catalog API UpsertCatalogObject endpoint to create a CatalogPricingRule object specifying a discount (as identified by the discount_id value) to be applied to a given product (as identified by the match_products_id value) in the given time period (as identified by the time_period_ids value):

Upsert catalog object

In the example:

  • DE4AZASOM7WGFIJSBZEWEMRG in time_period_ids is the ID of the CatalogTimePeriod object created earlier.
  • IAPA75F4ZUBMCF6IVIP7FC2E is the ID of the CatalogProductSet object created earlier.
  • GAJS57APBZX445NOYMINZZUC is the ID of the CatalogDiscount object created earlier.
Link to section

Response

If successful, the operation returns the configured CatalogPricingRule object specifying the automatic application of the Happy Hour discount of 25% off drinks as the payload of a 200 OK response similar to the following:

You now have configured the pricing rule for the automatic discount for happy hours between 1 PM and 7 PM, lasting 50 weeks, and beginning on May 23, 2019.