我正在使用MONEI/ShopifAPI节点在Shopify中创建应用程序。我已经完成了创建Customer Shopify api节点/测试/客户的测试用例。测验jsI只需要格式参数来创建客户。当用户使用电子邮件和联系号码注册时,我希望在我的商店管理员处使用电子邮件和联系号码创建客户。我只想格式化param,就像webhook的params一样。创造
如果有人创建过customer,请在此处删除所需参数。另外,请检查我的代码是否是创建客户的正确方法。谢谢。
const createCustomer = function(shopDomain, accessToken, customer) {
const shopName=shopDomain.replace('.myshopify.com','');
const shopify = new ShopifyAPIClient({ shopName: shopName, accessToken: accessToken });
shopify.customer.create(customer).then(
response => console.log(`customer ${customer.url} created`),
err => console.log(`Error creating customer ${customer.url} ${JSON.stringify(err.response.body)}`)
);
}
函数调用
afterAuth(request, response) {
const { session: { accessToken, shop } } = request;
createCustomer(shop,accessToken,{
topic: 'admin/customers',
address: `${SHOPIFY_APP_HOST}/admin/customers`,
});
return response.redirect('/');
}
我从这里得到了答案。什么是输入。顾客对顾客。创建和维护客户。使现代化