Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Disable script from running on checkout woocommerce WordPress

  • REFUND REQUESTED

Hello I have a script that I have placed on my website it loads on all pages. I would like to disable it for checkout page. I am looking for the conditional statement and where to place it.

my script_>

<!-- BEGIN GROOVE WIDGET CODE -->
<script id="grv-widget">
/*<![CDATA[*/
window.groove = window.groove || {}; groove.widget = function(){ groove._widgetQueue.push(Array.prototype.slice.call(arguments)); }; groove._widgetQueue = [];
groove.widget('setWidgetId', '704aa3f8-33ac-16a2-f369-201a38a1f54e');
!function(g,r,v){var a,c,n=r.createElement("iframe");(n.frameElement||n).style.cssText="width: 0; height: 0; border: 0",n.title="",n.role="presentation",n.src="javascript:false",r.body.appendChild(n);try{a=n.contentWindow.document}catch(b){c=r.domain;var d="javascript:document.write('<head><script>document.domain=\""+c+"\";</",i="script></head><body></body>')";n.src=d+i,a=n.contentWindow.document}var s="https:"==r.location.protocol?"https://":"http://",p="http://groove-widget-production.s3.amazonaws.com".replace("http://",s);n.className="grv-widget-tag",a.open()._l=function(){c&&(this.domain=c);var t=this.createElement("script");t.type="text/javascript",t.charset="utf-8",t.async=!0,t.src=p+"/loader.js",this.body.appendChild(t)},a.write('<body onload="document._l();">'),a.close()}(window,document);
/*]]>*/
</script>
<!-- END GROOVE WIDGET CODE -->

Answers (3)

2016-10-25

Fahad Murtaza answers:

if (!is_page('page_slug')) {
// put code here
}


Fahad Murtaza comments:

Read more here https://developer.wordpress.org/reference/functions/is_page/

Your final code should look something like



// If its not a specific page

if (!is_page('page_slug')) {

?>
<!-- BEGIN GROOVE WIDGET CODE -->

<script id="grv-widget">

/*<![CDATA[*/

window.groove = window.groove || {}; groove.widget = function(){ groove._widgetQueue.push(Array.prototype.slice.call(arguments)); }; groove._widgetQueue = [];

groove.widget('setWidgetId', '704aa3f8-33ac-16a2-f369-201a38a1f54e');

!function(g,r,v){var a,c,n=r.createElement("iframe");(n.frameElement||n).style.cssText="width: 0; height: 0; border: 0",n.title="",n.role="presentation",n.src="javascript:false",r.body.appendChild(n);try{a=n.contentWindow.document}catch(b){c=r.domain;var d="javascript:document.write('<head><script>document.domain=\""+c+"\";</",i="script></head><body></body>')";n.src=d+i,a=n.contentWindow.document}var s="https:"==r.location.protocol?"https://":"http://",p="http://groove-widget-production.s3.amazonaws.com".replace("http://",s);n.className="grv-widget-tag",a.open()._l=function(){c&&(this.domain=c);var t=this.createElement("script");t.type="text/javascript",t.charset="utf-8",t.async=!0,t.src=p+"/loader.js",this.body.appendChild(t)},a.write('<body onload="document._l();">'),a.close()}(window,document);

/*]]>*/

</script>

<!-- END GROOVE WIDGET CODE -->

<?php

}

2016-10-25

Arnav Joy answers:

you can try this

<?php if( !is_checkout() ) { ?>

<!-- BEGIN GROOVE WIDGET CODE -->

<script id="grv-widget">

/*<![CDATA[*/

window.groove = window.groove || {}; groove.widget = function(){ groove._widgetQueue.push(Array.prototype.slice.call(arguments)); }; groove._widgetQueue = [];

groove.widget('setWidgetId', '704aa3f8-33ac-16a2-f369-201a38a1f54e');

!function(g,r,v){var a,c,n=r.createElement("iframe");(n.frameElement||n).style.cssText="width: 0; height: 0; border: 0",n.title="",n.role="presentation",n.src="javascript:false",r.body.appendChild(n);try{a=n.contentWindow.document}catch(b){c=r.domain;var d="javascript:document.write('<head><script>document.domain=\""+c+"\";</",i="script></head><body></body>')";n.src=d+i,a=n.contentWindow.document}var s="https:"==r.location.protocol?"https://":"http://",p="http://groove-widget-production.s3.amazonaws.com".replace("http://",s);n.className="grv-widget-tag",a.open()._l=function(){c&&(this.domain=c);var t=this.createElement("script");t.type="text/javascript",t.charset="utf-8",t.async=!0,t.src=p+"/loader.js",this.body.appendChild(t)},a.write('<body onload="document._l();">'),a.close()}(window,document);

/*]]>*/

</script>

<!-- END GROOVE WIDGET CODE -->

<?php } ?>

2016-10-25

mod mi answers:

According to woocommerce conditional tags here: https://docs.woocommerce.com/document/conditional-tags/

You should wrap your code with a conditional statement like the following.

Code:

if (!is_checkout): ?>

<!-- BEGIN GROOVE WIDGET CODE -->

<script id="grv-widget">

/*<![CDATA[*/

window.groove = window.groove || {}; groove.widget = function(){ groove._widgetQueue.push(Array.prototype.slice.call(arguments)); }; groove._widgetQueue = [];

groove.widget('setWidgetId', '704aa3f8-33ac-16a2-f369-201a38a1f54e');

!function(g,r,v){var a,c,n=r.createElement("iframe");(n.frameElement||n).style.cssText="width: 0; height: 0; border: 0",n.title="",n.role="presentation",n.src="javascript:false",r.body.appendChild(n);try{a=n.contentWindow.document}catch(b){c=r.domain;var d="javascript:document.write('<head><script>document.domain=\""+c+"\";</",i="script></head><body></body>')";n.src=d+i,a=n.contentWindow.document}var s="https:"==r.location.protocol?"https://":"http://",p="http://groove-widget-production.s3.amazonaws.com".replace("http://",s);n.className="grv-widget-tag",a.open()._l=function(){c&&(this.domain=c);var t=this.createElement("script");t.type="text/javascript",t.charset="utf-8",t.async=!0,t.src=p+"/loader.js",this.body.appendChild(t)},a.write('<body onload="document._l();">'),a.close()}(window,document);

/*]]>*/

</script>

<!-- END GROOVE WIDGET CODE -->

<?php endif;