Title: How to fix PHP errors
Last modified: October 6, 2025

---

# How to fix PHP errors

 *  [David Molnar](https://wordpress.org/support/users/dave82-1/)
 * (@dave82-1)
 * [8 months ago](https://wordpress.org/support/topic/how-to-fix-php-errors/)
 * There is a lot of PHP warning in the server error.log file like this:
 * PHP Warning:  Attempt to read property “ID” on null in …/wp-content/plugins/woocommerce-
   unit-of-measure/public/class-wc-uom-public.php on line 86
 * Since this plugin developer hasn’t fix this in months, I desided to give it a
   try. Here is how can you do it:
    1. Open the **/public/class-wc-uom-public.php**
    2. **Find the line 83** where is like this: private function woo_uom_output_getter(
       $uom_item_id = null) {
    3. After that line you need to change some lines.
 * Old code:
 *     ```wp-block-code
       private function woo_uom_output_getter($uom_item_id = null) {if (is_null($uom_item_id)) {global $post;$uom_item_id = $post->ID;
       ```
   
 * And you need to change into this:
 *     ```wp-block-code
               private function woo_uom_output_getter($uom_item_id = null) {            if (is_null($uom_item_id)) {            // global $post;            // $uom_item_id = $post->ID;            global $post, $product;            // 1) If there is global $product            if (isset($product) && is_a($product, 'WC_Product')) {                $uom_item_id = $product->get_id();                // 2) If there is $post            } elseif (isset($post) && is_object($post) && isset($post->ID)) {                $uom_item_id = (int) $post->ID;                // 3) Queried object ID (single product page)            } else {                $queried_id = get_queried_object_id();                if ($queried_id) {                    $uom_item_id = (int) $queried_id;                }            }        }        if (empty($uom_item_id)) {            return '';        }
       ```
   
 * This is fix the code and error messages are gone. Plugin works as expected.

The topic ‘How to fix PHP errors’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/woocommerce-unit-of-measure.svg)
 * [Unit Of Measure (UOM) for WooCommerce](https://wordpress.org/plugins/woocommerce-unit-of-measure/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce-unit-of-measure/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce-unit-of-measure/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce-unit-of-measure/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce-unit-of-measure/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce-unit-of-measure/reviews/)

## Tags

 * [error-handling](https://wordpress.org/support/topic-tag/error-handling/)

 * 0 replies
 * 1 participant
 * Last reply from: [David Molnar](https://wordpress.org/support/users/dave82-1/)
 * Last activity: [8 months ago](https://wordpress.org/support/topic/how-to-fix-php-errors/)
 * Status: not resolved