Shared helper functions for Shop public LiveViews.
Centralizes utility functions that were duplicated across shop_catalog, catalog_category, catalog_product, cart_page, checkout_page, and checkout_complete.
Summary
Functions
Find the best enabled language that has a slug for this entity.
Build a localized URL path, adding language prefix for non-default languages. Delegates to Routes.path which handles default vs non-default consistently.
Get the first image URL for a product.
Format a price value with currency. Returns "-" for nil price.
Extract current user from socket assigns scope.
Determine language from URL params.
Get signed URL for a Storage image file.
Convert a key string to human-readable format.
Parse page param with validation. Returns 1 for invalid/missing values.
Format address for a billing profile.
Format display name for a billing profile.
Functions
Find the best enabled language that has a slug for this entity.
Prefers the default language, then checks other enabled languages. Returns nil if no valid language found.
Build a localized URL path, adding language prefix for non-default languages. Delegates to Routes.path which handles default vs non-default consistently.
Get the first image URL for a product.
Handles Storage-based images (new format with featured_image_uuid or image_uuids) and legacy URL-based images (Shopify imports). Returns nil if no image is available.
Format a price value with currency. Returns "-" for nil price.
Extract current user from socket assigns scope.
Determine language from URL params.
Uses locale param if present, otherwise falls back to Translations.default_language/0. Used by catalog and category pages (non-product pages).
Get signed URL for a Storage image file.
Returns nil if file or variant not found (unlike product detail page which returns a placeholder). Falls back to original variant if requested variant is not available.
Convert a key string to human-readable format.
Example: "material_type" -> "Material Type"
Parse page param with validation. Returns 1 for invalid/missing values.
Format address for a billing profile.
Format display name for a billing profile.