Proper Inclusion of Modified "email_order_details.inc.twig" File

bionik_mattbionik_matt Member
in Help edited December 2013
I've modified the contents of the "email_order_details.inc.twig" file and have since included the modified version directly into the template as the 1.1 documentation suggests. Essentially I altered the HTML entities, left the logic as is, but wrapped the entire file in nested blocks. I'm calling the block inside the placeholders, having replaced the "include" function. Upon inspection of the email source code after a test transaction, the code is being displayed both in where it was pasted in the template and where the block is being called. How do I prevent it from being displayed in the pasted area so that only the block reference causes it to render?
Tagged:
Comments
  • lukeluke FoxyCart Team
    Hello Pentagear. Thanks for posting. Could you also include the store you're working with so we can take a look at your templates directly?

    With twig, I think if you define a block and call it, it will be output twice. Only when using the "use" statement, will block definitions not also output.
  • Not sure what I'm doing wrong. I keep trying to use the whisper feature, but I get:

    Body is required.
    You must select at least one recipient.
  • bionik_mattbionik_matt Member
    edited December 2013
    I've revealed the store via whisper, though I'm still pretty sure that after reading through the TWIG documentation on their site, it's based on how wrapping the block contents in an if statement, I just don't know which variables I have access to. A list of these variable names would be super helpful along with their context inside the placeholder tags.

    Otherwise, you'd have to paste the entire modified "email_order_details.inc.twig" content into the receipt page FOUR times, which just does not seem ideal.

    Seems like doubling up on the placeholders in the receipt causes no output in any of them. There's got to be a way...
  • Seems I've found the solution for this problem. The main issue that I ran into here was not the template but the lack of information regarding context identifiers such as is_order, is_updateinfo, is_subscription_cancel, and is_subscription_modification.

    I've not tested the subscription states, but the "is_order" and "is_updateinfo" are working! I had to do some trial-and-error testing based on the placeholder names trading the suffixes of _begin and _end for the prefix is_:

    {% if is_order %}{% endif %}
    {% if is_updateinfo %}{% endif %}
    {% if is_subscription_cancel %}{% endif %}
    {% if is_subscription_modification %}{% endif %}

    I think it would be good to also include this in the documentation somewhere, as it does not exist anywhere currently that I've been able to find.
  • I spoke too soon. The if statements seem to not be working since all my cart references aren't showing up.
  • Nevermind, the cart inclusion got stripped somehow. Right as rain! Going to attempt to modify the cart a bit and inline that as well.
  • winstonwinston FoxyCart Team
    @pentagear

    Glad you got it all figured out - sorry for our slow responses around the holidays!
  • @winston

    Not a problem! I do still recommend to the team about adding those context identifiers for TWIG to the 1.1 documentation somewhere. I'm sure many people would benefit from being able to access that information.

    Cheers and Happy Holidays!
Sign In or Register to comment.