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