pify/product
Products: create one with its option, variants and files in one call, read it back, update its fields and status, and replace its media.
productSet replaces the whole variant list it is given and deletes the
variants left out, so set only creates. An existing product changes
through update, set_status, replace_media and the variant
writes.
Types
The metafield a linked option reads its values from. The schema leaves both fields nullable.
pub type LinkedMetafield {
LinkedMetafield(
namespace: option.Option(String),
key: option.Option(String),
)
}
Constructors
-
LinkedMetafield( namespace: option.Option(String), key: option.Option(String), )
A product as get and set read it: the first 250 variants, Shopify’s
page limit, and the first 50 media. description_html is "" when the
product has no description.
pub type Product {
Product(
id: String,
description_html: String,
options: List(ProductOption),
variants: List(variant.VariantSummary),
media_ids: List(String),
)
}
Constructors
-
Product( id: String, description_html: String, options: List(ProductOption), variants: List(variant.VariantSummary), media_ids: List(String), )
One option and the values its variants use. A linked option takes its values from a metafield, and Shopify refuses a value name written to it.
pub type ProductOption {
ProductOption(
name: String,
values: List(String),
linked_metafield: option.Option(LinkedMetafield),
)
}
Constructors
-
ProductOption( name: String, values: List(String), linked_metafield: option.Option(LinkedMetafield), )
A new product with one option. Each variant holds a value of that option, and the values must differ.
pub type ProductSet {
ProductSet(
title: String,
description_html: String,
handle: option.Option(String),
status: ProductStatus,
option_name: String,
variants: List(variant.VariantCreate),
files: List(String),
)
}
Constructors
-
ProductSet( title: String, description_html: String, handle: option.Option(String), status: ProductStatus, option_name: String, variants: List(variant.VariantCreate), files: List(String), )Arguments
- handle
-
Nonelets Shopify build the handle from the title. - files
-
Image URLs Shopify downloads, in gallery order.
The status a write sets (ProductStatus). A draft is hidden from every
sales channel.
pub type ProductStatus {
ProductStatusActive
ProductStatusDraft
}
Constructors
-
ProductStatusActive -
ProductStatusDraft
Values
pub fn add_media_variables(
product_id: String,
urls: List(String),
) -> json.Json
pub const delete_media_mutation: String
productDeleteMedia needs only write_products. 2026-07 marks it
deprecated for fileUpdate(referencesToRemove:), which needs
write_files as well. Its errors are mediaUserErrors; the alias lets
execute.run_mutation read them as userErrors.
pub fn delete_media_variables(
product_id: String,
media_ids: List(String),
) -> json.Json
pub fn get(
client: pify.Client,
product_id: String,
) -> effect.Effect(
Result(option.Option(Product), error.ShopifyError),
key,
)
Read one product. None when Shopify holds no product with that id,
such as one a merchant deleted.
pub fn product_status_to_string(status: ProductStatus) -> String
pub const products_per_count: Int
The most products one variant_counts call reads.
pub fn replace_media(
client: pify.Client,
product_id: String,
remove remove: List(String),
add add: List(String),
) -> effect.Effect(Result(Nil, error.ShopifyError), key)
Add the images at add, then delete the media remove names. Adding
first keeps the gallery from going empty when the second call fails.
Either list may be empty, and an empty list sends no call.
pub fn set(
client: pify.Client,
product: ProductSet,
) -> effect.Effect(Result(Product, error.ShopifyError), key)
Create the product with its option, variants and files in one
synchronous productSet. A crash after the call leaves a whole product,
never half of one. The product is on no sales channel yet: see
publication.publish.
pub const set_mutation: String
pub fn set_status(
client: pify.Client,
product_id: String,
status: ProductStatus,
) -> effect.Effect(Result(Nil, error.ShopifyError), key)
Write the status alone, such as ProductStatusDraft to hide the product.
pub fn set_variables(product: ProductSet) -> json.Json
pub fn update(
client: pify.Client,
product_id: String,
title title: option.Option(String),
description_html description_html: option.Option(String),
status status: ProductStatus,
) -> effect.Effect(Result(Nil, error.ShopifyError), key)
Write the status, and the title and the description each when it is
Some. None leaves the product’s own. The handle stays, so the
product’s address does not change.
pub const update_mutation: String
productUpdate takes product: ProductUpdateInput; its input
argument is deprecated. Its UserError has no code.
pub fn variant_counts(
client: pify.Client,
product_ids: List(String),
) -> effect.Effect(
Result(List(#(String, Int)), error.ShopifyError),
key,
)
Each product’s count of variants, by id. A product Shopify does not hold is left out.
pub fn variant_counts_decoder() -> decode.Decoder(
List(#(String, Int)),
)
A deleted product reads null, and a node of another type reads {}:
both are left out. A node with an id is a product, so it must carry its
count.
pub const variant_counts_query: String
pub fn variant_counts_variables(
product_ids: List(String),
) -> json.Json