feat: Implement upsell functionality with repository and service layers

This commit is contained in:
2026-05-02 23:30:23 +03:30
parent 4928901a08
commit 5930c1ad6f
26 changed files with 3130 additions and 126 deletions

View File

@@ -0,0 +1,145 @@
<?php
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
$current_page = sanitize_text_field($_GET['page'] ?? 'sodino-competitor-price');
?>
<div id="sodino-app" class="min-h-screen bg-gray-50" dir="rtl">
<div class="bg-white border-b border-gray-200">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="py-6">
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold text-gray-900"><?php _e('سودینو', 'sodino'); ?></h1>
<p class="mt-1 text-sm text-gray-500"><?php _e('بهینه‌سازی هوشمند فروش', 'sodino'); ?></p>
</div>
</div>
</div>
</div>
</div>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<div class="flex gap-8">
<aside class="w-64 flex-shrink-0">
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<h2 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('منوی سودینو', 'sodino'); ?></h2>
<nav class="space-y-2">
<a href="<?php echo admin_url('admin.php?page=sodino-dashboard'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-dashboard' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('داشبورد', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-rules'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-rules' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قوانین', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-rule'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-rule' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن قانون', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-upsells'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-upsells' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('آپسل (پیشنهاد فروش)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-upsell'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-upsell' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن آپسل', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-competitor-price'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-competitor-price' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قیمت رقبا (به‌زودی)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-settings'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-settings' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('تنظیمات', 'sodino'); ?>
</a>
</nav>
</div>
</aside>
<main class="flex-1 min-w-0">
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6 mb-8">
<div class="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
<div>
<h2 class="text-2xl font-semibold text-gray-900"><?php _e('قیمت رقبا', 'sodino'); ?></h2>
<p class="mt-2 text-gray-600"><?php _e('به‌زودی بخش مانیتورینگ قیمت رقبا فعال خواهد شد.', 'sodino'); ?></p>
</div>
<span class="inline-flex items-center rounded-full bg-yellow-50 px-3 py-1 text-sm font-medium text-yellow-700"><?php _e('به‌زودی', 'sodino'); ?></span>
</div>
</div>
<div class="grid gap-6 lg:grid-cols-3">
<div class="lg:col-span-2 bg-white rounded-2xl border border-gray-200 shadow-sm p-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('مشخصات رقیب', 'sodino'); ?></h3>
<p class="text-sm text-gray-500 mb-6"><?php _e('این قابلیت به شما امکان می‌دهد قیمت محصولات خود را با رقبا مقایسه کرده و بهینه‌سازی کنید. (در نسخه‌های آینده فعال خواهد شد)', 'sodino'); ?></p>
<div class="overflow-x-auto rounded-xl border border-gray-200">
<table class="min-w-full divide-y divide-gray-200 text-right text-sm text-gray-700">
<thead class="bg-gray-50 text-gray-500">
<tr>
<th class="px-4 py-3 font-medium"><?php _e('محصول', 'sodino'); ?></th>
<th class="px-4 py-3 font-medium"><?php _e('قیمت شما', 'sodino'); ?></th>
<th class="px-4 py-3 font-medium"><?php _e('قیمت رقبا', 'sodino'); ?></th>
<th class="px-4 py-3 font-medium"><?php _e('اختلاف قیمت', 'sodino'); ?></th>
<th class="px-4 py-3 font-medium"><?php _e('وضعیت', 'sodino'); ?></th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200 bg-white">
<tr>
<td class="px-4 py-3"><?php _e('کفش دویدن', 'sodino'); ?></td>
<td class="px-4 py-3">23,500 تومان</td>
<td class="px-4 py-3">24,900 تومان</td>
<td class="px-4 py-3 text-green-600">1,400 تومان کمتر</td>
<td class="px-4 py-3"><span class="rounded-full bg-green-50 px-3 py-1 text-xs font-semibold text-green-700"><?php _e('رقبتی', 'sodino'); ?></span></td>
</tr>
<tr>
<td class="px-4 py-3"><?php _e('کرم محافظ پوست', 'sodino'); ?></td>
<td class="px-4 py-3">78,000 تومان</td>
<td class="px-4 py-3">82,000 تومان</td>
<td class="px-4 py-3 text-green-600">4,000 تومان کمتر</td>
<td class="px-4 py-3"><span class="rounded-full bg-green-50 px-3 py-1 text-xs font-semibold text-green-700"><?php _e('رقبتی', 'sodino'); ?></span></td>
</tr>
<tr>
<td class="px-4 py-3"><?php _e('کیف دستی', 'sodino'); ?></td>
<td class="px-4 py-3">155,000 تومان</td>
<td class="px-4 py-3">161,000 تومان</td>
<td class="px-4 py-3 text-red-600">6,000 تومان بیشتر</td>
<td class="px-4 py-3"><span class="rounded-full bg-gray-50 px-3 py-1 text-xs font-semibold text-gray-700"><?php _e('هشدار', 'sodino'); ?></span></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="space-y-6">
<div class="bg-white rounded-2xl border border-gray-200 shadow-sm p-6">
<div class="flex items-center justify-between mb-4">
<h3 class="text-lg font-semibold text-gray-900"><?php _e('افزودن رقیب', 'sodino'); ?></h3>
<span class="rounded-full bg-blue-50 px-3 py-1 text-xs font-semibold text-blue-700"><?php _e('به‌زودی', 'sodino'); ?></span>
</div>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2"><?php _e('URL سایت رقیب', 'sodino'); ?></label>
<input type="url" disabled class="w-full rounded-lg border border-gray-200 bg-gray-100 px-4 py-3 text-gray-500 shadow-sm" placeholder="https://example.com">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2"><?php _e('نام فروشگاه', 'sodino'); ?></label>
<input type="text" disabled class="w-full rounded-lg border border-gray-200 bg-gray-100 px-4 py-3 text-gray-500 shadow-sm" placeholder="<?php _e('مثلاً اسم فروشگاه رقبا', 'sodino'); ?>">
</div>
<button disabled class="w-full rounded-full bg-gray-300 px-4 py-3 text-sm font-semibold text-gray-700"><?php _e('افزودن', 'sodino'); ?></button>
</div>
</div>
<div class="bg-white rounded-2xl border border-gray-200 shadow-sm p-6">
<div class="flex items-center justify-between mb-4">
<div>
<h3 class="text-lg font-semibold text-gray-900"><?php _e('فعال‌سازی مانیتورینگ قیمت', 'sodino'); ?></h3>
<p class="mt-1 text-sm text-gray-500"><?php _e('این ویژگی در نسخه‌های آینده فعال می‌شود.', 'sodino'); ?></p>
</div>
<div class="flex items-center gap-3">
<span class="px-3 py-1 rounded-full bg-gray-100 text-xs font-semibold text-gray-600"><?php _e('غیرفعال', 'sodino'); ?></span>
</div>
</div>
<div class="rounded-2xl border border-gray-200 bg-gray-50 p-5 text-sm text-gray-500">
<?php _e('در اینجا می‌توانید فعال‌سازی خودکار تحلیل قیمت رقبا را مشاهده کنید؛ در حال حاضر این بخش در دست ساخت است.', 'sodino'); ?>
</div>
</div>
</div>
</div>
</main>
</div>
</div>
</div>

