How to Populate WooCommerce Checkout Fields From URL – 2026

Last updated on August 2nd, 2024 at 12:34 pm

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?

  1. Enhanced User Experience: Save customers time by pre-filling information.
  2. Personalised Offers: Customise fields for specific campaigns or user segments.
  3. 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.

  1. Create a Child Theme (if you don’t already have one):
  2. Add Code to functions.php:
    • Navigate to Appearance > Theme File Editor in your WordPress dashboard.
    • Select the functions.php file 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=1234567890

The 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.

See also  How to Set Up a Loyalty Program in WooCommerce Without Using a Plugin - 2026

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

  1. Marketing Campaigns: Send personalised emails with pre-filled checkout links to increase conversion rates.
  2. Customer Support: Provide customers with a direct link to the checkout page with their details already filled in to simplify the process.
  3. Affiliate Programs: Allow affiliates to create custom checkout links with pre-filled information to enhance user experience.
  4. Special Offers: Create targeted promotions where the customer’s details are pre-filled, making it easier for them to complete the purchase.
See also  How to Get Sale Push Notifications in WooCommerce Without a Plugin - 2026

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.

0 0 votes
Article Rating

Stay In Touch

Was this post helpful? Why not show your support and buy me a coffee?

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Scroll to Top
0
Would love your thoughts, please comment.x
()
x
×