在愿望列表模块- DNN Hotcakes中显示产品选项



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

如何更改,以便选项标签和所选值也显示?

我假设您使用的是Hotcakes 1。而不是版本2。但是代码应该与相同。我只在01.10.04测试过。

我已经构建了一个示例,说明如何基于您将在视图集中找到的Cart视图来完成此操作。

原来的愿望列表视图是这样的:

@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>

最新更新