Note: This tutorial and its steps are based on a Wix Editor site. You can adapt the steps for a Wix Studio site by using the equivalent Wix Studio features.
In this tutorial, you'll learn how to use Velo to implement cross-selling in your store. Cross-selling means suggesting a product to your customers when they get to the checkout page. Cross-selling can increase cart value, overall revenue, and conversion rates while improving the shopping experience.
You can see a similar implementation of the functionality described in this tutorial on this site, but with a different code solution. In both this tutorial and the example site, the site promotes Jasmine soap only if customers have one of the other products in their cart, but not Jasmine.
In the first part of this tutorial, we are going to set up the Cart Page using standard Editor elements. Then we'll use Velo and code to customize the Cart.
Enable Velo Dev Mode in the Wix Editor to let you work with code. Click Dev Mode in your site's top bar and turn on Enable Developer Mode in the dropdown.
You will see the Code sidebar on the left-hand side of your screen, and the Properties & Events panel in the bottom-right corner of the Editor.
To get to the Cart page in your store, click the Page Code button in the Code sidebar on the left-hand side of the Editor, then Cart page.
Now we're going to add an element to hold the details of the product you want to promote: name, price, image, and description.
Click Add on the left side of the Editor, then Box, and then select Container Boxes.
Add a text element to the Container for the product name, another for the price, and one more for the description.
Add an image (choose one from your gallery).
Add a button and change its text to Add to cart.
Note: Make sure you see the Attach to Box message before dropping all your elements into the container box.
Customize the elements in the Editor to match your store's design.
Now that you've set up your Cart page you can add the code to cross-sell your product.
You need to start working with your site's elements in code. One of the first things to do is to give your elements meaningful IDs. That will make it easier to work with them in code. You change an element's ID in the Properties & Events Panel.
When you select an element, its properties are displayed in the Properties & Events Panel.
If you can't see the Properties & Events Panel, click Tools in your site's top bar and check the box next to Properties & Events Panel in the dropdown.
Select each element that you added to the container and change their IDs as described below:
Note: If you already have code in the Cart Page, take care to avoid clashes between the code you've written and the code provided below. Pay particular attention to the onReady function.
Line 1: Import the module you need to work with Wix Data.
Line 2: Import your backend code.
Line 4: This is where you will insert your product's SKU. If you'd like to promote a different product, replace only the number inside the double quotes with a different SKU.
For example, if your product's SKU is 213, replace line 4 with:
const CROSS_SELL_PRODUCT_SKU = "213";
Lines 6-13: When the page loads, call the other functions in the code to: check for your promoted product in the cart (lines 20-25); find the product in your products databse (lines 27-32); display the product information in the cross-sell box (lines 34-44).
Lines 14-15: If the buyer visiting your store has already added your promoted product to their cart, don't show the cross-sell box.
Lines 20-25: Check the currently displayed cart for the product you've decided to promote.
Lines 27-32: Find the promoted product in your products database and get its information.
Lines 34-44: Display the product name, price, image, and description in the elements inside the cross-sell box.
Line 1: Import the Permissions
enum and webMethod
from wix-web-module
.
Line 2: Import the module you need to work with Wix Stores.
Line 4-5: Export the getCurrentCart()
function for use on the front-end (line 2 of the cart page code). Learn more here.