Can we fetch the data of shopping cart items and their variables before checkout

Mohammed Lais1
Mega Guru

in shopping cart   page, before checking out can we get the details of items present in the cart and their variables in script.

1 ACCEPTED SOLUTION

Rakesh Mamidi
ServiceNow Employee
ServiceNow Employee

If you need to do Glide record, here is the sample code.




var sc = new GlideRecord('sc_cart');


sc.addQuery('user',gs.getUserID());


sc.query();


if(sc.next()){


var item = new GlideRecord('sc_cart_item');


item.addQuery('cart',sc.sys_id);


item.query();


while(item.next()){


    var options = new GlideRecord('sc_item_option');


    options.addQuery('cart_item',item.sys_id);


    options.query();


    while(options.next()){


        gs.print("Question:" options.item_option_new.getDisplayValue());  


          gs.print("Question:" options.value.getDisplayValue());        


        }


  }


}


View solution in original post

8 REPLIES 8

Rakesh Mamidi
ServiceNow Employee
ServiceNow Employee

The details will be available in sc_cart table.


Mohammed Lais1
Mega Guru

how to fetch those details from sc_cart


Rakesh Mamidi
ServiceNow Employee
ServiceNow Employee

You need to client script on sc_cart table, which does a GlideAjax fetch details.


The client script runs in shopping cart page.



You can refer OOB "set location" client script on sc_cart table.


fortunately i know the procedure what you have mentioned.


my only concern is how to fetch the variable details of item present in shopping cart