• Resolved bryanlopez

    (@bryanlopez)


    I added some custom fields for my WooCommerce products, but when I send a GET request I just see the meta_box:[] empty, but they appear in the meta_data field (see bellow):

    "meta_data": [
               
                {
                    "id": 3927,
                    "key": "ff-continue_selling_out_of_stock",
                    "value": "1"
                },
                {
                    "id": 3928,
                    "key": "ff-pack_quantity",
                    "value": "77"
                },
                {
                    "id": 3929,
                    "key": "ff-barcode",
                    "value": "7777777"
                }
            ],
    "meta_box": [],

    I have a custom API in a WordPress plugin, so the requests are sent with this path: localsite/wp-json/ff/v1/product/265

    So, I tested using the normal path localsite/wp-json/wp/v2/product/265 and I get the expected result:

    "meta": [],
    "meta_box": {
            "ff-continue_selling_out_of_stock": "1",
            "ff-pack_quantity": "77",
            "ff-barcode": "7777777"
        },

    But if i try to update with a PUT or POST to that normal path localsite/wp-json/wp/v2/product/265 I get an error on postman (see bellow)

    POST I send

    {
        "meta_box": {
            "ff-pack_quantity": "66666",
            "ff-barcorde": "1111111",
            "ff-continue_selling_out_of_stock": "0"
        }
    }

    Error Response I GET

    {
        "code": "rest_cannot_edit",
        "message": "Sorry, you are not allowed to edit this post.",
        "data": {
            "status": 403
        }
    }

    -I need to send the request to the first path localsite/wp-json/ff/v1/product/id , so what could be the problem, what am i doing wrong? because both ways are not working

    Any help would be greatly appreciated

    Thanks!

    • This topic was modified 5 years, 10 months ago by bryanlopez.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘WooCommerce Custom Field NOT WORKING’ is closed to new replies.