I would really appreciate some help here. My JSON knowledge is limited, and I can't solve it.
I need to delete an item from a shopping cart quick view that I create via JSON. The front end seems to work, but it doesn't because it doesn't remove the item from the JSON object.
The JSON object looks like.
[
{
"id": 216687,
"productId": 9604505,
"catalogId": 306758,
"name": "xxxxxxxxx1",
"description": "",
"quantity": 1,
"totalPrice": "38,00",
"smallImage": "/images/products/large/xxxxx.jpg",
},
{
"id": 216687,
"productId": 9604503,
"catalogId": 306756,
"name": "xxxxxxxxx1",
"description": "",
"quantity": 1,
"totalPrice": "38,00",
"smallImage": "/images/products/large/xxxxx.jpg",
}
]
jQuery function:
//Deleting Items
$(document).on('click', '.shopping-cart .delete i', function(){
var $target = $(this).parent().parent();
var $positions = $('.shopping-cart .item');
$target.hide(300, function(){
$.when($target.remove()).then( function(){
if($positions.length === 1) {
$('.shopping-cart .items-list').remove();
$('.shopping-cart .title').text('Shopping cart is empty!');
}
});
});
});
I think that I am not deleting the item properly.