Velo Tutorial: Cross-Selling a Product in Your Store with Velo by Wix
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.
Overview
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.
![](https://d2x3xhvgiqkx42.cloudfront.net/12345678-1234-1234-1234-1234567890ab/ef9147e1-f2d9-4773-9a14-7bc889c76065/2020/08/20/c63c8566-3780-4ed5-a81b-2fded1991354/44e5f46e-92f4-4160-a71b-9a7afcac2698.png)
How to Build This Promotion
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.
Part I - Setting up the Cart Page
Step 1: Start Working with Velo
-
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.
Step 2: Adding Elements
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.
Part II - Customizing the Cart Page with Code
Now that you've set up your Cart page you can add the code to cross-sell your product.
Step 3: Element IDs in the Properties Panel
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.
![](https://d2x3xhvgiqkx42.cloudfront.net/12345678-1234-1234-1234-1234567890ab/ef9147e1-f2d9-4773-9a14-7bc889c76065/2020/10/26/d026b884-b2ad-4631-9fc5-931806c7b2d8/ecc3b29b-b27c-4003-a24c-f8b152d09566.png)
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:
- Container box: crossSellBox
- First text element: productName
- Second text element: productPrice
- Third text element: productDescription
- The image: productImage
- The button: addToCart
Step 4: Product SKU
- Navigate to the product section of your store dashboard.
- Choose the product you plan to promote.
- Note the product's SKU (stock keeping unit). This number is very useful for keeping track of inventory. You will need to assign SKUs to your products. Learn more about Adding and Customizing Product Options.
Step 5: Cart Page Code Editor
- Go back to the Cart page in the Editor.
- In the Editor, paste the following code into the code editor for the Cart Page.
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.
1
Understanding the Code
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.
Step 6: Backend Code
- Click the Code Files button in the Code sidebar, then hover over Backend, click the plus icon, and select Add Web Module.
- Name this module cart.web.js.
- Delete the provided sample code and paste the following code into the Web Module.
1
Understanding the Code
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.
Step 7: Save and Publish your Site.
- In the top right corner of the Editor, save and preview to check your progress.
- To see the live version of the site, click Publish.
![](https://d2x3xhvgiqkx42.cloudfront.net/12345678-1234-1234-1234-1234567890ab/ef9147e1-f2d9-4773-9a14-7bc889c76065/2020/10/26/b872a5a2-1247-42ec-bc36-afbbba3a9ea7/4161c25f-e394-4eef-b8fd-3fd57e39cadf.png)