pify/variant

Product variants: find by SKU, create, write price, compare-at price, barcode, SKU, option value and the inventory policy.

Types

Whether customers can buy the variant when it is out of stock (ProductVariantInventoryPolicy).

pub type InventoryPolicy {
  InventoryPolicyDeny
  InventoryPolicyContinue
}

Constructors

  • InventoryPolicyDeny

    DENY: no sale at zero available.

  • InventoryPolicyContinue

    CONTINUE: sales go on below zero.

Whether Shopify counts stock for the variant’s inventory item (InventoryItemInput.tracked).

pub type InventoryTracking {
  InventoryTracked
  InventoryUntracked
}

Constructors

  • InventoryTracked
  • InventoryUntracked

One value of one product option, as VariantOptionValueInput and selectedOptions carry it: option_name is the option, such as “Formato”, and name is the value, such as “Capa dura”.

pub type OptionValue {
  OptionValue(option_name: String, name: String)
}

Constructors

  • OptionValue(option_name: String, name: String)

The variant as Shopify stored it after bulk_update.

pub type UpdatedVariant {
  UpdatedVariant(
    id: String,
    price: decimal.Decimal,
    compare_at_price: option.Option(decimal.Decimal),
    barcode: option.Option(String),
  )
}

Constructors

pub type Variant {
  Variant(
    id: String,
    sku: option.Option(String),
    barcode: option.Option(String),
    price: decimal.Decimal,
    compare_at_price: option.Option(decimal.Decimal),
    product_id: String,
    inventory_item_id: String,
    tracked: Bool,
    inventory_policy: option.Option(InventoryPolicy),
  )
}

Constructors

A variant to create, under the product’s one option. productSet and bulk_create take the same input.

pub type VariantCreate {
  VariantCreate(
    option_value: String,
    sku: String,
    barcode: option.Option(String),
    price: decimal.Decimal,
    compare_at_price: option.Option(decimal.Decimal),
    inventory_policy: InventoryPolicy,
    tracking: InventoryTracking,
  )
}

Constructors

A variant as a product read or write answers it.

pub type VariantSummary {
  VariantSummary(
    id: String,
    sku: option.Option(String),
    inventory_item_id: String,
    tracking: InventoryTracking,
    selected_options: List(OptionValue),
  )
}

Constructors

pub type VariantUpdate {
  VariantUpdate(
    id: String,
    price: decimal.Decimal,
    compare_at_price: option.Option(decimal.Decimal),
    barcode: option.Option(String),
    sku: option.Option(String),
    option: option.Option(OptionValue),
  )
}

Constructors

Values

pub fn bulk_create(
  client: pify.Client,
  product_id: String,
  option_name: String,
  variants: List(VariantCreate),
) -> effect.Effect(
  Result(List(VariantSummary), error.ShopifyError),
  key,
)

Create variants on one product, variants_per_update per call, under the product’s option option_name. The strategy is DEFAULT: Shopify deletes the standalone “Default Title” variant when it is the only one and keeps a standalone variant with a custom value. A call is all or nothing.

pub const bulk_create_mutation: String
pub fn bulk_create_variables(
  product_id: String,
  option_name: String,
  variants: List(VariantCreate),
) -> json.Json
pub fn bulk_update(
  client: pify.Client,
  product_id: String,
  updates: List(VariantUpdate),
) -> effect.Effect(
  Result(List(UpdatedVariant), error.ShopifyError),
  key,
)

Write price, compare-at price and barcode for variants of one product, variants_per_update per call. A call is all or nothing: any userErrors fail it and nothing in it is written.

pub const bulk_update_mutation: String
pub fn bulk_update_variables(
  product_id: String,
  updates: List(VariantUpdate),
) -> json.Json
pub fn create_input(
  option_name: String,
  variant: VariantCreate,
) -> json.Json

One new variant as ProductVariantsBulkInput and ProductVariantSetInput both read it. The SKU rides inventoryItem, which both inputs take.

pub fn find_by_skus(
  client: pify.Client,
  skus: List(String),
) -> effect.Effect(Result(List(Variant), error.ShopifyError), key)

Search by SKU, skus_per_search at a time. Shopify’s search tokenizes and can match near SKUs, so only variants whose SKU equals a SKU of the same search come back. The search ignores case, so the match ignores case and surrounding spaces too. A blank SKU is never searched.

pub fn inventory_policy_decoder() -> decode.Decoder(
  InventoryPolicy,
)
pub fn inventory_policy_to_string(
  policy: InventoryPolicy,
) -> String
pub const search_query: String
pub fn search_variables(
  skus: List(String),
  after: option.Option(String),
) -> json.Json
pub fn set_inventory_policies(
  client: pify.Client,
  product_id: String,
  policies: List(#(String, InventoryPolicy)),
) -> effect.Effect(Result(List(String), error.ShopifyError), key)

Write the inventory policy of variants of one product, variants_per_update per call. A call is all or nothing.

pub const set_inventory_policies_mutation: String
pub fn set_inventory_policies_variables(
  product_id: String,
  policies: List(#(String, InventoryPolicy)),
) -> json.Json
pub const skus_per_search: Int

SKUs per search. Fifty sku: terms keep the search string short.

pub const summary_fields: String

The fields summary_decoder reads.

pub const variants_per_update: Int

Variants per productVariantsBulkUpdate call, Shopify’s array limit.

✨ Search Document