is there a way to automatically clear the cart when an order guide is first opened?

patricklatella
Mega Sage

I'm looking for a way to have an automatic cache out and empty of the cart when an order guide is opened to eliminate the possibility of old or "unchecked out" items being in the cart when the "checkout" page within the Order Guide is reached.

is this possible?     thanks!

1 ACCEPTED SOLUTION

Patrick, here you go. please mark as correct. also, check impersonating a user with no role.



onLoad client script:



function onLoad() {


    //Type appropriate comment here, and begin script below


  var ga = new GlideAjax('CartUtil');


  ga.addParam('sysparm_name', 'clearCart');


  ga.getXMLWait();


}



script include:




var CartUtil = Class.create();


CartUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {


clearCart: function() {


var clear = new GlideRecord('sc_cart_item');


clear.addQuery('cart.user', gs.getUserID());


clear.addQuery('active', 'true');


clear.query();


clear.deleteMultiple();


  return;


  }


});


View solution in original post

20 REPLIES 20

patricklatella
Mega Sage

great thanks Dan!