About sn_sc.CartJS()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2024 06:42 PM
Hello All,
Regarding the method "var cart = new sn_sc.CartJS();", if it is used twice within a short period by the same user, the same cart is returned.
Is there a way to ensure a different cart is created each time it is used?
Thanks & Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2024 07:16 PM
@zhangyuchen When you use var cart = new sn_sc.CartJS();, it returns the user's current cart if one already exists. This behavior is by design, as ServiceNow treats the cart as a session-based object, where each user typically has one active cart.
Issue:
If you call new sn_sc.CartJS() multiple times within the same session (or in a short period), it refers to the same cart unless the cart is checked out or explicitly cleared.
Solution: Create a New Cart
to force the creation of a new cart each time, you need to manually clear the existing cart or work with a unique cart identifier.
Hope this will help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2024 01:17 AM
Thank you for your response!
How can i use a unique cart identifier?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2025 12:18 PM
var checkoutInfo = cart.checkoutCart();