Announcement

Collapse
No announcement yet.

Trouble calling customer's custom fields

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

    Trouble calling customer's custom fields

    Can someone help me debug this code. I am able to call the customer's fields and loop through them successfully, but I cannot reference each custom field directly.

    Code:
        <mvt:item name="customfields" param="Read_Customer_ID(l.settings:customer:id, '')" />
        <mvt:foreach iterator="field" array="customfields">
            Code(&mvte:field:code;)<br/>
            Name(&mvte:field:name;)<br/>
            Value(&mvte:field:value;)<br/>
        </mvt:foreach>
        Attempt1: Terms(&mvte:customfields:terms;)<br />
        Attempt2: Terms(&mvte:global:customfields:terms;)
    Output...
    HTML Code:
    Code(terms)
    Name(Terms)
    Value(30)
    Code(termsPercent)
    Name(Terms Percentage)
    Value(0)
    Code(termsDays)
    Name(Terms Days)
    Value()
    Attempt1: Terms()
    Attempt2: Terms()

    #2
    You are using page entities to display your custom fields, that is, anything that starts with &mvt is a page entity.

    If you want to access them individually inside the loop, you would use l.settings:field:code, l.settings:field:name, l.settings:field:value -

    <mvt:eval expr="l.settings:field:code" />

    If you want to access them outside the loop, you'd need to add the array element, such as using this to access the 2nd element in the array, l.settings:customfields[2]:code

    <mvt:eval expr="l.settings:field[2]:code" />

    In your case above with "Attempt1" you would need to put the element in there, such as:

    <mvt:eval expr="l.settings:customfields[1]:terms" />

    It's possible that &mvte:customfields[1]:terms; might work but I personally use mvt:eval when I can so I'm not 100% sure.
    M.A.D.* since 1997

    http://www.scotsscripts.com

    *miva application developers

    Comment


      #3
      Try with &mvt: instead of &mvte:

      Or, to check the values of the var in the loop

      Code:
      <mvt:eval expr="l.settings:field:terms" />
      But, customfields is an array. Outside the loop you need to supply the index. So, probably something like this:

      Code:
      Attempt1: Terms(&mvte:customfields[1]:terms;)<br />
      Scott
      Need to offer Shipping Insurance?
      Interactive Design Solutions https://www.myids.net
      MivaMerchant Business Partner | Certified MivaMerchant Web Developer
      Competitive Rates, Custom Modules and Integrations, Store Integration
      AutoBaskets|Advanced Waitlist Integration|Ask about Shipping Insurance Integration
      My T-shirt Collection is mostly MivaCon T-shirts!!

      Comment


        #4
        Thank you so much for the replies. I still cannot figure out how to call the custom fields directly via their codes. I tried a million different combinations (including mvt:eval). According to this Miva reference document starting at line 19, the below should work.

        Code:
            <mvt:item name="customfields" param="Read_Customer_ID(l.settings:customer:id, '')" />
            code(&mvt:customfields[1]:code;) => value(&mvt:customfields[1]:value;)<br />
            code(&mvt:customfields[2]:code;) => value(&mvt:customfields[2]:value;)<br />
            code(&mvt:customfields[3]:code;) => value(&mvt:customfields[3]:value;)<br />
            <br />
            terms: (&mvte:customfields:terms;)<br />
            termsPercent: (&mvte:customfields:termsPercent;)<br />
            termsDays: (&mvte:customfields:termsDays;)<br />
        HTML Code:
        code(terms) => value(30)
        code(termsPercent) => value(88)
        code(termsDays) => value(55)
        
        terms: ()
        termsPercent: ()
        termsDays: ()

        Comment


          #5
          FWIW - I have been battling a version of this demon too. I am not trying to loop the content, I just can't seem to get Custom Customer Fields to carry over to emails from the ACAD page for the life of me. I've even had Developer Support look at it.


          [CODE]<mvt:item name="customfields" param="Read_Customer_ID(l.settings:customer:id, 'customer_bricks', g.Customer_fields:customer_bricks)" />
          <mvt:if expr="g.Customer_fields:customer_bricks EQ ''">
          <mvt:assign name="g.Customer_fields:customer_bricks" value="g.customer_bricks" />
          </mvt:if>

          <p>Has business a physical location open to the public?: &mvte:global:Customer_fields:customer_bricks;</p>/CODE]

          What is so very frustrating is this code works and passed the field along:

          Code:
          <mvt:item name="customfields" param="Read_Customer_ID(l.settings:customer:id, 'business_type', g.Customer_fields:customer_business_type)" />
          <mvt:if expr="g.Customer_fields:customer_business_type EQ ''">
          <mvt:assign name="g.Customer_fields:customer_business_type" value="g.business_type" />
          </mvt:if>
          
          <p>Business Type: &mvte:global:Customer_fields:customer_business_type; </p>
          Maybe something in this is what you are missing in your coding. I noticed in mine I have something in "Read_Customer_ID".
          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: Twitter | Facebook | FourSquare | Pinterest | Flickr

          Comment


            #6
            Thank you Lesli! Your code set me down the right path.

            I think there is something wrong with Custom Customer Fields, it does not behave the way they are documented in the Miva reference documents.

            Here is my solution. I still would be curious if anyone has an explanation why I have to name an output variable and why I have to list the custom fields.

            Code:
                <mvt:item name="customfields" param="Read_Customer_ID(l.settings:customer:id, 'terms, termsPercent, termsDays', g.invoicedCustomer)" />
                terms: (&mvte:global:invoicedCustomer:terms;)<br />
                termsPercent: (&mvte:global:invoicedCustomer:termsPercent;)<br />
                termsDays: (&mvte:global:invoicedCustomer:termsDays;)<br />

            Comment


              #7
              A lot of times this is because the customer custom fields are 1) Not loaded because they are not expected to be used and 2) the ID for the customer is not loaded as part of the page initialtion. So, in this case, of the customer CREATE page, there wouldn't even be an ID until after the customer created their account.
              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