Jump to content

Resolved - Newsletter subscription confirmation message


red sun

Recommended Posts

The newsletter subscription box works but does not show a confirmation message. I'm sure on older versions of CC that you used to see a "subscription successful" message.

 

There's a language setting for the success message: "newsletter.email_subscribed".

 

I tried the CC site demo and it doesn't appear to be working on there either. Any help much appreciated...

Link to comment
Share on other sites

In the file /classes/gui.class.php, near line 805, find the class method called _displayMailingList(). Make the following section of that function look like this and see what you get:

        if (isset($_POST['subscribe'])) {
            $newsletter = Newsletter::getInstance();
            if ($newsletter->subscribe($_POST['subscribe'])) {
                $GLOBALS['gui']->setNotify($GLOBALS['language']->newsletter['notify_subscribed']);
                httpredir(currentPage(null, array('subscribed' => 'true')));
            } else {
                $GLOBALS['gui']->setError($GLOBALS['language']->newsletter['email_invalid']);
                httpredir(currentPage(null, array('_a' => 'newsletter', 'subscribed' => 'false')));
            }
        }
Link to comment
Share on other sites

Fantastic, thank you so much for your help.

 

The function writes the following to the page:

<div id="gui_message">
<div class="gui_message-notice">Your email address has been added to our mailing list.</div>
</div>

The message is appearing above the main page content as it does in the newsletter template page. Is there any way for it to appear in the newsletter box?

Link to comment
Share on other sites

These statements:

httpredir(currentPage(null, array('subscribed' => 'true')));

httpredir(currentPage(null, array('_a' => 'newsletter', 'subscribed' => 'false')));

are the initial step in implementing (as yet incomplete) a "double-opt-in" scenario. There is yet no code (that I can find) that processes the GET key/value of 'subscribed'/'true|false'.

 

The email address that was inserted into the CC_newsletter_subscriber database table has a 'validation' value which will be used to have the subscriber validate from the email notice received.

 

To do what you want, try:

        if (isset($_POST['subscribe'])) {
            $newsletter = Newsletter::getInstance();
            if ($newsletter->subscribe($_POST['subscribe'])) {
                $GLOBALS['smarty']->assign('RSLT_SUBSCRIBED', true)));
            } else {
                $GLOBALS['smarty']->assign('RSLT_SUBSCRIBED', false)));
            }
        }
Oops! Two too many closing parens on each statement.
true);
false);
Then, in the skin template box.newsletter.php, find this sequence:

  {else}
  <form action="{$VAL_SELF}" method="post">
make it look like:

    {elseif isset($RSLT_SUBSCRIBED)}
        {if $RSLT_SUBSCRIBED}{$LANG.newsletter.notify_subscribed}{else}{$LANG.newsletter.email.invalid}{/if}
    {else}
    <form action="{$VAL_SELF}" method="post">
See what that does. (Be sure to clear the cache in CubeCart.)
Link to comment
Share on other sites

I cleared the cache and tried the solution above without any success. It removes the form, but doesn't show the success message.

 

I've used the solution you posted in this topic http://forums.cubecart.com/topic/47361-resolved-using-php-in-templates as it addresses my issue perfectly and means that we don't have to alter any core files, which is always the best approach.

 

 

This one Smarty statement should do the same as the {php} attempt:

{if !empty($smarty.get.subscribed)}<p class="confirmation">Thank you for subscribing</p>{/if}

 

See: http://www.smarty.ne....smarty.request

 

Knackering the admin area... maybe. But there is a separate controller file for the admin.

 

 

Many, many thanks for your assistance. Very much appreciated...

Link to comment
Share on other sites

Well, I really messed it up here:

                $GLOBALS['smarty']->assign('RSLT_SUBSCRIBED', true)));
            } else {
                $GLOBALS['smarty']->assign('RSLT_SUBSCRIBED', false)));

Two too many closing parentheses:

                $GLOBALS['smarty']->assign('RSLT_SUBSCRIBED', true);
            } else {
                $GLOBALS['smarty']->assign('RSLT_SUBSCRIBED', false);
Link to comment
Share on other sites

If you still want to assist on figuring this out to its finale, in the file box.newsletter.php, add {debug} at the very end. Then enter a new email address in the field.

 

When you click the submit button, a pop-up will show Smarty's diagnostics. Find the variable $RSLT_SUBSCRIBED (they are in alphabetical order).

 

If it is not there, then the PHP assign statements didn't get executed: an email address that already exists or something doesn't really look like an email address was entered.

 

If the variable is in the diagnostics, then there is a problem with the template file.

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