# Recipe 7: signed paperbacks and merch

For an agent helping an author sell signed copies, special editions and merch (bookmarks,
stickers, tote bags, mugs, prints) from their own site on Beautiful (beautiful.site). It builds on
the site from recipe 1 (https://beautiful.site/recipes/authors/website.md), and shares the shop
page and the store with recipe 6 (https://beautiful.site/recipes/authors/sell-direct.md). Read
https://beautiful.site/llms.txt first.

Beautiful never takes payments. The author's store does (Payhip or Shopify), with its shipping
rates and stock. The site shows what's for sale, says when something is sold out or when to order
by, and takes dedication requests ("To Maya, happy birthday").

## 1. What the author gets

- "Signed paperback · $22" on each book page they sign, and "Sold out" when the run is gone.
- A shop page (`/shop/`) with the ebooks (recipe 6), the signed copies and the merch, each with a
  photo, price and a line on how it ships.
- Limited runs that stop selling when they're gone: the store counts stock, the site says
  "Only 50 signed" and switches to "Sold out" when the author says (or on a date).
- A dedication form for buyers: the order number and who to sign it to, kept on Beautiful and
  emailed to the author.
- A notice at the top of the shop when it matters: "Order by December 10 for Christmas", "Shop
  closed while I'm at a convention until June 3".

## 2. Before you start

- **Recipe 1 is done.** Recipe 6 is optional: this recipe's shop page shows ebooks too.
- **The author ships.** Signed books and merch go out from their home, or from a printer that
  ships for them (print-on-demand merch). They need packaging and a shipping account (section 4).
  Say so plainly: it's work, and it's why most authors limit signed runs.
- **The store needs shipping rates.** The author sets them in the store; the site doesn't
  calculate shipping.
- **Photos.** One photo per item, ideally square, on a plain background. Phone photos are fine.
- **A paid site** for the dedication form to take messages (Beautiful forms take messages once the
  site is paid for). Everything else works on a trial.
- **Time**: one to two hours of the author's time in the store; twenty minutes of yours.

## 3. Talk to the author

Ask in one message:

> Let's set up signed copies and merch. A few questions:
>
> 1. Which books will you sign, in which edition (paperback, hardcover, a special edition), and at
>    what price?
> 2. Is each a limited run (how many?) or open while you have stock?
> 3. What merch, at what prices? Do you have it already, or would a print-on-demand service make
>    and ship it (shirts, mugs, totes)?
> 4. Where do you ship: your own country only, or worldwide? Do you have a shipping account
>    (Pirate Ship, Royal Mail Click & Drop, Canada Post, Australia Post…)?
> 5. Will you personalize: sign to a name, add a short message? Any limit on length?
> 6. Do you have a store already (Payhip, Shopify)? If you sell ebooks direct, we'll use the same
>    one.
> 7. Any dates readers should know: last order day for the holidays, a break while you travel?
> 8. Photos of each item, or I'll use the cover for the books until you have them.

| Question | Why | Default |
| --- | --- | --- |
| Books, edition, price | `direct.signed`, `direct.signedPrice` | Ask: never guess a price |
| Limited run | The stock line, "Sold out" | Open, no stock line |
| Merch | `src/data/merch.json` | None: signed books only |
| Where they ship | The shop's shipping line, store rates | Their own country only |
| Personalize | The dedication form | Signed only, no names |
| A store | Section 4 | Payhip, or the one recipe 6 set up |
| Dates | `notice` in `merch.json` | No notice |
| Photos | The shop page | The book's cover; for merch, ask (no photo, no listing) |

## 4. Pick the services

| The author | Store | Why |
| --- | --- | --- |
| Uses Payhip (recipe 6) or nothing yet | **Payhip**, physical products | One store for ebooks and print. Stock limit, shipping rates by country, its checkout opens on the site |
| Has Shopify | **Shopify** | Better for many products, variants (sizes, colors) and print-on-demand apps |
| Wants shirts, mugs, totes without stocking them | **Shopify with Printful or Printify** | The printer makes and ships each order; the author never touches it. Payhip has no print-on-demand |
| Sells only at events | Neither yet | Recipe 11 (events) instead; come back when they want online orders |

**Shipping.** Books ship cheapest as books: US Media Mail (books only: no merch in the parcel, or
it isn't Media Mail), Royal Mail Large Letter for a single paperback in the UK. Pirate Ship (US)
and Click & Drop (UK) print discounted labels. Worldwide shipping for a paperback often costs more
than the book: suggest a signed **bookplate** (a signed sticker, posted in an envelope) for
readers abroad.

### Payhip, for the author

1. Products, Add product, **Physical product**, for each item: title, price, photos, description.
2. Turn on **Limit quantity** and enter the run (50) for a limited run. Payhip stops selling at 0.
3. Settings, Shipping: a rate for each country or region they ship to, and "Don't ship to other
   countries" if they only ship at home.
4. Send me each product's link (`https://payhip.com/b/…`).

### Shopify, for the author

1. Products, Add product: title, price, photos, "This is a physical product" on, weight, and
   inventory (quantity, "Continue selling when out of stock" **off**).
2. Settings, Shipping and delivery: rates for each zone.
3. Print-on-demand: install Printful or Printify from the Shopify App Store, design the item there,
   and it adds the product to Shopify.
4. Send me each product's link.

## 5. How it works

```
src/content/books/<id>.md          direct.signed: the product link; signedPrice; signedRun; signedSoldOut
src/data/merch.json                the merch, the shop notice, the shipping line, the dedication form on or off
src/data/shop.json                 recipe 6's store settings (the shop page reads both)
src/pages/shop.astro               /shop/: notice, ebooks direct, signed copies, merch, bundles
src/pages/shop/dedication.astro    the dedication form (Beautiful form "dedication")
src/pages/shop/dedication/thanks.astro
```

The store holds the stock and stops selling at zero. The site can't see the store's stock, so
"Sold out" on the site is set by you: the author tells you, or you set `soldOut` with the
release that ends a run (`write_files` with `publish_at`, recipe 8). Until then, a reader who clicks a sold-out
item sees the store's own "sold out".

The dedication form is a plain Beautiful form: what readers send is emailed to the author and kept
for them, and you read it with `list_form_submissions`. The store's order confirmation links to
it (section 6, step 6).

## 6. Build it

1. In `src/content.config.ts`, give `direct` the signed run and the sold-out flag. Replace

   ```ts
           signedPrice: z.string().optional(),
   ```

   with

   ```ts
           signedPrice: z.string().optional(),
           signedRun: z.number().optional(), // a limited run: "Only 50 signed"
           signedSoldOut: z.boolean().default(false),
   ```

2. In `src/components/BuyButtons.astro`, show the sold-out state. Replace

   ```astro
       {direct.signed && status === "available" && (
         <a class="button" href={direct.signed}>
           Signed {print}{direct.signedPrice && ` · ${direct.signedPrice}`}
         </a>
       )}
   ```

   with

   ```astro
       {direct.signed && status === "available" && (direct.signedSoldOut ? (
         <span class="button soldout" aria-disabled="true">Signed {print} · Sold out</span>
       ) : (
         <a class="button" href={direct.signed}>
           Signed {print}{direct.signedPrice && ` · ${direct.signedPrice}`}
         </a>
       ))}
   ```

3. For each book they sign, add to its front matter (beside recipe 6's `ebook` if it's there) (each book is an entry: `edit_post` with `track_changes: false` and `save: true`, then `publish_post`):

   ```yaml
   direct:
     signed: https://payhip.com/b/Sgn01
     signedPrice: $22
     signedRun: 50
   ```

4. Copy the files below. If recipe 6 isn't done, also copy its `src/data/shop.json`, given under
   "src/data/shop.json, only without recipe 6" below (the recipe's copy command skips it, so copy
   that one by hand). This recipe's `src/pages/shop.astro`
   replaces recipe 6's: it shows everything recipe 6's did, plus the signed copies and merch.
5. Rewrite `src/data/merch.json` with the author's own: the copy command writes the example
   below (an author in Maine, US prices), which would go live as it is. Each item's name, price,
   link, photo, how it ships, and `run` for a limited one; their notice and shipping line, or `""`.
   Photos go in `public/shop/`. Leave `items` empty for signed books only.
6. The dedication form, if they personalize: in the store's order confirmation (Payhip:
   Settings, Checkout, "Message after purchase"; Shopify: Settings, Checkout, "Order status page"
   additional content), the author adds: "Want it signed to someone? Tell me here:
   https://<their site>/shop/dedication/". Set `dedication.on` to `false` if they don't
   personalize.
7. Add `{ "label": "Shop", "href": "/shop/" }` to `nav` in `src/data/site.json` if recipe 6
   didn't.
8. Add the CSS for the sold-out button to `src/styles/global.css`:
   `.button.soldout { opacity: 0.55; cursor: default; text-decoration: line-through; }`
9. Publish, and test (section 7).

### src/data/merch.json

```json
{
  "notice": "Order by December 10 for Christmas delivery in the US.",
  "shipping": "Signed books and merch ship from Maine within 5 days. US only; readers abroad can order a signed bookplate.",
  "dedication": { "on": true, "max": 120 },
  "items": [
    {
      "id": "bookplate",
      "name": "Signed bookplate",
      "price": "$5",
      "url": "https://payhip.com/b/Plt01",
      "photo": "/shop/bookplate.jpg",
      "alt": "A cream bookplate signed in black ink",
      "ships": "Worldwide, in an envelope",
      "run": 0,
      "soldOut": false
    },
    {
      "id": "harbor-tote",
      "name": "Saltwater Bay tote",
      "price": "$24",
      "url": "https://payhip.com/b/Tote1",
      "photo": "/shop/harbor-tote.jpg",
      "alt": "A natural canvas tote printed with a navy harbor map",
      "ships": "US only",
      "run": 100,
      "soldOut": false
    }
  ]
}
```

- `notice`: one line at the top of the shop, or `""`.
- `alt`: what the photo shows, for readers who can't see it.
- `run`: a limited run's size ("Only 100 made"), or `0` for open stock.
- `soldOut`: set to `true` when the store sells the last one.

### src/data/shop.json, only without recipe 6

```json
{
  "store": "payhip",
  "overlay": true,
  "why": "",
  "bundles": []
}
```

### src/pages/shop.astro

```astro
---
// The author's shop (recipes 6 and 7): ebooks direct, signed copies, merch, bundles. The store
// does the selling and the stock; these are links to it.
import Base from "../layouts/Base.astro";
import site from "../data/site.json";
import shop from "../data/shop.json";
import merch from "../data/merch.json";
import { allBooks } from "../utils/books";
const all = await allBooks();
const ebooks = all.filter((b) => b.data.direct.ebook && b.data.status !== "announced");
const signed = all.filter((b) => b.data.direct.signed && b.data.status === "available");
const title = (id: string) => all.find((b) => b.id === id)?.data.title ?? id;
const print = (formats: string[]) => formats.find((f) => /paperback|hardcover/i.test(f))?.toLowerCase() ?? "copy";
---
<Base title="Shop" description={`Buy ${site.name}'s books, signed copies and merch direct.`}>
  {merch.notice && <p class="notice">{merch.notice}</p>}
  <section class="section">
    <h1>Shop</h1>
    {shop.why && <p class="lead">{shop.why}</p>}
  </section>
  {signed.length > 0 && (
    <section class="section">
      <h2>Signed copies</h2>
      <ul class="shop">
        {signed.map((b) => (
          <li>
            <a href={`/books/${b.id}/`}><img src={b.data.cover} alt={b.data.coverAlt ?? `The cover of ${b.data.title}`} width="160" height="240" loading="lazy" /></a>
            <h3>{b.data.title}, signed {print(b.data.formats)}</h3>
            {b.data.direct.signedRun && !b.data.direct.signedSoldOut && <p class="muted">Only {b.data.direct.signedRun} signed</p>}
            {b.data.direct.signedSoldOut ? (
              <p><span class="button soldout" aria-disabled="true">Sold out</span></p>
            ) : (
              <p><a class="button primary" href={b.data.direct.signed}>Buy signed{b.data.direct.signedPrice && ` · ${b.data.direct.signedPrice}`}</a></p>
            )}
          </li>
        ))}
      </ul>
    </section>
  )}
  {merch.items.length > 0 && (
    <section class="section">
      <h2>Merch</h2>
      <ul class="shop">
        {merch.items.map((m) => (
          <li>
            <img src={m.photo} alt={m.alt || m.name} width="240" height="240" loading="lazy" />
            <h3>{m.name}</h3>
            <p class="muted">{m.ships}{m.run > 0 && !m.soldOut && ` · Only ${m.run} made`}</p>
            {m.soldOut ? (
              <p><span class="button soldout" aria-disabled="true">Sold out</span></p>
            ) : (
              <p><a class="button primary" href={m.url}>Buy · {m.price}</a></p>
            )}
          </li>
        ))}
      </ul>
    </section>
  )}
  {ebooks.length > 0 && (
    <section class="section">
      <h2>Ebooks</h2>
      <ul class="shop">
        {ebooks.map((b) => (
          <li>
            <a href={`/books/${b.id}/`}><img src={b.data.cover} alt={b.data.coverAlt ?? `The cover of ${b.data.title}`} width="160" height="240" loading="lazy" /></a>
            <h3>{b.data.title}</h3>
            <p><a class="button primary" href={b.data.direct.ebook}>{b.data.status === "preorder" ? "Preorder" : "Buy"} the ebook{b.data.direct.ebookPrice && ` · ${b.data.direct.ebookPrice}`}</a></p>
          </li>
        ))}
      </ul>
    </section>
  )}
  {shop.bundles.length > 0 && (
    <section class="section">
      <h2>Bundles</h2>
      <ul class="shop">
        {shop.bundles.map((x) => (
          <li>
            {x.cover && <img src={x.cover} alt={`The cover of ${x.title}`} width="160" height="240" loading="lazy" />}
            <h3>{x.title}</h3>
            <p class="muted">{x.books.map(title).join(", ")}</p>
            <p><a class="button primary" href={x.url}>Buy the bundle · {x.price}</a></p>
          </li>
        ))}
      </ul>
    </section>
  )}
  <section class="section">
    {merch.shipping && <p>{merch.shipping}</p>}
    {merch.dedication.on && signed.length > 0 && <p>Want a signed copy made out to someone? After you order, <a href="/shop/dedication/">tell me who to sign it to</a>.</p>}
    <p class="muted">Questions about an order? Write to {site.contact}.</p>
  </section>
</Base>
<style>
  .notice { margin: 0; padding: 12px 16px; text-align: center; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
  .shop { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 32px; }
  .shop img { border-radius: 4px; box-shadow: 0 8px 20px rgb(0 0 0 / 0.16); height: auto; max-width: 100%; aspect-ratio: auto; object-fit: cover; }
  .shop h3 { font-size: 1.05rem; margin: 12px 0 4px; }
</style>
```

### src/pages/shop/dedication.astro

```astro
---
// Who to sign a copy to (recipe 7). A Beautiful form: each request is emailed to the author and
// kept for them (list_form_submissions, form "dedication").
import Base from "../../layouts/Base.astro";
import merch from "../../data/merch.json";
---
<Base title="Sign it to someone" description="Tell me who to sign your copy to." signup={false}>
  <section class="section narrow">
    <h1>Who should I sign it to?</h1>
    <p class="lead">Send this after you order, and I'll sign your copy before it ships.</p>
    <form class="card-form" data-bty-form="dedication" data-bty-redirect="/shop/dedication/thanks/">
      <label>Your order number <input name="order" required maxlength="40" autocomplete="off" /></label>
      <label>The email you ordered with <input name="email" type="email" required autocomplete="email" /></label>
      <label>Sign it to <input name="to" required maxlength="60" placeholder="Maya" /></label>
      <label>A short message (optional) <textarea name="message" rows="3" maxlength={merch.dedication.max} placeholder="Happy birthday!"></textarea></label>
      <p class="muted">Up to {merch.dedication.max} characters. I'll write it as you spell it.</p>
      <button class="button primary" type="submit">Send</button>
      <p data-bty-status></p>
    </form>
  </section>
</Base>
<style>
  .narrow { max-width: 560px; }
  .card-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .card-form label { display: grid; gap: 6px; font-weight: 600; }
  .card-form input, .card-form textarea { box-sizing: border-box; max-width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: inherit; }
</style>
```

### src/pages/shop/dedication/thanks.astro

```astro
---
import Base from "../../../layouts/Base.astro";
---
<Base title="Got it" signup={false}>
  <section class="section narrow">
    <h1>Got it, thank you</h1>
    <p class="lead">I'll sign it just as you asked before it ships. If you made a mistake, send the form again with the same order number.</p>
    <p><a href="/shop/">Back to the shop</a></p>
  </section>
</Base>
```

## 7. Test it

1. `/shop/` at desktop and phone width (`screenshot`): the notice, signed copies with "Only 50
   signed", the merch with photos and how each ships, the ebooks (if recipe 6 is done), the
   shipping line. Every price matches the store's.
2. Each product link: open it, and check it's that item at that price, and that shipping to a
   country they don't ship to is refused at checkout (ask the author to try one address abroad,
   or check the store's shipping settings with them).
3. A book they sign: its page has "Signed paperback · $22". Set `signedSoldOut: true` on a preview
   (`write_files` then `deploy` with `production: false`; REST: `POST /v1/sites/{site}/changesets` with `{ "files": [{ "path", "content" }] }`, then `POST …/deploys` with `{ "production": false }`, and open its `preview_url`) and check the button reads "Sold out" and isn't a link.
   Set it back.
4. The dedication form on the live site (paid sites only): send one with order "TEST", then
   `list_form_submissions` (form `dedication`) shows it, and the author got the email. Tell the
   author it was you. How to send a test through this form: from a browser, as a reader would. Where the page's spam check (Cloudflare Turnstile) can't be passed, as in a headless browser, the form still sends, after up to a minute, and the message is held for review: `list_form_submissions` with `spam: true` shows it, and nobody is emailed. That still proves the form works. A script that posts the form itself lands there too. With no browser to run, ask the author to send one from their phone and check it arrived.

## 8. Hand it over

> Your shop is live at [url]/shop/: signed copies of [books], and [merch]. Readers pay in
> [store], which stops selling at [n] for the limited runs and charges your shipping rates.
>
> After each order, readers can tell you who to sign it to at [url]/shop/dedication/. Those come
> to your email, and I can list them any time ("what dedications came in this week?").
>
> When something sells out, tell me and I'll mark it on the site (the store already stops selling
> it). Before the holidays, tell me your last order day and I'll put it at the top of the shop.

## 9. Keep it running

- **Sold out.** The author says so (or the store's email does): set `signedSoldOut: true` or the
  item's `soldOut: true`, and publish. A run that ends on a date ("signed copies until launch
  week ends"): the book is a CMS entry, so `edit_post` it with `signedSoldOut: true` and
  `save: true`, then `publish_post` with `publish_at` at that minute (the live book stays as it is
  until then). An item in `merch.json`: `write_files` with the file changed and `publish_at`.
- **Restock.** Back to `false`, and the author raises the stock in the store.
- **Dedications for a batch of orders.** `list_form_submissions` with form `dedication`, then give
  the author a list: order, name, message. With many orders, the CSV:
  `GET /v1/sites/{site}/forms/dedication/submissions?format=csv`.
- **The holidays.** Set `notice` a month before ("Order by December 10…"), and schedule a release
  that changes it the day after the last order day ("Orders now ship after January 2").
- **A convention or a break.** `notice` says so, and the author pauses the products in the store.
- **New merch.** A new item in `merch.json` with its photo, once the store has the product.

## 10. When it goes wrong

| What you see | Why | Fix |
| --- | --- | --- |
| A reader bought a sold-out item | The store's stock wasn't limited | Author: Payhip, the product, Limit quantity; Shopify, inventory with "Continue selling" off. They refund the extra orders |
| The site says "Sold out" but the store still sells | `soldOut` set, store not paused | Author pauses or zeroes it in the store |
| Shipping wasn't charged | No rate for that country | Author: the store's shipping settings |
| The dedication form says it isn't taking messages yet | The site isn't paid for | Forms take messages on paid sites; until then the author asks by email |
| A dedication came in for an order that doesn't exist | A typo, or a reader filling it before ordering | Author checks the email it came from against their orders |
| `template_error` in `shop.astro` | `merch.json` or `shop.json` is missing, or missing a key | Both are needed, with every key above (`[]` and `""` are fine) |
