very confusing lol
This commit is contained in:
1 parent
16d0cd85c2
commit
da382942d3
1 file changed
+11
-10
+11
-10
@@ -234,13 +234,15 @@ async def update_itm(item_id: str, lego_set: dict, item_data: dict = None):
|
|||||||
# Convert price to cents for Square API
|
# Convert price to cents for Square API
|
||||||
price_in_cents = int(set_adjustedprice * 100)
|
price_in_cents = int(set_adjustedprice * 100)
|
||||||
|
|
||||||
# Get current item to retrieve variation ID (only if not provided)
|
# ALWAYS fetch fresh item data right before update to get latest version
|
||||||
if item_data is None:
|
# The item_data parameter is just used to avoid lookup during enrichment check,
|
||||||
item = await get_item_by_id(item_id)
|
# but we need fresh data for the update to avoid version conflicts
|
||||||
else:
|
print(
|
||||||
item = item_data
|
f"[@DEBUG] Fetching fresh item data before update to get current version..."
|
||||||
|
)
|
||||||
|
fresh_item = await get_item_by_id(item_id)
|
||||||
|
|
||||||
variations = item.get("variations", [])
|
variations = fresh_item.get("variations", [])
|
||||||
|
|
||||||
if not variations:
|
if not variations:
|
||||||
print(
|
print(
|
||||||
@@ -253,11 +255,10 @@ async def update_itm(item_id: str, lego_set: dict, item_data: dict = None):
|
|||||||
variation_version = variations[0].get("version")
|
variation_version = variations[0].get("version")
|
||||||
|
|
||||||
# Get current version for version control
|
# Get current version for version control
|
||||||
current_version = item.get("version")
|
current_version = fresh_item.get("version")
|
||||||
|
|
||||||
print(f"[@DEBUG] Item version: {current_version}")
|
print(f"[@DEBUG] Fresh item version: {current_version}")
|
||||||
print(f"[@DEBUG] Variation version: {variation_version}")
|
print(f"[@DEBUG] Fresh variation version: {variation_version}")
|
||||||
print(f"[@DEBUG] Full item data: {json.dumps(item, indent=2)}")
|
|
||||||
|
|
||||||
# Build upsert body
|
# Build upsert body
|
||||||
upsert_body = {
|
upsert_body = {
|
||||||
|
|||||||
Reference in new issue
Block a user