Refreshing content
How to refresh dynamically the content of your placements.
Can shoppers choose different variants of your products, changing the price of the product? You will need to use this feature.
If you have a product that can be purchased in different variants, you will need to refresh the content of your placements dynamically each time the shopper changes the variant.
Our placements offer a simple way to refresh the content of your placements: Simply update the relevant data attribute of the placement (data-purchase-amount
).
You can do it with this little snippet of JavaScript:
Remember to replace the newPurchaseAmount
with the actual value you want to set, in the same format as the one you set in the placement.
Our placements will automatically refresh the content of the placement when the data-purchase-amount
data attribute is updated.
If you are also using custom variables in your placements, you will need to update them and then trigger the refresh manually, using the refresh
function.
For example, let’s say you are using the category
variable in your placement, and you want to refresh the placement when the shopper changes the category:
Of course, if you have the id
of the specific placement you want to refresh, you can do it with a single line of JavaScript: