Retrieving available promotions

Version: 10.3

When you retrieve sellable items before they are added to the shopping cart, it is possible to return eligible promotions, which on the storefront might stimulate shoppers to make additional purchases. You use the Search mechanism to return promotion information (such as the cart display text and benefits). When retrieving available promotions, no calculations are done to determine discounted prices.

Note

By default, SXA Storefront does not include support for retrieving available promotions.

When retrieving available promotions, the following are impacted in the Commerce Engine:

  • Promotion index, which includes items and categoryqualifications fields.

  • GlobalCatalogPolicy policy, which includes the AllowPromotionsToBeReturnedWithSellableItem option. By default, this option is set to false.

  • IgnorePromotions policy key in the Commerce Engine API header, which is part of the GetSellableItemsSummary, GetBulkPrices, and SellableItems.ByKey APIs.

And, the following are impacted in Commerce Engine (CE) Connect:

  • IncludePromotions PriceType, which is available in CE Connect and used in the GetProductPricesWithPromotionsResult and GetProductBulkPricesAndPromotionsResult APIs.

  • PricingServiceProvider provider, which includes two methods to call when you need promotions: GetProductPricesWithPromotionsResult and GetProductBulkPricesAndPromotionsResult.

For APIs that return sellable items, such as GetSellableItemsSummary, the promotion is returned in the AssociatedPromotionsComponent component as shown in the following JSON:

RequestResponse
   "@odata.type": "#Sitecore.Commerce.Plugin.Promotions.AssociatedPromotionsComponent",
            "Id": "8b1c298558cf448191af580b08fc2fa4",
            "Name": "",
            "Comments": "",
            "SellableItemId": "Entity-SellableItem-6042567",
            "Policies": [],
            "Items": [
                {
                    "Name": "",
                    "PromotionId": "Entity-Promotion-Habitat_PromotionBook-PromoCat1",
                    "DisplayCartText": "PromoCat1 dct",
                    "Policies": [],
                    "PromotionActions": [
                        {
                            "Name": "CartFreeGiftAction",
                            "Id": "e6f9e89caa5442e9b2bb2e4b47ac994d",
                            "LibraryId": "CartFreeGiftAction",
                            "Policies": [],
                            "Properties": [
                                {
                                    "Name": "MaximumQuantity",
                                    "DisplayType": "System.Int32",
                                    "Value": "0",
                                    "IsOperator": false,
                                    "Policies": []
                                },
                                {
                                    "Name": "AddToCartAutomatically",
                                    "DisplayType": "System.Boolean",
                                    "Value": "true",
                                    "IsOperator": false,
                                    "Policies": []
                                }
                            ]
                        }
                    ]
                },
                {
                    "Name": "",
                    "PromotionId": "Entity-Promotion-Habitat_PromotionBook-TestCategoryPromotionEnabled",
                    "DisplayCartText": "Test category promotion II",
                    "Policies": [],
                    "PromotionActions": [
                        {
                            "Name": "CartFreeGiftAction",
                            "Id": "2cc89dd3762d48f6be6282b9a5c8b95e",
                            "LibraryId": "CartFreeGiftAction",
                            "Policies": [],
                            "Properties": [
                                {
                                    "Name": "MaximumQuantity",
                                    "DisplayType": "System.Int32",
                                    "Value": "0",
                                    "IsOperator": false,
                                    "Policies": []
                                },
                                {
                                    "Name": "AddToCartAutomatically",
                                    "DisplayType": "System.Boolean",
                                    "Value": "true",
                                    "IsOperator": false,
                                    "Policies": []
                                }
                            ]
                        }
                    ]
                }
            ],

For APIs that return pricing information, such as GetSellableItemsSummary(), the promotion is returned in the SellableItemPricing model as shown in the following JSON:

