From the course: WordPress: Customizing WooCommerce Themes

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Add checkout fields

Add checkout fields - WordPress Tutorial

From the course: WordPress: Customizing WooCommerce Themes

Start my 1-month free trial

Add checkout fields

- [Instructor] One of the more common customizations store owners make to the checkout, is to add a How Did You Hear About Us field. It can be pretty tricky with other platforms, but with WooCommerce we can do it in a couple of hooks. I'm gonna go to my code editor, and open up my themes functions.php. I'm gonna scroll down to the bottom, and add a comment: Add how did you hear about us to the checkout. Just to make that a little bit more clear. Now we're gonna actually add the function, add_filter. And we're gonna use the same filter we used above, woocommerce_checkout_fields, which has all of the fields in it. And we're gonna write the function that modifies these fields. hplussports_how_did_you_hear_about_us, that's a little bit long, let's go with hplussports_hear_about_us. And we're gonna run this at priority 30, so it runs after the one above. Now we're gonna write the function, function, copy, paste, we need to bring in fields, which is all of the fields, and now we're ready to…

Contents