Python API: REST/GRAPHQL: Variant compare_to_price not update

Hi I have this issue with a shop.

I used this approach in other shops without any problem, I can’t set and change the compare_at_price fields to run some promotion in sync with my ERP.

I used two approaches for the python API:

def SetPromoVariant(shopify, variant_id, promo, price):
    v = shopify.Variant.find(variant_id)
    v.price = promo
    v.save()
    v.compare_at_price = price
    v.save()

or

def SetPromoVariant(shopify, variant_id, promo, price):
    v = shopify.Variant.find(variant_id)
    v.price = promo
    v.compare_at_price = price
    v.save()

or

def SetPromoVariant(shopify, variant_id, promo, price):
        query = """mutation productVariantUpdate($input: ProductVariantInput!) {
  productVariantUpdate(input: $input) {
    productVariant {
      id
      title
      inventoryPolicy
      inventoryQuantity
      price
      compareAtPrice
    }
    userErrors {
      field
      message
    }
  }
}"""

    result = shopify.GraphQL().execute(
                query=query,
                variables={
                      "input": {
                        "id": f"gid://shopify/ProductVariant/{variant_id}",
                        "price": f"{promo}",
                        "compareAtPrice": f"{price}"
                      }
                    })
    print(result)

N.B. The promo is bigger than the price, and every call return a success message, but the prices on the sites still not updated.

Did someone notice the same issue?

Hey @FrancoTampieri

Are you able to capture a request ID from the response headers? It’ll help determine what we’re receiving this end / where it’s going wrong.

Sure,

that’s the grapple response:

{"data":{"productVariantUpdate":{"productVariant":{"id":"gid:\/\/shopify\/ProductVariant\/44497351147785","title":"42","inventoryPolicy":"DENY","inventoryQuantity":1,"price":"196.00","compareAtPrice":"280.00"},"userErrors":[]}},"extensions":{"cost":{"requestedQueryCost":10,"actualQueryCost":10,"throttleStatus":{"maximumAvailable":1000.0,"currentlyAvailable":990,"restoreRate":50.0}}}}

It’s looks like right. but nothing happen on the server :disappointed_face:

the prices on the sites still not updated.

Can you please DM me the site/product details?

Thank you Scott I’ll keep waiting your feedback :slightly_smiling_face:

I used the last python API ShopifyAPI 12.3.0 and the API is 2023-04 I didn’t use the 2023-07 because is not supported yet by the python API

Solved over DM. For anyone coming across this in future - the issue was caused by another app immediately overwriting the changes.