Skip to content

Square Location Overrides

Why Location Overrides?

Square orders include a location_id (the store or location that received the order). You can map each Square location to a different LGL fund/campaign so that:

  • Location A (e.g. online store) → Unrestricted Fund
  • Location B (e.g. event pop-up) → Event Fund

If you don't set an override, the Square type default (configured in Mappings) is used for all Square orders.

Where to Configure

Dashboard → Mappings (or the Square location overrides section). The UI lists Square locations (from the Square API) and lets you choose an LGL fund (and optionally campaign) per location.

API: GET /api/square/location-overrides, PUT /api/square/location-overrides (admin/super_admin). The dashboard calls these to list and save overrides.

How the Worker Uses Overrides

  1. Order webhook or polling delivers an order with order.location_id.
  2. Worker calls getSquareMappingForLocation(db, order.location_id) (see lib/campaign-mapping.ts).
  3. If a row exists in square_location_overrides for that location, use its fund_id (and optional campaign_id).
  4. Otherwise use the Square type default from campaign mapping.

Data Stored

Overrides are stored in D1 table square_location_overrides (migration 013): location_id, fund_id, and optionally other LGL reference fields. Type default is in campaign_type_defaults (e.g. type "square").

Adding or Changing an Override

  1. In Dashboard → Mappings, open the Square / location overrides section.
  2. Select a Square location from the list (locations are loaded from Square API).
  3. Select the LGL fund (and campaign if needed) from the dropdowns.
  4. Save. New syncs for that location will use the new mapping.