Jump to content

Problems editing regsiter_confirmation-1.0 by Al Brookbanks


Will Shaman

Recommended Posts

Subscribing to my CC6 installation is remarkably easy, but I want to send new registrants a welcome email. I was therefore delighted to discover Al's code snippet, "regsiter_confirmation-1.0" (yeah, I know "register" is spelled incorrectly, but that's how it comes). However, the email this snippet sends is very basic and I want to make it more useful. Understanding that PHP and HTML can exist in the same document, I tried various combinations and placements, but had no luck changing the actual email that gets sent.

In an effort to understand the code (I'm not a PHP man) I amended it by putting numbers in the three different places text is placed (I've emboldened and underlined them them below to make them easier to spot, though they're just plain text in the actual imported code). This code is the same as Al's original, except for the insertion of the numbers:

------------------------ AMENDED CODE ------------------------------

<snippets_import version="1.0">
    <info>
        <author>Al Brookbanks (CubeCart Limited)</author>
        <homepage>http://www.cubecart.com</homepage>
    </info>
    <snippets>
        <snippet>
        <enabled>1</enabled>
        <unique_id>[email protected]</unique_id>
        <description>Send registration confirmation email</description>
        <hook_trigger>class.user.register_user.inserted</hook_trigger>
        <php_code><![CDATA[<?php
$GLOBALS['gui']->setNotify('ONE Thank you for registering.');
mail($_POST['email'], 'TWO Thank you for registering', 'THREE Thank you for registering with '.$GLOBALS['config']->get('config', 'store_name').'.', 'From: '.$GLOBALS['config']->get('config', 'email_address'));
?>]]></php_code>
        <version>1.0</version>
        <priority>1</priority>
        </snippet>
    </snippets>
</snippets_import>

------------------------ END OF CODE ------------------------------

The strange thing is, the email I get back ignores my new text completely — no sign of ONE, TWO, or THREE anywhere. I thought at first it must be a cache thing, but I cleared both browser text and went to Maintenance and cleared all caches.

Anyone know what I'm missing?

Thanks in advance,

Will

Link to comment
Share on other sites

This is an XML structure, and so I am believing it is the source for reading in the values into a proper code_snippet.

A proper code_snippet is databased in the table CubeCart_code_snippet. You can edit the code_snippet in admin, Manage Hooks, Code Snippets tab.

 

Link to comment
Share on other sites

Thanks for the swift response.

I did edit the code in the place you mentioned. I also edited the original xml file before importing, then checked it looked as expected in that tab (it did). That's what's not working for me.

Looks like I'll be obliged to purchase Semperfi's "Registration Email Manager CC6" (https://www.semperfiwebservices.com/registration-email-manager-cc6.html), though I'm surprised this basic functionality hasn't made it to version 6 yet.

Link to comment
Share on other sites

So, the PHP code looks like you expect it to be in the Code Snippets tab.

But what you see in the Code Snippets tab is not what is appearing in the email received?

Yet, you also say you edited the XML file before importing it as a snippet.

Then you say you emptied caches, etc. That would only be applicable if you imported this XML file prior to making any edits.

So, did you try to import this XML file more than once?

More on how snippets are managed:

Editing a Code Snippet in admin (assuming something was changed) will update the data in the CubeCart_code_snippet database table. You can use an external database management utility (such as phpMyAdmin) to look at the contents of this table.

Then, CubeCart will delete a corresponding file in the /includes/extra/ folder. The file is named snippet_###.php where ### is an MD5 hash of several aspects of the snippet details.

Finally, CubeCart will re-save the snippet PHP code from what is in the database back to that file when required - which is not necessarily at this point in time.

But if the appropriate snippet_###.php file exists, you can view it in an editor.

Link to comment
Share on other sites

Wow, that's a really useful answer. Thanks!

To answer your specific questions:

  • The email received bears little relation to the way I edit the snippet. I have been able to successfully change the subject line, but the email body stubbornly resists my edits. Either changes I make to the snippet cause it to fail (resulting in no email at all) or the email I receive contain the same text as that of the original (before my edits).
  • Yes, I did try editing the snippet more than once. Each time, I took a fresh (unedited) copy of the snippet as supplied by Al. Then I either [a] imported it and edited it in the snippets tab under Manage Hooks, or edited the xml file first then imported it imported it and checked my edits were as expected by viewing in the snippets tab. Every time I cleared the old version that failed, I also cleared the cache, SQL cache and language cache, as well as my browser cache, just to make sure nothing's hanging around from the previous attempt.

Though that's very useful information for possible future snippet handling, for this particular case I've gone and bought Semperfi's registration email mod — it's a more integrated solution anyway. I was wondering though why even very simple editing of text for display doesn't always show up in the email. Is that something generic I'm missing about how to update snippets? Or do you think that's just a feature of this particular snippet?

Thanks for always being helpful.

Best,

Will

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...