170
admin/views/dashboard.php Normal file
View File

@@ -0,0 +1,170 @@
<?php
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
$summary = $dashboardData['summary'];
$salesChart = $dashboardData['sales_chart'];
$rulePerformance = $dashboardData['rule_performance'];
$userBehavior = $dashboardData['user_behavior'];
$insights = $dashboardData['insights'];
$current_page = sanitize_text_field($_GET['page'] ?? 'sodino-dashboard');
?>
<div id="sodino-app" class="min-h-screen bg-gray-50" dir="rtl">
<!-- Header -->
<div class="bg-white border-b border-gray-200">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="py-6">
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold text-gray-900"><?php _e('سودینو', 'sodino'); ?></h1>
<p class="mt-1 text-sm text-gray-500"><?php _e('بهینه‌سازی هوشمند فروش', 'sodino'); ?></p>
</div>
</div>
</div>
</div>
</div>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<div class="flex gap-8">
<!-- Sidebar -->
<aside class="w-64 flex-shrink-0">
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<h2 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('منوی سودینو', 'sodino'); ?></h2>
<nav class="space-y-2">
<a href="<?php echo admin_url('admin.php?page=sodino-dashboard'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-dashboard' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('داشبورد', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-rules'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-rules' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قوانین', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-rule'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-rule' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن قانون', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-upsells'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-upsells' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('آپسل (پیشنهاد فروش)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-upsell'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-upsell' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن آپسل', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-competitor-price'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-competitor-price' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قیمت رقبا (به‌زودی)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-settings'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-settings' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('تنظیمات', 'sodino'); ?>
</a>
</nav>
</div>
</aside>
<!-- Main Content -->
<main class="flex-1 min-w-0">
<!-- Overview Card -->
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6 mb-8">
<h2 class="text-xl font-semibold text-gray-900 mb-2"><?php _e('نمای کلی داشبورد', 'sodino'); ?></h2>
<p class="text-gray-600"><?php _e('نمایش سریع KPIها، عملکرد قوانین و رفتار مشتریان.', 'sodino'); ?></p>
</div>
<!-- Stats Grid -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
<div class="bg-gradient-to-br from-blue-600 to-blue-700 rounded-lg p-6 text-white">
<h3 class="text-sm font-medium opacity-90"><?php _e('درآمد کل', 'sodino'); ?></h3>
<div class="text-2xl font-bold mt-2"><?php echo wc_price($summary['total_revenue']); ?></div>
</div>
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<h3 class="text-sm font-medium text-gray-600"><?php _e('میزان تخفیف داده شده', 'sodino'); ?></h3>
<div class="text-2xl font-bold text-gray-900 mt-2"><?php echo wc_price($summary['total_discount']); ?></div>
</div>
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<h3 class="text-sm font-medium text-gray-600"><?php _e('نرخ تبدیل تقریبی', 'sodino'); ?></h3>
<div class="text-2xl font-bold text-gray-900 mt-2"><?php echo esc_html($summary['conversion_rate']); ?>%</div>
</div>
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<h3 class="text-sm font-medium text-gray-600"><?php _e('بهترین قانون', 'sodino'); ?></h3>
<div class="text-2xl font-bold text-gray-900 mt-2"><?php echo esc_html($summary['best_rule'] ?? __('بدون داده', 'sodino')); ?></div>
</div>
</div>
<!-- Charts Grid -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-8">
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('نمودار فروش (قبل و بعد)', 'sodino'); ?></h3>
<div class="h-64">
<canvas id="sodinoSalesChart" class="w-full h-full"></canvas>
</div>
</div>
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('تاثیر تخفیف', 'sodino'); ?></h3>
<div class="h-64">
<canvas id="sodinoDiscountChart" class="w-full h-full"></canvas>
</div>
</div>
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('عملکرد قوانین', 'sodino'); ?></h3>
<div class="h-64">
<canvas id="sodinoRuleChart" class="w-full h-full"></canvas>
</div>
</div>
</div>
<!-- User Behavior and Insights -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('رفتار کاربران', 'sodino'); ?></h3>
<div class="grid grid-cols-2 gap-4">
<div class="bg-gray-50 rounded-lg p-4">
<div class="text-sm font-medium text-gray-600"><?php _e('بازدید محصول', 'sodino'); ?></div>
<div class="text-2xl font-bold text-gray-900 mt-1"><?php echo esc_html($userBehavior['product_views']); ?></div>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<div class="text-sm font-medium text-gray-600"><?php _e('افزودن به سبد', 'sodino'); ?></div>
<div class="text-2xl font-bold text-gray-900 mt-1"><?php echo esc_html($userBehavior['add_to_cart']); ?></div>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<div class="text-sm font-medium text-gray-600"><?php _e('شروع پرداخت', 'sodino'); ?></div>
<div class="text-2xl font-bold text-gray-900 mt-1"><?php echo esc_html($userBehavior['checkout_start']); ?></div>
</div>
<div class="bg-gray-50 rounded-lg p-4">
<div class="text-sm font-medium text-gray-600"><?php _e('خرید', 'sodino'); ?></div>
<div class="text-2xl font-bold text-gray-900 mt-1"><?php echo esc_html($userBehavior['purchases']); ?></div>
</div>
</div>
</div>
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('بینش‌ها', 'sodino'); ?></h3>
<div class="space-y-3">
<?php foreach ($insights as $insight) : ?>
<div class="bg-gray-50 rounded-lg p-4">
<div class="text-sm text-gray-600"><?php echo esc_html($insight); ?></div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</main>
</div>
</div>
</div>
<script id="sodino-dashboard-data" type="application/json">
<?php echo wp_json_encode([
'salesChart' => $salesChart,
'summary' => $summary,
'rulePerformance' => [
'names' => array_column($rulePerformance, 'name'),
'revenue' => array_column($rulePerformance, 'revenue'),
'discount' => array_column($rulePerformance, 'discount'),
],
'translations' => [
'afterApplying' => __('پس از اعمال سودینو', 'sodino'),
'beforeApplying' => __('قبل از اعمال سودینو', 'sodino'),
'totalDiscount' => __('مجموع تخفیف', 'sodino'),
'totalRevenue' => __('درآمد پس از تخفیف', 'sodino'),
'discountEffect' => __('تاثیر تخفیف', 'sodino'),
'ruleRevenue' => __('درآمد ایجاد شده', 'sodino'),
'ruleDiscount' => __('تخفیف ثبت شده', 'sodino'),
],
], JSON_UNESCAPED_UNICODE); ?>
</script>

