Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue in getcartcontent - Object's Key/Value #349

Open
cheema14 opened this issue Nov 7, 2022 · 0 comments
Open

issue in getcartcontent - Object's Key/Value #349

cheema14 opened this issue Nov 7, 2022 · 0 comments

Comments

@cheema14
Copy link

cheema14 commented Nov 7, 2022

When I call cart's getcontent method it returns a json response to me. which is okay.
But the problem is below:
{
"data": {
"1667847103": {
"id": 1667847103,
"name": "Second Service",
"price": 50,
"quantity": 1,
"attributes": {
"id": 2,
"booking_id": "2",
"service_from": "01:00",
"service_to": "01:10",
"booking_day": "Monday",
"item_type": "services",
"variant": null,
"extras": [],
"restorant_id": 30,
"image": "/uploads/service_items/e479b758-e38d-4fa3-b0c4-35571caa439a_thumbnail.jpg",
"friendly_price": "€50.00"
},
"conditions": []
},
"cart_items": {
"id": 1667851688,
"name": "new dimensions",
"price": 100,
"quantity": 1,
"attributes": {
"id": 7,
"booking_id": "34",
"service_from": "09:00",
"service_to": "09:30",
"booking_day": "Invalid Date",
"item_type": "services",
"variant": null,
"extras": [],
"restorant_id": 30,
"image": "/uploads/service_items/cbe92aff-586f-447a-a2cc-baa5f95c22c5_thumbnail.jpg",
"friendly_price": "€100.00"
},
"conditions": []
}
},
"total": 450,
"quantity": 6,
"status": true,
"errMsg": ""
}

There is a key which is actually id:1667847103 and then there is a key which I made "cart_items". As you know that in JS you cannot do anyObj.1667847103, so I added a key "cart_items" so that I would be able to do anyObj.cart_items.blah .blah

Whenever I add cart_items in the Cart's addRow method, it only adds the last item being added to the cart.
but when I Revert the code it works fine.

Can somebody help me with that real quick? I am stuck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant