wixdata query from Stores/Products

Hello,

i would like to make a query and let me show p.e. the price of the product in an existing text-field.
How i get “price” in a text-field?
Next question:
how i can connect the product to the “addToCartButton”?

wixData.query(“Stores/Products”)
.eq(“name”,“206”)
.find()
.then( (results) =>{
let price = results.formatedPrice;
})

Have a look at the price field in the collection as it is a number type and can be filtered, whilst the formatted price field can’t be filtered.

For add to cart, either simply add the button to your website and set it up for any product or use the code below and adjust it to suit your own site.

After creating a dynamic page and adding the Products dataset, you should add a button (a regular button), add an onClick event, get the product ID using the getCurrentItem function and use the addToCart function to add it to the cart. Here’s an example of what I’m referring:

export function addToCartBtn_click(event, $w) {
 const productId = $w('#dynamicDataset').getCurrentItem()._id;
    $w("#shoppingCartIcon1").addToCart(productId, 1, { choices: { Color: 'red' } });
}