A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello, I am trying to add a range weight conditions on a delivery profile, that's the code:
query = """ mutation deliveryProfileUpdate($id: ID!, $profile: DeliveryProfileInput!) { deliveryProfileUpdate(id: $id, profile: $profile) { profile { id } userErrors { field message } } } """ variables = { "id":"gid://shopify/DeliveryProfile/{}".format(did), "profile":{ "locationGroupsToCreate": { "locations": "gid://shopify/Location/{}".format(location_id), "zonesToCreate": { "name": name, "countries": countries, "methodDefinitionsToCreate": [ { "name": "Spedizione standard", "active": True, # Set the rate definition for the delivery zone. #"rateDefinition": { # "price": { # "amount": 0, "currencyCode": "EUR" # }, #}, "rateDefinition": { "price": { "amount": 10.0, "currencyCode": "EUR" } }, "weightConditionsToCreate": { "criteria": { "unit": "KILOGRAMS", "value": weight, }, "operator": "GREATER_THAN_OR_EQUAL_TO" } } for weight in weights ] + [ { "name": "Spedizione standard", "active": True, # Set the rate definition for the delivery zone. #"rateDefinition": { # "price": { # "amount": 0, "currencyCode": "EUR" # }, #}, "rateDefinition": { "price": { "amount": 10.0, "currencyCode": "EUR" } }, "weightConditionsToCreate": { "criteria": { "unit": "KILOGRAMS", "value": weight, }, "operator": "LESS_THAN_OR_EQUAL_TO" } } for weight in weights ] } } } } result = shopify.GraphQL().execute(query, variables=variables)
How to properly set the range, like the code above it doesn't work I have to fille the minumum weight and maximum weight, how to achieve that?
Solved! Go to the solution
This is an accepted solution.
I have solved, for someone who is interested to create a range weight, you need to add a list of
wieghtConditionsToCreate:
"weightConditionsToCreate": [ {
"criteria": {
"unit": "KILOGRAMS",
"value": weight_and_price["weights"]["min"],
},
"operator": "GREATER_THAN_OR_EQUAL_TO"
},
{
"criteria": {
"unit": "KILOGRAMS",
"value": weight_and_price["weights"]["max"],
},
"operator": "LESS_THAN_OR_EQUAL_TO"
}
]
This is an accepted solution.
I have solved, for someone who is interested to create a range weight, you need to add a list of
wieghtConditionsToCreate:
"weightConditionsToCreate": [ {
"criteria": {
"unit": "KILOGRAMS",
"value": weight_and_price["weights"]["min"],
},
"operator": "GREATER_THAN_OR_EQUAL_TO"
},
{
"criteria": {
"unit": "KILOGRAMS",
"value": weight_and_price["weights"]["max"],
},
"operator": "LESS_THAN_OR_EQUAL_TO"
}
]