Liquid、JavaScriptなどに関する質問
https://shopify.dev/docs/api/ajax/reference/cart#bundled-section-rendering
↑を参考にした
let formData = { 'items': [...this.items], 'sections':['cart-notification-product', 'cart-notification-button', 'cart-icon-bubble'], 'sections_url': window.location.pathname }; fetch(window.Shopify.routes.root + 'cart/add.js', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(formData) }) .then(response => { console.log( response ); }) .catch((error) => { console.error('Error:', error); });
responceにsectionsが含まれて欲しいのですが返却値にありません。。
■返却されたデータ
■希望するレスポンス内容
{
attributes: {},
cart_level_discount_applications: [],
currency: "CAD",
item_count: 1,
items: [{…}],
items_subtotal_price: 100100,
note: null,
original_total_price: 100100,
requires_shipping: true,
sections: {
cart-items: "<div id=\"shopify-section-template--14199693705272_…9930913703934\" defer=\"defer\"></script>\n\n\n\n\n</div>",
cart-icon-bubble: "<div id=\"shopify-section-cart-icon-bubble\" class=\"…ss=\"visually-hidden\">1 item</span>\n </div></div>",
cart-live-region-text: "<div id=\"shopify-section-cart-live-region-text\" cl…opify-section\">New subtotal: $1,001.00 CAD\n</div>",
cart-footer: "<div id=\"shopify-section-template--14199693705272_… </div>\n </div>\n </div>\n</div>\n\n\n\n\n\n\n</div>"
},
token: "9ee5d43a08fb9a779828e42a4b6aa09a",
total_discount: 0,
total_price: 100100,
total_weight: 1000,
}
何か足りない部分があるのでしょうか?
よろしくお願いいたします。
解決済! ベストソリューションを見る。
成功
確認されているのはfetchで返されるResponseオブジェクトの中身です。
期待されるレスポンス内容は、response.json() をした結果のことだと思われます。
成功
確認されているのはfetchで返されるResponseオブジェクトの中身です。
期待されるレスポンス内容は、response.json() をした結果のことだと思われます。
ご回答ありがとうございます!
response.json()
で確認することを失念しておりました!
修正し、期待したレスポンスを確認することができました!
ユーザー | ランク |
---|---|
36 | |
11 | |
7 | |
6 | |
6 |
すべてのShopifyアカウントはデフォルトではmyshopify.comのURLと関連付けられており、これはアカウント設定時に使用したビジネス名に基づいて作成されます。しかし、オ...
By Nina_13 Nov 26, 2023このトピックは英語版コミュニティの投稿:Shopify Web Pixel Manager Sandbox FAQの日本翻訳です。
By Mirai Nov 19, 2023Shopifyの管理画面では、商品ごとや配送元のロケーション(倉庫)ごとにカスタム配送料を設定することができます。特に購入金額による送料無料設定は、顧客の購買意欲を高める効果的な手...
By Alex06 Nov 5, 2023