| 1 |
<?php |
| 2 |
|
| 3 |
namespace SyncBasalam\Admin\Product\elements\SingleProduct; |
| 4 |
|
| 5 |
defined('ABSPATH') || exit; |
| 6 |
|
| 7 |
class WholesaleField |
| 8 |
{ |
| 9 |
public static function renderCheckbox() |
| 10 |
{ |
| 11 |
$isWholesale = get_post_meta(get_the_ID(), '_sync_basalam_is_wholesale', true); |
| 12 |
$checked = ($isWholesale === 'yes') ? 'yes' : 'no'; |
| 13 |
|
| 14 |
woocommerce_wp_checkbox([ |
| 15 |
'id' => '_sync_basalam_is_wholesale', |
| 16 |
'label' => '� |
| 17 |
حصول ع� |
| 18 |
ده است', |
| 19 |
'description' => 'اگر این � |
| 20 |
حصول ع� |
| 21 |
ده است، این گزینه را فعال ن� |
| 22 |
ایید.', |
| 23 |
'desc_tip' => true, |
| 24 |
'value' => $checked, |
| 25 |
]); |
| 26 |
|
| 27 |
wp_nonce_field('sync_basalam_save_wholesale_action', '_sync_basalam_wholesale_nonce'); |
| 28 |
} |
| 29 |
|
| 30 |
public static function saveCheckbox($postId) |
| 31 |
{ |
| 32 |
if ( |
| 33 |
!isset($_POST['_sync_basalam_wholesale_nonce']) |
| 34 |
|| !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_sync_basalam_wholesale_nonce'])), 'sync_basalam_save_wholesale_action') |
| 35 |
) { |
| 36 |
return; |
| 37 |
} |
| 38 |
|
| 39 |
$syncBasalamIsCheckboxValue = isset($_POST['_sync_basalam_is_wholesale']) ? 'yes' : 'no'; |
| 40 |
update_post_meta($postId, '_sync_basalam_is_wholesale', $syncBasalamIsCheckboxValue); |
| 41 |
} |
| 42 |
} |
| 43 |
|