How to add variables to SC Shopping Cart template in Service Portal?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 10:40 AM
Hi community,
I'm working on the Service Portal and my requirement is to view some variable fields in in the SC Shopping Cart widget. I took the clone copy of the SC Shopping Cart widget and have added the angular ng-templates to the cloned widget.
I am not sure what are the others changes should be done in the cloned widget to display few variables from the catalog item to the Shopping cart widget.
Kindly let me know what changes are required in the script to achieve this requirement.
(Note : The variable types are dropdown and single line text.).
Do reply if any clarification needed from my side.
Any input on this would be of great help.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2023 06:59 PM
Hello @diNesh_M,
Please refer to the link below:
https://www.servicenow.com/community/developer-forum/adding-variables-to-sc-shopping-cart-template-i...
Mark my correct and helpful, if it is helpful and please hit the thumbs-up button to mark it as the correct solution.
Thanks & Regards,
Abbas Shaik

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2023 01:43 AM
Hi Abbas,
I have written the below script in SPCart script include to get the value of the requested for variable .
But not sure where to make the changes in the "large_shopping_cart_v2.html" Angular ng-template .
Hope only if the changes were made in Angular ng-template ,the Shopping cart widget will display the requested for variable.
Kindly let me know what changes needs to done in the large_shopping_cart_v2.html" Angular ng-template.
SPCart script includes:
var scItemOptionGR = new GlideRecord("sc_item_option");
scItemOptionGR.addQuery("cart_item",cartItemID);
scItemOptionGR.query();
var variables = {};
while(scItemOptionGR.next())
{
var v = scItemOptionGR.getDisplayValue('value');
variables[scItemOptionGR.item_option_new.name] = (v == null || v =='' ? '' : v);
}
var cartItem = GlideappCartItem.get(cartItemID);
return {
variables:variables.requested_for,
}