Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

208
Vistas
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 Respuestas
Responde la pregunta

0

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

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda