Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Woocommerce REST API how send custom meta?

Woocommerce not send meta with custom plug-ins in format .json.

What should I add to the file functions.php?

How to forcibly compel him to send some meta?

Sorry for such a simple question, but I have not found a solution for spaces google

like image 745
Taras Bezdushnuy Avatar asked Aug 31 '25 21:08

Taras Bezdushnuy


1 Answers

Send the following payload to the API:

    $data = [
        'name' => 'Product Name',
        'type' => 'simple',
        'regular_price' => '19.95',
        'description' => 'Simple Product,
        'categories' => [
            ['id' => 1]
        ],
        'virtual' => true,
        'reviews_allowed' => false,
        'meta_data' => [
            [
                'key' => '_custom_meta_1',
                'value' => 'value1'
            ],
            [
                'key' => '_custom_meta_2',
                'value' => 'value2'
            ]
        ]
    ];

the "meta_data" field, should be an array, containing arrays with "key" and "value" attributes.

like image 137
MarkNL Avatar answered Sep 03 '25 18:09

MarkNL