pify/storefront/product

Storefront products: one by handle, a page of the catalog, and the recommendations for one product.

Types

pub type PriceRange {
  PriceRange(
    min_variant_price: money.Money,
    max_variant_price: money.Money,
  )
}

Constructors

pub type Product {
  Product(
    id: String,
    handle: String,
    title: String,
    description: String,
    description_html: String,
    vendor: String,
    product_type: String,
    tags: List(String),
    available_for_sale: Bool,
    updated_at: String,
    options: List(ProductOption),
    price_range: PriceRange,
    compare_at_price_range: PriceRange,
    featured_image: option.Option(storefront.Image),
    images: List(storefront.Image),
    variants: List(Variant),
    has_more_variants: Bool,
    seo: storefront.Seo,
    metafields: List(storefront.Metafield),
  )
}

Constructors

  • Product(
      id: String,
      handle: String,
      title: String,
      description: String,
      description_html: String,
      vendor: String,
      product_type: String,
      tags: List(String),
      available_for_sale: Bool,
      updated_at: String,
      options: List(ProductOption),
      price_range: PriceRange,
      compare_at_price_range: PriceRange,
      featured_image: option.Option(storefront.Image),
      images: List(storefront.Image),
      variants: List(Variant),
      has_more_variants: Bool,
      seo: storefront.Seo,
      metafields: List(storefront.Metafield),
    )

    Arguments

    has_more_variants

    The product has more variants than the read returned: variants_per_product for by_handle, variants_per_page for a page of products.

pub type ProductOption {
  ProductOption(id: String, name: String, values: List(String))
}

Constructors

  • ProductOption(id: String, name: String, values: List(String))

One page of list. search is Shopify’s product search syntax.

pub type ProductPage {
  ProductPage(
    first: Int,
    after: option.Option(String),
    search: option.Option(String),
    sort: ProductSort,
    reverse: Bool,
  )
}

Constructors

pub type ProductSort {
  ProductSortTitle
  ProductSortProductType
  ProductSortVendor
  ProductSortUpdatedAt
  ProductSortCreatedAt
  ProductSortBestSelling
  ProductSortPrice
  ProductSortId
  ProductSortRelevance
}

Constructors

  • ProductSortTitle
  • ProductSortProductType
  • ProductSortVendor
  • ProductSortUpdatedAt
  • ProductSortCreatedAt
  • ProductSortBestSelling
  • ProductSortPrice
  • ProductSortId
  • ProductSortRelevance
pub type Variant {
  Variant(
    id: String,
    title: String,
    sku: option.Option(String),
    available_for_sale: Bool,
    price: money.Money,
    compare_at_price: option.Option(money.Money),
    selected_options: List(storefront.SelectedOption),
    image: option.Option(storefront.Image),
  )
}

Constructors

Values

pub fn by_handle(
  client: storefront.StorefrontClient,
  handle: String,
  metafields: List(storefront.MetafieldIdentifier),
) -> effect.Effect(
  Result(option.Option(Product), error.ShopifyError),
  key,
)
pub const by_handle_query: String
pub const fields: String

The fields of one product: 20 images and variants_per_product variants.

pub fn first_page(first: Int) -> ProductPage

The first page of the catalog by title.

pub const list_query: String
pub fn list_variables(
  page: ProductPage,
  metafields: List(storefront.MetafieldIdentifier),
) -> json.Json
pub const page_fields: String

The fields of each product in a page: the featured image only and variants_per_page variants, so a page stays under Shopify’s query cost.

pub fn product_sort_to_string(sort: ProductSort) -> String
pub fn recommendations(
  client: storefront.StorefrontClient,
  product_id: String,
  metafields: List(storefront.MetafieldIdentifier),
) -> effect.Effect(Result(List(Product), error.ShopifyError), key)

Shopify answers null for a product it has no recommendations for; that reads as an empty list.

pub const recommendations_query: String
pub fn variant_decoder() -> decode.Decoder(Variant)

Reads the fields variant_fields selects.

pub const variant_fields: String
pub const variants_per_page: Int
pub const variants_per_product: Int
✨ Search Document