Shopping cart functionality with variable

There are many ways to do this.
this is one example (it’s with quantities but it’s the same principle)

Another simple way would be to have an array as variable to keep track of the products, and then use array functions to add/remove a product. Keep in mind that in this case you want to store a simple value like a string in the array.