Hi
I am very new to coding but I believe it’s possible to use Velo to display an Including VAT price on a product page.
What I would like to do is add a text box that looks at the price of the product and displays that value plus 20%.
Does anyone know how to code this?
I’ve tried various different examples from searching the internet but nothing seems quite right.
I would really appreciate any help!
Because I am new to coding I don’t really understand how the examples work - therefore I don’t really understand what I am doing wrong when I change things to match my labels.
I have a text box on my page that’s labelled ExVATPrice and I would like that box to display the product price.
Then I have another text box labelled IncVATPrice that I would like to look at the ExVATPrice box and display the value plus 20%.
I am fairly sure I can manage the code for the latter part, but I don’t know how to get the first text box to find the product price in the first place.
All help gatefully received,
Thank you
Cat
For info I started here https://www.wix.com/velo/example/low-in-stock-notification and attempted to modify the code, as it’s a similar idea - but I just got stuck!
Hi there,
Use the getProduct( ) method to get the product object, access its price, then increase it by %20.
const product = await $w('#productPage').getProduct();
// Show the new price incl. vat
$w('#vatPrice').text = `$${(product.price / 0.2) + product.price}`;
Hope this helps~!
Ahmad
I am going to try that, thanks so much.
I’ve got this code to work for me:
$w . onReady ( function () { getProduct ();
})
async function getProduct () {
let product = await $w ( ‘#productPage’ ). getProduct ();
$w ( ‘#ExVATPrice’ ). text = $ {( product . price ) .toFixed(2) };
$w ( ‘#IncVATPrice’ ). text = $ {( product . price * 1.2 ) .toFixed(2) };
}
Cat
Hello everybody ! We used Cat’s code and it works great, very simple to integrate in your project. Would anyone know how to combine it with product options ? When added, the total price is unfortunately not updated / refresh when activating colours or list options ? Thanks very much
WOW someone beat wix to it, just been offered this app on their market for this exact reason, It is crazy that it is actually possible but wix cannot ad this and asks its customers that pay already for a website to pay an extra per month to have this “basic” function!
I have not tested it myself but appears to work well on demo site etc!
Would be great to have this exact feature available through wix!