Magento 2: How to hide the price for guest user only wholesale group user can see price












0















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 ?










share|improve this question



























    0















    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 ?










    share|improve this question

























      0












      0








      0








      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 ?










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 11 '18 at 14:26









      SheenuSheenu

      5711




      5711






















          3 Answers
          3






          active

          oldest

          votes


















          0














          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;
          }

          }





          share|improve this answer
























          • 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



















          0














          Product Available Extension allows the store owner to hide the product price and add to cart button from guests or certain customer groups.






          share|improve this answer































            0














            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;





            share|improve this answer
























            • It is not working

              – Sheenu
              Jan 18 '18 at 12:02











            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
            });


            }
            });














            draft saved

            draft discarded


















            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









            0














            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;
            }

            }





            share|improve this answer
























            • 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
















            0














            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;
            }

            }





            share|improve this answer
























            • 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














            0












            0








            0







            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;
            }

            }





            share|improve this answer













            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;
            }

            }






            share|improve this answer












            share|improve this answer



            share|improve this answer










            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



















            • 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













            0














            Product Available Extension allows the store owner to hide the product price and add to cart button from guests or certain customer groups.






            share|improve this answer




























              0














              Product Available Extension allows the store owner to hide the product price and add to cart button from guests or certain customer groups.






              share|improve this answer


























                0












                0








                0







                Product Available Extension allows the store owner to hide the product price and add to cart button from guests or certain customer groups.






                share|improve this answer













                Product Available Extension allows the store owner to hide the product price and add to cart button from guests or certain customer groups.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 11 '18 at 18:12









                VitaliiVitalii

                353139




                353139























                    0














                    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;





                    share|improve this answer
























                    • It is not working

                      – Sheenu
                      Jan 18 '18 at 12:02
















                    0














                    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;





                    share|improve this answer
























                    • It is not working

                      – Sheenu
                      Jan 18 '18 at 12:02














                    0












                    0








                    0







                    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;





                    share|improve this answer













                    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;






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jan 11 '18 at 22:14









                    3CE3CE

                    364213




                    364213













                    • 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





                    It is not working

                    – Sheenu
                    Jan 18 '18 at 12:02


















                    draft saved

                    draft discarded




















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    1300-talet

                    1300-talet

                    Display a custom attribute below product name in the front-end Magento 1.9.3.8