Magento 2: How to hide the price for guest user only wholesale group user can see price
How to hide the price for guest user only wholesale group user can see price in
is there any script or code or some free extension please suggest ?
magento2 price customer-group
add a comment |
How to hide the price for guest user only wholesale group user can see price in
is there any script or code or some free extension please suggest ?
magento2 price customer-group
add a comment |
How to hide the price for guest user only wholesale group user can see price in
is there any script or code or some free extension please suggest ?
magento2 price customer-group
How to hide the price for guest user only wholesale group user can see price in
is there any script or code or some free extension please suggest ?
magento2 price customer-group
magento2 price customer-group
asked Jan 11 '18 at 14:26
SheenuSheenu
5711
5711
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
You can hide the price by override the wrapResult function in vendor/magento/module-catalog/Pricing/Render/FinalPriceBox.php
app/code/Vendor/Module/etc/di.xml
<preference for="MagentoCatalogPricingRenderFinalPriceBox" type="VendorModulePricingRenderFinalPriceBox" />
app/code/Vendor/Module/Pricing/Render/FinalPriceBox.php
<?php
namespace VendorModulePricingRender;
use MagentoCatalogPricingPrice;
use MagentoFrameworkPricingRender;
use MagentoFrameworkPricingRenderPriceBox as BasePriceBox;
use MagentoMsrpPricingPriceMsrpPrice;
class FinalPriceBox extends MagentoCatalogPricingRenderFinalPriceBox
{
protected function wrapResult($html)
{
$result = '';
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$httpContext=$objectManager->get('MagentoFrameworkAppHttpContext');
$isLoggedIn=$httpContext->getValue(MagentoCustomerModelContext::CONTEXT_AUTH);
if($isLoggedIn){
$result = '<div class="price-box ' . $this->getData('css_classes') . '" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>' . $html . '</div>';
}
return $result;
}
}
Hello Vinz , i have tried your code it is not working
– Sheenu
Jan 18 '18 at 11:16
On which page do you need to hide the price ?
– Vinz
Jan 18 '18 at 13:43
i want to hide product list page, product details page and everywhere for guest user only login user with wholesale group can see price
– Sheenu
Jan 19 '18 at 10:34
@Vinz Does this solution also work with FPC? Won't it save the $isLoggedIn state of the first user that saves the FPC?
– Maarten Wolfsen
Jan 3 at 11:08
add a comment |
Product Available Extension allows the store owner to hide the product price and add to cart button from guests or certain customer groups.
add a comment |
Adding my opinion to @Vinz answer, you should get logged-in customer group id
<?php $context = $objectManager->get('MagentoFrameworkAppHttpContext'); ?>
<?php $isLoggedIn = $context->getValue(MagentoCustomerModelContext::CONTEXT_AUTH); ?>
<?php $customerGroupId = $context->getValue(MagentoCustomerModelContext::CONTEXT_GROUP); ?>
<?php if($isLoggedIn && $customerGroupID == 'WHOLESALE ENTITY ID') // you should put the entity id to WHOLESALE ENTITY ID
<?php $result = '<div class="price-box ' . $this->getData('css_classes') . '" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>' . $html . '</div>';
?>
return $result;
It is not working
– Sheenu
Jan 18 '18 at 12:02
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f209091%2fmagento-2-how-to-hide-the-price-for-guest-user-only-wholesale-group-user-can-se%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can hide the price by override the wrapResult function in vendor/magento/module-catalog/Pricing/Render/FinalPriceBox.php
app/code/Vendor/Module/etc/di.xml
<preference for="MagentoCatalogPricingRenderFinalPriceBox" type="VendorModulePricingRenderFinalPriceBox" />
app/code/Vendor/Module/Pricing/Render/FinalPriceBox.php
<?php
namespace VendorModulePricingRender;
use MagentoCatalogPricingPrice;
use MagentoFrameworkPricingRender;
use MagentoFrameworkPricingRenderPriceBox as BasePriceBox;
use MagentoMsrpPricingPriceMsrpPrice;
class FinalPriceBox extends MagentoCatalogPricingRenderFinalPriceBox
{
protected function wrapResult($html)
{
$result = '';
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$httpContext=$objectManager->get('MagentoFrameworkAppHttpContext');
$isLoggedIn=$httpContext->getValue(MagentoCustomerModelContext::CONTEXT_AUTH);
if($isLoggedIn){
$result = '<div class="price-box ' . $this->getData('css_classes') . '" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>' . $html . '</div>';
}
return $result;
}
}
Hello Vinz , i have tried your code it is not working
– Sheenu
Jan 18 '18 at 11:16
On which page do you need to hide the price ?
– Vinz
Jan 18 '18 at 13:43
i want to hide product list page, product details page and everywhere for guest user only login user with wholesale group can see price
– Sheenu
Jan 19 '18 at 10:34
@Vinz Does this solution also work with FPC? Won't it save the $isLoggedIn state of the first user that saves the FPC?
– Maarten Wolfsen
Jan 3 at 11:08
add a comment |
You can hide the price by override the wrapResult function in vendor/magento/module-catalog/Pricing/Render/FinalPriceBox.php
app/code/Vendor/Module/etc/di.xml
<preference for="MagentoCatalogPricingRenderFinalPriceBox" type="VendorModulePricingRenderFinalPriceBox" />
app/code/Vendor/Module/Pricing/Render/FinalPriceBox.php
<?php
namespace VendorModulePricingRender;
use MagentoCatalogPricingPrice;
use MagentoFrameworkPricingRender;
use MagentoFrameworkPricingRenderPriceBox as BasePriceBox;
use MagentoMsrpPricingPriceMsrpPrice;
class FinalPriceBox extends MagentoCatalogPricingRenderFinalPriceBox
{
protected function wrapResult($html)
{
$result = '';
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$httpContext=$objectManager->get('MagentoFrameworkAppHttpContext');
$isLoggedIn=$httpContext->getValue(MagentoCustomerModelContext::CONTEXT_AUTH);
if($isLoggedIn){
$result = '<div class="price-box ' . $this->getData('css_classes') . '" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>' . $html . '</div>';
}
return $result;
}
}
Hello Vinz , i have tried your code it is not working
– Sheenu
Jan 18 '18 at 11:16
On which page do you need to hide the price ?
– Vinz
Jan 18 '18 at 13:43
i want to hide product list page, product details page and everywhere for guest user only login user with wholesale group can see price
– Sheenu
Jan 19 '18 at 10:34
@Vinz Does this solution also work with FPC? Won't it save the $isLoggedIn state of the first user that saves the FPC?
– Maarten Wolfsen
Jan 3 at 11:08
add a comment |
You can hide the price by override the wrapResult function in vendor/magento/module-catalog/Pricing/Render/FinalPriceBox.php
app/code/Vendor/Module/etc/di.xml
<preference for="MagentoCatalogPricingRenderFinalPriceBox" type="VendorModulePricingRenderFinalPriceBox" />
app/code/Vendor/Module/Pricing/Render/FinalPriceBox.php
<?php
namespace VendorModulePricingRender;
use MagentoCatalogPricingPrice;
use MagentoFrameworkPricingRender;
use MagentoFrameworkPricingRenderPriceBox as BasePriceBox;
use MagentoMsrpPricingPriceMsrpPrice;
class FinalPriceBox extends MagentoCatalogPricingRenderFinalPriceBox
{
protected function wrapResult($html)
{
$result = '';
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$httpContext=$objectManager->get('MagentoFrameworkAppHttpContext');
$isLoggedIn=$httpContext->getValue(MagentoCustomerModelContext::CONTEXT_AUTH);
if($isLoggedIn){
$result = '<div class="price-box ' . $this->getData('css_classes') . '" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>' . $html . '</div>';
}
return $result;
}
}
You can hide the price by override the wrapResult function in vendor/magento/module-catalog/Pricing/Render/FinalPriceBox.php
app/code/Vendor/Module/etc/di.xml
<preference for="MagentoCatalogPricingRenderFinalPriceBox" type="VendorModulePricingRenderFinalPriceBox" />
app/code/Vendor/Module/Pricing/Render/FinalPriceBox.php
<?php
namespace VendorModulePricingRender;
use MagentoCatalogPricingPrice;
use MagentoFrameworkPricingRender;
use MagentoFrameworkPricingRenderPriceBox as BasePriceBox;
use MagentoMsrpPricingPriceMsrpPrice;
class FinalPriceBox extends MagentoCatalogPricingRenderFinalPriceBox
{
protected function wrapResult($html)
{
$result = '';
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$httpContext=$objectManager->get('MagentoFrameworkAppHttpContext');
$isLoggedIn=$httpContext->getValue(MagentoCustomerModelContext::CONTEXT_AUTH);
if($isLoggedIn){
$result = '<div class="price-box ' . $this->getData('css_classes') . '" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>' . $html . '</div>';
}
return $result;
}
}
answered Jan 11 '18 at 17:21
VinzVinz
401213
401213
Hello Vinz , i have tried your code it is not working
– Sheenu
Jan 18 '18 at 11:16
On which page do you need to hide the price ?
– Vinz
Jan 18 '18 at 13:43
i want to hide product list page, product details page and everywhere for guest user only login user with wholesale group can see price
– Sheenu
Jan 19 '18 at 10:34
@Vinz Does this solution also work with FPC? Won't it save the $isLoggedIn state of the first user that saves the FPC?
– Maarten Wolfsen
Jan 3 at 11:08
add a comment |
Hello Vinz , i have tried your code it is not working
– Sheenu
Jan 18 '18 at 11:16
On which page do you need to hide the price ?
– Vinz
Jan 18 '18 at 13:43
i want to hide product list page, product details page and everywhere for guest user only login user with wholesale group can see price
– Sheenu
Jan 19 '18 at 10:34
@Vinz Does this solution also work with FPC? Won't it save the $isLoggedIn state of the first user that saves the FPC?
– Maarten Wolfsen
Jan 3 at 11:08
Hello Vinz , i have tried your code it is not working
– Sheenu
Jan 18 '18 at 11:16
Hello Vinz , i have tried your code it is not working
– Sheenu
Jan 18 '18 at 11:16
On which page do you need to hide the price ?
– Vinz
Jan 18 '18 at 13:43
On which page do you need to hide the price ?
– Vinz
Jan 18 '18 at 13:43
i want to hide product list page, product details page and everywhere for guest user only login user with wholesale group can see price
– Sheenu
Jan 19 '18 at 10:34
i want to hide product list page, product details page and everywhere for guest user only login user with wholesale group can see price
– Sheenu
Jan 19 '18 at 10:34
@Vinz Does this solution also work with FPC? Won't it save the $isLoggedIn state of the first user that saves the FPC?
– Maarten Wolfsen
Jan 3 at 11:08
@Vinz Does this solution also work with FPC? Won't it save the $isLoggedIn state of the first user that saves the FPC?
– Maarten Wolfsen
Jan 3 at 11:08
add a comment |
Product Available Extension allows the store owner to hide the product price and add to cart button from guests or certain customer groups.
add a comment |
Product Available Extension allows the store owner to hide the product price and add to cart button from guests or certain customer groups.
add a comment |
Product Available Extension allows the store owner to hide the product price and add to cart button from guests or certain customer groups.
Product Available Extension allows the store owner to hide the product price and add to cart button from guests or certain customer groups.
answered Jan 11 '18 at 18:12
VitaliiVitalii
353139
353139
add a comment |
add a comment |
Adding my opinion to @Vinz answer, you should get logged-in customer group id
<?php $context = $objectManager->get('MagentoFrameworkAppHttpContext'); ?>
<?php $isLoggedIn = $context->getValue(MagentoCustomerModelContext::CONTEXT_AUTH); ?>
<?php $customerGroupId = $context->getValue(MagentoCustomerModelContext::CONTEXT_GROUP); ?>
<?php if($isLoggedIn && $customerGroupID == 'WHOLESALE ENTITY ID') // you should put the entity id to WHOLESALE ENTITY ID
<?php $result = '<div class="price-box ' . $this->getData('css_classes') . '" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>' . $html . '</div>';
?>
return $result;
It is not working
– Sheenu
Jan 18 '18 at 12:02
add a comment |
Adding my opinion to @Vinz answer, you should get logged-in customer group id
<?php $context = $objectManager->get('MagentoFrameworkAppHttpContext'); ?>
<?php $isLoggedIn = $context->getValue(MagentoCustomerModelContext::CONTEXT_AUTH); ?>
<?php $customerGroupId = $context->getValue(MagentoCustomerModelContext::CONTEXT_GROUP); ?>
<?php if($isLoggedIn && $customerGroupID == 'WHOLESALE ENTITY ID') // you should put the entity id to WHOLESALE ENTITY ID
<?php $result = '<div class="price-box ' . $this->getData('css_classes') . '" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>' . $html . '</div>';
?>
return $result;
It is not working
– Sheenu
Jan 18 '18 at 12:02
add a comment |
Adding my opinion to @Vinz answer, you should get logged-in customer group id
<?php $context = $objectManager->get('MagentoFrameworkAppHttpContext'); ?>
<?php $isLoggedIn = $context->getValue(MagentoCustomerModelContext::CONTEXT_AUTH); ?>
<?php $customerGroupId = $context->getValue(MagentoCustomerModelContext::CONTEXT_GROUP); ?>
<?php if($isLoggedIn && $customerGroupID == 'WHOLESALE ENTITY ID') // you should put the entity id to WHOLESALE ENTITY ID
<?php $result = '<div class="price-box ' . $this->getData('css_classes') . '" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>' . $html . '</div>';
?>
return $result;
Adding my opinion to @Vinz answer, you should get logged-in customer group id
<?php $context = $objectManager->get('MagentoFrameworkAppHttpContext'); ?>
<?php $isLoggedIn = $context->getValue(MagentoCustomerModelContext::CONTEXT_AUTH); ?>
<?php $customerGroupId = $context->getValue(MagentoCustomerModelContext::CONTEXT_GROUP); ?>
<?php if($isLoggedIn && $customerGroupID == 'WHOLESALE ENTITY ID') // you should put the entity id to WHOLESALE ENTITY ID
<?php $result = '<div class="price-box ' . $this->getData('css_classes') . '" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>' . $html . '</div>';
?>
return $result;
answered Jan 11 '18 at 22:14
3CE3CE
364213
364213
It is not working
– Sheenu
Jan 18 '18 at 12:02
add a comment |
It is not working
– Sheenu
Jan 18 '18 at 12:02
It is not working
– Sheenu
Jan 18 '18 at 12:02
It is not working
– Sheenu
Jan 18 '18 at 12:02
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f209091%2fmagento-2-how-to-hide-the-price-for-guest-user-only-wholesale-group-user-can-se%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown