The CreatorCon Call for Content is officially open! Get started here.

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

diNesh_M
Tera Contributor

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

2 REPLIES 2

Abbas_5
Tera Sage
Tera Sage

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

diNesh_M
Tera Contributor

@Abbas 

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,
}