Process discount request

Request details

Ecwid will send the cart details in a body of POST HTTP request.

📘

Ecwid can cache the requests to your endpoint. How custom discount works

POST https://mycoolapp.com/discounts HTTP/1.1

{
  "storeId": 1003,
  "merchantAppSettings": {},
  "cart": {
    "id": null,
    "orderNumber": null,
    "vendorOrderNumber": null,
    "subtotal": 2130,
    "ipAddress": null,
    "couponDiscount": 213,
    "paymentStatus": "INCOMPLETE",
    "fulfillmentStatus": "NEW",
    "refererUrl": null,
    "orderComments": null,
    "volumeDiscount": 0,
    "membershipBasedDiscount": 0,
    "totalAndMembershipBasedDiscount": 0,
    "discount": 0,
    "customerGroupId": null,
    "customerGroup": null,
    "customerId": null,
    "customerEmail": null,
    "discountCoupon": {
      "id": 135823561,
      "ownerId": 1003,
      "name": "Coupon",
      "code": "YOURCODE",
      "discountType": "PERCENT",
      "status": "ACTIVE",
      "discount": 10,
      "launchDate": "2019-09-30 23:00:00 +0000",
      "expirationDate": null,
      "totalLimit": null,
      "usesLimit": "UNLIMITED",
      "applicationLimit": "UNLIMITED",
      "creationDate": "2021-09-21 13:40:21 +0000",
      "orderCount": 0,
      "legacyCatalogLimit": null,
      "catalogLimit": null,
      "repeatCustomerOnly": false,
      "newCustomerOnly": false,
      "parentId": 41576009,
      "customerId": 0,
      "cartId": 1950723716,
      "updateDate": "2021-02-23 02:01:30 +0000"
    },
    "discountInfo": null,
    "handlingFee": {
      "name": "Handling Fee",
      "value": 0,
      "description": ""
    },
    "hidden": false,
    "items": [
      {
        "weight": 120,
        "price": 2130,
        "amount": 1,
        "productId": 352841275,
        "combinationId": 12345,
        "name": "Test Product",
        "categoryId": null,
        "sku": "00002312",
        "selectedOptions": [
          {
            "name": "Size",
            "nameTranslated": null,
            "type": "CHOICE",
            "value": "S",
            "valueTranslated": {
              "en": "S"
            },
            "valuesArray": [
              "S"
            ],
            "valuesArrayTranslated": null,
            "files": null,
            "selections": [
              {
                "selectionTitle": "S",
                "selectionModifier": 0,
                "selectionModifierType": "ABSOLUTE"
              }
            ]
          }
        ],
        "dimensions": {
          "length": 0,
          "width": 0,
          "height": 0
        },
        "productPrice": 2130,
        "categoryIds": [],
        "categories": [],
        "quantity": null,
        "unlimited": true,
        "inStock": true,
        "priceInProductList": 2130,
        "isShippingRequired": true,
        "productClassId": 0,
        "enabled": true,
        "warningLimit": 0,
        "fixedShippingRateOnly": false,
        "fixedShippingRate": 0,
        "options": [
          {
            "type": "SELECT",
            "name": "Size",
            "defaultChoice": 0,
            "required": false,
            "choices": [
              {
                "text": "S",
                "priceModifier": 0,
                "priceModifierType": "ABSOLUTE"
              },
              {
                "text": "M",
                "priceModifier": 0,
                "priceModifierType": "ABSOLUTE"
              }
            ]
          }
        ],
        "wholesalePrices": [],
        "compareToPrice": null,
        "url": "https://store.ecwid.com/#!/Test-Product/p/352841275",
        "created": "2021-05-03 18:23:13 +0000",
        "updated": "2021-09-21 13:42:21 +0000",
        "createTimestamp": 1620066193,
        "updateTimestamp": 1632231741,
        "defaultCombinationId": 222806564,
        "imageUrl": null,
        "thumbnailUrl": null,
        "smallThumbnailUrl": null,
        "hdThumbnailUrl": null,
        "originalImageUrl": null,
        "originalImage": null,
        "borderInfo": null,
        "galleryImages": [],
        "defaultCategoryId": 0,
        "seoTitle": "",
        "seoDescription": "",
        "favorites": {
          "count": 0,
          "displayedCount": "0"
        },
        "attributes": [
          {
            "id": 27942320,
            "name": "UPC",
            "type": "UPC",
            "value": "TEST",
            "show": "DESCR"
          },
          {
            "id": 27942321,
            "name": "Brand",
            "type": "BRAND",
            "value": "GENERIC",
            "show": "DESCR"
          }
        ],
        "relatedProducts": {
          "productIds": [],
          "relatedCategory": {
            "enabled": false,
            "categoryId": 0,
            "productCount": 5
          }
        },
        "combinations": [
          {
            "id": 222806563,
            "sku": "00002444",
            "combinationNumber": 2,
            "options": [
              {
                "name": "Size",
                "nameTranslated": {
                  "en": "Size"
                },
                "value": "M",
                "valueTranslated": {
                  "en": "M"
                }
              }
            ],
            "smallThumbnailUrl": null,
            "hdThumbnailUrl": null,
            "thumbnailUrl": null,
            "imageUrl": null,
            "originalImageUrl": null,
            "price": null,
            "defaultDisplayedPrice": 2130,
            "defaultDisplayedPriceFormatted": "$2 130.00",
            "compareToPrice": null,
            "wholesalePrices": null,
            "quantity": null,
            "unlimited": true,
            "inStock": true,
            "warningLimit": 0,
            "weight": 190,
            "borderInfo": null,
            "attributes": [],
            "isShippingRequired": null
          },
          {
            "id": 222806564,
            "sku": "00002312",
            "combinationNumber": 1,
            "options": [
              {
                "name": "Size",
                "nameTranslated": {
                  "en": "Size"
                },
                "value": "S",
                "valueTranslated": {
                  "en": "S"
                }
              }
            ],
            "smallThumbnailUrl": null,
            "hdThumbnailUrl": null,
            "thumbnailUrl": null,
            "imageUrl": null,
            "originalImageUrl": null,
            "price": null,
            "defaultDisplayedPrice": 2130,
            "defaultDisplayedPriceFormatted": "$2 130.00",
            "compareToPrice": null,
            "wholesalePrices": null,
            "quantity": null,
            "unlimited": true,
            "inStock": true,
            "warningLimit": 0,
            "weight": 120,
            "borderInfo": null,
            "attributes": [],
            "isShippingRequired": null
          }
        ],
        "showOnFrontpage": 2
      }
    ],
    "shippingAddress": {
      "street": "test",
      "city": "test",
      "countryCode": "US",
      "postalCode": "10001",
      "stateOrProvinceCode": "NY",
      "stateOrProvinceName": "New York"
    },
    "originAddress": {
      "street": "1 Teema, Harris Road, South End\n",
      "city": "Port Elizabeth",
      "countryCode": "DE",
      "postalCode": "54570",
      "stateOrProvinceCode": ""
    },
    "weight": 120,
    "weightUnit": "kg",
    "dimensionUnit": "CM",
    "currency": "USD",
    "predictedPackages": null,
    "paymentMethod": "PayPal",
    "extraFields": null
  },
 "lang": "en"
}
NameTypeDescription
storeIdnumberEcwid store ID
merchantAppSettingsjsonMerchant settings for your integration set up by your code. More details
cart<CartDetails>All available cart information when cart is recalculated at checkout
langstringCustomer's storefront language (e.g. en)

