30% Discount Get your Kallyas WordPress license Today for only $49! Or renew your support at $18 for extra 6 months. Shop Now

Moving Terms and Conditions checkbox above Payments

Looks like this has been requested a lot (on other themes supporting WooCommerce as well) and not too many solutions have been provided, thus we would like to show you how to move the Terms and Conditions checkbox above Payments.

The first thing you need to do is override the woocommerce/tempaltes/checkout/terms.php template in the kallyas-child theme and remove the checkbox from there. To do that, you will need to create the following directory structure in your child theme: kallyas-child/woocommerce/checkout/terms.php. Edit this file and remove the paragraph containing the terms and conditions checkbox, so in the end the template will look like this:

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

if ( wc_get_page_id( 'terms' ) > 0 && apply_filters( 'woocommerce_checkout_show_terms', true ) ) : ?>
   <?php do_action( 'woocommerce_checkout_before_terms_and_conditions' ); ?>
    <?php do_action( 'woocommerce_checkout_after_terms_and_conditions' ); ?>
<?php endif; ?>

 

The next step is to display the checkbox where we want. In our example we’ve decided to display it above the Payments section, but you can use any of the available WooCommerce hooks for the checkout page: http://businessbloomer.com/woocommerce-visual-hook-guide-checkout-page/ and display it where you want. For this, we need to edit the child theme’s fucntions.php file and add this code:

add_action('woocommerce_review_order_before_payment', 'zn_kc_move_terms_and_conditions', 90);
function zn_kc_move_terms_and_conditions()
{
   ?>
   <p class="form-row terms wc-terms-and-conditions">
      <input type="checkbox" class="input-checkbox" name="terms" <?php checked( apply_filters( 'woocommerce_terms_is_checked_default', isset( $_POST['terms'] ) ), true ); ?> id="terms" />
      <label for="terms" class="checkbox"><?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 class="required">*</span></label>
      <input type="hidden" name="terms-field" value="1" />
   </p>
   <?php
}

 

Save the file and view your checkout page, you will see the checkbox is now displayed above the payments section 🙂