I am adding a new column to the ProductVariant table called ShipETAID which is an int. I have the new field ShipETA showing up correctly in a Administration Product Variant page with the correct data and I can up data the fields. But when I call @model.ShipETAID from the front end I always get '0' returned. What am I missing???
In Nop.Data.Mapping.Catalog.ProductVariantMap.cs I added:
this.Ignore(pv => pv.ShipETA);
In Nop.Core.Domain.Catalog.ProductVariant.cs I added:
/// <summary>
/// Gets or sets the Shipping ETA Id
/// </summary>
public virtual int ShipETAID { get; set; }
/// <summary>
/// Gets or sets the Ship ETA
/// </summary>
public virtual ShipETAMode ShipETA
{
get
{
return (ShipETAMode)this.ShipETAID;
}
set
{
this.ShipETAID = (int)value;
}
}
I added the file Nop.Core.Domain.Catalog.ShipETAMode.cs
namespace Nop.Core.Domain.Catalog
{
/// <summary>
/// Represents a backorder mode
/// </summary>
public enum ShipETAMode
{
/// <summary>
/// Item is on Backorder
/// </summary>
Backorders = 0,
/// <summary>
/// Usually Ships in 3-5 Days
/// </summary>
ShipsInThreeToFiveDays = 10,
/// <summary>
/// Usually Ships in 7+ Days
/// </summary>
ShipsInSevenPlusDays = 20,
/// <summary>
/// Item is Out of Print
/// </summary>
OutOfPrint = 30,
/// <summary>
/// Limited Remaining
/// </summary>
OutOfPrintInStock = 40,
}
}
To \Presentation\Nop.Web\Administration\Views\Shared\_ProductVariantInfo.cshtml I added:
<tr id="pnlShipETA">
<td class="adminTitle">
@Html.NopLabelFor(model => model.ShipETAId):
</td>
<td class="adminData">
@Html.DropDownListFor(model => model.ShipETAId, ((ShipETAMode)Model.ShipETAId).ToSelectList())
@Html.ValidationMessageFor(model => model.ShipETAId)
</td>
</tr>
In Nop.Web.Models.Catalog.ProductDetailsModel.cs I added:
public partial class ProductVariantModel : BaseNopEntityModel
{
public ProductVariantModel()
{
GiftCard = new GiftCardModel();
ProductVariantPrice = new ProductVariantPriceModel();
PictureModel = new PictureModel();
AddToCart = new AddToCartModel();
ProductVariantAttributes = new List<ProductVariantAttributeModel>();
}
public int ShipETAID { get; set; }
public ShipETAMode ShipETA
{
get
{
return (ShipETAMode)this.ShipETAID;
}
set
{
this.ShipETAID = (int)value;
}
}
I added the file \Presentation\Nop.Web\Views\Catalog\_ProductVariantShipETA.cshtml:
@model ProductDetailsModel.ProductVariantModel
@using Nop.Web.Models.Catalog;
@if (Model.ShipETAID == 0)
{
<div class="ShipETA">
@T("Products.ShipETA")<text>: Back Ordered</text>
</div>
}
@if (Model.ShipETAID == 10)
{
<div class="ShipETA">
@T("Products.ShipETA")<text>: Item is Out of Print</text>
</div>
}
@if (Model.ShipETAID == 20)
{
<div class="ShipETA">
@T("Products.ShipETA")<text>: 3-5 Days (Supplies Limited)</text>
</div>
}
@if (Model.ShipETAID == 30)
{
<div class="ShipETA">
@T("Products.ShipETA")<text>: 7+ Days</text>
</div>
}
@if (Model.ShipETAID == 40)
{
<div class="ShipETA">
@T("Products.ShipETA")<text>: 3-5 Days</text>
</div>
}
Then I call it in \Presentation\Nop.Web\Views\Catalog\ProductTemplate.SingleVariant.cshtml by:
@Html.Partial("_ProductVariantShipETA", defaultProductVariant)