Get Shopping Cart Quantity in Catalog client script ?

shilpa344
Giga Expert

Hi All,

I am trying to get the value of shopping cart Quantity on a catalog client script. Once submitting the request, if quantity selected in more than 1, there should be a pop-up message.

I tried couple of scripts but not getting quantity selected by the user.

var userID = g_user.userID;

var cart = new GlideRecord('sc_cart');

cart.addQuery('user',userID);

cart.query();

if (cart.next()) {

var cartItem = new GlideRecord('sc_cart_item');

cartItem.addQuery('cart',cart.sys_id); cartItem.query();

if (cartItem.next()) {

alert('Order quantity is limited to 1 ');

}

}

Thanks

1 ACCEPTED SOLUTION

Hi All,



I am able to fix the issue with the help of below thread


How to get Shopping Cart Quantity in Catalog client script ?



var count = $('quantity').value;


if(count > 1){


var conMsg = confirm('');


if(conMsg == true){


//Your code;


}


else{


return false;


}


}


View solution in original post

3 REPLIES 3

Kalaiarasan Pus
Giga Sage

Can you move this script to a script include and access it with GlideAjax?


Hi All,



I am able to fix the issue with the help of below thread


How to get Shopping Cart Quantity in Catalog client script ?



var count = $('quantity').value;


if(count > 1){


var conMsg = confirm('');


if(conMsg == true){


//Your code;


}


else{


return false;


}


}


is this a catalog client script or a script include?  also can you tell if we can the cart price also in a similar way ?  or is there some other way to  get the catalog price onload of the form?