How to Open the WooCommerce Terms and Conditions Link in a New Tab

0
1256

WooCommerce displays the terms and conditions acceptance checkbox on the payment form of the checkout page. The checkbox field is a requirement before placing an order. If a customer wants to read the terms and conditions, it is displayed in the small area of the payment form. As a result, it is hard to read and scroll through. This tutorial will show you how to open the WooCommerce terms and conditions link in a new tab on the checkout page.

WooCommerce Terms and Conditions Checkbox

WooCommerce uses an accordion effect to display the terms and conditions on the checkout page. The area expands when clicking the terms and conditions link. Consequently, this makes the WooCommerce terms and conditions difficult to read and may frustrate customers.

A better solution is to have the link open in a new tab. Moreover, opening a separate tab is essential if you are using a third-party company to generate your privacy policy and terms and conditions.

Copy and paste the following PHP code snippet into the functions.php file of your active parent theme or child theme.

function golden_oak_web_design_woocommerce_checkout_terms_and_conditions() {
  remove_action( 'woocommerce_checkout_terms_and_conditions', 'wc_terms_and_conditions_page_content', 30 );
}
add_action( 'wp', 'golden_oak_web_design_woocommerce_checkout_terms_and_conditions' );

The PHP code snippet does two things. First, it removes the accordion effect from the terms and conditions checkbox field. This is done by unhooking the function wc_terms_and_conditions_page_content from the action woocommerce_checkout_terms_and_conditions. Secondly, the code snippet will force the terms and conditions link to open in a new tab.

Final Thoughts

If you populate the terms and conditions page on your website with Javascript, the content will not display within the accordion area on the checkout page. This is due to the content being filtered by WordPress for security reasons. As a result, you will need to have the WooCommerce terms and conditions link open in a new tab.

LEAVE A REPLY

Please enter your comment!
Please enter your name here