As I construct a shopping cart, the display object
provides the available data to the shopper. On the other hand, the cart object
contains the representation of the items selected by the shopper. The main issue arises when someone wants to modify an item in the cart and adjust its size. Unfortunately, the sizes
are no longer accessible in the cart item because only one size has been chosen, eliminating the others.
// display object
{
"sizes": [
{
"price": 4.99,
"title": "s"
},
{
"price": 5.99,
"title": "m"
},
{
"price": 6.99,
"title": "l"
}
],
"desc": "here's our green hat",
"title": "green hat"
}
// cart object
{
"size":
{
"price": 4.99,
"title": "s"
},
"desc": "here's our green hat",
"title": "green hat"
}
One possible solution could be passing the entire display object
along with marking (using some method) which option has been selected. Alternatively, there might be another solution that I am overlooking. Any suggestions?