return order + success page return order + ...

This commit is contained in:
hamid zarghami
2025-10-08 09:08:01 +03:30
parent 1b7e9eb168
commit 700e757128
17 changed files with 1295 additions and 24 deletions
+8 -2
View File
@@ -48,9 +48,15 @@ const CartPayment: NextPage = () => {
)
}
// محاسبه هزینه ارسال
// بارگذاری انتخاب‌های ارسال از localStorage
const savedShipments = typeof window !== 'undefined' ? localStorage.getItem('selectedShipments') : null
const selectedShipments = savedShipments ? JSON.parse(savedShipments) : {}
// محاسبه هزینه ارسال بر اساس انتخاب‌های کاربر
const totalShippingCost = shippingData?.results?.shipping?.reduce((total, shop) => {
return total + (shop.shippers?.[0]?.totalShippingCost || 0)
const selectedShipperId = selectedShipments[shop.shopId]
const selectedShipper = shop.shippers?.find(shipper => shipper.shipperId === selectedShipperId)
return total + (selectedShipper?.totalShippingCost || shop.shippers?.[0]?.totalShippingCost || 0)
}, 0) || 0
// محاسبه قیمت نهایی