Promotions

The Cleverbridge GraphQL API offers features to oversee and control promotions, which Shieldware, Inc. employs for product management. To streamline operations and ensure precision, Shieldware integrates their Salesforce account with the Cleverbridge GraphQL API. This integration allows the e-commerce manager to centrally manage all products through Salesforce, establishing it as the definitive source of accurate product information.

View and Manage Promotions

For the past 3 years, Shieldware, Inc. has been using the Cleverbridge platform to manage its product information. However, this has created certain challenges for their sales team, who frequently rely on Salesforce for product information. To save time and ensure accurate product and pricing information, Shieldware integrates their Salesforce account with the Cleverbridge GraphQL API. This integration enables the e-commerce manager to manage all of Shieldware's products from within Salesforce, eliminating the need to open the Commerce Assistant and establishing Salesforce as the single source of truth for up-to-date product information.

You can use the GraphQL API to manage your promotions in the following ways:

View Information for One of your Promotions

To get the data stored in the Cleverbridge platform for a promotion, use the promotion query object. You must provide the id of the promotion and specify the fields you would like to return.

Example Request

query {
  promotion(id: 30367) {
    id
    name
    discount {
      id
      doNotAllowOtherDiscounts
      maxIntervalCount
      maxQuantity
      showOriginalAndDiscountPrice
      priceType {
        id
        name
      }
    }
    priceConfigurationList {
      items {
        id
      }
      type {
        id
      }
    }
    couponSettings {
      caseSensitiveCodes
      couponUseLimit
      couponList {
        coupons {
          code
          isActive
          quantityUsageCount
        }
      }
    }
    productList {
      type {
        id
      }
      products {
        id
      }
    }
    validFrom
    validTo
    isActive
    isActiveAndValid
    affiliate {
      id
    }
    client {
      id
    }
    clientSalesRevenueStatistics {
      last14Days {
        type {
          id
        }
        value
      }
      last24Hours {
        type {
          id
        }
        value
      }
      lastMonth {
        type {
          id
        }
        value
      }
    }
  }
}

The API call returns the promotion object with the requested fields. You can use this information to update your internal systems.

Example Response

{
  "data": {
    "promotion": {
      "id": 30367,
      "name": "Summer Special",
      "discount": {
        "id": 176890,
        "doNotAllowOtherDiscounts": true,
        "maxIntervalCount": null,
        "maxQuantity": 1,
        "showOriginalAndDiscountPrice": true,
        "priceType": {
          "id": "PERCENTAGE_DISCOUNT",
          "name": "Percentage discount"
        }
      },
      "priceConfigurationList": null,
      "couponSettings": {
        "caseSensitiveCodes": false,
        "couponUseLimit": 50,
        "couponList": {
          "coupons": [
            {
              "code": "ME6-Q49-T39",
              "isActive": false,
              "quantityUsageCount": 0
            },
            {
              "code": "LDG-NRR-53Z",
              "isActive": false,
              "quantityUsageCount": 0
            },
            {
              "code": "RWM-7L9-L1M",
              "isActive": false,
              "quantityUsageCount": 0
            },
            {
              "code": "WUC-GBT-NH2",
              "isActive": false,
              "quantityUsageCount": 0
            },
            {
              "code": "UJH-73Y-VWT",
              "isActive": false,
              "quantityUsageCount": 0
            },
            {
              "code": "1XQ-XUA-3EJ",
              "isActive": false,
              "quantityUsageCount": 0
            },
            {
              "code": "2DM-KAR-3UR",
              "isActive": false,
              "quantityUsageCount": 0
            },
            {
              "code": "FVA-8UP-H99",
              "isActive": false,
              "quantityUsageCount": 0
            },
            {
              "code": "5JT-NCP-FYM",
              "isActive": false,
              "quantityUsageCount": 0
            },
            {
              "code": "1DA-FU2-PaM",
              "isActive": false,
              "quantityUsageCount": 2
            }
          ]
        }
      },
      "productList": {
        "type": {
          "id": "POSITIVE"
        },
        "products": [
          {
            "id": 97773
          },
          {
            "id": 97772
          },
          {
            "id": 97771
          }
        ]
      },
      "validFrom": "2012-06-01T12:06:00Z",
      "validTo": "2012-08-31T12:06:00Z",
      "isActive": true,
      "isActiveAndValid": false,
      "affiliate": null,
      "client": {
        "id": 864
      },
      "clientSalesRevenueStatistics": {
        "last14Days": {
          "type": {
            "id": "CLIENT_SALES_REVENUE_LAST_14_DAYS"
          },
          "value": 0
        },
        "last24Hours": {
          "type": {
            "id": "CLIENT_SALES_REVENUE_LAST_24_HOURS"
          },
          "value": 0
        },
        "lastMonth": {
          "type": {
            "id": "CLIENT_SALES_REVENUE_LAST_MONTH"
          },
          "value": 0
        }
      }
    }
  }
}

