PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.8.5
ووسلام – همگام سازی ووکامرس و باسلام v1.8.5
1.10.19 1.10.20 1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.2 1.9.1 1.9.0 1.8.8 1.8.5 1.8.6 All 53 releases
sync-basalam / includes / Admin / Product / elements / SingleProduct / PriceIncreaseField.php

PriceIncreaseField.php in ووسلام – همگام سازی ووکامرس و باسلام 1.8.5, at includes/Admin/Product/elements/SingleProduct/PriceIncreaseField.php

112 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SyncBasalam\Admin\Product\elements\SingleProduct;
4
5 defined('ABSPATH') || exit;
6
7 class PriceIncreaseField
8 {
9 public const META_KEY = '_sync_basalam_increase_price_value';
10
11 public static function renderField()
12 {
13 $value = get_post_meta(get_the_ID(), self::META_KEY, true);
14 $isCommission = $value === '-1';
15 $displayValue = '';
16
17 if (!$isCommission && $value !== '' && is_numeric($value)) {
18 $displayValue = number_format((int) $value, 0);
19 }
20
21 $unit = (!$isCommission && is_numeric($value) && (int) $value > 100) ? 'تو�
22 ان' : 'درصد';
23 $tooltip = 'اگر این فیلد را پر کنید، در ساخت payload به جای افزایش قی�
24 ت اصلی تنظی�
25 ات استفاده �
26 ی‌شود. خالی بگذارید تا ه�
27 ان تنظی�
28 اصلی اع�
29 ال شود. �
30 قدار ۱ تا ۱۰۰ درصد، بیشتر از ۱۰۰ �
31 بلغ ثابت تو�
32 انی، و گزینه «کار�
33 زد دسته‌بندی» �
34 عادل -۱ است.';
35 ?>
36 <p class="form-field _sync_basalam_increase_price_value_field basalam-form-group-full basalam-p basalam-increase-price-field" style="padding:12px !important;">
37 <span class="basalam-increase-price-field__label-section">
38 <span class="basalam-increase-price-field__header">
39 <label for="<?php echo esc_attr(self::META_KEY . '_display'); ?>">افزایش قی�
40 ت اختصاصی</label>
41 <span class="woocommerce-help-tip" tabindex="0" aria-label="<?php echo esc_attr($tooltip); ?>"></span>
42 </span>
43 </span>
44
45 <span class="basalam-increase-price-field__control-section">
46 <span class="basalam-input-container basalam-increase-price-field__input-row">
47 <input type="text"
48 id="<?php echo esc_attr(self::META_KEY . '_display'); ?>"
49 class="short basalam-input basalam-p percentage-input basalam-font-pelak-12"
50 data-role="increase-price-input"
51 value="<?php echo esc_attr($displayValue); ?>"
52 inputmode="numeric"
53 autocomplete="off"
54 style="flex:0.1 !important;"
55 <?php echo $isCommission ? 'disabled' : ''; ?>
56 >
57 <span class="percentage-unit basalam-p basalam-min-width-0 basalam-font-13"><?php echo esc_html($unit); ?></span>
58 </span>
59
60 <span class="basalam-increase-price-field__toggle-row">
61 <input type="checkbox"
62 id="<?php echo esc_attr(self::META_KEY . '_toggle'); ?>"
63 class="toggle-percentage"
64 <?php echo checked($isCommission, true, false); ?>
65 >
66 <label class="basalam-font-10" for="<?php echo esc_attr(self::META_KEY . '_toggle'); ?>">کار�
67 زد دسته‌بندی</label>
68 </span>
69 </span>
70
71 <input type="hidden"
72 id="<?php echo esc_attr(self::META_KEY); ?>"
73 name="<?php echo esc_attr(self::META_KEY); ?>"
74 data-role="increase-price-hidden"
75 value="<?php echo esc_attr($value); ?>"
76 >
77 </p>
78 <?php
79 wp_nonce_field('sync_basalam_save_price_increase_action', '_sync_basalam_price_increase_nonce');
80 }
81
82 public static function saveField($postId)
83 {
84 if (
85 !isset($_POST['_sync_basalam_price_increase_nonce'])
86 || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_sync_basalam_price_increase_nonce'])), 'sync_basalam_save_price_increase_action')
87 ) {
88 return;
89 }
90
91 if (!isset($_POST[self::META_KEY])) {
92 delete_post_meta($postId, self::META_KEY);
93
94 return;
95 }
96
97 $rawValue = sanitize_text_field(wp_unslash($_POST[self::META_KEY]));
98
99 if ($rawValue === '') {
100 delete_post_meta($postId, self::META_KEY);
101
102 return;
103 }
104
105 if (!is_numeric($rawValue)) {
106 return;
107 }
108
109 update_post_meta($postId, self::META_KEY, (string) intval($rawValue));
110 }
111 }
112