[REST API] variable product created without given attributes
-
Hi,
I try to import variable products autmatically via the REST API of WooCommerce (3.2.1).
In my system is one attribute stored with ID 1:[ { "id": 1, "name": "Entwickelt oder Digital", "slug": "pa_2xju1krpnrjvxux2odlox1fb", "type": "select", "order_by": "menu_order", "has_archives": false, "_links": { "self": [{ "href": "...\/wp-json\/wc\/v2\/products\/attributes\/1" } ], "collection": [{ "href": "...\/wp-json\/wc\/v2\/products\/attributes" } ] } } ]
Then I try to create a variable product via POST https://…/wp-json/wc/v2/products with
{ "name": "IMG_5993", "attributes": [{ "id": 1, "variation": true } ], "categories": [{ "id": 67 } ], "type": "variable", "slug": "lcc5lwpteuabkpm10frauldo" }
As a result the product appears in the shop but misses the requested attribute. The response for my requests looks like
{ "id": 271, "name": "IMG_5993", "slug": "lcc5lwpteuabkpm10frauldo", "permalink": ".../index.php/produkt/lcc5lwpteuabkpm10frauldo/", "date_created": "2017-10-30T13:43:58", "date_created_gmt": "2017-10-30T12:43:58", "date_modified": "2017-10-30T13:43:58", "date_modified_gmt": "2017-10-30T12:43:58", "type": "variable", "status": "publish", "featured": false, "catalog_visibility": "visible", "description": "", "short_description": "", "sku": "", "price": "", "regular_price": "", "sale_price": "", "date_on_sale_from": null, "date_on_sale_from_gmt": null, "date_on_sale_to": null, "date_on_sale_to_gmt": null, "price_html": "", "on_sale": false, "purchasable": false, "total_sales": 0, "virtual": false, "downloadable": false, "downloads": [], "download_limit": -1, "download_expiry": -1, "external_url": "", "button_text": "", "tax_status": "taxable", "tax_class": "", "manage_stock": false, "stock_quantity": null, "in_stock": false, "backorders": "no", "backorders_allowed": false, "backordered": false, "sold_individually": false, "weight": "", "dimensions": { "length": "", "width": "", "height": "" }, "shipping_required": true, "shipping_taxable": true, "shipping_class": "", "shipping_class_id": 0, "reviews_allowed": true, "average_rating": "0", "rating_count": 0, "related_ids": [], "upsell_ids": [], "cross_sell_ids": [], "parent_id": 0, "purchase_note": "", "categories": [{ "id": 67, "name": "Shooting vom 30.10.2017", "slug": "78exy65zicfue0u9qifdthjq" } ], "tags": [], "images": [{ "id": 0, "date_created": "2017-10-30T14:44:08", "date_created_gmt": "2017-10-30T12:44:08", "date_modified": "2017-10-30T14:44:08", "date_modified_gmt": "2017-10-30T12:44:08", "src": ".../wp-content/plugins/woocommerce/assets/images/placeholder.png", "name": "Platzhalter", "alt": "Platzhalter", "position": 0 } ], "attributes": [], "default_attributes": [], "variations": [], "grouped_products": [], "menu_order": 0, "meta_data": [{ "id": 3294, "key": "_wpas_done_all", "value": "1" } ], "_links": { "self": [{ "href": ".../index.php/wp-json/wc/v2/products/271" } ], "collection": [{ "href": ".../index.php/wp-json/wc/v2/products" } ] } }
Here you can see the attributes array is empty.
Where is the problem? Am I missing required parameters or preconditions? Or is there a problem in the API for variable products?
Please help.
Best regards, Klaus Hauschild
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘[REST API] variable product created without given attributes’ is closed to new replies.