REST API support requires Mix and Match Products 1.10.0
This is a advanced document is written for WooCommerce developers looking to extend or customize WooCommerce Mix and Match Products.
WooCommerce 2.6 added support for REST API endpoints based on the WordPress REST API infrastructure.
Mix and Match Products extends the /products/ and /orders/ endpoint responses with a new properties. mnm_child_items
appears in both contexts.
- In product context,
lists the products that are available as part of a Mix and Match container product.mnm_child_items
- In order context,
is applicable to the Mix and Match container line item and lists the order item IDs of the line item products that were selected as part of the Mix and Match container product. Themnm_child_items
mnm_child_of
property is applicable to child order items and references the order item ID of their parent.
Products
↑ Back to topProduct Properties
↑ Back to topProduct properties only applicable only for Mix and Match type products.
Attribute | Type | Context | Description |
---|---|---|---|
mnm_layout_override | bool | read | Has product-specific layouts that override global setting |
mnm_layout | string | read write | Single-product details page layout. Values: tabular | grid |
mnm_form_location | string | read | Single-product details page add to cart form location. Values: default | after_summary |
mnm_content_source | string | read | Source of child products. Values: products | categories |
mnm_child_category_ids | array | read | List of child categories allowed in this product |
mnm_child_items | array | read write | List of child items contained in this product. |
mnm_min_container_size | integer | read write | Minimum container size. |
mnm_max_container_size | integer null | read write | Maximum container quantity. Use null when the container has no max quantity restriction. |
mnm_discount | string | read write | Indicates the percentage discount to apply to each child product when per-product pricing is enabled. |
mnm_priced_per_product | boolean | read write | Indicates whether the container price is calculated from the price of the selected child products. |
mnm_packing_mode | string | read write | Indicates how the child products are packed/shipped.Values virtual | together | separate | separate_plus |
mnm_weight_cumulative | boolean | read write | Indicates how the shipping weight should be calculated |
mnm_shipped_per_product | boolean | read write | [Deprecated] Indicates whether the child products are shipped individually. |
Child Items Properties
↑ Back to topThe properties of each array in the mnm_child_items
response.
Attribute | Type | Context | Description |
---|---|---|---|
child_item_id |
| read | The item ID in the custom database table. |
child_id |
| read | [Deprecated] If the product is a variation, this is the variation ID. If the product is simple product, this is the product ID. |
product_id |
| read write | The product ID of this child item product. |
variation_id | integer | read write | The variation ID of this child item product. |
delete |
| write | Indicates if this child item should be deleted. Note: This is not supported when the product is using categories as the content source. |
Working with Products: Examples
↑ Back to topCreating a Mix and Match Product from products
curl -X POST https://example.com/wp-json/wc/v3/products \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Sample Six Pack",
"type": "mix-and-match",
"regular_price": "0",
"short_description": "Pick 6.",
"mnm_layout": "grid",
"mnm_form_location": "after_summary",
"mnm_min_container_size": 6,
"mnm_max_container_size": 6,
"mnm_discount": "25",
"mnm_priced_per_product": true,
"mnm_packing_mode": "together",
"mnm_content_source": "products"
"mnm_child_items": [
{
"product_id": 7
},
{
"product_id": 9
},
{
"product_id": 14
},
{
"product_id": 16
},
{
"product_id": 17
},
{
"product_id": 10,
"variation_id": 12
}
]
}'
Adding a Child Product
curl -X POST https://example.com/wp-json/wc/v3/products/1351 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"mnm_child_items": [
{
"product_id": 1281
}
]
}'
Deleting a Child Product
curl -X POST https://example.com/wp-json/wc/v3/products/1351 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"mnm_child_items": [
{
"child_item_id": 9,
"delete": true
}
]
}'
Creating a Mix and Match Product from categories
curl -X POST https://example.com/wp-json/wc/v3/products \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"name": "Sample Six Pack by Category",
"type": "mix-and-match",
"regular_price": "99",
"description": "So many products to choose from.",
"mnm_min_container_size": 6,
"mnm_max_container_size": 6,
"mnm_content_source": "categories"
"mnm_child_category_ids": [ 53, 54 ]
}'
Note: Individual products cannot be added or deleted when the allowed contents are pulled from categories.
Orders
↑ Back to topLine Item Properties
↑ Back to topAttribute | Type | Context | Description |
---|---|---|---|
mnm_child_of |
|
| Order Item ID of parent line item, applicable if the item is part of a Mix and Match container. |
mnm_child_items |
| read | Order Item IDs of selected child line items, applicable if the item is a Mix and Match container item. |
mnm_configuration | array | write | Mix and Match container configuration array. Must be defined when adding a Mix and Match-type line item to an order, to ensure child line items are added to the order as well. See Container Configuration Properties. |
Container Configuration Properties
↑ Back to topAttribute | Type | Context | Description |
---|---|---|---|
product_id |
| write | Child product ID. |
variation_id | integer | write | Child variation ID if the child is a variation. |
quantity |
| write | Child product quantity. |
Mix and Match Configuration Properties
↑ Back to topThe following extensions have known compatibility issues with Name Your Price. This list is not exhaustive. Other extensions and third-party plugins may cause issues to Name Your Price, or not work as expected with it.
Working with Orders: Examples
↑ Back to topAdding a Mix and Match container to order
curl -X POST https://example.com/wp-json/wc/v3/orders/199 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"line_items": [
{
"product_id": 1351,
"quantity": 1,
"mnm_configuration": [
{
"product_id": 17,
"quantity": 3
},
{
"product_id": 10,
"variation_id": 12,
"quantity": 3
}
]
}
]
}'
Questions & Support
↑ Back to topSomething missing from this documentation? Do you still have questions and need assistance?
- Have a question before you buy this extension? Please fill out this pre-sales form – please include the name of this extension in your query.
- Already purchased and need some assistance? Get in touch with the developer via the WooCommerce.com Support page and choose this extension name from the “I need help with” dropdown. Please include a clear description of the issue.