_setLastVisited
How to Use _setLastVisited
Method
_setLastVisited
method stores information about the last visited products in the browser's local storage. This feature allows you to track user activity by recording the product and variant IDs that a user has viewed. It can be useful for implementing features like "Recently Viewed Products."Usage Steps:
1.
ProductId
and VariantId
:ProductId
: The unique identifier of the product that was viewed.VariantId
: The unique identifier of the product variant that was viewed.2.
ProductId
and VariantId
, it will store this information in local storage under the key "visitedProducts"
.Example:
productId
is "12345"
and the variantId
is "67890"
. Replace these with the actual IDs of the product and variant that the user has visited.Common Use Cases:
1.
2.
3.
Notes:
"visitedProducts"
. It ensures that no more than 16 entries are stored at any time.