Configuration of the Shopping Cart on Portal

Joshua Cassity
Kilo Guru

I am interested in a couple of things dealing with the cart:

1. How would we remove the Requested For, Deliver to and Special Instructions from the cart view? Many of our options are service based and we don't really deliver an AD account to an address.. lol. I'd imagine this is something where we'd clone the widget and do some modifications but I'm no widget guru.

find_real_file.png

2. How would I push a quantity value stored in a catalog item's variable (u_quantity) into the shopping cart when it's added and then prevent the user from changing it in the cart view?

Ex. Someone orders a door stop with a quantity of 35, I want the quantity to be 35 in the cart on the portal but not let them alter it without altering the quantity on the original request.

How would a fella go about doing that?

Thanks.

1 ACCEPTED SOLUTION

Joshua Cassity
Kilo Guru

Through much trial and error I have had a breakthrough in updating the quantity on the portal shopping cart using a business rule. Sharing that wealth in case anyone else needs this.



1. I created a variable set that will be used with only the Quantity field on it. This is imperative as we will use this variable's system id as a condition on the business rule to prevent it from running other than for quantity updates.



2. I created a Before Insert/Update BR on the sc_item_option table with a condition that the Question be the variable that was setup in Step 1. I initially tried to do this on the cart item; however, it appears the item option isn't created before the cart item so I would never get any results when I attempted to query the related table.



find_real_file.png



3. I wrote a pretty simple glide query to get the values of the Cart Item and Value from the current Item Option form, search the Cart Items table until it found a match on the related cart and then updated it's quantity with the value of the variable.




// Get the Current Cart Item and Value from the catalog item option.


var cartItem = current.cart_item;


var qty = current.value;


     


// Query the cart and update it's quantity value with the variable's value.


var gr = new GlideRecord('sc_cart_item');


gr.addQuery('sys_id', cartItem);


gr.query();



while(gr.next()){


      gr.quantity = qty;


      gr.update();


}


s);




And that was it.



Catalog Item - Add to Cart


find_real_file.png




Shopping Cart Display


find_real_file.png



I hope this helps anyone else who is struggling with dealing with this. It was a two day nightmare for me but we finally have somewhat of a solution.


View solution in original post

7 REPLIES 7

Jaspal Singh
Mega Patron
Mega Patron

Hi Joshua,



Look for Service Catalog >>   Maintain cart Layout


find_real_file.png



Look for Cart Preview Screen (Two Step) & then


find_real_file.png


brianrichards
Tera Guru

I don't have the headspace to drill into much with regards to your part two, but the work to be done here is in the ng-angular-template that is associated with the SC Shopping Cart widget. There are two templates in the related list for that widget, and you can remove elements from the cart by simply modifying the html in the default template 'large_shopping_cart.html'.



The u_quantity variable is accessible as {{item.quantity}, and it would just take a little angular voodoo to make your field read-only as desired.



- Brian


So you're saying all that's controlled here:



find_real_file.png


I was able to remove these fields by taking the large shopping cart template, removing the Angular that displays those three fields and doing an 'Insert and Stay' labeling the new template custom_shopping_cart.



Resulting in the following:



find_real_file.png


My concern is that even though the field is hidden, we have a variable on each item that determines who the requested for person will be (ex. On Behalf of), so I guess we'd have to clone the OOTB widget anyway so that those people don't become overwritten by the Requested For person in the cart.