Announcement

Collapse
No announcement yet.

Customer Custom Fields

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

  • lesliekirk
    replied
    Originally posted by Nick View Post
    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
    The custom field item has been assigned to this page all along. It was one of the first things I did.

    Please keep in mind, that I'm an integrator who takes the bits and pieces and then puts them together to make it work. I have looked at the docs numerous times over.

    Obviously, this didn't work for me:

    Code:
    <mvt:item name="customfields" param="Read_Customer_ID( CUST_ID, 'test', l.settings:customfields )" />
    &mvte:customfields:test;
    but the code you posted did spit out this:

    Code:
    :field:code=test
    :field:fieldtype=textfield
    :field:group_id=0
    :field:id=105
    :field:info=Field for message
    :field:name=Test
    :value:field_id=105
    :value:value=This is just a test.
    The last line, the "value" is what I need.




    Leave a comment:


  • ids
    replied
    Not trying to redirect the discussion, but it looks like a solution is presented.

    There is a school of thought that you shouldn't need to assign an item to a page if the component item is valid. IOW, especially for a Miva module, Customfields, adding the Read_Customer_ID should be all that was needed for the function to run.

    So, are there other systematic concerns with Component ITEMs?

    Scott


    Leave a comment:


  • Nick
    replied
    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

    Leave a comment:


  • lesliekirk
    replied
    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?

    Leave a comment:


  • Kent Multer
    replied
    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...."

    Leave a comment:


  • lesliekirk
    replied
    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>

    Leave a comment:


  • Nick
    replied
    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?

    Leave a comment:


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

    Leave a comment:


  • Nick
    replied
    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?

    Leave a comment:


  • lesliekirk
    replied
    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.

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    well, that makes some sense. and as much as i try to keep my own code 'syntax' orthogonal, i have many a 'bad' moment.

    Leave a comment:


  • Nick
    replied
    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.

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    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).

    Leave a comment:


  • Nick
    replied
    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.

    Leave a comment:


  • Kent Multer
    replied
    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 )" />

    Leave a comment:

Working...
X