Skip to content

How to remove compareAtPrice ProductVariantsBulkUpdate #1226

@mtbd-ljceranic

Description

@mtbd-ljceranic

Hey there,

I am trying to do a productVariantsBulkUpdate mutation to remove a compareAtPrice (setting it to null), but it seems to be ignored. Possibly json serialization excluding any properties that are null?

Just wondering what the best way is to remove a compare at price on a variant?

var productVariantsBulkUpdateInputList = new List<ProductVariantsBulkInput>();
var productVariantsBulkUpdateInput = new ProductVariantsBulkInput
{
    id = productVariant.id,
    price = itemPrice,
    compareAtPrice = null
};
productVariantsBulkUpdateInputList.Add(productVariantsBulkUpdateInput);

var graphRequest = new GraphRequest
{
    Query = """
            mutation ($productId: ID!, $variants: [ProductVariantsBulkInput!]!){
                productVariantsBulkUpdate(
                  productId: $productId
                   variants: $variants
                ) {
                    __typename
                    product {
                        __typename
                        id
                    }
                    userErrors {
                        __typename
                        field
                        message
                        code
                    }
                }
            }
            """,
    Variables = new Dictionary<string, object>
    {
        { "productId", shopifyProduct.id },
        { "variants", productVariantsBulkUpdateInputList }
    }
};

await graphService.PostAsync<ProductVariantsBulkUpdateResult>(graphRequest);

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions