Using a Button to Add to Database Field

Hi all,

For my website, I have a dynamic page that loads different products depending on how the user interacts with the site and provides them with a user-submit form to complete their purchase.

I wanted to make it so that, when they click a button to open one of the product “pages” [they all slide out of the same page but take up the user’s full screen] either a specific section of the database would be check to allow me to see which product they ordered (boolean) or text would be submitted to the database.

I hope this makes sense and you all can help me find a solution. Let me know if anything needs clarification.

Thank you!

Hi,

what I would do, is I would create a separate collection for purchases. In the collection I would store relevant purchaser details (user id if site has login, name, address, …) and reference to the item being purchased.

So, it is like building a regular form in Wix Code, with a minor detail, that you need to fill the reference to the item with the item being viewed. That can be done by using onBeforeSave event handler and setFieldValue() function on a dataset to set the item reference.

Few articles that may help you to get started:
CMS: About Reference Fields in Database Collections | Help Center | Wix.com (has also links to other articles on reference fields)
wix-dataset - Velo API Reference - Wix.com - event handler to set (it can also be done from the editor in properties panel of the Dataset)
wix-dataset - Velo API Reference - Wix.com - can be used to set the reference field value

Let me know if you need further assistance!

Thank you! The “setFieldValue” worked perfectly for the form!