View File

@@ -3,52 +3,165 @@
if (!defined('ABSPATH')) {
exit;
}
$current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-rule');
?>
<div class="wrap">
<h1><?php echo $rule->id ? __('ویرایش قانون', 'sodino') : __('افزودن قانون جدید', 'sodino'); ?></h1>
<div id="sodino-app" class="min-h-screen bg-gray-50" dir="rtl">
<!-- Header -->
<div class="bg-white border-b border-gray-200">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="py-6">
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold text-gray-900"><?php _e('سودینو', 'sodino'); ?></h1>
<p class="mt-1 text-sm text-gray-500"><?php _e('بهینه‌سازی هوشمند فروش', 'sodino'); ?></p>
</div>
</div>
</div>
</div>
</div>
<form method="post">
<?php wp_nonce_field('gheymatyar_save_rule', 'gheymatyar_rule_nonce'); ?>
<table class="form-table">
<tr>
<th scope="row"><label for="name"><?php _e('عنوان قانون', 'sodino'); ?></label></th>
<td><input type="text" name="name" id="name" value="<?php echo esc_attr($rule->name); ?>" class="regular-text" required></td>
</tr>
<tr>
<th scope="row"><label for="condition_type"><?php _e('نوع شرط', 'sodino'); ?></label></th>
<td>
<select name="condition_type" id="condition_type" class="regular-text" required>
<option value="user_type" <?php selected($rule->condition_type, 'user_type'); ?>><?php _e('نوع کاربر', 'sodino'); ?></option>
</select>
</td>
</tr>
<tr>
<th scope="row"><label for="condition_value"><?php _e('نوع کاربر', 'sodino'); ?></label></th>
<td>
<select name="condition_value" id="condition_value" class="regular-text" required>
<option value="new" <?php selected($rule->condition_value, 'new'); ?>><?php _e('کاربر جدید', 'sodino'); ?></option>
<option value="returning" <?php selected($rule->condition_value, 'returning'); ?>><?php _e('کاربر بازگشتی', 'sodino'); ?></option>
</select>
</td>
</tr>
<tr>
<th scope="row"><label for="action_type"><?php _e('نوع عملیات', 'sodino'); ?></label></th>
<td>
<select name="action_type" id="action_type" class="regular-text" required>
<option value="discount_percent" <?php selected($rule->action_type, 'discount_percent'); ?>><?php _e('درصد تخفیف', 'sodino'); ?></option>
</select>
</td>
</tr>
<tr>
<th scope="row"><label for="action_value"><?php _e('درصد تخفیف', 'sodino'); ?></label></th>
<td><input type="number" name="action_value" id="action_value" value="<?php echo esc_attr($rule->action_value); ?>" min="0" max="100" step="0.01" class="small-text" required> %</td>
</tr>
<tr>
<th scope="row"><label for="enabled"><?php _e('وضعیت', 'sodino'); ?></label></th>
<td><label><input type="checkbox" name="enabled" id="enabled" value="1" <?php checked($rule->enabled, 1); ?>> <?php _e('فعال باشد', 'sodino'); ?></label></td>
</tr>
</table>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<div class="flex gap-8">
<!-- Sidebar -->
<aside class="w-64 flex-shrink-0">
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<h2 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('منوی سودینو', 'sodino'); ?></h2>
<nav class="space-y-2">
<a href="<?php echo admin_url('admin.php?page=sodino-dashboard'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-dashboard' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('داشبورد', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-rules'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-rules' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قوانین', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-rule'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-rule' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن قانون', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-upsells'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-upsells' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('آپسل (پیشنهاد فروش)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-upsell'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-upsell' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن آپسل', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-competitor-price'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-competitor-price' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قیمت رقبا (به‌زودی)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-settings'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-settings' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('تنظیمات', 'sodino'); ?>
</a>
</nav>
</div>
</aside>
<?php submit_button($rule->id ? __('به‌روزرسانی قانون', 'sodino') : __('افزودن قانون', 'sودino'), 'primary'); ?>
</form>
<!-- Main Content -->
<main class="flex-1 min-w-0">
<!-- Page Header -->
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6 mb-8">
<div class="flex items-center justify-between">
<div>
<h2 class="text-2xl font-semibold text-gray-900"><?php echo $rule->id ? __('ویرایش قانون', 'sodino') : __('افزودن قانون جدید', 'sodino'); ?></h2>
<p class="mt-2 text-gray-600"><?php _e('قانون قیمت‌گذاری پویا ایجاد یا ویرایش کنید.', 'sodino'); ?></p>
</div>
<a href="<?php echo admin_url('admin.php?page=sodino-rules'); ?>" class="inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-lg text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-200">
<svg class="-ml-1 mr-2 h-5 w-5" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M9.707 16.707a1 1 0 01-1.414 0l-6-6a1 1 0 010-1.414l6-6a1 1 0 011.414 1.414L5.414 9H17a1 1 0 110 2H5.414l4.293 4.293a1 1 0 010 1.414z" clip-rule="evenodd" />
</svg>
<?php _e('بازگشت به قوانین', 'sodino'); ?>
</a>
</div>
</div>
<!-- Form -->
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<form method="post">
<?php wp_nonce_field('gheymatyar_save_rule', 'gheymatyar_rule_nonce'); ?>
<div class="grid gap-6 md:grid-cols-2">
<!-- Rule Name -->
<div class="md:col-span-2">
<label for="name" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('عنوان قانون', 'sodino'); ?></label>
<input type="text" name="name" id="name" value="<?php echo esc_attr($rule->name); ?>" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" required>
<p class="mt-2 text-sm text-gray-500"><?php _e('نامی کوتاه و قابل فهم برای قانون انتخاب کنید.', 'sodino'); ?></p>
</div>
<!-- Priority -->
<div>
<label for="priority" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('اولویت', 'sodino'); ?></label>
<input type="number" name="priority" id="priority" value="<?php echo esc_attr($rule->priority ?: 10); ?>" min="1" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<p class="mt-2 text-sm text-gray-500"><?php _e('عدد بالاتر، اولویت بیشتری دارد.', 'sodino'); ?></p>
</div>
<!-- Usage Limit -->
<div>
<label for="usage_limit" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('محدودیت تعداد استفاده', 'sodino'); ?></label>
<input type="number" name="usage_limit" id="usage_limit" value="<?php echo esc_attr($rule->usage_limit ?? 0); ?>" min="0" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<p class="mt-2 text-sm text-gray-500"><?php _e('0 به معنی بدون محدودیت است.', 'sodino'); ?></p>
</div>
<!-- User Roles -->
<div class="md:col-span-2">
<label for="user_roles" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('محدودیت نقش کاربری', 'sodino'); ?></label>
<select name="user_roles[]" id="user_roles" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" multiple size="4">
<?php foreach (wp_roles()->roles as $role_key => $role_data) : ?>
<option value="<?php echo esc_attr($role_key); ?>" <?php echo in_array($role_key, (array) $rule->user_roles, true) ? 'selected' : ''; ?>><?php echo esc_html($role_data['name']); ?></option>
<?php endforeach; ?>
</select>
<p class="mt-2 text-sm text-gray-500"><?php _e('نقش‌هایی که این قانون باید برای آنها اعمال شود.', 'sodino'); ?></p>
</div>
<!-- Condition Type -->
<div>
<label for="condition_type" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('نوع شرط', 'sodino'); ?></label>
<select name="condition_type" id="condition_type" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" required>
<option value="user_type" <?php selected($rule->condition_type, 'user_type'); ?>><?php _e('نوع کاربر', 'sodino'); ?></option>
<option value="product_category" <?php selected($rule->condition_type, 'product_category'); ?>><?php _e('دسته‌بندی محصول', 'sodino'); ?></option>
<option value="product_ids" <?php selected($rule->condition_type, 'product_ids'); ?>><?php _e('محصولات خاص', 'sodino'); ?></option>
</select>
<p class="mt-2 text-sm text-gray-500"><?php _e('نوع شرطی که باید قبل از اعمال قانون بررسی شود.', 'sodino'); ?></p>
</div>
<!-- Condition Value -->
<div>
<label for="condition_value" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('مقدار شرط', 'sodino'); ?></label>
<input type="text" name="condition_value" id="condition_value" value="<?php echo esc_attr($rule->condition_value); ?>" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" required>
<p class="mt-2 text-sm text-gray-500"><?php _e('برای کاربر جدید/بازگشتی: new یا returning. برای دسته‌بندی: شناسه دسته‌بندی، برای محصولات: شناسه محصول.', 'sodino'); ?></p>
</div>
<!-- Action Type -->
<div>
<label for="action_type" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('نوع عملیات', 'sodino'); ?></label>
<select name="action_type" id="action_type" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" required>
<option value="discount_percent" <?php selected($rule->action_type, 'discount_percent'); ?>><?php _e('درصد تخفیف', 'sodino'); ?></option>
<option value="discount_fixed" <?php selected($rule->action_type, 'discount_fixed'); ?>><?php _e('تخفیف ثابت', 'sodino'); ?></option>
<option value="free_shipping" <?php selected($rule->action_type, 'free_shipping'); ?>><?php _e('ارسال رایگان', 'sodino'); ?></option>
</select>
</div>
<!-- Action Value -->
<div>
<label for="action_value" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('مقدار عملیات', 'sodino'); ?></label>
<input type="number" name="action_value" id="action_value" value="<?php echo esc_attr($rule->action_value); ?>" min="0" step="0.01" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<p class="mt-2 text-sm text-gray-500"><?php _e('برای درصد یا مقدار ثابت وارد کنید.', 'sodino'); ?></p>
</div>
<!-- Status -->
<div class="md:col-span-2">
<label class="flex items-center gap-3 text-gray-700">
<input type="checkbox" name="enabled" id="enabled" value="1" <?php checked($rule->enabled, 1); ?> class="h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<span><?php _e('فعال باشد', 'sodino'); ?></span>
</label>
</div>
</div>
<!-- Submit Button -->
<div class="mt-8 flex justify-end">
<button type="submit" class="inline-flex items-center px-6 py-3 border border-transparent text-sm font-medium rounded-lg text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-200">
<?php echo $rule->id ? __('به‌روزرسانی قانون', 'sodino') : __('افزودن قانون', 'sodino'); ?>
</button>
</div>
</form>
</div>
</main>
</div>
</div>
</div>

