The CreatorCon Call for Content is officially open! Get started here.

how to hide the button add to cart only in backend through client script

Fdeveloper
Kilo Guru

Hi,

i should hide the button add to cart only in the backend in the portal the button should be visible , i try it to check 

Hide 'Add to Cart' to true not working and i try it No cart it works the button is hiding but it also hidding from the portal 

i should hide the button through client script any suggestion please to resolve this issue 

19 REPLIES 19

Hi @sureshloganathan ,

I tried this solution and don't work for me i still see the button also i don't need to hide the button to all catalog item i want to hide it only for some catalog item that contain the caalog name company , so i used script include to get the name of the catalog :

script include

var test = Class.create();
test.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getServiceCatalog: function() {
        var catSysID = this.getParameter('sysparm_cat_sys_id');
        var gr = new GlideRecord('sc_cat_item');
        if (gr.get(catSysID)) {
            var grCat = new GlideRecord('sc_catalog');
            if (grCat.get(gr.sc_catalogs)) {
                return grCat.title;

            }
        }
        return;
    },
    type: 'test'
});

client script

function onLoad() {

        var catSysID = g_form.getUniqueValue(); 
	    alert(catSysID);
		
        var ajax = new GlideAjax('test'); 
        ajax.addParam('sysparm_name', 'getServiceCatalog'); 
        ajax.addParam('sysparm_cat_sys_id', catSysID); 
        ajax.getXMLAnswer(function(answer) {
            //if (answer.length > 0) {
			if (answer == 'company') {
               // alert('service catalog name:' + answer);
		g_form.setValue('no_cart_v2',true);// don't work 
	document.getElementById('add_to_cart_button').style.display = 'none';// don't work
				
     });
            }

Hi, What i provided the steps definitely it should work. Because you are disabling the OOB option. Please find below screenshot and follow the same in your instance.

Not require to achieve using the code.

 

Please mark as correct answer if it helped

find_real_file.png

 

find_real_file.png

Regards,

Suresh.

Regards,
Suresh.

hi @sureshloganathan ,

if i use this solution the button will be hide from all catalog item i nedd to hide the button only for some catalog item

Hi What are catalog item you should hide, you can change it here. Please find below screenshot. please disable the hide 'add to cart' button.

You can see this option for each catalog item. Which catalog you dont want to show Disable the mentioned option.

Please mark as correct answer if it helped.

find_real_file.png

Regards,

Suresh

Regards,
Suresh.

Saurav11
Kilo Patron
Kilo Patron

Hello,

Did you try the below:-

Go to Maintain cart layouts

Then after opened from the list open the Order status screen

Once opened make the add to cart checkbox under button tab false

 

Please mark answer correct/helpful based on Impact.