jcrumble wrote:I have an instance with multiple different stores some of which have different locations. I have setup each location as a store and these stores share a catalog, but have different subdomains that direct the user to the proper store. I have a request to add the address and phone number to the top header for some stores (which those that do not want it on their site I intend to leave blank in the store configuration). Everything I am finding involves hard coding the address and phone in the html. How can I use the variables from the store configuration to display this information for each individual store rather than having to hard code it. Primarily I need the variable names, where to set them if they are not already set, and where to place the changes in the HTML.
Any assistance or direction anyone can provide would be greatly appreciated.
Thanks,
Jeff
You can take the benefit of setting service of nopcommerce. Go to http://yourstore/Admin/Setting/AllSettings and data accordingly and retrieve them by the name and storeid like
store1.address yourstore1addressvalue store1.
store2.address yourstore2addressvalue store2.
Then at view(.cshtml) can retrieve the address like bellow
var CurrentStore = EngineContext.Current.Resolve<IStoreContext>().CurrentStore;
var _settingService = EngineContext.Current.Resolve<ISettingService>();
var CurrentStoreAddress = _settingService.GetSetting("store1.address", CurrentStore.Id);
You need to add the namespace of the EngineContext,IStoreContext and ISettingService at top of the view like bellow
@using Nop.Core.Infrastructure
@using Nop.Core
@using Nop.Services.Configuration
So the full code should be like bellow to retrieve address of the specific store.
@using Nop.Core.Infrastructure
@using Nop.Core
@using Nop.Services.Configuration
@{
var CurrentStore = EngineContext.Current.Resolve<IStoreContext>().CurrentStore;
var _settingService = EngineContext.Current.Resolve<ISettingService>();
var CurrentStoreAddress = _settingService.GetSetting("store1.address", CurrentStore.Id);
}
<div>@CurrentStoreAddress.Value</div>