1

This is most likely another Stash parse order issue, but I'm not sure.

I'm trying to stay DRY and use Stash inside of Cartthrob notification emails.

I have my templates set up like so:

default_site/  
- emails.group/  
-- low-inventory.html
- stash/  
-- layouts/
--- email.html  

I've set up Cartthrob to use low-inventory.html as the email notification.
I'm intending to use email.html as the wrapper layout/view file.

emails.group/low-inventory.html looks something like this:

{stash:embed:layouts:email}

{exp:stash:set name="title"}Low Stock Notification{/exp:stash:set}

{exp:stash:set name="content" parse_tags="yes"}
  {exp:channel:entries entry_id="{entry_id}"}
    Product ({title}) has a low inventory ({inventory}).
  {/exp:channel:entries}
{/exp:stash:set}

stash/layouts/email.html looks something like this:

{exp:stash:set name="img_url" type="snippet"}{site_url}images/site/{/exp:stash:set}

<html>
<body>
    <table>
        <tr>
            <td>{exp:stash:title}</td>
        </tr>
        <tr>
            <td>{exp:stash:content}</td>
        </tr>
    </table>
</body>
</html>

The email I receive in my inbox ends up looking like this:

{f9577b1c0aa0d3ee98693cf99f47a0e01185658551}

I know something like that means something hasn't been parsed properly.
Although, I'm not sure where I've gone wrong or what to change.
Or, if you know that this isn't possible with Cartthrob notifications, let me know.

Any suggestions would be appreciated. Thanks!

2
  • To clarify, I only see this in the email. If I view the template in the browser it works perfectly. – Jason Varga Jan 2 '13 at 17:13
  • Also, if I add process="start" to the {stash:embed} tag, I see the wrapper/view, but now the stash set/get tags don't seem to work. (Email and in-browser) – Jason Varga Jan 2 '13 at 17:14
2

You're seeing the placeholder code that should get replaced when the template_post_parse hook is called. I guess CT notification templates don't support that hook.

You could either use an EE embed ( assuming CT supports those) or try to get the embed to be processed later in the parse order but without relying on that hook. That would mean using process="inline" parameter for the stash embed and putting it at the bottom of the host template, rather than the top.

3
  • Not sure why I seem to be logged in as a new account. Weird. – Mark Croxton Jan 2 '13 at 20:38
  • Merged those accounts for you Mark. – Derek Hogue Jan 3 '13 at 21:29
  • I made sure all my setters were before my getters and made my embed process inline. – Jason Varga Jan 4 '13 at 14:49
1

I think it basically comes down to this: you need to set, before you get.

What if you add process="end" to the {stash:embed}? That means that the sets will happen first, and then it will process the embed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.