# Affiliates

Run your own affiliate programme, without a network: bloggers, creators or partner shops send you customers through
a link or a coupon, and the orders they bring are credited to them. Find it under **Afiliați** in the admin menu; its
settings are in **Setări → Afiliere**. Both need *Manages the affiliate programme* (Shop manager and Marketing by
default).

Orders are credited from the day you add the first affiliate, and each credited order opens a commission. Payouts
come next; until then **Comisioane** is the record you settle from.

## Adding an affiliate

**Afiliat nou** asks for:

- **Nume** and **E-mail**. If a customer account has the same e-mail, orders from that account through the affiliate's
  own link or coupon are flagged for review.
- **Cod de link**: letters, digits, `-` and `_`. Their link is the address of any page of the shop with `?ref=CODE` at
  the end, for example `https://yourshop.ro/?ref=ANA` or a product page with `?ref=ANA`.
- **Cupon** (optional): the code of a voucher you created in **Promoții → Vouchere**. An order that uses it is credited
  to the affiliate, with no cookie involved, so it also works in the mobile app and when the visitor refuses cookies.
- **Comision**: the percent of the products' value, without VAT, shipping and SGR deposits. Empty uses the default
  from the settings.
- **Stare**: *Activ*, or *Oprit* to stop their link and coupon from crediting new orders (what was credited stays).

An affiliate's page shows their link, their clicks over the last 30 days, and the last 50 orders credited to them,
each with how it came (link or coupon) and any flag.

## Applications from customers

To let customers apply, turn on **Clienții pot aplica din cont** in **Setări → Afiliere** and give the address of the
page with the programme's terms (commission, payment, what is not allowed); without terms the sign-up can't open.
Their account then shows **Afiliere** with a short form: the name to display, where they publish, a few lines about
themselves, and the terms to accept. Their account's e-mail is used.

Each application appears at the top of **Afiliați** as **Cerere nouă**, with what they wrote. Open it, change the
code if you like, and set the state to **Activ** to accept it or **Respins** to turn it down, then save: the applicant
gets an e-mail either way.

An accepted affiliate's **Afiliere** page shows their link (it works with any page), their coupon if you gave one,
their rate, their clicks over 30 days, the orders they brought, what is pending and approved, and their latest
commissions with the products' value. It never shows who bought: no order numbers, names or addresses.

## How an order is credited

1. A visitor arrives through an affiliate's link. The click is counted (per day, nothing about the visitor) and the
   visit is remembered while they browse.
2. If they have accepted **marketing** cookies, the visit is also kept in a cookie (`syncshop_ref`) for the number of
   days set in the settings (30 by default). If they haven't, nothing beyond the visit is kept, and their order is
   not credited through the link. If they withdraw the consent later, the cookie is deleted.
3. When the order is placed, it is credited to one affiliate:
   - the affiliate whose **coupon** the order used, or
   - the affiliate whose **link** the visitor came through, within the window and with marketing cookies allowed.

   When both apply to different affiliates, the coupon wins (switchable). When a visitor clicks several affiliates'
   links, the latest wins (switchable to the first).
4. Two kinds of order are still credited, but flagged for you to check, and their commissions are never approved by
   themselves:
   - an affiliate ordering through their own link or coupon (*Comandă prin propriul link sau cupon*);
   - the third order or more for one affiliate from the same internet address within 30 days (*Multe comenzi de la
     aceeași adresă*): often the affiliate, a household or an office ordering for itself. The address is kept only as
     a scrambled code, for 90 days, and is never shown.

The order's page in the admin shows the affiliate under **Client**, with a link to them.

## Commissions

Every credited order opens a commission in **Afiliați → Comisioane**:

- **Value**: the products' price without VAT, after promotions and vouchers; no delivery, no SGR deposit, no gift
  cards. It follows the order: a refunded withdrawal lowers it, a cancelled or fully returned order cancels it.
- **Rate**: the affiliate's own, or the default from the settings, fixed when the order is credited.
- **În așteptare** (pending) until the order has gone out (shipped or handed over in store) and the days set in
  **Setări → Afiliere → Comisionul se aprobă după** have passed (30 by default; they cover the 14-day withdrawal
  and the way back of a return). A task every night at 04:10 approves the ones whose time came and cancels the ones
  whose order went (see [Scheduled tasks](scheduled-tasks.md)).
- A commission flagged for review (the affiliate's own order) is never approved by itself. **Aprobă** approves any
  pending commission at once; **Altfel** lets you approve it at another amount or cancel it, each with a reason.
- **Aprobat** (approved) is final: the commission is booked in the profit figures as a marketing cost on the day
  it was approved, and it is what you owe the affiliate.

The top of the page sums what is pending, approved and cancelled, for everyone or for one affiliate; an affiliate's
page shows their pending and approved totals and each order's commission.
