Recalculate Order Total

7 years ago
Is there any built-in process, a plug-in, or does someone have any experience with the recalculation of an order total when the quantities of the line items are modified. For example, an order comes in for:

Product A:
  Price: $10.00 excl tax and $10.90 incl tax
  Quantity 2,
  Total: $20.00 excl tax and $21.80 incl tax
Order Subtotal  (excl tax):  $20.00
Order Tax:                        $  1.80
Order Total (incl tax):         $21.80

The store is short one, and since the user is in a hurry he updates the quantity field and forgets to recalculate the totals. The resulting order is:

Product A:
  Price: $10.00 excl tax and $10.90 incl tax
  Quantity 1,
  Total: $20.00 excl tax and $21.80 incl tax
Order Subtotal  (excl tax):  $20.00
Order Tax:                        $  1.80
Order Total (incl tax):         $21.80

If the user doesn't remember to update the totals, sub-totals, and tax amounts, they will be charged the original amount even though they were shorted.

I'm hoping there's something that will allow the line item's totals to be automatically calculated, as well as the order's totals. Ideally for me, it would best if the page prompted the user to see if they wanted to re-calculate the order.

Product A:
  Price: $10.00 excl tax and $10.90 incl tax
  Quantity 1,
  Total: $10.00 excl tax and $10.90 incl tax
Order Subtotal  (excl tax):  $10.00
Order Tax:                        $  0.90
Order Total (incl tax):         $10.90


And the same goes when adding a new product to an existing order from the Administrative site. Adding a new product should pickup the existing price and add it to the order and update the totals.
7 years ago
https://www.nopcommerce.com/boards/t/16544/order-total-after-deleted-items.aspx
5 years ago
The upcoming version 3.80 will finally support it. It'll have 'ordersettings.autoupdateordertotalsoneditingorder' setting (disabled by default) indicating whether order totals should be automatically re-calculated
4 years ago
a.m. wrote:
The upcoming version 3.80 will finally support it. It'll have 'ordersettings.autoupdateordertotalsoneditingorder' setting (disabled by default) indicating whether order totals should be automatically re-calculated



What is the use of this feature ?, will this auto update
Text box named Order total , does it uses Jquery to update textbox value ? Because after setting Value to "True" , i cant see any changes in order totals. Should i restart the application ?
3 years ago
a.m. wrote:
The upcoming version 3.80 will finally support it. It'll have 'ordersettings.autoupdateordertotalsoneditingorder' setting (disabled by default) indicating whether order totals should be automatically re-calculated



Dear Androu

We are having a problem .
when a customer orders a product from my store, they can ring me to add or take away from the amount they have ordered.

i then go to my orders after they ring.  Edit Order Details and change the amount in here. when i click on the save button to save changes nothing seems to happen. this is a problem as-
1- my order is not updated
2- my website now will display the wrong amount of stock we have in store.

I have checked into http://admin-demo.nopcommerce.com/Admin/Order/Edit/1 but doesnt calculate work corectly.

please give us help.
1 year ago
Hi All,
Any updates on this?
why is that details line qty is updated only when   AutoUpdateOrderTotalsOnEditingOrder is false.  Should this be opposite i.e when it is True?

Also, to update the totals can we do this?
                if (!_orderSettings.AutoUpdateOrderTotalsOnEditingOrder)
                {
                    orderItem.UnitPriceInclTax = unitPriceInclTax;
                    orderItem.UnitPriceExclTax = unitPriceExclTax;
                    orderItem.Quantity = quantity;
                    orderItem.DiscountAmountInclTax = discountInclTax;
                    orderItem.DiscountAmountExclTax = discountExclTax;
                  orderItem.PriceInclTax = priceInclTax = unitPriceInclTax * quantity; //priceInclTax ;
                    orderItem.PriceExclTax = priceExclTax = unitPriceExclTax * quantity;// priceExclTax;

                    _orderService.UpdateOrderItem(orderItem);
                }


Sundar
4 months ago
I think this setting
_orderSettings.AutoUpdateOrderTotalsOnEditingOrder
is around the wrong set of order values

Code is currently
            
            if (quantity > 0)
            {
                var qtyDifference = orderItem.Quantity - quantity;

                if (!_orderSettings.AutoUpdateOrderTotalsOnEditingOrder)
                {
                    orderItem.UnitPriceInclTax = unitPriceInclTax;
                    orderItem.UnitPriceExclTax = unitPriceExclTax;
                    orderItem.Quantity = quantity;
                    orderItem.DiscountAmountInclTax = discountInclTax;
                    orderItem.DiscountAmountExclTax = discountExclTax;
                    orderItem.PriceInclTax = priceInclTax;
                    orderItem.PriceExclTax = priceExclTax;
                    await _orderService.UpdateOrderItemAsync(orderItem);
                }

                //adjust inventory
                await _productService.AdjustInventoryAsync(product, qtyDifference, orderItem.AttributesXml,
                    string.Format(await _localizationService.GetResourceAsync("Admin.StockQuantityHistory.Messages.EditOrder"), order.Id));
            }
            else
            {
                //adjust inventory
                await _productService.AdjustInventoryAsync(product, orderItem.Quantity, orderItem.AttributesXml,
                    string.Format(await _localizationService.GetResourceAsync("Admin.StockQuantityHistory.Messages.DeleteOrderItem"), order.Id));

                //delete item
                await _orderService.DeleteOrderItemAsync(orderItem);
            }

            //update order totals
            var updateOrderParameters = new UpdateOrderParameters(order, orderItem)
            {
                PriceInclTax = unitPriceInclTax,
                PriceExclTax = unitPriceExclTax,
                DiscountAmountInclTax = discountInclTax,
                DiscountAmountExclTax = discountExclTax,
                SubTotalInclTax = priceInclTax,
                SubTotalExclTax = priceExclTax,
                Quantity = quantity
            };
            await _orderProcessingService.UpdateOrderTotalsAsync(updateOrderParameters);


i would have thought you edit the Product totals and the values are updated and saved
Then
_orderSettings.AutoUpdateOrderTotalsOnEditingOrder
should deturmine if the order totals are updated as well

Also the Operator Message is misleading : "Check to automatically update order totals on editing an order in admin area. IMPORANT: currently this functionality is in BETA testing status."