How to directly link to Privacy Policy page in checkout

Hi there!

In the checkout page there’s a link to the Privacy Policy page, where you have to check the box so you can proceed to buy, that doesn’t directly link to the page itself but open a hidden accordion that in my case show some Visual Composer shortcodes.

I need to chang this setting and link directly to the page instead of open that accordion. How can I fix this?

Thanks in advance :slight_smile:
Best regards

Hello There,

Thanks for writing in! Because what you are trying to accomplish requires a template customization, we would highly to suggest that you use a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

Once you have your child theme active and ready, please follow the following steps below:
1] Using Notepad or TextEdit or Sublime Text or any text editor, please create a new file in your local machine.
2] Insert the following code into that new file

<?php
/**
 * Checkout terms and conditions checkbox
 *
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     3.1.1
 */
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

$terms_page_id = wc_get_page_id( 'terms' );

if ( $terms_page_id > 0 && apply_filters( 'woocommerce_checkout_show_terms', true ) ) :
	$terms         = get_post( $terms_page_id );
	$terms_content = has_shortcode( $terms->post_content, 'woocommerce_checkout' ) ? '' : wc_format_content( $terms->post_content );

	if ( $terms_content ) {
		do_action( 'woocommerce_checkout_before_terms_and_conditions' );
		echo '<div class="woocommerce-terms-and-conditions" style="display: none; max-height: 200px; overflow: auto;">' . $terms_content . '</div>';
	}
	?>
	<p class="form-row terms wc-terms-and-conditions">
		<label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
			<input type="checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" name="terms" <?php checked( apply_filters( 'woocommerce_terms_is_checked_default', isset( $_POST['terms'] ) ), true ); ?> id="terms" /> <span><?php printf( __( 'I&rsquo;ve read and accept the <a href="%s" target="_blank">terms &amp; conditions</a>', 'woocommerce' ), esc_url( wc_get_page_permalink( 'terms' ) ) ); ?></span> <span class="required">*</span>
		</label>
		<input type="hidden" name="terms-field" value="1" />
	</p>
	<?php do_action( 'woocommerce_checkout_after_terms_and_conditions' ); ?>
<?php endif; ?>

3] Save the file named as terms.php
4] Upload this file to your server in the child theme’s folder wp-content/themes/x-child/woocommerce/checkout/ or wp-content/themes/pro-child/woocommerce/checkout/ if you are using Pro theme.

You must create the folder path since this does not exist yet in your child theme.

Hope this helps. Please let us know how it goes.

1 Like

Hi @RueNel,

thank you so much for your help! It works great, just as I wanted to :smiley:
I’m already using the child team (as all should do) so it was just a matter of copy paste :slight_smile:

You rock, guys :heart:

Thanks again,

best regards

On behalf of my colleague, you’re welcome. Cheers! :slight_smile:

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.