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
-
PriceRange( min_variant_price: money.Money, max_variant_price: money.Money, )
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_productforby_handle,variants_per_pagefor 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
-
ProductPage( first: Int, after: option.Option(String), search: option.Option(String), sort: ProductSort, reverse: Bool, )
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
-
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), )
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 fn decoder() -> decode.Decoder(Product)
pub const fields: String
The fields of one product: 20 images and variants_per_product
variants.
pub fn list(
client: storefront.StorefrontClient,
page: ProductPage,
metafields: List(storefront.MetafieldIdentifier),
) -> effect.Effect(
Result(graphql.Connection(Product), error.ShopifyError),
key,
)
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