Using wp wc CLI to add meta_data
-
I feel like I should be able to do
sudo wp wc customer update 141 --meta_data="[{"key":"test_meta1","value":"test_meta_value"}]" --user=1
However, this does not work.
The result I get is
Success: Updated customer 141.
However,
sudo wp wc customer get 141 --fields=meta_data --user=1 | grep test_meta
returns blank.
curl -X PUT https://www.example.com/wp-json/wc/v3/customers/141 \ -u consumer_key:consumer_secret \ -H "Content-Type: application/json" \ -d '{"meta_data": [{"key": "test_meta1","value": "test_meta_value"}]}'
would work, but I’d prefer to use the wp wc CLI if possible, rather than the REST API.
I’ve also tried adding meta_data to products, with similar challenges – eg
sudo wp wc product create --name="test2" --sku="test2" --regular_price=10 --meta_data="[{"meta_data": [{"key": "test_meta1","value": "test_meta_value"}]}]" --user=1
What’s the right format for supplying meta_data on the wp wc CLI command line interface? I get it needs to be an array… but what format does that actually mean? Can anyone product a working example?
- The topic ‘Using wp wc CLI to add meta_data’ is closed to new replies.