我在我的react-native应用程序中使用Shopify Buy 插件进行访客结账
但我面临这个问题(见下图)
我还参考了https://github.com/Shopify/js-buy-sdk/issues/518的解决方案,但我的代码中没有此类问题。
请任何帮助表示赞赏。
我的代码
import Client from 'shopify-buy';
const client = Client.buildClient({
storefrontAccessToken: my_token,
domain: my_domain
});
export default class App extends Component {
componentWillMount() {
client.checkout.create().then((res) => {
this.setState({
checkout: res,
});
});
}
_handleAddToBagBtn = (variantID) => {
const checkoutId = this.state.checkout.id;
const lineItemsToAdd = [{'variantID': variantID, quantity: 1}];
client.checkout.addLineItems(checkoutId, lineItemsToAdd).then((checkout) => {
console.warn(checkout.lineItems);
});
}
}
render() {
return (
<TouchableOpacity onPress={() => this._handleAddToBagBtn(variantID)} >Click Here</TouchableOpacity>
);
}