gpt4 book ai didi

c# - 创建购物车时带有 .net c# 异常的 magento API

转载 作者:太空宇宙 更新时间:2023-11-03 16:08:39 24 4
gpt4 key购买 nike

因此,我一直在尝试将我现有的 ASP .net 网络应用程序与 Magento 网络商店集成。我可以将新产品添加到目录中,但遇到了无数问题。我想要做的就是创建一个新的购物车,并将现有客户列表中的客户添加到其中,并在从购物车创建订单之前将一些产品添加到购物车中。

下面的代码导致异常:“客户的标识符无效或客户不存在。”请告诉我我做错了什么以及我该如何处理。我只需要为我在目录中的产品创建一个新订单。

cartID = mage.shoppingCartCreate(mageSessionID, "");
MageService.customerCustomerEntity[] custs = mage.customerCustomerList(mageSessionID, filter1);
MageService.shoppingCartCustomerEntity custom = new shoppingCartCustomerEntity();
custom.customer_id = custs[0].customer_id;
custom.firstname = custs[0].firstname;
custom.lastname = custs[0].lastname;
custom.email = custs[0].email;
custom.website_id = custs[0].website_id;
custom.store_id = custs[0].store_id;
custom.mode = "customer";
Boolean cartFlag = mage.shoppingCartCustomerSet(mageSessionID,cartID, custom, "");

最佳答案

你有一个从未回答过的老问题,我遇到了同样的问题。没有任何文档可以提及解决方案/修复。我已经找到它并且觉得仍然值得为遇到的其他人回答这个老问题。

如果要设置客户 ID,还需要将 customer_idSpecified 设置为 TRUE。

然后就可以了。

在您上面的代码中,它将是:

custom.customer_idSpecified = custs[0].customer_idSpecified;

希望你现在已经明白了。

谢恩

关于c# - 创建购物车时带有 .net c# 异常的 magento API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18328152/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com