⚙️ تنظیمات افزونه ووکارت
";
// ذخیره تنظیمات
if (isset($_POST['save_settings'])) {
// شمارههای مجاز برای ارسال رایگان
$phones_raw = sanitize_text_field($_POST['allowed_phones']);
$phones = array_map('trim', explode(',', $phones_raw));
update_option('free_shipping_allowed_phones', $phones);
// تعداد سفارش پیشفرض برای مشتری وفادار
update_option('woo_cart_loyalty_threshold', intval($_POST['loyalty_threshold']));
// زمان ارسال پیامک
update_option('woo_cart_sms_time', sanitize_text_field($_POST['sms_time']));
// اطلاعات پنل پیامک
update_option('woo_cart_sms_username', sanitize_text_field($_POST['sms_username']));
update_option('woo_cart_sms_password', sanitize_text_field($_POST['sms_password']));
update_option('woo_cart_sms_pattern', sanitize_text_field($_POST['sms_pattern']));
update_option('woo_cart_sms_service_type', sanitize_text_field($_POST['sms_service_type'])); // normal یا خدماتی
// درصد تخفیف پیشفرض
update_option('woo_cart_default_discount_percent', intval($_POST['default_discount_percent']));
echo "
✅ تنظیمات با موفقیت ذخیره شد.
";
}
// دریافت تنظیمات ذخیرهشده
$phones_str = implode(',', get_option('free_shipping_allowed_phones', []));
$loyalty_threshold = get_option('woo_cart_loyalty_threshold', 3);
$sms_time = get_option('woo_cart_sms_time', '10:00');
$sms_username = get_option('woo_cart_sms_username', '');
$sms_password = get_option('woo_cart_sms_password', '');
$sms_pattern = get_option('woo_cart_sms_pattern', '');
$sms_service_type = get_option('woo_cart_sms_service_type', 'normal');
$default_discount = get_option('woo_cart_default_discount_percent', 10);
// فرم تنظیمات
echo "
";
// تست پیامک
echo "
📨 تست ارسال پیامک
";
if (isset($_POST['send_test_sms'])) {
$test_phone = sanitize_text_field($_POST['test_phone']);
woo_cart_send_sms($test_phone, "این یک پیامک تستی از افزونه ووکارت است.");
echo "
پیامک تستی ارسال شد به شماره $test_phone
";
}
echo "
";
}