
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2017 12:38 PM
Hi All,
In Dev Helsinski....
Trying to get the value of shopping cart Quantity on a catalog client script. Using price from UI macro "sc_order_item_subtotal", id = price_label_span but not able to get the quantity
Thanks
Tez
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2017 02:31 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2019 07:48 AM
hi, did you get a solution for this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2019 06:57 PM
Hi, I need to get price and quantity in catalog client script.
can you tell me how you achieved it using UI macro "sc_order_item_subtotal", id = price_label_span ????????
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2019 09:32 PM
Thank you Abhinay.
I tried $('quantity').value but my Chrome failed with "TypeError : $ is not a function".
I even added a system property glide.script.block.client.globals=false. It did not help either.
Finally, I used a GlideAjax and got what I wanted.
CART item values are stored in sc_cart_item on server. You can write a GlideAjax and get the number of items added in cart.
-------
Client Script:
var user = g_user.userID;
var ga = new GlideAjax('GetCartQuantity');
ga.addParam('sysparm_name','getCartQuantity');
ga.addParam('sysparm_userid',user);
ga.getXML(getcartquantity);
function getcartquantity(response){
var cart_quantity = response.responseXML.documentElement.getAttribute("answer");
alert(cart_quantity);
}
----------
Server side ( you need to add a script include named GetCartQuantity ). Make sure it is client callable.
var GetCartQuantity = Class.create();
GetCartQuantity.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCartQuantity:function() {
var dbg=true;
var userid = this.getParameter('sysparm_userid');
var sc = new GlideRecord('sc_cart');
sc.addQuery('name','DEFAULT');
sc.addQuery('user',userid);
sc.query();
while(sc.next()){
var cc= new GlideRecord('sc_cart_item');
cc.addQuery('item_name','SYS****ID***OF ** CATALOG ITEM');
cc.addQuery('cart',sc.sys_id);
cc.query();
if(cc.next()){
return cc.quantity;
}
}
}
});
-------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2019 07:48 AM