2016-09-14 2 views

Antwort

1

Ich werde eine Annahme machen, dass Sie Hotcakes 1.xx und nicht Version 2.xx dafür verwenden, aber der Code sollte für beide gleich sein. Ich habe es nur am 01.10.04 getestet.

Ich habe ein Beispiel aufgebaut, wie dies auf den Wagen Ansicht basiert tun Sie bereits in der Viewset finden.

Die ursprüngliche Merklistenansicht wie folgt aussieht:

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

Unterhalb der Beschreibung des Produkts, fügte ich die folgenden Ausschnitt:

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

, dass die gesamte Ansicht wie folgt aussehen macht:

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

Nice! Das funktioniert perfekt. Danke Will, du bist magisch! –

Verwandte Themen