Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

91
Visualizações
How to set a policy/flag to stop a product from selling when out of stock

I'm really new to the Shopify API, and I'm working with someone else's code. I'm uploading a product trough my Shopify store, but I want to set some sort of policy where a product can't be sold when it's out of stock, is there a way this can be done on code?

Every time I create a product on Shopify, I do it like this:

static async createProductInShopify(product) {
    const createProductsURL = SHOPIFY_URL + '/products.json';
    const latestPrice = product.prices[product.prices.length - 1];

    const requestBody = {
        product: {
            title: product.name,
            body_html: product.body,
            vendor: 'My Store',
            product_type: 'Sample Product',
            handle: product.handle,
            tags: product.categories,
            images: [
                {
                    src: product.imageURL
                }
            ],
            variants: [
                {
                    option1: product.size ? 'Big' : 'Normal',
                    price: latestPrice,
                    requires_shipping: true,
                    taxable: false,
                    inventory_quantity: product.quantity,
                    inventory_management: 'shopify',
                    inventory_policy: 'continue'
                }
            ]
        }
    };

    const response = await ShopifyController.fetch(createProductsURL, requestBody, 'POST', product);

    const shopifyJSON = await response.json();
    product.productID = `${shopifyJSON.product.id}`;
    product.productVariantID = `${shopifyJSON.product.variants[0].id}`;
    product.inventoryLevelID = `${shopifyJSON.product.variants[0].inventory_item_id}`;
    await product.save();
    return product;
}

I assume that the inventory_policy is where that flag can be set, however, I need some confirmation to see if that is true.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

yes, the inventory_policy for product variant has to be set to something. i am sharing the screenshot for the value.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda