Magento 2.2.6 how to develope loggedin customer only show price in website
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I am using Magento 2.2.6 I need to customize and if any plugin available for logged-in customer show only price not show for guest user in Magento website. if anyone idea reply me. I have try to one module integrate but not hide price in listing and detail.
magento2 price product-view listing
add a comment |
I am using Magento 2.2.6 I need to customize and if any plugin available for logged-in customer show only price not show for guest user in Magento website. if anyone idea reply me. I have try to one module integrate but not hide price in listing and detail.
magento2 price product-view listing
Please review this question magento.stackexchange.com/questions/209091/… I hope it helps you.
– Raj
13 hours ago
@Raj I tried it but not working it
– Rv Singh
13 hours ago
add a comment |
I am using Magento 2.2.6 I need to customize and if any plugin available for logged-in customer show only price not show for guest user in Magento website. if anyone idea reply me. I have try to one module integrate but not hide price in listing and detail.
magento2 price product-view listing
I am using Magento 2.2.6 I need to customize and if any plugin available for logged-in customer show only price not show for guest user in Magento website. if anyone idea reply me. I have try to one module integrate but not hide price in listing and detail.
magento2 price product-view listing
magento2 price product-view listing
edited 11 hours ago
Kirti Nariya
1,081415
1,081415
asked 14 hours ago
Rv SinghRv Singh
696417
696417
Please review this question magento.stackexchange.com/questions/209091/… I hope it helps you.
– Raj
13 hours ago
@Raj I tried it but not working it
– Rv Singh
13 hours ago
add a comment |
Please review this question magento.stackexchange.com/questions/209091/… I hope it helps you.
– Raj
13 hours ago
@Raj I tried it but not working it
– Rv Singh
13 hours ago
Please review this question magento.stackexchange.com/questions/209091/… I hope it helps you.
– Raj
13 hours ago
Please review this question magento.stackexchange.com/questions/209091/… I hope it helps you.
– Raj
13 hours ago
@Raj I tried it but not working it
– Rv Singh
13 hours ago
@Raj I tried it but not working it
– Rv Singh
13 hours ago
add a comment |
1 Answer
1
active
oldest
votes
You need to override price renderer.
First, create a sample module. We consider here "Stackoverflow_Answer"
Create etc/di.xml and put below code
<preference for="MagentoCatalogPricingRenderFinalPriceBox" type="StackoverflowAnswerPricingRenderFinalPriceBox" />
<preference for="MagentoConfigurableProductPricingRenderFinalPriceBox" type="StackoverflowAnswerPricingRenderFinalPriceBox" />
Now created FinalPriceBox.php under Pricing/Render folder and put below code.
<?php
namespace StackoverflowAnswerPricingRender;
use MagentoCatalogPricingPrice;
use MagentoFrameworkPricingRender;
use MagentoFrameworkPricingRenderPriceBox as BasePriceBox;
use MagentoMsrpPricingPriceMsrpPrice;
class FinalPriceBox extends MagentoCatalogPricingRenderFinalPriceBox
{
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoFrameworkPricingSaleableInterface $saleableItem,
MagentoFrameworkPricingPricePriceInterface $price,
MagentoFrameworkPricingRenderRendererPool $rendererPool,
array $data = ,
MagentoCatalogModelProductPricingRendererSalableResolverInterface $salableResolver = null,
MagentoCatalogPricingPriceMinimalPriceCalculatorInterface $minimalPriceCalculator = null
) {
parent::__construct($context,
$saleableItem,
$price,
$rendererPool,
$data,
$salableResolver,
$minimalPriceCalculator);
}
protected function wrapResult($html)
{
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$httpContext = $objectManager->get('MagentoFrameworkAppHttpContext');
$isLoggedIn = $httpContext->getValue(MagentoCustomerModelContext::CONTEXT_AUTH);
if($isLoggedIn){
return '<div class="price-box ' . $this->getData('css_classes') . '" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>' . $html . '</div>';
}else{
$wording = 'Please Login To See Price';
return '<div class="" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>'.$wording.'</div>';
}
}
}
I had the same task yesterday, it works. Let me know if you face any issue.
Not working i m tried same code but not reflect on listing page and detail page
– Rv Singh
11 hours ago
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%2f268932%2fmagento-2-2-6-how-to-develope-loggedin-customer-only-show-price-in-website%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to override price renderer.
First, create a sample module. We consider here "Stackoverflow_Answer"
Create etc/di.xml and put below code
<preference for="MagentoCatalogPricingRenderFinalPriceBox" type="StackoverflowAnswerPricingRenderFinalPriceBox" />
<preference for="MagentoConfigurableProductPricingRenderFinalPriceBox" type="StackoverflowAnswerPricingRenderFinalPriceBox" />
Now created FinalPriceBox.php under Pricing/Render folder and put below code.
<?php
namespace StackoverflowAnswerPricingRender;
use MagentoCatalogPricingPrice;
use MagentoFrameworkPricingRender;
use MagentoFrameworkPricingRenderPriceBox as BasePriceBox;
use MagentoMsrpPricingPriceMsrpPrice;
class FinalPriceBox extends MagentoCatalogPricingRenderFinalPriceBox
{
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoFrameworkPricingSaleableInterface $saleableItem,
MagentoFrameworkPricingPricePriceInterface $price,
MagentoFrameworkPricingRenderRendererPool $rendererPool,
array $data = ,
MagentoCatalogModelProductPricingRendererSalableResolverInterface $salableResolver = null,
MagentoCatalogPricingPriceMinimalPriceCalculatorInterface $minimalPriceCalculator = null
) {
parent::__construct($context,
$saleableItem,
$price,
$rendererPool,
$data,
$salableResolver,
$minimalPriceCalculator);
}
protected function wrapResult($html)
{
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$httpContext = $objectManager->get('MagentoFrameworkAppHttpContext');
$isLoggedIn = $httpContext->getValue(MagentoCustomerModelContext::CONTEXT_AUTH);
if($isLoggedIn){
return '<div class="price-box ' . $this->getData('css_classes') . '" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>' . $html . '</div>';
}else{
$wording = 'Please Login To See Price';
return '<div class="" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>'.$wording.'</div>';
}
}
}
I had the same task yesterday, it works. Let me know if you face any issue.
Not working i m tried same code but not reflect on listing page and detail page
– Rv Singh
11 hours ago
add a comment |
You need to override price renderer.
First, create a sample module. We consider here "Stackoverflow_Answer"
Create etc/di.xml and put below code
<preference for="MagentoCatalogPricingRenderFinalPriceBox" type="StackoverflowAnswerPricingRenderFinalPriceBox" />
<preference for="MagentoConfigurableProductPricingRenderFinalPriceBox" type="StackoverflowAnswerPricingRenderFinalPriceBox" />
Now created FinalPriceBox.php under Pricing/Render folder and put below code.
<?php
namespace StackoverflowAnswerPricingRender;
use MagentoCatalogPricingPrice;
use MagentoFrameworkPricingRender;
use MagentoFrameworkPricingRenderPriceBox as BasePriceBox;
use MagentoMsrpPricingPriceMsrpPrice;
class FinalPriceBox extends MagentoCatalogPricingRenderFinalPriceBox
{
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoFrameworkPricingSaleableInterface $saleableItem,
MagentoFrameworkPricingPricePriceInterface $price,
MagentoFrameworkPricingRenderRendererPool $rendererPool,
array $data = ,
MagentoCatalogModelProductPricingRendererSalableResolverInterface $salableResolver = null,
MagentoCatalogPricingPriceMinimalPriceCalculatorInterface $minimalPriceCalculator = null
) {
parent::__construct($context,
$saleableItem,
$price,
$rendererPool,
$data,
$salableResolver,
$minimalPriceCalculator);
}
protected function wrapResult($html)
{
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$httpContext = $objectManager->get('MagentoFrameworkAppHttpContext');
$isLoggedIn = $httpContext->getValue(MagentoCustomerModelContext::CONTEXT_AUTH);
if($isLoggedIn){
return '<div class="price-box ' . $this->getData('css_classes') . '" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>' . $html . '</div>';
}else{
$wording = 'Please Login To See Price';
return '<div class="" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>'.$wording.'</div>';
}
}
}
I had the same task yesterday, it works. Let me know if you face any issue.
Not working i m tried same code but not reflect on listing page and detail page
– Rv Singh
11 hours ago
add a comment |
You need to override price renderer.
First, create a sample module. We consider here "Stackoverflow_Answer"
Create etc/di.xml and put below code
<preference for="MagentoCatalogPricingRenderFinalPriceBox" type="StackoverflowAnswerPricingRenderFinalPriceBox" />
<preference for="MagentoConfigurableProductPricingRenderFinalPriceBox" type="StackoverflowAnswerPricingRenderFinalPriceBox" />
Now created FinalPriceBox.php under Pricing/Render folder and put below code.
<?php
namespace StackoverflowAnswerPricingRender;
use MagentoCatalogPricingPrice;
use MagentoFrameworkPricingRender;
use MagentoFrameworkPricingRenderPriceBox as BasePriceBox;
use MagentoMsrpPricingPriceMsrpPrice;
class FinalPriceBox extends MagentoCatalogPricingRenderFinalPriceBox
{
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoFrameworkPricingSaleableInterface $saleableItem,
MagentoFrameworkPricingPricePriceInterface $price,
MagentoFrameworkPricingRenderRendererPool $rendererPool,
array $data = ,
MagentoCatalogModelProductPricingRendererSalableResolverInterface $salableResolver = null,
MagentoCatalogPricingPriceMinimalPriceCalculatorInterface $minimalPriceCalculator = null
) {
parent::__construct($context,
$saleableItem,
$price,
$rendererPool,
$data,
$salableResolver,
$minimalPriceCalculator);
}
protected function wrapResult($html)
{
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$httpContext = $objectManager->get('MagentoFrameworkAppHttpContext');
$isLoggedIn = $httpContext->getValue(MagentoCustomerModelContext::CONTEXT_AUTH);
if($isLoggedIn){
return '<div class="price-box ' . $this->getData('css_classes') . '" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>' . $html . '</div>';
}else{
$wording = 'Please Login To See Price';
return '<div class="" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>'.$wording.'</div>';
}
}
}
I had the same task yesterday, it works. Let me know if you face any issue.
You need to override price renderer.
First, create a sample module. We consider here "Stackoverflow_Answer"
Create etc/di.xml and put below code
<preference for="MagentoCatalogPricingRenderFinalPriceBox" type="StackoverflowAnswerPricingRenderFinalPriceBox" />
<preference for="MagentoConfigurableProductPricingRenderFinalPriceBox" type="StackoverflowAnswerPricingRenderFinalPriceBox" />
Now created FinalPriceBox.php under Pricing/Render folder and put below code.
<?php
namespace StackoverflowAnswerPricingRender;
use MagentoCatalogPricingPrice;
use MagentoFrameworkPricingRender;
use MagentoFrameworkPricingRenderPriceBox as BasePriceBox;
use MagentoMsrpPricingPriceMsrpPrice;
class FinalPriceBox extends MagentoCatalogPricingRenderFinalPriceBox
{
public function __construct(
MagentoFrameworkViewElementTemplateContext $context,
MagentoFrameworkPricingSaleableInterface $saleableItem,
MagentoFrameworkPricingPricePriceInterface $price,
MagentoFrameworkPricingRenderRendererPool $rendererPool,
array $data = ,
MagentoCatalogModelProductPricingRendererSalableResolverInterface $salableResolver = null,
MagentoCatalogPricingPriceMinimalPriceCalculatorInterface $minimalPriceCalculator = null
) {
parent::__construct($context,
$saleableItem,
$price,
$rendererPool,
$data,
$salableResolver,
$minimalPriceCalculator);
}
protected function wrapResult($html)
{
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$httpContext = $objectManager->get('MagentoFrameworkAppHttpContext');
$isLoggedIn = $httpContext->getValue(MagentoCustomerModelContext::CONTEXT_AUTH);
if($isLoggedIn){
return '<div class="price-box ' . $this->getData('css_classes') . '" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>' . $html . '</div>';
}else{
$wording = 'Please Login To See Price';
return '<div class="" ' .
'data-role="priceBox" ' .
'data-product-id="' . $this->getSaleableItem()->getId() . '"' .
'>'.$wording.'</div>';
}
}
}
I had the same task yesterday, it works. Let me know if you face any issue.
answered 12 hours ago
Amitkumar solankiAmitkumar solanki
443213
443213
Not working i m tried same code but not reflect on listing page and detail page
– Rv Singh
11 hours ago
add a comment |
Not working i m tried same code but not reflect on listing page and detail page
– Rv Singh
11 hours ago
Not working i m tried same code but not reflect on listing page and detail page
– Rv Singh
11 hours ago
Not working i m tried same code but not reflect on listing page and detail page
– Rv Singh
11 hours ago
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%2f268932%2fmagento-2-2-6-how-to-develope-loggedin-customer-only-show-price-in-website%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
Please review this question magento.stackexchange.com/questions/209091/… I hope it helps you.
– Raj
13 hours ago
@Raj I tried it but not working it
– Rv Singh
13 hours ago