Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8347991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:33:12+00:00 2026-06-09T07:33:12+00:00

Afternoon, I have an array retreived via an AJAX call. It brings back the

  • 0

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"
    }
 ]
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:33:13+00:00Added an answer on June 9, 2026 at 7:33 am
    if (result.constructor != Array) {
        result = [result];
    }
    
    var subTotal = 0, orderTotal = 0;
    for (var i = result.length - 1; i >= 0; i--) {
        var tmp = parseFloat(result[i].productPrice) * result[i].itemQty;
        orderTotal += (parseFloat(result[i].productShipping) + tmp);
        subTotal += tmp;
    }
    
    $('#ordSubTotal').text("£" + subTotal.toFixed(2));
    $('#ordTotal').text("£" + orderTotal.toFixed(2));
    

    Maybe it helps for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Afternoon all I have a lovely webservice call that brings back a list, we'll
Afternoon all. I have the following scenario: I have a search page where by
Good afternoon. I have an array with some keys, and values in them. I
I have been stuck on this all afternoon, and even tried the following search:
I have spent the afternoon trying to wrap my mind around how to translate
I have searched all morning and yesterday afternoon and still cannot find an solution
I have been struggling all afternoon trying to get a simple mailto: tag to
I have been trying all afternoon to get the jQuery Sifr Plugin ( http://jquery.thewikies.com/sifr/
Afternoon All, I have a web form that i wish my user to fill
Afternoon all. I have a drop down list in my view <div class=editor-label> @Html.LabelFor(model

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.