View File

@@ -3,13 +3,81 @@
if (!defined('ABSPATH')) {
exit;
}
$current_page = sanitize_text_field($_GET['page'] ?? 'sodino-rules');
?>
<div class="wrap">
<h1><?php _e('قوانین قیمت‌گذاری', 'sodino'); ?></h1>
<div id="sodino-app" class="min-h-screen bg-gray-50" dir="rtl">
<!-- Header -->
<div class="bg-white border-b border-gray-200">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="py-6">
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold text-gray-900"><?php _e('سودینو', 'sodino'); ?></h1>
<p class="mt-1 text-sm text-gray-500"><?php _e('بهینه‌سازی هوشمند فروش', 'sodino'); ?></p>
</div>
</div>
</div>
</div>
</div>
<a href="<?php echo admin_url('admin.php?page=sodino-add-rule'); ?>" class="page-title-action"><?php _e('افزودن قانون جدید', 'sodino'); ?></a>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<div class="flex gap-8">
<!-- Sidebar -->
<aside class="w-64 flex-shrink-0">
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<h2 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('منوی سودینو', 'sodino'); ?></h2>
<nav class="space-y-2">
<a href="<?php echo admin_url('admin.php?page=sodino-dashboard'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-dashboard' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('داشبورد', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-rules'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-rules' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قوانین', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-rule'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-rule' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن قانون', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-upsells'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-upsells' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('آپسل (پیشنهاد فروش)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-upsell'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-upsell' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن آپسل', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-competitor-price'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-competitor-price' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قیمت رقبا (به‌زودی)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-settings'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-settings' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('تنظیمات', 'sودینو'); ?>
</a>
</nav>
</div>
</aside>
<form method="post">
<?php $rulesTable->display(); ?>
</form>
<!-- Main Content -->
<main class="flex-1 min-w-0">
<!-- Page Header -->
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6 mb-8">
<div class="flex items-center justify-between">
<div>
<h2 class="text-2xl font-semibold text-gray-900"><?php _e('قوانین قیمت‌گذاری', 'sodino'); ?></h2>
<p class="mt-2 text-gray-600"><?php _e('مدیریت قوانین قیمت‌گذاری پویا و تخفیف‌های هوشمند.', 'sodino'); ?></p>
</div>
<a href="<?php echo admin_url('admin.php?page=sodino-add-rule'); ?>" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-lg text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-200">
<svg class="-ml-1 mr-2 h-5 w-5" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" clip-rule="evenodd" />
</svg>
<?php _e('افزودن قانون جدید', 'sodino'); ?>
</a>
</div>
</div>
<!-- Rules Table -->
<div class="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden">
<form method="post">
<?php $rulesTable->display(); ?>
</form>
</div>
</main>
</div>
</div>
</div>

