ASP .NET core Razor page - Avoid refreshing the page - asp.net-core

I have tow buttons in one Form, first button for add website info to a local table and second button for add social media info to another table, after all info added locally,
then I can click on 'add all info' button for add all info in same time to database.
My question is how can I add info to a table without refreshing the page?
AddAllInfo.cshtml:
<div class="col-md-6 mb-3">
<label class="form-label" asp-for="NewWebSiteInfo.websiteName">Website URL</label>
<input type="text" asp-for="NewWebSiteInfo.websiteName" class="form-control" />
</div>
<div class="col-md-6 mb-3">
<label class="form-label" asp-for="NewWebSiteInfo.websiteUrl">Website URL</label>
<input type="text" asp-for="NewWebSiteInfo.websiteUrl" class="form-control" />
</div>
<button type="submit" validatedisable="True" asp-page-handler="AddWebsiteInfo" class="btn btn-primary" >Add Website info</button>
<div class="mb-3">
#if (AddInfoModel.WebSitelist.Count > 0)
{
<div class="col-12 border p-3">
<table class="table table-striped table-bordered">
<thead style="background-color:lightgray">
<tr>
<th>WebsiteName</th>
<th>websiteURL</th>
</tr>
</thead>
<tbody>
#foreach (Website item in AddAllInfoModel.WebSitelist)
{
<tr>
<td>#item.WebsiteName</td>
<td>#item.websiteURL</td>
</tr>
}
</tbody>
</table>
</div>
}
</div>
</br>
</br>
<div class="col-md-6 mb-3">
<label class="form-label" asp-for="NewSocialMediaInfo.SocialMediaName">Social Media</label>
<input type="text" asp-for="NewSocialMediaInfo.SocialMediaName" class="form-control" />
</div>
<div class="col-md-6 mb-3">
<label class="form-label" asp-for="NewSocialMediaInfo.SocialMediaAccount">Account</label>
<input type="text" asp-for="NewSocialMediaInfo.SocialMediaAccount" class="form-control" />
</div>
<button type="submit" validatedisable="True" asp-page-handler="AddSocialMediaInfo" class="btn btn-primary" >Add socil Media info</button>
<div class="mb-3">
#if (AddInfoModel.SocialMedialist.Count > 0)
{
<div class="col-12 border p-3">
<table class="table table-striped table-bordered">
<thead style="background-color:lightgray">
<tr>
<th>SocialMediaName</th>
<th>SocialMediaAccount</th>
</tr>
</thead>
<tbody>
#foreach (SocialMedia item in AddAllInfoModel.SocialMedialist)
{
<tr>
<td>#item.SocialMediaName</td>
<td>#item.SocialMediaAccount</td>
</tr>
}
</tbody>
</table>
</div>
}
</div>
</br>
<div class="col-4 offset-2">
<button type="submit" class="btn btn-primary form-control"> Add all info </button>
</div>
</form> ```
AddAllInfo.cshtml.cs:
public void OnPostAddSocialMediaInfo()
{
SocialMedialist.Add(new SocialMedia { SocialMediaName = NewSocialMediaInfo.SocialMediaName,
SocialMediaAccount=NewSocialMediaInfo.SocialMediaAccount});
}
public void OnPostAddWebsiteInfo()
{
WebSitelist.Add(new WebSite { WebSiteName = NewWebSiteInfo.WebsiteName,
websiteUrl =NewWebSiteInfo.websiteUrl});
}

You can use js to pass data to handler,and then use js to add html to tbody,here is a demo to add data to table without refresh the page:
<div class="col-md-6 mb-3">
<label class="form-label" asp-for="NewWebSiteInfo.websiteName">Website URL</label>
<input type="text" asp-for="NewWebSiteInfo.websiteName" class="form-control" />
</div>
<div class="col-md-6 mb-3">
<label class="form-label" asp-for="NewWebSiteInfo.websiteUrl">Website URL</label>
<input type="text" asp-for="NewWebSiteInfo.websiteUrl" class="form-control" />
</div>
<input type="button" onclick="AddWebsiteInfo()" class="btn btn-primary" value="Add Website info">
<div class="mb-3">
#if (AddInfoModel.WebSitelist.Count > 0)
{
<div class="col-12 border p-3">
<table class="table table-striped table-bordered">
<thead style="background-color:lightgray">
<tr>
<th>WebsiteName</th>
<th>websiteURL</th>
</tr>
</thead>
<tbody>
#foreach (Website item in AddAllInfoModel.WebSitelist)
{
<tr>
<td>#item.WebsiteName</td>
<td>#item.websiteURL</td>
</tr>
}
</tbody>
</table>
</div>
}
</div>
</br>
</br>
<div class="col-md-6 mb-3">
<label class="form-label" asp-for="NewSocialMediaInfo.SocialMediaName">Social Media</label>
<input type="text" asp-for="NewSocialMediaInfo.SocialMediaName" class="form-control" />
</div>
<div class="col-md-6 mb-3">
<label class="form-label" asp-for="NewSocialMediaInfo.SocialMediaAccount">Account</label>
<input type="text" asp-for="NewSocialMediaInfo.SocialMediaAccount" class="form-control" />
</div>
<input type="button" onclick="AddSocialMediaInfo()" class="btn btn-primary" value="Add socil Media info">
<div class="mb-3">
#if (AddInfoModel.SocialMedialist.Count > 0)
{
<div class="col-12 border p-3">
<table class="table table-striped table-bordered">
<thead style="background-color:lightgray">
<tr>
<th>SocialMediaName</th>
<th>SocialMediaAccount</th>
</tr>
</thead>
<tbody>
#foreach (SocialMedia item in AddAllInfoModel.SocialMedialist)
{
<tr>
<td>#item.SocialMediaName</td>
<td>#item.SocialMediaAccount</td>
</tr>
}
</tbody>
</table>
</div>
}
</div>
</br>
<div class="col-4 offset-2">
<input type="button" onclick="AddAllInfo()" class="btn btn-primary" value="Add all info">
</div>
</form> ```
js:
#section Scripts{
<script>
function AddWebsiteInfo() {
var NewWebSiteInfo = {
'websiteName': $("#NewWebSiteInfo_websiteName").val(),
'websiteUrl': $("#NewWebSiteInfo_websiteUrl").val()
};
$.ajax({
type: 'POST',
url: '?handler=AddWebsiteInfo',
data: NewWebSiteInfo,
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
dataType: 'json',
success: function (data) {
var html = "<tr><td>" + data.websiteName + "</td><td>" + data.websiteUrl + "</td></tr>";
$("tbody")[0].innerHTML = $("tbody")[0].innerHTML + html;
}
});
}
function AddSocialMediaInfo() {
var NewAddSocialMediaInfo = {
'SocialMediaName': $("#NewSocialMediaInfo_SocialMediaName").val(),
'SocialMediaAccount': $("#NewSocialMediaInfo_SocialMediaAccount").val()
};
$.ajax({
type: 'POST',
url: '?handler=AddSocialMediaInfo',
data: NewAddSocialMediaInfo,
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
dataType: 'json',
success: function (data) {
var html = "<tr><td>" + data.socialMediaName + "</td><td>" + data.socialMediaAccount + "</td></tr>";
$("tbody")[1].innerHTML = $("tbody")[1].innerHTML + html;
}
});
}
function AddAllInfo() {
AddWebsiteInfo();
AddSocialMediaInfo();
}
</script>
}
handler:
[BindProperty]
public WebSiteInfo NewWebSiteInfo { get; set; }
[BindProperty]
public SocialMediaInfo NewSocialMediaInfo { get; set; }
public void OnGet()
{
}
public JsonResult OnPostAddWebsiteInfo()
{
WebSitelist.Add(new WebSite { WebSiteName = NewWebSiteInfo.WebsiteName,
websiteUrl =NewWebSiteInfo.websiteUrl});
return new JsonResult(NewWebSiteInfo);
}
public JsonResult OnPostAddSocialMediaInfo()
{
SocialMedialist.Add(new SocialMedia { SocialMediaName = NewSocialMediaInfo.SocialMediaName,
SocialMediaAccount=NewSocialMediaInfo.SocialMediaAccount});
return new JsonResult(NewSocialMediaInfo);
}

The best way to do this is to run the post request in javascript, this will not refresh the page.
2nd option is by calling the get method again at the end of the post method and then passing the model with the data to the get. So that when the page refreshes the data is filled in again

Related

Add Delete details in Master Detail model - ASP.NET Core

I am doing CRUD operations on a Master Detail models Team and TeamMember using modal popup. I followed this video to create Add and Delete buttons in Create action like this:
This is the code i used to perform this:
TeamController:
public IActionResult Create()
{
Team team = new Team();
team.TeamMembers.Add(new TeamMember() { TeamMemberId = 1 });
return PartialView("_AddTeamPartialView", team);
}
[HttpPost]
public IActionResult Create(Team team)
{
if (team != null)
{
_dbcontext.Team.Add(team);
_dbcontext.SaveChanges();
return RedirectToAction("Index");
}
return View();
}
_AddTeamPartialView.cshtml:
#model Team
#{
ViewData["Title"] = "_AddTeamPartialView";
}
<div class="modal fade" role="dialog" tabindex="-1" id="addTeam" aria-labelledby="addTeamLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false" >
<div class="modal-dialog modal-xl modal-dialog-scrollable" role="document">
<div class="modal-content">
<div class="modal-header">
<h3>Team</h3>
</div>
<div class="modal-body">
<form asp-action="Create" method="post">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="TeamName" class="control-label">TeamName</label>
<input asp-for="TeamName" class="form-control" />
<span asp-validation-for="TeamName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Coach" class="control-label">Coach</label>
<input asp-for="Coach" class="form-control" />
<span asp-validation-for="Coach" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="NumberTeamMembers" class="control-label">NumberTeamMembers</label>
<input asp-for="NumberTeamMembers" class="form-control" id="NumberOfTeamMembers" />
<span asp-validation-for="NumberTeamMembers" class="text-danger"></span>
</div>
<h3>Members</h3>
<table class="table table-bordered" id="membersTable">
<thead>
<tr>
<th>Name</th>
<th>BirthDate</th>
<th>Phone</th>
<th>
<button id="addbtnMember" type="button" class="btn btn-sm btn-secondary visible"
onclick="AddItem(this)">
Add
</button>
</th>
</tr>
</thead>
<tbody >
#for (int i = 0; i < Model.TeamMembers.Count; i++)
{
<tr>
<td>
#Html.EditorFor(x => x.TeamMembers[i].Name, new { htmlAttributes = new { #class = "form-control" } })
</td>
<td>
#Html.EditorFor(x => x.TeamMembers[i].BirthDate, new { htmlAttributes = new { #class = "form-control" } })
</td>
<td>
#Html.EditorFor(x => x.TeamMembers[i].Phone, new { htmlAttributes = new { #class = "form-control" } })
</td>
<td>
<button id="btnremove-#i" type="button" class="btn btn-sm btn-danger"
onclick="DeleteItem(this)" >
Delete
</button>
</td>
</tr>
}
</tbody>
</table>
<input type="hidden" id="hdnLastIndex" value="0" />
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" onclick="javascript:window.location.reload()">CANCEL</button>
<button type="submit" class="btn btn-primary">SAVE</button>
</div>
</form>
</div>
</div>
</div>
</div>
#*#section Scripts {
#{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}*#
<script>
function DeleteItem(btn) {
$(btn).closest('tr').remove();
document.getElementById('hdnLastIndex').value = document.getElementById('hdnLastIndex').value - 1;
}
function AddItem(btn) {
var table = document.getElementById('membersTable');
var rows = table.getElementsByTagName('tr');
var rowOuterHtml = rows[rows.length - 1].outerHTML;
var lastrowIdx = document.getElementById('hdnLastIndex').value;
var RowNumber = document.getElementById('NumberOfTeamMembers').value;
var nextrowIdx = eval(lastrowIdx) + 1;
document.getElementById('hdnLastIndex').value = nextrowIdx;
rowOuterHtml = rowOuterHtml.replaceAll('_' + lastrowIdx + '_', '_' + nextrowIdx + '_');
rowOuterHtml = rowOuterHtml.replaceAll('[' + lastrowIdx + ']', '[' + nextrowIdx + ']');
rowOuterHtml = rowOuterHtml.replaceAll('-' + lastrowIdx, '-' + nextrowIdx);
if (nextrowIdx < RowNumber) {
var newRow = table.insertRow();
newRow.innerHTML = rowOuterHtml;
}
}
</script>
By using this code i can add team members less or egal the number of team members, but the problem is that when i delete one the team members (for example the first team member) during the create operation of a new team, all the team members inserted after the deleted one won't be saved. where is the problem in this code?

