Mục đích:

Woocommerce Rest API cung cấp khả năng tương tác với các bên thứ 3 để quản lý gian hàng Woocommerce như quản lý đơn hàng, tạo/sửa/xóa sản phẩm cũng như biến thể sản phẩm từ nền tảng của bên thứ 3.

Mô tả:

Woocommerce cho phép truy cập hệ thống từ bên ngoài thông qua username & endpoints (cấu hình trong settings)

Chú ý: Username & password chỉ hiển thị một lần => cần ghi lại để sử dụng.

Các đường dẫn để truy cập (endpoints):

+ Lấy list all orders: https://yourcompany.com/wp-json/wc/v3/orders/

+ GET request to view a single order: https://yourcompany.com/wp-json/wc/v3/orders/{insert order ID}

+ List all products (variable products): domain/wp-json/wc/v3/products

Chú ý: để bảo vệ hệ thống, 1 request chỉ lấy được tối đa 100 records

. Endpoint để giới hạn số bản ghi/request như sau:

https://yourcompany.com/wp-json/wc/v3/products?type=variable&per_page=50  (Lấy 50 records/page, loại variable product)

. Thông tin về tổng số bản ghi có trong header của request: X-WP-Total: Total returned records & X-WP-TotalPages: Total returned pages

+ To view a single product: https://yourcompany.com/wp-json/wc/v3/products/{insert product ID}

+ To view a single product variation: https://yourcompany.com/wp-json/wc/v3/products/{insert product ID}/variations/{insert variation ID}

+ To view all customers: https://yourcompany.com/wp-json/wc/v3/customers/

+ To view a single customer: https://yourcompany.com/wp-json/wc/v3/customers/{insert customer ID}

Ứng dụng Woocommerce Rest API vào xử lý dữ liệu & tự động hóa:

1. Lấy database sản phẩm (variable) và các biến thể

2. Quản trị tồn kho tự động & In hóa đơn đơn hàng tự động

3. Quản trị CRM & thực hiện remarketing khách hàng đã mua

4. Cung cấp dữ liệu cho các kênh quảng cáo (Google Shopping ads/Google merchant)

Test Rest API: 

Reqbin: https://reqbin.com/

Leave a Reply

Your email address will not be published. Required fields are marked *