Hide prices for non-registered customers

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
9 years ago
vittorio.arenella wrote:
Hi i have the problem with hidding price

I have multistore version. NOP 3.2

http://retail.cosmeticishop.it   b2C

http://pro.cosmeticishop.it   b2B

the site have same products but:

in retail user guests can see the price

in pro user guests can't see the price.

ACL works for all site and dont have configuration for site.

There is a solution? any plug-in?

vittorio


Hi,

I have sorted out this issue. If you hide the prices by roles, then its common for all the stores. So it wont help you. Just leave it as default.

My approach needs a bit of customization with some C# and MVC knowledge. Since you have 2 stores and those must be using 2 themes. Just open the theme folder for the one which you want to hide the price. Usually under Presentation\Nop.Web\Themes folder. go to view under Presentation\Nop.Web\Themes\<your theme name>\Views.

you need to find all the views, which shows the product price.

then in the view add,


@using Nop.Core.Infrastructure;
@using Nop.Core.Domain.Customers;

var isGuest = EngineContext.Current.Resolve<Nop.Core.IWorkContext>().CurrentCustomer.IsGuest();


Now wrap the price displace inside a if statement which checks isGuest is not true. So once customer logged in, it will show the price.


But this to work, you need to turn guest checkout off.

Hope this give an idea to you. By this way, you dont need to update any core nop commerce features. So your other store will work as usual.
9 years ago
rjpatel43 wrote:
Hi ,

I wanted to  hide price for few countries , how can i do that ?


Hi,

I haven't done this. but i know roughly how it can be done. It needs to be customized Assuming you are a programmer with C# and MVC knowledge.

With first request from customer, nop commerce creates a guid and guest customer entry in the customer table. During this time, nop commerce also stores the customer's last visited IP as well. So from IP address, you can get the country. Getting country from IP address is already implemented in admin--> Online Customers page. you can have a look on that.

Now you need to have a setting to store which countries to block. Its up to you to implement. you can have a new page with the list of country to block. or you can have just one text box setting under admin --> Setting --> Catalog.

So, when first request is from the guest, just run a check on the IP and Block country, set a setting a custom attribute for a customer with a Boolean to store if he/she can or cant see the price. If you see Adming-->Edit Customer page, you can see how custom customer attribute works.

Now last part, when customer navigates to catalog pages, just read this custom attribute using IWorkContext.CurrentCustomer. Add a boolean variable to page entity object. So in the view, based on this boolean, you can show/hide the price.

Note: Relaying on IP for country is not 100% fool proof.
8 years ago
Ideally, we would be able to do this w/o modifying code if we had per-store ACLs (any reason why this hasn't been implemented as part of multi-store project?) or a per-store catalog setting.

We're trying jeyara's approach, by modifying the view for the second store. Rather than looking for price, it might be easier to look how the view handles CallForPrice, and short circuit it so it handles non-registered customers the same way. Another search term might be CustomerEntersPrice. In our case (using a Nop-Templates theme), it was in _ProductPrice.cshtml -same as in the original nopC - (and don't forget to add the "@using Nop.Core.Domain.Customers;".

We're still figuring out how to get hide the price on the product list and the compare list (want to keep the changes to a minimum, since we've been trying no to fork it too much).
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.