When updating the customer money via the CustomerStatisticUpdater class, a customer money instance will be automatically created, if it does not currently exist for the specified customer and currency. If you need to manually create customer money for another scenario, see the example below. For more information about the CustomerStatisticUpdater class, see For developers: Update the customer money.
You will be creating customer money in the following cases:
To create customer money, you have to perform the following:
Here is a code example:
CreateCustomerMoney(Guid customerId, Guid orderId)
OrdersManager ordersManager = OrdersManager.GetManager();
Customer customer = ordersManager.GetCustomer(customerId);
//Customer does not exist.
Order order = ordersManager.GetOrder(orderId);
//Order does not exist.
CustomerMoney customerMoney = ordersManager.CreateCustomerMoney();
customerMoney.Currency = order.Currency;
customerMoney.CurrencyInfo = order.CurrencyInfo;
customerMoney.Total = order.Total;
customerMoney.LastModified = DateTime.Now;
customerMoney.Parent = customer;
Back To Top