Selling items inside an experience

By using Sansar's official script libraries, you can allow visitors to make purchases from the Sansar Store while visiting your experience. By using this script feature, you can create an immersive shopping experience for your visitors.

This article covers one possible way to configure and trigger the StoreListing library script, but with creative use of the official script library many other configurations are possible.

Open a store listing by interacting with an object

In this example, we'll be adding scripts to an object that allow visitors to quickly purchase a specific item from the Sansar Store when they click the object. To accomplish this, we need two scripts: one to detect when the object has been clicked, and one to open the store listing once a click has been detected. Both of these scripts are part of the Scene Script Library, which appears in your Sansar inventory by default.

You will also need an object in your scene for visitors to interact with and launch the store interface. It should be sized and located in such a way that avatars may approach it within 3 meters and click with their mouse cursor.

Finding the Scene Script Library

While editing your scene, use the dropdown menus to filter your inventory for Purchased items, and ScriptsScene Script Library is included by default.

Alternatively, you may search your inventory for "Scene Script Library" in the Search by name field.

Scene_Script_Library.jpg
Find Scene Script Library in your purchased scripts. No purchase is necessary; it is included by default.

Configuring StoreListing

The StoreListing script opens a specific store listing in the Sansar client when it is triggered by another script. To configure StoreListing:

  1. Drag Scene Script Library from your inventory onto an object in your scene.
  2. Open the object's Properties panel by right-clicking it and choosing Properties.
  3. In the Properties panel, scroll down to the section marked "Scene Script Library".
  4. In the second dropdown menu under Script, select StoreListing.
  5. Take note of the field labeled -> Show Listing. The Interaction script will need to be configured using the value in this field. The value is "show" by default, but you may change it.
    Note: If you have multiple objects selling different items in your scene, the value for -> Show Listing must be different for each one.
  6. In the Product ID or URL field, enter the URL (from your web browser) or product ID of any listing in the Sansar Store. The listing does not need to be one that you created yourself.
  7. Leave all other fields with their default values.
StoreListing.jpg StoreListing_parameters.jpg
In the second dropdown menu under Scene Script Library, choose StoreListing. Enter the URL or product ID of a listing from the Sansar Store in the Product ID or URL field. Take note of the value in the -> Show Listing field for use in the next section.

Next, you must configure another script to trigger this StoreListing script. In this example, we'll be using the Interaction script to trigger when the object is clicked.

Configuring Interaction

The Interaction script makes an object "clickable" with a mouse or VR controller. When this interactive object is clicked, the script can then trigger other scripts, such as StoreListing. To configure Interaction:

  1. Drag a copy of the Scene Script Library from your inventory into the same object where you configured StoreListing.
  2. If it is not already open, open the object's Properties panel by right-clicking it and choosing Properties.
  3. In the Properties panel, scroll down to the second section marked "Scene Script Library". The second dropdown menu in this section should be set to Interaction by default.
  4. Enter an appropriate value for Interaction Prompt. This is the text that appears when a visitor hovers their mouse cursor over the object.
  5. In the On 1st Click -> field, copy the value you entered for -> Show Listing in the StoreListing script.
  6. Leave all other fields with their default values.
Interaction_parameters.jpg
In the second Scene Script Library, make sure the second dropdown menu is set to Interaction. Then, copy the value from -> Show Listing in StoreListing into the field for On 1st Click ->. This is how the two scripts will know to communicate with each other.

You have now successfully configured a pair of scripts from Sansar's official Scene Script Library. When a visitor approaches within 3 meters of your scripted object, they can click it to trigger the Interaction script. Interaction sends the message "show" to the StoreListing script, which opens a Sansar Store panel allowing the visitor to immediately buy the listed item.

Click_Me.jpg Store_listing.jpg
When a visitor approaches the object, the Interaction Prompt appears when they hover their mouse over it. If they click, they are given the option to immediately buy the item listed in the StoreListing's Product ID or URL field. When a visitor clicks the interactive object a limited Sansar Store panel appears, allowing them to immediately purchase the item designated by the StoreListing script.
Was this article helpful?
5 out of 6 found this helpful
Have more questions? Submit a request

0 Comments

Article is closed for comments.