Jump to content
Sign in to follow this  
Robin Somes

Syntax error in email template appears to break ordering

Recommended Posts

Site: www.piscesconservation.com/cube

CC 6.2.5 Foundation / All In One Shipping 1.0.11 / Facebook 1.0.0 / PayPal 1.0.8 / Product Addons 1.0.12 / SagePay 1.0.6

We've updated 3 products on our site this morning, and put through some test orders. Minor changes to the plain text of the Cart: Digital Download email seem to have broken the ordering process; despite restoring the default email templates, ordering remains broken.

  1. Added new digital files to each of the products and amended product descriptions.
  2. Customer places 1st test order for software (guest checkout, not signed-in): order proceeds correctly, CC confirmation & download emails received by customer, download successful. SagePay success confirmation email received by customer.
  3. All CC and SagePay confirmation emails received by us correctly. Order shows on CC Admin pages as Completed; Transaction Logs tab appears on order details page. Payment appears in card merchant portal as successful.
  4. Changed plain text of Digital Download email; HTML error received.
  5. Customer places 2nd test order (guest checkout, not signed-in). SagePay card payment apparently proceeds OK, but ends on a blank page after the card verification. Chrome warns that insecure items are being loaded.
  6. Customer receives email saying that the order was received and processing. No Digital Download email. SagePay success confirmation email received by customer.
  7. All CC and SagePay confirmation emails received by us correctly, but order shows on CC Admin pages as Pending; there's no Transaction Logs tab on order details page. Payment appears in card merchant portal as successful.
  8. Restored default email templates. HTML error still received.
  9. Customer returns to front page of shop site, to find items still in shopping cart. Empties basket. Adds 3rd product. Goes through checkout (guest checkout, not signed-in). SagePay card payment apparently proceeds OK, but ends on a blank page after the card verification. Chrome warns that insecure items are being loaded.
  10. Customer receives email saying that the order was received and processing. No Digital Download email. SagePay success confirmation email received by customer.
  11. All CC and SagePay confirmation emails received by us correctly, but order shows on CC Admin pages as Pending; there's no Transaction Logs tab on order details page. Payment appears in card merchant portal as successful.
  12. Customer returns to front page of shop site, to find items still in shopping cart.

So in short, orders are going through, money is changing hands, but confirmation of the order success is not getting back to CC, the Digital Download emails are not going out, and the basket is not being emptied. Meanwhile, whatever I do to restore the email templates, doesn't help.

I changed the plain text of Cart: Digital Download email from

Hi {$DATA.first_name|capitalize},

Your digital files are now ready for download. Please use the links provided below to access them below:

{foreach from=$DOWNLOADS item=download}
{$download.name}: (Link expires on {$download.expire})
{$download.url}
{/foreach}

If the links above don't work, please try copy and pasting them it into your browser address bar. You can also find access to these files from your the customer area of our website.

to

Hi {$DATA.first_name|capitalize},

Your digital files are now ready for download. Please use the link(s) provided below to access them:

{foreach from=$DOWNLOADS item=download}
{$download.name}: (Link expires on {$download.expire})
{$download.url}
{/foreach}

If the links above don't work, please try copy and pasting them it into your browser address bar. If you created a customer account, you can also get access to these files from the customer area of our website - log in to your account from the front page of the site (top right of page: Login / Register). If you have any problems, please contact us. 

On clicking 'Save', I received an error warning: HTML Content: Syntax error in template "Hi {$DATA.first_name|capitalize},..." on line 7 "" unclosed {foreach} tag. 

The {foreach} tag is very obviously not unclosed; taking out the spaces and line return before {/foreach} makes no difference.

Under Email Contents and Templates: Import, I've reinstalled my email templates with the defaults. This restores the original text. However, on clicking 'Save' I still get the HTML Warning error.

Any help would be appreciated...

Please also note the typos in the 2 sentences of the email template: "Please use the links provided below to access them below" and "You can also find access to these files from your the customer area of our website."

TIA,

Robin

 

Edited by Robin Somes
typo

Share this post


Link to post
Share on other sites

I see this happen all the time. in short, just dont' edit the templates using the editor. Copy the source code to an external editor, then use that to modify and save back. It malforms the smarty code in some cases.

Check your store error log, you'll probably see a related smarty error

Share this post


Link to post
Share on other sites

Many thanks Noodleman; I'll try that. Quite frustrating. I do indeed have smarty errors in the log - although they're swamped by some time code error at the moment.

Cheers,

Robin

... unfortunately, tried it, still getting the HTML syntax error.

Share this post


Link to post
Share on other sites

If your template is pretty much stock with minor adjustments then I would delete it and start over. I can grab the default code for you if you want?

Alternatively, if your template is heavily modified then you will likely need to copy the source code to an editor and review it line by line to correct. it can take a while.

I probably see this with other customers about once every couple of weeks.

Share this post


Link to post
Share on other sites

Yep, same here with our customers - the editor just isnt fit for purpose which is frustrating.  I know that Al has looked at this and wants to change to something else

Share this post


Link to post
Share on other sites

Many thanks. Assuming you mean the email template for that email, other than the minor alterations given in my original post up there ^, it wasn't modified at all, and I didn't go near the code and variables. The only alterations I made were on the Plain Text Content tab. I've tried it within the Editor box on the page, and by copying into Notepad then pasting back in to the Editor box.
R

Share this post


Link to post
Share on other sites

Which template was it you edited? is it only the digital download one?

Edited by Noodleman

Share this post


Link to post
Share on other sites

Yes, changed 

Hi {$DATA.first_name|capitalize},

Your digital files are now ready for download. Please use the links provided below to access them below:

{foreach from=$DOWNLOADS item=download}
{$download.name}: (Link expires on {$download.expire})
{$download.url}
{/foreach}

If the links above don't work, please try copy and pasting them it into your browser address bar. You can also find access to these files from your the customer area of our website.

to

Hi {$DATA.first_name|capitalize},

Your digital files are now ready for download. Please use the link(s) provided below to access them:

{foreach from=$DOWNLOADS item=download}
{$download.name}: (Link expires on {$download.expire})
{$download.url}
{/foreach}

If the links above don't work, please try copy and pasting them it into your browser address bar. If you created a customer account, you can also get access to these files from the customer area of our website - log in to your account from the front page of the site (top right of page: Login / Register). If you have any problems, please contact us.

Share this post


Link to post
Share on other sites

put the editor into source mode, and past this into the HTML section:

 

<p>Hi {$DATA.first_name|capitalize},</p>

<p>Your digital files are now ready for download. Please use the links provided below to access them below:</p>
<!--{foreach from=$DOWNLOADS item=download}-->

<p><strong>{$download.name}:</strong> (Link expires on {$download.expire}<strong>)</strong></strong></p>
 

 

and in the plain tab, add the following:

Hi {$DATA.first_name|capitalize},

Your digital files are now ready for download. Please use the links provided below to access them below:

{foreach from=$DOWNLOADS item=download}
{$download.name}: (Link expires on {$download.expire})
{$download.url}
{/foreach}

If the links above don't work, please try copy and pasting them it into your browser address bar. You can also find access to these files from your the customer area of our website.

 

Share this post


Link to post
Share on other sites

Yep, done that (with the additional precaution of copying from here, pasting into Notepad, then copying/pasting into the Editor).  Still getting the error, unfortunately.

Share this post


Link to post
Share on other sites

I've not (at least within living memory) revised any of the other templates - and I have in any case restored the defaults, using the option to do that on the Import tab. The full error is:

 

[Exception] /home/u101124/public_html/piscesconservation.com/cube/includes/lib/smarty/sysplugins/smarty_internal_templatecompilerbase.php:7 - Syntax error in template "string:

Hi {$DATA.first_name|capitalize},

..." on line 7 "" unclosed {foreach} tag

 

Share this post


Link to post
Share on other sites

I think it's malformed the content when saving, I replicated the same problem here as well. Assuming the forum doesn't malform it, try this:

 

<p>Hi {$DATA.first_name|capitalize},</p>
<p>Your digital files are now ready for download. Please use the links provided below to access them below:</p>
{foreach from=$DOWNLOADS item=download}
<p><strong>{$download.name}:</strong> (Link expires on {$download.expire}<strong>)</strong><br>
<a href="{$download.url}">{$download.url}</a></p>
{/foreach}
<p>If the links above don't work, please try copy and pasting them it into your browser address bar. You can also find access to these files from your the customer area of our website.</p> 
<p>&nbsp;</p>

It's 100% an issue with this template, can reproduce it on demand in a test store. the code above is the code directly from the database before being malformed. 

Share this post


Link to post
Share on other sites

OK, I've copied that in to Notepad, saved it, closed the file, re-opened, selected and copied, then pasted into the Editor in the HTML Content tab. Clicked Save, and it saves without the error message. So far so good, many thanks! I've run out of time this afternoon, I'll revisit it later this evening or tomorrow morning.

Thanks again

R

Share this post


Link to post
Share on other sites

It happened to me a few years ago.

Luckily I had another site that I could copy the code from.

Share this post


Link to post
Share on other sites
2 hours ago, Noodleman said:

I think it's malformed the content when saving, I replicated the same problem here as well. Assuming the forum doesn't malform it, try this:

 

<p>Hi {$DATA.first_name|capitalize},</p>
<p>Your digital files are now ready for download. Please use the links provided below to access them below:</p>
{foreach from=$DOWNLOADS item=download}
<p><strong>{$download.name}:</strong> (Link expires on {$download.expire}<strong>)</strong><br>
<a href="{$download.url}">{$download.url}</a></p>
{/foreach}
<p>If the links above don't work, please try copy and pasting them it into your browser address bar. You can also find access to these files from your the customer area of our website.</p> 
<p>&nbsp;</p>

It's 100% an issue with this template, can reproduce it on demand in a test store. the code above is the code directly from the database before being malformed. 

Does merely *looking* at the HTML Content tab break it? I've just checked the HTML Content again, and it's:
<p>Hi {$DATA.first_name|capitalize},</p>

<p>Your digital files are now ready for download. Please use the links provided below to access them below:</p>
<!--{foreach from=$DOWNLOADS item=download}-->

<p><strong>{$download.name}:</strong> (Link expires on {$download.expire}<strong>)</strong></strong></p>

Didn't change anything at all. Switched to the Plain Text Content tab, deleted one small word, clicked Save, and I'm back with the error again. Copied/pasted your suggested code above into the Editor once again, clicked Save: no error.

Share this post


Link to post
Share on other sites
3 minutes ago, Noodleman said:

yup, the HTML it redners isn't what is in the DB

Pretty damn frustrating. The workaround is obviously to  make whatever changes are necessary in the Plain Text version first, switch to HTML Content, paste in your code, make the same changes there, then save. But aggravating nonetheless. Luckily the changes I'm making are trivial.

Thanks again for your help.

R

Edited by Robin Somes

Share this post


Link to post
Share on other sites

Noodleman said to paste this in the editor:

<p>Hi {$DATA.first_name|capitalize},</p>
<p>Your digital files are now ready for download. Please use the links provided below to access them below:</p>
{foreach from=$DOWNLOADS item=download}
<p><strong>{$download.name}:</strong> (Link expires on {$download.expire}<strong>)</strong><br>
<a href="{$download.url}">{$download.url}</a></p>
{/foreach}
<p>If the links above don't work, please try copy and pasting them it into your browser address bar. You can also find access to these files from your the customer area of our website.</p> 
<p>&nbsp;</p> 

Please know that while HTML code is in the editor, and it is necessary that the editor be in Source mode, that some Smarty tags (e.g., repeating sections) need to be enclosed in HTML comments. So, the code while in the editor, and in Source mode, must be:

<p>Hi {$DATA.first_name|capitalize},</p>
<p>Your digital files are now ready for download. Please use the links provided below to access them below:</p>
<!--{foreach from=$DOWNLOADS item=download}-->
<p><strong>{$download.name}:</strong> (Link expires on {$download.expire}<strong>)</strong><br>
<a href="{$download.url}">{$download.url}</a></p>
<!--{/foreach}-->
<p>If the links above don't work, please try copy and pasting them it into your browser address bar. You can also find access to these files from your the customer area of our website.</p> 
<p>&nbsp;</p> 

The reason is because the editor validates the correctness of HTML DOM structure. The editor will see the Smarty code (enclosed in braces) and will wrap paragraph tags around it. If the editor sees Smarty tags between  <table> and <tr> (for building rows in a table), the tags will be moved outside the <table> structure. (And there are other rules the editor employs based on keeping unwanted HTML out of the content.)

The way around this is to "hide" the Smarty tags in HTML comments. CubeCart stores the editor content in the database without these HTML comment markers, adds them to certain Smarty tags before giving the content to the editor, and removes them when the editor sends the content back. (Please know that the content from all three tabs: General, HTML Content, Plain Text Content, will be sent back to CubeCart regardless even if you never actually looked at the other tab's content.)

In some of the posts above, I am not seeing any of the content after the $download.url.

Share this post


Link to post
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.

Sign in to follow this  

×
×
  • Create New...