1. Documentation /
  2. Mix and Match Products /
  3. Mix and Match: REST API Reference

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_layout_overrideboolread
write
Has product-specific layouts that override global setting
mnm_layoutstringread writeSingle-product details page layout. Values: tabular | grid
mnm_form_locationstringread
write
Single-product details page add to cart form location. Values: default | after_summary
mnm_content_sourcestringread
write
Source of child products. Values: products | categories
mnm_child_category_idsarrayread
write
List of child categories allowed in this product
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_packing_modestringread writeIndicates how the child products are packed/shipped.Values virtual | together | separate | separate_plus
mnm_weight_cumulativebooleanread writeIndicates how the shipping weight should be calculated
mnm_shipped_per_productbooleanread write[Deprecated] Indicates 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_item_idintegerreadThe item ID in the custom database table.
child_idintegerread[Deprecated] If 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 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 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.

  • 30-day money back guarantee
  • Support teams across the world
  • Safe and secure online payment