Skip to content

Product Templates

ProductTemplate defines what a trip IS - its route, structure, and identity. Content is written in a source locale and can be translated when creating market-specific versions.

  • Define trip itinerary (cities, nights per stop)
  • Store base marketing content
  • Calculate trip duration automatically
  • Provide foundation for market-specific products

Table: product_templates

FieldTypePurpose
titlevarcharProduct name
subtitlevarcharMarketing tagline
skuvarcharAuto-generated: <ID>-<DAYS>
source_localevarcharContent language (e.g., en_US)
itineraryjsonbArray of stops with city, nights, details
durationintTrip length in days (auto-calculated)
highlightsjsonbKey selling points
categoriesjsonbProduct categories (beach, luxury, etc.)

Source: backend/app/Models/ProductTemplate.php

[
{
"city": "Beijing",
"nights": 2,
"title": "Arrival & Forbidden City",
"details": "Explore the historic heart of China...",
"day_image": "path/to/image.jpg"
},
{
"city": "Xi'an",
"nights": 2,
"title": "Terracotta Warriors",
"details": "Visit the legendary army..."
}
]

Cities and nights define the trip structure. Airports are NOT stored here - they are configured at the ProductByMarket level.

Duration is automatically calculated from itinerary:

duration = total_nights + 1

Example: 2 nights Beijing + 2 nights Xi’an = 4 nights + 1 = 5 days

$template->getRouteSummary(); // "Beijing -> Xi'an -> Shanghai"
$template->getTotalNights(); // 6
$template->isMultiStop(); // true if > 2 stops
$template->getItineraryCities(); // ["Beijing", "Xi'an", "Shanghai"]
$template->getItineraryWithDayOffsets(); // Adds day_offset to each stop

Source: backend/app/Models/ProductTemplate.php:183-248

Templates support AI-powered content generation:

  1. Trip Parser - Paste raw trip info, AI generates all fields
  2. Title-based Generation - Enter title, AI generates descriptions

Configuration: OPENROUTER_API_KEY environment variable

Source: backend/app/Services/ProductTemplateAIService.php

  • SKU is auto-generated on save (cannot be manually edited)
  • Duration auto-calculates from itinerary nights
  • Templates with associated ProductByMarket records are “locked”
  • Itinerary changes propagate to market products