API v1.0.12 Release Notes
Released on Thursday, March 3, 2016
New Features
Payment Types allow using multiple payment types on a single order
Generate Variants
Breaking Changes
DefinesVariant has been moved from the Spec model to the Product-Spec Assignment model
Generating Variants
There are 4 things needed to create a product with variants Spec(s) Spec options a spec product relationship that sets Defines variant = true an explicit call to POST {productID}/variants/generate
it's pretty simple once they're initially set up. Take the ubiquitous shirt example Specs size small, large color red, black
spec - product = size/shirt/definesvariant = true spec - product = color/shirt/definesvariant = true
a call to POST {productID}/variants/generate
will generate 4 variants
small red
small black
large red
large black
Adding specs is pretty simple add color:blue and a call to POST {productID}/variants/generate
will ADD the missing variants 1 small blue 2 large blue The tricky bit starts when a spec is removed. if color is deleted, all the variants are not relevant because color is built into all of them. Delete color and add logo to our shirt. So that this is the config of shirt: size: small,large logo: logoA,logoB
and a call to POST {productID}/variants/generate
will only ADD new variants and you'll have 8. Even with the spec deleted, the dependant variant can still exist, it's just not tied to the deleted spec. This is important if that variant is already on an order.
small logoA
small logoB
large logoA
large logoB
small red
small black
large red
large black
if your intention is to start over and reset the variants, there is the spec nuclear option:
POST {productID}/variants/generate?overwriteExisting=true
This will DELETE ALL variants and regenerate them based on the current spec configurations. If a variant is on a lineitem, it will be removed. The previous example deletes color and adds logo. calling overwriteExisting=true will result in
small logoA
small logoB
large logoA
large logoB
The key to overwriteExisting=true is that it will always delete all variants and regenerate regardless of the change to the spec configuration.