Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Piccia Neri
Piccia Neri
8,937 Points

Wordpress: How to add a click-wrap agreement to an enquiry button?

Hello there, I have looked everywhere but, surprisingly, I cannot find any answers to this question either in the form of plugins or tutorials.

A client needs a click-wrap agreement on his Wordpress site in a number of places.

i.e. the visitor clicks on a button and before they carry on, a pop-up window comes up with the T&Cs and they have to tick a box and agree before they are taken to the enquiry or booking form.

I thought this was pretty standard and I would find a plugin for it – no such luck! Am getting a bit desperate as it needs sorting out asap – client wants to go live today and everything else has been done. I would be extremely grateful for any help!

5 Answers

Adrian Randall
Adrian Randall
4,807 Points

There should be a js file in your theme

Located at: /wp-content/themes/<your_theme_name>/js/<some_name.js>

It varies a little but generally this is the location of the included javascript files

However if there isn't an existing one then yes you need to create and enqueue

Adrian Randall
Adrian Randall
4,807 Points

Never heard of the term click wrap, try adding an onClick or onSubmit (if it's a form) event. Then you can catch the the event, and show a confirm using JS.

Here's a JSFiddle example...just add a checkbox and check for it being selected http://jsfiddle.net/vandalo/nvZc4/

Piccia Neri
Piccia Neri
8,937 Points

thanks Adrian, that's a good workaround, now I need to work out how to adapt it to my needs as I don't really know js!

thank you very much that really helped.

Piccia Neri
Piccia Neri
8,937 Points

ok, I can see how that would work – sorry if it's a daft question, but where do I put the Javascript in Wordpress? I have a limited understanding of this – do I have to save a .js file and then enqueue it in functions.php? because if that's the case, I don't know how to do it... sorry, I am a relative newbie...

Piccia Neri
Piccia Neri
8,937 Points

thanks Adrian, I'll try that – or maybe I will bite the bullet and fork out for this:

http://wplegalpages.com/

Posting it here just in case anyone else develops a need for a similar function and doesn't want to fiddle around with js.