Title: __PHP_Incomplete_Class_Name
Last modified: November 27, 2019

---

# __PHP_Incomplete_Class_Name

 *  Resolved [marlondc](https://wordpress.org/support/users/marlondc/)
 * (@marlondc)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/__php_incomplete_class_name/)
 * Hi,
 * I have a custom endpoint that fetches woocommerce products.
 * However when the product returns on our client the meta data is populated by 
   these __PHP_Incomplete_Class_Name: WC_Meta_Data issues.
 * this is the code that enables the endpoint
 *     ```
       function add_custom_product_endpoint($allowed_endpoints)
       {
           if (!isset($allowed_endpoints['wp/custom-product-endpoint']) || !in_array('products', $allowed_endpoints['wp/custom-product-endpoint'])) {
               $allowed_endpoints['wp/custom-product-endpoint'][] = 'products';
           }
           return $allowed_endpoints;
       }
       add_filter('wp_rest_cache/allowed_endpoints', 'add_custom_product_endpoint', 10, 1);
       ```
   
 * What should I do to remedy this?
 * Thanks
    -  This topic was modified 6 years, 6 months ago by [marlondc](https://wordpress.org/support/users/marlondc/).
    -  This topic was modified 6 years, 6 months ago by [marlondc](https://wordpress.org/support/users/marlondc/).

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

 *  Plugin Author [Richard Korthuis](https://wordpress.org/support/users/rockfire/)
 * (@rockfire)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/__php_incomplete_class_name/#post-12199702)
 * Hi [@marlondc](https://wordpress.org/support/users/marlondc/)
 * Thank you for using our plugin!
 * Without looking at the code for your custom endpoint this is hard to debug for
   me. It seems the result of your endpoint isn’t correct json, but it is all speculation.
   Is there a possibility you could share the code for your endpoint with us?
 *  Thread Starter [marlondc](https://wordpress.org/support/users/marlondc/)
 * (@marlondc)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/__php_incomplete_class_name/#post-12209003)
 * Hi Richard,
 * Thanks for your reply and advice. It does seem that the result of the endpoint
   is not correct json.
 * I am making a WC_Product_Query to get the products
 * I then use this function to get the data Coast_WC_REST_Products_Controller->prepare_object_for_response
   to get the data. I then return that.
 * I have seen that WC_Meta_Data classes exist in that data. What I have done is
   I jsonSerialize to convert into valid JSON.
 * Is this the correct method or is there a WP function to unserialize it for me.
   I understand this is probably out of scope for this forum.
 *  Plugin Author [Richard Korthuis](https://wordpress.org/support/users/rockfire/)
 * (@rockfire)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/__php_incomplete_class_name/#post-12209024)
 * Hi [@marlondc](https://wordpress.org/support/users/marlondc/)
 * No problem 🙂
 * You could user `wp_json_encode(...)` to ensure that the data is indeed valid 
   JSON.
 *  Plugin Author [Richard Korthuis](https://wordpress.org/support/users/rockfire/)
 * (@rockfire)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/__php_incomplete_class_name/#post-12323854)
 * This thread has been marked as resolved due to lack of activity.
 * You’re always welcome to open a [new topic](https://wordpress.org/support/plugin/wp-rest-cache/#new-post).
 * Thanks for understanding!

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

The topic ‘__PHP_Incomplete_Class_Name’ is closed to new replies.

 * ![](https://ps.w.org/wp-rest-cache/assets/icon-256x256.png?rev=3328849)
 * [WP REST Cache](https://wordpress.org/plugins/wp-rest-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-rest-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-rest-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-rest-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-rest-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-rest-cache/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Richard Korthuis](https://wordpress.org/support/users/rockfire/)
 * Last activity: [6 years, 4 months ago](https://wordpress.org/support/topic/__php_incomplete_class_name/#post-12323854)
 * Status: resolved