Jump to content

[Resolved] Order confirmation email query


cpierrep

Recommended Posts

Hi all

I've recently upgraded from CC3 to CC6.0.11  (6.0.12 did not work due to a server limitation)

Store works fine, however I do have an issue with the confirmation emails sent to clients. The default template (File manager, Email templates, Cart: Order Confirmed) works perfectly - emails get sent out, all fields populated, clients receive them.

However, if i make any change to either the HTML or Plain text content , nor order confirmation emails are sent out! If for example I change the the first line in the plain text content from "Thank You {$DATA.first_name}! " to "Thank you {$DATA.first_name}! " (ie just change the capitalisation of You), the confirmation emails are no longer sent out. With regards to the the HTML Content, it is immaterial whether I change something in the HTML view or in the Source View - result is the same, no emails sent out. Even if I change it back to what it was, the problems persists - I have to reload the default templates.

What is interesting is that if i make changes to the "Admin:Order received" template, I do not have the same issue - those emails go out fine.

given that the emails work fine with default templates as well as with the edited "Admin:Order received", I do not think this is a problem related to the mailer (I use the PHPmail function)

Any help gladly received

 

 

Link to comment
Share on other sites

Thanks BooJewels, that was a handy reference, which has helped me to resolve the problem. Well, partially resolved!

In the posts of Alipitt13 and bsmither it was suggested that that the follwoing code 

</table>
{if !empty({$DATA.note_to_customer}

<p>)}</p>

<p>&quot;{$DATA.note_to_customer}&quot;</p>
{/if} 

Should be replaced with this:

</table>
{if !empty({$DATA.note_to_customer})}
<p>&quot;{$DATA.note_to_customer}&quot;</p>
{/if} 

 

Now, I tried this, but like fo alipitt13, CC6 would not save the code! (copied/pasted it into the html source code, then switched to HTML/Wysiwig view,in which it would immediately display the "faulty" ")" - so it just would not save it. Also tried to save the code in the html source code view first, but same result.)

But, like alipit13, i removed the code, and voila! the template saved. I have now been able to make the other changes which I wanted to, but obviously this part of the code is effective broken.

Nevertheless, the changes which i want to be able to make, I can make - so, partially resolved.

Link to comment
Share on other sites

Hi. Sorry, I thought I had made it clear enough that the next section does not work, hence I had to remove it:

</table>
{if !empty({$DATA.note_to_customer})}
<p>&quot;{$DATA.note_to_customer}&quot;</p>
{/if} 

 

If I try to key in the above code  (or copy and paste it), the template will not save - it simply reverts to the "old" version of the template, which has this:

</table>
{if !empty({$DATA.note_to_customer}

<p>)}</p>

<p>&quot;{$DATA.note_to_customer}&quot;</p>
{/if} 

 

So:

1. I cannot save the code as in the first code-copy above, not by first trying to save it under the Source view, nor by typing it in the source view and then going to the wysiwig view and trying to save it there. It simply will not save with that code.

2. Only by removing that code completely can I save the rest of the code (or any edits I want to make)

3. By removing the code, the note to customer is not displayed.

 

hope that clears things up

regards

 

Link to comment
Share on other sites

Sorry about that. Now that I've tried to add the comment code to mine, I see what you mean. Smarty is royally messing up the if statement.

Try this - at least it saved.

{capture name="note"}{$DATA.note_to_customer}{/capture}
{if !empty($smarty.capture.note)}
{/if}

 

Link to comment
Share on other sites

In the very short term, try:

</table>
{if !empty({$DATA.note_to_customer}

<p>)}</p>

<p>&quot;{$DATA.note_to_customer}&quot;</p>
{/if} 

Replace with this:

</table>
{if !empty($DATA.note_to_customer)}
<p>&quot;{$DATA.note_to_customer}&quot;</p>
{/if}

The problem is that Smarty has been told to "protect" content enclosed in braces. The actual fault is that Smarty does not check for nested brace-pairs. This means that the first open-brace starts the protection, and the first close-brace stops the protection. That orphans the content that follows which includes the close-parenthesis and the second close-brace. That causes a syntax error and Smarty will crash the PHP.

In Smarty, everything can be done inside one pair of braces. Notice that the $DATA variable is no longer enclosed in braces inside the {if} statement.

Link to comment
Share on other sites

15 hours ago, bsmither said:

> In the very short term, try:

</table>

{if !empty($DATA.note_to_customer)}

<p>&quot;{$DATA.note_to_customer}&quot;</p>

{/if}

e problem is that Smarty has been told to "protect" content enclosed in braces. The actual fault is that Smarty does not check for nested brace-pairs. This means that the first open-brace starts the protection, and the first close-brace stops the protection. That orphans the content that follows which includes the close-parenthesis and the second close-brace. That causes a syntax error and Smarty will crash the PHP.

In Smarty, everything can be done inside one pair of braces. Notice that the $DATA variable is no longer enclosed in braces inside the {if} statement.

 

Ok, thanks. this does do the trick.

 

 

Link to comment
Share on other sites

I totally forgot to come back to this - I was going to check my technical support fixed version and report back. 

Al actually sorted mine out for me when I was getting errors with processing orders before my shop went live and when I look at the code at the bottom of that template, that is actually what it now says - just as bsmither posted.

I'm happy to confirm that for myself too, as I periodically need to change templates when I'm on holiday or something, so I'm happy to know that the current version is correct (and why, thanks) so that I can keep the content as a master correct version and edit and paste a copy temporarily as required.

I've found with CC6 especially, that keeping a plain text file version of page and template contents - copying and editing it and then pasting that in seems to work better than trying to edit an open template or document within admin - that way I always have a copy that I know worked to return to and start over if I louse something up.

Link to comment
Share on other sites

Can I please ask a supplementary question.  I was going to start a new topic, but as it directly references this discussion it seemed easier to add it here.

I'm somewhat confused - easily done and not for the first time, I know.  That bit at the bottom:  $DATA.note_to_customer - presumably is to include the note to the customer entered by admin in that e-mail (I added this to the order complete e-mail under your direction here so that I could add comments and I do use it on every order), but as this is the message to confirm a new order, presumably one hasn't even been added yet, so it seems redundant? 

I've noticed that I'm not getting customer comments added in the checkout process with my orders and in my case, as they contain pertinent instructions from the customer, they're pretty important - meaning that I can't reply to the e-mail on my phone etc. without looking at the order in admin., which isn't always possible.

Can I change  $DATA.note_to_customer to whatever is the correct macro for the customer-entered order comments - it appears in the template as {$VAL_CUSTOMER_COMMENTS} so would something like $DATA. CUSTOMER_COMMENTS  work so that the customer-entered comment from the checkout will appear in my admin order e-mail?   I'm using an edited eTone skin, but this section of the checkout confirm template appears the same as in Foundation.

 

This is my shop if you want to look (I can't seem to edit my sig.):   https://www.boo-creations.co.uk/shop/ 

Link to comment
Share on other sites

Many thanks @bsmither I'll try changing it to that - hence asking before I tried it, I knew there would be more to it than me just guessing.  Now I've got my shop working well, I don't want to break it.

Why is the 'note to customer' included in the order confirmation e-mail - when there's not likely to be one at that stage, yet these customer comments aren't, that bit doesn't make sense to me?

Link to comment
Share on other sites

The Order Confirmation email template is sent when the order goes to Processing. The admin can move the order to Pending, add notes to the customer, then move the order back to Processing where a new email will be sent.

I can only guess at why the Customer's Comments were not included in the admin notification email -- perhaps the notification was only meant to be a tickle, not a fully-informative order management document.

The Customer's Comments are printed on a second page when the admin is printing the shipping manifest.

Link to comment
Share on other sites

Thanks.  I've actually just realised (as it didn't work) what I was doing wrong (hence not grasping it).   I was looking at the 'Order Confirmed' template which goes to the customer, I was initially thinking that the same e-mail went to both the customer and admin. I wasn't realising that I really need to edit the Admin order received template separately - I'd completely missed that.

I'll put the relevant bit in the admin e-mail and put the customer one back as it was.  Thank you!

Link to comment
Share on other sites

That has worked now thanks. 

But as you fix one issue you find another.  I swear I didn't touch it, but when the e-mail came through to me - in the HTML version at least - the space between first name and last name had gone, merging the customer name into one. 

I think it might be useful for the customer to see a copy of their own comments too, if they're not in the confirmation e-mail, they're going to wonder if I've even seen them, as they're important details.  So after my dinner, I'll look to add it into the customer e-mail too.  I'm also going to try your 'reply to' edit posted in another topic, as that would be really useful.  The contact form does it and it's much better.

