In order to more effectively allow users to continue editing products across sessions the web widget provides support for a form of user accounts. By passing in a unique user ID corresponding to a user registered with your application, you can associate cart data with users and reload that data when initiating a new widget session for a particular user.{
  // associates the current widget session with a particular user
  uniqueUserId: "b89eaac7e61417341b710b727768294d0e6a277b"

When a uniqueUserId is passed in, each selection or change that user makes to a product is automatically saved to our secure accounts database. If the same user later initiates a widget session their cart data will be restored, including items that were unfinished (items are considered finished when a user adds them to the cart by clicking next on the edit screen). As long as you continue to initiate the widget with consistent, unique IDs associated with your unique users, they will receive a customized, stateful widget experience akin to them having an account in the widget directly.


Note that the uniqueUserId corresponds to a user registered with your application. We recommend hashing user IDs before passing them to the widget to ensure the privacy of your users. Additionally, unique user IDs must conform to the following regex /^[a-zA-Z0-9_-]{3,}$/ (alphanumeric, hyphen, and underscore characters; minimum length of 3).

Additional Functionality

Saving Indicator

User sessions initiated this way also show a saving indicator on the edit page, to provide visual confirmation to the user that their changes are being saved.


PIO getCart() and getNumItems()

PIO.getCart() and PIO.getNumItems() can be used to access information about a specific account when passed recipeId, uniqueUserId, and a callback, which is executed with the returned data. Ie: PIO.getCart(recipeId, uniqueUserId, callback).

PIO.getCart("6cfb4f30-34c7-4cf6-9490-f51925650811", "b89eaac7e61417341b710b727768294d0e6a277b", function(data) {console.log(data)})