floriankajbe Posted March 28, 2023 Share Posted March 28, 2023 Hello, I wanted to build this simple function into my webshop, but I don't know how to do it or if it's even possible. Can anyone help me? Link to comment Share on other sites More sharing options...
Slava Posted March 30, 2023 Share Posted March 30, 2023 Hi, there is 2 options: Add this code to the bottom of config/config.inc.php if ($context->cookie->isSessionAlive() ? Configuration::set('PS_CATALOG_MODE', 0) : Configuration::set('PS_CATALOG_MODE', 1)); or wrap all prices in your theme .tpl files {if $customer.is_logged} <p>Display price</p> {else} <p>DO NOT Display price</p> {/if} Link to comment Share on other sites More sharing options...
Mediacom87 Posted March 30, 2023 Share Posted March 30, 2023 Hi, you can define it directly in groups definitions or with a module to simplified it with a message to inform visitors like https://www.prestatoolbox.com/security/205-display-catalog-mode-for-visitors.html Link to comment Share on other sites More sharing options...
AmirRzd Posted March 31, 2023 Share Posted March 31, 2023 (edited) As mentioned in PrestaShop customer group section: PrestaShop has three default customer groups: Visitor - All persons without a customer account or customers that are not logged in. Guest - All persons who placed an order through Guest Checkout. Customer - All persons who created an account on this site. [and logged in] So PrestaShop can determine if a customer is logged in or not with this built-in feature. No coding needed. So to hide prices for not logged in visitors, simply: Go to Shop Parameters > Customer Settings > Groups (tab) Edit "Visitor" group Set "Show prices" to "NO" Save Like the image below: The result when the visitor is not logged in: When the customer is logged in: The following instruction is optional: Now if you want to inform your visitors/customers that they need to login to see the prices depending on your theme you can set a banner or a text block informing them and make that module hidden for "Customer" group. In the default classic theme: Go to Design > Position and click on the "Transplant a module" blue button In the "Module" field search for "Custom Text Block" or "Banner" In the "Transplant to" field search for "displayTop" or any other hook you prefer. Click on "Save" Now you need to create a proper content (an HTML Text or a Banner). I explain the Custom text module: Go to Modules > Module Manager Search for "Custom Text Block" Enable it if it is disabled and then click "Configure" Provide a proper information for visitors (Not logged in users). For example: "To see the prices, please login to your account. If you do not have an account you can create a new one here." And you can link the words to the log in page. Save Then you need to hide this block for logged in customers: Go to Shop Parameters > Customer Settings > Groups (tab) Edit "Customer" group In the "Authorized modules" section, set the "Custom Text Block" module to "NO" Save Now what visitors (not logged in) will see: And what customers (logged in) will see: All of this with no need to edit codes, just with some configurations. I hope it helps. Edited March 31, 2023 by AmirRzd (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now