Create customer money

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:

  • When there are not any CustomerMoney records created for the customer, i.e. the customer has not any registered orders yet.
  • When there is no CustomerMoney record for the currency of the current order.

To create customer money, you have to perform the following:

  1. Get the orders managers:
    Get an instance of the OrdersManager object.
  2. Get the customer.
    Get the specified customer. For more information, see For developers: Query customers.
  3. Get the order.
    Get the specified order. For more information, see For developers: Query orders.
  4. Create new customer money.
    Create a new instance of the CustomerMoney class by calling the CreateCustomerMoney method of the orders manager.
  5. Specify the details of the customer money.
    Set the properties of the CustomerMoney instance.
  6. Associate the customer with the customer money.
    To associate the customer with the customer money, set the Parent property of the CustomerMoney instance to the instance of the customer, and add the customer money to the CustomerMoney collection property of the Customer instance.
  7. Save the changes.
    Save the changes to the manager.

Use the following code sample:

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?