fix: simplify shipping payload, remove forced local_pick_up/free_shipping

- build_item_payload now sends only mode in shipping payload by default
- Let ML determine free_shipping/local_pick_up based on account config
- Better error message for mandatory free shipping scenario
This commit is contained in:
2026-05-26 06:13:50 +00:00
parent f742cdaa42
commit 314075021e

View File

@@ -125,7 +125,9 @@ def _extract_meli_error(err: MeliError) -> str:
if "me2 adoption is mandatory" in lowered: if "me2 adoption is mandatory" in lowered:
return msg + " | Debes activar MercadoEnvíos (ME2) en tu cuenta de MercadoLibre. Ve a Configuración > Envíos en el panel de vendedor de ML." return msg + " | Debes activar MercadoEnvíos (ME2) en tu cuenta de MercadoLibre. Ve a Configuración > Envíos en el panel de vendedor de ML."
if "user has not mode" in lowered: if "user has not mode" in lowered:
return msg + " | Tu cuenta no tiene configurado este modo de envío. Configura tus métodos de envío en MercadoLibre." return msg + " | Tu cuenta no tiene configurado este modo de envío. Ve a Configuración > Envíos en MercadoLibre y completa la configuración de MercadoEnvíos."
if "mandatory free shipping" in lowered:
return msg + " | MercadoLibre está forzando envío gratis en tu cuenta. Esto es normal si estás en el programa de envíos gratuito. El artículo se publicará con envío gratis."
return msg return msg
except Exception: except Exception:
pass pass
@@ -149,6 +151,10 @@ def build_item_payload(
if len(title) > 60: if len(title) > 60:
title = title[:57] + "..." title = title[:57] + "..."
shipping_payload = {"mode": shipping_mode}
if shipping_mode == "me2":
# Let ML determine free_shipping/local_pick_up defaults based on account config
pass
payload = { payload = {
"title": title, "title": title,
"category_id": meli_category_id, "category_id": meli_category_id,
@@ -159,7 +165,7 @@ def build_item_payload(
"listing_type_id": listing_type_id, "listing_type_id": listing_type_id,
"condition": "new", "condition": "new",
"pictures": [{"source": url} for url in images if url], "pictures": [{"source": url} for url in images if url],
"shipping": {"mode": shipping_mode, "local_pick_up": False, "free_shipping": False}, "shipping": shipping_payload,
"attributes": [], "attributes": [],
} }