API Sản phẩm Ship 0đ
API này cho phép lấy danh sách sản phẩm có hỗ trợ ship 0đ (miễn phí vận chuyển) với đầy đủ thông tin chi tiết về chính sách ship.
Ví dụ minh họa: Sản phẩm có freeship
Ví dụ minh họa: Sản phẩm có freeship
GET https://api.socdo.vn/v1/products_freeship
Các tham số:
- page: Trang hiện tại (mặc định 1)
- limit: Số lượng sản phẩm mỗi trang (mặc định 20, tối đa 100)
- category_id: ID danh mục (lọc sản phẩm theo danh mục cụ thể)
- shop_id: ID shop (lọc sản phẩm theo shop cụ thể)
- sort: Sắp xếp - 'time-desc' (mới nhất), 'time-asc' (cũ nhất), 'price-asc' (giá thấp), 'price-desc' (giá cao)
- min_price: Giá tối thiểu (lọc sản phẩm từ giá này trở lên)
- max_price: Giá tối đa (lọc sản phẩm đến giá này)
Ví dụ lấy sản phẩm ship 0đ bằng cURL:
curl -X GET "https://api.socdo.vn/v1/products_freeship?page=1&limit=20&sort=time-desc" -H "Authorization: Bearer <token>"
Ví dụ lấy sản phẩm ship 0đ theo danh mục bằng cURL:
curl -X GET "https://api.socdo.vn/v1/products_freeship?category_id=5&shop_id=30&min_price=100000&max_price=5000000" -H "Authorization: Bearer <token>"
Ví dụ kết nối bằng PHP:
<?php
// Lấy sản phẩm ship 0đ với lọc
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.socdo.vn/v1/products_freeship?" . http_build_query([
"page" => 1,
"limit" => 20,
"category_id" => 5,
"sort" => "price-asc",
"min_price" => 50000,
"max_price" => 2000000
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer <token>"
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
if ($data["success"]) {
foreach ($data["data"]["products"] as $product) {
echo "Sản phẩm: " . $product["name"] . "\n";
echo "Giá: " . $product["price_formatted"] . "\n";
echo "Ship: " . $product["shipping_info"]["free_ship_details"] . "\n\n";
}
}
?>
Dữ liệu trả về mẫu:
{
"success": true,
"message": "Lấy danh sách sản phẩm ship 0đ thành công",
"data": {
"products": [
{
"id": 12345,
"name": "iPhone 15 Pro Max 256GB",
"slug": "iphone-15-pro-max-256gb",
"price": 28990000,
"old_price": 32990000,
"discount_percent": 12,
"shop_id": 30,
"category_ids": [1, 11],
"brand_id": 5,
"brand_name": "Apple",
"brand_logo": "https://api.socdo.vn/uploads/thuong-hieu/apple-logo.png",
"image": "https://api.socdo.vn/uploads/minh-hoa/iphone15-pro-max.jpg",
"thumb": "https://api.socdo.vn/uploads/thumbs/sanpham_anh_340x340/iphone15-pro-max.jpg",
"product_url": "https://api.socdo.vn/san-pham/12345/iphone-15-pro-max-256gb.html",
"shipping_info": {
"has_free_shipping": true,
"free_ship_type": "complete",
"free_ship_details": "Miễn phí ship hoàn toàn",
"min_order_for_free_ship": 0
},
"badges": [
"Giảm 12%",
"Freeship",
"Chính hãng"
],
"is_authentic": 1,
"is_featured": 1,
"is_trending": 1,
"is_flash_sale": 0,
"created_at": 1703123456,
"updated_at": 1703123456,
"price_formatted": "28.990.000 ₫",
"old_price_formatted": "32.990.000 ₫"
},
{
"id": 12346,
"name": "Samsung Galaxy S24 Ultra 512GB",
"slug": "samsung-galaxy-s24-ultra-512gb",
"price": 25990000,
"old_price": 27990000,
"discount_percent": 7,
"shop_id": 30,
"category_ids": [1, 11],
"brand_id": 8,
"brand_name": "Samsung",
"brand_logo": "https://api.socdo.vn/uploads/thuong-hieu/samsung-logo.png",
"image": "https://api.socdo.vn/uploads/minh-hoa/samsung-s24-ultra.jpg",
"thumb": "https://api.socdo.vn/uploads/thumbs/sanpham_anh_340x340/samsung-s24-ultra.jpg",
"product_url": "https://api.socdo.vn/san-pham/12346/samsung-galaxy-s24-ultra-512gb.html",
"shipping_info": {
"has_free_shipping": true,
"free_ship_type": "fixed_amount",
"free_ship_details": "Hỗ trợ ship 30.000đ",
"min_order_for_free_ship": 500000
},
"badges": [
"Giảm 7%",
"Freeship",
"Chính hãng"
],
"is_authentic": 1,
"is_featured": 1,
"is_trending": 0,
"is_flash_sale": 1,
"created_at": 1703123456,
"updated_at": 1703123456,
"price_formatted": "25.990.000 ₫",
"old_price_formatted": "27.990.000 ₫"
}
],
"pagination": {
"current_page": 1,
"total_pages": 15,
"total_records": 298,
"per_page": 20,
"has_next": true,
"has_prev": false
},
"filters": {
"category_id": 0,
"shop_id": 0,
"sort": "time-desc",
"min_price": 0,
"max_price": 0
}
}
}
Tính năng chi tiết:
- Ship 0đ thông minh: Tự động lọc sản phẩm có hỗ trợ ship miễn phí
- Nhiều loại freeship: Hoàn toàn, theo %, cố định, theo sản phẩm
- Thông tin ship chi tiết: Loại hỗ trợ, điều kiện, số tiền
- Lọc đa dạng: Theo danh mục, shop, giá, sắp xếp
- Badges thông minh: Tự động hiển thị Freeship, giảm giá, chính hãng
- URL đầy đủ: Tự động tạo URL cho sản phẩm và hình ảnh
- Phân trang: Hỗ trợ pagination với thông tin chi tiết
Các loại ship 0đ hỗ trợ:
- complete: Miễn phí ship hoàn toàn (free_ship_all = 1)
- percentage: Hỗ trợ ship theo % đơn hàng (free_ship_all = 2)
- product_specific: Hỗ trợ ship theo từng sản phẩm (free_ship_all = 3)
- fixed_amount: Hỗ trợ ship số tiền cố định (free_ship_discount > 0)
Các bảng database liên quan:
- sanpham: Bảng chính chứa thông tin sản phẩm
- transport: Cấu hình ship và chính sách freeship
- thuong_hieu: Thông tin thương hiệu sản phẩm
- category_sanpham: Thông tin danh mục sản phẩm
Logic ship 0đ:
- Điều kiện chính: transport.free_ship_all = 1 HOẶC transport.free_ship_discount > 0
- free_ship_all = 1: Miễn phí ship hoàn toàn cho tất cả sản phẩm
- free_ship_all = 2: Hỗ trợ ship theo % của tổng đơn hàng
- free_ship_all = 3: Hỗ trợ ship riêng cho từng sản phẩm
- free_ship_discount > 0: Hỗ trợ ship số tiền cố định
- free_ship_min_order: Đơn tối thiểu để được ship 0đ
Tham số lọc sản phẩm:
- category_id: Lọc theo danh mục sản phẩm cụ thể
- shop_id: Lọc theo shop cụ thể
- sort: Sắp xếp theo thời gian hoặc giá
- min_price/max_price: Lọc theo khoảng giá
- page/limit: Phân trang kết quả
Thông tin shipping_info:
- has_free_shipping: Luôn true (vì API chỉ lấy sản phẩm có ship 0đ)
- free_ship_type: Loại hỗ trợ ship (complete/percentage/product_specific/fixed_amount)
- free_ship_details: Mô tả chi tiết chính sách ship
- min_order_for_free_ship: Đơn tối thiểu để được ship 0đ
Lưu ý:
- Bạn cần lấy token xác thực trước khi gọi API này
- API chỉ trả về sản phẩm có hỗ trợ ship 0đ (đã được lọc sẵn)
- Thông tin ship được lấy từ bảng transport của shop
- Hỗ trợ phân trang với limit tối đa 100 sản phẩm/page
- URL sản phẩm và hình ảnh được tạo tự động
- Badges hiển thị các tính năng đặc biệt (freeship, giảm giá, chính hãng)
- Có thể lọc theo nhiều tiêu chí khác nhau