top of page
Upsell Products

Upsell Products

Promote products based on items in your cart

Intermediate.png

Intermediate

6K

Published:

July 29, 2020

Girl Enjoying her Drink

by

Anchor 1
Hire a Developer

Example Description

In this example we select a product we would like to promote (upsell) and display it on the cart page. The upsell product is displayed when site visitors have a product in their cart from the same Stores collection as the upsell product. Site visitors can add the upsell product to the cart directly from the cart page.

Example Code

Tab 1

.

Tab 2

.

Tab 3

.

This code solution can be complicated.

How We Built It

Page Elements

 

On the cart page we added the following elements:

  • A container box to display information about the upsell product

  • 3 text elements to display the product name, price, and description

  • An image to display the product image

  • An Add to Cart button

 

Code

 

In the backend cart.jsw module, we get information about the current site visitor’s shopping cart.

 

On the cart page, we do the following:

  1. Define a variable that contains information about the upsell product.

  2. Initially hide the upsell box.

  3. Use the backend function to get information about the current cart.

  4. Check whether the upsell product is currently in the cart by comparing the upsell product ID with each cart item product ID.

  5. If the upsell item is not in the cart, we get information about the upsell product from the Stores/Products collection and display the information in the upsell box.

  6. We set an event handler that runs if a site visitor clicks the Add to Cart button. It adds the upsell product to the cart with the upsell choices defined in the upsell variable, and hides the upsell box.

APIs We Used

Non-code example.

Non-code example.

Non-code example.

Non-code example.

Non-code example.

Related Articles

Hire a Developer

Velo solutions are powerful tools, but building them on your own can be challenging. Let an experienced Velo development shop build it for you, so you can keep working on your site or business.

Related Examples

Did this help?

Yes

|

No

Thanks for your feedback!

Add to Cart Gallery

Add to Cart Gallery

Let customers add products to their cart—right from your product gallery.

Intermediate.png

Advanced

Bulk Add to Cart

Bulk Add to Cart

Let customers add multiple items to their cart—all at once.

Intermediate.png

Advanced

Related Items

Related Items

Recommend products based on price, brand and more.

Intermediate.png

Intermediate

Anchor 2
bottom of page