Product Discount
Use the REST API to interact with the product discount in the application.
You should take into account when making your request
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?
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.
Create a Product Discount
Use this endpoint to create a product discount.
- Rest
{
"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
}
}
- Rest
{
"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:
Include | Description |
---|---|
department | Fetches the departments associated with the product discount. |
Query Parameters:
- Rest
{
"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.
- Rest
{}
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.
- Rest
{}
Response
{
"data": "Item deleted"
}
Product Discount Fields
Name | Description | ||
---|---|---|---|
product_id | Type: Integer Description: This field represents the unique identifier associated with a product in the system. | ||
product_option_id | Type: Integer Description: This field represents the unique identification associated with a product option in the system. | ||
product_option_value_id | Type: Integer Description: This field represents the unique identification associated with a specific product option value in the system. | ||
quantity | Type: Integer Description: This field can be used to represent the quantity of products to which the discount will be applied. | ||
quantity_sold | Type: Integer Description: This field represents the quantity of products sold with a discount. | ||
priority | Type: Integer Description: This field indicates the priority of the discount. | ||
discount | Type: 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. | ||
criteria | Type: Enum Description: This field specifies the criteria that can apply the discount. Enums: You can use these criteria:
| ||
date_start | Type: Date Description: This field indicates the start date when the discount is valid. | ||
date_end | Type: Date Description: This field indicates the end date when the discount is no longer valid. | ||
department_id | Type: Integer Description: This field stores the unique identifier of the department associated with the product. | ||
exclude_departments | Type: Array Description: This list contains department identifiers that should be excluded from the discount. | ||
include_departments | Type: 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.