Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 504799

How to create custom check boxes on the checkout page

$
0
0

Replies: 0

Hi all,

I’m using lifterLMS 2.7.12.

I’d like to add additional checkboxes on the checkout page, e.g. one for agreeing to terms and condition. Because it is necessary that the customer checks this check box for every course he is purchasing.

Therefore I’ve modified form-checkout.php and added the following code below the payment method section:

<?php if ( ‘yes’ === get_option( ‘lifterlms_registration_require_agree_to_terms’ ) && get_option( ‘lifterlms_terms_page_id’ ) ) : ?>

<div class=”llms-form-item-wrapper agree_to_terms”>
<input type=”checkbox” name=”agree_to_terms” id=”agree_to_terms” value=”yes” />
<label for=”agree_to_terms”>
<?php printf( __( ‘I have read and agree to the Terms and Conditions‘, ‘lifterlms’ ), get_the_permalink( get_option( ‘lifterlms_terms_page_id’ ) ) ); ?>
</label>
</div>
<div class=”llms-form-item-wrapper agree_to_terms”>
<input type=”checkbox” name=”agree_to_disclaimer” id=”agree_to_terms” value=”yes” />
<label for=”agree_to_terms”>
Ich möchte sofort Zugang zu dem digitalen Inhalt und weiß, dass mein Widerrufsrecht mit dem Zugang erlischt.
</label>
</div>

<?php endif; ?>

The two checkboxes and the corresponding text is displayed on the checkout page. But when I click on “Buy now” the checkboxes are not validated. I know that I have put some code somewhere, e.g.

function terms_check() {
if ( empty( $agree_to_terms ) ) {
return new WP_Error( ‘registration-error’, __( ‘You must agree to the Terms and Conditions.’, ‘lifterlms’ ) );
}
}
?>
<?php
// add an action to the hook
add_action( ‘lifterlms_after_checkout_form’, ‘terms_check’ );
?>

So my question is what do I have to do to get the checkboxes validated? Where do I have to put the validation function and how can I invoke the function by clicking on “Buy now”?

Thanks in advance
Matthias


Viewing all articles
Browse latest Browse all 504799

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>