Documentation

Ucommerce includes full API reference documentation and lots of helpful articles to help you build your e-commerce site as effortlessly as possible.

Topics Payment Providers
v7.18

Migrating IClientContext

The IClientContext interface was removed as part of removing the XSLT namespace. If you were using this, migrating it requires a few different components as this was not really ported 1-1 in V9.

The following methods shows how to port each method call on the IClientContext to a V9 equivalent.

CurrentProductCatalogGroup

    
    
        clientContext.CurrentProductCatalogGroup
    
    

changes to:

    
    Ucommerce.Search.Models.ProductCatalogGroup store = Ucommerce.Infrastructure.ObjectFactory.Instance.Resolve<Ucommerce.Api.ICatalogContext>().CurrentCatalogGroup;
    
    

GetBasket

    
    
        clientContext.GetBasket(create);
    
    

changes to:

    Ucommerce.EntitiesV2.PurchaseOrder basket = Ucommerce.Infrastructure.ObjectFactory.Instance.Resolve<Ucommerce.Api.ITransactionLibrary>().GetBasket(false);
    
    

IsLoggedIn

    
    
                clientContext.IsLoggedIn
        
    

changes to:

    Ucommerce.EntitiesV2.PurchaseOrder basket = Ucommerce.Infrastructure.ObjectFactory.Instance.Resolve<Ucommerce.Api.ITransactionLibrary>().GetBasket(false);
    
    

CurrentMemberId

    
    
                CurrentMemberId
                
    

changes to:

    string memberId = Ucommerce.Infrastructure.ObjectFactory.Instance.Resolve<Ucommerce.Security.IMemberService>().GetCurrentMember()?.MemberId;
    
    

CurrentMemberName

    
    
                clientContext.CurrentMemberName
        
    

changes to:

    string memberName = Ucommerce.Infrastructure.ObjectFactory.Instance.Resolve<Ucommerce.Security.IMemberService>().GetCurrentMember()?.LoginName;
    
    

IpAddress

    
    
        		clientContext.IpAddress
        
    

changes to:

    string ip = System.Web.HttpContext.Current.Request.UserHostAddress;
    
    

TryGetCustomer

To get the current customer which was previously associated with the IClientContext interface, this has no equivalent in V9.

    
    
        		clientContext.TryGetCustomer()
        		
    

Instead you can try and grab the Customer associated with the member logged in, or the Customer associated with the basket.

    var customerFromLogin = ObjectFactory.Instance.Resolve<IRepository<Customer>>().Select(x => x.MemberId == memberId);
    
    var customerFromBasket = ObjectFactory.Instance.Resolve<IOrderContext>().GetBasket(true).PurchaseOrder.Customer;