How to Hide "Order Now" button on the Portal at Runtime

G24
Kilo Sage

Hello.  I read the post here but that solution is not working for me.

When my code runs, I get the "this.jQuery is defined" alert message, but still the button is not hidden.

 

Thoughts on what might be going wrong here?  Thank you.

 

S1.png

 

I want to do this because if our users answer certain questions the wrong way on a Catalog Item, we don't want them to even be able to submit it.

1 ACCEPTED SOLUTION

G24
Kilo Sage

I was able to get this working finally, using a different this.jQuery() query:

function onCondition() {
	if (this.jQuery){
		//alert("1");
		//this.jQuery("btn-primary").hide(); //Did NOT work for me.  I have no elements of type "btn-primary".
		//this.jQuery("#btn-primary").hide(); //Did NOT work for me.  I have no elements with id "btn-primary".
		
		//this.jQuery(".btn-primary").hide(); //Any element with class == .btn-primary.  This did work for me.
		this.jQuery("button[name='submit']").hide(); //Any button element where 'name' = 'submit'.  Works also.
		//alert("2");
	}
}

View solution in original post

9 REPLIES 9

Sid_Takali
Kilo Patron
Kilo Patron

Hi @G24 I'm not sure what you are missing. The code works fine form me

SiddharamTakali_4-1719423885382.png

After clicking ok on Alert message you can see Order Now button has become hidden in below image.

SiddharamTakali_0-1719423729584.png

Refer below Catalog UI Policy which I tried on my PDI

 

SiddharamTakali_2-1719423790524.png

 

SiddharamTakali_3-1719423850752.png

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

 

 

Thank you.  Would something about the following configuration cause the code to NOT work?

xxxxx.png

 

Or could it be something in how the Order / Submit button is being searched for?  Maybe my button is named or classed differently?  Here is what the rendered button looks like:

yyy.png

Hi @G24 I have tried this as well and still I'm able to hide Order Now button. 

Add condition to Catalog UI Policy and try to hide Order Now button conditionally. Let's check if it works on conditionally? 

@Sid_Takali Thanks for all your help.  I was able to get this working finally, using a different this.jQuery() selector.  I posted the solution that worked for me.  Thanks again.

G24
Kilo Sage

I was able to get this working finally, using a different this.jQuery() query:

function onCondition() {
	if (this.jQuery){
		//alert("1");
		//this.jQuery("btn-primary").hide(); //Did NOT work for me.  I have no elements of type "btn-primary".
		//this.jQuery("#btn-primary").hide(); //Did NOT work for me.  I have no elements with id "btn-primary".
		
		//this.jQuery(".btn-primary").hide(); //Any element with class == .btn-primary.  This did work for me.
		this.jQuery("button[name='submit']").hide(); //Any button element where 'name' = 'submit'.  Works also.
		//alert("2");
	}
}