---
title: "WooCommerce Connector"
description: "คู่มือการผสานรวม WooCommerce ฉบับสมบูรณ์สำหรับการซิงค์ลูกค้า คำสั่งซื้อ สินค้า และเหตุการณ์ cart กับ Brevo ผ่าน Tajo"
url: https://tajo.io/th/docs/connectors/ecommerce/woocommerce/
markdown: https://tajo.io/th/docs/connectors/ecommerce/woocommerce.md
lang: th-TH
robots: noindex
---

ขอสิทธิ์ใช้งานล่วงหน้า

กรอกชื่อและที่อยู่อีเมลที่ทำงานของคุณ เราจะส่งลิงก์เพื่อยืนยันคำขอเข้าใช้งาน Tajo ทางอีเมล

# WooCommerce Connector

สถานะตัวเชื่อม: กำลังพัฒนา กำลังสร้าง ยังไม่ได้รับการยืนยัน

| ฟิลด์ต้นทาง | ฟิลด์ปลายทาง | ค่าตัวอย่าง |
| --- | --- | --- |
| `record.id` | `source_id` | `record_1042` |
| `record.updated_at` | `updated_at` | `2026-10-18T08:00:00Z` |
| `record.value` | `value` | `sample_value` |

เชื่อมต่อร้านค้า WooCommerce ของคุณกับ Brevo ผ่าน Tajo เพื่อการซิงค์ข้อมูล e-commerce ที่สมบูรณ์ ใช้ WooCommerce REST API เพื่อซิงค์ลูกค้า คำสั่งซื้อ สินค้า และข้อมูลคูปองสำหรับแคมเปญการตลาดที่กำหนดเป้าหมายและเวิร์กโฟลว์อัตโนมัติ

## ภาพรวม

| คุณสมบัติ | ค่า |
| --- | --- |
| **แพลตฟอร์ม** | WooCommerce (WordPress) |
| **หมวดหมู่** | E-commerce |
| **ความซับซ้อนในการตั้งค่า** | ปานกลาง |
| **การผสานรวมอย่างเป็นทางการ** | ไม่ |
| **ข้อมูลที่ซิงค์** | ลูกค้า คำสั่งซื้อ สินค้า คูปอง |
| **ทักษะที่ใช้ได้** | 10 |

## ฟีเจอร์

- **การซิงค์ลูกค้า** - การซิงค์ข้อมูลลูกค้าแบบเรียลไทม์กับผู้ติดต่อ Brevo
- **การติดตามคำสั่งซื้อ** - การติดตามเหตุการณ์ order lifecycle ที่สมบูรณ์สำหรับเวิร์กโฟลว์หลังการซื้อ
- **การซิงค์แคตาล็อกสินค้า** - ซิงค์สินค้าและ variations สำหรับคำแนะนำในอีเมล
- **การจัดการคูปอง** - ซิงค์รหัสคูปองสำหรับแคมเปญโปรโมชัน
- **รองรับ webhook** - การอัปเดตแบบเรียลไทม์ผ่าน WooCommerce webhooks
- **การละทิ้ง cart** - ติดตามและกู้คืน carts ที่ถูกละทิ้ง
- **รองรับหลาย site** - เชื่อมต่อการติดตั้ง WordPress multisite WooCommerce
- **Custom meta fields** - แมป WooCommerce custom meta กับแอตทริบิวต์ Brevo

## ข้อกำหนดเบื้องต้น

ก่อนเริ่มต้น ตรวจสอบให้แน่ใจว่าคุณมี:

1. WordPress site ที่ติดตั้งและเปิดใช้งาน WooCommerce plugin
2. WooCommerce REST API ที่เปิดใช้งาน (Settings > Advanced > REST API)
3. API Consumer Key และ Consumer Secret ที่สร้างแล้ว
4. Site ของคุณต้องใช้ HTTPS สำหรับการยืนยันตัวตน API
5. บัญชี Brevo ที่มีสิทธิ์เข้าถึง API
6. บัญชี Tajo ที่มีข้อมูลประจำตัว API

## การยืนยันตัวตน

### REST API Keys

WooCommerce ใช้คู่ Consumer Key และ Consumer Secret สำหรับการยืนยันตัวตน สร้างได้ที่ WooCommerce > Settings > Advanced > REST API

#### OAuth 1.0a (HTTPS sites)

```bash
curl https://yourstore.com/wp-json/wc/v3/orders \
  -u "consumer_key:consumer_secret"
```

#### Query String Authentication (HTTPS)

```bash
curl "https://yourstore.com/wp-json/wc/v3/orders?consumer_key=ck_xxx&consumer_secret=cs_xxx"
```

### ระดับสิทธิ์

| สิทธิ์ | การเข้าถึง |
| --- | --- |
| **Read** | ดูทรัพยากรเท่านั้น |
| **Write** | สร้างและแก้ไขทรัพยากร |
| **Read/Write** | สิทธิ์ CRUD เต็มรูปแบบ |

## การกำหนดค่า

### การตั้งค่าพื้นฐาน

```yaml
connectors:
  woocommerce:
    enabled: true
    store_url: "https://yourstore.com"
    consumer_key: "ck_your_consumer_key"
    consumer_secret: "cs_your_consumer_secret"
    api_version: "wc/v3"
    verify_ssl: true

    # Data sync options
    sync:
      customers: true
      orders: true
      products: true
      coupons: true

    # Brevo list assignment
    lists:
      all_customers: 50
      buyers: 51
      abandoned_cart: 52
```

### การแมปฟิลด์ลูกค้า

แมปฟิลด์ลูกค้า WooCommerce กับแอตทริบิวต์ Brevo:

```yaml
customer_mapping:
  email: email
  first_name: FIRSTNAME
  last_name: LASTNAME
  billing.phone: SMS
  billing.company: COMPANY
  billing.city: CITY
  billing.state: STATE
  billing.country: COUNTRY
  billing.postcode: ZIP

  # E-commerce metrics (computed)
  orders_count: ORDER_COUNT
  total_spent: TOTAL_SPENT
  date_created: SIGNUP_DATE

  # Meta fields
  meta_data.loyalty_points: LOYALTY_POINTS
  meta_data.preferred_category: PREF_CATEGORY
```

### การกำหนดค่า Webhook

ลงทะเบียน webhooks ใน WooCommerce > Settings > Advanced > Webhooks:

```yaml
webhooks:
  - topic: "customer.created"
    event: "customer_created"
  - topic: "customer.updated"
    event: "customer_updated"
  - topic: "order.created"
    event: "order_placed"
  - topic: "order.updated"
    event: "order_updated"
  - topic: "order.completed"
    event: "order_fulfilled"
  - topic: "order.refunded"
    event: "order_refunded"
  - topic: "coupon.created"
    event: "coupon_created"
  - topic: "product.created"
    event: "product_added"
  - topic: "product.updated"
    event: "product_updated"
```

## API Endpoints

| เมธอด | Endpoint | คำอธิบาย |
| --- | --- | --- |
| `GET` | `/wc/v3/customers` | แสดงรายการลูกค้า |
| `POST` | `/wc/v3/customers` | สร้างลูกค้า |
| `GET` | `/wc/v3/customers/{id}` | ดูลูกค้า |
| `PUT` | `/wc/v3/customers/{id}` | อัปเดตลูกค้า |
| `GET` | `/wc/v3/orders` | แสดงรายการคำสั่งซื้อ |
| `POST` | `/wc/v3/orders` | สร้างคำสั่งซื้อ |
| `GET` | `/wc/v3/orders/{id}` | ดูคำสั่งซื้อ |
| `GET` | `/wc/v3/products` | แสดงรายการสินค้า |
| `GET` | `/wc/v3/products/{id}` | ดูสินค้า |
| `GET` | `/wc/v3/products/{id}/variations` | แสดงรายการ product variations |
| `GET` | `/wc/v3/coupons` | แสดงรายการคูปอง |
| `GET` | `/wc/v3/reports/sales` | ดูรายงานยอดขาย |
| `GET` | `/wc/v3/reports/top_sellers` | ดูสินค้าขายดี |
| `POST` | `/wc/v3/webhooks` | สร้าง webhook |

