PhoenixKitEcommerce.Catalogue.ItemCommerce (PhoenixKitEcommerce v0.5.0)

Copy Markdown View Source

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

Catalogue owns the item and never validates or renders this namespace — that is this module's job, reached only through PhoenixKitEcommerce.Catalogue.Extension (see its moduledoc for the discovery contract). Validations mirror PhoenixKitEcommerce.Product's changeset for the fields the two share.

Summary

Functions

Merges params (submitted form/API values, or nil) over current (the existing data["ecommerce"] map, or nil) and validates the result.

Changeset — same validations as PhoenixKitEcommerce.Product.changeset/2 for the fields the two share.

Types

t()

@type t() :: %PhoenixKitEcommerce.Catalogue.ItemCommerce{
  compare_at_price: term(),
  cost_per_item: term(),
  currency: term(),
  download_expiry_days: term(),
  download_limit: term(),
  file_uuid: term(),
  legacy_product_uuid: term(),
  made_to_order: term(),
  price_from: term(),
  price_modifiers: term(),
  price_on_request: term(),
  price_unit: term(),
  product_type: term(),
  requires_shipping: term(),
  shop_status: term(),
  shopify: term(),
  tags: term(),
  taxable: term(),
  translation_fingerprints: term(),
  vendor: term(),
  weight_grams: term()
}

Functions

cast(params, current)

@spec cast(map() | nil, map() | nil) ::
  {:ok, map()} | {:error, [{atom(), String.t()}]}

Merges params (submitted form/API values, or nil) over current (the existing data["ecommerce"] map, or nil) and validates the result.

Returns {:ok, map} with the full resulting namespace — defaults included, decimals rendered as strings so the map stays JSON-safe for JSONB storage — or {:error, [{field, message}]}.

changeset(struct, attrs)

@spec changeset(t(), map()) :: Ecto.Changeset.t()

Changeset — same validations as PhoenixKitEcommerce.Product.changeset/2 for the fields the two share.