Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh "/public/page-data" #56

Open
mikejw opened this issue Dec 4, 2021 · 1 comment
Open

Refresh "/public/page-data" #56

mikejw opened this issue Dec 4, 2021 · 1 comment

Comments

@mikejw
Copy link

mikejw commented Dec 4, 2021

Hi there,

I apologise if this a fairly newb question. However I'm wondering how my site built on the platform will maintain correct stock info when it fluctuates (by variant). I have tried pulling in variants and "availableForSale" data into the ProductCard graphql fragment as below:

export const query = graphql`
  fragment ProductCard on ShopifyProduct {
    id
    title
    slug: gatsbyPath(
      filePath: "/products/{ShopifyProduct.productType}/{ShopifyProduct.handle}"
    )
    images {
      id
      altText
      gatsbyImageData(aspectRatio: 1, width: 640)
    }
    priceRangeV2 {
      minVariantPrice {
        amount
        currencyCode
      }
    }
    vendor,
    variants {
      availableForSale 
    }
  }
`

However this info doesn't seem to be updated when I then update the variants info on the Shopify site. Do I need to deploy a cron job to continually refresh data within /public/page-data to make sure variants info is constantly up to date? i.e. this product is or isn't sold out.

@mikejw
Copy link
Author

mikejw commented Dec 6, 2021

I managed to get the stock status by using the client object with the product listing component and looping through each product. Happy to share the code if anyone is interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant