I’m working on a POS app, which creates variants for products, many times the original product only has the default variant.
Problem: no matter what I pass to the “strategy” argument, looks like it’s always replacing the default variant, I tried many things like using productSet or even creating the productOptions before creating the variants, and the default variant always get replaced by the new one.
CURL with the mutation to create the new variant:
curl --location --request POST ‘https://SHOP.myshopify.com/admin/api/2024-07/graphql.json’
–header ‘X-Shopify-Access-Token: TOKEN’
–header ‘Content-Type: application/json’
–data-raw ‘{“query”:“mutation ProductVariantsCreate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {\n productVariantsBulkCreate(productId: $productId, variants: $variants, strategy: DEFAULT) {\n productVariants {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n userErrors {\n field\n message\n }\n }\n}”,“variables”:{“productId”:“PRODUCT_ID”,“variants”:[{“price”:10,“compareAtPrice”:0.01,“optionValues”:[{“name”:“Temporary testing 1”,“optionName”:“Title”}]}]}}’