Announcement

Collapse
No announcement yet.

Release 8 update 9 Custom fields question

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

    Release 8 update 9 Custom fields question

    Hello forum: Can someone point me to documentation on the use of the new update 9 custom fields features. Specifically, is there a custom field that can be assigned to a basket and an explanation about the order custom fields?
    THanks, Larry

    PS took a look at the update 9 release notes. Now looking for documentation on the use of: "A new StoreMorph item "customfields" supports multiple functions for reading and writing Custom Fields."
    Thanks, Larry
    Last edited by wajake41; 04-24-13, 05:21 AM.
    Larry
    Luce Kanun Web Design
    www.facebook.com/wajake41
    www.plus.google.com/116415026668025242914/posts?hl=en



    #2
    Re: Release 8 update 9 Custom fields question

    The Reference Guide should be updated next week with all the new stuff, but in the meantime I'll get Brennan to chime in.
    Thanks,

    Rick Wilson
    CEO
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


      #3
      Re: Release 8 update 9 Custom fields question

      Larry,

      I pulled this from our internal pages until our reference guide gets updated.

      Custom Fields Use

      One of the key new features was allowing store morph code to call functions directly inside the module through the use <mvt:item/> tags. The two main components are reading a custom field and writing to a custom field.


      Read Function Parameters
      Read_***( id/code, custom_field_code, [destination] )
      Parameters
      • Code/ID of the category/customer/order/product
        • The parameter can either be a number, a string, or a variable. E.g. 1, '1', 'code', l.settings:product:code, g.Category_Code

      • The custom fields to load. Expected values are ''(empty string), 'single_custom_field_code', 'comma_separated, list_of, custom_field, codes'
        • A blank string loads all custom fields for that category/customer/order/product in an array. E.g. returns the custom fields 'size', 'height', 'weight', etc... (see examples below)
        • A single custom field returns the custom field as the main member of the destination field (see examples below)
        • A comma separated list of custom fields returns each custom field as a member of the destination field (see examples below)

      • [Optional] The destination where the custom field values will be saved. Must be a variable
        • Defaults to the item name. E.g. item name is customfields, so the structure is returned to l.settings:customfields (see examples below)
        • Can pass in either a local or global variable of your choice. E.g. l.settings:my_custom_fields, g.My_Custom_Fields, etc...


      Write Functions Parameters
      Write_***( id/code, custom_field, value )
      Parameters
      • Code/ID of the category/customer/order/product
        • The parameter can either be a number, a string, or a variable. E.g. 1, '1', 'code', l.settings:product:code, g.Category_Code

      • The custom field code to write to
      • The parameter can either be a string or a variable. E.g. 'custom_field_code', g.Custom_Field_Code
      • The value you want to set the custom field to
      • The parameter can either be a string or a variable. E.g. 'custom field value', g.Custom_Field_Value



      Read Functions
      Code:
      <mvt:item name="customfields" param="Read_Category_Code( 'category_code', 'custom_field_code', l.settings:customfields )" />
      <mvt:item name="customfields" param="Read_Category_ID( 1, 'custom_field_code', l.settings:customfields )" />
      <mvt:item name="customfields" param="Read_Customer_Login( '[email protected]', 'custom_field_code', l.settings:customfields )" />
      <mvt:item name="customfields" param="Read_Customer_ID( 666, 'custom_field_code', l.settings:customfields )" />
      <mvt:item name="customfields" param="Read_Order( 1000, 'custom_field_code', l.settings:customfields )" />
      <mvt:item name="customfields" param="Read_Product_Code( 'product_code', 'custom_field_code', l.settings:customfields )" />
      <mvt:item name="customfields" param="Read_Product_ID( 1, 'custom_field_code', l.settings:customfields )" />
      Write Functions

      Code:
      <mvt:item name="customfields" param="Write_Category_Code( 'category_code', 'custom_field_code', 'value' )" />
      <mvt:item name="customfields" param="Write_Category_ID( 1, 'custom_field_code', 'value' )" />
      <mvt:item name="customfields" param="Write_Customer_Login( '[email protected]', 'custom_field_code', 'value' )" />
      <mvt:item name="customfields" param="Write_Customer_ID( 666, 'custom_field_code', 'value' )" />
      <mvt:item name="customfields" param="Write_Order( 1000, 'custom_field_code', 'value' )" />
      <mvt:item name="customfields" param="Write_Product_Code( 'product_code', 'custom_field_code', 'value' )" />
      <mvt:item name="customfields" param="Write_Product_ID( 1, 'custom_field_code', 'value' )" />
      Miscellaneous Functions

      Code:
      <mvt:item name="customfields" param="Read_Basket( 'custom_field_code', l.settings:customfields )" /> /*Reads a custom field from the sNN_BasketInfo table*/
      <mvt:item name="customfields" param="Write_Basket( 'custom_field_code', 'value' )" /> /*Writes a custom field to the sNN_BasksetInfo table*/
      <mvt:item name="customfields" param="Debug()" /> /*Outputs any errors that may have occurred, such as a non-existent product code*/
      Examples

      Code:
      <mvt:item name="customfields" param="Read_Product_ID( 62, '', l.settings:test )" />
      <mvt:foreach iterator="field" array="test">
          &mvte:field:code;<br/>
          &mvte:field:name;<br/>
          &mvte:field:value;<br/>
      </mvt:foreach>
      Code:
      <mvt:item name="customfields" param="Read_Order( 1000, '' )" />
      <mvt:foreach iterator="field" array="customfields">
          &mvte:field:code;<br/>
          &mvte:field:name;<br/>
          &mvte:field:value;<br/>
      </mvt:foreach>
      Code:
      <mvt:item name="customfields" param="Write_Basket( 'lamp_color', 'green' )" />
      <mvt:item name="customfields" param="Read_Basket( 'lamp_color', l.settings:custom_basket_lamp_color )" />
      &mvte:custom_basket_lamp_color;
      Code:
      <mvt:item name="customfields" param="Read_Customer_Login( '[email protected]', 'middle_name, maiden_name' )" />
      &mvte:customfields:middle_name;
      &mvte:customfields:maiden_name;
      Code:
      <mvt:item name="customfields" param="Read_Category_Code( 'teams', 'dodgers, angels', g.Custom_Fields )" />
      &mvte:global:Custom_Fields:dodgers;
      &mvte:global:Custom_Fields:angels;
      Code:
      <mvt:item name="customfields" param="Write_Basket( 'my_made_up_code', 'This is my value I am going to write to the basket' )" />
      <mvt:item name="customfields" param="Write_Basket( 'color', 'red' )" />
      <mvt:item name="customfields" param="Read_Basket( '' )" />
      <mvt:foreach iterator="basket" array="customfields">
           &mvte:basket:code; - &mvte:basket:value;<br/>
      </mvt:foreach>

      Thanks,

      Wayne
      Wayne Smith

      Comment


        #4
        Re: Release 8 update 9 Custom fields question

        Hi Wayne: Hope you can help.
        I am creating a custom basket field like this in OSEL:
        <mvt:item name="customfields" param="Write_Basket('coupon_code', g.OCST_comment)" />

        But after the order is created, I cannot retrieve the custom field value from the order like this in INVC (or in OCST):
        <mvt:item name="customfields" param="Read_Order( '10903', ' ' )" />
        <mvt:foreach iterator="field" array="customfields">
        &mvte:field:code;<br/>
        &mvte:field:name;<br/>
        &mvte:field:value;<br/>
        </mvt:foreach>

        or like this
        <mvt:item name="customfields" param="Read_Order( 10903, ' ' )" />
        <mvt:foreach iterator="field" array="customfields">
        &mvte:field:code;<br/>
        &mvte:field:name;<br/>
        &mvte:field:value;<br/>
        </mvt:foreach>

        What am I doing wrong?
        Larry
        Larry
        Luce Kanun Web Design
        www.facebook.com/wajake41
        www.plus.google.com/116415026668025242914/posts?hl=en


        Comment


          #5
          Re: Release 8 update 9 Custom fields question

          Got my solution.
          Needed to define an Order custom field in admin that matches the Basket custon field name.
          Larry
          Larry
          Luce Kanun Web Design
          www.facebook.com/wajake41
          www.plus.google.com/116415026668025242914/posts?hl=en


          Comment


            #6
            Re: Release 8 update 9 Custom fields question

            Looking for help for example code to add a checkbox custom field on Customer Create (ACAD) page for opt-in email newsletter subscription.

            The code name for the customer custom checkbox field is "emaillist". When a customer checks it, the value of 'emaillist' will have a value of "1", otherwise the value will be "0".

            Before PR 8 Update 9, we use Emporium Plus modules in one of my store to implement the function. The code is listed below:

            <!--Newsletter Optin checkbox BEGINS-->
            <mvt:item name="custedit" param="newsletter" />
            <tr><td align="left" valign="middle" colspan="2">
            <mvt:item name="fonts" param="body_font">
            <mvt:if expr="l.settings:custedit:current:value EQ 1">
            <input type="checkbox" name="CFM_value[&mvte:custedit:current:id;]" value="1" checked>
            <mvt:else>
            <input type="checkbox" name="CFM_value[&mvte:custedit:current:id;]" value="1">
            </mvt:if>
            <input type="hidden" name="CFM_field[&mvte:custedit:current:id;]" value="1">
            I want to receive ActiveHerb newsletters, specials and news updates via email.
            </mvt:item>
            </td></tr>
            <!--Newsletter Optin checkbox ENDS-->

            But we would like to do the same with Miva native module. What exact Read or Write code do I have to use?

            Comment


              #7
              Re: Release 8 update 9 Custom fields question

              I want to know how to do this too.
              I want to have the customer give me more info when they create their account.
              Also I want to make the custom customer field required.

              Let's make this really easy when asking for help.. just a simple text field as an example.

              Lets say I have a custom customer field defined named EXINFO. I entered in the utilities for custom field.
              Now I want to add it to my ACAD customer create template.
              I go to the customer fields tab and put in some html there like this:

              <mvt:item name="custedit" param="EXINFO" />
              <input type="text" name="EXINFO" value="" required>
              </mvt:item>

              I tried putting required in the html tag for the input field. but it's being ignored by miva.

              Where do I put the write code for writing my EXINFO into the customer custom field? I'll bet it doesn't go on the ACAD template.

              Miva, Please help us more with this stuff.

              Comment


                #8
                Re: Release 8 update 9 Custom fields question

                Hey Kelly,
                You would need to create a PreAction to test for the value of g.exinfo.
                If g.exinfo is not true then you would add a message to the error_messages array, change the g.screen to return ACAD.
                http://www.alphabetsigns.com/

                Comment


                  #9
                  Re: Release 8 update 9 Custom fields question

                  I'm having an "oh, duh!" moment. Thanks alphabet!
                  Last edited by kayakbabe; 07-11-13, 07:04 AM.

                  Comment


                    #10
                    Re: Release 8 update 9 Custom fields question

                    Here is how you would do the custom customer field example.

                    Here are the steps:

                    1. Create the custom customer field under utilities
                    2. Add the HTML to the ACAD (account create) page template where you want it to display on the page.
                    3. The last step which you are missing, is saving the value of the custom field with the customer record. This will always be done on the Screen your form submits to. Typically the account create takes you to ACED page or the ACLN page. You would then use one of the new Write Customer functions described above:

                    Code:
                    <mvt:item name="customfields" param="Write_Customer_Login( '[email protected]', 'custom_field_code', 'value' )" />
                    <mvt:item name="customfields" param="Write_Customer_ID( 666, 'custom_field_code', 'value' )" />
                    Both do the same thing. The one difference is one use the customer id and the other uses the customer login. Both values are available on that page so it does now matter which you use.

                    Here is what the code would look like:

                    Code:
                    <mvt:if expr="NOT ISNULL g.EXINFO">
                        <mvt:item name="customfields" param="Write_Customer_Login( g.Customer:login, 'custom_field_code', g.EXINFO )" />
                    </mvt:if>
                    The code above will check and see if the field with the name of EXINFO has a value and if it does it will insert it into the Customer Custom Field for that customer.
                    Brennan Heyde
                    VP Product
                    Miva, Inc.
                    [email protected]
                    https://www.miva.com

                    Comment


                      #11
                      Re: Release 8 update 9 Custom fields question

                      activeherb,

                      I created the exact situation you described and did it with the following code:

                      On the ACAD ​page I added the code after the password inputs in the Customer Fields tab

                      Code:
                      <input type="checkbox" name="Customer_Newsletter" value="1" /> Opt-In Newsletter
                      On the ACED page I added the code to the top of the Customer Fields tab

                      Code:
                      //This part of the code is used if the customer created an account and had checked the newsletter checkbox on the ACAD page
                      <mvt:if expr="g.Action EQ 'ICST' AND g.Customer_Newsletter">
                           <mvt:item name="customfields" param="Write_Customer_ID( g.Basket:cust_id, 'emaillist', 1 )" />
                      </mvt:if>
                      
                      
                      //This part of the code is used if the customer is updating their account
                      <mvt:if expr="g.Action EQ 'UCST'">
                          <mvt:if expr="g.Customer_Newsletter">
                              <mvt:item name="customfields" param="Write_Customer_ID( g.Basket:cust_id, 'emaillist', 1 )" />
                          <mvt:else>
                              <mvt:item name="customfields" param="Write_Customer_ID( g.Basket:cust_id, 'emaillist', '' )" />
                          </mvt:if>
                      </mvt:if>
                      Further down in the code on ACED I added

                      Code:
                      <mvt:item name="customfields" param="Read_Customer_ID( g.Basket:cust_id, 'emaillist' )" />
                      
                      <mvt:if expr="l.settings:customfields">
                          <input type="checkbox" name="Customer_Newsletter" value="1" checked /> Opt-In Newsletter
                      <mvt:else>
                          <input type="checkbox" name="Customer_Newsletter" value="1" /> Opt-In Newsletter
                      </mvt:if>
                      Hope this code helps you, let me know if you have any more questions.
                      David Carver
                      Miva, Inc. | Software Developer

                      Comment


                        #12
                        Re: Release 8 update 9 Custom fields question

                        how can we have miva merchant check to make sure it is a required field and has content instead of being submitted blank? Without having to use a thirdparty module?
                        Last edited by kayakbabe; 07-11-13, 10:58 AM.

                        Comment


                          #13
                          Re: Release 8 update 9 Custom fields question

                          Currently there is not a way to add validation to a custom field so it is required. You would either have to use JavaScript Validation on the front end, or use module like tookit/toolbelt.
                          Brennan Heyde
                          VP Product
                          Miva, Inc.
                          [email protected]
                          https://www.miva.com

                          Comment


                            #14
                            Re: Release 8 update 9 Custom fields question

                            If you do use a third party module, here is some sample code to make a custom field required using kayakbabe example.

                            On the ACAD page modify the form hidden inputs:

                            Code:
                            // stuff above form
                            
                            <form name="contact" method="post" action="&mvte:global:secure_sessionurl;">
                            <input type="hidden" name="Store_Code" value="&mvte:global:Store_Code;">
                            <input type="hidden" name="PreAction" value="PREACTION_ACAD">
                            <input type="hidden" name="PrevPage" value="ACAD">
                            <input type="hidden" name="Action" value="ICST">
                            
                            // more stuff below
                            On the ACAD page > Customer Fields tab add:

                            Code:
                            <mvt:if expr="g.exinfo_form_error">
                            <div style="color:red;">EXINFO is a required field</div>
                            </mvt:if>
                            <div><label for="exinfo">EXINFO: </label><input type="text" id="exinfo" name="EXINFO" size="25" value=""></div>
                            Create a new page Code: PREACTION_ACAD Name: PREACTION ACAD

                            Code:
                            <mvt:comment>PREACTION_ACAD</mvt:comment>
                            <mvt:if expr="(ISNULL g.PreAction) AND ('PREACTION_' IN g.Action NE 1)">
                              <mvt:exit />
                            </mvt:if>
                            <mvt:item name="ry_toolbelt" param="assign|g.exinfo|trim(g.exinfo)" />
                            <mvt:if expr="ISNULL g.exinfo">
                            <mvt:item name="ry_toolbelt" param="assign|g.exinfo_form_error|'1'" />
                            <mvt:item name="ry_toolbelt" param="assign|g.error_message_count|'1'" />
                            <mvt:item name="ry_toolbelt" param="assign|g.error_messages[1]|'EXINFO is a required field'" />
                            <mvt:item name="ry_toolbelt" param="assign|g.Screen|'ACAD'" />
                            <mvt:else>
                            <mvt:item name="ry_toolbelt" param="assign|g.exinfo_form_error|" />
                            </mvt:if>
                            You can add some additional script to the PREACTION_ACAD page for exinfo form validation.

                            Don't forget to add Brennan's code on the ACLN or ACED pages
                            http://www.alphabetsigns.com/

                            Comment


                              #15
                              Re: Release 8 update 9 Custom fields question

                              I want to collect customer instructions during checkout and save it with the order.

                              I read the documentation but it does not show any examples on using the custom order fields and I'm a bit stumped.
                              It shoes this syntax:
                              Code:
                              <mvt:item name="customfields" param="Write_Order( 1000, 'custom_field_code', 'value' )" />
                              I created a custom order field code: instructions. Then on the OPAY screen I added.
                              Code:
                              <b>Special Instructions</b>
                              <textarea rows="5" cols="50" wrap="physical" name="instructions" class="instructions"></textarea>
                              Then on the invoice screen I assigned the customfields and added the following code to the top
                              Code:
                              <mvt:assign name="g.instructions" value="encodeentities(trim(g.instructions))" />
                              <!-- &mvt:global:instructions -->
                              <mvt:if expr="g.instructions">
                                  <mvt:item name="customfields" param="Write_Order( l.settings:order:id, 'instructions', g.instructions )" />
                              </mvt:if>
                              I can confirm g.instructions is sent to the invoice page but its not written to the custom field.
                              Ray Yates
                              "If I have seen further, it is by standing on the shoulders of giants."
                              --- Sir Isaac Newton

                              Comment

                              Working...
                              X