通过 Shopify Storefront GraphQL 获取和更新结账

发布于 2025-01-19 03:46:52 字数 751 浏览 0 评论 0原文

我想知道有什么方法可以使用Shopify StoreFront GraphQl获取和更新结帐?

请注意:结帐是由用户使用店面上的普通Web流创建的。这意味着结帐不是由GraphQl创建的。

让我们考虑以下情况:

  • 用户访问网站并进行结帐,
  • 用户放弃了结帐。

从Shopify Admin我可以获取废弃的结帐URL:https://mysite.com/111111/checkouts/foo/recover?keykekey=bar 基于此URL,我通过使用shopify js-buy-sdk做出GraphQl请求:

const client = ShopifyBuy.buildClient({
     domain: 'mysite.myshopify.com',
     storefrontAccessToken: 'xxxxxx'
});

// I tried both base64 and raw string version
const checkoutId=`gid://shopify/Checkout/foo?key=bar`

client.checkout.fetch(checkoutId).then((checkout) => {
     console.log('checkout', checkout);
})

服务器响应null

任何帮助将不胜感激。非常感谢!

I would like to know is there any way to fetch and update a checkout using Shopify Storefront GraphQL?

Note that: the checkout is created by the user using normal web flow on the storefront. It means the checkout is not created by GraphQL.

Let's consider this scenario:

  • The user visits the website and makes a checkout
  • The user abandoned the checkout.

From Shopify admin I can get the abandoned checkout URL: https: //mysite.com/1111111/checkouts/foo/recover?key=bar
Based on this URL I make a GraphQL request by using Shopify js-buy-sdk:

const client = ShopifyBuy.buildClient({
     domain: 'mysite.myshopify.com',
     storefrontAccessToken: 'xxxxxx'
});

// I tried both base64 and raw string version
const checkoutId=`gid://shopify/Checkout/foo?key=bar`

client.checkout.fetch(checkoutId).then((checkout) => {
     console.log('checkout', checkout);
})

The server response null.

Any help would be greatly appreciated. Many thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文