## ตัวอย่างโค้ด

### เริ่มต้น WooCommerce Connector

```javascript
import { TajoClient } from '@tajo/sdk';

const tajo = new TajoClient({
  apiKey: process.env.TAJO_API_KEY,
  brevoApiKey: process.env.BREVO_API_KEY
});

// Connect WooCommerce store
await tajo.connectors.connect('woocommerce', {
  storeUrl: 'https://yourstore.com',
  consumerKey: process.env.WC_CONSUMER_KEY,
  consumerSecret: process.env.WC_CONSUMER_SECRET
});
```

### ดึงและซิงค์ลูกค้า

```javascript
// Fetch customers using WooCommerce REST API
const WooCommerce = require('@woocommerce/woocommerce-rest-api').default;

const api = new WooCommerce({
  url: 'https://yourstore.com',
  consumerKey: process.env.WC_CONSUMER_KEY,
  consumerSecret: process.env.WC_CONSUMER_SECRET,
  version: 'wc/v3'
});

// List customers with pagination
const response = await api.get('customers', {
  per_page: 100,
  page: 1,
  orderby: 'registered_date',
  order: 'desc'
});

const customers = response.data;
// [{ id, email, first_name, last_name, billing, shipping, ... }]

// Pagination info from headers
const totalPages = response.headers['x-wp-totalpages'];
const totalItems = response.headers['x-wp-total'];
```

### จัดการเหตุการณ์ Webhook

```javascript
// WooCommerce webhook handler
app.post('/webhooks/woocommerce', async (req, res) => {
  const topic = req.headers['x-wc-webhook-topic'];
  const signature = req.headers['x-wc-webhook-signature'];

  // Verify webhook signature
  const expectedSignature = crypto
    .createHmac('sha256', WEBHOOK_SECRET)
    .update(JSON.stringify(req.body))
    .digest('base64');

  if (signature !== expectedSignature) {
    return res.status(401).send('Invalid signature');
  }

  // Forward to Tajo
  await tajo.connectors.handleWebhook('woocommerce', {
    topic,
    payload: req.body
  });

  res.status(200).send('OK');
});
```

### การดำเนินการ Batch

```javascript
// Batch create, update, and delete products
const batchResponse = await api.post('products/batch', {
  create: [
    { name: 'New Product', type: 'simple', regular_price: '19.99' }
  ],
  update: [
    { id: 123, regular_price: '24.99' }
  ],
  delete: [456]
});
```

## ขีดจำกัดอัตรา

WooCommerce เองไม่บังคับใช้ rate limits ของ API แต่เซิร์ฟเวอร์ WordPress และผู้ให้บริการ hosting อาจกำหนดขีดจำกัด:

| ปัจจัย | ขีดจำกัดทั่วไป | รายละเอียด |
| --- | --- | --- |
| **Shared hosting** | 50-100 คำขอ/นาที | แตกต่างตาม host |
| **Managed WP hosting** | 200-500 คำขอ/นาที | WP Engine, Kinsta ฯลฯ |
| **Self-hosted** | ไม่มีขีดจำกัดที่แน่ชัด | จำกัดโดยทรัพยากรเซิร์ฟเวอร์ |
| **ต่อหน้า** | สูงสุด 100 records | ค่าเริ่มต้นคือ 10 |
| **Batch operations** | 100 รายการ/batch | สร้าง อัปเดต หรือลบ |

ประสิทธิภาพเซิร์ฟเวอร์

ร้านค้า WooCommerce ขนาดใหญ่อาจมีการตอบสนอง API ที่ช้า ใช้ pagination จำกัดฟิลด์ด้วยพารามิเตอร์ `_fields` และกำหนดเวลา bulk syncs ในช่วง off-peak

