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

set data into a custom field #5

Open
Zmash opened this issue Mar 28, 2015 · 2 comments
Open

set data into a custom field #5

Zmash opened this issue Mar 28, 2015 · 2 comments

Comments

@Zmash
Copy link

Zmash commented Mar 28, 2015

Hey guys,
I dont know how i have to write some rest request to set a value in to my custom field.
I have installed your Plugin and i have created a custom field like http://www.remicorson.com/mastering-woocommerce-products-custom-fields/
Now the question is how i have to write the rest request to set data in this custom field.

I tried it like
"custom_meta": [
{
"my_custom_field_id": "my_custom_value",
}
]

@judgej
Copy link
Owner

judgej commented Mar 28, 2015

Hi,

What you have given should work, if I am reading it correctly. However, you may have an extra level in the structure there. Try this instead:

"custom_meta": {
    "my_custom_field_id": "my_custom_value",
}

You have an array of objects, while it should be one object with one or more properties that match the custom fields. I'm guessing you aren't using PHP to write to the API (just a guess), but in PHP this would be an associative array.

If doing it this way is counter-intuitive to non-PHP users of the API, then I'm happy to change it to take a more standard cross-platform approach.

@judgej
Copy link
Owner

judgej commented Aug 2, 2017

Use the new v2 REST API (WC 3.x) instead of this plugin. It now does everything this plugin does out of the box. The README gives some examples of how you would manage the metadata fields.

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