Afternoon,
I have an array retreived via an AJAX call. It brings back the following results, sometimes with multiple items
itemQty: 1
productBrand: "Brand"
productPrice: "6.25"
productShipping: "0.35"
productSku: "sku"
productTitle: "ProdTitle"
OrderId: 123
Below is my jQuery code to sort and add the items together to make the sub total, shipping, then grand total.
var ordRes = result;
var subTotal = (ordRes.productPrice * parseInt(ordRes.itemQty)).toFixed(2);
var orderTotal = (parseFloat(ordRes.productShipping) + parseFloat(subTotal)).toFixed(2);
$('#ordSubTotal').text("£" + subTotal);
$('#ordShipping').text("£" + ordRes.productShipping);
$('#ordTotal').text("£" + orderTotal);
however when i bring back multiple items i am unable to add them together in subTotal, and orderTotal. can someone please shed some light on this for me?
* Returned JSON *
{
"d": [
{
"__type": "ABO.GetOrdersDetails",
"tweOrderId": 123,
"productSku": "sku",
"productTitle": "ProdTitle",
"productBrand": "Brand",
"itemQty": 1,
"productPrice": "6.25",
"productShipping": "0.35"
},
{
"__type": "ABO.GetOrdersDetails",
"tweOrderId": 123,
"productSku": "sku",
"productTitle": "ProdTitle",
"productBrand": "Brand",
"itemQty": 2,
"productPrice": "82.58",
"productShipping": "4.60"
}
]
}
Maybe it helps for you.