Is there a way to trigger something, that would change the allow overselling status with flows

Is there a way to trigger something, that would change the allow overselling status with flows

bear42
Shopify Partner
62 0 6

Is there a way to trigger something, that would change the allow overselling status with shopify flows, on variant level?

Replies 20 (20)

paul_n
Shopify Staff
1313 148 298

I think you want to change the overselling status on a product variant? The word "trigger" is confusing because that's what starts a workflow and not what does the action. 

 

You would need to use Send HTTP Request to call the productVariantUpdate API, where you can set the inventoryPolicy field to "ALLOW" 

https://shopify.dev/docs/api/admin-graphql/2024-01/mutations/productVariantUpdate#argument-input 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
bear42
Shopify Partner
62 0 6

Yes correct, i want to change the overselling status on product variant level.

bear42
Shopify Partner
62 0 6

Is that possible to do via flows?

paul_n
Shopify Staff
1313 148 298

I gave you the answer above. Use the Send HTTP Request action to call the API directly. You'll need to create an API key for your shop. There are a bunch of threads on the community about using Send HTTP Request. 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
bear42
Shopify Partner
62 0 6

Okay pretty close: 

bear42_1-1712586404340.png

 

What to put in the body, to change the variants inventory policy to "allow overselling"

 

paul_n
Shopify Staff
1313 148 298

If you look at the CURL examples in the docs, it shows the syntax, which you can adjust. Here's an example (not tested):

 

{
"query": "mutation productVariantUpdate($input: ProductVariantInput!) { productVariantUpdate(input: $input) { productVariant { id title inventoryPolicy inventoryQuantity price compareAtPrice } userErrors { field message } } }",
 "variables": {
    "input": {
      "id": "{{ productVariant.id }}",
      "inventoryPolicy": "CONTINUE"
    }
  }
}

 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
bear42
Shopify Partner
62 0 6

Great trying it out

 

bear42
Shopify Partner
62 0 6

Getting closer, but sadly i still seem to have some issues, do you have an idea?

bear42_0-1712848874174.pngbear42_1-1712848891940.png

 

 

 

paul_n
Shopify Staff
1313 148 298

I think you need to POST not GET. 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
bear42
Shopify Partner
62 0 6

Seem to have same issue, very strange, is it correct understood that i need to use the api from a private app?

bear42_0-1712849412919.png

bear42_1-1712849597116.png

 

 

paul_n
Shopify Staff
1313 148 298

Just double-checked against one I have working. Your key-value aren't specified correctly.

 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
bear42
Shopify Partner
62 0 6

Hi again man,

Last issue 😛

Alright so i made it like you recommended, but i can still not find the problem here, as it still say some sh*t with the api is wrong.
Once again, it is correctly understood we get the api keys from the shopify private app correct?

bear42_0-1712935697028.png

bear42_1-1712935798801.png

 


Hope we can solve it like last time... 🙂

paul_n
Shopify Staff
1313 148 298

URL structure is:

https://<your-domain>.myshopify.com/admin/api/latest/graphql.json

 

I think you are missing the admin part

 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
bear42
Shopify Partner
62 0 6

Alright, so far so good, i got it working to "Continue" allow overselling.

now i we got second flow, where i have a Condition, where it needs "Confirm" if "productvariant.inventoryquantity" if equal to a metafield value.

There does not seem to be a way in flows, to select the metafield value as "inventoryquantity", do you have a liquid code for this?

Or do i need a http signal once again to get the value and use it for a condition?

paul_n
Shopify Staff
1313 148 298

There is a release coming soon that will make this better (accessing metafield values). Currently you have two ways - use the metafield in the condition and compare that to the inventory quantity. You can also use Run code to do the comparison and return true/false from that, which you can they use in a condition. 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
bear42
Shopify Partner
62 0 6

Is there any ETA on that release?

I think we will use Run code to do the comparison.
Can you help with what inputs, outputs and code i should use here, to make it check if "Variantquantity" is the same as variant metafield "smartpack.po-qty"?

bear42_0-1713169992582.png

 



paul_n
Shopify Staff
1313 148 298

This example may help (its for converting tags to metafields and returns a list of metafields to set). https://github.com/Shopify/flow-code-examples/tree/main/run-code-examples/product-tags-to-metafields

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
bear42
Shopify Partner
62 0 6

Is there an easier way than doing it this way.

How to do way no 1 then, as a condition to make sure that the value of variants metafield value is the same as the inventory qty?

No eta on the release?

paul_n
Shopify Staff
1313 148 298

ETA - very soon, but some risk it gets delayed. 

 

For option 1 you build a condition like you want to check the value of a metafield. There is a template in the library in Flow, or many threads here on how to do that. For the value field, click the <> in the field to add the inventory variable you want

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
bear42
Shopify Partner
62 0 6

Alright tried that, will test tomorrow, can you check?

bear42_0-1713380119084.png



Also we have a issue when checking for a value for a curtain meta field value, but it seems to check if just one of the variants in the order have that namespace, and another have that key, and another have a value.
What am i doing wrong?

bear42_1-1713380187127.png