Adding Order Note during checkout

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 yıl önce
Greetings,

I'm currently adding an Order Notes area during the Confirm of an order.  The customer requested the ability so the users can let the owners of the site know any special requests.  I've placed the text area onto the page but am having issue with getting the model to respond.  I noticed that the model is not passed in and added it to the method ConfirmOrder, however, I get a null Order Note.  Btw, I modified the OrderNote Table to contain a CustomerId.

Here is what I have thus far:

Confirm.cshtml


...
<div class="order-notes-title">
      @T("Checkout.OrderNote")
</div>
<div class="clear">
</div>
<div class="order-notes-body">
      @Html.TextAreaFor(model => model.OrderNote, new { style = "width:400px; height:100px" })
</div>
<div class="clear">
</div>
...


CheckoutConfirmModel.cs


...
public string OrderNote { get; set; }


CheckoutController.cs (ConfirmOrder method)


...  down to line 847 or so (else to check on _webHelper)
//Check for order note
if (!string.IsNullOrEmpty(model.OrderNote))
{
     //Add customer's order note
     var orderNote = new OrderNote
     {
          CustomerId = _workContext.CurrentCustomer.Id,
          Note = model.OrderNote,
          DisplayToCustomer = true,
          CreatedOnUtc = DateTime.Now
     };
     placeOrderResult.PlacedOrder.OrderNotes.Add(orderNote);
     _orderService.UpdateOrder(placeOrderResult.PlacedOrder);
}
...
11 yıl önce
Have you considered using Checkout Attribute?  You can create one of type Textbox.  The entered value would appear to the store owner at the bottom of the Products tab of an Order in Admin.

(Why did you add CustomerId to OrderNote?  OrderNote has OrderId which allows you to get to Order to get CustomerId)
11 yıl önce
chajo10 wrote:
Greetings,

I'm currently adding an Order Notes area during the Confirm of an order.


Logically the confirm page should be where the user confirms the information entered not where new information is entered.

I'd agree with New York use a checkout attribute.
11 yıl önce
Originally I needed to differentiate who sent in what note (admin/user).  The Checkout Attribute is far better and easier.  Thanks for the suggestion.  It works perfectly for what I needed it to do.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.