How can I hide the 'Order Now' button of catalog item via client script?

Tomi Corigliano
Kilo Sage

I already tried several things on my Catalog UI Policy:

find_real_file.png

However they all give the error message:

There is a JavaScript error in your browser console

1 ACCEPTED SOLUTION

Michael Jones -
Giga Sage

Is this in the portal, or in the backend-UI?

For the UI Policy you need to set the field "Isolate Script" to false - you can either add it to the form, or add it to the list view and change it that way. 

For the portal you need to make sure the "Run Scripts in UI Type" is set to all.

Then you can use something like this to hide the button - (replace with .show() to reveal

function onCondition() {

    if (jQuery) {
        jQuery("#oi_order_now_button").hide();
    } else {
        this.jQuery("#submit-btn").hide();
    }



}

I hope this helps!

If this was helpful, or correct, please be kind and mark the answer appropriately.

Michael Jones - Proud member of the GlideFast Consulting Team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

View solution in original post

9 REPLIES 9

Jaspal Singh
Mega Patron
Mega Patron

Hi Tomi,

Do you want to hide it for one catalog item completely or is it on specific condition.

If completely then why not use the No Order Now & set it to True on the Catalog item itself. Refer link

Community Alums
Not applicable

Hi @Tomi Corigliano ,

Why you want to write a Client Script ? you can do it without writing a script :

To hide Order Now button Navigate to ->maintain cart layout in that find Order this Item widget like below,and unchecked order now in Button section.Try it works.

find_real_file.png

Or ,

To hide Order Now button Navigate to ->maintain cart layout in that find Order this Item widget like below,and unchecked order now in Button section.Try it works.

find_real_file.png

 

Mark my answer correct & Helpful, if Applicable.

Thanks,

Sandeep

Ethan Davies
Mega Sage
Mega Sage

Hi Tomi,

Since you are using code to manipulate the DOM you will need to do this in a Catalog Client Script instead. Write your code in the client script and make sure the 'Isolate Script' field on the Client Script record itself is set to FALSE (this will allow your code to run).

It is generally best practice to not use any code such as jQuery to manipulate the DOM and hide elements. OOTB there is a method to hide the 'Order Now' button here.

Please mark are helpful or correct if it solved your issue.

There's no option 'Isolate Script'

find_real_file.png