如何在客户设置中添加新的设置值 [英] How to Add New Setting Value in Customer settings

查看:52
本文介绍了如何在客户设置中添加新的设置值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在安装 nopcommerce 2.5 后在客户设置页面(/Admin/Setting/CustomerUser)中添加新的设置值.我该怎么做?我有 nopcommerce 2.5 源代码.我正在寻找自定义客户设置页面的方法添加新的观看价值.

I want to add new setting value in Customer settings Page(/Admin/Setting/CustomerUser) after installed nopcommerce 2.5.How can I do?I got nopcommerce 2.5 source code.I'm finding the ways to customize Customer settings Page to add new seeting value.

推荐答案

您需要在 CustomerSettingsModel 中添加新属性,例如

you need to add new property in CustomerSettingsModel e.g

//Nop.Admin/Models/Setting/

public bool ZipCodeEnbale{get;set}

然后在 CustomerUser.cshtml 中为其添加控件

then add control for it in CustomerUser.cshtml

//Nop.Admin/Views/Setting/

<tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.CustomerSettings.ZipCodeEnbale):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.CustomerSettings.ZipCodeEnbale)
                @Html.ValidationMessageFor(model => model.CustomerSettings.ZipCodeEnbale)
            </td>
        </tr>

运行应用程序后,您将看到新属性将添加到 CustomerSeeting 标签中的管理员/客户设置页面下.

after run the application you will see new property will add under Admin/Customer setting page in CustomerSeeting tab.

注意:如果您在安装 nopcommerec 时将默认值设置为属性,那么您需要在 (Nop.Service) 中的 InstallationService.cs 中进行一些额外的更改在安装设置方法下的 CustomerSettings 中添加新的属性值.例如

Note: if you ant to set default value to property while installing nopcommerec then you need to some additional chnages in InstallationService.cs in (Nop.Service) add new property value in CustomerSettings under InstallSettings method. e.g

EngineContext.Current.Resolve<IConfigurationProvider<CustomerSettings>>()
                .SaveSettings(new CustomerSettings()
                {
                    ZipCodeEnbale= true,
                }

这篇关于如何在客户设置中添加新的设置值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