Eren Labs JOURNAL TR
WooCommerce Errors

“Invalid value posted for …” in WooCommerce: when an option value doesn’t fit the variation

WooCommerce shows this when an add-to-cart request carries an option value that the chosen variation doesn't accept. The attribute name in the message tells you which option to look at.

In this article12 sections

A variation is defined by its option values, such as Size: S. When an add-to-cart request names a variation and also sends option values, WooCommerce checks that they agree. This notice means one value didn’t: the request said one size while the variation is another, or sent a size this product doesn’t have.

WooCommerce’s own product page always sends values that fit, because the variation is picked from them. So the request almost always came from a link, a feed or a plugin.

The exact message#

Invalid value posted for Size

The same failure can also read:

  • Invalid value posted for Size. Allowed values: S, M

Who sees it: Shoppers, as an error notice after an add-to-cart request for a variation. The name at the end is the attribute’s label. The longer wording comes from the Store API, used by block-based buttons, and lists the values the product accepts for that attribute.

What WooCommerce checks#

For each option used for variations, WooCommerce takes the value sent in the request, if any, and compares it with the variation:

  1. If the variation has a fixed value, the sent value must be exactly that value.
  2. If the variation is set to Any, the sent value must be one of the values the product has for that option.

Before comparing, a value for a global attribute (one set up under Products > Attributes) is turned into a slug, so Large becomes large. A value for a custom attribute typed on the product keeps its exact spelling and case. An empty value is ignored, and the variation’s own value is used.

The first value that fails stops the request, and its attribute label goes into the message.

Causes and how to fix each one#

A link such as ?add-to-cart=12&variation_id=34&attribute_size=M breaks when variation 34 is the Small. This happens when a link is copied and only the size is changed, or when a spreadsheet or feed fills the variation and option columns from different rows.

