Write textbox info to new field in order table

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
9 years ago
I am fairly new to 'mvc' & NopCommerce.
I have the following:
Full unaltered code for version 2.65 NopCommerce.
Database: CorpWear265_Restore_Test
Table: Order   New Field: OrderEnquiry
Presentation=>Nop.Web=>Themes=>CorpWear2=>Views=>ShoppingCart=>OrderSummary.cshtml

TextBox:
Additional Info:<textarea   id="AdditionalInformation" name="AdditionalInformation"   >@Session["AdditionalInformation"]</textarea>

Presentation=>Nop.Web=>Themes=>CorpWear2=>VIews=>Order=>Details.cshtml
@Html.Raw(Model.OrderEnquiry)

What I am trying to do:
Write the following to OrderEnquiry in Order table:
<br/><br/>
<b>Additional Information:</b> Content of Textbox<br/>

The following I need help with: (not sure of correct Controller & model file names)
Write code for new model in OrderDetailsModel.cs
Write code for OrderController.cs

Thanks in advance for any help given.
9 years ago
Welcome to nopCommerce world!
Are you strict to use nopCommerce 2.65 ? If it is not then it is wise to use latest version (v3.4). All your customization should be easy and you will get many bug fixes, faster in performance and new features than v2.65 .
9 years ago
It has to be version 2.65 because it has many customisations in the view code by a previous developer.
One of the problems is that the controller & model code was compiled into a ddl
and no source code left available on the server.
The OrderEnquiry field is in the Order table, but I do not know how to write/read to it etc.
I appreciate any help given.
9 years ago
I have tried the following:
Nop.Core.Domain.Orders.Order.cs
#region Properties
// Instance members must be virtual on data table objects like OrderEnquiry.cs
// Virtual is required by data access frameworks so that these frameworks
// can implement more complex features like lazy loading.
public virtual string OrderEnquiry { get; set; }

Nop.Data.Mapping.Orders.OrderMap.cs
// This code maps a column in the database to the new property we created above
// This creates a nullable nvarchar with a length of 255 characters
// in the OrderEnquiry SQL table
this.Property(o => o.OrderEnquiry).HasMaxLength(255).IsOptional();

Nop.Web.Themes.CorpWear2.Views.Order.Details.cs
http://localhost:2619/customer/orders
http://localhost:2619/orderdetails/7697
@Html.Widget("orderdetails_page_bottom")
<div class = "order-enquiry">
OrderEnquiry:
@Html.Raw(Model.OrderEnquiry)
#
</div>

Using Sql Management Studio I entered text into Field: OrderEnquiry record:7697
Refreshed Details.cs page, but still does not show any data.
PLease I need help writting/reading OrderEnquiry field in Order Table.
Thanks in advance for any help given.
9 years ago
I have managed to read from field OrderEnquiry by doing the following:
Nop.Web.Controllers.OrderController.cs
#region Utilities

[NonAction]
protected OrderDetailsModel PrepareOrderDetailsModel(Order order)
{
// Alteration
model.OrderEnquiry = order.OrderEnquiry;

I just now need to be able to write to the field from textbox in
http://localhost:2619/checkout/confirm
/Themes/CorpWear2/Views/Checkout/Confirm.cshtml
<div id="order-summary-body" >
            @Html.Action("OrderSummary", "ShoppingCart", new { prepareAndDisplayOrderReviewData = true })
    </div>
/Themes/CorpWear2/Views/ShoppingCart/OrderSummary.cshtml
<textarea cols="20" id="AdditionalInformation" name="AdditionalInformation"  rows="2" style="Width: 465px; Height: 45px;">@Session["AdditionalInformation"]</textarea>

It should then display in
http://localhost:2619/checkout/completed
<div class="order-summary-body">
        @Html.Action("OrderSummary", "ShoppingCart", new { isEditable = false })
    </div>
OrderSummary:
<div id="order-summary-body" >Info:
            @Html.Action("OrderSummary", "ShoppingCart", new { prepareAndDisplayOrderReviewData = true })
            #
    </div>

It Does not update Order Table, Please can you help with this.
Thanks in advance for any help given
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.