How to get the gross sales from the Order API in PHP

I have tried using the Order API to get each lineitem gross sales, however, I am not able to accumulate all the lineitems gross sales instead it concatenate with one another when I used the array_sum function in PHP…

Below is the link of my code I have posted on stackoverflow

Since you’re doing it on the inside loop, all you’re doing is creating an array with 1 line item’s gross money, and then summing it (which is just the value), and then moving on. Presumably you would want to create the array outside of the inner foreach loop, and then add each line item’s gross amount to the array, and then after the loop sum up the array.

1 Like

Thanks for your help once again!