View File

@@ -3,10 +3,198 @@
if (!defined('ABSPATH')) {
exit;
}
$current_page = sanitize_text_field($_GET['page'] ?? 'sodino-settings');
?>
<div class="wrap">
<h1><?php _e('تنظیمات قیمت‌یار', 'sodino'); ?></h1>
<div class="notice notice-info">
<p><?php _e('در اینجا تنظیمات افزونه در آینده قرار خواهد گرفت.', 'sodino'); ?></p>
<div id="sodino-app" class="min-h-screen bg-gray-50" dir="rtl">
<!-- Header -->
<div class="bg-white border-b border-gray-200">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="py-6">
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold text-gray-900"><?php _e('سودینو', 'sodino'); ?></h1>
<p class="mt-1 text-sm text-gray-500"><?php _e('بهینه‌سازی هوشمند فروش', 'sodino'); ?></p>
</div>
</div>
</div>
</div>
</div>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<div class="flex gap-8">
<!-- Sidebar -->
<aside class="w-64 flex-shrink-0">
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<h2 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('منوی سودینو', 'sodino'); ?></h2>
<nav class="space-y-2">
<a href="<?php echo admin_url('admin.php?page=sodino-dashboard'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-dashboard' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('داشبورد', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-rules'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-rules' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قوانین', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-rule'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-rule' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن قانون', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-upsells'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-upsells' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('آپسل (پیشنهاد فروش)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-upsell'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-upsell' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن آپسل', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-competitor-price'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-competitor-price' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قیمت رقبا (به‌زودی)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-settings'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-settings' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('تنظیمات', 'sodino'); ?>
</a>
</nav>
</div>
</aside>
<!-- Main Content -->
<main class="flex-1 min-w-0">
<!-- Page Header -->
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6 mb-8">
<h2 class="text-2xl font-semibold text-gray-900"><?php _e('تنظیمات سودینو', 'sodino'); ?></h2>
<p class="mt-2 text-gray-600"><?php _e('کنترل کامل تجربه قیمت‌گذاری و بهینه‌سازی درآمد را از اینجا انجام دهید.', 'sodino'); ?></p>
</div>
<?php if (isset($_GET['updated']) && $_GET['updated'] === 'true') : ?>
<div class="mb-6 bg-green-50 border border-green-200 rounded-lg p-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-green-400" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
</svg>
</div>
<div class="mr-3">
<p class="text-sm font-medium text-green-800"><?php _e('تنظیمات با موفقیت ذخیره شد.', 'sodino'); ?></p>
</div>
</div>
</div>
<?php endif; ?>
<form method="post" class="space-y-6">
<?php wp_nonce_field('sodino_save_settings', 'sodino_settings_nonce'); ?>
<!-- General Section -->
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<div class="mb-6">
<h3 class="text-lg font-semibold text-gray-900"><?php _e('عمومی', 'sodino'); ?></h3>
<p class="mt-1 text-sm text-gray-500"><?php _e('تنظیمات کلی فعال‌سازی پلاگین و ویژگی‌های اصلی.', 'sodino'); ?></p>
</div>
<div class="grid gap-6 md:grid-cols-2">
<div class="bg-gray-50 rounded-lg p-5 border border-gray-200">
<label class="flex items-center gap-3 text-gray-700">
<input type="checkbox" name="plugin_enabled" value="1" <?php checked($settings['plugin_enabled'], 1); ?> class="h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<span><?php _e('فعال‌سازی کل پلاگین', 'sodino'); ?></span>
</label>
<p class="mt-3 text-sm text-gray-500"><?php _e('اگر غیرفعال باشد، هیچ قاعده‌ای اعمال نخواهد شد.', 'sodino'); ?></p>
</div>
<div class="bg-gray-50 rounded-lg p-5 border border-gray-200">
<label class="flex items-center gap-3 text-gray-700">
<input type="checkbox" name="pricing_enabled" value="1" <?php checked($settings['pricing_enabled'], 1); ?> class="h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<span><?php _e('فعال‌سازی قیمت‌گذاری پویا', 'sodino'); ?></span>
</label>
<p class="mt-3 text-sm text-gray-500"><?php _e('این گزینه، اعمال قوانین قیمت‌گذاری را کنترل می‌کند.', 'sodino'); ?></p>
</div>
<div class="bg-gray-50 rounded-lg p-5 border border-gray-200">
<label class="flex items-center gap-3 text-gray-700">
<input type="checkbox" name="upsell_enabled" value="1" <?php checked($settings['upsell_enabled'], 1); ?> class="h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<span><?php _e('فعال‌سازی سیستم آپسل', 'sodino'); ?></span>
</label>
<p class="mt-3 text-sm text-gray-500"><?php _e('پیشنهادهای درآمدی اضافه را نمایش می‌دهد.', 'sodino'); ?></p>
</div>
</div>
</div>
<!-- Pricing Behavior Section -->
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<div class="mb-6">
<h3 class="text-lg font-semibold text-gray-900"><?php _e('رفتار قیمت‌گذاری', 'sodino'); ?></h3>
<p class="mt-1 text-sm text-gray-500"><?php _e('چگونگی اجرای قوانین در فرآیند قیمت‌گذاری.', 'sodino'); ?></p>
</div>
<div class="grid gap-6 md:grid-cols-2">
<div class="bg-gray-50 rounded-lg p-5 border border-gray-200">
<label class="flex items-center gap-3 text-gray-700">
<input type="checkbox" name="allow_multiple_rules" value="1" <?php checked($settings['allow_multiple_rules'], 1); ?> class="h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<span><?php _e('اجازه اعمال چند قانون همزمان', 'sodino'); ?></span>
</label>
<p class="mt-3 text-sm text-gray-500"><?php _e('قوانین معتبر به صورت متوالی اعمال می‌شوند.', 'sodino'); ?></p>
</div>
<div class="bg-gray-50 rounded-lg p-5 border border-gray-200">
<label class="block text-sm font-medium text-gray-700 mb-3"><?php _e('استراتژی اعمال', 'sodino'); ?></label>
<select name="strategy" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<option value="highest_discount" <?php selected($settings['strategy'], 'highest_discount'); ?>><?php _e('بالاترین تخفیف', 'sodino'); ?></option>
<option value="first_valid" <?php selected($settings['strategy'], 'first_valid'); ?>><?php _e('اولین قانون معتبر', 'sodino'); ?></option>
<option value="priority" <?php selected($settings['strategy'], 'priority'); ?>><?php _e('بر اساس اولویت', 'sodino'); ?></option>
</select>
<p class="mt-3 text-sm text-gray-500"><?php _e('استراتژی انتخاب قانون زمانی که بیش از یک قانون معتبر وجود داشته باشد.', 'sodino'); ?></p>
</div>
</div>
</div>
<!-- Limits Section -->
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<div class="mb-6">
<h3 class="text-lg font-semibold text-gray-900"><?php _e('محدودیت‌ها', 'sodino'); ?></h3>
<p class="mt-1 text-sm text-gray-500"><?php _e('پارامترهای محدودسازی برای حفظ حاشیه سود.', 'sodino'); ?></p>
</div>
<div class="grid gap-6 md:grid-cols-2">
<div class="bg-gray-50 rounded-lg p-5 border border-gray-200">
<label class="block text-sm font-medium text-gray-700 mb-3"><?php _e('حداکثر درصد تخفیف', 'sodino'); ?></label>
<input type="number" name="max_discount_percent" value="<?php echo esc_attr($settings['max_discount_percent']); ?>" min="0" max="100" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<p class="mt-3 text-sm text-gray-500"><?php _e('حداکثر تخفیف مجاز برای هر محصول را تعیین می‌کند.', 'sodino'); ?></p>
</div>
<div class="bg-gray-50 rounded-lg p-5 border border-gray-200">
<label class="block text-sm font-medium text-gray-700 mb-3"><?php _e('حداقل قیمت محصول', 'sodino'); ?></label>
<input type="number" name="min_product_price" value="<?php echo esc_attr($settings['min_product_price']); ?>" min="0" step="0.01" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<p class="mt-3 text-sm text-gray-500"><?php _e('از کاهش قیمت زیر این مقدار جلوگیری می‌کند.', 'sodino'); ?></p>
</div>
</div>
</div>
<!-- Features Section -->
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<div class="mb-6">
<h3 class="text-lg font-semibold text-gray-900"><?php _e('ویژگی‌ها', 'sodino'); ?></h3>
<p class="mt-1 text-sm text-gray-500"><?php _e('گزینه‌های پیشرفته برای شخصی‌سازی رفتار درآمدی.', 'sodino'); ?></p>
</div>
<div class="grid gap-6 md:grid-cols-2">
<div class="bg-gray-50 rounded-lg p-5 border border-gray-200">
<label class="flex items-center gap-3 text-gray-700">
<input type="checkbox" name="ab_testing_enabled" value="1" <?php checked($settings['ab_testing_enabled'], 1); ?> class="h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<span><?php _e('فعال‌سازی تست A/B', 'sodino'); ?></span>
</label>
<p class="mt-3 text-sm text-gray-500"><?php _e('امکان فعال‌سازی سناریوهای آزمایشی را اضافه می‌کند.', 'sodino'); ?></p>
</div>
<div class="bg-gray-50 rounded-lg p-5 border border-gray-200">
<label class="flex items-center gap-3 text-gray-700">
<input type="checkbox" name="cart_pricing_enabled" value="1" <?php checked($settings['cart_pricing_enabled'], 1); ?> class="h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<span><?php _e('اعمال قیمت‌گذاری در سبد خرید', 'sodino'); ?></span>
</label>
<p class="mt-3 text-sm text-gray-500"><?php _e('در صورت خاموش بودن، قیمت‌گذاری پویا فقط در نمایش محصول انجام می‌شود.', 'sodino'); ?></p>
</div>
<div class="bg-gray-50 rounded-lg p-5 border border-gray-200">
<label class="flex items-center gap-3 text-gray-700">
<input type="checkbox" name="scheduled_campaigns_enabled" value="1" <?php checked($settings['scheduled_campaigns_enabled'], 1); ?> class="h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<span><?php _e('فعال‌سازی کمپین‌های زمان‌بندی شده', 'sodino'); ?></span>
</label>
<p class="mt-3 text-sm text-gray-500"><?php _e('با فعال کردن، می‌توانید قوانین را به صورت زمان‌بندی‌شده اجرا کنید.', 'sodino'); ?></p>
</div>
</div>
</div>
<!-- Submit Button -->
<div class="flex justify-end">
<button type="submit" class="inline-flex items-center px-6 py-3 border border-transparent text-sm font-medium rounded-lg text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-200">
<?php _e('ذخیره تنظیمات', 'sodino'); ?>
</button>
</div>
</form>
</main>
</div>
</div>
</div>

