在愿望清单模块中显示产品选项 - DNN Hotcakes

时间:2016-09-14 17:13:26

标签: e-commerce dotnetnuke dotnetnuke-module

愿望清单模块的当前默认视图显示产品,但不显示所选的选项。

如何更改以便显示选项标签和选定值?

1 个答案:

答案 0 :(得分:1)

我将假设你使用Hotcakes 1.xx而不是版本2.xx,但代码应该两者都相同。我只是在01.10.04进行了测试。

我已根据您在视图集中找到的购物车视图构建了一个如何执行此操作的示例。

原始愿望清单视图如下所示:

@model IEnumerable<Hotcakes.Modules.Core.Areas.Account.Models.SavedItemViewModel>

<h2>@Localization.GetString("SavedItems")</h2>
@Html.Raw((string)TempData["messages"])
<div class="hc-record-list hc-wishlist clearfix">
    @foreach (var item in Model)
    {
        <div class="hc-record">
            <div class="hc-recimage">
                <a href="@item.FullProduct.ProductLink">
                    <img src="@item.FullProduct.ImageUrls.SmallUrl" border="0" alt="@item.FullProduct.ImageUrls.SmallAltText" />
                </a>
            </div>
            <div class="hc-recname">
                <h2>@item.FullProduct.Item.ProductName</h2>
                <div class="hc-recdescription">
                    @Html.Raw(item.FullProduct.Item.LongDescription)
                </div>
            </div>
            <div class="hc-reccontrols">
                <table class="dnnFormItem">
                    <tr>
                        <td class="hc-recprice">
                            @Html.Raw(item.FullProduct.UserPrice.DisplayPrice(true))
                        </td>
                        <td>
                            @if(!item.FullProduct.Item.IsGiftCard && !item.FullProduct.Item.IsUserSuppliedPrice)
                            {
                                using (Html.BeginHccRouteForm(HccRoute.WishList, new { action = "addtocart" }, FormMethod.Post))
                                {
                                    <input type="hidden" name="itemid" value="@item.SavedItem.Id" />
                                    <input class="dnnPrimaryAction" type="submit" value="@Localization.GetString("AddToCart")" />
                                }
                            }
                        </td>
                        <td>
                            @using (Html.BeginHccRouteForm(HccRouteNames.WishList, new { action = "delete" }, FormMethod.Post))
                            {
                                <input type="hidden" name="itemid" value="@item.SavedItem.Id" />
                                <input type="submit"  class="hc-delete" value="@Localization.GetString("RemoveSavedItem")" />
                            }
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    }
</div>

在产品说明下方,我添加了以下代码段:

@using Hotcakes.Commerce.Catalog
@if (item.SavedItem.SelectionData != null && item.SavedItem.SelectionData.OptionSelectionList != null && item.SavedItem.SelectionData.OptionSelectionList.Count > 0)
{
    <div class="clearfix">
        @Html.Raw(item.FullProduct.Item.Options.CartDescription(item.SavedItem.SelectionData.OptionSelectionList))
    </div>
}

这使得整个视图看起来像这样:

@using Hotcakes.Commerce.Catalog
@model IEnumerable<Hotcakes.Modules.Core.Areas.Account.Models.SavedItemViewModel>

<h2>@Localization.GetString("SavedItems")</h2>
@Html.Raw((string)TempData["messages"])
<div class="hc-record-list hc-wishlist clearfix">
    @foreach (var item in Model)
    {
        <div class="hc-record">
            <div class="hc-recimage">
                <a href="@item.FullProduct.ProductLink">
                    <img src="@item.FullProduct.ImageUrls.SmallUrl" border="0" alt="@item.FullProduct.ImageUrls.SmallAltText" />
                </a>
            </div>
            <div class="hc-recname">
                <h2>@item.FullProduct.Item.ProductName</h2>
                <div class="hc-recdescription">
                    @Html.Raw(item.FullProduct.Item.LongDescription)
                </div>
                @if (item.SavedItem.SelectionData != null && item.SavedItem.SelectionData.OptionSelectionList != null && item.SavedItem.SelectionData.OptionSelectionList.Count > 0)
                {
                    <div class="clearfix">
                        @Html.Raw(item.FullProduct.Item.Options.CartDescription(item.SavedItem.SelectionData.OptionSelectionList))
                    </div>
                }
            </div>
            <div class="hc-reccontrols">
                <table class="dnnFormItem">
                    <tr>
                        <td class="hc-recprice">
                            @Html.Raw(item.FullProduct.UserPrice.DisplayPrice(true))
                        </td>
                        <td>
                            @if(!item.FullProduct.Item.IsGiftCard && !item.FullProduct.Item.IsUserSuppliedPrice)
                            {
                                using (Html.BeginHccRouteForm(HccRoute.WishList, new { action = "addtocart" }, FormMethod.Post))
                                {
                                    <input type="hidden" name="itemid" value="@item.SavedItem.Id" />
                                    <input class="dnnPrimaryAction" type="submit" value="@Localization.GetString("AddToCart")" />
                                }
                            }
                        </td>
                        <td>
                            @using (Html.BeginHccRouteForm(HccRouteNames.WishList, new { action = "delete" }, FormMethod.Post))
                            {
                                <input type="hidden" name="itemid" value="@item.SavedItem.Id" />
                                <input type="submit"  class="hc-delete" value="@Localization.GetString("RemoveSavedItem")" />
                            }
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    }
</div>