简体   繁体   English

SCA SuiteScript查询项进行编码

[英]SCA SuiteScript query item to code

I need to add an non-inventory item by internal id to the cart in SCA, how would I go about pulling that item and then adding it? 我需要通过内部ID将非库存商品添加到SCA中的购物车,我将如何拉出该商品然后添加它? The code samples I find are for pulling data always refer to views, I am thinking I need to pull it as an item, as I need to add it as an item using methods in LiveOrder.Model 我找到的用于提取数据的代码示例始终引用视图,我想我需要将其作为项目来提取,因为我需要使用LiveOrder.Model中的方法将其作为项目添加。

thanks for anyhelp you may give 谢谢你的帮助

Really depends on which version of SCA you are using. 确实取决于您使用的SCA版本。 The quick answer is to look in the ItemDetails.View.js file in the Modules directory and find the code for the addToCart method. 快速的答案是在Modules目录中的ItemDetails.View.js文件中查找并找到addToCart方法的代码。

The longer answer is that SCA's architecture and performance leave much to be desired. 更长的答案是,SCA的体系结构和性能还有很多不足之处。 If you have things like multiple add to or update cart I found that it was easier to write my own cart.ss service and then just forward to the cart or refresh the page on completion. 如果您有多个添加或更新购物车之类的东西,我发现编写自己的cart.ss服务更容易,然后转发到购物车或在完成时刷新页面。

So I found out that the easiest way to do this is like this, the items are returns in a object array, so thanks for your help 因此,我发现最简单的方法是这样,将项目返回到对象数组中,因此感谢您的帮助

$.get('/api/items?id=10779&fieldset=details', function(obj) {
}).done(function(obj) {
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM