Mix and Match: REST API Reference

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, mnm_child_itemslists the products that are available as part of a Mix and Match container product.
  • In order context, mnm_child_itemsis 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. The mnm_child_of property is applicable to child order items and references the order item ID of their parent.

Products ↑ Back to top

Product Properties ↑ Back to top

Product properties only applicable only for Mix and Match type products.

AttributeTypeContextDescription
mnm_layoutstringread writeSingle-product details page layout. Values: tabular grid
mnm_child_itemsarrayread writeList of child items contained in this product.
mnm_min_container_sizeintegerread writeMinimum container size.
mnm_max_container_sizeinteger
null
read writeMaximum container quantity. Use null when the container has no max quantity restriction.
mnm_discountstringread writeIndicates the percentage discount to apply to each child product when per-product pricing is enabled.
mnm_priced_per_productbooleanread writeIndicates whether the container price is calculated from the price of the selected child products.
mnm_shipped_per_productbooleanread writeIndicates whether the child products are shipped individually.

Child Items Properties ↑ Back to top

The properties of each array in the mnm_child_items response.

AttributeTypeContextDescription
child_idintegerreadIf the product is a variation, this is the variation ID. If the product is simple product, this is the product ID.
product_idintegerread writeList of child items contained in this product.
variation_idintegerread writeMinimum container size.
deletebooleanwriteMaximum container quantity. Use null when the container has no max quantity restriction.

Working with Products: Examples ↑ Back to top

Creating a Mix and Match Product

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",
    "description": "So many products to choose from.",
    "short_description": "Pick 6.",
    "categories": [
        {
            "id": 9
        }
    ],
    "mnm_child_items": [
        { 
            "product_id": 7
        },
        { 
            "product_id": 9
        },
        { 
            "product_id": 14
        },
        { 
            "product_id": 16
        },
        { 
            "product_id": 17
        },
        { 
            "product_id": 10,
            "variation_id": 12
        }
    ],
    "mnm_layout": "grid",
    "mnm_min_container_size": 6,
    "mnm_max_container_size": 6,
    "mnm_discount": "25",
    "mnm_priced_per_product": true,
    "mnm_shipped_per_product": false
}'

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_id": 1281,
            "delete": true
        }
    ]
}'

Orders ↑ Back to top

Line Item Properties ↑ Back to top

AttributeTypeContextDescription
mnm_child_ofintegerread Order Item ID of parent line item, applicable if the item is part of a Mix and Match container.
mnm_child_itemsarrayread Order Item IDs of selected child line items, applicable if the item is a Mix and Match container item.
mnm_configurationarraywriteMix 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 top

AttributeTypeContextDescription
product_idintegerwriteChild product ID.
variation_idintegerwriteChild variation ID if the child is a variation.
quantityintegerwriteChild product quantity.

Mix and Match Configuration Properties ↑ Back to top

The 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 top

Adding 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 top

Something 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.

WooCommerce - the most customizable eCommerce platform for building your online business.

Back to the top