187
admin/views/upsell-form.php Normal file
View File

@@ -0,0 +1,187 @@
<?php
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
$current_page = sanitize_text_field($_GET['page'] ?? 'sodino-add-upsell');
$trigger_product = null;
$trigger_product_label = '';
$target_product = null;
$target_product_label = '';
if ($upsell->trigger_type === 'product' && $upsell->trigger_value) {
$trigger_product = wc_get_product(intval($upsell->trigger_value));
$trigger_product_label = $trigger_product ? $trigger_product->get_name() : '';
}
if ($upsell->target_product_id) {
$target_product = wc_get_product($upsell->target_product_id);
$target_product_label = $target_product ? $target_product->get_name() : '';
}
$product_categories = get_terms([
'taxonomy' => 'product_cat',
'hide_empty' => false,
]);
?>
<div id="sodino-app" class="min-h-screen bg-gray-50" dir="rtl">
<div class="bg-white border-b border-gray-200">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="py-6">
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold text-gray-900"><?php _e('سودینو', 'sodino'); ?></h1>
<p class="mt-1 text-sm text-gray-500"><?php _e('بهینه‌سازی هوشمند فروش', 'sodino'); ?></p>
</div>
</div>
</div>
</div>
</div>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<div class="flex gap-8">
<aside class="w-64 flex-shrink-0">
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<h2 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('منوی سودینو', 'sodino'); ?></h2>
<nav class="space-y-2">
<a href="<?php echo admin_url('admin.php?page=sodino-dashboard'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-dashboard' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('داشبورد', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-rules'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-rules' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قوانین', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-rule'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-rule' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن قانون', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-upsells'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-upsells' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('آپسل (پیشنهاد فروش)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-upsell'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-upsell' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن آپسل', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-competitor-price'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-competitor-price' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قیمت رقبا (به‌زودی)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-settings'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-settings' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('تنظیمات', 'sodino'); ?>
</a>
</nav>
</div>
</aside>
<main class="flex-1 min-w-0">
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6 mb-8">
<div class="flex items-center justify-between gap-4 flex-col sm:flex-row sm:items-center">
<div>
<h2 class="text-2xl font-semibold text-gray-900"><?php echo $upsell->id ? __('ویرایش آپسل', 'sodino') : __('افزودن آپسل جدید', 'sodino'); ?></h2>
<p class="mt-2 text-gray-600"><?php _e('یک پیشنهاد فروش مکمل هوشمند برای مشتریان ایجاد یا ویرایش کنید.', 'sodino'); ?></p>
</div>
<a href="<?php echo admin_url('admin.php?page=sodino-upsells'); ?>" class="inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-lg text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-200">
<?php _e('بازگشت به آپسل‌ها', 'sodino'); ?>
</a>
</div>
</div>
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<form method="post" class="space-y-6">
<?php wp_nonce_field('sodino_save_upsell', 'sodino_upsell_nonce'); ?>
<div class="grid gap-6 md:grid-cols-2">
<div class="md:col-span-2">
<label for="title" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('عنوان', 'sodino'); ?></label>
<input type="text" name="title" id="title" value="<?php echo esc_attr($upsell->title); ?>" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" required>
</div>
<div class="md:col-span-2">
<label class="block text-sm font-medium text-gray-700 mb-2"><?php _e('نوع شرط', 'sodino'); ?></label>
<div class="space-y-3">
<label class="flex items-center gap-3 rounded-lg border border-gray-200 bg-white px-4 py-3 cursor-pointer hover:border-blue-300">
<input type="radio" name="trigger_type" value="product" class="trigger-type" <?php checked($upsell->trigger_type, 'product'); ?>>
<span><?php _e('محصول خاص', 'sodino'); ?></span>
</label>
<label class="flex items-center gap-3 rounded-lg border border-gray-200 bg-white px-4 py-3 cursor-pointer hover:border-blue-300">
<input type="radio" name="trigger_type" value="category" class="trigger-type" <?php checked($upsell->trigger_type, 'category'); ?>>
<span><?php _e('دسته‌بندی', 'sodino'); ?></span>
</label>
<label class="flex items-center gap-3 rounded-lg border border-gray-200 bg-white px-4 py-3 cursor-pointer hover:border-blue-300">
<input type="radio" name="trigger_type" value="cart_total" class="trigger-type" <?php checked($upsell->trigger_type, 'cart_total'); ?>>
<span><?php _e('مبلغ سبد خرید', 'sodino'); ?></span>
</label>
</div>
</div>
<input type="hidden" name="trigger_value" id="trigger_value" value="<?php echo esc_attr($upsell->trigger_value); ?>">
<div id="trigger-product-wrapper" class="md:col-span-2 <?php echo $upsell->trigger_type === 'product' ? '' : 'hidden'; ?>">
<label for="trigger_product_search" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('محصول فعال‌ساز', 'sodino'); ?></label>
<div class="relative">
<input type="text" id="trigger_product_search" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" placeholder="<?php _e('جستجوی محصول...', 'sodino'); ?>" value="<?php echo esc_attr($trigger_product_label); ?>">
<div id="trigger_product_results" class="absolute z-10 mt-1 w-full rounded-xl border border-gray-200 bg-white shadow-lg hidden"></div>
</div>
<p class="mt-2 text-sm text-gray-500"><?php _e('محصولی که باعث نمایش پیشنهاد آپسل می‌شود را انتخاب کنید.', 'sodino'); ?></p>
</div>
<div id="trigger-category-wrapper" class="md:col-span-2 <?php echo $upsell->trigger_type === 'category' ? '' : 'hidden'; ?>">
<label for="trigger_value_category" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('دسته‌بندی', 'sodino'); ?></label>
<select name="trigger_value" id="trigger_value_category" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<option value=""><?php _e('دسته‌بندی را انتخاب کنید', 'sodino'); ?></option>
<?php foreach ($product_categories as $category) : ?>
<option value="<?php echo esc_attr($category->term_id); ?>" <?php selected($upsell->trigger_type, 'category'); selected($upsell->trigger_value, $category->term_id); ?>><?php echo esc_html($category->name); ?></option>
<?php endforeach; ?>
</select>
</div>
<div id="trigger-amount-wrapper" class="md:col-span-2 <?php echo $upsell->trigger_type === 'cart_total' ? '' : 'hidden'; ?>">
<label for="trigger_value_amount" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('مبلغ سبد خرید', 'sodino'); ?></label>
<input type="number" name="trigger_value" id="trigger_value_amount" value="<?php echo esc_attr($upsell->trigger_type === 'cart_total' ? $upsell->trigger_value : ''); ?>" min="0" step="0.01" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
</div>
<div class="md:col-span-2">
<label for="target_product_search" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('محصول پیشنهادی', 'sodino'); ?></label>
<div class="relative">
<input type="hidden" name="target_product_id" id="target_product_id" value="<?php echo esc_attr($upsell->target_product_id); ?>">
<input type="text" id="target_product_search" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100" placeholder="<?php _e('جستجوی محصول پیشنهادی...', 'sodino'); ?>" value="<?php echo esc_attr($target_product_label); ?>">
<div id="target_product_results" class="absolute z-10 mt-1 w-full rounded-xl border border-gray-200 bg-white shadow-lg hidden"></div>
</div>
<p class="mt-2 text-sm text-gray-500"><?php _e('محصولی که به مشتری پیشنهاد می‌شود را انتخاب کنید.', 'sodino'); ?></p>
</div>
<div>
<label for="discount_type" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('نوع تخفیف', 'sodino'); ?></label>
<select name="discount_type" id="discount_type" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
<option value="percentage" <?php selected($upsell->discount_type, 'percentage'); ?>><?php _e('درصدی', 'sodino'); ?></option>
<option value="fixed" <?php selected($upsell->discount_type, 'fixed'); ?>><?php _e('مبلغ ثابت', 'sodino'); ?></option>
<option value="none" <?php selected($upsell->discount_type, 'none'); ?>><?php _e('بدون تخفیف', 'sodino'); ?></option>
</select>
</div>
<div>
<label for="discount_value" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('مقدار تخفیف', 'sodino'); ?></label>
<input type="number" name="discount_value" id="discount_value" value="<?php echo esc_attr($upsell->discount_value); ?>" min="0" step="0.01" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
</div>
<div>
<label for="priority" class="block text-sm font-medium text-gray-700 mb-2"><?php _e('اولویت', 'sodino'); ?></label>
<input type="number" name="priority" id="priority" value="<?php echo esc_attr($upsell->priority); ?>" min="1" class="w-full rounded-lg border border-gray-300 bg-white px-4 py-3 text-gray-700 shadow-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100">
</div>
<div class="md:col-span-2">
<label class="flex items-center gap-3 text-gray-700">
<input type="checkbox" name="status" id="status" value="1" <?php checked($upsell->status, 1); ?> class="h-5 w-5 rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<span><?php _e('فعال باشد', 'sodino'); ?></span>
</label>
</div>
</div>
<div class="flex justify-end">
<button type="submit" class="inline-flex items-center px-6 py-3 border border-transparent text-sm font-medium rounded-lg text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-200">
<?php echo $upsell->id ? __('ذخیره آپسل', 'sodino') : __('افزودن آپسل', 'sodino'); ?>
</button>
</div>
</form>
</div>
</main>
</div>
</div>
</div>

View File

@@ -0,0 +1,78 @@
<?php
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
$current_page = sanitize_text_field($_GET['page'] ?? 'sodino-upsells');
?>
<div id="sodino-app" class="min-h-screen bg-gray-50" dir="rtl">
<div class="bg-white border-b border-gray-200">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="py-6">
<div class="flex items-center justify-between">
<div>
<h1 class="text-3xl font-bold text-gray-900"><?php _e('سودینو', 'sodino'); ?></h1>
<p class="mt-1 text-sm text-gray-500"><?php _e('بهینه‌سازی هوشمند فروش', 'sodino'); ?></p>
</div>
</div>
</div>
</div>
</div>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<div class="flex gap-8">
<aside class="w-64 flex-shrink-0">
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6">
<h2 class="text-lg font-semibold text-gray-900 mb-4"><?php _e('منوی سودینو', 'sodino'); ?></h2>
<nav class="space-y-2">
<a href="<?php echo admin_url('admin.php?page=sodino-dashboard'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-dashboard' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('داشبورد', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-rules'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-rules' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قوانین', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-rule'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-rule' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن قانون', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-upsells'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-upsells' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('آپسل (پیشنهاد فروش)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-add-upsell'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-add-upsell' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('افزودن آپسل', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-competitor-price'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-competitor-price' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('قیمت رقبا (به‌زودی)', 'sodino'); ?>
</a>
<a href="<?php echo admin_url('admin.php?page=sodino-settings'); ?>" class="block px-3 py-2 rounded-md text-sm font-medium <?php echo $current_page === 'sodino-settings' ? 'bg-blue-50 text-blue-700 border-r-2 border-blue-700' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'; ?>">
<?php _e('تنظیمات', 'sodino'); ?>
</a>
</nav>
</div>
</aside>
<main class="flex-1 min-w-0">
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6 mb-8">
<div class="flex items-center justify-between gap-4 flex-col sm:flex-row sm:items-center">
<div>
<h2 class="text-2xl font-semibold text-gray-900"><?php _e('مدیریت آپسل‌ها', 'sodino'); ?></h2>
<p class="mt-2 text-gray-600"><?php _e('ایجاد، ویرایش و مدیریت پیشنهادهای فروش مکمل.', 'sodino'); ?></p>
</div>
<a href="<?php echo admin_url('admin.php?page=sodino-add-upsell'); ?>" class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-lg text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-200">
<svg class="-ml-1 mr-2 h-5 w-5" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" clip-rule="evenodd" />
</svg>
<?php _e('افزودن آپسل جدید', 'sodino'); ?>
</a>
</div>
</div>
<div class="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden">
<form method="post">
<?php $upsellTable->display(); ?>
</form>
</div>
</main>
</div>
</div>
</div>