| 1 |
<?php |
| 2 |
|
| 3 |
namespace SyncBasalam\Admin\Components; |
| 4 |
|
| 5 |
use SyncBasalam\Admin\Settings\SettingsConfig; |
| 6 |
use SyncBasalam\Utilities\PriceAdjustment; |
| 7 |
|
| 8 |
defined('ABSPATH') || exit; |
| 9 |
|
| 10 |
class SettingPageComponents |
| 11 |
{ |
| 12 |
public static function renderDeleteAccess() |
| 13 |
{ |
| 14 |
echo '<input type="hidden" name="sync_basalam_settings[' . esc_attr(SettingsConfig::TOKEN) . ']" value="">' |
| 15 |
. '<input type="hidden" name="sync_basalam_settings[' . esc_attr(SettingsConfig::REFRESH_TOKEN) . ']" value="">'; |
| 16 |
} |
| 17 |
|
| 18 |
public static function syncStatusProduct() |
| 19 |
{ |
| 20 |
$value = syncBasalamSettings()->getSettings(SettingsConfig::SYNC_STATUS_PRODUCT) == true ? false : true; |
| 21 |
echo '<input type="hidden" name="sync_basalam_settings[' . esc_attr(SettingsConfig::SYNC_STATUS_PRODUCT) . ']" value="' . esc_attr($value) . '">'; |
| 22 |
} |
| 23 |
|
| 24 |
public static function syncStatusOrder() |
| 25 |
{ |
| 26 |
$value = syncBasalamSettings()->getSettings(SettingsConfig::SYNC_STATUS_ORDER) == true ? false : true; |
| 27 |
echo '<input type="hidden" name="sync_basalam_settings[' . esc_attr(SettingsConfig::SYNC_STATUS_ORDER) . ']" value="' . esc_attr($value) . '">'; |
| 28 |
} |
| 29 |
|
| 30 |
public static function renderAutoConfirmOrderButton() |
| 31 |
{ |
| 32 |
$value = syncBasalamSettings()->getSettings(SettingsConfig::AUTO_CONFIRM_ORDER) == true ? false : true; |
| 33 |
echo '<input type="hidden" name="sync_basalam_settings[' . esc_attr(SettingsConfig::AUTO_CONFIRM_ORDER) . ']" value="' . esc_attr($value) . '">'; |
| 34 |
} |
| 35 |
|
| 36 |
public static function renderDefaultWeight() |
| 37 |
{ |
| 38 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::DEFAULT_WEIGHT); |
| 39 |
echo '<input type="number" name="sync_basalam_settings[' . esc_attr(SettingsConfig::DEFAULT_WEIGHT) . ']" min="50" value="' . esc_attr($current_value) . '" class="basalam-input basalam-p" required>'; |
| 40 |
} |
| 41 |
|
| 42 |
public static function renderPackageWeight() |
| 43 |
{ |
| 44 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::DEFAULT_PACKAGE_WEIGHT); |
| 45 |
echo '<input type="number" name="sync_basalam_settings[' . esc_attr(SettingsConfig::DEFAULT_PACKAGE_WEIGHT) . ']" min="1" value="' . esc_attr($current_value) . '" class="basalam-input basalam-p" required>'; |
| 46 |
} |
| 47 |
|
| 48 |
public static function renderDefaultPreparation() |
| 49 |
{ |
| 50 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::DEFAULT_PREPARATION); |
| 51 |
echo '<input type="number" name="sync_basalam_settings[' . esc_attr(SettingsConfig::DEFAULT_PREPARATION) . ']" min="0" value="' . esc_attr($current_value) . '" class="basalam-input basalam-p" required>'; |
| 52 |
} |
| 53 |
|
| 54 |
public static function renderCapPreparationToCategoryMax() |
| 55 |
{ |
| 56 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::CAP_PREPARATION_TO_CATEGORY_MAX); |
| 57 |
echo '<select class="basalam-select basalam-select-center" name="sync_basalam_settings[' . esc_attr(SettingsConfig::CAP_PREPARATION_TO_CATEGORY_MAX) . ']">' |
| 58 |
. '<option value="yes"' . selected($current_value, 'yes', false) . '>کاهش به حداکثر � |
| 59 |
جاز</option>' |
| 60 |
. '<option value="no"' . selected($current_value, 'no', false) . '>عد� |
| 61 |
ارسال</option>' |
| 62 |
. '</select>'; |
| 63 |
} |
| 64 |
|
| 65 |
public static function renderDefaultStockQuantity() |
| 66 |
{ |
| 67 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::DEFAULT_STOCK_QUANTITY); |
| 68 |
echo '<input type="number" name="sync_basalam_settings[' . esc_attr(SettingsConfig::DEFAULT_STOCK_QUANTITY) . ']" min="0" value="' . esc_attr($current_value) . '" class="basalam-input basalam-p" required>'; |
| 69 |
} |
| 70 |
|
| 71 |
public static function renderSafeStock() |
| 72 |
{ |
| 73 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::SAFE_STOCK); |
| 74 |
echo '<input type="number" name="sync_basalam_settings[' . esc_attr(SettingsConfig::SAFE_STOCK) . ']" min="0" value="' . esc_attr($current_value) . '" class="basalam-input basalam-p" required>'; |
| 75 |
} |
| 76 |
|
| 77 |
public static function renderVariableProductStockSource() |
| 78 |
{ |
| 79 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::VARIABLE_PRODUCT_STOCK_SOURCE); |
| 80 |
|
| 81 |
echo '<select class="basalam-select basalam-select-center" name="sync_basalam_settings[' . esc_attr(SettingsConfig::VARIABLE_PRODUCT_STOCK_SOURCE) . ']">' |
| 82 |
. '<option value="variation"' . selected($current_value, 'variation', false) . '>� |
| 83 |
وجودی � |
| 84 |
تغیرها</option>' |
| 85 |
. '<option value="product"' . selected($current_value, 'product', false) . '>� |
| 86 |
وجودی والد</option>' |
| 87 |
. '</select>'; |
| 88 |
} |
| 89 |
|
| 90 |
public static function renderPriceChange() |
| 91 |
{ |
| 92 |
static $priceChangeControlIndex = 0; |
| 93 |
$priceChangeControlIndex++; |
| 94 |
|
| 95 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::PRICE_CHANGE_VALUE); |
| 96 |
$is_commission = PriceAdjustment::isCommission($current_value); |
| 97 |
$is_checked = $is_commission ? 'checked' : ''; |
| 98 |
$input_disabled = $is_commission ? 'disabled' : ''; |
| 99 |
$input_value = $is_commission || !is_numeric($current_value) ? '' : number_format((int) $current_value); |
| 100 |
$checkbox_id = 'toggle-percentage-' . $priceChangeControlIndex; |
| 101 |
$hidden_input_id = 'price-change-value-' . $priceChangeControlIndex; |
| 102 |
$text_input_id = 'price-change-input-' . $priceChangeControlIndex; |
| 103 |
|
| 104 |
echo '<div class="basalam-input-container">'; |
| 105 |
echo '<input type="text" id="' . esc_attr($text_input_id) . '" data-role="price-change-input" name="sync_basalam_settings[' . esc_attr(SettingsConfig::PRICE_CHANGE_VALUE) . ']" value="' . esc_attr($input_value) . '" class="basalam-input basalam-p percentage-input" inputmode="text" autocomplete="off" ' . esc_attr($input_disabled) . ' required>'; |
| 106 |
echo '<span class="percentage-unit basalam-p basalam-min-width-0 basalam-font-13">' . esc_html(PriceAdjustment::unitLabel($current_value)) . '</span>'; |
| 107 |
echo '</div>'; |
| 108 |
|
| 109 |
echo '<div class="basalam-flex-end-gap-4 basalam-margin-top-8">'; |
| 110 |
echo '<input type="checkbox" id="' . esc_attr($checkbox_id) . '" class="toggle-percentage" name="toggle_percentage" ' . esc_attr($is_checked) . '>'; |
| 111 |
echo '<label class="basalam-font-10" for="' . esc_attr($checkbox_id) . '">کار� |
| 112 |
زد دستهبندی</label>'; |
| 113 |
echo '</div>'; |
| 114 |
|
| 115 |
echo '<input type="hidden" id="' . esc_attr($hidden_input_id) . '" data-role="price-change-hidden" name="sync_basalam_settings[' . esc_attr(SettingsConfig::PRICE_CHANGE_VALUE) . ']" value="' . esc_attr($current_value) . '">'; |
| 116 |
} |
| 117 |
|
| 118 |
public static function renderDefaultRound() |
| 119 |
{ |
| 120 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::ROUND_PRICE); |
| 121 |
echo '<select class="basalam-select basalam-select-center" name="sync_basalam_settings[' . esc_attr(SettingsConfig::ROUND_PRICE) . ']">' |
| 122 |
. '<option value="none"' . selected($current_value, "none", false) . '>رند نکردن</option>' |
| 123 |
. '<option value="up"' . selected($current_value, "up", false) . '>بالا</option>' |
| 124 |
. '<option value="down"' . selected($current_value, "down", false) . '>پایین</option>' |
| 125 |
. '</select>'; |
| 126 |
} |
| 127 |
|
| 128 |
public static function renderSyncProduct() |
| 129 |
{ |
| 130 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::SYNC_PRODUCT_FIELDS); |
| 131 |
echo '<select class="basalam-select basalam-select-center" name="sync_basalam_settings[' . esc_attr(SettingsConfig::SYNC_PRODUCT_FIELDS) . ']" id="basalam-sync-type">' |
| 132 |
. '<option value="all"' . selected($current_value, "all", false) . '>ه� |
| 133 |
ه اطلاعات</option>' |
| 134 |
. '<option value="price_stock"' . selected($current_value, "price_stock", false) . '>فقط قی� |
| 135 |
ت و � |
| 136 |
وجودی</option>' |
| 137 |
. '<option value="custom"' . selected($current_value, "custom", false) . '>سفارشی</option>' |
| 138 |
. '</select>'; |
| 139 |
} |
| 140 |
|
| 141 |
public static function renderWholesaleProducts() |
| 142 |
{ |
| 143 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::ALL_PRODUCTS_WHOLESALE); |
| 144 |
echo '<select class="basalam-select basalam-select-center" name="sync_basalam_settings[' . esc_attr(SettingsConfig::ALL_PRODUCTS_WHOLESALE) . ']">' |
| 145 |
. '<option value="none"' . selected($current_value, "none", false) . '>هیچ یا برخی � |
| 146 |
حصولات ع� |
| 147 |
ده</option>' |
| 148 |
. '<option value="all"' . selected($current_value, "all", false) . '>ه� |
| 149 |
ه � |
| 150 |
حصولات ع� |
| 151 |
ده</option>' |
| 152 |
. '</select>'; |
| 153 |
} |
| 154 |
|
| 155 |
public static function renderAttrAddToDesc() |
| 156 |
{ |
| 157 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::ADD_ATTR_TO_DESC_PRODUCT); |
| 158 |
echo '<select class="basalam-select basalam-select-center" name="sync_basalam_settings[' . esc_attr(SettingsConfig::ADD_ATTR_TO_DESC_PRODUCT) . ']">' |
| 159 |
. '<option value="no"' . selected($current_value, 'no', false) . '>اضافه نشود</option>' |
| 160 |
. '<option value="yes"' . selected($current_value, 'yes', false) . '>اضافه شود</option>' |
| 161 |
. '</select>'; |
| 162 |
} |
| 163 |
|
| 164 |
public static function renderOrderStatus() |
| 165 |
{ |
| 166 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::ORDER_STATUES_TYPE); |
| 167 |
echo '<select class="basalam-select basalam-select-center" name="sync_basalam_settings[' . esc_attr(SettingsConfig::ORDER_STATUES_TYPE) . ']">' |
| 168 |
. '<option value="woosalam_statuses"' . selected($current_value, 'woosalam_statuses', false) . '>وضعیت های ووسلا� |
| 169 |
</option>' |
| 170 |
. '<option value="woocommerce_statuses"' . selected($current_value, 'woocommerce_statuses', false) . '>وضعیت های ووکا� |
| 171 |
رس</option>' |
| 172 |
. '</select>'; |
| 173 |
} |
| 174 |
|
| 175 |
public static function renderShortAttrAddToDesc() |
| 176 |
{ |
| 177 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::ADD_SHORT_DESC_TO_DESC_PRODUCT); |
| 178 |
echo '<select class="basalam-select basalam-select-center" name="sync_basalam_settings[' . esc_attr(SettingsConfig::ADD_SHORT_DESC_TO_DESC_PRODUCT) . ']">' |
| 179 |
. '<option value="no"' . selected($current_value, 'no', false) . '>اضافه نشود</option>' |
| 180 |
. '<option value="yes"' . selected($current_value, 'yes', false) . '>اضافه شود</option>' |
| 181 |
. '</select>'; |
| 182 |
} |
| 183 |
|
| 184 |
public static function renderProductPrice() |
| 185 |
{ |
| 186 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::PRODUCT_PRICE_FIELD); |
| 187 |
echo '<select class="basalam-select basalam-select-center" name="sync_basalam_settings[' . esc_attr(SettingsConfig::PRODUCT_PRICE_FIELD) . ']">' |
| 188 |
. '<option value="original_price"' . selected($current_value, 'original_price', false) . '>قی� |
| 189 |
ت اصلی</option>' |
| 190 |
. '<option value="sale_price"' . selected($current_value, 'sale_price', false) . '>قی� |
| 191 |
ت حراجی (تک قی� |
| 192 |
ت)</option>' |
| 193 |
. '<option value="sale_strikethrough_price"' . selected($current_value, 'sale_strikethrough_price', false) . '>قی� |
| 194 |
ت حراجی (خط خورده)</option>' |
| 195 |
. '</select>'; |
| 196 |
} |
| 197 |
|
| 198 |
public static function renderProductDiscountDuration() |
| 199 |
{ |
| 200 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::DISCOUNT_DURATION); |
| 201 |
|
| 202 |
echo '<input type="number" name="sync_basalam_settings[' . esc_attr(SettingsConfig::DISCOUNT_DURATION) . ']" min="1" max="90" value="' . esc_attr($current_value) . '" class="basalam-input basalam-p percentage-input" required>'; |
| 203 |
} |
| 204 |
|
| 205 |
public static function renderDiscountReductionPercent() |
| 206 |
{ |
| 207 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::DISCOUNT_REDUCTION_PERCENT); |
| 208 |
|
| 209 |
echo '<input type="number" name="sync_basalam_settings[' . esc_attr(SettingsConfig::DISCOUNT_REDUCTION_PERCENT) . ']" min="0" max="100" value="' . esc_attr($current_value) . '" class="basalam-input basalam-p percentage-input" required>'; |
| 210 |
} |
| 211 |
|
| 212 |
public static function renderTasksPerMinute() |
| 213 |
{ |
| 214 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::TASKS_PER_MINUTE); |
| 215 |
$is_auto = syncBasalamSettings()->getSettings(SettingsConfig::TASKS_PER_MINUTE_AUTO) == 'true'; |
| 216 |
$disabled = $is_auto ? 'disabled' : ''; |
| 217 |
|
| 218 |
echo '<input type="number" name="sync_basalam_settings[' . esc_attr(SettingsConfig::TASKS_PER_MINUTE) . ']" min="1" max="60" value="' . esc_attr($current_value) . '" class="basalam-input basalam-p basalam-tasks-manual-input" ' . esc_attr($disabled) . ' required>'; |
| 219 |
} |
| 220 |
|
| 221 |
public static function renderTasksPerMinuteAutoToggle() |
| 222 |
{ |
| 223 |
$is_auto = syncBasalamSettings()->getSettings(SettingsConfig::TASKS_PER_MINUTE_AUTO) == 'true'; |
| 224 |
$checked = $is_auto ? 'checked' : ''; |
| 225 |
|
| 226 |
echo '<label class="basalam-switch">'; |
| 227 |
echo '<input type="hidden" name="sync_basalam_settings[' . esc_attr(SettingsConfig::TASKS_PER_MINUTE_AUTO) . ']" value="false">'; |
| 228 |
echo '<input type="checkbox" name="sync_basalam_settings[' . esc_attr(SettingsConfig::TASKS_PER_MINUTE_AUTO) . ']" value="true" ' . esc_attr($checked) . ' class="basalam-tasks-auto-toggle">'; |
| 229 |
echo '<span class="basalam-slider"></span>'; |
| 230 |
echo '</label>'; |
| 231 |
} |
| 232 |
|
| 233 |
public static function renderTasksPerMinuteInfo() |
| 234 |
{ |
| 235 |
$is_auto = syncBasalamSettings()->getSettings(SettingsConfig::TASKS_PER_MINUTE_AUTO) == 'true'; |
| 236 |
$display_style = $is_auto ? '' : 'display: none;'; |
| 237 |
|
| 238 |
$monitor = syncBasalamContainer()->get(\SyncBasalam\Services\SystemResourceMonitor::class); |
| 239 |
$optimal = $monitor->calculateOptimalTasksPerMinute(); |
| 240 |
|
| 241 |
echo '<div class="basalam-p basalam-form-group-full" style="' . esc_attr($display_style) . '">'; |
| 242 |
echo '<div class="basalam-tasks-info basalam-tasks-info-container" data-initial-optimal="' . esc_attr($optimal) . '">'; |
| 243 |
|
| 244 |
echo '<div class="basalam-tasks-info-flex">'; |
| 245 |
|
| 246 |
echo '<div class="basalam-tasks-info-item">'; |
| 247 |
echo '<strong class="basalam-tasks-info-label">🚀 تعداد تسک های اجرایی در دقیقه: </strong>'; |
| 248 |
echo '<span class="basalam-tasks-info-value-primary" id="basalam-tasks-optimal-value">' . esc_html($optimal) . ' تسک در دقیقه</span>'; |
| 249 |
echo '</div>'; |
| 250 |
|
| 251 |
echo '</div>'; |
| 252 |
|
| 253 |
echo '</div>'; |
| 254 |
echo '</div>'; |
| 255 |
} |
| 256 |
|
| 257 |
public static function renderPrefixProductTitle() |
| 258 |
{ |
| 259 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::PRODUCT_PREFIX_TITLE); |
| 260 |
echo '<input type="text" name="sync_basalam_settings[' . esc_attr(SettingsConfig::PRODUCT_PREFIX_TITLE) . ']" value="' . esc_attr($current_value) . '" class="basalam-input basalam-p basalam-max-width-80 basalam-font-12">'; |
| 261 |
} |
| 262 |
|
| 263 |
public static function renderSuffixProductTitle() |
| 264 |
{ |
| 265 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::PRODUCT_SUFFIX_TITLE); |
| 266 |
echo '<input type="text" name="sync_basalam_settings[' . esc_attr(SettingsConfig::PRODUCT_SUFFIX_TITLE) . ']" value="' . esc_attr($current_value) . '" class="basalam-input basalam-p basalam-max-width-80 basalam-font-12">'; |
| 267 |
} |
| 268 |
|
| 269 |
public static function renderAttributeSuffixEnabled() |
| 270 |
{ |
| 271 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::PRODUCT_ATTRIBUTE_SUFFIX_ENABLED); |
| 272 |
$checked = $current_value == 'yes' ? 'checked' : ''; |
| 273 |
|
| 274 |
echo '<label class="basalam-switch">'; |
| 275 |
echo '<input type="checkbox" name="sync_basalam_settings[' . esc_attr(SettingsConfig::PRODUCT_ATTRIBUTE_SUFFIX_ENABLED) . ']" value="yes" ' . esc_attr($checked) . ' class="basalam-attribute-suffix-toggle">'; |
| 276 |
echo '<span class="basalam-slider"></span>'; |
| 277 |
echo '</label>'; |
| 278 |
echo '<input type="hidden" name="sync_basalam_settings[' . esc_attr(SettingsConfig::PRODUCT_ATTRIBUTE_SUFFIX_ENABLED) . ']" value="no" class="basalam-attribute-suffix-hidden">'; |
| 279 |
} |
| 280 |
|
| 281 |
public static function renderAttributeSuffixPriority() |
| 282 |
{ |
| 283 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::PRODUCT_ATTRIBUTE_SUFFIX_PRIORITY); |
| 284 |
$is_enabled = syncBasalamSettings()->getSettings(SettingsConfig::PRODUCT_ATTRIBUTE_SUFFIX_ENABLED) == 'yes'; |
| 285 |
$disabled = $is_enabled ? '' : 'disabled'; |
| 286 |
|
| 287 |
echo '<input type="text" name="sync_basalam_settings[' . esc_attr(SettingsConfig::PRODUCT_ATTRIBUTE_SUFFIX_PRIORITY) . ']" value="' . esc_attr($current_value) . '" class="basalam-input basalam-p basalam-attribute-suffix-priority basalam-max-width-80 basalam-font-12" placeholder="� |
| 288 |
ثال: ناشر" ' . esc_attr($disabled) . '>'; |
| 289 |
} |
| 290 |
|
| 291 |
public static function renderMapOptionsProduct() |
| 292 |
{ |
| 293 |
?> |
| 294 |
<div id="Basalam-map-option-form" class="basalam-flex-center-vertical" role="group" aria-label="تغییر نا� |
| 295 |
ویژگی دسته بندی"> |
| 296 |
<?php wp_nonce_field('basalam_add_map_option_nonce', 'basalam_add_map_option_nonce', false); ?> |
| 297 |
<label for="woo-option-name" class="basalam-p__small">نا� |
| 298 |
ویژگی در ووکا� |
| 299 |
رس</label> |
| 300 |
<input type="text" class="basalam-input basalam-width-auto" id="woo-option-name" name="woo-option-name"> |
| 301 |
<label for="Basalam-option-name" class="basalam-p__small">نا� |
| 302 |
ویژگی در باسلا� |
| 303 |
</label> |
| 304 |
<input type="text" class="basalam-input basalam-width-auto" id="Basalam-option-name" name="Basalam-option-name"> |
| 305 |
<button type="button" id="Basalam-map-option-submit" class="basalam-primary-button basalam-p basalam-button-auto">ذخیره</button> |
| 306 |
</div> |
| 307 |
<?php |
| 308 |
} |
| 309 |
|
| 310 |
public static function renderSyncProductFields() |
| 311 |
{ |
| 312 |
echo '<div>'; |
| 313 |
echo self::renderSingleCheckbox(SettingsConfig::SYNC_PRODUCT_FIELD_NAME, 'نا� |
| 314 |
'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML is escaped inside the component method. |
| 315 |
echo self::renderSingleCheckbox(SettingsConfig::SYNC_PRODUCT_FIELD_SKU, 'کد � |
| 316 |
حصول (SKU)'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML is escaped inside the component method. |
| 317 |
echo self::renderSingleCheckbox(SettingsConfig::SYNC_PRODUCT_FIELD_PHOTOS, 'عکس'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML is escaped inside the component method. |
| 318 |
echo self::renderSingleCheckbox(SettingsConfig::SYNC_PRODUCT_FIELD_PRICE, 'قی� |
| 319 |
ت'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML is escaped inside the component method. |
| 320 |
echo self::renderSingleCheckbox(SettingsConfig::SYNC_PRODUCT_FIELD_STOCK, '� |
| 321 |
وجودی'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML is escaped inside the component method. |
| 322 |
echo self::renderSingleCheckbox(SettingsConfig::SYNC_PRODUCT_FIELD_WEIGHT, 'وزن'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML is escaped inside the component method. |
| 323 |
echo self::renderSingleCheckbox(SettingsConfig::SYNC_PRODUCT_FIELD_DESCRIPTION, 'توضیحات'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML is escaped inside the component method. |
| 324 |
echo self::renderSingleCheckbox(SettingsConfig::SYNC_PRODUCT_FIELD_ATTR, 'ویژگی ها'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML is escaped inside the component method. |
| 325 |
echo self::renderSingleCheckbox(SettingsConfig::SYNC_PRODUCT_FIELD_VIDEO, 'ویدیو'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML is escaped inside the component method. |
| 326 |
echo '</div>'; |
| 327 |
|
| 328 |
echo '<div class="basalam-margin-top-25-bottom-10">'; |
| 329 |
echo '<label class="basalam-label basalam-p">� |
| 330 |
تغیرها</label><br>'; |
| 331 |
echo self::renderSingleCheckbox(SettingsConfig::SYNC_PRODUCT_FIELD_VARIANT_PRICE, 'قی� |
| 332 |
ت � |
| 333 |
تغیرها'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML is escaped inside the component method. |
| 334 |
echo self::renderSingleCheckbox(SettingsConfig::SYNC_PRODUCT_FIELD_VARIANT_STOCK, '� |
| 335 |
وجودی � |
| 336 |
تغیرها'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- HTML is escaped inside the component method. |
| 337 |
echo '</div>'; |
| 338 |
} |
| 339 |
|
| 340 |
private static function renderSingleCheckbox($field_key, $label) |
| 341 |
{ |
| 342 |
return '<label class="basalam-p sync-checkbox-label basalam-checkbox-label">' |
| 343 |
. '<input type="hidden" name="sync_basalam_settings[' . esc_attr($field_key) . ']" value="">' |
| 344 |
. '<input type="checkbox" name="sync_basalam_settings[' . esc_attr($field_key) . ']" value="1" ' |
| 345 |
. checked(syncBasalamSettings()->getSettings($field_key), true, false) . '>' |
| 346 |
. esc_html($label) |
| 347 |
. '</label>'; |
| 348 |
} |
| 349 |
|
| 350 |
public static function renderDeveloperMode() |
| 351 |
{ |
| 352 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::DEVELOPER_MODE); |
| 353 |
echo '<select name="sync_basalam_settings[' . esc_attr(SettingsConfig::DEVELOPER_MODE) . ']" class="basalam-select basalam-select-center" onchange="this.form.submit()">' |
| 354 |
. '<option value="false"' . selected($current_value, "false", false) . '>غیرفعال</option>' |
| 355 |
. '<option value="true"' . selected($current_value, "true", false) . '>فعال</option>' |
| 356 |
. '</select>'; |
| 357 |
} |
| 358 |
|
| 359 |
public static function renderCategoryOptionsMapping($data) |
| 360 |
{ |
| 361 |
$delete_nonce = wp_create_nonce('basalam_delete_mapped_option_nonce'); |
| 362 |
|
| 363 |
echo '<div class="options_mapping_section" data-delete-nonce="' . esc_attr($delete_nonce) . '">'; |
| 364 |
echo '<p class="basalam-p">لیست ویژگی ها : </p>'; |
| 365 |
echo "<table class='basalam-table basalam-p'>"; |
| 366 |
echo '<thead><tr><th>نا� |
| 367 |
ویژگی در ووکا� |
| 368 |
رس</th><th>نا� |
| 369 |
ویژگی در باسلا� |
| 370 |
</th><th>ع� |
| 371 |
لیات</th></tr></thead>'; |
| 372 |
echo '<tbody>'; |
| 373 |
|
| 374 |
if (!empty($data)) { |
| 375 |
foreach ($data as $item) { |
| 376 |
echo '<tr data-woo="' . esc_attr($item['woo_name']) . '" data-basalam="' . esc_attr($item['sync_basalam_name']) . '">'; |
| 377 |
echo '<td>' . esc_html($item['woo_name']) . '</td>'; |
| 378 |
echo '<td>' . esc_html($item['sync_basalam_name']) . '</td>'; |
| 379 |
echo '<td> |
| 380 |
<button |
| 381 |
type="button" |
| 382 |
class="Basalam-delete-option basalam-primary-button basalam-button-auto" |
| 383 |
data-_wpnonce="' . esc_attr($delete_nonce) . '"> |
| 384 |
حذف |
| 385 |
</button> |
| 386 |
</td>'; |
| 387 |
echo '</tr>'; |
| 388 |
} |
| 389 |
} |
| 390 |
|
| 391 |
echo '</tbody></table>'; |
| 392 |
echo '</div>'; |
| 393 |
} |
| 394 |
|
| 395 |
public static function renderShippingMethod() |
| 396 |
{ |
| 397 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::ORDER_SHIPPING_METHOD); |
| 398 |
|
| 399 |
echo '<select class="basalam-select basalam-select-center" name="sync_basalam_settings[' . esc_attr(SettingsConfig::ORDER_SHIPPING_METHOD) . ']">'; |
| 400 |
echo '<option value="basalam"' . selected($current_value, 'basalam', false) . '>ح� |
| 401 |
ل و نقل باسلا� |
| 402 |
</option>'; |
| 403 |
|
| 404 |
// Get active WooCommerce shipping methods |
| 405 |
if (class_exists('WC_Shipping')) { |
| 406 |
$shipping_zones = \WC_Shipping_Zones::get_zones(); |
| 407 |
$unique_methods = []; |
| 408 |
|
| 409 |
foreach ($shipping_zones as $zone) { |
| 410 |
$zone_id = $zone['id'] ?? 0; |
| 411 |
$shipping_zone = new \WC_Shipping_Zone($zone_id); |
| 412 |
$methods = $shipping_zone->get_shipping_methods(true); |
| 413 |
|
| 414 |
foreach ($methods as $method) { |
| 415 |
$method_value = 'wc_' . $method->id; |
| 416 |
$method_title = $method->get_title() ?: $method->get_method_title(); |
| 417 |
|
| 418 |
// Avoid duplicate methods |
| 419 |
if (!isset($unique_methods[$method_value])) { |
| 420 |
$unique_methods[$method_value] = $method_title; |
| 421 |
} |
| 422 |
} |
| 423 |
} |
| 424 |
|
| 425 |
// Render options |
| 426 |
foreach ($unique_methods as $value => $title) { |
| 427 |
echo '<option value="' . esc_attr($value) . '"' . selected($current_value, $value, false) . '>' . esc_html($title) . '</option>'; |
| 428 |
} |
| 429 |
} |
| 430 |
|
| 431 |
echo '</select>'; |
| 432 |
} |
| 433 |
|
| 434 |
public static function renderCustomerPrefixName() |
| 435 |
{ |
| 436 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::CUSTOMER_PREFIX_NAME); |
| 437 |
echo '<input type="text" name="sync_basalam_settings[' . esc_attr(SettingsConfig::CUSTOMER_PREFIX_NAME) . ']" value="' . esc_attr($current_value) . '" class="basalam-input basalam-p basalam-max-width-80 basalam-font-12" placeholder="� |
| 438 |
ثال: آقای/خان� |
| 439 |
">'; |
| 440 |
} |
| 441 |
|
| 442 |
public static function renderCustomerSuffixName() |
| 443 |
{ |
| 444 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::CUSTOMER_SUFFIX_NAME); |
| 445 |
echo '<input type="text" name="sync_basalam_settings[' . esc_attr(SettingsConfig::CUSTOMER_SUFFIX_NAME) . ']" value="' . esc_attr($current_value) . '" class="basalam-input basalam-p basalam-max-width-80 basalam-font-12" placeholder="� |
| 446 |
ثال: عزیز">'; |
| 447 |
} |
| 448 |
|
| 449 |
public static function renderVideoSource() |
| 450 |
{ |
| 451 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::VIDEO_SOURCE) ?: 'inherit'; |
| 452 |
|
| 453 |
echo '<select class="basalam-select basalam-select-center basalam-video-source-select" name="sync_basalam_settings[' . esc_attr(SettingsConfig::VIDEO_SOURCE) . ']">' |
| 454 |
. '<option value="inherit"' . selected($current_value, 'inherit', false) . '>ارثبری از قالب یا افزونه</option>' |
| 455 |
. '<option value="plugin_box"' . selected($current_value, 'plugin_box', false) . '>باکس اختصاصی افزونه (در صفحه � |
| 456 |
حصول)</option>' |
| 457 |
. '</select>'; |
| 458 |
} |
| 459 |
|
| 460 |
public static function renderVideoInheritMode() |
| 461 |
{ |
| 462 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::VIDEO_INHERIT_MODE) ?: 'auto'; |
| 463 |
|
| 464 |
echo '<select class="basalam-select basalam-select-center basalam-video-inherit-mode-select" name="sync_basalam_settings[' . esc_attr(SettingsConfig::VIDEO_INHERIT_MODE) . ']">' |
| 465 |
. '<option value="auto"' . selected($current_value, 'auto', false) . '>تشخیص خودکار (Woodmart، Flatsome، YITH، ...)</option>' |
| 466 |
. '<option value="manual"' . selected($current_value, 'manual', false) . '>وارد کردن دستی meta key</option>' |
| 467 |
. '</select>'; |
| 468 |
} |
| 469 |
|
| 470 |
public static function renderVideoMetaKey() |
| 471 |
{ |
| 472 |
$current_value = syncBasalamSettings()->getSettings(SettingsConfig::VIDEO_META_KEY); |
| 473 |
|
| 474 |
echo '<input type="text" name="sync_basalam_settings[' . esc_attr(SettingsConfig::VIDEO_META_KEY) . ']" value="' . esc_attr((string) $current_value) . '" class="basalam-input basalam-p basalam-video-meta-key basalam-max-width-80 basalam-font-12" placeholder="� |
| 475 |
ثال: _woodmart_product_video">'; |
| 476 |
} |
| 477 |
} |
| 478 |
|