Change Product Template Based On Stock Quantity

Change Product Template Based On Stock Quantity

CultPensML
Visitor
1 0 0

Hi,

 

I'm trying to create a flow which will change the product template used by a product depending on the quantity in stock of the variants. I have the trigger working correctly using the "Product Variant Quantity Changed" with "Product has out of stock variants equal to 0 - True/False" but cannot find the field in the actions which needs updating to make the change.

Reply 1 (1)

Mat_w
Shopify Staff
3 1 1

Hello! We currently don't have any Actions to update the product template directly. But you can use the SendHTTPRequest action to send a GraphQL mutation to update the product template used. In the example section of the SendHTTPRequest action docs there is a sample of how to use it to send a GraphQL request to Shopify Admin to update a product, you could follow that and instead of updating the product description like in the example you can update the `templateSuffix` property:

 

mutation {
    productUpdate(input: {id: \"{{ product.id }}\", templateSuffix: "new-product"}) {
        product {
            id
            templateSuffix
        }
    }
}

 

 

Mat_w | Flow Software Developer @ Shopify
- Finding Flow useful? [Leave us a review](https://apps.shopify.com/flow/reviews)
- Need Flow help? Check out our [help docs](https://help.shopify.com/en/manual/shopify-flow).
- Building for Flow? Check out [Flow's dev docs](https://shopify.dev/docs/apps/flow).