In suite commerce advanced (SCA) I'm creating an e...
# ask-stanley-ai
m
In suite commerce advanced (SCA) I'm creating an extension which work in the Product List Page (PLP). I need here to know the numbers of lines in the shopping cart. How can I know how many line are in the shopping cart from the PLP, I call the LiveOrderModel.getInstance(), but it seems not loaded when I want to know the lines. How can I wait till the LiveOrderModel is loaded entirelly ?
c
AI generated answer (using internal Slack threads):
In SuiteCommerce Advanced (SCA), you can use the
LiveOrder.Model
to get the number of lines in the shopping cart. However, you need to ensure that the
LiveOrder.Model
is fully loaded before you try to access the line items. You can use the
done()
function to ensure that the
LiveOrder.Model
is fully loaded before you try to access the line items. Here is a sample code snippet:
Copy code
javascript
var liveOrderModel = LiveOrderModel.getInstance();

liveOrderModel.done(function() {
    var numberOfLines = liveOrderModel.get('lines').length;
    console.log('Number of lines in the shopping cart: ' + numberOfLines);
});
In this code,
LiveOrderModel.getInstance()
returns a jQuery Deferred object. The
done()
function is called when the Deferred object is resolved, which means that the
LiveOrder.Model
is fully loaded. Inside the
done()
function, you can safely access the line items in the shopping cart. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823003
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.816002369
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.810469449
Please provide your feedback on this answer.