> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firmhouse.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Apply third-party Shopify discounts to subscriptions

Some merchants use a third-party Shopify discount app (for example to give B2B customers with a specific tag a discount at checkout). These apps work great for giving the discount on the first Shopify order, but the discount usually does **not** automatically carry over to the recurring subscription orders that follow.

This article explains why that happens and how to make sure the same discount is applied on the Firmhouse subscription so it keeps working for all future orders.

## Why third-party app discounts don't always carry over

For a Shopify discount to also apply to the recurring subscription, it needs to be configured as a **subscription discount** in Shopify (a discount that is set up to apply to recurring orders, not only the first one).

Most third-party discount apps create one-time, automatic discounts that only apply at checkout. They don't include the recurring information that Firmhouse needs to extend the discount to renewals. The result: the customer gets the discount on their first Shopify order, but the matching subscription in Firmhouse has no applied discount, so all future orders are billed at full price.

A clear sign that this is what's happening: the discount shows up on the first Shopify order, but when you open the subscription in Firmhouse the **Applied discounts** section is empty.

## Apply the discount with Shopify Flow

The recommended workaround is to use Shopify Flow to call the Firmhouse API after checkout and apply a matching Firmhouse discount to the new subscription. This keeps everything in one place: the third-party app keeps applying the first-order discount in Shopify, and Shopify Flow makes sure Firmhouse adds the same discount to the subscription so it also applies to all future orders.

The setup is:

1. Create the recurring discount once in Firmhouse.
2. Get a Firmhouse Project Access Token.
3. Set up a Shopify Flow that runs after checkout, looks up the new subscription, and applies the Firmhouse discount to it.

### 1. Create the recurring discount in Firmhouse

Open **Discounts** in your Firmhouse portal and create the discount you want subscribers to get on every recurring order (for example, a 10% B2B discount). Activate it. See [Giving discounts to your customers](giving-discounts.md) for details.

You'll need this discount's **promotion ID** in the Shopify Flow step. You can find it by editing the discount in the portal and copying the ID from the page URL.

### 2. Get a Firmhouse Project Access Token

Shopify Flow will use a Project Access Token to authenticate calls to the Firmhouse API. See [API Access Tokens](/configure/integrations/api-access-tokens) for how to create one. Use a **Write** access token.

### 3. Create the Shopify Flow

In Shopify Admin, open **Flow** and create a new workflow:

1. **Trigger:** *Order created* (or another event that matches when the third-party app applies its discount, for example *Customer tags added* for B2B-tag based flows).
2. **Condition (optional):** Add a condition that limits the workflow to the orders you want. For example, only run when the customer has a specific tag (`b2b`) or when a specific discount code or app is involved.
3. **First action — look up the Firmhouse subscription:** Add a *Send HTTP request* action that calls the Firmhouse API to find the subscription for this Shopify order:
   * **URL:** `https://portal.firmhouse.com/graphql`
   * **HTTP method:** `POST`
   * **Headers:**
     * `Content-Type: application/json`
     * `X-Project-Access-Token: <your Firmhouse Project Access Token>`
   * **Body:**
     ```json theme={null}
     {
       "query": "query($shopifyId: String!) { getOrderBy(shopifyId: $shopifyId) { subscription { id } } }",
       "variables": {
         "shopifyId": "{{order.id}}"
       }
     }
     ```
   In the response, the subscription ID is at `data.getOrderBy.subscription.id`. Save this for the next step using the standard Flow output mapping.
4. **Second action — apply the Firmhouse discount to the subscription:** Add another *Send HTTP request* action that calls the `applyPromotionToSubscription` mutation:
   * **URL:** `https://portal.firmhouse.com/graphql`
   * **HTTP method:** `POST`
   * **Headers:** same as above.
   * **Body:**
     ```json theme={null}
     {
       "query": "mutation($subscriptionId: ID!, $promotionId: ID!) { applyPromotionToSubscription(input: { subscriptionId: $subscriptionId, promotionId: $promotionId }) { appliedPromotion { id } errors { attribute message } } }",
       "variables": {
         "subscriptionId": "<subscription id from previous step>",
         "promotionId": "<your Firmhouse promotion id>"
       }
     }
     ```

After the Flow runs, the discount will appear under **Applied discounts** on the subscription in Firmhouse, and from then on it will also apply to every recurring order.

## Verify it worked

1. Place a test order that meets the third-party app's discount conditions (for example, a checkout with a customer that has the right tag).
2. In Firmhouse, open the new subscription and check the **Applied discounts** section — your discount should be listed there.
3. Look at the next scheduled order or invoice on the subscription to confirm the discount is calculated.

## Tips

* Create a separate Firmhouse discount (and a matching Flow branch) per customer segment if you offer different percentages.
* If the third-party app changes the discount it gives at checkout, update the matching Firmhouse discount accordingly so the recurring orders stay in sync.
* If you also want Firmhouse to enforce the same product or price requirements that an automatic discount would, add `validatePromotion: true` to the mutation input.

## Related articles

* [Giving discounts to your customers](giving-discounts.md)
* [Discounts on Shopify Checkout](discounts-on-shopify-checkout.md)
* [Use Shopify Flow Triggers](/configure/integrations/shopify-flow-triggers)
* [API Access Tokens](/configure/integrations/api-access-tokens)
