Close

Remove Pricing from Product

janelle.autry
9 years ago
#8836 Quote
Avatar
  • 7
Is there a way to use post a product using the Category template without having a price associated with it? Right now, I have the "Price" empty and the template pulls through $0.00.  I want to use one category page in my store has just an informational page.
iliyan.tanev
9 years ago
#8842 Quote
Avatar
  • Moderator
  • 347
Hi,

Open the Presentation\Nop.Web\Views\Shared\_ProductBox.cshtml view and wrap the .prices div with the following check:


 var currentCategoryId = Url.RequestContext.RouteData.Values["categoryId"];

if (currentCategoryId != null && Convert.ToInt32(currentCategoryId.ToString()) != the id of the category you don't want to have prices on)
{
       <div class="prices">
       ...
      </div>
}


This will remove the price from all products that are in the specified category. 
Regards,
Iliyan Tanev
Nop-Templates Dev Team
janelle.autry
9 years ago
#8844 Quote
Avatar
  • 7










Hi!  I placed the code and it is still showing a price of $0.00.  I have attached the code to see if I misplaced it.

        <div class="add-info">
      var currentCategoryId = Url.RequestContext.RouteData.Values["categoryId"];

  if (currentCategoryId != null && Convert.ToInt32(currentCategoryId.ToString()) != varietals)
       {  
     <div class="prices">
                @if (!String.IsNullOrEmpty(Model.ProductPrice.OldPrice))
                {
                    <span class="price old-price">@Model.ProductPrice.OldPrice</span>
                }
                <span class="price actual-price">@Model.ProductPrice.Price</span>
                @if (Model.ProductPrice.DisplayTaxShippingInfo)
                {
                    var inclTax = EngineContext.Current.Resolve<IWorkContext>().TaxDisplayType == TaxDisplayType.IncludingTax;
                    //tax info is already included in the price (incl/excl tax). that's why we display only shipping info here
                    //of course, you can modify appropriate locales to include VAT info there
                    <div class="tax-shipping-info">
                        @T(inclTax ? "Products.Price.TaxShipping.InclTax" : "Products.Price.TaxShipping.ExclTax", Url.RouteUrl("Topic", new { SeName = Html.GetTopicSeName("shippinginfo") }))
                    </div>
                    }
            </div>
  }
iliyan.tanev
9 years ago
#8848 Quote
Avatar
  • Moderator
  • 347
Hi,

You have placed the code right, but you have confused the category id with it's name.

You could get the id from the database or by going to the administration -> Catalog -> Categories -> List  and click the edit button. At the end of the url you will see a number. This is the id.
Regards,
Iliyan Tanev
Nop-Templates Dev Team
janelle.autry
9 years ago
#8856 Quote
Avatar
  • 7
Wonderful!  Thank you for the correction!  It works great know!