to add cart functionality.

Product cards are created dynamically, so we don’t know their ids. Even if we assign them ids, then also how can i access particular product on which i click.

Suppose I want to add a product in the cart and i click on buy button ,so how can i get that clicked product id .