0

我使用 shopify buy sdk 创建结帐

我试过了

const lineItemsToAdd = [
                          variantId: 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yOTEwNjAyMjc5Mg==',
                          quantity: 1
                        }
                    ];
const shippingAddress = {
                      address1: self.selectedAddress.address1,
                      address2: self.selectedAddress.address2,
                      city: self.selectedAddress.city,
                      company: null,
                      country: self.selectedAddress.country.country_language.name,
                      firstName: 'Bob',
                      lastName: 'Norman',
                      phone: self.selectedAddress.phone,
                      province:  self.selectedAddress.state.state_language.name,
                      zip: '11001'
                    };

await client.checkout.updateShippingAddress(checkoutData.id, shippingAddress);

 let mainCheckoutId = await client.checkout.addLineItems(checkoutData.id, lineItemsToAdd);

地址有效但无法将产品添加到订单项,它返回 null 如下

mainCheckoutId.lineItems = null

还有错误消息

userErrors retuns message ="Variant is invalid";

我尝试了很多产品,都发布到在线销售渠道

而且我也确定变体ID是正确的

4

1 回答 1

0

我不知道您是否解决了问题,但看起来您在 lineItemsToAdd 中缺少大括号:

const lineItemsToAdd = [{variantId: 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8yOTEwNjAyMjc5Mg==', quantity: 1}];
于 2020-12-16T08:54:08.717 回答