How to submit related entities in asp.net core razor page form?

I have two models Invoice and Product, one invoice can have many products as usual.
public class InvoiceModel
{
public string Name { get; set; }
public string Description { get; set; }
[Required(ErrorMessage = "Products are required!")]
public List<ProductModel> Products { get; set; }
}
public class ProductModel
{
public string Name { get; set; }
public string Model { get; set; }
public string Brand { get; set; }
}
and i want to create a new invoice with products.
so when i generate razor page for invoice create, it only generate input fields for Name and Description,
then i added product table, and button to the form, when the user clicks on add product button, a new row is added to the table using jsscript.
I have referred to this Url for binding complex object lists, but when I submit the form newly added products are not posted to the server-side.
Can anyone point me to the right way to resolve this issue,
Thanks
Try my codes bellow and my test result in screenshot.
#page
#model IndexModel
#{
}
<h3>#ViewData["confirmation"]</h3>
<form class="form-horizontal" method="post">
<div class="form-group">
<label for="Name" class="col-sm-2 control-label">Name</label>
<div class="col-sm-10">
<input asp-for="CC.Name" type="text" class="form-control">
</div>
</div>
<div class="form-group">
<label for="Description" class="col-sm-2 control-label">Description</label>
<div class="col-sm-10">
<input asp-for="CC.Description" type="text" class="form-control">
</div>
</div>
<script type="text/javascript">
var mytab = document.getElementById("myTable");
var i = 0;
function myfunction() {
document.getElementById("myTable").style.display = "block";
document.getElementById("myTable").insertRow(-1).innerHTML =
'<td> <input type="text" name="cc.Products[' +i + '].Name" /> </td><td> <input type="text" name="cc.Products[' + i + '].Model" /> </td><td> <input type="text" name="cc.Products[' + i + '].Brand" /> </td>';
i++;
}
</script>
<button type="button" onclick="myfunction()">Add Product</button>
<table id="myTable" style="display: none;" class="table table-striped">
<tr>
<th>Name</th>
<th>Model</th>
<th>Brand</th>
</tr>
</table>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Create</button>
</div>
</div>
</form>
enter image description here
enter image description here
According to your description ,I guess you used the wrong input tag's name this is the reason why you coulnd't get the ProductModel's vaule.
If your post method's parameter name like public InvoiceModel ProductModels { get; set; }, then the table's name should like this ProductModels.Products[0].Name and ProductModels.Products[1].Name.
More details, you could refer to below codes:
<form class="form-horizontal" method="post">
<div class="form-group">
<label for="Name" class="col-sm-2 control-label">Name</label>
<div class="col-sm-10">
<input asp-for="ProductModels.Name" type="text" class="form-control">
</div>
</div>
<div class="form-group">
<label for="Description" class="col-sm-2 control-label">Description</label>
<div class="col-sm-10">
<input asp-for="ProductModels.Description" type="text" class="form-control">
</div>
</div>
<button type="button" onclick="myFunction()">Add Product</button>
<table id="myTable">
<tr>
<td>Name</td>
<td>Model </td>
<td>Brand</td>
</tr>
<tr>
<td>
<input type="text" name="productModels.Products[0].Name" />
</td>
<td>
<input type="text" name="productModels.Products[0].Model" />
</td>
<td>
<input type="text" name="productModels.Products[0].Brand" />
</td>
</tr>
<tr>
<td>
<input type="text" name="productModels.Products[1].Name" />
</td>
<td>
<input type="text" name="productModels.Products[1].Model" />
</td>
<td>
<input type="text" name="productModels.Products[1].Brand" />
</td>
</tr>
</table>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Create</button>
</div>
</div>
</form>
Backend:
[BindProperty]
public InvoiceModel ProductModels { get; set; }
public void OnGet()
{
}
public void OnPost(InvoiceModel productModels)
{
//var Name = Request.Form["Name"];
//var Description = Request.Form["Description"];
var Name = Request.Form["Name"];
var Model = Request.Form["Model"];
var Brand = Request.Form["Brand"];
ViewData["confirmation"] = $"{Name},{Model},{Brand}";
}
Result:

How to replace in Laravel 8

You can see I can add numbers by doing CRUD operation in laravel
I have added 1.6 and it shows 1.6
But I want when I add 1.6 it will replace and will show one point six
This is NumberController.php
public function index()
{
$products = Product::latest()->paginate(5);
return view('products.index',compact('products'))
->with('i', (request()->input('page', 1) - 1) * 5);
}
public function store(Request $request)
{
$request->validate([
'name' => 'required',
'detail' => 'required',
]);
Product::create($request->all());
return redirect()->route('products.index')
->with('success','Product created successfully.');
}
I will add my value here
This is my create.blade.php
<form action="{{ route('products.store') }}" method="POST">
#csrf
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>Name:</strong>
<input type="text" name="name" class="form-control" placeholder="Name">
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12">
<div class="form-group">
<strong>Detail:</strong>
<input type="double" name="detail" class="form-control" placeholder="Detail">
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 text-center">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</form>
I have to show replace value here
This is my index.blade.php
<table class="table table-bordered">
<tr>
<th>No</th>
<th>Name</th>
<th>Details</th>
<th width="280px">Action</th>
</tr>
#foreach ($products as $product)
<tr>
<td>{{ ++$i }}</td>
<td>{{ $product->name }}</td>
<td>{{ $product->detail }}</td>
<td>
<form action="{{ route('products.destroy',$product->id) }}" method="POST">
<a class="btn btn-info" href="{{ route('products.show',$product->id) }}">Show</a>
<a class="btn btn-primary" href="{{ route('products.edit',$product->id) }}">Edit</a>
#csrf
#method('DELETE')
<button type="submit" class="btn btn-danger">Delete</button>
</form>
</td>
</tr>
#endforeach
</table>

