Announcement

Collapse
No announcement yet.

Editing Customer Fields

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

    Editing Customer Fields

    We have a need to have different customer fields for retail vs an availability group.

    The availability group only needs to checkout using:

    Name
    Title
    Phone
    Email

    They only need the info once - not for shipping and billing.

    For retail they need the traditional setup.

    So how can we setup different fields for an availability group vs retail?

    #2
    Re: Editing Customer Fields

    Hello,

    This can be accomplished by customizing some of the template code to conditionally serve template code to people signed into an availability group account that is different then those who are not.

    If you have toolkit installed in your store this can be done fairly easily using the agroup function along with some simple conditional statements. Here is a code example:
    Code:
    <mvt:item name="toolkit" param="agroup|acount" />
    <mvt:if expr="g.acount GT 0">
    <mvt:foreach iterator="customer_agroup" array="customer_agroups">
        <mvt:if expr="l.settings:customer_agroup:name EQ 'YOUR_GROUP_NAME_HERE'">
            <mvt:item name="toolkit" param="sassign|ingroup|true" /> 
        <mvt:else>
            <mvt:item name="toolkit" param="sassign|ingroup|false" /> 
        </mvt:if>
    </mvt:foreach>
    </mvt:if>
    
    <mvt:if expr="g.ingroup EQ 'true'">
        CODE FOR AVAILABILITY GROUP HERE
    <mvt:else>
        CODE FOR EVERYONE ELSE HERE
    </mvt:if>
    If you do not have toolkit, you can still accomplish this using the mv:do function that is built into the engine. The code is a little more complicated, but here is the same idea as above, but using that code:

    Code:
    <mvt:comment><!-- Check if Customer is in availability group --></mvt:comment>
        <mvt:if expr="g.Basket:cust_id">
            <mvt:do name="l.result" file="g.Module_Feature_AGR_DB" value="AvailabilityGroup_Load_Name( 'YOUR_GROUP_NAME_HERE', l.availgroup )" />
            <mvt:if expr="l.result">
                <mvt:do name="l.exists" file="g.Module_Feature_AGR_DB" value="AvailGroupXCustomer_Load( l.availgroup:id, g.Basket:cust_id, l.null )" />
                <mvt:if expr="l.exists">
                    <mvt:assign name="g.basket:customer:ingroup" value="1" />
                </mvt:if>
            </mvt:if>
        </mvt:if>
    
    <mvt:if expr="g.basket:customer:ingroup">
        AVAILABILITY GROUP CODE HERE
    <mvt:else>
        CODE FOR EVERYONE ELSE
    </mvt:if>
    Either of those code snippets depending on your set up will allow you to conditionally display things for an availability group that are different then what everyone else sees. In your specific case, you can put the template code for your customer fields in the section for CODE FOR EVERYONE ELSE, and place a modified version of the customer field code that only includes the fields you want to show in the section for AVAILABILITY GROUP CODE HERE.

    One thing to keep in mind is depending on your store's settings, some of the fields you are looking to hide may be set to required in your admin. In that case you will either want to make those fields not required, or pass filler data for those fields using hidden inputs in your code.

    Hope this helps!

    - Joe

    Comment


      #3
      Re: Editing Customer Fields

      Thanks Joe! - I was trying to figure out the MVT:DO code for availability groups for something else on the same site for awhile and couldn't figure it out.

      It is working great in my basic test - my only question is how can I get it to work to check for 4 availability groups? I tried doing an OR and it didn't work:
      Code:
      <mvt:do name="l.result" file="g.Module_Feature_AGR_DB" value="AvailabilityGroup_Load_Name( 'Availability 1' OR 'Availability 2', l.availgroup )" />
      I also tried repeating the line 4 times and it didn't work either:
      Code:
      <mvt:do name="l.result" file="g.Module_Feature_AGR_DB" value="AvailabilityGroup_Load_Name( 'Availability 1', l.availgroup )" />	<mvt:do name="l.result" file="g.Module_Feature_AGR_DB" value="AvailabilityGroup_Load_Name( 'Availability 2', l.availgroup )" />
      	<mvt:do name="l.result" file="g.Module_Feature_AGR_DB" value="AvailabilityGroup_Load_Name( 'Availability 3', l.availgroup )" />
      	<mvt:do name="l.result" file="g.Module_Feature_AGR_DB" value="AvailabilityGroup_Load_Name( 'Availability 4', l.availgroup )" />

      Comment


        #4
        Re: Editing Customer Fields

        To check multiple availability groups you would need to duplicate the block of code that sets the g.basket:customer:ingroup variable. Something like this should do it:

        Code:
        <mvt:if expr="g.Basket:cust_id">
            <mvt:comment><!-- Check Group 1 --></mvt:comment>
            <mvt:do name="l.result" file="g.Module_Feature_AGR_DB" value="AvailabilityGroup_Load_Name( 'Availability 1', l.availgroup )" />
            <mvt:if expr="l.result">
                <mvt:do name="l.exists" file="g.Module_Feature_AGR_DB" value="AvailGroupXCustomer_Load( l.availgroup:id, g.Basket:cust_id, l.null )" />
                <mvt:if expr="l.exists">
                    <mvt:assign name="g.basket:customer:ingroup" value="1" />
                </mvt:if>
            </mvt:if>
        
            <mvt:comment><!-- Check Group 2 --></mvt:comment>
            <mvt:do name="l.result" file="g.Module_Feature_AGR_DB" value="AvailabilityGroup_Load_Name( 'Availability 2', l.availgroup )" />
            <mvt:if expr="l.result">
                <mvt:do name="l.exists" file="g.Module_Feature_AGR_DB" value="AvailGroupXCustomer_Load( l.availgroup:id, g.Basket:cust_id, l.null )" />
                <mvt:if expr="l.exists">
                    <mvt:assign name="g.basket:customer:ingroup" value="1" />
                </mvt:if>
            </mvt:if>
        
            <mvt:comment><!-- Check Group 3 --></mvt:comment>
            <mvt:do name="l.result" file="g.Module_Feature_AGR_DB" value="AvailabilityGroup_Load_Name( 'Availability 3', l.availgroup )" />
            <mvt:if expr="l.result">
                <mvt:do name="l.exists" file="g.Module_Feature_AGR_DB" value="AvailGroupXCustomer_Load( l.availgroup:id, g.Basket:cust_id, l.null )" />
                <mvt:if expr="l.exists">
                    <mvt:assign name="g.basket:customer:ingroup" value="1" />
                </mvt:if>
            </mvt:if>
        </mvt:if>
        What this will do is check each availability group separately. If a customer is assigned to any of them it will set your g.basket:customer:ingroup variable to be 1. Otherwise that variable will not be set. From there the second part of the code would remain the same:

        Code:
        <mvt:if expr="g.basket:customer:ingroup">
            AVAILABILITY GROUP CODE HERE
        <mvt:else>
            CODE FOR EVERYONE ELSE
        </mvt:if>

        Comment


          #5
          Re: Editing Customer Fields

          Thanks so much again! Is there some place that references how to use all miva functions more specifically?

          Comment

          Working...
          X