CartGiỏ hàng khách hàng
Lấy báo giá gần nhất (Last quote)
Lấy lại báo giá cho giỏ hàng (hiện tại xử lý giống getQuote).
Endpoint
PUT /site/customercarts/{uuid}/getlastquote
Headers
| Key | Value | Bắt buộc | Mô tả |
|---|---|---|---|
SiteTenantId | {tenant_id} | Có | ID của công ty/tenant. |
SiteAuthorization | {jwt_token} | Không | Token khách hàng (nếu đã đăng nhập). |
Workflow & Logic
API này dùng để lấy lại báo giá (quote) cho giỏ hàng ở bước checkout. Hiện tại luồng xử lý giống getQuote: request sẽ sync thông tin checkout vào cart rồi tính lại:
- Giá bán theo chính sách giá (website/customer type).
- Phí vận chuyển (khi
shipping_type = deliveryvà đủ dữ liệu). - Khuyến mãi (bundle evaluate + cart evaluate).
- Quy đổi điểm tích lũy (loyalty redeem evaluate) nếu có
redeem_points.
Quy trình xử lý
-
Lấy & kiểm tra giỏ hàng theo
uuid- Hệ thống tìm cart theo
uuidtrong shop hiện tại (SiteTenantId). - Nếu cart đã gắn với một khách hàng, khách hàng khác đang đăng nhập không dùng được cart này. Khách chưa đăng nhập vẫn dùng được cart bằng
uuid. - Nếu không tồn tại → trả lỗi
error_cart_not_found.
- Hệ thống tìm cart theo
-
Ghi đè thông tin checkout từ request vào cart
- Ghi các field billing/shipping (
billing_full_name,shipping_address,shipping_region_id, ...). - Ghi
store_id,pickup_store_id,shipping_type,shipping_profile_rate_id. - Ghi
payment_method,coupon_code,redeem_points, thông tin hóa đơn (tax_*). - Mục tiêu là đồng bộ trạng thái checkout trước khi tính giá; chưa tạo order.
- Ghi các field billing/shipping (
-
Enrich cart data & tính tổng tiền hàng
- Chuẩn hóa item thành
details[]từdatatrong cart. - Áp dụng chính sách giá đang active (
active_price_policy_id). - Tính
price_sell,total_weight,total_item, đồng thời loại item không hợp lệ.
- Chuẩn hóa item thành
-
Tính phí vận chuyển tạm thời
- Nếu
shipping_type = deliveryvà có đủshipping_address,shipping_region_id> 0,shipping_profile_rate_id> 0: tính phí theo cấu hình vận chuyển của shop. - Gán
price_shipping,price_shipping_originaltheo rate đang chọn (shipping_profile_rate_id). - Nếu thiếu dữ liệu bắt buộc → phí ship = 0, vẫn trả quote.
- Nếu
-
Chạy promotion engine
- Bundle evaluate: áp dụng bundle + build
bundles_map. - Cart evaluate: khuyến mãi cấp cart (order/shipping/coupon) và sync
promotionengine,price_discount_*.
- Bundle evaluate: áp dụng bundle + build
-
Đánh giá loyalty (nếu có điểm redeem)
- Đánh giá số điểm
redeem_pointstheo chương trình tích điểm của shop. - Nếu approved, cập nhật
price_discount_loyaltyvà điều chỉnhprice_final.
- Đánh giá số điểm
-
Gắn thông tin quote & trả về kết quả
- Build
price_quote(payload/hash/expired) để dùng cho bước checkout. - Trả về cart đã quote (cart object + details + promotionengine + loyalty + price_quote).
- Build
Request Body
Body là JSON chứa thông tin checkout để hệ thống sync vào cart và tính quote.
{
"store_id": 1,
"pickup_store_id": 0,
"shipping_type": "delivery",
"shipping_address_id": 0,
"shipping_full_name": "Nguyễn Văn A",
"shipping_phone": "0900000000",
"shipping_email": "[email protected]",
"shipping_address": "12 Nguyễn Huệ, P. Bến Nghé",
"shipping_region_id": 1,
"shipping_sub_region_id": 0,
"shipping_sub_sub_region_id": 0,
"shipping_legacy_province_name": "",
"shipping_legacy_district_name": "",
"shipping_legacy_ward_name": "",
"shipping_profile_rate_id": 0,
"billing_full_name": "Nguyễn Văn A",
"billing_phone": "0900000000",
"billing_email": "[email protected]",
"billing_address": "12 Nguyễn Huệ, P. Bến Nghé",
"billing_region_id": 1,
"billing_sub_region_id": 0,
"billing_sub_sub_region_id": 0,
"birthday": "",
"gender": 0,
"payment_method": 0,
"note": "",
"coupon_code": "",
"tax_name": "",
"tax_address": "",
"tax_email": "",
"tax_code": "",
"tax_is_company": 0,
"redeem_points": 0,
"gift_selections": []
}Response Schema
HTTP 200 - Thành công
Giống Lấy báo giá giỏ hàng.
HTTP 422 - Lỗi dữ liệu / logic
| Mã lỗi | Mô tả |
|---|---|
error_cart_not_found | Không tìm thấy giỏ hàng theo uuid. |