Vorbly Code | WIX CODE CURRENCY FORMATTING

Vorbly <Code>

CODING MADE EASY WITH VORBLY

WIX CODE CURRENCY FORMATTING

Need to format currency or pricing for your checkout? This tutorial will show you how to format currency and pricing using Wix Code. You can now customize your own checkout and shopping cart. We will provide you with the webpage elements and sample codes required to implement this feature.

THE DEMO

1/2

THE ELEMENTS

The Page

Text Element:

  • Price per item: #UnitPrice

  • Total Price (Unit Price X quantity): #TotalPrice

User Input: #quantity

​​

Button Element: #Calculate

THE CODE

Page Code

export function Calculate_click(event, $w) {

        let price = Number(($w('#UnitPrice').text).replace("$", "").replace(",", "").replace(".", ""));

        let selectedQuantity = Number($w('#quantity').value);

             $w('#TotalPrice').text = String ( "$" + parseFloat(String((selectedQuantity * price)/100)).toFixed(2).replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,"));

}

COMMENTS

I'm a paragraph. Click here to add your own text and edit me. It's easy.

WEB DESIGN & DEVELOPMENT SOLUTIONS

GET PROFESSIONAL HELP