public class AdminTabStripCreatedEventConsumer : IConsumer<PageRenderingEvent>, IConsumer<AdminTabStripCreated> { public void HandleEvent(AdminTabStripCreated eventMessage) { if (eventMessage?.Helper == null) return;
//we need customer details page var tabsElementId = "product-edit"; if (!eventMessage.TabStripName.Equals(tabsElementId)) return;
//compose script to create a new tab var productEditTabElementId = "tab-productEdit"; var productEditTab = new HtmlString($@" <script type='text/javascript'> $(document).ready(function() {{ $(` <li> <a data-tab-name='{productEditTabElementId}' data-toggle='tab' href='#{productEditTabElementId}'> {_localizationService.GetResource("Plugins.Payments.Worldpay.WorldpayCustomer")} </a> </li> `).appendTo('#{tabsElementId} .nav-tabs:first'); $(` <div class='tab-pane' id='{productEditTabElementId}'> { // eventMessage.Helper.Partial("~/Plugins/Widgets.ProductReviews/Views/_TabEditProduct.cshtml", 0).RenderHtmlContent() .Replace("</script>", "<\\/script>") //we need escape a closing script tag to prevent terminating the script block early } </div> `).appendTo('#{tabsElementId} .tab-content:first'); }}); </script>");
//add this tab as a block to render on the customer details page eventMessage.BlocksToRender.Add(ProductEditTab); } } }