wc-api-custom-meta icon indicating copy to clipboard operation
wc-api-custom-meta copied to clipboard

Cant update custom meta via curl

Open russwittmann opened this issue 9 years ago • 7 comments

Currently I'm trying to update my site meta using curl if I try this: curl -X PUT https://dev.domain.com/wc-api/v3/products/241074 -u key:secret -H "Content-Type: application/json" -d '{"product":{"meta": {"my_availability":"S"}}}' and it doesn't work, although a regular update works curl -X PUT https://dev.domain.com/wc-api/v3/products/241074 -u key:secret -H "Content-Type: application/json" -d '{"product":{"regular_price": "9000.00"}}' of a normal woo field, I'm so close but I just can't get it, any help is appreciated

russwittmann avatar Jun 27 '16 22:06 russwittmann

Should it be custom_meta rather than meta? I left meta free for core WC use.

judgej avatar Jun 28 '16 09:06 judgej

its definitely called meta here is the results of just a query. and All I need to change is "my_availability" to "S"

{
    "product":{
        "title":"GOLD $20 LIBERTY",
        "id":241074,
        "created_at":"2016-06-19T17:28:38Z",
        "updated_at":"2016-06-19T17:28:38Z",
        "type":"simple",
        "status":"publish",
        "downloadable":false,
        "virtual":false,
        "permalink":"https:\/\/dev.monacorarecoins.com\/coin\/gold-20-liberty-id241074\/",
        "sku":"",
        "price":"9000.00",
        "regular_price":"9000.00",
        "sale_price":null,
        "price_html":"<span class=\"amount\">&#36;9,000.00<\/span>",
        "taxable":true,
        "tax_status":"taxable",
        "tax_class":"",
        "managing_stock":false,
        "stock_quantity":null,
        "in_stock":true,
        "backorders_allowed":false,
        "backordered":false,
        "sold_individually":false,
        "purchaseable":true,
        "featured":false,
        "visible":true,
        "catalog_visibility":"visible",
        "on_sale":false,
        "product_url":"",
        "button_text":"",
        "weight":null,
        "dimensions":{
            "length":"",
            "width":"",
            "height":"",
            "unit":"cm"
        },
        "shipping_required":true,
        "shipping_taxable":true,
        "shipping_class":"",
        "shipping_class_id":null,
        "description":"",
        "short_description":"",
        "reviews_allowed":true,
        "average_rating":"0.00",
        "rating_count":0,
        "related_ids":[
            3898,
            301520,
            991,
            27250,
            338
        ],
        "upsell_ids":[

        ],
        "cross_sell_ids":[

        ],
        "parent_id":0,
        "categories":[
            "$20 Double Eagle",
            "$20 Gold Liberty Double Eagles For Sale",
            "Best Values",
            "Buy Type I $20 Liberties",
            "Gold Double Eagles"
        ],
        "tags":[
            "1853"
        ],
        "images":[
            {
                "id":0,
                "created_at":"2016-06-28T16:49:01Z",
                "updated_at":"2016-06-28T16:49:01Z",
                "src":"https:\/\/dev.mydomain.com\/wp-content\/plugins\/woocommerce\/assets\/images\/placeholder.png",
                "title":"Placeholder",
                "alt":"Placeholder",
                "position":0
            }
        ],
        "featured_src":"",
        "attributes":[

        ],
        "downloads":[

        ],
        "download_limit":0,
        "download_expiry":0,
        "download_type":"",
        "purchase_note":"",
        "total_sales":0,
        "variations":[

        ],
        "parent":[

        ],
        "grouped_products":[

        ],
        "menu_order":0,
        "meta":{
            "ebar_coin_id":"241074",
            "ebar_search_title":"GOLD $20 LIBERTY",
            "my_availability":"Y",
            "ebar_grade":"MS61",
            "ebar_grading_service":"NGC",
            "ebar_date_mint":"1853",
            "ebar_comod":"DEL",
            "ebar_condition":"MS61",
            "ebar_coin_description":"GOLD $20 LIBERTY",
            "ebar_pcgs_number":"",
            "ebar_cert_number":"01890861003643203003",
            "ebar_code":"DEL",
            "ebar_key":"N",
            "ebar_finest":"N",
            "ebar_numis":"9470",
            "ebar_cu3000":"0008250",
            "ebar_top100":"N",
            "ebar_featured":"N",
            "ebar_notes":"7\/15 AUC=$10,350",
            "ebar_valued":"Y",
            "ebar_ship":"N",
            "ebar_year":"1853",
            "_wc_rating_count":[

            ],
            "_wc_average_rating":"0"
        }
    }
}

JDJ: formatted for clarity.

russwittmann avatar Jun 28 '16 16:06 russwittmann

Sorry, I'm getting the dreaded "Consumer Secret is invalid" message on my instance, after some server upgrades, and run out of time trying to work around that problem.

Can you confirm that you did try custom_meta as the name of the object to send custom metadata fields to?

judgej avatar Jul 02 '16 22:07 judgej

Correct it doesn't work with custom_meta. If you want I can give you access to my instance?

russwittmann avatar Jul 02 '16 22:07 russwittmann

Give me a day or two to get it working at my end. I do need a working system if I'm going to be able to do anything useful here.

judgej avatar Jul 03 '16 21:07 judgej

Any luck?

russwittmann avatar Jul 18 '16 22:07 russwittmann

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.

judgej avatar Aug 02 '17 15:08 judgej