I have a more generic issue where the Product revenue(sum of products*qty) in GA is higher than the order revenue(subtotal+shipping+tax).Upon digging in found that order level discounts are not being applied to product revenue
s.no item unitprice qty total
1 xx 50 4 200
2 xy 6 2 12
order-level discount: 25
Solved! Go to Solution.
Depending on how you actually want to go about doing this, you can override the values set by the E-Commerce Extension. So options include:
So the issue you have with JS is decimal places. As soon as you start dividing by odd numbers you'll get numbers like 9.659999999999998 which will then cause discrepancies further down.
If you wanted to apply to the product prices I would first set up a variable with the amount of discount to apply to each item:
var discountToApply = Math.trunc(discount / product_prices.length) ;
var remainingDiscout = discount - (discountToApply * product_prices.length)
Then a for loop that would minus that amount from each product. After the loop, you will need to subtract the remaining discount from one of the product prices.
This will give you the discount unit price for each item.