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

206
Visualizações
Pushing Woocommerce orders to Google Sheets

I have setup a woocommerce website, used for delivery of meals from different restaurants in my area. I have tried to setup an automatic transfer of the order data from the json file straight to a Google sheet our drivers use, but I have found myself encountering errors in Google Script everytime woo's webhook fires, and not being able to detect the issue.

Here is my google script code

//this is a function that fires when the webapp receives a GET request
function doGet(e) {
  return HtmlService.createHtmlOutput("request received");
}

//this is a function that fires when the webapp receives a POST request
function doPost(e) {
  var myData = JSON.parse([e.postData.contents]);
  var order_number = myData.number;
  var order_address = myData.billing.address_1;
  var item = ""
  var url = "https://fivestars-delivery.com/mon-compte//driver-dashboard/?orderid=" + order_number;

  for (var i = 0; i < myData.line_items.length(); ++i) {
    item += myData.line_items[i].product_id + "\n"
    total += parseInt(myData.line_items[i].total)
  }

  var fees = ""
  // var feesTotal = 0

  for (var i = 0; i < myData.fee_lines.length(); ++i) {
    // convertir en entier
    // feesTotal += parseInt(myData.fee_lines[i].total)
    fees += myData.fee_lines[i].amount + " " + myData.fee_lines[i].name + " - " + myData.fee_lines[i].total + "\n"
  }

  var discount = myData.discount_total
  // nom client
  var nomClient = myData.first_name + " " + myData.last_name
  var order_total = myData.total;
  var payment_method = myData.payment_method_title;
  var phone = myData.billing.phone

  var note = myData.billing.address_2 + "\n" + myData.customer_note

  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.appendRow([order_number, " ", " ", " ",order_address, " ", "Attente d'envoi",url, order_total, payment_method, nomClient, phone, note, item + fees + discount, ]);
}

-I set up a WooCommerce API and webhook using the api's secret key

-Entered my web application's URL as delivery URL in the webhook

I cannot find out what is wrong and none of the situations I found online have found no help so far.

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

0

The variable total is never created, but it is used within the for loop.

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