Customizing customer preferences

In Xperience, you can modify how the system decides which currency, payment method and shipping option are preferred for a registered customer. The customer’s preferred currency, payment method and shipping option are pre-filled when the customer goes through the checkout process.

By default, the preferred currency, payment method and shipping option are chosen based on the customer’s last order.

To customize how the system chooses the preferred currency, payment method and shipping option:

  1. Prepare an assembly (Class Library project) with class discovery enabled in your Xperience solution (or use an existing one). See Adding custom assemblies

    • Reference the project from both your live site and Xperience administration (CMSApp) projects.
  2. Create a new class that implements the ICustomerPreferencesProvider interface (found in the CMS.Ecommerce namespace).

  3. Define the GetPreferences method.

    • The method must return an object of the CustomerPreferences class, which contains the CurrencyID, PaymentOptionID and ShippingOptionID properties (all nullable integers). Assign null values to the properties that you do not want to set.
  4. Register your ICustomerPreferencesProvider implementation using the RegisterImplementation assembly attribute.

    
    
    
     using CMS;
     using CMS.Ecommerce;
    
     [assembly: RegisterImplementation(typeof(ICustomerPreferencesProvider), typeof(CustomCustomerPreferencesProvider))]
    
     public class CustomCustomerPreferencesProvider : ICustomerPreferencesProvider
     {
         public CustomerPreferences GetPreferences(CustomerInfo customer, SiteInfoIdentifier site)
         {
             ...
         }
     }
    
    
     
  5. Save and Rebuild your project.

If you open your website, the system uses the registered ICustomerPreferencesProvider implementation. Registered customers now have their currency, payment method and shipping option pre-filled based on your custom logic.