feat(Core): add optimize and complete code

This commit is contained in:
2026-05-17 20:05:15 +03:30
parent aa944bf339
commit 4e60b7efdd
25 changed files with 858 additions and 54 deletions

80
admin/views/templates.php Normal file
View File

@@ -0,0 +1,80 @@
<?php
// Prevent direct access
if (!defined('ABSPATH')) {
exit;
}
$current_page = 'sodino-templates';
require_once SODINO_PLUGIN_DIR . 'admin/components/layout.php';
sodino_admin_layout($current_page, function() use ($ruleTemplates, $upsellTemplates) {
?>
<div class="bg-white rounded-lg shadow-sm border border-gray-200 p-6 mb-8">
<div class="flex flex-col gap-4 lg:flex-row lg:items-center lg: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>
</div>
</div>
<section class="mb-8">
<div class="mb-4">
<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-4 lg:grid-cols-2">
<?php foreach ($ruleTemplates as $key => $template) : ?>
<article class="bg-white rounded-lg border border-gray-200 p-5 shadow-sm">
<div class="flex h-full flex-col justify-between gap-5">
<div>
<h4 class="text-base font-semibold text-gray-900"><?php echo esc_html($template['title']); ?></h4>
<p class="mt-2 text-sm leading-6 text-gray-600"><?php echo esc_html($template['description']); ?></p>
<div class="mt-4 flex flex-wrap gap-2">
<?php foreach ((array) $template['actions'] as $action) : ?>
<span class="rounded-full bg-blue-50 px-3 py-1 text-xs font-medium text-blue-700">
<?php echo esc_html(sprintf('%s: %s', $action['type'], $action['value'])); ?>
</span>
<?php endforeach; ?>
</div>
</div>
<a href="<?php echo esc_url(admin_url('admin.php?page=sodino-add-rule&template=' . $key)); ?>" class="inline-flex items-center justify-center rounded-lg bg-blue-600 px-4 py-2 text-sm font-semibold text-white hover:bg-blue-700">
<?php _e('استفاده از قالب', 'sodino'); ?>
</a>
</div>
</article>
<?php endforeach; ?>
</div>
</section>
<section>
<div class="mb-4">
<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-4 lg:grid-cols-2">
<?php foreach ($upsellTemplates as $key => $template) : ?>
<article class="bg-white rounded-lg border border-gray-200 p-5 shadow-sm">
<div class="flex h-full flex-col justify-between gap-5">
<div>
<h4 class="text-base font-semibold text-gray-900"><?php echo esc_html($template['title']); ?></h4>
<p class="mt-2 text-sm leading-6 text-gray-600"><?php echo esc_html($template['description']); ?></p>
<div class="mt-4 flex flex-wrap gap-2">
<span class="rounded-full bg-emerald-50 px-3 py-1 text-xs font-medium text-emerald-700">
<?php echo esc_html(sprintf(__('تخفیف پیش‌فرض: %s%%', 'sodino'), $template['discount_value'])); ?>
</span>
</div>
</div>
<a href="<?php echo esc_url(admin_url('admin.php?page=sodino-add-upsell&template=' . $key)); ?>" class="inline-flex items-center justify-center rounded-lg bg-emerald-600 px-4 py-2 text-sm font-semibold text-white hover:bg-emerald-700">
<?php _e('ساخت آپسل از قالب', 'sodino'); ?>
</a>
</div>
</article>
<?php endforeach; ?>
</div>
</section>
<?php
});
?>