Announcement

Collapse
No announcement yet.

Price Group Conditional Test

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Price Group Conditional Test

    I was able to setup a conditional to test for a price group using the following:

    Code:
    <mvt:if expr="g.customer:pgrpcount GT 0">Something
            <mvt:else>Something else</mvt:if>
    But it only tests if the user is in at least one price group.

    Is there a way to test if a user is in specific price groups so I can list them?

    #2
    Re: Price Group Conditional Test

    You need an array to get all the price groups.
    This is using Toolkit.

    Code:
    <mvt:item name="toolkit" param="pgroup|pcount" />
    <mvt:if expr="g.pcount GT 0">
            <mvt:foreach iterator="customer_pgroup" array="customer_pgroups">
                <mvt:if expr="l.settings:customer_pgroup:name EQ 'wholesale'">
    
                Do something
    
                </mvt:if>
            </mvt:foreach>
    <mvt:else>
    
    Do something else
    
    </mvt:if>

    Comment


      #3
      Re: Price Group Conditional Test

      Thanks for your solution. Is the only way to do this through toolkit? We currently don't have toolkit on this store, and was hoping to not have to purchase it for something simple.

      Comment


        #4
        Re: Price Group Conditional Test

        You could do something like this using mvt:do which does not need toolkit

        Code:
        <mvt:do name="g.count" file="g.Module_Feature_PGR_DB" value="PriceGroupAndModuleList_Load_Customer( g.basket:cust_id, g.PriceGroups )" />
        
        <mvt:if expr="l.count GT 0">
                <mvt:foreach iterator="customer_pgroup" array="global:PriceGroups">
                    <mvt:if expr="l.settings:customer_pgroup:name EQ 'wholesale'">
        
        
                    Do something
        
        
                    </mvt:if>
                </mvt:foreach>
        <mvt:else>
        
        
        Do something else
        
        
        </mvt:if>
        Brennan Heyde
        VP Product
        Miva, Inc.
        [email protected]
        https://www.miva.com

        Comment


          #5
          Re: Price Group Conditional Test

          Thanks Brennan. For some reason this isn't working - it will only trigger the 'do something else' not the 'do something'. I replace 'wholesale' with 'Wholesale Florida' since that is the name of one of my price groups. And I am logged in as a customer that is a member of it.

          Comment


            #6
            Re: Price Group Conditional Test

            For further clarification, this is the exact code I am using on the BASK page to show the proper price in the basket depending on what price group (if any) a customer is in:

            Code:
            <mvt:do name="g.count" file="g.Module_Feature_PGR_DB" value="PriceGroupAndModuleList_Load_Customer( g.basket:cust_id, g.PriceGroups )" />
            
            <mvt:if expr="l.count GT 0">
                    <mvt:foreach iterator="customer_pgroup" array="global:PriceGroups">
                        <mvt:if expr="l.settings:customer_pgroup:name EQ 'Wholesale Florida'">&mvt:group:formatted_price;
                    </mvt:if>
                    </mvt:foreach><mvt:else>&mvt:group:formatted_base_price;</mvt:if>

            Comment


              #7
              Re: Price Group Conditional Test

              g.count NE l.count...change l.count to g.count...


              and just for the sake of education (as opposed to copying/pasting)...probably better to use a variable like:

              g.baskPriceGroupTestCount


              Global variables persist throughout the page and any function from that point on, its quite possible that some other test or function would have a g.count variable. So, when you see that type of variable in an example, its best to explicitly change it...especially if you are using two example functions :)
              Last edited by Bruce - PhosphorMedia; 06-25-15, 10:24 AM.
              Bruce Golub
              Phosphor Media - "Your Success is our Business"

              Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
              phosphormedia.com

              Comment


                #8
                Re: Price Group Conditional Test

                Thanks Bruce! It is working great.

                Comment


                  #9
                  Re: Price Group Conditional Test

                  Along those same lines I now need to do a conditional for an availability group. But I just don't know the right way to do it. I have tried several variations just trying to plug in values so I am sure this is way off:
                  Code:
                  <mvt:do name="g.availgcount" file="g.Module_Feature_AGR_DB" value="AvailabilityGroupAndModuleList_Load_Customer( g.basket:cust_id, g.AvailabilityGroups )" />
                  
                  <mvt:if expr="g.availgcount GT 0">
                          <mvt:foreach iterator="customer_agroup" array="global:AvailabilityGroups">
                              <mvt:if expr="l.settings:customer_agroup:name EQ 'Availability Group'"><a href="">Availability Group</a>
                          </mvt:if>
                          </mvt:foreach><mvt:else>Nothing</mvt:if>

                  Comment


                    #10
                    Re: Price Group Conditional Test

                    Does anybody know how to accomplish the above conditional for availability groups? Thanks,

                    Comment


                      #11
                      Re: Price Group Conditional Test

                      Not off hand, but that's not a correct function...if I remember correctly, you actually need two functions to get the availability name. Sorry, bit behind on some other client dev work ATM.
                      Bruce Golub
                      Phosphor Media - "Your Success is our Business"

                      Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                      phosphormedia.com

                      Comment


                        #12
                        Re: Price Group Conditional Test

                        I made a couple modifications based on some research I did in trying to find the correct function and came up with the following that is of course not working. This store does not have toolkit:

                        Code:
                        <mvt:do name="g.availgcount" file="g.Module_Feature_AGR_DB" value="AvailGroupXCustomer_Load( g.basket:agrp_id, g.basket:cust_id, availgroupxcustomer )" />
                        
                        <mvt:if expr="g.availgcount GT 0">
                                <mvt:foreach iterator="customer_agroup" array="global:AvailabilityGroups">
                                    <mvt:if expr="l.settings:customer_agroup:name EQ 'Volusia County Corrections'"><a href="">Volusia County Corrections</a>
                                </mvt:if>
                                </mvt:foreach><mvt:else>Nothing</mvt:if>

                        Comment


                          #13
                          Re: Price Group Conditional Test

                          couple of things off the top of my head...when used in an expression, you need to use the normalize variable name. For example, g.availablilitygroups.

                          also you should scope the variable when assigning it. personally, i'd stick with local unless you really need a global, so in the mvdo, use l.settings:variable (you can then use the marco expression &mvt;variablename;)
                          Bruce Golub
                          Phosphor Media - "Your Success is our Business"

                          Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
                          phosphormedia.com

                          Comment

                          Working...
                          X