Check: Open the product’s Variations tab, find the variation by its ID in the header (such as #34), and compare its option values with the ones in the link.

Fix: Change the option value to match the variation, or leave the option out of the link: for a variation with fixed values, WooCommerce fills them in itself.

2. The value is spelled differently from what is stored#

For a custom attribute, the value must match exactly, including capitals: s fails when the product says S. For a global attribute, the value must be the term’s slug. Case doesn’t matter there, but a term named Extra Large with the slug xl needs xl, not its name.

Check: For a global attribute, go to Products > Attributes, click Configure terms next to it and read the Slug column. For a custom attribute, open the product’s Attributes tab and read the values exactly as typed.

Fix: Use the stored value or slug in the link, feed or plugin setting.

3. The variation is set to Any and the value isn’t one of the product’s#

A variation set to Any Size accepts any size the product has, and nothing else. A link asking for XXL fails when the product only lists S, M and L. For a global attribute, the term must be assigned to this product, not just exist in the store.

Check: Open the product’s Attributes tab and look at the values listed for that attribute.

Fix: Add the value to the product’s attribute, or correct the link to a value the product has.

4. A theme or plugin sends labels instead of values#

Swatch, quick-view, quick-order and translation plugins sometimes send the label shown to shoppers, or a translated value, instead of the stored value. The product works from its own page and fails from the plugin’s button.

Check: Add the same variation from the product’s own page. If that works and the plugin’s button doesn’t, the plugin is sending the value. Health Check & Troubleshooting can switch it off for your session to confirm.

Fix: Update the plugin or report the attribute and value to its developer.

Quick reference#

CauseHow to checkFix
The link names one variation and a different optionOpen the product's Variations tab, find the variation by its ID in the header (such as #34), and compare its option values with the ones in the link.Change the option value to match the variation, or leave the option out of the link: for a variation with fixed values, WooCommerce fills them in itself.
The value is spelled differently from what is storedFor a global attribute, go to Products > Attributes, click Configure terms next to it and read the Slug column. For a custom attribute, open the product's Attributes tab and read the values exactly as typed.Use the stored value or slug in the link, feed or plugin setting.
The variation is set to Any and the value isn't one of the product'sOpen the product's Attributes tab and look at the values listed for that attribute.Add the value to the product's attribute, or correct the link to a value the product has.
A theme or plugin sends labels instead of valuesAdd the same variation from the product's own page. If that works and the plugin's button doesn't, the plugin is sending the value. Health Check & Troubleshooting can switch it off for your session to confirm.Update the plugin or report the attribute and value to its developer.

Reproduced on a test store#

We set up each case below on a clean WooCommerce 11.2.1 store on 6 November 2026 and recorded exactly what it showed.

What we didWhat WooCommerce showed
Variable product Hoodie, custom attribute Size with values S | M (Used for variations), one variation per size, both priced 10. Logged out. Request ?add-to-cart=<parent>&variation_id=<S variation>&attribute_size=M.Invalid value posted for Size
Same product. Request ?add-to-cart=<parent>&variation_id=<S variation>&attribute_size=s.Invalid value posted for Size
Global attribute Size (pa_size) with a term named Extra Large, slug xl. Variable product using it, variation xl priced 10. Request ?add-to-cart=PARENT_ID&variation_id=VARIATION_ID&attribute_pa_size=Extra%20Large.Invalid value posted for Size
The same link with attribute_pa_size=xl, the term's slug.No message. The product was added to the cart.
Hoodie with a single variation set to Any Size, priced 10. Request ?add-to-cart=<parent>&variation_id=<variation>&attribute_size=XXL.Invalid value posted for Size
Same, with attribute_size=M.No message. The product was added to the cart.
First Hoodie. POST /wc/store/v1/cart/add-item with id=<S variation> and variation [{"attribute":"Size","value":"M"}].Invalid value posted for Size. Allowed values: S, M

For developers#

To see what a variation and its parent accept, run this in wp shell:

print_r( wc_get_product_variation_attributes( 34 ) ); // '' = Any
foreach ( wc_get_product( 12 )->get_attributes() as $a ) {
    echo $a->get_name(), ': ', implode( ', ', $a->get_slugs() ), "\n";
}

Request keys are attribute_ plus the sanitized attribute name, for example attribute_pa_size for a global attribute and attribute_size for a custom one. The Store API accepts the attribute’s label or name in the variation array and returns the error code woocommerce_rest_invalid_variation_data with the allowed values, which is the quickest way to see what WooCommerce expects.

Where this lives in WooCommerce 11.2.1:

  • includes/class-wc-cart.php, WC_Cart::add_to_cart: For each variation attribute with a value: accepts it if it equals the variation’s stored value, or if the variation is set to Any and the value is one of the product’s values. Otherwise throws the message.
  • includes/class-wc-cart.php, WC_Cart::add_to_cart: Posted values for global attributes go through sanitize_title(); values for custom attributes are cleaned but keep their case.
  • includes/class-wc-product-attribute.php, WC_Product_Attribute::get_slugs: The product’s own values for the attribute: term slugs for a global attribute, the typed values for a custom one.
  • includes/wc-product-functions.php, wc_get_product_variation_attributes: The variation’s stored values. An empty value means Any.
  • src/StoreApi/Utilities/CartController.php, CartController::parse_variation_data: Same rule for the Store API, with the allowed values listed in the message.

Back to the WooCommerce error reference.

Frequently asked questions#


Which value is invalid?

The message names the attribute, such as Size. Compare the value sent for that attribute with the variation’s value on the Variations tab, or with the product’s values if the variation is set to Any.


Why does it work on the product page but not from my link?

The product page picks the variation from the chosen values, so they always agree. A link names the variation and the values separately, and they can disagree.


Are attribute values case-sensitive?

For custom attributes typed on the product, yes. For global attributes, the value is turned into a slug first, so case doesn’t matter but the slug must match.


Do I need to put the options in an add-to-cart link at all?

Only for options the variation leaves as Any. For fixed options, WooCommerce uses the variation’s own values when none are sent.


What does "Allowed values" in the longer message mean?

That is the Store API’s version. It lists the values the product has for the attribute, as slugs for global attributes or exactly as typed for custom ones.


More in WooCommerce Errors

Keep exploring

All articles