Store Framework
Displaying asynchronous prices

Although useful to enhance user experience, displaying the most up-to-date prices comes at the heavy cost of increasing your store's page response time.

This is due to the fact that fetching the newest prices in your store database relies on making a new request to the server every time a product is rendered on the interface.

A favorable way out is to set your store to fetch product prices on the client-side, promoting a decrease of response time in your pages in order to display the asynchronous prices.

Asynchronous prices do not mean outdated. They are product prices stored in the browser cache according to the user navigation. If your store does not routinely update product prices, it is strongly recommended to display asynchronous prices instead.

{"base64":"  ","img":{"width":250,"height":511,"type":"gif","mime":"image/gif","wUnits":"px","hUnits":"px","length":36523,"url":""}}

Learn below how to set your store up to decrease page response time with asynchronous prices!

Step by step

  1. Ensure that your store is not fetching the price data on the server-side by setting the simulationBehavior prop (from the Search Result app) to skip:
"": { "blocks": [ "search-result-layout" ], "props": { "context": { + "simulationBehavior": "skip" } } },
  1. Ensure that the Product Summary and the Product Price apps are listed as dependencies in your theme's manifest.json file:
"dependencies": { "vtex.product-summary": "2.x", "vtex.product-price": "1.x" }
  1. Add the priceBehavior prop to your product-summary.shelf block and set its value to async:
"product-summary.shelf": { "props": { + "priceBehavior": "async" }, "children": [ // other children "product-list-price#summary", "flex-layout.row#selling-price-savings", "product-installments#summary", "add-to-cart-button", ] }
  1. Wrap the all price blocks under the product-price-suspense block (from the Product Prices app):
{ "product-summary.shelf": { "props": { "priceBehavior": "async" }, "children": [ // other children - "product-list-price#summary", - "flex-layout.row#selling-price-savings", - "product-installments#summary", - "add-to-cart-button", + "product-price-suspense" ] }, + "product-price-suspense": { + "children": [ + "product-list-price#summary", + "flex-layout.row#selling-price-savings", + "product-installments#summary", + "add-to-cart-button" + ] + } }
Photo of the contributor
Photo of the contributor
+ 2 contributors
Was this helpful?
Suggest edits (Github)
Photo of the contributor
Photo of the contributor
+ 2 contributors
On this page