Good morning everyone! I’ve got another rookie que...
# suitecommerce
j
Good morning everyone! I’ve got another rookie question… I’m exploring the Commerce API with an extension for SCA 2019.1 and it seems like I’m not getting the live data from the sales order. Is that normal? Here’s a quick overview… I am setting a Custom Transaction Body Field using Scriptable Cart. The deployment log shows that it is processing the logic and working with the updated data. In the Extension Service Controller, I’m using nlapiGetWebContainer().getShoppingSession().getOrder().getCustomFieldValues() to return the Custom Transaction Body Fields, and then I’m logging that to the console. The extension data is accurate at login, but during the session the Custom Transaction Body Field changes because of logic happening in Scriptable Cart. The Scriptable Cart log shows the change, but the data I’m getting back from getCustomFieldValues() is unchanged from the values at login. Is it possible to get the live transaction body data? Or do I need to move all the logic into the extension and then push that into the sales order with setCustomFieldValues()?
s
The frontend application will save a copy of the live order as a model. If you update the cart in the backend of the site then it will go out of date with the frontend of the model until you tell them to sync.
j
That makes sense and is consistent with what I’m seeing… so how can I tell them to sync?
p
as far as i remember custom columns and custom body fields populated by scriptable cart can’t be seen by the commerce api
s
I can't confirm/deny what Pablo said but I trust him, he'll have more experience that I will on this. What I can say is that involving scriptable cart in this sort of operation is... icky. We don't really recommend mixing scriptable cart and the SCA application – a lot of stuff that folks want to do with Scriptable Cart can now be done in SCA.
And normally you would do a
fetch()
on the LiveOrder model singleton
j
Ok great, thanks guys
I’ll try out the LiveOrder approach with the understanding that moving the logic to the extension might be inevitable and better. We do have to keep using Scriptable Cart for a piece of it because item prices change depending on certain things in the user session.
s
OK, well I would try and put as much into the extension as possible, and I would use things like the checkout and cart components, and also the methods available to you on the live order model
and if you're going to use the commerce api, I would use SC.Models.Init
p
One way communication (commerce api to scriptable cart) does work. Just don't try the other way round (scriptable cart to commerce api).