简体   繁体   中英

Group products using Woocommerce REST API

I'm trying to create a grouped products using latest version of Woocommerce REST API. I managed to create a product with type grouped and a few products with type simple . But how do I actually group them together? The grouped_products array, which contain IDs of grouped products is read only and parent_id property is not what I'm looking for. Any solutions?

The grouped_products property is now editable in the WooCommerce REST API v2. It was previously marked as READ ONLY but that only applies to v1 of the REST API. With v2 of the REST API you can create a grouped product and set the grouped_products array like this:

curl -X POST https://example.com/wp-json/wc/v2/products \
    -u consumer_key:consumer_secret \
    -H "Content-Type: application/json" \
    -d '{
  "name": "Test grouped product",
  "type": "grouped",
  "grouped_products": [1, 2, 3]
}'

where 1, 2 and 3 are the child simple products to be included in the grouped product.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM