Customising the WooCommerce checkout process can significantly enhance user experience and streamline the purchasing journey. One useful technique is to pre-fill checkout fields based on URL parameters. This approach can save customers time and reduce friction during the checkout process. In this guide, we’ll show you how to populate WooCommerce checkout fields from the URL without using additional plugins.
Why Populate Checkout Fields From URL?
- Enhanced User Experience: Save customers time by pre-filling information.
- Personalised Offers: Customise fields for specific campaigns or user segments.
- Streamlined Process: Reduce cart abandonment by simplifying the checkout process.
Step 1: Adding Code to Your Theme’s Functions File
To achieve this, you’ll need to add custom code to your theme’s functions.php file. If you don’t have a child theme set up, it’s best to create one to ensure your customisations are not lost when the theme updates. You can easily create a child theme using our free child theme generator.
- Create a Child Theme (if you don’t already have one):
- Visit our Free WordPress Child Theme Generator to create and download your child theme.
- Follow the instructions to install and activate your child theme.
- Add Code to
functions.php:- Navigate to Appearance > Theme File Editor in your WordPress dashboard.
- Select the
functions.phpfile of your child theme. - Add the following code snippet to populate the checkout fields:
/*
* Snippet: How to Populate WooCommerce Checkout Fields From URL – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1341
* Tested with WooCommerce 10.7.0
* "Populate WooCommerce checkout fields from URL"
*/
function wcsuccess_populate_checkout_fields_from_url() {
if (is_checkout() && !is_wc_endpoint_url()) {
// Define the checkout fields and their corresponding URL parameters
$fields_to_populate = array(
'billing_first_name' => 'first_name',
'billing_last_name' => 'last_name',
'billing_email' => 'email',
'billing_phone' => 'phone',
'billing_address_1' => 'address',
'billing_city' => 'city',
'billing_postcode' => 'postcode',
'billing_country' => 'country',
'billing_state' => 'state'
);
foreach ($fields_to_populate as $checkout_field => $url_param) {
if (isset($_GET[$url_param]) && !empty($_GET[$url_param])) {
WC()->checkout()->get_value($checkout_field);
wc_get_template('checkout/form-billing.php');
echo "<script>
jQuery(document).ready(function($) {
$('input[name=\"$checkout_field\"]').val('" . esc_js($_GET[$url_param]) . "');
});
</script>";
}
}
}
}
add_action('woocommerce_before_checkout_form', 'wcsuccess_populate_checkout_fields_from_url');
Step 2: Customise the URL Parameters
Ensure your URLs include the parameters you want to use for pre-filling the checkout fields. For example:
https://yourstore.com/checkout?first_name=John&last_name=Doe&email=john.doe@example.com&phone=1234567890The parameters in the URL (first_name, last_name, email, etc.) should match the keys defined in the $fields_to_populate array in the code snippet.
Step 3: Test the Functionality
Navigate to your WooCommerce checkout page using a URL that includes the parameters. Verify that the checkout fields are pre-filled with the corresponding values from the URL.
Use Cases for Populating Checkout Fields From URL
- Marketing Campaigns: Send personalised emails with pre-filled checkout links to increase conversion rates.
- Customer Support: Provide customers with a direct link to the checkout page with their details already filled in to simplify the process.
- Affiliate Programs: Allow affiliates to create custom checkout links with pre-filled information to enhance user experience.
- Special Offers: Create targeted promotions where the customer’s details are pre-filled, making it easier for them to complete the purchase.
Conclusion
Populating WooCommerce checkout fields from the URL is a powerful technique to enhance user experience, streamline the checkout process, and increase conversions. By implementing the code provided in this guide, you can pre-fill checkout fields based on URL parameters without the need for additional plugins.
I have been working with WordPress and WooCommerce since 2012 and have developed a deep knowledge of the content management system. Since 2012, I have developed several plugins and designed dozens of websites utilising different frameworks, CMS’s and programming languages. I am proficient in PHP, Python, Java, C, C++, R and JavaScript with limited experience in Go, Kotlin and Swift.
Educationally, I have a Master’s degree in cyber security a Bachelor’s (Hons, First Class) in Applied Research and a Graduate Certificate in Data Science. I’m currently undertaking PhD studies investigating IoT cybersecurity. I recently graduated with First Class Honours and Masters of Information Technology, receiving the Executive Dean’s Award for studies undertaken in the 2021 and 2022 academic years. I have worked in the information technology industry for the past 11 years primarily as a software/web developer specific to design, optimisation, network management and security. My research interests are in the areas of Internet of Things (IoT), 5G and Beyond Networks, information security for wireless networks and software development.
Stay In Touch

