We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50664
    • 4 Posts
    I'm very new to ModX and I'm trying to figure this out, but I'm stumped and my Google-Foo is failing me. I am building a store for a friend of mine and she wants to be able to offer wholesale pricing to people who're logged in and default consumer pricing if they aren't.

    I have the default price in a TV and I was going to create a new TV for Wholesale pricing, but I don't know how to only display one or the other if the user is logged in. Is this possible?

    I found the code here: https://rtfm.modx.com/revolution/2.x/developing-in-modx/other-development-resources/class-reference/moduser/moduser.ismember for figuring out if they are a member of a group, but I think that's snippet code and I don't know how to use it to do what I'm trying to do in my chunk.

    Any help would be appreciated.

    This question has been answered by BobRay. See the first response.

      • 42562
      • 1,145 Posts
      in your /manager/?a=element/snippet/create

      name isLegitMember
      code
      <?php
      $user = $modx->getObject('modUser', array('id' => $modx->user->get('id'))); // get present user infos
      if ($user) {
        if ($user->isMember(array($group))) {
          $page = $modx->getObject('modResource', $pageId);
          return $page->getTVValue($tv);
        }
      }


      In your HTML template or particular resource, make this call
      [[!isLegitMember? &pageId=`[[*id]]` &group=`Administrator` &tv=`wholeSale`]]
        TinymceWrapper: Complete back/frontend content solution.
        Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
        5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
      • discuss.answer
        • 3749
        • 24,544 Posts
        This should also do it if you have the Personalize extra installed. Put this tag where you want the price to appear:

        [[!Personalize?
            &yesChunk=`@CODE:[[*Wholesale]]`
            &noChunk=`@CODE:[[*Retail]]`
            &allowedGroups=`Administrator,customer`
        ]]


        Wholesale and Retail are the names of TVs holding the wholesale or retail price. Only members of a group listed in &allowedGroups can see the wholesale price.

          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 50664
          • 4 Posts
          Quote from: BobRay at Sep 22, 2015, 07:35 AM
          This should also do it if you have the Personalize extra installed. Put this tag where you want the price to appear:

          [[!Personalize?
              &yesChunk=`@CODE:[[*Wholesale]]`
              &noChunk=`@CODE:[[*Retail]]`
              &allowedGroups=`Administrator,customer`
          ]]


          Wholesale and Retail are the names of TVs holding the wholesale or retail price. Only members of a group listed in &allowedGroups can see the wholesale price.


          This is exactly what I was looking for. Is this written somewhere in the documentation where I can read up and learn more?
            • Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org