How to Ensure Customers Click on the Terms of Service (ToS) Checkbox at Checkout in WooCommerce
This guide provides step-by-step instructions on configuring WooCommerce checkout settings to make the Terms of Service checkbox mandatory.
To copy the ID for the Terms of Service (ToS) checkbox at checkout, right-click on the ToS field and select 'Inspect'

Once the console is open, click on the ToS checkbox. Look for the ID name (in this case, it is 'terms')

In the following code, replace (my_field_name) with the ID you copied from your page.
Code to add
// Required ToS checkboxes
if (!document.getElementById('my_field_name').checked) {
return {
proceed: false,
errorMessage: 'Please accept all the Conditions!',
errorTitle: 'Before Continuing',
data
}
}
Copy the code and edit the IDP plugin on your plugin editor

Make sure Instant Direct Payments by OpenPath was selected:

In the plugin files go to Inc folder > elements_js.php

In the elements_js.php file, locate the code section containing oe.beforeSend. paste the code and save it.

Now when people click and does not check the ToS box will received an error.

Updated 4 months ago