Announcement

Collapse
No announcement yet.

Custom Fields Trouble within CGTY Product List

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

    Custom Fields Trouble within CGTY Product List

    Within the foreach category_listing:products array on my CTGY template I have a few product custom fields I would like to display. Having trouble. And I think I could score a B- if you gave me a quiz on the new custom fields function, as I've used it quite successfully in numerous templates so far but I am at a total loss here.

    I can insert this following code (within foreach category_listing:products) and generate a nice list of custom product field codes and names. Works as expected.

    Code:
    <mvt:item name="customfields" param="Read_Product_Code( l.settings:product:code, '', l.settings:custompfields )" />
       <mvt:foreach iterator="field" array="custompfields">
          &mvte:field:code;<br/>
          &mvte:field:name;<br/>
       </mvt:foreach>
    I do that just to test if I've not made any typos, and to get the correct custom field code. Works fine. But what I'm trying to accomplish is post the value of a particular custom field. Since I know the Read function is sound, I make some changes and do this:

    Code:
    <mvt:item name="customfields" param="Read_Product_Code( l.settings:product:code, 'shipping', l.settings:custompfields )" />
    &mvt:custompfields:shipping;
    Sadly, that "shipping" custom field value will not display. Or that variable doesn't exist. Or whatever. Same goes for several other fields I tried. There is indeed data filled in to the field for the products in the array. That data will even display if I add field:value to the test array in my first code snippet above. But, of course, that populates the page will all the custom field values for all the products -- but nevertheless it is there!

    Surely I've done something wrong, but I can't figure it out. Can you help?

    Thanks
    Last edited by Mark Stephens; 08-24-15, 09:32 PM.

    #2
    Re: Custom Fields Trouble within CGTY Product List

    Try this:
    Code:
    <mvt:item name="customfields" param="Read_Product_Code( l.settings:product:code, 'shipping', l.settings:custompfields )" />
    &mvt:custompfields;

    Comment


      #3
      Re: Custom Fields Trouble within CGTY Product List

      Ah, okay! Thank you. Solved.
      Last edited by Mark Stephens; 08-25-15, 08:05 AM.

      Comment


        #4
        Re: Custom Fields Trouble within CGTY Product List

        I might need to start drinking more coffee...but why are you using the Read_Product_Code() function in (presumably) the category product listing.

        If that custom field is checked in the select boxes below the template, the custom field values are added to the array

        &mvt:product:customfield_values:customfields:[the custom field];
        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


          #5
          Re: Custom Fields Trouble within CGTY Product List

          Originally posted by Bruce - PhosphorMedia View Post
          If that custom field is checked in the select boxes below the template, the custom field values are added to the array

          &mvt:product:customfield_values:customfields:[the custom field];
          Just tried it . . . and OMFG you're 100% right. I thought I had to use the new custom fields system!

          Thanks. Lesson learned.

          Comment


            #6
            Re: Custom Fields Trouble within CGTY Product List

            Those functions are needed when you are trying access that information from outside of formal arrays. Most (if not all) product arrays automatically contain those values. however, their variable names can change. For example in the basket they are present as:

            l.settings:group:customfield_values:customfields:f abricbyhalfyard

            and

            &mvt:group:customfield_values:customfields:fabricb yhalfyard;

            It rather imperative, if you are doing ANY code changing other than text, that you acquire a variable inspection tool such as our Merchant Inspector...which clearly shows these (and all other variables). The Token list viewer built into Merchant is better than nothing, but does not show ALL variables and is a bit cumbersome to use.

            Here's a screen shot of Inspector.


            www.phosphormedia.com/product/pm_inspector.html
            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