Disable price filter

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 anni tempo fa
How can I disable the price filter for some categories?  I know how to turn it on or off completely, but we have to be able to show it for only some categories.

Thanks!
5 anni tempo fa
You can set price range to null from category edit page.

This will with default nopCommerce price filter.
Hope you are not using any third party plugin for filter.
5 anni tempo fa
Hello,

We are actually using the Hop Templates Motion theme.  If I leave the price range box blank in the admin (which I have been doing), the slider still shows up.  As a desperate attempt, I put the word "null" in the box and I got a format exception.
5 anni tempo fa
Hello to anyone reading this.

I was able to accomplish this by using a view component that gets the data from a custom setting in the admin.
3 anni tempo fa
I had to remind myself how I did this today, two years later.  Here's a longer note for myself in two more years and for anyone else:

In the class for my component:


private string PriceRangeFilterClass(int CategoryId)
{
  List<int> lstCategoryIds = new List<int>();
  List<string> lstExclusions = new List<string>();

  try
  {
    // Fill lstExclusions with category names from the setting.
    lstExclusions = _settingService.GetSettingByKey<string>("nopajaxfilterssettings.disablepricerangefilterforcategories").Split(',').ToList();
  }
  catch
  {
    // Do nothing.  The setting does not exist.
    return string.Empty;
  }

  // Iterate through exclusions.  Add the IDs to the list of IDs.
  foreach (string s in lstExclusions)
  {
    int intCatId;
    try
    {
      intCatId = _categoryService.GetAllCategories().Where(x => x.Name == s).FirstOrDefault().Id;
    }
    catch
    {
      intCatId = 0;
    }
    lstCategoryIds.Add(intCatId);
  }
  
  // If the list of IDs contains this category's ID...
  if (lstCategoryIds.Contains(CategoryId))
  {
    return "hide-price-range";
  }
  else
  {
    return String.Empty;
  }
}


In the Default view:


@model string
@String.Format("{0}", Model)


In the PriceRangeFilterSlider view:


var currentCategoryId = Convert.ToInt32(Url.ActionContext.RouteData.Values["categoryId"].ToString());
var priceRangeFilterClassResult = await Component.InvokeAsync("NopAjaxFiltersSettingsExtend", new { CategoryId = currentCategoryId });
string priceRangeFilterClass = priceRangeFilterClassResult.RenderHtmlContent();

<div class="block filter-block priceRangeFilterPanel7Spikes @priceRangeFilterClass" data-currentcurrencysymbol="@Model.CurrencySymbol">
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.