Jiten rash (away) Posted August 30, 2013 Share Posted August 30, 2013 (edited) Hello guys If u like to dispaly price only to login users for some privacy...and want--->DISPLAY PRICE ONLY TO LOGIN USERS.go to backoffice customers and groups edit or tick the correct symbol on guest and customer now the important thing we must display alert to guest and visitors that they need to login to view prices so we need to add a piece of code homefeatured.tpl product list.tpl product.tpl block special.tpl note:homefeatured and blockspecial are located in themes/default/modules {if $logged} {else} <p class="logout">login for prices</p> {/if} <span class="price">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span></p>{else}<div style="height:21px;"></div>{/if}{if $logged} {else} <p class="logout">login for prices</p> {/if} Edited September 5, 2013 by Jiten rash (see edit history) 3 Link to comment Share on other sites More sharing options...
Jiten rash (away) Posted August 30, 2013 Author Share Posted August 30, 2013 (edited) sorry demo has been deleted u can also do this it doesnt removes the shoping cart ok do this find themes/modules/homefeatured.tpl replace the text marked red with green u need to find this code marked with red in all product_list.tplproduct.tpl In modules: blockspecial.tplhomefeatured.tpl <span class="price">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}</span> {if $logged}{if isset($product.show_price) && $product.show_price && !isset($restricted_country_mode)}<span class="price" style="display: inline;">{if !$priceDisplay}{convertPrice price=$product.price}{else}{convertPrice price=$product.price_tax_exc}{/if}{/if}{else}<p class="logged_out">login for prices</p>{/if} Edited September 17, 2013 by Jiten rash (see edit history) 1 Link to comment Share on other sites More sharing options...
seanloo Posted October 12, 2013 Share Posted October 12, 2013 (edited) Thanks to Jiten rash and EI Patron. I'm appreciate for your guides above. I'll try this in my b2b shop soon. To show message for non-logged users, how about using jQuery jGrowl? http://plugins.jquery.com/jgrowl/ Maybe add this code in necessary TPL-files. {if $cookie->isLogged()} {else} <script type="text/javascript"> $.jGrowl('{l s='Register or login to see prices'}', { life: 5000 }); </script> {/if} Edited October 12, 2013 by seanloo (see edit history) Link to comment Share on other sites More sharing options...
pinatz Posted October 14, 2016 Share Posted October 14, 2016 Hello. I have last version of prestashop. And I would like show "LOGIN TO SEE PRICE" at the place of the price. The methods written in this post can't be applied because they are for some old version. Someone can help me? Link to comment Share on other sites More sharing options...
rocky Posted October 14, 2016 Share Posted October 14, 2016 It will take a bit of work, but it should be possible. You could override the Tools::displayPrice function. For example, create override/classes/Tools.php with the following: <?php class Tools extends ToolsCore { public static function displayPrice($price, $currency = null, $no_utf8 = false, Context $context = null) { if ($context == null) $context = Context::getContext(); if (!$context->customer->id) return 'LOG IN TO SEE PRICE'; else return parent::displayPrice($price, $currency, $no_utf8, $context); } } This will work for the areas that use PHP to format the price. The areas that use JavaScript to format the price will continue to display prices though. You'll need to create a JavaScript variable called logged that can be used to determine whether a customer is logged in. For example: var logged = {if $cookie->logged}true{else}false{/if}; Finally, you'll need to find all the calls to formatCurrency inside your theme and add code that checks whether a customer is logged in. For example: $('#our_price_display').text(!logged ? 'LOG IN FOR PRICE' : formatCurrency(parseFloat($('#our_price_display').attr('content')), currencyFormat, currencySign, currencyBlank)); Link to comment Share on other sites More sharing options...
El Patron Posted October 14, 2016 Share Posted October 14, 2016 (edited) put this at bottom of your classes/conifiguration.php if ($cookie->isLogged() ? Configuration::set('PS_CATALOG_MODE', 0) : Configuration::set('PS_CATALOG_MODE', 1)); Then you only need to prompt them to register/login to see prices. Happy day, el Edited October 31, 2016 by El Patron (see edit history) Link to comment Share on other sites More sharing options...
rocky Posted October 14, 2016 Share Posted October 14, 2016 @El Patron Thank you for sharing. I can't believe I didn't think of that. 1 Link to comment Share on other sites More sharing options...
pinatz Posted October 16, 2016 Share Posted October 16, 2016 (edited) Hello. I tried to insert what you wrote but it doesn't work. Maybe I added in the wrong section of the file. However I don't know if it is what I need. As you can see in the image in attachment, i would like see the written "Log in to see price" instead of the price. Actually website is configured that if you are not registered, you see nothing and if you are registered, you see price. I want that if you are not registered, you see the written "Login to see price" Thanks Matteo Edited October 17, 2016 by pinatz (see edit history) Link to comment Share on other sites More sharing options...
rocky Posted October 17, 2016 Share Posted October 17, 2016 @pinatz If you're seeing the price as 0 on the product page, then it means you've missed changing a line of code in themes/<your_theme>/product.js. Make sure every instance of formatCurrency has been changed to !logged ? 'LOG IN FOR PRICE' : formatCurrency Also, make sure you've added the following to the JavaScript variables in product.tpl: var logged = {if $logged}true{else}false{/if}; Link to comment Share on other sites More sharing options...
pinatz Posted October 17, 2016 Share Posted October 17, 2016 @pinatz If you're seeing the price as 0 on the product page, then it means you've missed changing a line of code in themes/<your_theme>/product.js. Make sure every instance of formatCurrency has been changed to !logged ? 'LOG IN FOR PRICE' : formatCurrency Also, make sure you've added the following to the JavaScript variables in product.tpl: var logged = {if $logged}true{else}false{/if}; Don't see the price. Price is 0 because in the product price i didn't set price. Link to comment Share on other sites More sharing options...
rocky Posted October 17, 2016 Share Posted October 17, 2016 OK, I've tried to come up with an easier solution. Undo my previous solution (except for the override) and then do the following: 1. Go to Customers > Groups and click the tick icon under "Show prices" for the "Visitors" group to disable prices just for logged-out customers. 2. Change the following at about line of 258 of product.tpl: {if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE} to: {if !$logged}{l s='LOG IN TO SEE PRICES'} {elseif $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE} This should replace the price with "LOG IN TO SEE PRICES" on the product page. My previous override will change the other prices. 1 Link to comment Share on other sites More sharing options...
El Patron Posted October 17, 2016 Share Posted October 17, 2016 It might be a lot simpler to do this: back office-->customers-->groups-->edit visitor-->disable 'show' prices. ps will then not display prices all throught the visitors non-logged visit. Then rather then putting in code to check for login status, use the .tpl variable when price is to be displayed or not. Link to comment Share on other sites More sharing options...
pinatz Posted October 31, 2016 Share Posted October 31, 2016 OK, I've tried to come up with an easier solution. Undo my previous solution (except for the override) and then do the following: 1. Go to Customers > Groups and click the tick icon under "Show prices" for the "Visitors" group to disable prices just for logged-out customers. 2. Change the following at about line of 258 of product.tpl: {if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE} to: {if !$logged}{l s='LOG IN TO SEE PRICES'} {elseif $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE} This should replace the price with "LOG IN TO SEE PRICES" on the product page. My previous override will change the other prices. PERFECT! IT WORKS! YOU'RE GREAT How can I write in english in English language and in Italian in Italian language? How can I change the dimension and the bond font? Link to comment Share on other sites More sharing options...
rocky Posted November 1, 2016 Share Posted November 1, 2016 You can go to Localization > Translations > Front office translations and then scroll down to the "product" section to translate the text into different languages. I think to make it easier to format, change the first line to: {if !$logged}<span class="login_price">{l s='LOG IN TO SEE PRICES'}</span> Then you can add CSS code like the following to style it: .login_price { font-weight: bold; } Link to comment Share on other sites More sharing options...
pinatz Posted November 2, 2016 Share Posted November 2, 2016 You can go to Localization > Translations > Front office translations and then scroll down to the "product" section to translate the text into different languages. I think to make it easier to format, change the first line to: {if !$logged}<span class="login_price">{l s='LOG IN TO SEE PRICES'}</span> Then you can add CSS code like the following to style it: .login_price { font-weight: bold; } Fantastic! It works with translation. But with CSS i don't see differences. I modified product.css file. Is it correct? Link to comment Share on other sites More sharing options...
rocky Posted November 3, 2016 Share Posted November 3, 2016 Yes, that's right. There must be some CSS overriding it. You can try using font-weight: bold!important; or adding some class like #product in front of .login_price to prevent CSS from overriding it. Link to comment Share on other sites More sharing options...
pinatz Posted November 3, 2016 Share Posted November 3, 2016 Ok.. I tried but nothing.I modified the product.css file in the themes/mytheme/css folder adding in the end of the file #product.login_price { font-weight: bold!important; } I recompiled files and and deleted cache. Nothing Link to comment Share on other sites More sharing options...
rocky Posted November 3, 2016 Share Posted November 3, 2016 Try adding a space: #product .login_price { font-weight: bold!important; } Link to comment Share on other sites More sharing options...
pinatz Posted November 4, 2016 Share Posted November 4, 2016 Try adding a space: #product .login_price { font-weight: bold!important; } Nothing.. no bold! It is not so important.. I wuold like see in bold, but if it is not possible, it doesn't matter Link to comment Share on other sites More sharing options...
pinatz Posted November 16, 2016 Share Posted November 16, 2016 Hello Guys. I am here again. I configured volume price. But it is always shown, also when i am not logged in. How can set volume price only after logged in? Matteo Link to comment Share on other sites More sharing options...
pinatz Posted December 7, 2016 Share Posted December 7, 2016 nothing Link to comment Share on other sites More sharing options...
El Patron Posted December 8, 2016 Share Posted December 8, 2016 nothing there is several solutions proposed in this topic and about 100 other topics. Please don't 'bump' posts, put some effort into it please. Link to comment Share on other sites More sharing options...
pinatz Posted February 11, 2017 Share Posted February 11, 2017 (edited) there is several solutions proposed in this topic and about 100 other topics. Please don't 'bump' posts, put some effort into it please. For example? Because I don't find anything Edited February 11, 2017 by pinatz (see edit history) Link to comment Share on other sites More sharing options...
KingKalp Posted February 13, 2017 Share Posted February 13, 2017 OK, I've tried to come up with an easier solution. Undo my previous solution (except for the override) and then do the following: 1. Go to Customers > Groups and click the tick icon under "Show prices" for the "Visitors" group to disable prices just for logged-out customers. 2. Change the following at about line of 258 of product.tpl: {if $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE} to: {if !$logged}{l s='LOG IN TO SEE PRICES'} {elseif $product->show_price && !isset($restricted_country_mode) && !$PS_CATALOG_MODE} This should replace the price with "LOG IN TO SEE PRICES" on the product page. My previous override will change the other prices. How about the Prestashop 1.7 , cant find what you said. Link to comment Share on other sites More sharing options...
rocky Posted February 16, 2017 Share Posted February 16, 2017 In PrestaShop v1.7, the prices are in themes/classic/templates/catalog/product.tpl, themes/classic/templates/catalog/_partials/product-prices.tpl, themes/classic/templates/catalog/listing/product-list.tpl, themes/classic/templates/catalog/_partials/miniatures/pack-product.tpl, themes/classic/templates/catalog/_partials/miniatures/product.tpl. You'll need to find all the {$product.price}, {$product.price_tax_inc} and {$product.price_amount} in those files and add {if !$logged}{l s='LOG IN TO SEE PRICES' d='Shop.Theme.Catalog'}{else} before them and {/if} after. Link to comment Share on other sites More sharing options...
swapnilphanse Posted February 17, 2017 Share Posted February 17, 2017 In PrestaShop v1.7, the prices are in themes/classic/templates/catalog/product.tpl, themes/classic/templates/catalog/_partials/product-prices.tpl, themes/classic/templates/catalog/listing/product-list.tpl, themes/classic/templates/catalog/_partials/miniatures/pack-product.tpl, themes/classic/templates/catalog/_partials/miniatures/product.tpl. You'll need to find all the {$product.price}, {$product.price_tax_inc} and {$product.price_amount} in those files and add {if !$logged}{l s='LOG IN TO SEE PRICES' d='Shop.Theme.Catalog'}{else} before them and {/if} after. Hello, I followed your given steps in PS v1.7. The prices are visible to only to logged in user but I am not able to display message "Login to see prices" to a guest or visitor. Can you please advice further. Link to comment Share on other sites More sharing options...
rocky Posted February 18, 2017 Share Posted February 18, 2017 Oops, I forgot the $logged variable was removed in PrestaShop v1.7. You need to use {if !$customer.is_logged} instead. Otherwise, the code is working fine on my test site. Link to comment Share on other sites More sharing options...
Daniele0884 Posted April 22, 2018 Share Posted April 22, 2018 On 16/2/2017 at 7:58 AM, rocky said: In PrestaShop v1.7, the prices are in themes/classic/templates/catalog/product.tpl, themes/classic/templates/catalog/_partials/product-prices.tpl, themes/classic/templates/catalog/listing/product-list.tpl, themes/classic/templates/catalog/_partials/miniatures/pack-product.tpl, themes/classic/templates/catalog/_partials/miniatures/product.tpl. You'll need to find all the {$product.price}, {$product.price_tax_inc} and {$product.price_amount} in those files and add {if !$logged}{l s='LOG IN TO SEE PRICES' d='Shop.Theme.Catalog'}{else} before them and {/if} after. Hi Rocky, I use PS 1.7.2.4 your changes work! I would like that the text "LOG IN TO SEE PRICES" appears when I disable SHOW PRICE for visitors, in manage customers group. And not when customers are not logged. Can you help me? it possible this? thanks Link to comment Share on other sites More sharing options...
ana777 Posted January 30 Share Posted January 30 Hy Guys, I have PS 8.1 website with Warehouse theme installed. Catalogue is showing prices only for logged users, but faceted search module sometime shows prices (even for visitors) and other times does not show. I only need to show prices for logged users. Anyone knows why this happens? Or what is the solution? 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