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

KeyValueBắt buộcMô tả
SiteTenantId{tenant_id}CóID của công ty/tenant.
SiteAuthorization{jwt_token}KhôngToken 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 = delivery và đủ 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ý

  1. Lấy & kiểm tra giỏ hàng theo uuid

    • Hệ thống tìm cart theo uuid trong 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.
  2. 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.
  3. Enrich cart data & tính tổng tiền hàng

    • Chuẩn hóa item thành details[] từ data trong 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ệ.
  4. Tính phí vận chuyển tạm thời

    • Nếu shipping_type = delivery và 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_original theo 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.
  5. 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_*.
  6. Đánh giá loyalty (nếu có điểm redeem)

    • Đánh giá số điểm redeem_points theo chương trình tích điểm của shop.
    • Nếu approved, cập nhật price_discount_loyalty và điều chỉnh price_final.
  7. 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).

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ỗiMô tả
error_cart_not_foundKhông tìm thấy giỏ hàng theo uuid.

On this page