// Adding a custom checkout date field add_filter( 'woocommerce_billing_fields', 'add_birth_date_billing_field', 20, 1 ); function add_birth_date_billing_field($billing_fields) { $billing_fields['billing_birth_date'] = array( 'type' => 'date', 'label' => __('Geboortedatum'), 'class' => array('form-row-wide'), 'priority' => 25, 'required' => true, 'clear' => true, ); return $billing_fields; } // Check customer age add_action('woocommerce_checkout_process', 'check_birth_date'); function check_birth_date() { // Check billing city 2 field if( isset($_POST['billing_birth_date']) && ! empty($_POST['billing_birth_date']) ){ // Get customer age from birthdate $age = date_diff(date_create($_POST['billing_birth_date']), date_create('now'))->y; // Checking age and display an error notice avoiding checkout (and emptying cart) if( $age < 18 ){ wc_add_notice( __( "Om een bestelling te plaatsen, moet je minimaal 18 jaar oud zijn." ), "error" ); WC()->cart->empty_cart(); // <== Empty cart (optional) } } }
In case of any complain or © copyright or issues please check disclaimer page for faster resolutions.
Wat is het verschil tussen UX en UI?
UI-design en UX-design In de wereld van webdesign, maar ook in het ontwikkelen van softwareread more...
Block malicious web traffic
Sucuri firewall The internet is full of malicious actors. There are low-level annoyances like “scriptread more...
Verify that Google can find your page
Google Search console Google Search Console is a free tool from Google that helps youread more...
Every website needs hosting
SiteGround hosting Every website needs hosting. Unless you happen to operate a web hosting agency,read more...
E-commerce webshop
E-commerce is a booming industry worldwide. The advent of the internet and the rapid, sustainedread more...
Search engine optimization by Yoast
Yoast Plugin Search Engine Optimization (SEO) can be a very technical field. It is alsoread more...
Why should you use Cloudways?
Cloudways hosting Web hosting is an essential service for any internet-based or internet-interfaced business. Whetherread more...
WP Rocket is the best way to boost your site
WP Rocket Plugin WP Rocket is a WordPress plugin that facilitates faster page loads andread more...
Google analytics is a free service provided by Google
Google Analytics Google analytics is a free service provided by Google that helps webmasters, siteread more...
Het snelste en beste webshopplatform Woocommerce
In case of any complain or © copyright or issues please check disclaimer page forread more...
Create a multilingual wordpress site
Translatepress plug-in The internet is truly global in nature. An internet user in the Netherlandsread more...