top of page
Anchor 1

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 ($)

Blue socks with pink dots

Turquoise socks with pink dots

$

5

$

5

Example Wix Code Multiple Numbers
bottom of page