Multiple Numbers | WixCreate | Wix Code - Corvid
 

Wix Tutorial - Multiple Numbers with Wix Code Calculations

To configure a customized shopping cart, you have to calculate the total price by multiplying the quantity with the price per product. 

Elements:

User Input:

  • Quantity for product: #quantity   |   Add onChange event in the Properties Panel

​​
Text Elements:

  • Unit Price: #UnitPrice

  • Total Price: #TotalPrice

Wix Code:

export function quantity_change(event, $w) {
   let price = Number($w('#UnitPrice').text);
   let selectedQuantity = Number(event.target.value);
    $w('#TotalPrice').text = String(selectedQuantity * price);
}

Demo:

Product

Price ($)

Quantity

Total Price ($)

Turquoise socks with pink dots

$

5

$

5

Websites designed by WixCreate that use the above Wix Code:

Official Wix Expert & Wix Agency Partner

© 2020 by WIXCreate.com

I  All Rights Reserved  I  info@wixcreate.com  I  202-640-5440

facebook-2.gif