Skip to content

Instantly share code, notes, and snippets.

@rynaldos-zz
Last active December 14, 2020 17:37
Show Gist options
  • Save rynaldos-zz/4993f8515580601856d51fccf974f8de to your computer and use it in GitHub Desktop.
Save rynaldos-zz/4993f8515580601856d51fccf974f8de to your computer and use it in GitHub Desktop.
[WooCommerce 3.0+] Disable terms and conditions toggle and force it to open in a new tab
function disable_wc_terms_toggle() {
wp_enqueue_script( 'disable-terms-toggle', '/disable-terms-toggle.js', array( 'wc-checkout', 'jquery' ), null, true );
wp_add_inline_script( 'disable-terms-toggle', "jQuery( document ).ready( function() { jQuery( document.body ).off( 'click', 'a.woocommerce-terms-and-conditions-link' ); } );" );
}
add_action( 'wp_enqueue_scripts', 'disable_wc_terms_toggle', 1000 );
// This snippet can be used alongside https://gist.github.com/rynaldos/0bee7d84a83c5b52096c747c19d088c0 (custom terms and conditions link)
@bjornweb
Copy link

WC 3.4.0 +

Use the following remove_action and WC will default back to opening a tab with the terms and conditions page.

add_action( 'wp', 'my_project_wc_change_hooks' );
function my_project_wc_change_hooks() {
  remove_action( 'woocommerce_checkout_terms_and_conditions', 'wc_checkout_privacy_policy_text', 20 );
  remove_action( 'woocommerce_checkout_terms_and_conditions', 'wc_terms_and_conditions_page_content', 30 );
}

@Frithir
Copy link

Frithir commented Jan 24, 2019

Prefect @bjornweb just what I needed :)

@ECWireless
Copy link

@bjornweb what folder do you put this function in?

@damadorPL
Copy link

@bjornweb what folder do you put this function in?

usually functions php - best in child theme :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment