Total de postagens:
2
Karma:
10
Ingressou:
29/11/2021
Localização:
Spain
Hi, I'm only finding this method in IWorkContext: Task<Customer> GetCurrentCustomerAsync(); I'm also not finding the IsInCustomerRole method, I'm just finding the following method in CustomerService.cs class. public virtual async Task<bool> IsInCustomerRoleAsync(Customer customer, string customerRoleSystemName, bool onlyActiveCustomerRoles = true) Can somebody help me? Thank you so much
Total de postagens:
357
Karma:
3116
Ingressou:
09/12/2018
Localização:
Bangladesh
In 4.40, it is in CustomerExtensions.cs file here is the path : Libraries\Nop.Core\Domain\Customers\CustomerExtensions.cs Example of use: customer.IsInCustomerRole("customer role system name", false)
Total de postagens:
2
Karma:
10
Ingressou:
29/11/2021
Localização:
Spain
Hi! Thanks for your quick reply but in this file that you are telling me, I don't see that method. Only the following methods appear: bool IsSearchEngineAccount(this Customer customer) bool IsBackgroundTaskAccount(this Customer customer)
MVP
Programador certificado
Total de postagens:
3950
Karma:
35257
Ingressou:
08/02/2010
Localização:
Australia
IsInCustomerRoleAsync(...) Is in nopCommerce_4.40.4_Source\Libraries\Nop.Services\Customers\CustomerService.cs Searching the solution is useful for finding things :)
Total de postagens:
27
Karma:
155
Ingressou:
28/06/2009
Localização:
United States
I'm using NC 4.40. I need to add 5% to the displayed price if they are not logged in. I can do the add 5% part. But, in my _ProductBox.cshtml file, how can I tell the customer role or if they are logged in?
Total de postagens:
11339
Karma:
101107
Ingressou:
22/05/2011
Localização:
United States
RE: "...add 5% to the displayed price" Unless maybe if you are using "customer enters prices", just changing the "displayed price" in the .cshtml file is not going to affect how that price is recalculated when it gets added to the cart, etc.
Total de postagens:
27
Karma:
155
Ingressou:
28/06/2009
Localização:
United States
True. But, if I can determine if they are a Guest I will increase the displayed price, hide the add to cart button and display a message that says they need to register/log in to see "their" price.
Total de postagens:
27
Karma:
155
Ingressou:
28/06/2009
Localização:
United States
Thanks for your reply. But, I'm not sure how to use the code. The below is the view page code. Where would I place the code you gave? ---------------------------------------------------------- @model ProductOverviewModel @using Nop.Core @using Nop.Core.Domain.Catalog @using Nop.Core.Domain.Orders @using Nop.Core.Domain.Tax @using Nop.Core.Domain.Customers; @using Nop.Core.Infrastructure; @using Nop.Services.Customers; @inject CatalogSettings catalogSettings @inject IWorkContext workContext @inject IViewComponentSelector viewComponentSelector @{ //prepare "Add to cart" AJAX link var addtocartlink = ""; var shoppingCartTypeId = (int)ShoppingCartType.ShoppingCart; var quantity = 1; if (Model.ProductPrice.ForceRedirectionAfterAddingToCart) { addtocartlink = Url.RouteUrl("AddProductToCart-Catalog", new { productId = Model.Id, shoppingCartTypeId = shoppingCartTypeId, quantity = quantity, forceredirection = Model.ProductPrice.ForceRedirectionAfterAddingToCart }); } else { addtocartlink = Url.RouteUrl("AddProductToCart-Catalog", new { productId = Model.Id, shoppingCartTypeId = shoppingCartTypeId, quantity = quantity }); } } <div class="product-item" data-productid="@Model.Id"> <h2 class="product-title"> <a href="@Url.RouteUrl("Product", new { SeName = Model.SeName })">@Model.Name</a> </h2> <div class="picture"> <a href="@Url.RouteUrl("Product", new { SeName = Model.SeName })" title="@Model.DefaultPictureModel.Title"> @if (viewComponentSelector.SelectComponent("LazyLoadImage") != null) { @await Component.InvokeAsync("LazyLoadImage", new (string Key, string Value)[] { ("src", Model.DefaultPictureModel.ImageUrl), ("alt", Model.DefaultPictureModel.AlternateText), ("title", Model.DefaultPictureModel.Title) }) } else { <img alt="@Model.DefaultPictureModel.AlternateText" src="@Model.DefaultPictureModel.ImageUrl" title="@Model.DefaultPictureModel.Title" /> } </a> </div> <div class="details"> @if (Model.ReviewOverviewModel.AllowCustomerReviews) { var ratingPercent = 0; if (Model.ReviewOverviewModel.TotalReviews != 0) { ratingPercent = ((Model.ReviewOverviewModel.RatingSum * 100) / Model.ReviewOverviewModel.TotalReviews) / 5; } <div class="product-rating-box" title="@string.Format(T("Reviews.TotalReviews").Text, Model.ReviewOverviewModel.TotalReviews)"> <div class="rating"> <div style="width: @(ratingPercent)%"> </div> </div> </div> } <div class="description"> @Html.Raw(Model.ShortDescription) </div> @if (catalogSettings.ShowSkuOnCatalogPages && !string.IsNullOrEmpty(Model.Sku)) { <div class="sku"> <span>PART #: @Model.Sku</span><br /> </div> } <div class="add-info"> @await Component.InvokeAsync("Widget", new { widgetZone = PublicWidgetZones.ProductBoxAddinfoBefore, additionalData = Model }) <div class="prices"> @if (!string.IsNullOrEmpty(Model.ProductPrice.OldPrice)) { <span class="price old-price">@Model.ProductPrice.OldPrice</span> } @if (!string.IsNullOrEmpty(Model.ProductPrice.Price)) { <span class="price actual-price">@Model.ProductPrice.Price</span> } else { <span class="price actual-price">Register/Log In to see your price!</span> } @if (Model.ProductPrice.DisplayTaxShippingInfo) { var inclTax = await workContext.GetTaxDisplayTypeAsync() == 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 <span class="tax-shipping-info"> @T(inclTax ? "Products.Price.TaxShipping.InclTax" : "Products.Price.TaxShipping.ExclTax", Url.RouteUrl("Topic", new { SeName = await Html.GetTopicSeNameAsync("shippinginfo") })) </span> } @if (!string.IsNullOrEmpty(Model.ProductPrice.BasePricePAngV)) { <div class="base-price-pangv"> @Model.ProductPrice.BasePricePAngV </div> } </div> @await Component.InvokeAsync("Widget", new { widgetZone = PublicWidgetZones.ProductBoxAddinfoMiddle, additionalData = Model }) <div class="buttons"> @if (!Model.ProductPrice.DisableBuyButton) { var addToCartText = T("ShoppingCart.AddToCart").Text; if (Model.ProductPrice.IsRental) { addToCartText = T("ShoppingCart.Rent").Text; } if (Model.ProductPrice.AvailableForPreOrder) { addToCartText = T("ShoppingCart.PreOrder").Text; } <button type="button" class="button-2 product-box-add-to-cart-button" onclick="AjaxCart.addproducttocart_catalog('@addtocartlink');return false;">@(addToCartText)</button> } </div> @await Component.InvokeAsync("Widget", new { widgetZone = PublicWidgetZones.ProductBoxAddinfoAfter, additionalData = Model }) </div> </div> </div>