Title: PHP Warning: Undefined variable $field_values in CheckoutFieldsFrontend.php
Last modified: April 10, 2025

---

# PHP Warning: Undefined variable $field_values in CheckoutFieldsFrontend.php

 *  Resolved [shinagawa](https://wordpress.org/support/users/shinagawa/)
 * (@shinagawa)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/php-warning-undefined-variable-field_values-in-checkoutfieldsfrontend-php/)
 * Thank you for WooCommerce 9.8.1 release.
 * After changing the password on the My Account screen (/my-account/edit-account/),
   warning was logged in debug.log below (WooCommerce9.8.1+PHP8.3.10).
 * [10-Apr-2025 08:55:37 UTC] PHP Warning: Undefined variable $field_values in /***/
   wp-content/plugins/woocommerce/src/Blocks/Domain/Services/CheckoutFieldsFrontend.
   php on line 312
 *     ```wp-block-code
       protected function get_posted_additional_field_values( $location, $group, $sanitize = true ) {
           $additional_fields = $this->checkout_fields_controller->get_fields_for_location( $location );
   
           // phpcs:disable WordPress.Security.NonceVerification.Missing
           foreach ( $additional_fields as $field_key => $field_data ) {
               $post_key                   = CheckoutFields::get_group_key( $group ) . $field_key;
               $field_values[ $field_key ] = wc_clean( wp_unslash( $_POST[ $post_key ] ?? '' ) );
   
               if ( $sanitize ) {
                   $field_values[ $field_key ] = $this->checkout_fields_controller->sanitize_field( $field_key, $field_values[ $field_key ] );
               }
           }
           // phpcs:enable WordPress.Security.NonceVerification.Missing
           return $field_values;
       }
       ```
   
 * When the foreach loop does not execute, the $field_values variable remains undefined,
   which results in a warning being logged.
 * Thank you for your time and support.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Nadir Seghir](https://wordpress.org/support/users/senadir/)
 * (@senadir)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/php-warning-undefined-variable-field_values-in-checkoutfieldsfrontend-php/#post-18409571)
 * Thank you, we will fix this soon! It shouldn’t impact changing a password.
 *  Thread Starter [shinagawa](https://wordpress.org/support/users/shinagawa/)
 * (@shinagawa)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/php-warning-undefined-variable-field_values-in-checkoutfieldsfrontend-php/#post-18409678)
 * Thank you for your quick reply. That’s a relief. Best regards,
 *  [Moses M. (woo-hc)](https://wordpress.org/support/users/mosesmedh/)
 * (@mosesmedh)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/php-warning-undefined-variable-field_values-in-checkoutfieldsfrontend-php/#post-18411410)
 * Hi [@shinagawa](https://wordpress.org/support/users/shinagawa/),
 * I’m glad the response was helpful! Since you’re using WooCommerce, would you 
   mind taking a moment to leave a review for the plugin? Your feedback means a 
   lot to us and helps us continue improving. You can leave your review here: [https://wordpress.org/support/plugin/woocommerce/reviews/#new-post](https://wordpress.org/support/plugin/woocommerce/reviews/#new-post)

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘PHP Warning: Undefined variable $field_values in CheckoutFieldsFrontend.
php’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [Moses M. (woo-hc)](https://wordpress.org/support/users/mosesmedh/)
 * Last activity: [1 year, 1 month ago](https://wordpress.org/support/topic/php-warning-undefined-variable-field_values-in-checkoutfieldsfrontend-php/#post-18411410)
 * Status: resolved