Format Personified Fields in th order notification email

Follow

Comments

8 comments

  • Avatar
    Josh

    Oh and this is the email notification code:

     

    {% for line in line_items %}

    {{ line.quantity }} x {{line.title }} for {{ line.price | money }} each {% capture v %}p9d-attr-{{ line.variant.id }}{% endcapture %}

    {{ attributes[v] }}

    {% endfor %} 

  • Avatar
    Zetya Support

    Hi Josh,

    So here's a trick I use.

    1. First, change your formatter to add a HTML newline <br/> to the variant fields (in cart.liquid):

                return fields.join(', ') +'<br />';

    1. Go to the notification email and enable the HTML version. For the attributes, use the following:

    {{ attributes[v] | remove: '[' | remove: ']' | replace: '=', ' = ' }}

    Gavin.

  • Avatar
    Josh

    Hi Gavin,

    Thanks so much for that, it seems perfect. Unfortunately my Javascript skills leave a lot to be desired, I usually manage to wing it with copy and paste! Could you possibly please tell me exactly where to place the line:

    return fields.join(', ') +'<br />';

    in

     

    <script id="p9d-row-template" type="text/html">

        <tr id="p9d-${ record.variant }-${ record.ts }" class="p9d-record">

            

    <td class="desc">

    <p><span class="collarcolour">${ record.values.collarcolour }</span></p>

    <p><span class="embroidcolour">${ record.values.embroidcolour }</span></p>

    <p><span class="name">${ record.values.name }</span></p>

    <p><span class="number">${ record.values.number }</span></p>

    </td>

    <td>

    <input type="text" size="2" id="p9d-update-${ record.variant }-${ record.ts }" value="${ record.qty }" class="p9d-update" /> 

    <a href="#" id="p9d-remove-${ record.ts }" rel="p9d-update-${ record.variant }-${ record.ts }" class="p9d-remove">{{ 'remove.png' | asset_url | img_tag, 'Remove' }}</a>

    </td>

    <td></td>

    <td></td>

    </tr>

    </script>

    Sorry for my lack of knowledge!

  • Avatar
    Zetya Support

    Hi Josh,

    That line is part of the formatter function (in cart.liquid):

    function formatter(values) {  
    

    var fields = [];

    for (field in values) {

    fields.push(field + " = " + values[field]);

    }

    return fields.join(',') + '<br/>';

    }

     Thanks, Gavin.

  • Avatar
    Josh

    Hi Gavin,

    Thank you for that. Sorry to be a pain, but may i ask you one last thing:

    My current formatter code reads:

    function formatter(values) {  
    

            var fields = [];

            for (field in values) {

                if (field != 'product') {

                    fields.push(field + "=" + values[field]);

                }

            }

            return values.product + ": " + fields.join("; ");

        }

     

    Do I replace the whole thing or just replace the line:

    return values.product + ": " + fields.join("; "); 
    

    with

    return fields.join(',') + '<br/>';
    

     

    Once again, I apologise for the hassle, I just don't want to break the client's store!

  • Avatar
    Josh

    Hi Gavin,

    My apologies for harrassing you, but is there any chance you could help me with the above post?

  • Avatar
    Zetya Support

    Hi Josh,

    Sorry for the delay - thought I'd answered this already.

    The code you need to replace is:

    return values.product + ": " + fields.join(", ") + "<br/>";
    

    Thanks, Gavin.

  • Avatar
    Josh

    Awesome, much appreciated, thank you!

Please sign in to leave a comment.