RequestResponse
{
    "@odata.context": "https://localhost:5000/api/$metadata#Collection(Sitecore.Commerce.Plugin.Catalog.SellableItemSummary)",
    "value": [
        {
            "Name": "",
            "ItemId": "Habitat_Master|6042567|",
            "Policies": [],
            "Summaries": [
                {
                    "@odata.type": "#Sitecore.Commerce.Plugin.Inventory.ConnectItemAvailability",
                    "Name": "",
                    "ItemId": "Habitat_Master|6042567|56042567",
                    "Count": 10000,
                    "IsAvailable": true,
                    "IsAlwaysAvailable": false,
                    "AvailableDate": "0001-01-01T00:00:00Z",
                    "AvailabilityExpires": "2020-04-02T14:42:35.7805389Z",
                    "Policies": []
                },
                {
                    "@odata.type": "#Sitecore.Commerce.Plugin.Inventory.ConnectItemAvailability",
                    "Name": "",
                    "ItemId": "Habitat_Master|6042567|56042568",
                    "Count": 10000,
                    "IsAvailable": true,
                    "IsAlwaysAvailable": false,
                    "AvailableDate": "0001-01-01T00:00:00Z",
                    "AvailabilityExpires": "2020-04-02T14:42:35.7834423Z",
                    "Policies": []
                },
                {
                    "@odata.type": "#Sitecore.Commerce.Plugin.Inventory.ConnectItemAvailability",
                    "Name": "",
                    "ItemId": "Habitat_Master|6042567|56042569",
                    "Count": 10000,
                    "IsAvailable": true,
                    "IsAlwaysAvailable": false,
                    "AvailableDate": "0001-01-01T00:00:00Z",
                    "AvailabilityExpires": "2020-04-02T14:42:35.7875943Z",
                    "Policies": []
                },
                {
                    "@odata.type": "#Sitecore.Commerce.Plugin.Catalog.SellableItemPricing",
                    "Name": "Habitat Viva 4-Door 22.0 Cubic Foot Refrigerator with Ice Maker",
                    "ItemId": "6042567",
                    "Policies": [],
                    "ListPrice": {
                        "CurrencyCode": "USD",
                        "Amount": 1919.6900
                    },
                    "SellPrice": {
                        "CurrencyCode": "USD",
                        "Amount": 1919.6900
                    },
                    "Variations": [
                        {
                            "Name": "Habitat Viva 4-Door 22.0 Cubic Foot Refrigerator w/ Ice Maker (Stainless)",
                            "ItemId": "56042567",
                            "Policies": [],
                            "ListPrice": {
                                "CurrencyCode": "USD",
                                "Amount": 2429.9900
                            },
                            "SellPrice": {
                                "CurrencyCode": "USD",
                                "Amount": 2429.9900
                            }
                        },
                        {
                            "Name": "Habitat Viva 4-Door 22.0 Cubic Foot Refrigerator w/ Ice Maker (Black)",
                            "ItemId": "56042568",
                            "Policies": [],
                            "ListPrice": {
                                "CurrencyCode": "USD",
                                "Amount": 2029.9900
                            },
                            "SellPrice": {
                                "CurrencyCode": "USD",
                                "Amount": 2029.9900
                            }
                        },
                        {
                            "Name": "Habitat Viva 4-Door 22.0 Cubic Foot Refrigerator w/ Ice Maker (White)",
                            "ItemId": "56042569",
                            "Policies": [],
                            "ListPrice": {
                                "CurrencyCode": "USD",
                                "Amount": 2029.9900
                            },
                            "SellPrice": {
                                "CurrencyCode": "USD",
                                "Amount": 2029.9900
                            }
                        }
                    ],
                    "Promotions": [
                        {
                            "Name": "",
                            "PromotionId": "Entity-Promotion-Habitat_PromotionBook-PromoCat1",
                            "DisplayCartText": "PromoCat1 dct",
                            "Policies": [],
                            "PromotionActions": [
                                {
                                    "Name": "CartFreeGiftAction",
                                    "Id": "e6f9e89caa5442e9b2bb2e4b47ac994d",
                                    "LibraryId": "CartFreeGiftAction",
                                    "Policies": [],
                                    "Properties": [
                                        {
                                            "Name": "MaximumQuantity",
                                            "DisplayType": "System.Int32",
                                            "Value": "0",
                                            "IsOperator": false,
                                            "Policies": []
                                        },
                                        {
                                            "Name": "AddToCartAutomatically",
                                            "DisplayType": "System.Boolean",
                                            "Value": "true",
                                            "IsOperator": false,
                                            "Policies": []
                                        }
                                    ]
                                }
                            ]
                        },
                        {
                            "Name": "",
                            "PromotionId": "Entity-Promotion-Habitat_PromotionBook-TestCategoryPromotionEnabled",
                            "DisplayCartText": "Test category promotion II",
                            "Policies": [],
                            "PromotionActions": [
                                {
                                    "Name": "CartFreeGiftAction",
                                    "Id": "2cc89dd3762d48f6be6282b9a5c8b95e",
                                    "LibraryId": "CartFreeGiftAction",
                                    "Policies": [],
                                    "Properties": [
                                        {
                                            "Name": "MaximumQuantity",
                                            "DisplayType": "System.Int32",
                                            "Value": "0",
                                            "IsOperator": false,
                                            "Policies": []
                                        },
                                        {
                                            "Name": "AddToCartAutomatically",
                                            "DisplayType": "System.Boolean",
                                            "Value": "true",
                                            "IsOperator": false,
                                            "Policies": []
                                        }
                                    ]
                                }
                            ]
                        },

Do you have some feedback for us?

If you have suggestions for improving this article,