Close

Profile: Monitor36400

Avatar

User posts

Thank you for the information.
This did not exactly answer what we wanted but gave us enough details to be able to achieve what we wanted. The ~/Views/Catalog/SearchBox.cshtml view controls what happens when the Search box is visible. What we wanted was to actually hide the search button in the header so a user could not even get to the Search box.
Here is what we did in case it is of use to anyone else. We edited ~/Themes/Element/Views/Shared/_AirVariant1.cshtml.
Added

@using Nop.Core;
@using Nop.Core.Domain.Customers;
@using Nop.Core.Infrastructure;
@using Nop.Services.Customers;
  bool customerHasRoleAdministrator = EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.IsInCustomerRole("Administrators");
  bool customerHasRoleRegistered = EngineContext.Current.Resolve<IWorkContext>().CurrentCustomer.IsInCustomerRole("Registered");


Then placed this condition:
  
@if (customerHasRoleAdministrator||customerHasRoleRegistered)
  {}


around            
<div class="search-wrap">
                <span>@T("Search")</span>
            </div>


This gave us the desired effect.

We are using the Element Theme at v3.90.
We want to only show the 'Search' button in the header after login. From Configuration - Plugins - Local Plugins - Nop Instant Search - Edit we have set 'Limited to customer roles' to only include 'Administrators' and 'Registered'. But the Search button in the header still appears when no user is logged on. How can we condition the display of the 'Search' button?