Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 opened this issue Apr 11, 2017 · 1 comment

Comments

@macolo
Copy link

macolo commented Apr 11, 2017

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

@judgej
Copy link
Owner

judgej commented Aug 2, 2017

Use the new v2 REST API (WC 3.x) - it now does everything this plugin does out of the box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants