corregidos bugs de: ret, vs delivery, efectivo vs link, charsets, price query
This commit is contained in:
@@ -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, "") || "";
|
||||
|
||||
Reference in New Issue
Block a user