Skip to main content

Product Discount

Use the REST API to interact with the product discount in the application.

You should take into account when making your request
info

Remember that for some requests, you need to send the authentication token.

Header Parameters

{
"Authorization": "Bearer ...token..."
}

And the query parameters are as follows:

Query Parameters

{
"setting": {
"timezone": "America/Bogota",
"fromAdmin": true,
"appMode": "iadmin",
"authProvider": "local",
"locale": "en"
}
}
Do you want to see the changes made through the API?
info

After using the API to access products, it's important to update the cache to see the changes.

How to do it:

  • Go to the upper-right corner and select the dropdown menu with your username.
  • Click on 'Settings.'
  • In the 'Actions' section, look for the 'Clear Cache' option.
  • Click on 'Clear Cache' to update the information and view the updated products.

Clear cache

Create a Product Discount

Use this endpoint to create a product discount.

POST/api/icommerce/v3/product-discounts
{
"attributes": {
"include_departments": [
"0"
],
"exclude_departments": [
"1"
],
"quantity": "50",
"discount": "15",
"criteria": "percentage",
"date_start": "2023/11/02",
"date_end": "2023/11/30",
"priority": "5",
"product_id": 89,
"es": {}
}
}
Response
{
"data": ""
}

Modify a Product Discount

Use this endpoint to modify a product discount. You can send one or multiple values in the request. By default, the accepted value is the ID, but if you want to send another value, you need to include the following in the Query Parameters:

{
"filter": {
"field": "name" // The value by which the search will be conducted
}
}
PUT/api/icommerce/v3/product-discounts/{criteria}
{
"attributes": {
"id": 1,
"quantity": 20,
"discount": 500,
"criteria": "fixed",
"date_start": "2023/11/02",
"date_end": "2023/11/30",
"priority": 2,
"product_id": 89
}
}
Response
{
"data": "Item Updated"
}

Get Multiple Product Discounts

Use this endpoint to retrieve multiple product discounts. You can filter the product discounts, paginate them, and include additional data such as associated departments. The data that can be included is:

IncludeDescription
departmentFetches the departments associated with the product discount.

Query Parameters:

GET/api/icommerce/v3/product-discounts
{
"filter": {
"order": {
"field":"created_at",
"way":"desc"
}
},
"page": 1, // Page number of products
"take": 1, // Number of products to retrieve
"include": 'department'
}
Response
{
"data": [
{
"id": 1,
"productId": 89,
"price": 8500,
"finished": false,
"running": true,
"quantity": 50,
"priority": 5,
"discount": 15,
"criteria": "percentage",
"excludeDepartments": [
"1"
],
"includeDepartments": [
"0"
],
"department": null,
"dateStart": "2023-11-02",
"dateEnd": "2023-11-30",
"createdAt": "2023-11-16 14:48:38",
"updatedAt": "2023-11-16 14:51:36"
}
],
"meta": {
"page": {
"total": 1,
"lastPage": 1,
"perPage": "10",
"currentPage": 1
}
}
}

Get a Specific Product Discount

Use this endpoint to retrieve a specific product discount.

GET/api/icommerce/v3/product-discounts/{criteria}
{}
Response
{
"data": {
"id": 1,
"productId": 89,
"price": 8500,
"finished": false,
"running": true,
"quantity": 50,
"priority": 5,
"discount": 15,
"criteria": "percentage",
"excludeDepartments": [
"1"
],
"includeDepartments": [
"0"
],
"dateStart": "2023-11-02",
"dateEnd": "2023-11-30",
"createdAt": "2023-11-16 14:48:38",
"updatedAt": "2023-11-16 14:53:22"
}
}

Delete a Product Discount

Use this endpoint to delete a specific product discount by sending the ID.

DELETE/api/icommerce/v3/product-discounts/{id}
{}
Response
{
"data": "Item deleted"
}

Product Discount Fields

NameDescription
product_idType:
Integer
Description:
This field represents the unique identifier associated with a product in the system.
product_option_idType:
Integer
Description:
This field represents the unique identification associated with a product option in the system.
product_option_value_idType:
Integer
Description:
This field represents the unique identification associated with a specific product option value in the system.
quantityType:
Integer
Description:
This field can be used to represent the quantity of products to which the discount will be applied.
quantity_soldType:
Integer
Description:
This field represents the quantity of products sold with a discount.
priorityType:
Integer
Description:
This field indicates the priority of the discount.
discountType:
Double (20,2)
Description:
This field stores a decimal numeric value with a total precision of 20 digits, of which 2 are reserved for the decimal part. It can be used to represent discount values.
criteriaType:
Enum
Description:
This field specifies the criteria that can apply the discount.
Enums:
You can use these criteria:
percentage
fixed

date_startType:
Date
Description:
This field indicates the start date when the discount is valid.
date_endType:
Date
Description:
This field indicates the end date when the discount is no longer valid.
department_idType:
Integer
Description:
This field stores the unique identifier of the department associated with the product.
exclude_departmentsType:
Array
Description:
This list contains department identifiers that should be excluded from the discount.
include_departmentsType:
Array
Description:
This list contains department identifiers that should be included in the discount.

If you need further assistance or have any questions about how to fill out these fields, please don't hesitate to contact our support team.