Selling Items in an Experience

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 Store Listing 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 Scripts. Scene Script Library is included by default.

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


Configuring Store Listing

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

  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 Store Listing.

  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.



Next, you must configure another script to trigger this Store Listing 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 Store Listing. To configure Interaction:

  1. Drag a copy of the Scene Script Library from your inventory into the same object where you configured Store Listing.

  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 Store Listing script.

  6. Leave all other fields with their default values.



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 Store Listing script, which opens a Sansar Store panel allowing the visitor to immediately buy the listed item.

Last updated