Customer Custom Fields

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lesliekirk
    Super Moderator











    • Aug 2008
    • 9291

    #1

    Customer Custom Fields

    My custom field condition foo is weak. I would like to be able to check to see if any customer might have a Customer Custom Field and then if it does be able to display the content of that field in the Printable Invoice used in the batch reports.

    I'm trying to display a message for someone processing the order that a customer may have specific needs such as drop shipping, special labels, etc. This would be a constant that the customer should not have to enter in the Order Information type custom field. It would not be part of the checkout process but retained in the Customer Information.
    Leslie Kirk
    Miva Certified Developer
    Miva Merchant Specialist since 1997
    Previously of Webs Your Way
    (aka Leslie Nord leslienord)

    Email me: [email protected]
    www.lesliekirk.com

    Follow me: X | Facebook | Pinterest
  • Nick
    Super Moderator











    • Dec 2011
    • 575

    #2
    You could add this to the Printable Invoice template:

    Code:
    <mvt:do file="l.customfields_module:module" name="l.success" value="CustomerFieldValue_Load_CodeAndCustomer( 'customer_customfield_code', l.settings:order:cust_id, l.settings:customer_customfield_code:field, l.settings:customer_customfield_code:value )" />
    <mvt:if expr="l.settings:customer_customfield_code:value">
        &mvt:customer_customfield_code:value;
    </mvt:if>
    This will pull the value for the customer custom field and output if it is available.

    Let me know if you have trouble implementing.
    Nicholas Adkins
    Technical Training Specialist / Miva, Inc.
    [email protected]
    https://www.miva.com/mivalearn

    Comment

    • Kent Multer
      Mega Mivite









      • Mar 2006
      • 3251

      #3
      Hi Nick,
      Is there some reason why the usual mvt:item tag won't work on this template? E.g.
      Code:
      <mvt:item name="customfields" param="Read_Customer_ID( g.Customer:id, 'custom_field_code', l.settings:MyDestination )" />
      Kent Multer
      Magic Metal Productions
      http://TheMagicM.com
      * Web developer/designer
      * E-commerce and Miva
      * Author, The Official Miva Web Scripting Book -- available on-line:
      http://www.amazon.com/exec/obidos/IS...icmetalproducA

      Comment

      • Nick
        Super Moderator











        • Dec 2011
        • 575

        #4
        Kent Multer No the only caveat with using the item tag is that you need to assign the item to the template. I was just being lazy and did not want to explain assigning the item to the template.
        Nicholas Adkins
        Technical Training Specialist / Miva, Inc.
        [email protected]
        https://www.miva.com/mivalearn

        Comment

        • Bruce - PhosphorMedia
          Developer Partner











          • Mar 2006
          • 11256

          #5
          totally apropos of nothing, and this may be totally outside your realm, but why is the primary key 'l.settings:order:cust_id' not first? (otherwise, cool API call to know about).
          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

          • Nick
            Super Moderator











            • Dec 2011
            • 575

            #6
            Bruce - PhosphorMedia I do not think there is a specific reason but if I were to guess it would be because of the name of the function: CustomerFieldValue_Load_CodeAndCustomer

            Code comes first in the order of the name.
            Nicholas Adkins
            Technical Training Specialist / Miva, Inc.
            [email protected]
            https://www.miva.com/mivalearn

            Comment

            • Bruce - PhosphorMedia
              Developer Partner











              • Mar 2006
              • 11256

              #7
              well, that makes some sense. and as much as i try to keep my own code 'syntax' orthogonal, i have many a 'bad' moment.
              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

              • lesliekirk
                Super Moderator











                • Aug 2008
                • 9291

                #8
                Originally posted by Nick View Post
                You could add this to the Printable Invoice template:

                Code:
                <mvt:do file="l.customfields_module:module" name="l.success" value="CustomerFieldValue_Load_CodeAndCustomer( 'customer_customfield_code', l.settings:order:cust_id, l.settings:customer_customfield_code:field, l.settings:customer_customfield_code:value )" />
                <mvt:if expr="l.settings:customer_customfield_code:value">
                &mvt:customer_customfield_code:value;
                </mvt:if>
                This will pull the value for the customer custom field and output if it is available.

                Let me know if you have trouble implementing.
                It didn't seem to pull anything in.
                Leslie Kirk
                Miva Certified Developer
                Miva Merchant Specialist since 1997
                Previously of Webs Your Way
                (aka Leslie Nord leslienord)

                Email me: [email protected]
                www.lesliekirk.com

                Follow me: X | Facebook | Pinterest

                Comment

                • Nick
                  Super Moderator











                  • Dec 2011
                  • 575

                  #9
                  Originally posted by lesliekirk View Post

                  It didn't seem to pull anything in.
                  Can you show me what you added? Are you sure the variables customer ID and custom field are correct?
                  Nicholas Adkins
                  Technical Training Specialist / Miva, Inc.
                  [email protected]
                  https://www.miva.com/mivalearn

                  Comment

                  • lesliekirk
                    Super Moderator











                    • Aug 2008
                    • 9291

                    #10
                    Do I have to specify a single customer ID? If so, this isn't going to work the way I'd like it to.

                    Leslie Kirk
                    Miva Certified Developer
                    Miva Merchant Specialist since 1997
                    Previously of Webs Your Way
                    (aka Leslie Nord leslienord)

                    Email me: [email protected]
                    www.lesliekirk.com

                    Follow me: X | Facebook | Pinterest

                    Comment

                    • Nick
                      Super Moderator











                      • Dec 2011
                      • 575

                      #11
                      Originally posted by lesliekirk View Post
                      Do I have to specify a single customer ID? If so, this isn't going to work the way I'd like it to.
                      No you can use a variable, what is the variable you are using?
                      Nicholas Adkins
                      Technical Training Specialist / Miva, Inc.
                      [email protected]
                      https://www.miva.com/mivalearn

                      Comment

                      • lesliekirk
                        Super Moderator











                        • Aug 2008
                        • 9291

                        #12
                        Originally posted by Nick View Post

                        No you can use a variable, what is the variable you are using?
                        My Custom Customer Field code is "test"

                        Code:
                        <mvt:do file="l.customfields_module:module" name="l.success" value="CustomerFieldValue_Load_CodeAndCustomer( 'test', l.settings:order:cust_id, l.settings:customer_customfield_code:field, l.settings:customer_customfield_code:value )" />
                        <mvt:if expr="l.settings:customer_customfield_code:value"> &mvt:customer_customfield_code:value; </mvt:if>
                        Leslie Kirk
                        Miva Certified Developer
                        Miva Merchant Specialist since 1997
                        Previously of Webs Your Way
                        (aka Leslie Nord leslienord)

                        Email me: [email protected]
                        www.lesliekirk.com

                        Follow me: X | Facebook | Pinterest

                        Comment

                        • Kent Multer
                          Mega Mivite









                          • Mar 2006
                          • 3251

                          #13
                          Just guessing here, but: for the above code snippet, does the variable l.customfields_module:module have a value? It looks to me like either it needs to be initialized, or maybe it's supposed to be "l.settings:..." instead of just "l...."
                          Kent Multer
                          Magic Metal Productions
                          http://TheMagicM.com
                          * Web developer/designer
                          * E-commerce and Miva
                          * Author, The Official Miva Web Scripting Book -- available on-line:
                          http://www.amazon.com/exec/obidos/IS...icmetalproducA

                          Comment

                          • lesliekirk
                            Super Moderator











                            • Aug 2008
                            • 9291

                            #14
                            Originally posted by Kent Multer View Post
                            Just guessing here, but: for the above code snippet, does the variable l.customfields_module:module have a value? It looks to me like either it needs to be initialized, or maybe it's supposed to be "l.settings:..." instead of just "l...."
                            That's a good question - what would the "module" be?
                            Leslie Kirk
                            Miva Certified Developer
                            Miva Merchant Specialist since 1997
                            Previously of Webs Your Way
                            (aka Leslie Nord leslienord)

                            Email me: [email protected]
                            www.lesliekirk.com

                            Follow me: X | Facebook | Pinterest

                            Comment

                            • Nick
                              Super Moderator











                              • Dec 2011
                              • 575

                              #15
                              Sorry all, I got a little ahead of myself and forgot to add some code:

                              Code:
                              <mvt:do file="g.Module_Library_DB" name="l.loaded_module" value="Module_Load_Code_Cached( 'customfields', l.customfields_module )" />
                              <mvt:if expr="l.loaded_module">
                                  <mvt:do file="g.Module_Root $ l.customfields_module:module" name="l.success" value="CustomerFieldValue_Load_CodeAndCustomer( '
                              customer_customfield_code', l.settings:order:cust_id, l.customfield:field, l.customfield:value )" />
                                  <mvt:eval expr="decodeattribute(glosub(miva_array_serialize( l.customfield), ',', '<br>'))" />
                              </mvt:if>
                              All that being said the most optimized way of getting the customer custom field would be to assign the custom field item to the page then run the Read_Customer_ID function:

                              Code:
                              <mvt:item name="customfields" param="Read_Customer_ID( CUST_ID, 'custom_field_code', l.settings:customfields )" />
                              More information can be found here: https://docs.miva.com/template-langu...-documentation
                              Nicholas Adkins
                              Technical Training Specialist / Miva, Inc.
                              [email protected]
                              https://www.miva.com/mivalearn

                              Comment

                              Working...
                              X