# Adding a Manage Subscription Button to Order Emails

[Video: Adding a Manage Subscription Button to Order Emails](https://www.youtube.com/watch?v=qr__FDNX1Fw)

Add a **Manage your subscription** button to Shopify’s order confirmation email, right below **View your order**. The button appears **only** when the order contains a subscription product — one-time orders aren’t affected.

## Getting started

[Section titled “Getting started”](/content/docs/order-confirmation-email/index.html#getting-started)

In your Shopify admin, go to **Settings → Notifications → Customer notifications**. Under **Order processing**, click **Order confirmation**, then click **Edit code**.

## Step 1 — Find where to paste the code

[Section titled “Step 1 — Find where to paste the code”](/content/docs/order-confirmation-email/index.html#step-1--find-where-to-paste-the-code)

The template shows the **View your order** button in a few different ways depending on the order. To make the subscription button appear in every case, you’ll paste the code **after** that whole block.

1. Press **Ctrl + F** (or **Cmd + F** on Mac) and search for `Visit our store`.
2. Go to the **last** match. Just below it you’ll see these lines:

```
{% endif %}{% endunless %}

{% endif %}
```

3. Place your cursor on the empty line **after** that last `{% endif %}`, before the line that says `</td>`.

## Step 2 — Paste the code

[Section titled “Step 2 — Paste the code”](/content/docs/order-confirmation-email/index.html#step-2--paste-the-code)

```
{% assign subsy_has_subscription = false %}

{% for line in line_items %}{% if line.selling_plan_allocation %}{% assign subsy_has_subscription = true %}{% endif %}{% endfor %}

{% if subsy_has_subscription %}

<table class="row actions"><tr><td class="actions__cell"><table class="button main-action-cell"><tr>

<td class="button__cell"><a href="{{ shop.url }}/apps/subscription/customer-portal" class="button__text">Manage your subscription</a></td>

</tr></table></td></tr></table>

{% endif %}
```

After pasting, that part of the template should look like this:

```
            {% endif %}

{% assign subsy_has_subscription = false %}

... (the code you pasted) ...

{% endif %}

</td>

</tr>

</table>

</center>
```

## Step 3 — Save

[Section titled “Step 3 — Save”](/content/docs/order-confirmation-email/index.html#step-3--save)

Click **Save** at the top of the editor.

## Step 4 — Test with a real order

[Section titled “Step 4 — Test with a real order”](/content/docs/order-confirmation-email/index.html#step-4--test-with-a-real-order)

Place a test order for a subscription product on your storefront, then open the order confirmation email. **Manage your subscription** should appear below **View your order**. Click it to check the Customer Portal opens.

## Troubleshooting

[Section titled “Troubleshooting”](/content/docs/order-confirmation-email/index.html#troubleshooting)

- **The button doesn’t appear** — check the order contains a subscription product, not a one-time purchase.
- **The button appears on every order** — check you copied the full code, including the first three lines.
- **The email layout looks broken** — the code may be pasted inside another block. Click **Revert to default**, then follow Step 1 again.

## Where to go next

[Section titled “Where to go next”](/content/docs/order-confirmation-email/index.html#where-to-go-next)

- [Adding the Customer Portal](/content/docs/customer-portal-setup/index.html)
- [Managing Subscriptions](/content/docs/managing-subscriptions/index.html)
- [Adding Widgets to Your Storefront](/content/docs/storefront-setup/index.html)