View Information for All of your Promotions

To get the data stored in the Cleverbridge platform for all of your promotions, use the promotions query object. You must provide your clientId and specify the fields you would like to return.

Example Request

query {
  promotions(clientId: 864) {
    id
    name
    productList {
      type {
        id
      }
      products {
        id
      }
    }
    isActiveAndValid
    client {
      id
    }
  }
}

The API call returns the promotions object with the requested fields. You can use this information to update your internal systems.

Example Response

{
 "data": {
  "promotions": [
   {
    "id": 30364,
    "name": "Black Friday Promo - 50% off",
    "productList": {
     "type": {
      "id": "POSITIVE"
     },
     "products": [
      {
       "id": 97778
      },
      {
       "id": 97781
      },
      {
       "id": 97770
      },
      {
       "id": 97774
      },
      {
       "id": 97779
      },
      {
       "id": 97782
      },
      {
       "id": 97771
      },
      {
       "id": 97775
      },
      {
       "id": 97783
      },
      {
       "id": 97772
      },
      {
       "id": 97776
      },
      {
       "id": 97780
      },
      {
       "id": 97784
      },
      {
       "id": 97777
      },
      {
       "id": 97773
      }
     ]
    },
    "isActiveAndValid": true,
    "client": {
     "id": 864
    }
   },
   {
    "id": 30452,
    "name": "Product Anniversary - 30% off",
    "productList": {
     "type": {
      "id": "POSITIVE"
     },
     "products": [
      {
       "id": 97771
      },
      {
       "id": 97772
      },
      {
       "id": 97773
      }
     ]
    },
    "isActiveAndValid": false,
    "client": {
     "id": 864
    }
   },
   {
    "id": 30367,
    "name": "Summer Special",
    "productList": {
     "type": {
      "id": "POSITIVE"
     },
     "products": [
      {
       "id": 97773
      },
      {
       "id": 97772
      },
      {
       "id": 97771
      },
      {
       "id": 97774
      }
     ]
    },
    "isActiveAndValid": false,
    "client": {
     "id": 864
    }
   }
  ]
 }
}

Create a Promotion

To create a new promotion, use the createPromotion mutation object. To successfully make this call, certain fields are required, including clientId, name, isActive, and discount.

Example Request

mutation {
  createPromotion(
    input: {
      clientId: 864
      isActive: true
      name: "Summer Special"
      validFrom: "2020-08-31T14:06:00Z"
      validTo: "2020-10-31T14:06:00Z"
      discount: {
        priceTypeId: PERCENTAGE_DISCOUNT
        doNotAllowOtherDiscounts: true
        maxQuantity: 1
        percentagePrice: { pricePercentageValues: { quantity: 1, value: 25 } }
      }
      couponSettings: { couponUseLimit: 50, caseSensitiveCodes: false }
      productList: { typeId: POSITIVE, productIds: [97771, 97772, 97773] }
    }
  ) {
    createdPromotion {
      id
    }
  }
}

The API call returns the createPromotion object with the requested fields.

Example Response

{
  "data": {
    "createPromotion": {
      "createdPromotion": {
        "id": 102280
      }
    }
  }
}

Generate Coupon Codes

To generate coupon codes for a promotion, use the generateCouponCodes query object. To successfully make this call, certain fields are required, including characterSet, numberOfCharacters, and quantity.

📘

Note

You can provide a promotionId to make sure that no coupon codes are generated that are already associated with the promotion.

Example Request

