Hi All,
I have Custom Shipping provider. This is in an common project in the solution.
The class for the Custom shipping provider goes like this
[ServiceConfiguration(ServiceType = typeof(IShippingPlugin))]
public class ISMShippingProvider : IShippingPlugin
{
private readonly IMarket _currentMarket;
private readonly IContentLoader _contentLoader;
private readonly ReferenceConverter _referenceConverter;
private readonly ISynchronizedObjectInstanceCache _objectInstanceCache;
private readonly IWarehouseRepository _warehouseRepository;
private IDictionary<string, string> _configData;
#region Countries
public ISMShippingProvider(IMarket currentMarket) :
this(currentMarket,
ServiceLocator.Current.GetInstance<IContentLoader>(),
ServiceLocator.Current.GetInstance<ReferenceConverter>(),
ServiceLocator.Current.GetInstance<ISynchronizedObjectInstanceCache>(),
ServiceLocator.Current.GetInstance<IWarehouseRepository>())
{
}
public ISMShippingProvider(IMarket currentMarket, IContentLoader contentLoader, ReferenceConverter referenceConverter, ISynchronizedObjectInstanceCache objectInstanceCache, IWarehouseRepository warehouseRepository)
{
_currentMarket = currentMarket;
_contentLoader = contentLoader;
_referenceConverter = referenceConverter;
_objectInstanceCache = objectInstanceCache;
_warehouseRepository = warehouseRepository;
}
public ShippingRate GetRate(IMarket market, Guid shippingMethodId, IShipment shipment, ref string message)
{
if (shipment == null || !shipment.LineItems.Any())
{
return null;
}
var weight = GetWeight(shipment);
var isShippable = weight > 0;
if (shipment.ShippingAddress == null && isShippable)
{
return null;
}
var warehouse = _warehouseRepository.List().FirstOrDefault();
if (warehouse == null && isShippable)
{
return null;
}
string wareHouseCountry = warehouse?.ContactInformation.CountryCode;
string wareHouseZip = warehouse?.ContactInformation.PostalCode;
ShippingRate
shippingRate = null;
........
.....
}
}
Now when i try to save the order by saving shipping method Id in checkout service page
var shipment = cart.GetFirstShipment();
shipment.ShippingMethodId = method.ShippingMethodId;
_orderRepository.Save(cart);
I Get the error of Structure map : 'No default Instance is registered and cannot be automatically determined for type 'Mediachase.Commerce.IMarket''
Can anybody help please?
//ashish