# Credit an Affiliate for a Missed Sale

> Checks whether a sale already has a commission and adds the missing referral with the order as its reference.

- Job: [Affiliates & loyalty](https://storeagent.ai/mcp-recipes/job/affiliates/)
- What it does: Asks first: changes your store, only after you say yes
- Time saved: ~15 min vs doing it by hand
- Requires: StoreAgent (free plugin, MCP on every plan) + AffiliateWP
- Works in: Claude, ChatGPT, Cursor and any MCP client connected to the store through StoreAgent MCP
- Web page: https://storeagent.ai/mcp-recipes/missing-affiliate-commission/

## The prompt

```text
Affiliate [name] says they sent us the customer on order [order number], but the sale was not tracked. Look up the order and show me its date, total, status and customer. Check whether a referral already exists for that order. Then show the affiliate's rate, their coupon codes, and their visits on the day of the order. Tell me in plain words whether they should be credited and how much the commission should be at their rate. Wait for my OK, then add the referral as unpaid with the order as its reference.
```

## What happens when you paste it

You: Affiliate [name] says they sent us the customer on order [order number], but the sale was not tracked…

Assistant: Order 4182 is completed, $300, placed on 9 October. No referral exists for it. Maria Lopez earns 15% and had 2 visits that day, neither converted. Calling: `woocommerce/orders-query`, `affiliatewp/list-referrals`, `affiliatewp/get-affiliate`, `affiliatewp/list-affiliate-coupons`, `affiliatewp/list-visits`, `affiliatewp/add-referral`.

Assistant: This will make changes in WooCommerce. Do you want me to go ahead?

Assistant: Added a $45.00 unpaid referral for Maria Lopez with reference 4182 and the note: Customer referred by word of mouth.

## Abilities this recipe calls

- **Find orders** (`woocommerce/orders-query`, read only, from WooCommerce): Finds orders by status, customer, email or date, with the items in each order.
- **List referrals** (`affiliatewp/list-referrals`, read only, from AffiliateWP): Lists commissions with amount, status, affiliate, customer and campaign. Filters by affiliate, status or date.
- **Get an affiliate** (`affiliatewp/get-affiliate`, read only, from AffiliateWP): Finds one affiliate by ID, username or email, with rate, group, notes, lifetime earnings and referral URL.
- **List an affiliate's coupons** (`affiliatewp/list-affiliate-coupons`, read only, from AffiliateWP): Lists the coupon codes that credit one affiliate and the discount each one gives.
- **List visits** (`affiliatewp/list-visits`, read only, from AffiliateWP): Lists affiliate link visits with landing URL, referrer, campaign and whether they converted. No IP addresses.
- **Add a referral** (`affiliatewp/add-referral`, asks first, from AffiliateWP): Adds a manual commission for a sale or lead that was not tracked.

## Variations

Add one of these to the end of the prompt. Swap anything in [brackets] for your own details.

- Use a flat [amount] instead of their rate.
- The referral already exists. Change its amount to [amount] instead.

## Related recipes

- [Loyalty Program Health Check](https://storeagent.ai/mcp-recipes/loyalty-health-check.md): Tells you if your points program is working: how many points are redeemed, what it costs you and where points come from. Needs Advanced Loyalty Program.
- [Save Loyalty Points Before They Expire](https://storeagent.ai/mcp-recipes/save-expiring-points.md): Finds customers about to lose their points and gives them a small bonus that keeps their account active. Needs Advanced Loyalty Program.
- [Reward Your Top Loyalty Members](https://storeagent.ai/mcp-recipes/reward-top-loyalty-members.md): Ranks your most loyal customers by points earned and gives them a bonus as a thank you. Needs Advanced Loyalty Program.

---

Part of the StoreAgent WooCommerce MCP Recipes directory: https://storeagent.ai/mcp-recipes/ (index for LLMs: https://storeagent.ai/mcp-recipes/llms.txt). Get StoreAgent free: https://app.storeagent.ai/sign-up/
