How to store data in PHP without database?
If you can't run a database service, you could use SQLite or store the data in JSON or XML files.
How to store shopping cart items in session PHP?
Use the key in the cart session variable:
In the loop use the ID as product reference: $pid = $item ['pid']; echo "<button type='submit' name='buy' value='$pid'>Buy</button> "; ... and increment the value by one if it is already in the cart ... Then decrement the value using the same approach for the delete button.