Forums/Personified Addon

Format Personified Fields in th order notification email

Josh
posted this on September 16, 2011 15:11

Hello, we have been using personified for one of our clients stores, but they are displeased with the way that the orders are coming through as they are difficult to read.

Here is an example of how they are coming through at the moment:

3 x Embroidered Collar, Short Medium for $27.00 each

[1 x Embroidered Collar, Short Medium: collarcolour=Purple Collar; embroidcolour=Fluoro Orange Thread; name=JUDY; number=0400481315][1 x Embroidered Collar, Short Medium: collarcolour=Purple Collar; embroidcolour=White Thread; name=MILLIE; number=0413878258][1 x Embroidered Collar, Short Medium: collarcolour=Royal Blue Collar; embroidcolour=White Thread; name=TOMMY; number=0418481315]

Is it possible to format this info by adding a return between each line to something like this?:

3 x Embroidered Collar, Short Medium for $27.00 each

[1 x Embroidered Collar, Short Medium: collarcolour=Purple Collar; embroidcolour=Fluoro Orange Thread; name=JUDY; number=0400481315]
[1 x Embroidered Collar, Short Medium: collarcolour=Purple Collar; embroidcolour=White Thread; name=MILLIE; number=0413878258]
[1 x Embroidered Collar, Short Medium: collarcolour=Royal Blue Collar; embroidcolour=White Thread; name=TOMMY; number=0418481315]

 

This is the code that records the values on my cart page:

<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" />&nbsp;
<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>

Please help! Many thanks.

 

Comments

User photo
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 %} 

September 16, 2011 15:51.
User photo
Shopify Concierge
Shopify Concierge

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 />';


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

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

Gavin.

September 16, 2011 20:38.
User photo
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" />&nbsp;
<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!

September 19, 2011 09:23.
User photo
Shopify Concierge
Shopify Concierge

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.

September 19, 2011 20:25.
User photo
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!

September 20, 2011 08:26.
User photo
Josh

Hi Gavin,

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

September 28, 2011 08:55.
User photo
Shopify Concierge
Shopify Concierge

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.

September 28, 2011 20:55.
User photo
Josh

Awesome, much appreciated, thank you!

September 29, 2011 08:07.