judgej / wc-api-custom-meta

WordPress/WooCommerce plugin to support custom meta fields through the product API
32 stars 12 forks source link

Cant update custom meta via curl #15

Open russwittmann opened 8 years ago

russwittmann commented 8 years ago

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

judgej commented 8 years ago

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

russwittmann commented 8 years ago

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.

judgej commented 8 years ago

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?

russwittmann commented 8 years ago

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

judgej commented 8 years ago

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.

russwittmann commented 8 years ago

Any luck?

judgej commented 7 years ago

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.