## การแก้ไขปัญหา

| ปัญหา | สาเหตุ | วิธีแก้ |
| --- | --- | --- |
| `401 Unauthorized` | API keys ไม่ถูกต้อง | สร้าง Consumer Key/Secret ใหม่ในการตั้งค่า WooCommerce |
| `403 Forbidden` | สิทธิ์ไม่เพียงพอ | ตั้งค่า API key เป็น Read/Write access |
| ข้อผิดพลาด SSL certificate | SSL ไม่ถูกต้องบน site | ตรวจสอบ SSL certificate ที่ถูกต้อง ตั้งค่า `verify_ssl: false` สำหรับการทดสอบเท่านั้น |
| Webhooks ไม่ทำงาน | WordPress cron ถูกปิดใช้งาน | เปิดใช้งาน WP-Cron หรือกำหนดค่า server-level cron |
| การตอบสนอง API ช้า | ฐานข้อมูลขนาดใหญ่ | ปรับแต่ง WordPress database ใช้พารามิเตอร์ `_fields` |
| Custom fields หายไป | Meta data ไม่ถูกเปิดเผย | ใช้ฟิลด์ `meta_data` เพื่อเข้าถึง custom meta |
| ปัญหา pagination | ขนาดหน้าเริ่มต้น | ตั้งค่าพารามิเตอร์ `per_page` อย่างชัดเจน (สูงสุด 100) |

## แนวทางปฏิบัติที่ดีที่สุด

1. **ใช้ webhooks สำหรับ real-time sync** - กำหนดค่า WooCommerce webhooks แทนการ polling API
2. **ตรวจสอบลายเซ็น webhook** - ตรวจสอบ header `X-WC-Webhook-Signature` เสมอ
3. **แบ่งหน้าคำขอ list ทั้งหมด** - ใช้พารามิเตอร์ `page` และ `per_page` ตรวจสอบ header `X-WP-TotalPages`
4. **ใช้พารามิเตอร์ `_fields`** - ขอเฉพาะฟิลด์ที่จำเป็นเพื่อลดขนาดการตอบสนองและปรับปรุงประสิทธิภาพ
5. **Batch operations** - ใช้ batch endpoints สำหรับการดำเนินการ bulk create/update/delete (สูงสุด 100 รายการ)
6. **กำหนดเวลา large syncs** - รัน full syncs เริ่มต้นในช่วง off-peak เพื่อหลีกเลี่ยงความกดดันบนเซิร์ฟเวอร์
7. **เปิดใช้งาน HTTPS** - WooCommerce API ต้องการการเข้ารหัส TLS สำหรับการยืนยันตัวตน OAuth

## ความปลอดภัย

- **OAuth 1.0a** - การยืนยันตัวตนที่ปลอดภัยผ่านคู่ Consumer Key/Secret
- **HMAC webhook signatures** - การตรวจสอบลายเซ็น SHA-256 สำหรับ incoming webhooks
- **HTTPS จำเป็น** - API ต้องการการเข้ารหัส TLS สำหรับการยืนยันตัวตน
- **Permission scoping** - API keys สามารถตั้งค่าเป็น Read, Write หรือ Read/Write
- **ความปลอดภัย WordPress** - ได้รับประโยชน์จากการอัปเดตความปลอดภัย WordPress core
- **ข้อพิจารณา PCI** - ข้อมูลการชำระเงินจัดการโดย WooCommerce payment gateways ไม่เปิดเผยผ่าน API

## แหล่งข้อมูลที่เกี่ยวข้อง

- [Shopify Connector](https://tajo.io/th/docs/connectors/ecommerce/shopify)
- [BigCommerce Connector](https://tajo.io/th/docs/connectors/ecommerce/bigcommerce)
- [Customer Sync Skill](https://tajo.io/th/docs/skills/data-sync/customer-sync)
- [Abandoned Cart Skill](https://tajo.io/th/docs/skills/email-marketing/abandoned-cart)
