Search code examples
productbigcommerce

Accessing 'purchaseable' on product variant in Big Commerce


Does anyone know how to access (programmatically) whether a product variant is 'purchasable' in Big Commerce (see attached image)? I've tested the product object (docs) - nothing there. Also can't see anything that returns this value via GQL (docs). So can 'purchasable' be accessed? Or does it only exist to display a pop-up to the user when they select an item that isn't 'purchasable'?

enter image description here


Solution

  • Should have waited out a bit longer because it can be done with GQL - which may be helpful to others:

    query productById(
      $productId: Int!
      # Use GraphQL Query Variables to inject your product ID
    ) {
      site {
        product(entityId: $productId) {
          id
          entityId
          name
          variants {
            edges {
              node {
                sku
                isPurchasable
              }
            }
          }
        }
      }
    }
    

    Just note that the product needs to be 'visible on storefront'