API Reference PhoenixKitEcommerce v#0.5.0

Copy Markdown View Source

Modules

Compat alias for PhoenixKitEcommerce.Cart. Used as Ecto schema in queries (from(c in PhoenixKit.Modules.Shop.Cart, ...)).

Compat alias for PhoenixKitEcommerce.Web.Plugs.ShopSession. Must be a real Plug so plug macro works.

Compat alias for PhoenixKitEcommerce.Web.Routes.

Compat alias for PhoenixKitEcommerce.Web.UserOrderDetails. LiveView — delegates mount, handle_params.

Compat alias for PhoenixKitEcommerce.Web.UserOrders. LiveView — delegates mount, handle_params, handle_event.

E-commerce Shop Module for PhoenixKit.

Thin wrapper around PhoenixKit.Activity.log/1 for the shop module.

Shopping cart schema with support for guest and authenticated users.

Cart item schema with price snapshot for consistency.

Embedded schema for the shop fields a catalogue category stores under category.data["ecommerce"]. See PhoenixKitEcommerce.Catalogue.ItemCommerce moduledoc for the discovery contract this namespace is reached through.

Structurally implements PhoenixKitCatalogue.Extension — the catalogue item/category form "extension slot" (spec §2 principle 8). phoenix_kit_catalogue is an optional dependency, so this module does NOT declare @behaviour PhoenixKitCatalogue.Extension; that would force it to be loaded at compile time. Discovery is duck-typed, the same pattern as PhoenixKitEcommerce.AITranslatable / ai_translatables/0: catalogue finds this module via PhoenixKitEcommerce.catalogue_extensions/0 and is responsible for checking it is actually usable before calling it.

Embedded schema for the shop fields a catalogue item stores under item.data["ecommerce"].

