Add shipping cost field and render zero-dollar prices as "free"
Summary
- Adds a nullable
shipping_costinteger column tolistings(0 = ships free, >0 = ships for that amount, null = unspecified). - The admin new/edit forms show a shipping cost input only when "willing to ship" is checked (same conditional pattern as bundle price on quantity > 1).
-
formatPrice(0)now returns"free", so bothprice === 0andshippingCost === 0render consistently as "free" on the listing card and detail page. The detail page special-casesprice === 0to render just "free" (skips the awkward "firm"/"or best offer" suffix). - On the listing detail page, the old
ships/local pickup onlyline now shows one of:local pickup only,ships,ships free, orships for $5, depending onships+shippingCost.metaDescriptionis updated to match.
Test plan
-
pnpm db:migrateapplies0005_lovely_maria_hill.sqlcleanly. -
/admin/new: the shipping-cost field is hidden until "willing to ship" is checked, and persists on submit (try 0, positive, blank). -
/admin/edit/[id]: shipping cost loads from the existing row, toggles with the ships checkbox, and saves correctly. -
/sale/[shortId]: visually check all six display states (price=0, price>0) × (ships=false, ships=true+null, ships=true+0, ships=true+>0). -
/grid: free items show "free" on the card viaformatPrice. -
Submitting a negative shipping cost returns "valid shipping cost required". -
pnpm checkpasses (already verified locally).