bigcommerce / storefront-data-hooks

Hooks for React Storefront UI Components
MIT License
166 stars 36 forks source link

Variant type include purchasable flag #104

Closed maxmezzomo closed 3 years ago

maxmezzomo commented 3 years ago

Variant type is currently defined as

/** Variant */
export type Variant = Node & {
  __typename?: 'Variant'
  /** The ID of an object */
  id: Scalars['ID']
  /** Id of the variant. */
  entityId: Scalars['Int']
  /** Sku of the variant. */
  sku: Scalars['String']
  /** The variant's weight. If a weight was not explicitly specified on the variant, this will be the product's weight. */
  weight?: Maybe<Measurement>
  /** The variant's height. If a height was not explicitly specified on the variant, this will be the product's height. */
  height?: Maybe<Measurement>
  /** The variant's width. If a width was not explicitly specified on the variant, this will be the product's width. */
  width?: Maybe<Measurement>
  /** The variant's depth. If a depth was not explicitly specified on the variant, this will be the product's depth. */
  depth?: Maybe<Measurement>
  /** The options which define a variant. */
  options: OptionConnection
  /** Product options that compose this variant. */
  productOptions: ProductOptionConnection
  /** Default image for a variant. */
  defaultImage?: Maybe<Image>
  /** Variant prices */
  prices?: Maybe<Prices>
  /** Variant inventory */
  inventory?: Maybe<VariantInventory>
  /** Metafield data related to a variant. */
  metafields: MetafieldConnection
}

The product section on dashboard allows setting variants to purchasable or not. would be a nice small addition to include that in the Storefront API response and in these hooks. In the meantime setting the inventory to 0 works but its not the same.

It's not clear to me what the relationship between the storefront API and the management API is. Looking at https://developer.bigcommerce.com/api-reference/store-management/catalog/product-variants/getvariantbyid it seems that the storefront hooks and the typings it provides do not necessarily try and follow the management API which I think is fine and good as its got a different purpose. The only issue is that the purchasable toggle feature on the UI dashboard that store admins would use is then redundant if only fetching data use the storefront hooks, if that's correct.

Thanks for the time, Best

jorgemasta commented 3 years ago

I have not found any way to fetch the purchasable flag from the GraphQL API.

In this project, we use the GraphQL API when possible, if not we use the Management API.

maxmezzomo commented 3 years ago

Alright nice, I guess they only have it through the management, hopefully they add it to the GraphQL one.