query {
  generateCouponCodes(
    input: {
      promotionId: 30362
      quantity: 4
      numberOfCharacters: 9
      dashPosition: 3
      characterSet: ALPHANUMERIC_ALL_UPPER
    }
  )
}

The API call returns the generateCouponCodes object with a list of strings.

Example Response

{
  "data": {
    "generateCouponCodes": [
      "GSP-LJD-YF6",
      "XVP-N8Q-AQC",
      "MRQ-P6Q-J4V",
      "YEJ-L28-Q5K"
    ]
  }
}

Add Coupon Codes to a Promotion

To add coupon codes to a promotion, use the updatePromotion mutation. You must provide the id of the promotion you would like to update and a list of existing and new coupons. The following is an example of an updatePromotion mutation that adds four new coupon codes to the promotion.

🚧

Important

If the promotion already has coupon codes, you must provide those coupon codes in the request. Otherwise, the existing coupon codes will be removed.

Example Request

mutation {
  updatePromotion(
    input: {
      id: 30366
      couponSettings: {
        coupons: [
          { code: "BD3-1KK-UN3", quantityUsageCount: 112, isActive: true }
          { code: "GSP-LJD-YF6", quantityUsageCount: 0, isActive: true }
          { code: "XVP-N8Q-AQC", quantityUsageCount: 0, isActive: true }
          { code: "MRQ-P6Q-J4V", quantityUsageCount: 0, isActive: true }
          { code: "AYEJ-L28-Q5K", quantityUsageCount: 0, isActive: true }
        ]
      }
    }
  ) {
    updatedPromotion {
      id
      couponSettings {
        caseSensitiveCodes
        couponCount
        couponList {
          coupons {
            code
            isActive
            quantityUsageCount
          }
          isTruncated
        }
        couponUseLimit
      }
    }
  }
}

The API call returns the updatePromotion object with the requested fields.

Example Response

{
  "data": {
    "updatePromotion": {
      "updatedPromotion": {
        "id": 30366,
        "couponSettings": {
          "caseSensitiveCodes": false,
          "couponCount": 5,
          "couponList": {
            "coupons": [
              {
                "code": "BD3-1KK-UN3",
                "isActive": true,
                "quantityUsageCount": 112
              },
              {
                "code": "GSP-LJD-YF6",
                "isActive": true,
                "quantityUsageCount": 0
              },
              {
                "code": "XVP-N8Q-AQC",
                "isActive": true,
                "quantityUsageCount": 0
              },
              {
                "code": "MRQ-P6Q-J4V",
                "isActive": true,
                "quantityUsageCount": 0
              },
              {
                "code": "AYEJ-L28-Q5K",
                "isActive": true,
                "quantityUsageCount": 0
              }
            ],
            "isTruncated": false
          },
          "couponUseLimit": 50
        }
      }
    }
  }
}

Delete a Promotion

You can use the GraphQL API to delete a promotion from the Cleverbridge platform. To do so, use the deletePromotion mutation object. You must specify the id of the promotion you would like to delete.

Example Request

mutation {
  deletePromotion(id: 102280
) {
    deletedPromotionId
  }
}

The API call returns the deletePromotion object with the requested fields.

Example Response

{
  "data": {
    "deletePromotion": {
      "deletedPromotionId": 102280
    }
  }
}

Update a Promotion

To update a promotion, use the updatePromotion mutation. You must provide the id of the promotion you would like to update and specify the fields you would like to change. The following is an example of an updatePromotion mutation that adds a new product to the promotion.

Example Request

mutation {
  updatePromotion(
    input: {
      id: 30367
      productList: {
        typeId: POSITIVE
        productIds: [97771, 97772, 97773, 97774]
      }
    }
  ) {
    updatedPromotion {
      id
      productList {
        products {
          id
        }
      }
    }
  }
}

The API call returns the updatePromotion object with the requested fields.

Example Response

{
  "data": {
    "updatePromotion": {
      "updatedPromotion": {
        "id": 30367
        "productList": {
          "products": [
            {
              "id": 97771
            },
            {
              "id": 97772
            },
            {
              "id": 97773
            },
            {
              "id": 97774
            }
          ]
        }
      }
    }
  }
}