The Region feature is one of the features made available by the session system installation. It aims to regionalize user experience of the store. It allows, for example, for sellers to set their own prices and that the marketplaces display them according to the client’s region.
After you set up delivery of a SKU to a White Label Seller from your store, it is necessary for the session system to identify the zip code and country of the user browsing the store to show the custom price and availability by region.
This information about ZIP code and country can be stored in the cookie vtex_session, due to a purchase made previously by the user, or can be entered via JavaScript in the session.
To enter the country and zip code in the session, you must perform a POST
in the following route:
{{account-name}}.{{environment}}.com.br/api/sessions
Below are examples of bodies to be sent to POST
:
- Update session by postal code.
_10{_10 "public": {_10 "country": {_10 "value": "USA"_10 },_10 "postalCode": {_10 "value": "32004"_10 }_10 }_10}
- Update session by geo-coordinates.
_10{_10 "public": {_10 "country": {_10 "value": "USA"_10 },_10 "geoCoordinates": {_10 "value": "22.123,-14.1"_10 }_10 }_10}
- Update session by address.
_10{_10 "public": {_10 "storeUserEmail": {_10 "value": "<mailto:example@example.complexample.com>"_10 },_10 "addressId": {_10 "value": "123456789"_10 }_10 }_10}
To verify that the session has updated the country and zip code data, send a GET
request on the route below and search for the country
and postalCode
fields:
{{account-name}}.{{environment}}.com.br/api/sessions?items={{namespace}}.{{value}},{{namespace}}.{{value2}}
After refreshing the product page, the platform will update price and availability information according to the region specified in the country and zip code information.