feat(Rule): add new rules
This commit is contained in:
33
admin/views/partials/rule-action-row.php
Normal file
33
admin/views/partials/rule-action-row.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$action_type = $action['type'] ?? 'discount_percent';
|
||||
$action_value = $action['value'] ?? 0;
|
||||
?>
|
||||
<div class="sodino-rule-row rounded-lg border border-gray-200 bg-gray-50 p-4" data-row>
|
||||
<div class="grid gap-4 lg:grid-cols-[1.5fr_1fr_auto]">
|
||||
<div>
|
||||
<label class="block text-xs font-semibold text-gray-500 mb-2"><?php _e('نوع عملیات', 'sodino'); ?></label>
|
||||
<select name="actions[<?php echo esc_attr($index); ?>][type]" class="w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-gray-700">
|
||||
<option value="discount_percent" <?php selected($action_type, 'discount_percent'); ?>><?php _e('تخفیف درصدی', 'sodino'); ?></option>
|
||||
<option value="discount_fixed" <?php selected($action_type, 'discount_fixed'); ?>><?php _e('تخفیف ثابت', 'sodino'); ?></option>
|
||||
<option value="set_price" <?php selected($action_type, 'set_price'); ?>><?php _e('تنظیم قیمت ثابت', 'sodino'); ?></option>
|
||||
<option value="increase_percent" <?php selected($action_type, 'increase_percent'); ?>><?php _e('افزایش درصدی قیمت', 'sodino'); ?></option>
|
||||
<option value="increase_fixed" <?php selected($action_type, 'increase_fixed'); ?>><?php _e('افزایش ثابت قیمت', 'sodino'); ?></option>
|
||||
<option value="free_shipping" <?php selected($action_type, 'free_shipping'); ?>><?php _e('ارسال رایگان', 'sodino'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-xs font-semibold text-gray-500 mb-2"><?php _e('مقدار', 'sodino'); ?></label>
|
||||
<input type="number" name="actions[<?php echo esc_attr($index); ?>][value]" value="<?php echo esc_attr($action_value); ?>" min="0" step="0.01" class="w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-gray-700">
|
||||
<p class="mt-2 text-xs text-gray-500"><?php _e('برای ارسال رایگان میتواند 0 بماند.', 'sodino'); ?></p>
|
||||
</div>
|
||||
|
||||
<div class="flex items-end">
|
||||
<button type="button" class="sodino-remove-row rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm font-semibold text-red-700 hover:bg-red-100"><?php _e('حذف', 'sodino'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
53
admin/views/partials/rule-condition-row.php
Normal file
53
admin/views/partials/rule-condition-row.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
if (!defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$condition_type = $condition['type'] ?? 'user_type';
|
||||
$condition_operator = $condition['operator'] ?? 'is';
|
||||
$condition_value = $condition['value'] ?? '';
|
||||
?>
|
||||
<div class="sodino-rule-row rounded-lg border border-gray-200 bg-gray-50 p-4" data-row>
|
||||
<div class="grid gap-4 lg:grid-cols-[1.2fr_1fr_1.5fr_auto]">
|
||||
<div>
|
||||
<label class="block text-xs font-semibold text-gray-500 mb-2"><?php _e('نوع شرط', 'sodino'); ?></label>
|
||||
<select name="conditions[<?php echo esc_attr($index); ?>][type]" class="sodino-condition-type w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-gray-700">
|
||||
<option value="user_type" <?php selected($condition_type, 'user_type'); ?>><?php _e('نوع کاربر', 'sodino'); ?></option>
|
||||
<option value="product_ids" <?php selected($condition_type, 'product_ids'); ?>><?php _e('محصولات خاص', 'sodino'); ?></option>
|
||||
<option value="exclude_product_ids" <?php selected($condition_type, 'exclude_product_ids'); ?>><?php _e('بهجز محصولات', 'sodino'); ?></option>
|
||||
<option value="product_category" <?php selected($condition_type, 'product_category'); ?>><?php _e('دستهبندی محصول', 'sodino'); ?></option>
|
||||
<option value="exclude_product_category" <?php selected($condition_type, 'exclude_product_category'); ?>><?php _e('بهجز دستهبندی', 'sodino'); ?></option>
|
||||
<option value="product_tag" <?php selected($condition_type, 'product_tag'); ?>><?php _e('برچسب محصول', 'sodino'); ?></option>
|
||||
<option value="cart_total_min" <?php selected($condition_type, 'cart_total_min'); ?>><?php _e('حداقل مبلغ سبد', 'sodino'); ?></option>
|
||||
<option value="cart_total_max" <?php selected($condition_type, 'cart_total_max'); ?>><?php _e('حداکثر مبلغ سبد', 'sodino'); ?></option>
|
||||
<option value="cart_item_count_min" <?php selected($condition_type, 'cart_item_count_min'); ?>><?php _e('حداقل تعداد آیتم سبد', 'sodino'); ?></option>
|
||||
<option value="cart_item_count_max" <?php selected($condition_type, 'cart_item_count_max'); ?>><?php _e('حداکثر تعداد آیتم سبد', 'sodino'); ?></option>
|
||||
<option value="cart_contains_product" <?php selected($condition_type, 'cart_contains_product'); ?>><?php _e('سبد شامل محصول', 'sodino'); ?></option>
|
||||
<option value="cart_contains_category" <?php selected($condition_type, 'cart_contains_category'); ?>><?php _e('سبد شامل دستهبندی', 'sodino'); ?></option>
|
||||
<option value="customer_order_count_min" <?php selected($condition_type, 'customer_order_count_min'); ?>><?php _e('حداقل سفارش مشتری', 'sodino'); ?></option>
|
||||
<option value="customer_order_count_max" <?php selected($condition_type, 'customer_order_count_max'); ?>><?php _e('حداکثر سفارش مشتری', 'sodino'); ?></option>
|
||||
<option value="day_of_week" <?php selected($condition_type, 'day_of_week'); ?>><?php _e('روز هفته', 'sodino'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-xs font-semibold text-gray-500 mb-2"><?php _e('عملگر', 'sodino'); ?></label>
|
||||
<select name="conditions[<?php echo esc_attr($index); ?>][operator]" class="w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-gray-700">
|
||||
<option value="is" <?php selected($condition_operator, 'is'); ?>><?php _e('برابر است با', 'sodino'); ?></option>
|
||||
<option value="is_not" <?php selected($condition_operator, 'is_not'); ?>><?php _e('برابر نیست با', 'sodino'); ?></option>
|
||||
<option value="in" <?php selected($condition_operator, 'in'); ?>><?php _e('داخل لیست است', 'sodino'); ?></option>
|
||||
<option value="not_in" <?php selected($condition_operator, 'not_in'); ?>><?php _e('داخل لیست نیست', 'sodino'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-xs font-semibold text-gray-500 mb-2"><?php _e('مقدار', 'sodino'); ?></label>
|
||||
<input type="text" name="conditions[<?php echo esc_attr($index); ?>][value]" value="<?php echo esc_attr(is_array($condition_value) ? implode(',', $condition_value) : $condition_value); ?>" class="w-full rounded-lg border border-gray-300 bg-white px-3 py-2 text-gray-700" placeholder="<?php esc_attr_e('مثال: new یا 12,18,24', 'sodino'); ?>">
|
||||
<p class="mt-2 text-xs text-gray-500"><?php _e('برای چند مقدار، شناسهها را با کاما جدا کنید. نوع کاربر: guest, new, returning, logged_in', 'sodino'); ?></p>
|
||||
</div>
|
||||
|
||||
<div class="flex items-end">
|
||||
<button type="button" class="sodino-remove-row rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm font-semibold text-red-700 hover:bg-red-100"><?php _e('حذف', 'sodino'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user