wordpress-woocommerce-development
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWordPress WooCommerce Development Workflow
WordPress WooCommerce开发工作流
Overview
概述
Specialized workflow for building WooCommerce stores including setup, payment gateway integration, shipping configuration, custom product types, store optimization, and WordPress 7.0 enhancements.
专为搭建WooCommerce商店设计的工作流,包括商店搭建、支付网关集成、配送配置、自定义产品类型、商店优化以及WordPress 7.0的增强功能。
WordPress 7.0 + WooCommerce Features
WordPress 7.0 + WooCommerce功能
-
AI Integration
- Auto-generate product descriptions
- AI-powered customer service responses
- Product summary generation
- Marketing copy assistance
-
DataViews for Orders
- Modern order management interfaces
- Enhanced filtering and sorting
- Activity layout for order history
-
Real-Time Collaboration
- Collaborative order editing
- Team notes and communication
- Live inventory updates
-
Admin Refresh
- Consistent WooCommerce admin styling
- View transitions between screens
-
Abilities API
- AI-powered order processing
- Automated inventory management
- Smart shipping recommendations
-
AI集成
- 自动生成商品描述
- AI驱动的客服回复
- 商品摘要生成
- 营销文案辅助
-
订单DataViews
- 现代化订单管理界面
- 增强的筛选和排序功能
- 订单历史的活动布局
-
实时协作
- 协作式订单编辑
- 团队备注与沟通
- 实时库存更新
-
后台界面更新
- 统一的WooCommerce后台样式
- 页面间的视图过渡效果
-
Abilities API
- AI驱动的订单处理
- 自动化库存管理
- 智能配送推荐
When to Use This Workflow
何时使用此工作流
Use this workflow when:
- Setting up WooCommerce stores
- Integrating payment gateways
- Configuring shipping methods
- Creating custom product types
- Building subscription products
- Implementing AI-powered features (WP 7.0)
在以下场景使用此工作流:
- 搭建WooCommerce商店
- 集成支付网关
- 配置配送方式
- 创建自定义产品类型
- 搭建订阅产品
- 实现AI驱动的功能(WP 7.0)
Workflow Phases
工作流阶段
Phase 1: Store Setup
阶段1:商店搭建
Skills to Invoke
调用技能
- - Project scaffolding
app-builder - - WordPress patterns
wordpress-penetration-testing
- - 项目脚手架
app-builder - - WordPress模式
wordpress-penetration-testing
Actions
操作步骤
- Install WooCommerce
- Run setup wizard
- Configure store settings
- Set up tax rules
- Configure currency
- Test with WordPress 7.0 admin
- 安装WooCommerce
- 运行设置向导
- 配置商店设置
- 设置税务规则
- 配置货币
- 使用WordPress 7.0后台进行测试
WordPress 7.0 + WooCommerce Setup
WordPress 7.0 + WooCommerce设置
php
// Minimum requirements for WP 7.0 + WooCommerce
// Add to wp-config.php for collaboration settings
define('WP_COLLABORATION_MAX_USERS', 10);
// AI features are enabled by installing a provider plugin
// Install OpenAI, Anthropic, or Gemini connector from WordPress.org
// Then configure via Settings > Connectors in admin panelphp
// Minimum requirements for WP 7.0 + WooCommerce
// Add to wp-config.php for collaboration settings
define('WP_COLLABORATION_MAX_USERS', 10);
// AI features are enabled by installing a provider plugin
// Install OpenAI, Anthropic, or Gemini connector from WordPress.org
// Then configure via Settings > Connectors in admin panelCopy-Paste Prompts
可复制提示词
Use @app-builder to set up WooCommerce storeUse @app-builder to set up WooCommerce storePhase 2: Product Configuration
阶段2:商品配置
Skills to Invoke
调用技能
- - WooCommerce patterns
wordpress-penetration-testing
- - WooCommerce模式
wordpress-penetration-testing
Actions
操作步骤
- Create product categories
- Add product attributes
- Configure product types
- Set up variable products
- Add product images
- 创建商品分类
- 添加商品属性
- 配置产品类型
- 设置可变产品
- 添加商品图片
AI-Powered Product Descriptions (WP 7.0)
AI驱动的商品描述(WP 7.0)
php
// Auto-generate product descriptions with AI
add_action('woocommerce_new_product', 'generate_ai_description', 10, 2);
function generate_ai_product_description($product_id, $product) {
if ($product->get_description()) {
return; // Skip if description exists
}
// Check if AI client is available
if (!function_exists('wp_ai_client_prompt')) {
return;
}
$title = $product->get_name();
$short_description = $product->get_short_description();
$prompt = sprintf(
'Write a compelling WooCommerce product description for "%s" that highlights key features and benefits. Make it SEO-friendly and persuasive.',
$title
);
if ($short_description) {
$prompt .= "\n\nShort description: " . $short_description;
}
$result = wp_ai_client_prompt($prompt);
if (is_wp_error($result)) {
return;
}
// Use temperature for consistent output
$result->using_temperature(0.3);
$description = $result->generate_text();
if ($description && !is_wp_error($description)) {
$product->set_description($description);
$product->save();
}
}php
// Auto-generate product descriptions with AI
add_action('woocommerce_new_product', 'generate_ai_description', 10, 2);
function generate_ai_product_description($product_id, $product) {
if ($product->get_description()) {
return; // Skip if description exists
}
// Check if AI client is available
if (!function_exists('wp_ai_client_prompt')) {
return;
}
$title = $product->get_name();
$short_description = $product->get_short_description();
$prompt = sprintf(
'Write a compelling WooCommerce product description for "%s" that highlights key features and benefits. Make it SEO-friendly and persuasive.',
$title
);
if ($short_description) {
$prompt .= "\n\nShort description: " . $short_description;
}
$result = wp_ai_client_prompt($prompt);
if (is_wp_error($result)) {
return;
}
// Use temperature for consistent output
$result->using_temperature(0.3);
$description = $result->generate_text();
if ($description && !is_wp_error($description)) {
$product->set_description($description);
$product->save();
}
}Copy-Paste Prompts
可复制提示词
Use @wordpress-penetration-testing to configure WooCommerce productsUse @wordpress-penetration-testing to configure WooCommerce productsPhase 3: Payment Integration
阶段3:支付集成
Skills to Invoke
调用技能
- - Payment processing
payment-integration - - Stripe
stripe-integration - - PayPal
paypal-integration
- - 支付处理
payment-integration - - Stripe
stripe-integration - - PayPal
paypal-integration
Actions
操作步骤
- Choose payment gateways
- Configure Stripe
- Set up PayPal
- Add offline payments
- Test payment flows
- 选择支付网关
- 配置Stripe
- 设置PayPal
- 添加线下支付方式
- 测试支付流程
WordPress 7.0 AI for Payments
WordPress 7.0 AI支付功能
php
// AI-powered fraud detection
// Note: This is a demonstration - implement proper fraud detection with multiple signals
// Use AI to analyze order for fraud indicators
function ai_check_order_fraud($order_id) {
// Check if AI client is available
if (!function_exists('wp_ai_client_prompt')) {
return false; // Default to no suspicion if AI unavailable
}
$order = wc_get_order($order_id);
if (!$order) {
return false;
}
$prompt = sprintf(
'Analyze this order for potential fraud. Order total: $%s. Shipping address: %s, %s. Billing: %s. Is this suspicious? Return only "suspicious" or "clean" without explanation.',
$order->get_total(),
$order->get_shipping_address_1(),
$order->get_shipping_city(),
$order->get_billing_email()
);
$result = wp_ai_client_prompt($prompt);
if (is_wp_error($result)) {
return false;
}
$result->using_temperature(0.1); // Low temp for consistent classification
$analysis = $result->generate_text();
return (strpos($analysis, 'suspicious') !== false);
}php
// AI-powered fraud detection
// Note: This is a demonstration - implement proper fraud detection with multiple signals
// Use AI to analyze order for fraud indicators
function ai_check_order_fraud($order_id) {
// Check if AI client is available
if (!function_exists('wp_ai_client_prompt')) {
return false; // Default to no suspicion if AI unavailable
}
$order = wc_get_order($order_id);
if (!$order) {
return false;
}
$prompt = sprintf(
'Analyze this order for potential fraud. Order total: $%s. Shipping address: %s, %s. Billing: %s. Is this suspicious? Return only "suspicious" or "clean" without explanation.',
$order->get_total(),
$order->get_shipping_address_1(),
$order->get_shipping_city(),
$order->get_billing_email()
);
$result = wp_ai_client_prompt($prompt);
if (is_wp_error($result)) {
return false;
}
$result->using_temperature(0.1); // Low temp for consistent classification
$analysis = $result->generate_text();
return (strpos($analysis, 'suspicious') !== false);
}Copy-Paste Prompts
可复制提示词
Use @stripe-integration to integrate Stripe paymentsUse @paypal-integration to integrate PayPalUse @stripe-integration to integrate Stripe paymentsUse @paypal-integration to integrate PayPalPhase 4: Shipping Configuration
阶段4:配送配置
Skills to Invoke
调用技能
- - WooCommerce shipping
wordpress-penetration-testing
- - WooCommerce配送
wordpress-penetration-testing
Actions
操作步骤
- Set up shipping zones
- Configure shipping methods
- Add flat rate shipping
- Set up free shipping
- Integrate carriers
- 设置配送区域
- 配置配送方式
- 添加统一费率配送
- 设置免运费
- 集成物流承运商
AI Shipping Recommendations (WP 7.0)
AI配送推荐(WP 7.0)
php
// AI-powered shipping recommendations
add_action('woocommerce_after_checkout_form', 'ai_shipping_recommendations');
function ai_shipping_recommendations($checkout) {
// Check if AI client is available
if (!function_exists('wp_ai_client_prompt')) {
return;
}
$cart = WC()->cart;
if ($cart->is_empty() || !$cart->get_cart_contents_weight()) {
return;
}
$prompt = sprintf(
'Based on this cart (total weight: %d kg, destination: %s), recommend the best shipping method from: free shipping (orders over $100), flat rate ($9.99), or express ($24.99). Consider delivery time and cost efficiency. Respond with just the recommended method name.',
$cart->get_cart_contents_weight(),
WC()->customer->get_shipping_country()
);
$result = wp_ai_client_prompt($prompt);
if (is_wp_error($result)) {
return;
}
$result->using_temperature(0.1); // Low temp for consistent recommendation
$recommendation = $result->generate_text();
if (strpos($recommendation, 'express') !== false) {
wc_add_notice(esc_html__('AI Recommendation: Consider Express shipping for faster delivery!', 'woocommerce'), 'info');
}
}php
// AI-powered shipping recommendations
add_action('woocommerce_after_checkout_form', 'ai_shipping_recommendations');
function ai_shipping_recommendations($checkout) {
// Check if AI client is available
if (!function_exists('wp_ai_client_prompt')) {
return;
}
$cart = WC()->cart;
if ($cart->is_empty() || !$cart->get_cart_contents_weight()) {
return;
}
$prompt = sprintf(
'Based on this cart (total weight: %d kg, destination: %s), recommend the best shipping method from: free shipping (orders over $100), flat rate ($9.99), or express ($24.99). Consider delivery time and cost efficiency. Respond with just the recommended method name.',
$cart->get_cart_contents_weight(),
WC()->customer->get_shipping_country()
);
$result = wp_ai_client_prompt($prompt);
if (is_wp_error($result)) {
return;
}
$result->using_temperature(0.1); // Low temp for consistent recommendation
$recommendation = $result->generate_text();
if (strpos($recommendation, 'express') !== false) {
wc_add_notice(esc_html__('AI Recommendation: Consider Express shipping for faster delivery!', 'woocommerce'), 'info');
}
}Copy-Paste Prompts
可复制提示词
Use @wordpress-penetration-testing to configure shippingUse @wordpress-penetration-testing to configure shippingPhase 5: Store Customization
阶段5:商店自定义
Skills to Invoke
调用技能
- - Store customization
frontend-developer - - Store design
frontend-design
- - 商店自定义
frontend-developer - - 商店设计
frontend-design
Actions
操作步骤
- Customize product pages
- Modify cart page
- Style checkout flow
- Create custom templates
- Add custom fields
- 自定义商品页面
- 修改购物车页面
- 设计结账流程样式
- 创建自定义模板
- 添加自定义字段
WordPress 7.0 Template Customization
WordPress 7.0模板自定义
php
// Custom product template with WP 7.0 blocks
add_action('woocommerce_after_main_content', 'add_product_ai_chat');
function add_product_ai_chat() {
if (!is_product()) return;
global $product;
?>
<div class="product-ai-assistant">
<h3>AI Shopping Assistant</h3>
<button id="ai-chat-toggle" type="button">Ask about this product</button>
<div id="ai-chat-panel" style="display:none;">
<div id="ai-chat-messages"></div>
<input type="text" id="ai-chat-input" placeholder="Ask about sizing, materials, etc.">
</div>
</div>
<script>
document.getElementById('ai-chat-toggle').addEventListener('click', function() {
const panel = document.getElementById('ai-chat-panel');
panel.style.display = panel.style.display === 'none' ? 'block' : 'none';
});
</script>
<?php
}
// AI-powered product Q&A
add_action('wp_ajax_ai_product_question', 'handle_ai_product_question');
add_action('wp_ajax_nopriv_ai_product_question', 'handle_ai_product_question');
function handle_ai_product_question() {
// Verify nonce for security
if (!check_ajax_referer('ai_product_question_nonce', 'nonce', false)) {
wp_send_json_error(['message' => 'Security check failed']);
}
$question = isset($_POST['question']) ? sanitize_text_field($_POST['question']) : '';
$product_id = isset($_POST['product_id']) ? intval($_POST['product_id']) : 0;
if (empty($question) || empty($product_id)) {
wp_send_json_error(['message' => 'Missing required fields']);
}
$product = wc_get_product($product_id);
if (!$product) {
wp_send_json_error(['message' => 'Product not found']);
}
// Check if AI client is available
if (!function_exists('wp_ai_client_prompt')) {
wp_send_json_error(['message' => 'AI service unavailable']);
}
$prompt = sprintf(
'Customer question about "%s": %s\n\nProduct details:
- Price: $%s
- SKU: %s
- Stock: %s
Answer helpfully, accurately, and concisely:',
$product->get_name(),
$question,
$product->get_price(),
$product->get_sku(),
$product->get_stock_status()
);
$result = wp_ai_client_prompt($prompt);
if (is_wp_error($result)) {
wp_send_json_error(['message' => $result->get_error_message()]);
}
$result->using_temperature(0.4); // Slightly higher for more varied responses
$answer = $result->generate_text();
if (is_wp_error($answer)) {
wp_send_json_error(['message' => 'Failed to generate response']);
}
wp_send_json_success(['answer' => $answer]);
}php
// Custom product template with WP 7.0 blocks
add_action('woocommerce_after_main_content', 'add_product_ai_chat');
function add_product_ai_chat() {
if (!is_product()) return;
global $product;
?>
<div class="product-ai-assistant">
<h3>AI Shopping Assistant</h3>
<button id="ai-chat-toggle" type="button">Ask about this product</button>
<div id="ai-chat-panel" style="display:none;">
<div id="ai-chat-messages"></div>
<input type="text" id="ai-chat-input" placeholder="Ask about sizing, materials, etc.">
</div>
</div>
<script>
document.getElementById('ai-chat-toggle').addEventListener('click', function() {
const panel = document.getElementById('ai-chat-panel');
panel.style.display = panel.style.display === 'none' ? 'block' : 'none';
});
</script>
<?php
}
// AI-powered product Q&A
add_action('wp_ajax_ai_product_question', 'handle_ai_product_question');
add_action('wp_ajax_nopriv_ai_product_question', 'handle_ai_product_question');
function handle_ai_product_question() {
// Verify nonce for security
if (!check_ajax_referer('ai_product_question_nonce', 'nonce', false)) {
wp_send_json_error(['message' => 'Security check failed']);
}
$question = isset($_POST['question']) ? sanitize_text_field($_POST['question']) : '';
$product_id = isset($_POST['product_id']) ? intval($_POST['product_id']) : 0;
if (empty($question) || empty($product_id)) {
wp_send_json_error(['message' => 'Missing required fields']);
}
$product = wc_get_product($product_id);
if (!$product) {
wp_send_json_error(['message' => 'Product not found']);
}
// Check if AI client is available
if (!function_exists('wp_ai_client_prompt')) {
wp_send_json_error(['message' => 'AI service unavailable']);
}
$prompt = sprintf(
'Customer question about "%s": %s\n\nProduct details:
- Price: $%s
- SKU: %s
- Stock: %s
Answer helpfully, accurately, and concisely:',
$product->get_name(),
$question,
$product->get_price(),
$product->get_sku(),
$product->get_stock_status()
);
$result = wp_ai_client_prompt($prompt);
if (is_wp_error($result)) {
wp_send_json_error(['message' => $result->get_error_message()]);
}
$result->using_temperature(0.4); // Slightly higher for more varied responses
$answer = $result->generate_text();
if (is_wp_error($answer)) {
wp_send_json_error(['message' => 'Failed to generate response']);
}
wp_send_json_success(['answer' => $answer]);
}Copy-Paste Prompts
可复制提示词
Use @frontend-developer to customize WooCommerce templatesUse @frontend-developer to customize WooCommerce templatesPhase 6: Extensions
阶段6:扩展功能
Skills to Invoke
调用技能
- - WooCommerce extensions
wordpress-penetration-testing
- - WooCommerce扩展
wordpress-penetration-testing
Actions
操作步骤
- Install required extensions
- Configure subscriptions
- Set up bookings
- Add memberships
- Integrate marketplace
- 安装所需扩展
- 配置订阅功能
- 设置预订功能
- 添加会员体系
- 集成商城平台
Abilities API for WooCommerce (WP 7.0)
WooCommerce的Abilities API(WP 7.0)
php
// Register ability categories first
add_action('wp_abilities_api_categories_init', function() {
wp_register_ability_category('ecommerce', [
'label' => __('E-Commerce', 'woocommerce'),
'description' => __('WooCommerce store management and operations', 'woocommerce'),
]);
});
// Register abilities
add_action('wp_abilities_api_init', function() {
// Register ability to update inventory
wp_register_ability('woocommerce/update-inventory', [
'label' => __('Update Inventory', 'woocommerce'),
'description' => __('Update product stock quantity', 'woocommerce'),
'category' => 'ecommerce',
'input_schema' => [
'type' => 'object',
'properties' => [
'product_id' => ['type' => 'integer', 'description' => 'Product ID to update'],
'quantity' => ['type' => 'integer', 'description' => 'New stock quantity']
],
'required' => ['product_id', 'quantity']
],
'output_schema' => [
'type' => 'object',
'properties' => [
'success' => ['type' => 'boolean'],
'new_quantity' => ['type' => 'integer']
]
],
'execute_callback' => 'woocommerce_update_inventory_handler',
'permission_callback' => function() {
return current_user_can('manage_woocommerce');
}
]);
// Register ability to process orders
wp_register_ability('woocommerce/process-order', [
'label' => __('Process Order', 'woocommerce'),
'description' => __('Mark order as processing and trigger fulfillment', 'woocommerce'),
'category' => 'ecommerce',
'input_schema' => [
'type' => 'object',
'properties' => [
'order_id' => ['type' => 'integer', 'description' => 'Order ID to process']
],
'required' => ['order_id']
],
'output_schema' => [
'type' => 'object',
'properties' => [
'success' => ['type' => 'boolean'],
'status' => ['type' => 'string']
]
],
'execute_callback' => 'woocommerce_process_order_handler',
'permission_callback' => function() {
return current_user_can('manage_woocommerce');
}
]);
});
// Handler for inventory update
function woocommerce_update_inventory_handler($input) {
$product_id = isset($input['product_id']) ? absint($input['product_id']) : 0;
$quantity = isset($input['quantity']) ? absint($input['quantity']) : 0;
$product = wc_get_product($product_id);
if (!$product) {
return new WP_Error('invalid_product', 'Product not found');
}
// Update stock
wc_update_product_stock($product, $quantity);
return [
'success' => true,
'new_quantity' => $product->get_stock_quantity()
];
}
// Handler for order processing
function woocommerce_process_order_handler($input) {
$order_id = isset($input['order_id']) ? absint($input['order_id']) : 0;
$order = wc_get_order($order_id);
if (!$order) {
return new WP_Error('invalid_order', 'Order not found');
}
$order->update_status('processing');
return [
'success' => true,
'status' => 'processing'
];
}php
// Register ability categories first
add_action('wp_abilities_api_categories_init', function() {
wp_register_ability_category('ecommerce', [
'label' => __('E-Commerce', 'woocommerce'),
'description' => __('WooCommerce store management and operations', 'woocommerce'),
]);
});
// Register abilities
add_action('wp_abilities_api_init', function() {
// Register ability to update inventory
wp_register_ability('woocommerce/update-inventory', [
'label' => __('Update Inventory', 'woocommerce'),
'description' => __('Update product stock quantity', 'woocommerce'),
'category' => 'ecommerce',
'input_schema' => [
'type' => 'object',
'properties' => [
'product_id' => ['type' => 'integer', 'description' => 'Product ID to update'],
'quantity' => ['type' => 'integer', 'description' => 'New stock quantity']
],
'required' => ['product_id', 'quantity']
],
'output_schema' => [
'type' => 'object',
'properties' => [
'success' => ['type' => 'boolean'],
'new_quantity' => ['type' => 'integer']
]
],
'execute_callback' => 'woocommerce_update_inventory_handler',
'permission_callback' => function() {
return current_user_can('manage_woocommerce');
}
]);
// Register ability to process orders
wp_register_ability('woocommerce/process-order', [
'label' => __('Process Order', 'woocommerce'),
'description' => __('Mark order as processing and trigger fulfillment', 'woocommerce'),
'category' => 'ecommerce',
'input_schema' => [
'type' => 'object',
'properties' => [
'order_id' => ['type' => 'integer', 'description' => 'Order ID to process']
],
'required' => ['order_id']
],
'output_schema' => [
'type' => 'object',
'properties' => [
'success' => ['type' => 'boolean'],
'status' => ['type' => 'string']
]
],
'execute_callback' => 'woocommerce_process_order_handler',
'permission_callback' => function() {
return current_user_can('manage_woocommerce');
}
]);
});
// Handler for inventory update
function woocommerce_update_inventory_handler($input) {
$product_id = isset($input['product_id']) ? absint($input['product_id']) : 0;
$quantity = isset($input['quantity']) ? absint($input['quantity']) : 0;
$product = wc_get_product($product_id);
if (!$product) {
return new WP_Error('invalid_product', 'Product not found');
}
// Update stock
wc_update_product_stock($product, $quantity);
return [
'success' => true,
'new_quantity' => $product->get_stock_quantity()
];
}
// Handler for order processing
function woocommerce_process_order_handler($input) {
$order_id = isset($input['order_id']) ? absint($input['order_id']) : 0;
$order = wc_get_order($order_id);
if (!$order) {
return new WP_Error('invalid_order', 'Order not found');
}
$order->update_status('processing');
return [
'success' => true,
'status' => 'processing'
];
}Copy-Paste Prompts
可复制提示词
Use @wordpress-penetration-testing to configure WooCommerce extensionsUse @wordpress-penetration-testing to configure WooCommerce extensionsPhase 7: Optimization
阶段7:优化
Skills to Invoke
调用技能
- - Performance
web-performance-optimization - - Database optimization
database-optimizer
- - 性能优化
web-performance-optimization - - 数据库优化
database-optimizer
Actions
操作步骤
- Optimize product images
- Enable caching
- Optimize database
- Configure CDN
- Set up lazy loading
- 优化商品图片
- 启用缓存
- 优化数据库
- 配置CDN
- 设置懒加载
WordPress 7.0 Performance
WordPress 7.0性能特性
- Client-side media processing
- Font Library enabled
- Responsive grid block
- View transitions for perceived performance
- 客户端媒体处理
- 字体库已启用
- 响应式网格区块
- 视图过渡效果提升感知性能
Copy-Paste Prompts
可复制提示词
Use @web-performance-optimization to optimize WooCommerce storeUse @web-performance-optimization to optimize WooCommerce storePhase 8: Testing
阶段8:测试
Skills to Invoke
调用技能
- - E2E testing
playwright-skill - - Test automation
test-automator
- - 端到端测试
playwright-skill - - 测试自动化
test-automator
Actions
操作步骤
- Test checkout flow
- Verify payment processing
- Test email notifications
- Check mobile experience
- Performance testing
- 测试结账流程
- 验证支付处理
- 测试邮件通知
- 检查移动端体验
- 性能测试
WordPress 7.0 Testing
WordPress 7.0测试要点
- Test with new admin interface
- Verify AI features work
- Test DataViews for orders
- Verify collaboration features
- 测试新后台界面
- 验证AI功能正常运行
- 测试订单DataViews
- 验证协作功能
AI-Powered Store Testing
AI驱动的商店测试
php
// Automated AI testing for fraud detection during checkout
add_action('woocommerce_after_checkout_validation', 'ai_validate_order', 20);
function ai_validate_order($fields, $errors) {
// Skip if AI is not available
if (!function_exists('wp_ai_client_prompt')) {
return;
}
// Skip for logged-in users (assumed trusted)
if (is_user_logged_in()) {
return;
}
$order_data = [
'email' => isset($fields['billing_email']) ? $fields['billing_email'] : '',
'phone' => isset($fields['billing_phone']) ? $fields['billing_phone'] : '',
'address' => isset($fields['billing_address_1']) ? $fields['billing_address_1'] : '',
];
// Skip if insufficient data
if (empty($order_data['email'])) {
return;
}
$prompt = sprintf(
'This is a checkout validation. Check if these details seem legitimate: email=%s, phone=%s, address=%s. Return only "valid" or "suspicious" without additional text.',
sanitize_email($order_data['email']),
sanitize_text_field($order_data['phone']),
sanitize_text_field($order_data['address'])
);
$result = wp_ai_client_prompt($prompt);
if (is_wp_error($result)) {
// Don't block checkout on AI errors
return;
}
$result->using_temperature(0.1); // Low temp for consistent classification
$response = $result->generate_text();
if (is_wp_error($response)) {
return;
}
if (strpos($response, 'suspicious') !== false) {
$errors->add('validation', __('Additional verification may be needed for this order. We will contact you if needed.', 'woocommerce'));
}
}php
// Automated AI testing for fraud detection during checkout
add_action('woocommerce_after_checkout_validation', 'ai_validate_order', 20);
function ai_validate_order($fields, $errors) {
// Skip if AI is not available
if (!function_exists('wp_ai_client_prompt')) {
return;
}
// Skip for logged-in users (assumed trusted)
if (is_user_logged_in()) {
return;
}
$order_data = [
'email' => isset($fields['billing_email']) ? $fields['billing_email'] : '',
'phone' => isset($fields['billing_phone']) ? $fields['billing_phone'] : '',
'address' => isset($fields['billing_address_1']) ? $fields['billing_address_1'] : '',
];
// Skip if insufficient data
if (empty($order_data['email'])) {
return;
}
$prompt = sprintf(
'This is a checkout validation. Check if these details seem legitimate: email=%s, phone=%s, address=%s. Return only "valid" or "suspicious" without additional text.',
sanitize_email($order_data['email']),
sanitize_text_field($order_data['phone']),
sanitize_text_field($order_data['address'])
);
$result = wp_ai_client_prompt($prompt);
if (is_wp_error($result)) {
// Don't block checkout on AI errors
return;
}
$result->using_temperature(0.1); // Low temp for consistent classification
$response = $result->generate_text();
if (is_wp_error($response)) {
return;
}
if (strpos($response, 'suspicious') !== false) {
$errors->add('validation', __('Additional verification may be needed for this order. We will contact you if needed.', 'woocommerce'));
}
}Copy-Paste Prompts
可复制提示词
Use @playwright-skill to test WooCommerce checkout flowUse @playwright-skill to test WooCommerce checkout flowWooCommerce + WordPress 7.0 AI Use Cases
WooCommerce + WordPress 7.0 AI用例
-
Product Descriptions
- Auto-generate from product attributes
- Translate descriptions
- SEO optimization
-
Customer Service
- AI chatbot for common questions
- Order status lookup
- Return processing
-
Inventory Management
- Demand forecasting
- Low stock alerts
- Reorder recommendations
-
Marketing
- Personalized emails
- Product recommendations
- Abandoned cart recovery
-
Order Processing
- Fraud detection
- Shipping optimization
- Invoice generation
-
商品描述
- 根据商品属性自动生成
- 翻译描述内容
- SEO优化
-
客户服务
- 常见问题AI聊天机器人
- 订单状态查询
- 退货处理
-
库存管理
- 需求预测
- 低库存提醒
- 补货推荐
-
营销推广
- 个性化邮件
- 商品推荐
- 购物车挽回
-
订单处理
- 欺诈检测
- 配送优化
- 发票生成
Quality Gates
质量检查清单
- Products displaying correctly
- Checkout flow working
- Payments processing
- Shipping calculating
- Emails sending
- Mobile responsive
- AI features tested (WP 7.0)
- DataViews working (WP 7.0)
- 商品显示正常
- 结账流程可用
- 支付处理正常
- 配送计算正确
- 邮件发送正常
- 移动端响应良好
- AI功能已测试(WP 7.0)
- DataViews功能正常(WP 7.0)
Related Workflow Bundles
相关工作流包
- - WordPress development
wordpress - - Theme development
wordpress-theme-development - - Plugin development
wordpress-plugin-development - - Payment processing
payment-integration
- - WordPress开发
wordpress - - 主题开发
wordpress-theme-development - - 插件开发
wordpress-plugin-development - - 支付处理
payment-integration
Limitations
局限性
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
- 仅当任务与上述描述的范围完全匹配时使用此技能。
- 请勿将输出结果视为环境特定验证、测试或专家评审的替代品。
- 如果缺少必要的输入、权限、安全边界或成功标准,请暂停并询问澄清。