Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
v:2.0:snippets:email_notifications_subscriptions [2015/08/03 14:52] – [Optional: Change the email subject] adam | v:2.0:snippets:email_notifications_subscriptions [2023/05/02 12:17] (current) – [Combining Conditions] adam | ||
---|---|---|---|
Line 3: | Line 3: | ||
The following functionality allows you to receive email notifications for subscription events. | The following functionality allows you to receive email notifications for subscription events. | ||
- | ===== Configure | + | ===== Configure |
- | While on your store admin' | + | This page is primarily related to configuring custom email notifications that are sent to the store administrators. This approach could be applied to the main store email receipt though - so that the changes impact |
- | ===== Newly-Created Subscription Condition ===== | + | If you want to trigger a custom email receipt just for store administrators, |
- | At this snippet | + | If you want to make customisations to your main email receipt so customers see the changes as well - you will work from the **emails** template page in the administration, |
- | <code javascript> | + | ===== Newly-Created Subscription Condition ===== |
- | {% set today = " | + | |
- | {% set creation_date | + | |
+ | Add this snippet in the email template text area if you want to be notified whenever a customer registers a new subscription. | ||
- | {% if has_subscriptions and creation_date == today %} | + | <code javascript> |
- | {% set is_new_sub = 1 %} | + | {% if is_new_subscription |
+ | {# INSERT CUSTOM CODE HERE #} | ||
{% endif %} | {% endif %} | ||
- | |||
- | {% for item in items %} | ||
- | {% if item.name == "Past Due Amount" | ||
- | {% set is_new_sub = 0 %} | ||
- | {% endif %} | ||
- | {% endfor %} | ||
</ | </ | ||
- | |||
==== Optional: Change the email subject ==== | ==== Optional: Change the email subject ==== | ||
- | In case you want to modify the email subject to be more descriptive to the newly-created subscription event, add this snippet below: | + | In case you want to modify the email subject to be more descriptive to the newly-created subscription event, add this snippet below the above snippet: |
- | <code javascript> | + | <code javascript> |
- | {% set email_subject | + | {% set custom_subject |
- | {{ email_subject|fc_output_data(' | + | {{ custom_subject|fc_output_data(' |
{% endif %} | {% endif %} | ||
</ | </ | ||
+ | ==== Optional: Don't send receipts for subscription renewals ==== | ||
+ | |||
+ | If you don't want to send email receipts for subscription renewals, but just for initial subscription orders, subscription cancels and subscription updates, you can do that with a setting on your store' | ||
+ | |||
+ | If you need to handle it conditionally within your templates though, you can add the following code below the above snippet: | ||
+ | |||
+ | <code javascript> | ||
+ | {% set custom_subject = '' | ||
+ | {{ custom_subject|fc_output_data(' | ||
+ | {% endif %} | ||
+ | </ | ||
===== Cancel Subscription Condition ===== | ===== Cancel Subscription Condition ===== | ||
- | At this snippet in the **admin text email template** if you want to be notified whenever a customer cancels a subscription. | + | Add this snippet in the email template |
<code javascript> | <code javascript> | ||
Line 50: | Line 54: | ||
As with the above optional snippet, you can include this in the custom code section of the cancelled subscription condition: | As with the above optional snippet, you can include this in the custom code section of the cancelled subscription condition: | ||
- | <code javascript> | + | <code javascript> |
- | {{ email_subject|fc_output_data(' | + | {{ custom_subject|fc_output_data(' |
</ | </ | ||
- | |||
- | You wouldn' | ||
===== Modify Subscription Condition ===== | ===== Modify Subscription Condition ===== | ||
- | At this snippet in the **admin text email template** if you want to be notified whenever a customer modifies a subscription. | + | At this snippet in the email template |
<code javascript> | <code javascript> | ||
Line 69: | Line 71: | ||
===== Combining Conditions ===== | ===== Combining Conditions ===== | ||
- | Feel free to combine the conditions in one conditional statement separated by an **and** statement. | + | Feel free to combine the conditions in one conditional statement separated by an **and** statement. |
+ | |||
+ | < | ||
+ | {% set custom_subject = "" | ||
+ | |||
+ | {% if is_new_subscription %} | ||
+ | {# New Subscription Purchase #} | ||
+ | {% set custom_subject = " | ||
+ | {% elseif is_subscription_cancel %} | ||
+ | {# Subscription Cancellation #} | ||
+ | {% set custom_subject = " | ||
+ | {% elseif is_subscription_modification %} | ||
+ | {# Subscription Modification #} | ||
+ | {% set custom_subject = "Your subscription has been modified [" ~ order_id ~ " | ||
+ | {% elseif has_subscriptions and not is_updateinfo %} | ||
+ | {# Subscription Renewal #} | ||
+ | {% set custom_subject = "Your subscription has been renewed [" ~ order_id ~ " | ||
+ | {% endif %} | ||
+ | |||
+ | {% if custom_subject != "" | ||
+ | {# A custom subscription is set, so let's replace the default subscription #} | ||
+ | {{ custom_subject|fc_output_data(' | ||
+ | {% endif %} | ||
+ | </ |