Selling Items in an Experience
Last updated
Last updated
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.
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.
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.
The Store Listing script opens a specific store listing in the Sansar client when it is triggered by another script. To configure Store Listing:
Drag Scene Script Library from your inventory onto an object in your scene.
Open the object's Properties panel by right-clicking it and choosing Properties.
In the Properties panel, scroll down to the section marked "Scene Script Library".
In the second dropdown menu under Script, select Store Listing.
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.
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.
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.
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:
Drag a copy of the Scene Script Library from your inventory into the same object where you configured Store Listing.
If it is not already open, open the object's Properties panel by right-clicking it and choosing Properties.
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.
Enter an appropriate value for Interaction Prompt. This is the text that appears when a visitor hovers their mouse cursor over the object.
In the On 1st Click -> field, copy the value you entered for -> Show Listing in the Store Listing script.
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.