corregidos bugs de: ret, vs delivery, efectivo vs link, charsets, price query

This commit is contained in:
Lucas Tettamanti
2026-01-26 23:27:47 -03:00
parent 53293ce9b3
commit 493f26af17
13 changed files with 757 additions and 193 deletions

View File

@@ -258,16 +258,27 @@ const runStatus = llmMeta?.error ? "warn" : "ok";
...baseAddress,
phone: baseAddress.phone || phoneFromWa,
};
// Obtener shipping_method y payment_method del contexto (preferir decision que es el resultado del turn)
const shippingMethod = decision?.context_patch?.shipping_method || reducedContext?.shipping_method || null;
const paymentMethod = decision?.context_patch?.payment_method || reducedContext?.payment_method || null;
const order = await createOrder({
tenantId,
wooCustomerId: externalCustomerId,
basket: basketToUse,
address: addressWithPhone,
shippingMethod,
paymentMethod,
run_id: null,
});
actionPatch.woo_order_id = order?.id || null;
actionPatch.order_total = calcOrderTotal(order);
newTools.push({ type: "create_order", ok: true, order_id: order?.id || null });
// Notificar via SSE para actualizar la pantalla de pedidos
sseSend("order.created", {
order_id: order?.id,
chat_id,
shipping_method: shippingMethod,
});
} else if (act.type === "update_order") {
const baseAddrUpd = reducedContext?.delivery_address || reducedContext?.address || {};
const phoneFromWaUpd = from?.replace(/@.*$/, "")?.replace(/[^0-9]/g, "") || "";