Skip to content

Add shipping cost field and render zero-dollar prices as "free"

jedmund requested to merge jedmund/shipping-cost into main

Summary

  • Adds a nullable shipping_cost integer column to listings (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 both price === 0 and shippingCost === 0 render consistently as "free" on the listing card and detail page. The detail page special-cases price === 0 to render just "free" (skips the awkward "firm"/"or best offer" suffix).
  • On the listing detail page, the old ships / local pickup only line now shows one of: local pickup only, ships, ships free, or ships for $5, depending on ships + shippingCost. metaDescription is updated to match.

Test plan

  • pnpm db:migrate applies 0005_lovely_maria_hill.sql cleanly.
  • /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 via formatPrice.
  • Submitting a negative shipping cost returns "valid shipping cost required".
  • pnpm check passes (already verified locally).

🤖 Generated with Claude Code

Merge request reports

Loading