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

@@ -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>