ETA:  I can also now see how including the note to customer might well be useful, if the customer places the order, but pays off-line, you can add a comment for them as you update it to processing.

Link to comment
Share on other sites

Hi BooJewels

        you said : "I swear i didn't touch it, but..... the space between the first name and last name had gone"

Interestingly enough, the exact same thing happened to me, also with the html version....

w.r.t. to the customer seeing a copy of their own comments, yes it certainly makes sense for them to receive a copy too. I  included this in my edited confirmation email, in the following two lines in the html code:

         <p><b>Your comments:</b></p>
         <p>&quot;{$DATA.customer_comments}&quot;</p>

and the following two lines in the plain text code:

        Your comments:
       {$DATA.customer_comments}
 

In the admin template I "personalised" it a little bit by adding the client's name as well, so it appears something like the the following:

          Joe has added the following comments:
          "blah blah"

In the html code this was done with:

        <p>{$DATA.first_name}&nbsp; has added the following comments:</p>
        <p><b>&quot;{$DATA.customer_comments}&quot;</b></p>

and in the plain text version with:

         {$DATA.first_name}  has added the following comments:
         {$DATA.customer_comments} 

hope this is of help

 

 

Link to comment
Share on other sites

Thanks @cpierrep that's pretty much what I have done, but the additional first name in the admin is a nice touch.  I put some horizontal rules and dashes between mine too, as if you also included a note to the customer, which I did for the purpose of my testing, the resulting layout was a bit confusing.  I also took the quotation marks out from the note to customer as it looked a bit odd as part of the e-mail, but left them around the customer's comment as that seemed appropriate.

Maybe I'm not bonkers after all.  I was meticulous in my editing and did it in a plain text editor and pasted it back into the template.  I know there was a space in the name earlier as I checked the e-mail I'd got from a genuine order, before I'd started tinkering.

It does drive you nuts though - I noticed later when checking customer e-mails I'd received in my tests, that in the plain text version it had what it called 'part no.', which I edited to 'product code', as that's the term used on the site, but when I went to do the same in the HTML version, it wasn't even included, which I think it should be, so I'll need to look at that today. 

Link to comment
Share on other sites

With regards to:

</table>
{if !empty($DATA.note_to_customer)}
<p>&quot;{$DATA.note_to_customer}&quot;</p>
{/if}

Instead try:

</table>
{if !empty({$DATA.note_to_customer})}
<p>&quot;{$DATA.note_to_customer|nl2br}&quot;</p>
{/if}

The nl2br converts new lines to breaks in html so any paragraphs in your note will look right.  Only add nl2br to the HTML version though, not the Plain Text version.

 

Link to comment
Share on other sites

I think I've now got the two main order templates working to my satisfaction, but I did notice several anomalies in the templates - differences between the admin version and the customers and between the plain text and HTML versions of the same template.  I think they should maybe be looked after during the CC6 upgrade process to be more consistent for those sellers who use a vanilla version of the site and don't tinker the way people here are more likely to.  I certainly think that the customer comment should be included in the templates, especially to admin.

Amongst the anomalies I've spotted, in the Admin:Order Received plain text template - as mentioned above - it has an entry for 'Part Number' where on the site it uses the term 'Product Code', but this doesn't even appear in the HTML version, nor either version of the customer order confirmed e-mail.  For me, this is important data and should appear in all four versions.  I've added it to the missing three versions of my templates (just in brackets after the name).

In the HTML version of the customer order e-mail (Cart:order confirmed), the data link to follow the order is not clickable from the e-mail, where it is in the admin version.

I edited the code as follows:

<p>{$DATA.link}</p>

edited to:

<p><a href="{$DATA.link}">{$DATA.link}</a></p>

There is very definitely a glitch that takes the space out between the first and last name of the customer on the first line of the admin e-mail, I pasted the entire template worth of updated code in and checked that the space was there, did a dummy order and the name was merged in my e-mail, when I opened the template up, the space had gone and I still had my copy on the clipboard, so re-pasted it in and the space was definitely there.  I've replaced it now with a no break space and that is seemingly holding it correctly. 

I've just spotted that the table containing the order sometimes left-aligns and is sometimes centrally-aligns - something else I need to look at.

ETA:  I solved the central align issue thanks to the details in this thread: https://forums.cubecart.com/topic/51039-resolved-force-plain-text/#comment-216261

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...