May 2018
Intermediate to advanced
334 pages
7h 25m
English
Populating the OrdersProducts array is the next step, and this can be done by looping through the cart table's rows and pushing each cart row's details to the array. Inside the loop, read all the necessary values from the row, either from its attribute or td. Remember to form an object and assign the values to field names that match the model class, as follows:
// 2. Push cart items into order object as an array.$('#tblCart tbody tr').each(function () { order.OrdersProducts.push( { Productid: $(this).attr('data-product-id'), Productname: $(this).find('td.name').html(), Productprice: $(this).attr('data-price'), Finalprice: $(this).find('td.price').html().replace('$', ''), Productqty: $(this).find('td.qty').html() ...