if cart is empty, disable cart icon in serviceportal

Devi D
Tera Expert

Hi Everyone ,

 

if we add any items then cart icon should be displayed , if not cart should be hidden in service portal.

 

can anyone please help me on this requirement .

 

 

Thank you .

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@Devi D 

what's your business requirement for this?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur, 

As per client requirement , ideally cart icon should not be visible on the header menu on service portal. if items added , then only it should be visible.

DeviD_0-1737531667990.png

 

@Devi D 

you will have to clone the OOB widget and then handle the visibility.

But I won't recommend doing this.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Juhi Poddar
Kilo Patron

Hello @Devi D 

  • You can directly enable or disable the cart from the menu item.

JuhiPoddar_1-1737531251886.png

  • However, if you want to add a condition, it is set in the Header Menu widget, which is read-only.
  • If you are already using a cloned version of this widget, you can add an additional condition (&& cartItemCount > 0).

The updated condition will be:

 

::options.enable_cart && data.isLoggedIn && !accessibilityEnabled && cartItemCount > 0

 

JuhiPoddar_0-1737531093532.png

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar