Coding an add to cart button in a repeater

Hello!
I would like to add an add to cart button to a repeater. That button would only add a single item to the cart and the user could continue browsing on my store page without having to go to the product’s dynamic page and come back.
So far, my repeater is all linked to fields in my collection except for the button itself.

I am completely new to the coding world…just starting to explore the possibilities. Thanks for your help!

Here is a sample of my web page’s add-to-cart code. Each $item addresses individual repeater containers and checks requested input count against inventory (I’m not proud of it, but it works).

export async function addToCart_click ( event ) {
$w ( “#plantRepeater” ). forEachItem (( $item , itemData , index ) => {
$item ( “#countNote” ). text = “” ; //Clear count error message if one left over
let c = $item ( “#inpCount” ). value ; //get requested plant count
if ( c != “0” && c != “” ) //If some inventory exists, continue
{
//The following checks for
let count = parseInt ( c , 10 ); //Convert plant count to integer
let inventory = parseInt ( $item ( ‘#plantCount’ ). text , 10 ); //Convert plant inventory
let price = parseInt ( $item ( ‘#price’ ). text , 10 ); //Convert plant cost
console . log ( "Price, count and inventory = " , price , count , inventory )
if ( count > inventory ) {
$item ( “#countNote” ). text = “Error - Count exceeds inventory” ;
$item ( “#inpCount” ). value = “” ;
return ;
}
$w ( “#submit” ). enable (); //Make the submit button visible
.
.
.

Hi Colin, thanks for your help. Here is what makes the whole thing a bit complicated I think:
My repeater is linked to a collection named “Partitions” and that collection contains a reference field to my store collection. How then could I code something to make a particular item, shown in the repeater, be added to the cart directly when the cart button is clicked?
I don’t know how to get the particular item’s id from the stores collection.

Names:
#cartbutton
#shoppingCartIcon
#dataset1
#repeater1