Chuyển đến nội dung
Skillpedia
API và máy chủ (backend)48k · #6193

woo-guard

Skill này làm gì

Agent này kiểm tra xem mã cho cửa hàng trực tuyến xây dựng bằng WooCommerce có an toàn và cập nhật không. Nó đảm bảo mã hoạt động đúng với các phiên bản WooCommerce mới nhất, đặc biệt về thanh toán, vận chuyển và cách xử lý đơn hàng.

Khi nào nên dùng

  • ✓Khi rà soát mã mới hoặc đã thay đổi cho một cửa hàng WooCommerce.
  • ✓Trước khi ra mắt một tính năng hoặc bản cập nhật mới cho cửa hàng WooCommerce.
  • ✓Khi mã tương tác với hệ thống đơn hàng, thanh toán hoặc thanh toán đơn hàng (checkout).

Liên kết skill

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/woo-guard/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/woo-guard/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Rà soát mã này để đảm bảo nó tương thích với các phiên bản WooCommerce mới nhất và tuân theo các thực hành bảo mật tốt nhất.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent phân tích mã để đảm bảo nó dùng đúng hàm để truy cập và lưu dữ liệu đơn hàng và sản phẩm, và việc kiểm tra thanh toán và checkout được thực hiện ở phía máy chủ.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Woo Guard

You are reviewing generated or changed WooCommerce code before it ships. Apply the rules below as a guard pass after the first implementation pass. WooCommerce is a moving platform — order storage changed engines, checkout changed frameworks — and code written from memory targets the WooCommerce of three years ago. With money on the line, "works on my demo store" is not a standard.

These rules exist because AI agents produce WooCommerce code with systematic failures: order meta read through get_post_meta() (broken on HPOS stores), products updated by direct meta writes that skip lookup tables and hooks, checkout validated only in JavaScript, prices computed in floats, and woocommerce_* hooks registered before confirming WooCommerce is active.

When to Use

Use this skill when reviewing generated or changed WooCommerce code — extensions, payment and shipping integrations, checkout customizations, and order/product logic — before it ships. Activate it reactively after an agent writes or modifies WooCommerce hooks, HPOS logic, or checkout flows.

How to use this skill

Guard-pass mode (recommended): after WooCommerce code has been generated or edited, apply the rules to the diff or target files, then run the self-check before delivery.

Live mode (explicit): when the user invokes this skill before writing WooCommerce code, apply the same rules while writing, then run the self-check before delivery.

Review mode (the user asks you to review or audit WooCommerce code): walk references/review-checklist.md and produce a structured findings report. Do not edit code in review mode unless asked.

Security floor — these hold in all WooCommerce code, at maximum severity, because money is on the line:

  • Escape all output with the context-correct esc_* function.
  • wp_unslash() then sanitize all request data before it touches logic.
  • Capability check plus nonce on every state change.
  • $wpdb->prepare() for every query containing a variable.

If wp-guard is installed, run it alongside for the full WordPress layer.

Adapt to the project first

  1. Read the project's agent instructions and the extension's declared WooCommerce version range. Project conventions win on conflict.
  2. Determine the order storage mode this code must support: HPOS, legacy posts, or both (the default assumption is both).
  3. Determine the checkout in play: Blocks/Store API, legacy shortcode checkout, or both. Hooks for one do not fire in the other.
  4. Check whether WooCommerce activity is guarded: feature checks or class_exists( 'WooCommerce' ) before any wc_* call or woocommerce_* hook.

The Rules

Order and product data — must fix

  1. Orders are not posts. Access orders only through the CRUD API: wc_get_order(), wc_get_orders(), $order->get_meta(), $order->update_meta_data() + $order->save(). Forbidden on order data: get_post_meta(), update_post_meta(), WP_Query/get_posts() with post_type => shop_order, and direct $wpdb joins on postmeta. These work on legacy stores and silently break on HPOS stores. Details: references/hpos-and-crud.md.

  2. CRUD objects, getters/setters, then save. Products, customers, and coupons go through their CRUD objects (wc_get_product(), setters, ->save()). Direct meta writes skip lookup-table sync, skip the hooks other extensions rely on, and skip cache invalidation. Stock changes go through wc_update_product_stock() semantics; order state changes through $order->update_status() — which fire the emails and hooks the store expects.

  3. Declare feature compatibility. Any extension touching orders declares HPOS compatibility (FeaturesUtil::declare_compatibility( 'custom_order_tables', … )); any extension touching checkout declares cart_checkout_blocks compatibility (or incompatibility, honestly). A missing declaration shows every store owner a warning banner with your plugin's name on it.

Checkout and money — must fix

  1. Checkout validation is server-side. Validate at woocommerce_checkout_process (legacy) or through Store API extension schemas (Blocks). JavaScript validation is UX, never security. Know which checkout the store runs and wire both when the extension claims general compatibility.

…

Câu hỏi thường gặp

Vì sao tôi không nên dùng `get_post_meta()` để truy cập dữ liệu đơn hàng?

Trong các phiên bản WooCommerce mới hơn (HPOS), đơn hàng không còn được lưu như bài viết thông thường. Dùng `get_post_meta()` có thể khiến mã ngừng hoạt động đúng trên các cửa hàng đó.

‘Validate checkout server-side’ nghĩa là gì?

Nghĩa là các kiểm tra quan trọng để đảm bảo đơn hàng có thể hoàn tất (như tình trạng còn hàng hoặc thông tin thanh toán) nên được thực hiện trên máy chủ, không chỉ trong trình duyệt của khách. Điều này rất quan trọng cho bảo mật.

Vì sao mã cần khai báo khả năng tương thích với HPOS và các khối checkout?

Khai báo tương thích cho WooCommerce và các lập trình viên khác biết mã của bạn đã được kiểm thử và hoạt động với cách quản lý đơn hàng mới (HPOS) và hệ thống checkout hiện đại (khối), tránh cảnh báo và lỗi cho chủ cửa hàng.

Chi tiết

Mô tả gốc của tác giả

Review generated or changed WooCommerce extensions, payment and shipping integrations, checkout customizations, and order or product logic.

repo: sickn33/agentic-awesome-skills

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#6193
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự