• Resolved marlondc

    (@marlondc)


    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 5 years, 3 months ago by marlondc.
    • This topic was modified 5 years, 3 months ago by marlondc.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Richard Korthuis

    (@rockfire)

    Hi @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

    (@marlondc)

    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

    (@rockfire)

    Hi @marlondc

    No problem ??

    You could user wp_json_encode(...) to ensure that the data is indeed valid JSON.

    Plugin Author Richard Korthuis

    (@rockfire)

    This thread has been marked as resolved due to lack of activity.

    You’re always welcome to open a new topic.

    Thanks for understanding!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘__PHP_Incomplete_Class_Name’ is closed to new replies.