I've created an online store using Flask and I am handling the management of the shopping cart using localStorage, so I have a bunch of JavaScript functions which manage the adding and deleting items from the shopping cart, updating the HTML values and innerTexts and saves the list of all items as JSON in localStorage['CART'] in the following pattern:
{
"data": [
{
"id": 7,
"name": "Item 1",
"gross_amount": 10.99,
"count": 1
},
{
"id": 6,
"name": "Item 2",
"gross_amount": 8.99,
"count": 2
}
]
}
Other than that, I'm working with WTForms and on submit I now would like to retrieve that object, send it to the back end on submit so I can convert them into python objects to process the order.
Is there a way similar to request.form.data with which I can retrieve the JSON object?
Side note: In case that's not possible, I would generally only need the IDs & Count because prices are then calculated querying the database again as otherwise users could manipulate prices fiddling with the localStorage data. Maybe there is an easier way to solve this and I may just not have the experience to see the forest for the trees.