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

62
Visualizações
The given data was invalid "Requested quantity is not available.", NextJS and Commerce JS

Hi guys i'm creating an e-commerce with CommerceJs and NextJS when handling payment i get this error

message: "The given data was invalid." type: "unprocessable_entity" line_items.item_7RyWOwmK5nEa2V.quantity: ["Requested quantity is not available."]

i tried to change my code like the docs but no luck

const orderData = {
    line_items: {
      item_7RyWOwmK5nEa2V: {
        quantity: 1,
      }
    },
    customer: {
      firstname: 'John',
      lastname: 'Doe',
      email: 'john.doe@example.com'
    },
    shipping: {
      name: 'John Doe',
      street: '123 Fake St',
      town_city: 'San Francisco',
      county_state: 'US-CA',
      postal_zip_code: '94103',
      country: 'US'
    },
    fulfillment: {
      shipping_method: 'ship_7RyWOwmK5nEa2V'
    },
    billing: {
      name: 'John Doe',
      street: '234 Fake St',
      town_city: 'San Francisco',
      county_state: 'US-CA',
      postal_zip_code: '94103',
      country: 'US'
    },
    payment: {
      gateway: 'stripe',
      stripe: {
        payment_method_id: paymentMethod.id,
      },
    }
  }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You must go into your commerce.js dashboard and edit the available quantity of your product there. You will see it under dashboard > products > productName > inventoryAvailable. Be sure to also check if you have variants, that the selected variant has an available inventory to draw from as well...

You can use this code to test if your product inventory is available...

commerce.checkout.checkQuantity("your-checkout-token", 'item-id', {
    amount: 1,
    variant_id: 'your-variant-id-OPTIONAL'
}).then((response) => console.log(response.available));
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