0

In my file

app/design/frontend/Eadesignro/a1turbo/Magento_Catalog/templates/product/view/attribute.phtml

I have to test if user is logged and if he is a b2b user. I test if user is logged with these lines of code:

$_loggedin = $this->helper('Magento\Checkout\Helper\Cart')->getCart()->getCustomerSession()->isLoggedIn();
if( $_loggedin )
    echo 'LOGGED';
    else echo 'NOT LOGGED';

But how can I check if the user is a b2b user? thank you!

3
  • B2B is customer group here ? Commented Nov 29, 2019 at 13:21
  • yes,B2B is customer group Commented Nov 29, 2019 at 13:33
  • Check my answer and let me know if you need any help there then. Commented Nov 29, 2019 at 13:34

1 Answer 1

3

You can use below line in your phtml to get customer's group ID

<?php $customerGroupId = $this->helper('Magento\Checkout\Helper\Cart')->getCart()->getCustomerSession()->getCustomerGroupId(); ?>

You can check B2B customer's group ID in backend and you can add condition based on that ID.

Hope this will work for you!

2
  • 1
    thank you so much! Commented Nov 29, 2019 at 14:02
  • You're welcome Buddy 😊👍 Commented Nov 29, 2019 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.