Menu
Feedback
Start here
Tutorials


VTEX Modules: Getting Started
Prices
8. Adding a price rule
Adding a price rule

There are two of adding a price rule:

  • through the Admin
  • by API REST

Follow the steps below to add a price rule to your store:

Admin

  1. In the VTEX Admin, go to Prices > Price rules, or type Price rules in the search bar at the top of the page.
  2. Click on the green New Rule button.
  3. In the first step, What is the general data of this rule?, select a trade policy from the dropdown menu.
  4. In the second step, What items will this rule apply to?, choose whether the rule will apply to all products or only to chosen categories and brands. If you select the second option, you should also choose the Categories and/or desired Brands.
  5. In the third step, Apply rule to items within a markup range?, switch the toggle to yes to make use of the markup range. Type in the markup's minimum percentage in the From field and its max percentage in the up to field to select items within this range.
  6. In the next step, Select timeframe to apply this rule in?, switching the toggle to yes will allow you to use this criteria. Choose the Start Date, Start Hour, End Date and the End Hour to define the period in which this rule will be applied.
  7. In the final step, What will the price change for this rule be?, set the price percentage modifier. The price rule will apply this modifier to the selected SKUs.
  8. Click on Save
  9. A sidebar to confirm the new rule will appear. Click on Confirm.

API REST

Authentications for Prices module's API REST calls should be done using AppKey and AppToken. For more info, read our article on how to generate an AppKey and AppToken to authenticate integrations

To add a price rule, you need to send a POST to the following endpoint:

https://api.vtex.com/{{accountName}}/pricing/pipeline/catalog

  • The request object has the following properties:
PropertiesTypesDescription
tradePolicyIdstringID of the price table in which the rule will be applied
rulesarrayPrice rule criteria
idintegerPrice rule ID. You can add more than one rule to the same price table.
contextobjectObject containing the price rule properties
categoriesobjectCategory to which to rule applies
brandsobjectBrand to which the rule applies
markupRangeobjectRules applied to items in a markup range
fromintegerMinimum markup range value
tointegerMaximum markup range value
dateRangeobjectRule's date and time range
fromstringStart date and time
tostringEnd date and time
percentualModifierintegerPrice variation for this rule
  • The response object has the following properties:
PropertiesTypesDescription
tradePolicyIdstringID of the price table in which the rule will be applied
rulesarrayPrice rule's object array to be applied to the price table
idintegerPrice rule ID. You can add more than one rule to the same price table.
contextobjectObject containing the price rule properties
categoriesobjectCategory to which to rule applies
brandsobjectBrand to which the rule applies
markupRangeobjectRules applied to items in a markup range
fromintegerMinimum markup range value
tointegerMaximum markup range value
dateRangeobjectRule's date and time range
fromstringStart date and time
tostringEnd date and time
percentualModifierintegerPrice variation for this rule
  • Below, we have an example of a Header and Body to be used in the request

Headers

HeaderValue
Acceptapplication/vnd.vtex.pricing.v3+json
Content-Typeapplication/json
X-VTEX-API-AppKey{{X-VTEX-API-AppKey}}
X-VTEX-API-AppToken{{X-VTEX-API-AppToken}}

Body


{
"tradePolicyId": "1",
"rules": [
{
"id": 0,
"context": {
"categories": {
"8": "categoryName"
},
"brands": {
"2000003": "brandName"
},
"markupRange": {
"from": 20,
"to": 50
},
"dateRange": {
"from": "2019-07-09T15:00:00.000Z",
"to": "2019-07-12T15:00:00.000Z"
}
},
"percentualModifier": 10
}
]
}

If the array is sent blank, previously added rules will be deleted

Contributors
3
Photo of the contributor
Photo of the contributor
Photo of the contributor
+ 3 contributors
Was this helpful?
Yes
No
Suggest Edits (GitHub)
7. Price rule - Concept definition
« Previous
9. Fixed Price - Concept Definition
Next »
Contributors
3
Photo of the contributor
Photo of the contributor
Photo of the contributor
+ 3 contributors
On this page
Still got questions?
Ask the community
Find solutions and share ideas in the VTEX community.
Join our community
Request support from VTEX
For personalized assistance, contact our experts.
Open a support ticket
GithubDeveloper portalCommunityFeedback