- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2020 06:22 AM
Hi,
I need help to hide/disable "Add to cart" for a specific catalog item. We have a Yes/No variable and if variable is answered as No only then hide "Add to Cart" button.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2020 07:48 AM
Hi,
just use it in onchange
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(g_form.getValue(have_you) == 'No')
{
if(window == null){
// for portal
var z = this.document.getElementsByClassName("btn btn-default sc-btn form-control ng-scope");
z[0].style.display = 'none';
}
else{
// for native
gel('oi_add_to_cart_button').style.display = 'none';
}
}
else{
if(window == null){
// for portal
var z = this.document.getElementsByClassName("btn btn-default sc-btn form-control ng-scope");
z[0].style.display = '';
}
else{
// for native
gel('oi_add_to_cart_button').style.display = '';
}
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2020 07:11 AM
Thanks for the quicks response.
When I tried your script it wasn't working and throws below error
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(g_form.getValue(have_you) == 'No')
{
document.getElementById("widget-sc-cat").style.display = 'none'; // hide
}
//you can get the id of your button by inspecting it.
else{
document.getElementById("widget-sc-cat").style.display = ''; // show
}
}
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2020 07:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2020 07:25 AM
Yes, I confirmed that.