Next.js Discord

Discord Forum

Next.js Commerce by Vercel

Unanswered
Somali posted this in #help-forum
Open in Discord
SomaliOP
I have exactly the same problem as here (https://discord.com/channels/752553802359505017/752647196419031042/1187544244748038225) when initiating the repo and integrating with Shopify. It works only if I force search (I can see the products that way) but my homepage is empty. I can't even see the navbar. Can anyone help me please?

5 Replies

SomaliOP
Toyger
from code it looks like it get items from collection with name hidden-homepage-featured-items so you need to create such collection at shopify and add products to it.
I'm stuck retrieving the metafields of the products:

I'm getting the metafield properties (category, technologies, flowRate and name) as an object with a property called value inside of it. What I wanted was to retrieve the value of the property value directly (e.g. { category: 'Basin', flowRate: 6, name: 'Curve Tap' }).
{
  (...)
  category: { value: 'Basin' },
  technologies: {
    value: '["Mixture","Sustainable","Recyclable"]'
  },
  flowRate: { value: '6' },
  name: { value: 'Curve Tap' }
}

And here's how I'm retrieving on the product fragment:
const productFragment = /* GraphQL */ `
  fragment product on Product {
    (...)
    category: metafield(namespace: "product", key: "category") {
      ...metafield
    }
    technologies: metafield(namespace: "product", key: "technologies") {
      ...metafield
    }
    flowRate: metafield(namespace: "product", key: "flow_rate") {
      ...metafield
    }
    name: metafield(namespace: "product", key: "name") {
      ...metafield
    }
  }
  ${metafieldFragment}
`;

const metafieldFragment = /* GraphQL */ `
  fragment metafield on Metafield {
    value
  }
`;

Can someone help me please?
there is a space in the code. The issue has been solved on github but the original rep hasn't been updated yet. It takes few seconds to solve the issue anyways.

Here's the solution: https://github.com/vercel/commerce/issues/1207#issue-1910390339