Skip to main content

Bulk Add Custom Discounts to Cart

POST 

https://useast.api.elasticpath.com/v2/carts/:cartID/custom-discounts

The default value for custom discounts on both the cart and cart items is set to 5 if this parameter is not configured in the store. To verify the custom discount limit value, call Get all settings endpoint.

To increase the custom discount value, contact Elastic Path Support team.

Request

Path Parameters

    cartID stringrequired

    Specifies the system generated ID for the cart that the shopper created.

Body

    data object[]
  • Array [
  • amountnumberrequired

    Specifies an amount to be applied for the custom discount. It must be less than zero.

    descriptionstringrequired

    Specifies a description for the custom discount.

    discount_codestringrequired

    Specifies the discount code used for the custom discount.

    discount_enginestringrequired

    Specifies from where the custom discount is applied. For example, Talon.one.

    external_idstringrequired

    Specifies an external id for the custom discount.

    typestringrequired

    Specifies the type of the resource. Always custom_discount.

    relationships object
    item object
    data object
    typestring

    Specifies the type of item. For example, custom_item or cart_item.

    iduuid

    Specifies the unique identifier of the cart_item or custom_item in the cart.

  • ]
  • options object
    add_all_or_nothingboolean

    When true, if an error occurs for any item, no items are added to the cart. When false, valid items are added to the cart and the items with errors are reported in the response. Default is false.

Responses

Response Headers
    Schema
      data object[]
    • Array [
    • amount object
      amountnumber

      Specifies an amount to be applied for the custom discount. It must be less than zero.

      currencystring

      The currency set for the custom discount.

      formattedstring

      The formatted value for the custom discount.

      descriptionstring

      Specifies a description for the custom discount.

      discount_codestring

      Specifies the discount code used for the custom discount.

      discount_enginestring

      Specifies from where the custom discount is applied. For example, Talon.one.

      external_idstring

      Specifies an external id for the custom discount.

      typestringrequired

      Specifies the type of the resource. Always custom_discount.

      iduuidrequired

      Specifies the UUID of the custom discount.

      relationships object
      item object
      data object
      typestring

      Specifies the type of item. For example, custom_item or cart_item.

      iduuid

      Specifies the unique identifier of the cart_item or custom_item in the cart.

    • ]
    • options object
      add_all_or_nothingboolean

      When true, if an error occurs for any item, no items are added to the cart. When false, valid items are added to the cart and the items with errors are reported in the response. Default is false.

    Authorization: http

    name: bearerAuthtype: httpscheme: bearer
    var client = new HttpClient();
    var request = new HttpRequestMessage(HttpMethod.Post, "https://useast.api.elasticpath.com/v2/carts/:cartID/custom-discounts");
    request.Headers.Add("Accept", "application/json");
    request.Headers.Add("Authorization", "Bearer <token>");
    var content = new StringContent("{\n \"data\": [\n {\n \"amount\": 0,\n \"description\": \"string\",\n \"discount_code\": \"string\",\n \"discount_engine\": \"string\",\n \"external_id\": \"string\",\n \"type\": \"string\",\n \"relationships\": {\n \"item\": {\n \"data\": {\n \"type\": \"string\",\n \"id\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\"\n }\n }\n }\n }\n ],\n \"options\": {\n \"add_all_or_nothing\": true\n }\n}", null, "application/json");
    request.Content = content;
    var response = await client.SendAsync(request);
    response.EnsureSuccessStatusCode();
    Console.WriteLine(await response.Content.ReadAsStringAsync());
    Request Collapse all
    Base URL
    https://useast.api.elasticpath.com
    Auth
    Parameters
    — pathrequired
    Body
    {
      "data": [
        {
          "amount": 0,
          "description": "string",
          "discount_code": "string",
          "discount_engine": "string",
          "external_id": "string",
          "type": "string",
          "relationships": {
            "item": {
              "data": {
                "type": "string",
                "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
              }
            }
          }
        }
      ],
      "options": {
        "add_all_or_nothing": true
      }
    }
    
    ResponseClear

    Click the Send API Request button above and see the response here!

    We use cookies to enhance your experience. By continuing to visit this site you agree to our use of cookies.