Adding Variable Products to Cart
When adding a variation from a variable product to the cart, there are several approaches you can take. Below are examples of each method and their outcomes.Method 1: No Attribute Data
To make things clear from the start. Adding a variable product without attribute data will fail as the variation cannot be determined. This method is not recommended.Method 2: Using Attribute Data
- Incorrect Values
- Correct Values
Note the lowercase “no”
Method 3: Using Variation ID
You can directly add a specific variation using its ID.Method 4: Using Alternative Attribute Formats
- Using Labels
- Mixed Format (Slug and Label)
You can use attribute labels instead of slugs.
Important Notes
- Attribute values are case-sensitive
- When using variation IDs, attribute data is optional
- Custom attribute labels must match exactly
- Values maybe limited to specific options
- You can use either attribute slugs (
attribute_pa_color
) or labels (Color
)