Skip to content

Commit a21f359

Browse files
committed
Create README.md
1 parent 406332f commit a21f359

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# wc-api-custom-meta
2+
WordPress/WooCommerce plugin to support custom meta fields through the product API
3+
4+
A very simple plugin that allows you to create, update or remove custom meta fields when
5+
managing prducts through the WooCommerce API.
6+
7+
It is necessary to install this plugin on the WC site providing the API.
8+
I have raised a ticket asking whether this can ever be a core feature of WooCommerce,
9+
but the ticket has been rejected (rather rudely):
10+
11+
https://github.com/woothemes/woocommerce/issues/7593
12+
13+
It may come back, but this plugin fills a gap in the meantime.
14+
15+
To use it, add elements to the product array passed to the `products` entrypoint. Each element is
16+
an array, with examples that follow:
17+
18+
~~~php
19+
$product = [
20+
'product' => [
21+
'title' => 'Foobar',
22+
...
23+
'custom_meta' => [
24+
'my_custom_field_name' => 'my custom value',
25+
],
26+
'remove_custom_meta' => [
27+
'remove_all_instances_of_this_field_name',
28+
'remove_just_one_value_of_this_field_name' => 'this is the value',
29+
],
30+
]
31+
]
32+
~~~
33+
34+
That's it. Make sure those elements are in yoru REST API request, and this plugin is installed at the other end,
35+
and you can set any meta fields you like.
36+
37+
I have not tested this with anything other than strings, so be wary that the behaviour storing otehr data structures
38+
in metafields are *undefined* at present.

0 commit comments

Comments
 (0)