博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
NopCommerce 增加 Customer Settings
阅读量:6257 次
发布时间:2019-06-22

本文共 3000 字,大约阅读时间需要 10 分钟。

预期:

仿照Customer 的 Phone number enabled 和 required

增加MemberType

 

相关步骤如下:

1.运行站点

Admin -> Settings -> All settings(advanced)

-> Add new record

仿照 customersettings.phone 新增

customersettings.membertypeenabled

customersettings.membertyperequired

        

2.运行站点

Admin -> Configuration -> Languages -> Edit

-> Add new record

仿照 CustomerUser.phone 新增

Admin.Configuration.Settings.CustomerUser.MemberTypeEnabled

Admin.Configuration.Settings.CustomerUser.MemberTypeRequired

        

3.Nop.Core\Domain\Customers\CustomerSettings.cs

仿照 PhoneEnabled 及 PhoneRequired 新增

/// <summary>

/// Gets or sets a value indicating whether 'Member Type' is enabled

/// </summary>

public bool MemberTypeEnabled { get; set; }

/// <summary>

/// Gets or sets a value indicating whether 'Member Type' is required

/// </summary>

public bool MemberTypeRequired { get; set; }

 

                  

4.Presentation\Nop.Web\Administration\Models\Settings\CustomerUserSettingsModel.cs

修改 CustomerSettingsModel

仿照 PhoneEnabled 及 PhoneRequired 新增

 

[NopResourceDisplayName("Admin.Configuration.Settings.CustomerUser.MemberTypeEnabled")]

public bool MemberTypeEnabled { get; set; }

 

[NopResourceDisplayName("Admin.Configuration.Settings.CustomerUser.MemberTypeRequired")]

public bool MemberTypeRequired { get; set; }

                  

                  

5.Presentation\Nop.Web\Administration\Views\Setting\CustomerUser.cshtml

仿照 PhoneEnabled 及 PhoneRequired 新增

<div class="form-group">

         <div class="col-md-3">

                   @Html.NopLabelFor(model => model.CustomerSettings.MemberTypeEnabled)

         </div>

         <div class="col-md-9">

                   @Html.NopEditorFor(model => model.CustomerSettings.MemberTypeEnabled)

                   @Html.ValidationMessageFor(model => model.CustomerSettings.MemberTypeEnabled)

         </div>

</div>

<div class="form-group" id="pnlMemberTypeRequired">

         <div class="col-md-3">

                   @Html.NopLabelFor(model => model.CustomerSettings.MemberTypeRequired)

         </div>

         <div class="col-md-9">

                   @Html.NopEditorFor(model => model.CustomerSettings.MemberTypeRequired)

                   @Html.ValidationMessageFor(model => model.CustomerSettings.MemberTypeRequired)

         </div>

</div>

                  

 

if ($('#@Html.FieldIdFor(model => model.CustomerSettings.MemberTypeEnabled)').is(':checked')) {

         $('#pnlMemberTypeRequired').show();

} else {

         $('#pnlMemberTypeRequired').hide();

}

 

 

$("#@Html.FieldIdFor(model => model.CustomerSettings.MemberTypeEnabled)").click(toggleCustomerRequiredFormField);

                  

6.解决方案 Clean 和 Rebuild

 

7.运行站点 查看效果

                  

 

其他:

Presentation\Nop.Web\Administration\Controllers\SettingController.cs

 

public ActionResult CustomerUser()

{

         if (!_permissionService.Authorize(StandardPermissionProvider.ManageSettings))

                   return AccessDeniedView();

 

         var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext);

         var customerSettings = _settingService.LoadSetting<CustomerSettings>(storeScope);

                           

 

Presentation\Nop.Web\Administration\Infrastructure\Mapper\AutoMapperConfiguration.cs

         仿照  cfg.CreateMap<CustomerUserSettingsModel.CustomerSettingsModel, CustomerSettings>()

             //.ForMember(dest => dest.MemberTypeEnabled, mo => mo.Ignore())

                   //.ForMember(dest => dest.MemberTypeRequired, mo => mo.Ignore())

                                              

        

        

转载地址:http://kqtsa.baihongyu.com/

你可能感兴趣的文章
【BZOJ】2563: 阿狸和桃子的游戏
查看>>
redis 中文字符显示
查看>>
国内外MD5在线解密网站
查看>>
【OC语法要闻速览】一、方法调用
查看>>
Git-命令行-删除本地和远程分支
查看>>
本文将介绍“数据计算”环节中常用的三种分布式计算组件——Hadoop、Storm以及Spark。...
查看>>
顺序图【6】--☆☆
查看>>
Docker Swarm 让你事半功倍
查看>>
string.Format字符串格式说明
查看>>
[转]IC行业的牛人
查看>>
javaScript事件(四)event的公共成员(属性和方法)
查看>>
linux系统常用命令
查看>>
在 Word 中的受支持的区域设置标识符的列表
查看>>
Caffe + Ubuntu 14.04 64bit + CUDA 6.5 配置说明2
查看>>
An easy to use android color picker library
查看>>
Oracle SID爆破工具SidGuess
查看>>
批处理常用命令总结2
查看>>
解读ASP.NET 5 & MVC6系列(9):日志框架
查看>>
MyEclipse生成WAR包并在Tomcat下部署发布(转发)
查看>>
Android -- 自定义View小Demo,绘制钟表时间(一)
查看>>