F
F
ftomovden2018-01-28 17:40:08
WordPress
ftomovden, 2018-01-28 17:40:08

How to remove checkbox from terms.php file in woocommerce?

Good afternoon. Help deal with the issue. There is a terms.php file, which is located in the wp-content\plugins\woocommerce\templates\checkout directory.
It contains the code that needs to be changed. For some reason, the checkbox itself does not want to work for some unknown reason (does not respond to pressing). Based on the problem, the checkbox itself needs to be removed in such a way that, without its presence, the script skips further to checkout. Leave only text. At the moment, I delete the checkbox itself, and the script does not let me (writes that I need to express my consent).
The script itself:

<?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' ); ?> 
  <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( __( 'Ive read and accept the <a href="%s" target="_blank">terms & 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; ?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mike, 2018-01-29
@MikeKosulin

In functions.php or better Code Snippets plugin :

function set_checked_wc_terms( $terms_is_checked ) {   
  return true;   
}   
add_filter( 'woocommerce_terms_is_checked_default', 'set_checked_wc_terms', 10 );

In styles:
.terms > label.checkbox{
  display:none;
}

O
OneTwoThreeFourFive, 2018-01-29
@OneTwoThreeFourFive

<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" CHECKED/> <span><?php printf( __( 'Ive read and accept the <a href="%s" target="_blank">terms & conditions</a>', 'woocommerce' ), esc_url( wc_get_page_permalink( 'terms' ) ) ); ?></span> <span class="required">*</span> 
      </label>

Add "checked" to the end of input. The checkbox will be automatically checked when the page loads. If it is not needed, then apply display: none to it, this will hide it, but it will be marked and the system will let it go.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question