How can i generate downloadable PDF from the items in my Cart

I am using dompdf to generate a downloadable pdf from my multi-vendor eCommerce shopping cart and I am encountering this error even after defining $cartItems in QuotationController. $cartItems is defined in CartController I intend to fetch the items of CartController to the pdf
Here is the error:
Undefined variable: cartItems (View: C:\laragon\www\procure\resources\views\cart\quote.blade.php)
Here is QuoteController code:
<?php
namespace App\Http\Controllers;
use Barryvdh\DomPDF\PDF;
use Darryldecode\Cart\Cart;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class QuotationController extends Controller
{
public function quote(Request $request)
{
$product = DB::table('products')->get();
$cartItems = \Cart::session(auth()->id())->getContent();
$pdf = \PDF::loadView('cart.quote');
return $pdf->download('quotation.pdf');
//return view('cart.quote');
}
}
Heres is CartController:
<?php
namespace App\Http\Controllers;
use App\Product;
use Darryldecode\Cart\Cart;
class CartController extends Controller
{
public function add(Product $product)
{
// add the product to cart
\Cart::session(auth()->id())->add(array(
'id' => $product->id,
// 'img' => $product->cover_img,
'name' => $product->name,
'price' => $product->price,
'quantity' => 1,
'attributes' => array(),
'associatedModel' => $product,
));
return redirect()->route('cart.index');
}
public function index()
{
$cartItems = \Cart::session(auth()->id())->getContent();
view()->share('cartItems', $cartItems);
return view('cart.index', compact('cartItems'));
}
public function destroy($itemId)
{
\Cart::session(auth()->id())->remove($itemId);
return back();
}
public function update($rowId)
{
\Cart::session(auth()->id())->update($rowId, [
'quantity' => [
'relative' => false,
'value' => request('quantity'),
],
]);
return back();
}
public function checkout()
{
return view('cart.checkout');
}
}
And finally the blade file(quote.blade.php):
<section class="shopping-cart">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="cart-table table-responsive">
<table class="table">
<thead>
<tr>
<th class="t-pro">Product</th>
<th class="t-price">Price</th>
<th class="t-qty">Quantity</th>
<th class="t-total">Total</th>
<th class="t-rem"></th>
</tr>
</thead>
<tbody>
#foreach ($cartItems as $item)
<tr>
<td class="t-pro d-flex">
<div class="t-content">
<p class="t-heading">{{ $item->name }}</p>
</div>
</td>
<td class="t-price">KES {{ $item->price }} </td>
<td class="t-qty">
<div class="qty-box">
<div class="quantity buttons_added">
<form action="{{route('cart.update', $item->id)}}" method="get">
<input name="quantity" type="number" value="{{ $item->quantity }}">
<input class="button" type="submit" value="save">
</form>
</div>
</div>
</td>
<td class="t-total">{{Cart::session(auth()->id())->get($item->id)->getPriceSum()}}</td>
<td class="t-rem"><i class="far fa-trash-alt"></i></td>
</tr>
#endforeach
</tbody>
</table>
</div>
</div>
<div class="col-md-4">
<div class="coupon">
<h6>Discount Coupon</h6>
<p>Enter your coupon code if you have one</p>
<form action="#">
<input type="text" name="zip" value="" placeholder="Your Coupon">
<button type="button">Apply Code</button>
</form>
Print Quotation
</div>
</div>
<div class="col-md-4">
<div class="crt-sumry">
<h5>Cart Summery</h5>
<ul class="list-unstyled">
<li>Subtotal <span>KES {{\Cart::session(auth()->id())->getTotal()}}</span></li>
<li>Shipping & Tax <span>0.00</span></li>
<li>Grand Total <span>KES {{\Cart::session(auth()->id())->getTotal()}}</span></li>
</ul>
<div class="cart-btns text-right">
<button onclick="location.href='{{route('home')}}'" class="up-cart">Update Cart</button>
<button onclick="location.href='{{route('cart.checkout')}}'" class="chq-out ">Checkout</button>
</div>
</div>
</div>
</div>
</div>
</section>
Just visit this https://github.com/arafkarim/HTML-to-PDF i have just applied this thing in my similar project.

Display product options in Wishlist module - DNN Hotcakes

The current default view for the wish list module shows the product but not the options that were selected.
How can this be changed so that the option label and selected value are displayed as well?
I'm going to make an assumption that you're using Hotcakes 1.xx and not version 2.xx for this, but the code should be the same for both. I just only tested it in 01.10.04.
I've built an example of how to do this based upon the Cart view you'll find in the viewset already.
The original Wish List view looks like this:
#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>
Below the description of the product, I added the following snippet:
#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>
}
That makes the entire view look like this:
#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>