Normalizes a Shopify option name (e.g. "Cup Color", "Größe") into the bare attribute-set slug Writer.sync_variants/2 looks the catalogue set up by ("catalogue_set_" <> slug is the blueprint's own :name).

Function components rendering the "Shop" section that PhoenixKitEcommerce.Catalogue.Extension adds to the catalogue item and category forms. Field names/labels are ported from PhoenixKitEcommerce.Web.ProductForm's Pricing card and PhoenixKitEcommerce.Web.CategoryForm's basic-fields card, adapted to the item[ecommerce][...] / category[ecommerce][...] namespace the extension slot absorbs (see PhoenixKitCatalogue.Extensions.absorb/3).

Resolves a raw label — text as it arrives from an external source such as a Shopify option value ("Small", "Rouge") — to the value SLUG a catalogue attribute set already uses for that same choice, creating a new draft value when the set has none matching.

Writes Shopify sync changes into phoenix_kit_catalogue items — the write side of Block 3's "sync 6a" (docs/superpowers/specs/2026-09-05- catalogue-as-shop-product-list-design.md §5 Блок 3) and Block 7's 6b (same doc, same §, "Блок 7"), active only when ProductSource. current/0 is Catalogue. update_from_shopify/3/create_from_shopify/2 are called by PhoenixKitEcommerce.Shopify.Sync; sync_variants/2 (and the images/collections writers Block 7 adds alongside it) is called directly by the sync worker instead — nothing here touches phoenix_kit_shop_products (the legacy writer, Shop.update_product/2, stays the write path for the legacy source).

Category schema for product organization.

Central mapping from the error atoms returned by the e-commerce module's context, importers, image services, and web layer to translated human-readable strings.

PubSub event broadcasting for Shop module.

Gettext backend for phoenix_kit_ecommerce.

Plain-text extraction from HTML.

Converts HTML (as Shopify's body_html product field always is) into Markdown.

Analyze Shopify CSV files to extract option metadata.

Parse Shopify CSV and group rows by Handle.

Validates CSV files before import processing.

Filter products for import based on configurable rules.

Auto-detect CSV format from file headers.

Behaviour for CSV import format adapters.

Money parsing for supplier CSV feeds.

Build option values and price modifiers from Shopify variant rows.

Transform Shopify CSV rows into PhoenixKit Product format.

Prom.ua CSV format adapter implementing ImportFormat behaviour.

Main orchestrator for Shopify CSV import.

Shopify CSV format adapter implementing ImportFormat behaviour.

ImportConfig schema for configurable CSV import filtering.

ImportLog schema for tracking CSV import history.

Shared per-language slug generation for Product and Category.

Module-owned migration chain for the shop tables (phoenix_kit_shop_config, phoenix_kit_shop_shipping_methods, phoenix_kit_shop_categories, phoenix_kit_shop_products, phoenix_kit_shop_product_slugs, phoenix_kit_shop_category_slugs, phoenix_kit_shop_carts, phoenix_kit_shop_cart_items, phoenix_kit_shop_import_configs, phoenix_kit_shop_import_logs) plus the two slug-projection functions and their triggers.

Shop notifications: who hears about an order or an import, and when.

Supported option types for product options.

Context for managing product options.

Validates and normalizes product metadata for options and pricing.

Admin-controllable policy for the shop, in one place.

How a price is written on the storefront: From €40.00 /hour.

Product schema for e-commerce shop.

Behaviour for the storefront's product/category read path.

ProductSource adapter reading phoenix_kit_catalogue items/categories and returning hand-built %Product{}/%Category{} view-structs (see PhoenixKitEcommerce.ProductSource.Catalogue.View) so the facade, Options, PriceDisplay, CartItem and the storefront never need to know which adapter is active.

Ecto queries over phoenix_kit_catalogue's Item/Category schemas, scoped to the one catalogue the shop reads (get_config("shop_catalogue"), default name "decor3dprint", resolved through Catalogue.list_catalogues/0).

Builds hand-built %PhoenixKitEcommerce.Product{} / %PhoenixKitEcommerce.Category{} view-structs from a phoenix_kit_catalogue item/category, so the facade, Options, PriceDisplay, CartItem and the storefront templates read exactly the field names they read today from phoenix_kit_shop_products/ phoenix_kit_shop_categories — no behavior change on their side.

ProductSource adapter over phoenix_kit_shop_products and phoenix_kit_shop_categories.

Service for downloading images from external URLs and storing them in the Storage module.

Orchestrates batch migration of product images from external URLs to Storage module.

Shipping method schema for E-Commerce module.

Shop configuration storage schema (key-value JSONB).

Thin REST client for the Shopify Admin API's products.json endpoint.

Maps Shopify collections onto catalogue categories, preserving both orders — Block 7 Task 4 (docs/superpowers/plans/2026-09-06-block7- shopify-media-collections.md, §5 Блок 7 in the design spec), with the live-store allowlist and most-specific assignment added by Block 7b Task 2 (docs/superpowers/plans/2026-09-06-block7b-shopify-live-fixes.md) — the real store has 143 collections, of which only ~12 3d-printed-* ones are our categories; the rest (an "all products", a curated cross-category "featured" mix, per-tag collections, ...) must never become categories or move an item at all.

Compares local products against Shopify Admin API product data.

One local product's field-by-field diff against its matched Shopify product. changes only contains fields that actually differ, keyed by field atom, each holding %{current:, incoming:}. price_extreme? is true only when :price is in changes and the current/incoming ratio exceeds 3x.

Picks where a sync reads Shopify product data from: the Admin API (primary, full-fidelity) or the public storefront JSON endpoint (fallback, price-only — see PhoenixKitEcommerce.Shopify.StorefrontClient for why it is deliberately narrow).

Reads live product/price data from a store's public storefront JSON endpoint (/products.json) — no Admin API token required, because nothing is authenticated. This is the fallback price source: when the Admin API token configured for a store is missing or rejected, price sync keeps working through this keyless path instead of stalling until someone notices and rotates the token.

Orchestrates a Shopify → local product sync: fetch, diff, and selectively apply confirmed changes.

Word-level diff between two versions of a text field.

Pure mapping from a Shopify Admin API product payload's "options"/ "variants" into the shape PhoenixKitEcommerce.Catalogue.Writer. sync_variants/2 attaches as catalogue attribute sets: one set per real option (Shopify's auto-generated single-option "no variants" product — option name "Title", its lone value "Default Title" — is skipped, same as it never becomes a _option_slots entry on the legacy CSV path), values in the order they first appear across variants[], and a per-value price modifier.

Resolves URL slugs to Products and Categories with language awareness.

Localized fields helper for Shop module.

What the storefront calls the things it sells.

Provides common imports and setup for Shop module LiveViews.

Sub-permission checks for the bundled admin LiveViews.

Public cart page LiveView for E-Commerce module.

Carts admin list LiveView for E-Commerce module.

Public shop category page. Shows products filtered by category.

Public product detail page with add-to-cart functionality.

Categories list LiveView for Shop module.

Category create/edit form LiveView for Shop module.

Order confirmation page after successful checkout.

Checkout page LiveView for converting cart to order. Supports both logged-in users (with billing profiles) and guest checkout.

Reusable sidebar component for the shop storefront.

Shared helpers for storefront filter state management.

Rows for the admin settings cards: a title and its explanation on the left, the control on the right.

Reusable product display components for the shop storefront.

Shared layout wrapper for the shop storefront public pages.

Translation tabs component for Shop module forms.

E-Commerce module dashboard LiveView.

Shared helper functions for Shop public LiveViews.

Import configurations management LiveView.

LiveView for displaying import details.

Admin LiveView for managing CSV product imports.

Encapsulates option-related state for product form.

Global product options settings LiveView.

Plug that ensures a persistent shop session ID exists.

Product detail view LiveView for Shop module.

Product create/edit form LiveView for Shop module.

Products list LiveView for Shop module.

Shop module routes.

Catalog SEO assigns (canonical / hreflang / og) for the public shop LiveViews, multi-domain aware.

E-Commerce module settings LiveView.

Shipping method create/edit form LiveView.

Shipping methods list LiveView for E-Commerce module admin.

Public shop catalog main page. Shows categories and featured/active products.

Admin LiveView for the Shopify → shop one-way sync.

Test module for verifying Shop functionality

LiveView for displaying order details to the order owner.

LiveView for displaying user's shop orders.

Oban worker for background CSV import.

Oban worker for migrating product images from external URLs to Storage module.

Oban worker driving the three Block 7 catalogue writers as background jobs — Task 5 of docs/superpowers/plans/2026-09-06-block7-shopify- media-collections.md.

Mix Tasks

Finds and merges duplicate products by slug.

Installs PhoenixKit E-commerce module into parent application.