|
|
@@ -36,6 +36,7 @@ def initialize_cart(session, currency: str) -> dict[int, str] | NoReturn:
|
|
|
"order_id": order_id,
|
|
|
"currency": currency,
|
|
|
"subtotal": 0,
|
|
|
+ "total_weight": 0,
|
|
|
"shipping": 0,
|
|
|
"total": 0,
|
|
|
"item_amount": 0,
|
|
|
@@ -79,6 +80,7 @@ def update_cart_meta(
|
|
|
"""
|
|
|
session_meta_item_amount = 0
|
|
|
session_meta_subtotal = 0
|
|
|
+ session_meta_weight = 0
|
|
|
|
|
|
for item in session["items"].values():
|
|
|
if products is not None:
|
|
|
@@ -106,6 +108,7 @@ def update_cart_meta(
|
|
|
|
|
|
session_meta_item_amount += item_quantity
|
|
|
session_meta_subtotal += item_quantity * item["price"]
|
|
|
+ session_meta_weight += item_quantity * item["options"]["weight"]
|
|
|
|
|
|
# -- update also each item quantity and availability under session.cart.items
|
|
|
if item["options"]["product_variation_id"]:
|
|
|
@@ -120,9 +123,11 @@ def update_cart_meta(
|
|
|
# when doing POST /checkout, re-compute meta values
|
|
|
session_meta_item_amount += item["quantity"]
|
|
|
session_meta_subtotal += item["quantity"] * item["price"]
|
|
|
+ session_meta_weight += item["quantity"] * item["options"]["weight"]
|
|
|
|
|
|
session["meta"]["item_amount"] = session_meta_item_amount
|
|
|
session["meta"]["subtotal"] = session_meta_subtotal
|
|
|
+ session["meta"]["total_weight"] = session_meta_weight
|
|
|
|
|
|
# check items amount and eventually reset shipping value
|
|
|
if len(session["items"]) > 0:
|
|
|
@@ -198,6 +203,7 @@ def update_cart(
|
|
|
"product_variation_id": form.options.product_variation_id,
|
|
|
"size": form.options.size,
|
|
|
"style": form.options.style,
|
|
|
+ "weight": form.options.weight,
|
|
|
},
|
|
|
"price": form.price,
|
|
|
"quantity": 1,
|
|
|
@@ -219,6 +225,7 @@ def clear_cart(session, currency: str) -> NoReturn:
|
|
|
"order_id": order_id,
|
|
|
"currency": currency,
|
|
|
"subtotal": 0,
|
|
|
+ "total_weight": 0,
|
|
|
"shipping": 0,
|
|
|
"total": 0,
|
|
|
"item_amount": 0,
|