CartDetails

NameTypeDescription
subtotalnumberOrder subtotal. Includes the sum of all products' cost in the order without taxes, but including product variations and options
ipAddressstringCustomer IP
paymentStatusstringPayment status. Supported values:
  • AWAITING_PAYMENT
  • PAID
  • CANCELLED
  • REFUNDED
  • INCOMPLETE
fulfillmentStatusstringFulfilment status. Supported values:
  • AWAITING_PROCESSING
  • PROCESSING
  • SHIPPED
  • DELIVERED
  • WILL_NOT_DELIVER
  • RETURNED
refererUrlstringURL of the page when order was placed (without hash (#) part)
orderCommentsstringOrder comments
couponDiscountnumberDiscount applied to order using a coupon
volumeDiscountnumberSum of discounts based on subtotal. Is included into the discount field
discountnumberThe sum of all applied discounts except for the coupon discount. To get the total order discount, take the sum of couponDiscount and discount field values
membershipBasedDiscountnumberSum of discounts based on customer group. Is included into the discount field
totalAndMembershipBasedDiscountnumberThe sum of discount based on subtotal AND customer group. Is included into the discount field
discountCoupon<DiscountCouponInfo>Information about applied coupon
discountInfoArray<DiscountInfo>Information about applied discounts (coupons are not included)
customerGroupIdnumberCustomer group ID
customerGroupstringThe name of group (membership) the customer belongs to
handlingFee<HandlingFeeInfo>Handling fee details
customerIdnumberUnique customer internal ID (if the order is placed by a registered user)
itemsArray<OrderItems>Array of customer's order items with basic details
weightnumberTotal weight of the order
weightUnitstringActive weight units in the store at the moment of the request
currencystringActive currency in the store at the moment of the request
predictedPackagesArray<PredictedPackage>Predicted information about the packages to ship items in to customer
shippingAddress<ShippingAddressInfo>Shipping address details (destination)
originAddress<OriginAdressInfo>Origin address details (departure)
dimensionUnitstringActive dimension units of a store at the moment of the request. Possible values: IN,YD,CM,MM
paymentMethodstringPayment method used by customer
handlingFee<HandlingFeeInfo>Handling fee details
emailstringCustomer email address
extraFields<ExtraFieldsInfo>Additional optional information about order. Total storage of extra fields cannot exceed 8Kb. See Order extra fields

OrderItems

FieldTypeDescription
productIdnumberStore product ID
combinationIdnumberProduct variation ID (if a product has it)
categoryIdnumberID of category this product was added to cart from. If the product was added to cart from API or Search page, categoryID will return -1
pricenumberPrice of ordered item in the cart. Includes taxes in product price and product variations/options
weightnumberProduct weight
skustringProduct SKU. If the chosen options match a variation, this will be a variation SKU.
amountnumberAmount purchased
namestringProduct name
selectedOptionsArray<OrderItemOption>Product options values selected by the customer
dimensions<OrderItemDimensions>Product dimensions info
quantitynumberAmount of product items in stock. This field is omitted for the products with unlimited stock
unlimitedbooleantrue if the product has unlimited stock
inStockbooleantrue if the product or any of its variations is in stock (quantity is more than zero) or has unlimited quantity. false otherwise.
namestringProduct title
productPricenumberProduct price set by store owner
priceInProductListnumberProduct price displayed in a storefront. May differ from the price value when the product has options and variations and the default variation's price is different from the base product price. Does not include taxes
wholesalePricesArray<WholesalePrice>Sorted array of wholesale price tiers (quantity limit and price pairs)
compareToPricenumberProduct's sale price displayed strike-out in the customer frontend Omitted if empty
isShippingRequiredbooleantrue if product requires shipping, false otherwise
urlstringURL of the product's details page in the store. Learn more
createdstringDate and time of the product creation. Example: 2014-07-30 10:32:37 +0000
updatedstringProduct last update date/time
createTimestampnumberThe date of product creation in UNIX Timestamp format, e.g 1427268654
updateTimestampnumberProduct last update date in UNIX Timestamp format, e.g 1427268654
productClassIdnumberId of the class (type) that this product belongs to. 0 value means the product is of the default 'General' class. See also: Product types and attributes in Ecwid
enabledbooleantrue if product is enabled, false otherwise. Disabled products are not displayed in the store front.
optionsArray<ProductOption>A list of the product options. Empty ([]) if no options are specified for the product.
warningLimitnumberThe minimum 'warning' amount of the product items in stock, if set. When the product quantity reaches this level, the store administrator gets an email notification.
fixedShippingRateOnlybooleantrue if shipping cost for this product is calculated as 'Fixed rate per item' (managed under the "Tax and Shipping" section of the product management page in Ecwid Control panel). false otherwise. With this option on, the fixedShippingRate field specifies the shipping cost of the product
fixedShippingRatenumberWhen fixedShippingRateOnly is true, this field sets the product fixed shipping cost per item. When fixedShippingRateOnly is false, the value in this field is treated as an extra shipping cost the product adds to the global calculated shipping
defaultCombinationIdnumberIdentifier of the default product variation, which is defined by the default values of product options.
thumbnailUrlstringURL of the product thumbnail displayed on the product list pages. Thumbnails size is defined in the store settings. Default size of the biggest dimension is 400px. The original uploaded product image is available in the originalImageUrl field.
imageUrlstringURL of the product image resized to fit 1500x1500px. The original uploaded product image is available in the originalImageUrl field.
smallThumbnailUrlstringURL of the product thumbnail resized to fit 160x160px. The original uploaded product image is available in the originalImageUrl field.
hdThumbnailUrlstringProduct HD thumbnail URL resized to fit 800x800px
originalImageUrlstringURL of the original not resized product image
originalImage<ImageDetails>Details of the product image
galleryImagesArray<GalleryImage>List of the product gallery images
categoryIdsArray<number>List of the categories, which the product belongs to. If no categories provided, product will be displayed on the store front page, see showOnFrontpage field
categoriesArray<CategoriesInfo>List of the categories, which the product belongs to, with brief details. If no categories provided, product belogs to store front page, see showOnFrontpage field
seoTitlestringPage title to be displayed in search results on the web. Recommended length is under 55 characters
seoDescriptionstringPage description to be displayed in search results on the web. Recommended length is under 160 characters
defaultCategoryIdnumberIdentifier of the default category of the product
favorites<FavoritesStats>Product favorites stats
attributesArray<AttributeValue>Product attributes and their values
relatedProducts<RelatedProducts>Related or "You may also like" products of the product
combinationsArray<Variation>List of the product variations
showOnFrontpagenumberA positive number indicates the position (index) of a product in the store front page – the smaller the number, the higher the product is displayed on a page. A negative value means the product is not shown in the store front page

OrderItemOption

FieldTypeDescription
namestringOption name
typestringOption type. One of:
  • CHOICE (dropdown or radio button)
  • CHOICES (checkboxes)
  • TEXT (text input and text area)
  • DATE (date/time)
  • FILES (upload file option)
valuestringSelected/entered option value(s) as a string. For the CHOICES type, provides a string with all chosen values (comma-separated). You can use this to simply print out all selected values.
valuesArrayArraySelected option values as an array. For the CHOICES type, provides an array with the chosen values so you can iterate through them in your app.
filesArray<OrderItemOptionFile>Attached files (if the option type is FILES)

OrderItemOptionFile

FieldTypeDescription
idnumberFile ID
namestringFile name
sizenumberFile size in bytes
urlstringFile URL

OrderItemDimensions

FieldTypeDescription
lengthnumberLength of a product
widthnumberWidth of a product
heightnumberHeight of a product

FavoritesStats

FieldTypeDescription
countnumberThe actual number of 'likes' of this product
displayedCountstringThe displayed number of likes. May differ from the count if, for example, the value is more than 1000, than it will show 1K instead of the precise number

WholesalePrice

FieldTypeDescription
quantitynumberNumber of product items on this wholesale tier
pricenumberProduct price on the tier

ProductOption

FieldTypeDescription
typestringOne of SELECT, RADIO, CHECKBOX, TEXTFIELD, TEXTAREA, DATE, FILES
namestringProduct option name, e.g. Color
choicesArray<ProductOptionChoice>All possible option selections for the types SELECT, CHECKBOX or RADIO. This field is omitted for the product option with no selection (e.g. text, datepicker or upload file options)
defaultChoicenumberThe number, starting from 0, of the option's default selection. Only presents if the type is SELECT, CHECKBOX or RADIO.
requiredbooleantrue if this option is required, false otherwise. Default is false

ImageDetails

FieldTypeDescription
urlstringImage URL
widthintegerImage width
heightintegerImage height

GalleryImage

FieldTypeDescription
idnumberInternal gallery image ID
altstringImage description, displayed in the image tag's alt attribute
urlstringDeprecated. Original image URL. Equals originalImageUrl
thumbnailstringDeprecated. Image thumbnail URL resized to fit 160x160px. Equals smallThumbnailUrl
thumbnailUrlstringURL of the product thumbnail displayed on the product list pages. Thumbnails size is defined in the store settings. Default size of the biggest dimension is 400px. The original uploaded product image is available in the originalImageUrl field.
imageUrlstringURL of the product image resized to fit 1500x1500px. The original uploaded product image is available in the originalImageUrl field.
smallThumbnailUrlstringURL of the product thumbnail resized to fit 160x160px. The original uploaded product image is available in the originalImageUrl field.
hdThumbnailUrlstringProduct HD thumbnail URL resized to fit 800x800px
originalImageUrlstringURL of the original not resized product image
widthnumberImage width
heightnumberImage height
orderbynumberThe sort weight of the image in the gallery images list. The less the number, the closer the image to the beginning of the gallery

CategoriesInfo

FieldTypeDescription
idnumberCategory ID
enabledbooleantrue if category is enabled, false otherwise

AttributeValue

FieldTypeDescription
idnumberUnique attribute ID. See Product Classes for the information on attribute IDs
namestringAttribute displayed name
valuestringAttribute value
typestringAttribute type. There are user-defined attributes, general attributes and special 'price per unit’ attributes. The 'type’ field contains one of the following: CUSTOM, UPC, BRAND, GENDER, AGE_GROUP, COLOR, SIZE, PRICE_PER_UNIT, UNITS_IN_PRODUCT
showstringDefines where to display the product attribute value:. Supported values: NOTSHOW, DESCR, PRICE

RelatedProducts

FieldTypeDescription
productIdsArray<number>IDs of the related products
relatedCategoryRelatedCategoryDescribes the "N random related products from a category" option

RelatedCategory

FieldTypeDescription
enabledbooleantrue if the "N random related products from a category" option is enabled. false otherwise
categoryIdnumberId of the related category. Zero value means "any category", that is, random products from the whole store.
productCountnumberNumber of random products from the given category to be shown as related

Variation

FieldTypeDescription
idnumberVariation ID
combinationNumbernumberVariation # number, which is displayed in the variations table in Control panel
optionsArray<OptionValue>Set of options that identifies this variation. An array of name-value pairs
skustringVariation SKU. Omitted if the variation inherits the base product's SKU
thumbnailUrlstringURL of the product variation thumbnail displayed on the product list pages. Thumbnails size is defined in the store settings. Default size of biggest dimension is 400px. Omitted if the variation inherits the base product's image. The original uploaded product image is available in the originalImageUrl field.
imageUrlstringURL of the product variation image resized to fit 1500x1500px. Omitted if the variation inherits the base product's image. The original uploaded product image is available in the originalImageUrl field.
smallThumbnailUrlstringURL of the product variation thumbnail resized to fit 160x160px. Omitted if the variation inherits the base product's image. The original uploaded product image is available in the originalImageUrl field.
hdThumbnailUrlstringProduct variation HD thumbnail URL resized to fit 800x800px. Omitted if the variation inherits the base product's image.
originalImageUrlstringURL of the original not resized product variation image. Omitted if the variation inherits the base product's image.
quantitynumberAmount of the variation items in stock. Omitted if the variation inherits the base product's quantity.
unlimitedbooleantrue if the variation has unlimited stock (that is, never runs out)
pricenumberVariation price. Omitted if the variation inherits the base product's price.
wholesalePricesArray<WholesalePrice>Sorted array of the variation's wholesale price tiers (quantity limit and price). Omitted if the variation inherits the base product's tiered price settings.
weightnumberVariation weight in the units defined in store settings. Omitted if the variation inherits the base product's weight.
warningLimitnumberThe minimum 'warning' amount of the product items in stock for this variation, if set. When the variation in stock amount reaches this level, the store administrator gets an email notification. Omitted if the variation inherits the base product's settings.

OptionValue

FieldTypeDescription
namestringOption name
valuestringOption value

ProductOptionChoice

FieldTypeDescription
textstringOption selection text, e.g. 'Green'.
priceModifiernumberPercent or absolute value of the option's price markup. Positive, negative and zero values are allowed. Default is 0
priceModifierTypestringOption markup calculation type. PERCENT or ABSOLUTE. Default is ABSOLUTE.

DiscountCouponInfo

FieldTypeDescription
idnumberInternal unique coupon ID
namestringCoupon title in store control panel
codestringCoupon code
discountTypestringDiscount type: ABS, PERCENT, SHIPPING, ABS_AND_SHIPPING, PERCENT_AND_SHIPPING
statusstringDiscount coupon state: ACTIVE, PAUSED, EXPIRED or USEDUP
discountnumberDiscount amount
launchDatestringThe date of coupon launch, e.g. 2014-06-06 08:00:00 +0000
expirationDatestringCoupon expiration date, e.g. 2014-06-06 08:00:00 +0000
creationDatestringCoupon creation date. Format example: 2016-06-29 11:36:55 +0000
updateDatestringCoupon update date. Format example: 2016-06-29 11:36:55 +0000
totalLimitnumberThe minimum order subtotal the coupon applies to
usesLimitstringNumber of uses limitation: UNLIMITED, ONCEPERCUSTOMER, SINGLE
repeatCustomerOnlybooleanCoupon usage limitation flag identifying whether the coupon works for all customers or only repeat customers
orderCountnumberNumber of uses
catalogLimit<DiscountCouponCatalogLimit>Products and categories the coupon can be applied to

DiscountCouponCatalogLimit

FieldTypeDescription
productsArrayThe list of product IDs the coupon can be applied to
categoriesArrayThe list of category IDs the coupon can be applied to

DiscountInfo

FieldTypeDescription
valuenumberDiscount value
typestringDiscount type: ABS or PERCENT
basestringDiscount base, one of ON_TOTAL, ON_MEMBERSHIP, ON_TOTAL_AND_MEMBERSHIP
order_totalnumberMinimum order subtotal the discount applies to

ExtraFieldsInfo

FieldTypeDescription
YOUR_FIELD_NAMEstringYour custom name saved for the order extra field. The value length cannot exceed 255 characters

PredictedPackage

NameTypeDescription
heightnumberHeight of a predicted package
widthnumberWidth of a predicted package
lengthnumberLength of a predicted package
weightnumberTotal weight of a predicted package
declaredValuenumberDeclared value of a predicted package (subtotal of items in package)

ShippingAddressInfo

NameTypeDescription
streetstringCustomer's street
citystringCustomer's city
countryCodestringCustomer's country code in Ecwid
countryNamestringCustomer's country name in Ecwid
postalCodestringCustomer's postal code
stateOrProvinceCodestringCustomer's state or province code in Ecwid
stateOrProvinceNamestringCustomer's state or province name in Ecwid

OriginAdressInfo

NameTypeDescription
streetstringCustomer's street
citystringCustomer's city
countryCodestringCustomer's country code in Ecwid
postalCodestringCustomer's postal code
stateOrProvinceCodestringCustomer's state or province code in Ecwid

HandlingFeeInfo

FieldTypeDescription
namestringHandling fee name set by store admin. E.g. Wrapping
valuenumberHandling fee value
descriptionstringHandling fee description for customer