Skip to content

in WP debug mode, json includes a HTML warning: id was called <strong>incorrectly</strong>. Product properties should not be accessed directly. #21

Open
@macolo

Description

@macolo

This then triggers an invalid json error.

Example Query:
https://your-host.com/wc-api/v3/products?filter%5Bcategory%5D=Shoe&consumer_key=ck_123&consumer_secret=cs_1234

returns something like:

<br />
<b>Notice</b>:  id was called <strong>incorrectly</strong>. Product properties should not be accessed directly. Please see <a href="https://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.0.) in <b>/srv/www/ozz-stage/wordpress/wp-includes/functions.php</b> on line <b>4137</b><br />
{"products":[{"title":"Marietta Pink","id":11,"created_at":"2017-04-09T15:57:49Z","updated_at":"2017-04-10T06:18:46Z","type":"variable","status":"publish","downloadable":false,"virtual":false,"permalink":"https:\/\/your-host.coml\/product\/marietta-red\/","sku":"","price":"200","regular_price":"","sale_price":null,"price_html":"<span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">&#36;<\/span>200.00<\/span>","taxable":false,"tax_status":"taxable","tax_class"

The culprit is probably this one:
https://github.com/judgej/wc-api-custom-meta/blob/master/wc-api-custom-meta.php#L109

See docs here: https://docs.woocommerce.com/wc-apidocs/class-WC_Data.html#_get_id

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions