Email Custom Subject Lines

chesterpchesterp Member
Hi FC,

I've been browsing the admin and the fc doc to find where I can edit subjects lines for these scenarios
-When you make changes to your subscription
-When you cancel your subscription

It seems like there's only 1 field for this which is under

I saw settings as well for admin email but what Im trying to set a custom subject lines are for the customer.

Is there a way for me to change the subject for the cases I mentioned above?

  • fc_romanfc_roman Member, FoxyCart Team
    edited June 2016
    Hi @chesterp ,


    Inside the field you have correctly linked to, you can use Twig to generate context-specific subject lines.

    Once you're on that page, check the "Custom Text Template". This will load the email template in textarea. Insert the following code at the very top of this textarea:
    {% if is_subscription_modification %}
    {% set email_subject = "Subscription Modification Subject" %}
    {{ email_subject|fc_output_data('email_subject') }}
    {% elseif is_subscription_cancel %}
    {% set email_subject = "Subscription Cancel Subject" %}
    {{ email_subject|fc_output_data('email_subject') }}
    {% endif %}
    1. The default receipt wouldn't be sent at all. Now it should.
    2. There wouldn't be any text inside the email messages. Now there should be.
  • Interesting - in order to have a different subject in different languages, can is use the following mod then ? (all our products contain a locale and a lang)

    {% if (lang == "fr" || lang == "FR") %}
    {% set email_subject = "French subject line here" %}
    {{ email_subject|fc_output_data('email_subject') }}

    {% elseif (lang == "es" || lang == "ES") %}
    {% set email_subject = "Spanish subject line here" %}
    {{ email_subject|fc_output_data('email_subject') }}

    {% elseif (lang == "de" || lang == "DE") %}
    {% set email_subject = "German subject line here" %}
    {{ email_subject|fc_output_data('email_subject') }}


    {% endif %}
  • fc_adamfc_adam FoxyCart Team

    That approach could work for you, definitely. If you're using the latest iteration of our multiple languages snippet, that also adds in support for a custom language string for each different language to customise the subject too. Details on that here:

    As an aside, you could simplify your twig a little to only have to check once for each language code:

    {% if lang|upper == "DE" %}
  • @fc_roman @fc_adam

    Thanks for you response.

    I tried that and put those sample Codes on both text templates here

    But it's not working, I'm still getting the "Welcome to Test Report" which is the main receipt email subject line whenever I update my subscription or cancel a subscription. I was thinking of removing that, leaving it blank but I',m sure I wont get any email messages based on the label information.
  • fc_adamfc_adam FoxyCart Team

    Could you confirm what store you're applying this to?

    While I don't think it's causing your issue - you don't need the last {% else %} portion on your template - the else is handled by the default subject line set on your email.
  • @fc_adam

    At firstI don't have that else, but I also tried removing the main subject line then added that else, but nothing happens.

    I already removed that else and put back the subject line.

    I whispered you the store url.
  • fc_adamfc_adam FoxyCart Team

    Thanks for whispering that. Removing the actual subject line will stop the email from sending at all as you noticed.

    In terms of the issue you're experiencing with the twig logic - it had me stumped for a bit! The issue turned out to be the colon in your text, it was causing it to not work correctly. I'll create a bug report on our side to correct that, but in the meantime if you switch out to using some other delimiter such as a dash, that should get the subject working for you.
  • Guys,

    I haven't tried this custom code yet for subjects since I'm a bit confused.

    It looks like I need to manually enter the subject into the custom code?? But aren't these language fields already designated for the email subjects ?? >

  • fc_adamfc_adam FoxyCart Team

    Sorry for the confusion there - the "subject.." language strings there are what is used in the header area of the emails - it's not actually used for the subject line of the emails. To customise it you will need to use the Twig we discussed earlier.
  • @fc_adam Ok got it. Thanks.

    Roman said to update the "Custom Text Template" but I assume the "Custom Template" for the HTML email also needs to be updated right?

    Is this the correct placement of the twig? After the closing HTML tag?

  • fc_adamfc_adam FoxyCart Team

    That positioning is fine - you can place it anywhere within the template, but for readability I'd recommend either right at the top or at the bottom.
Sign In or Register to comment.