Add extra tab to Admin > Edit Order Details

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
Nop-Templates.com wrote:
Hello,

Without modifying the NOP core is it possible to add an additional tab to the Admin > Edit Order Details page please?

At the moment it has tabs of "Info", "Billing Info", "Shipping Info", "Products" & "Order notes"

I have a requirement to add an additional tab to this page which has custom functionality in the tab....

Is this possible and can anyone suggest the best way to achieve it please?

Many thanks

Hi,

Yes, it is possible.

All you need to do is to inherit from the IConsumer interface and implement the required method.

Here is a simple example:

public class AdminTabStripConsumer : IConsumer<AdminTabStripCreated>
{
  public void HandleEvent(AdminTabStripCreated tabEventInfo)
  {
    if (tabEventInfo != null && !string.IsNullOrEmpty(tabEventInfo.TabStripName))
    {
      if (tabEventInfo.TabStripName == "order-edit")
      {
        var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);

        object objectId = HttpContext.Current.Request.RequestContext.RouteData.Values["id"];

        if (!string.IsNullOrEmpty(objectId.ToString()))
        {
          string text = "Additional tab";
          string content = urlHelper.Action("YourController", "YourAction", new { id = objectId });

          tabEventInfo.BlocksToRender.Add(
            new MvcHtmlString(
              "<script>" +
                "$(document).ready(function() {" +
                  "$('#product-edit').data('kendoTabStrip').append(" +
                    "[{" +
                      "text: '" + text + "'," +
                      "contentUrl: '" + content + "'" +
                    "}]" +
                  ");" +
                "});" +
              "</script>"
            )
          );
        }
      }
    }
  }
}


tabEventInfo.TabStripName == "order-edit" - order-edit is the name of the tabstrip, which is defined in the "Presentation\Nop.Web\Administration\Views\Order\Edit.cshtml".

string content = urlHelper.Action("YourController", "YourAction", new { id = objectId }); - change YourController and YourAction to correspond with yours.

In the controller, you can define your logic for preparing the view. Example:

public ActionResult Action(int? id)
{
        // Add some logic, if you have any.
  return PartialView("Path/to/your/View.cshtml", id);
}


View.cshtml:

@model int?

@{
    var productId = Model;

    if (productId == null)
    {
        <div>Save before edit</div>
        return;
    }
}

<div>Your code here</div>


This will render an additional tab with name "Additional tab" and when you click it, it will make a request to your controller and action to get the html.

Hope this helps!

If there is anything that is not clear, please ask!

Regards,
Hristian



I have followed the steps and I get
Cannot read property 'append' of undefined
  in the console of browser for
 .data('kendoTabStrip') 


if I remove
 .data('kendoTabStrip') 
,error disappears but the tab does not render.

I am using 3.80 version.

Please help.

Vishal
7 years ago
vkotecha91 wrote:
Hello,


I am using 3.80 version.

Please help.

Vishal


You have to follow the previous post==>https://www.nopcommerce.com/boards/t/43586/adding-tab-via-plugin-in-version-380.aspx#173145
7 years ago
sohel wrote:
Hello,


I am using 3.80 version.

Please help.

Vishal

You have to follow the previous post==>https://www.nopcommerce.com/boards/t/43586/adding-tab-via-plugin-in-version-380.aspx#173145


Thanks a lot man! you saved my day!
6 years ago
Do i have to write all this code in my own Controller in My new Plugin ?
Quick Response will be highly appreciated..

And Any other changes i have to made in code?


Thanks
6 years ago
I want to create an Extra tab on Product Edit Page can i use the same code which used for Order Edit Page by just Changing order-edit to product-edit ?
6 years ago
I have added a Custom tab in Product-Edit , Now i want to Save That custom tab data On Product-Edit Save Button.

Quick Response will be highly appreciated.
6 years ago
No need to create plugin, Just did changes in Edit.cshtml file in "Admin/Views/Order".
Create a method like
@helper TabOrderHistory() {
//here add partial view
}
@Html.RenderBootstrapTabContent()  // here we have to call TabOrderHistory method
@Html.RenderBootstrapTabHeader()   // here need to add tab id and tab name with help of '@T()'

It's very simple Try :)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.