| 1 |
<?php |
| 2 |
/** |
| 3 |
* Setup Wizard - Currency Settings Step |
| 4 |
* |
| 5 |
* @package Yatra |
| 6 |
*/ |
| 7 |
|
| 8 |
defined('ABSPATH') || exit; |
| 9 |
|
| 10 |
use Yatra\Services\SettingsService; |
| 11 |
use Yatra\Helpers\CurrencyHelper; |
| 12 |
|
| 13 |
// Get actual Yatra settings |
| 14 |
$currency = SettingsService::get('currency', 'USD'); |
| 15 |
$currency_position = SettingsService::get('currency_position', 'before'); |
| 16 |
$thousand_separator = SettingsService::get('thousand_separator', ','); |
| 17 |
$decimal_separator = SettingsService::get('decimal_separator', '.'); |
| 18 |
$decimal_places = SettingsService::get('decimal_places', 2); |
| 19 |
|
| 20 |
// Get all currencies from CurrencyHelper |
| 21 |
$currencies = CurrencyHelper::getOptions(true); |
| 22 |
|
| 23 |
// Get popular currencies for quick selection |
| 24 |
$popular_currencies = CurrencyHelper::getPopular(); |
| 25 |
$popular_options = []; |
| 26 |
foreach ($popular_currencies as $code => $data) { |
| 27 |
$popular_options[$code] = "{$data['name']} ({$data['symbol']})"; |
| 28 |
} |
| 29 |
?> |
| 30 |
|
| 31 |
<form method="post" class="wizard-step"> |
| 32 |
<?php wp_nonce_field('yatra-setup'); ?> |
| 33 |
<input type="hidden" name="save_step" value="currency"> |
| 34 |
|
| 35 |
<div class="wizard-header wizard-header--task"> |
| 36 |
<p class="wizard-header-kicker"><?php echo esc_html($this->get_wizard_progress_label()); ?></p> |
| 37 |
<h1><?php esc_html_e('Currency & price display', 'yatra'); ?></h1> |
| 38 |
<p class="wizard-header-lead"><?php esc_html_e('Trip prices, deposits, and totals will use these rules everywhere on the site.', 'yatra'); ?></p> |
| 39 |
</div> |
| 40 |
|
| 41 |
<div class="wizard-content"> |
| 42 |
<!-- First Row - Currency & Position --> |
| 43 |
<div class="form-row" style="display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 20px;"> |
| 44 |
<div class="form-group"> |
| 45 |
<label class="form-label" for="currency"><?php esc_html_e('Currency', 'yatra'); ?></label> |
| 46 |
<select id="currency" name="currency" class="form-control"> |
| 47 |
<optgroup label="<?php esc_html_e('Popular Currencies', 'yatra'); ?>"> |
| 48 |
<?php foreach ($popular_options as $code => $label) : ?> |
| 49 |
<option value="<?php echo esc_attr($code); ?>" <?php selected($currency, $code); ?>> |
| 50 |
<?php echo esc_html($label); ?> |
| 51 |
</option> |
| 52 |
<?php endforeach; ?> |
| 53 |
</optgroup> |
| 54 |
<optgroup label="<?php esc_html_e('All Currencies', 'yatra'); ?>"> |
| 55 |
<?php foreach ($currencies as $code => $label) : ?> |
| 56 |
<?php if (!isset($popular_options[$code])) : // Skip popular currencies already shown ?> |
| 57 |
<option value="<?php echo esc_attr($code); ?>" <?php selected($currency, $code); ?>> |
| 58 |
<?php echo esc_html($label); ?> |
| 59 |
</option> |
| 60 |
<?php endif; ?> |
| 61 |
<?php endforeach; ?> |
| 62 |
</optgroup> |
| 63 |
</select> |
| 64 |
<p class="form-help"><?php esc_html_e('Select your preferred currency from 150+ world currencies', 'yatra'); ?></p> |
| 65 |
</div> |
| 66 |
|
| 67 |
<div class="form-group"> |
| 68 |
<label class="form-label" for="currency_position"><?php esc_html_e('Currency Position', 'yatra'); ?></label> |
| 69 |
<select id="currency_position" name="currency_position" class="form-control"> |
| 70 |
<option value="before" <?php selected($currency_position, 'before'); ?>><?php esc_html_e('Before ($99.99)', 'yatra'); ?></option> |
| 71 |
<option value="after" <?php selected($currency_position, 'after'); ?>><?php esc_html_e('After (99.99$)', 'yatra'); ?></option> |
| 72 |
</select> |
| 73 |
<p class="form-help"><?php esc_html_e('Where to display the currency symbol', 'yatra'); ?></p> |
| 74 |
</div> |
| 75 |
</div> |
| 76 |
|
| 77 |
<!-- Second Row - Separators --> |
| 78 |
<div class="form-row" style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px;"> |
| 79 |
<div class="form-group"> |
| 80 |
<label class="form-label" for="thousand_separator"><?php esc_html_e('Thousand Separator', 'yatra'); ?></label> |
| 81 |
<input type="text" id="thousand_separator" name="thousand_separator" value="<?php echo esc_attr($thousand_separator); ?>" maxlength="1" class="form-control"> |
| 82 |
<p class="form-help"><?php esc_html_e('e.g., comma (,) for 1,000', 'yatra'); ?></p> |
| 83 |
</div> |
| 84 |
|
| 85 |
<div class="form-group"> |
| 86 |
<label class="form-label" for="decimal_separator"><?php esc_html_e('Decimal Separator', 'yatra'); ?></label> |
| 87 |
<input type="text" id="decimal_separator" name="decimal_separator" value="<?php echo esc_attr($decimal_separator); ?>" maxlength="1" class="form-control"> |
| 88 |
<p class="form-help"><?php esc_html_e('e.g., period (.) for 99.99', 'yatra'); ?></p> |
| 89 |
</div> |
| 90 |
|
| 91 |
<div class="form-group"> |
| 92 |
<label class="form-label" for="decimal_places"><?php esc_html_e('Decimal Places', 'yatra'); ?></label> |
| 93 |
<input type="number" id="decimal_places" name="decimal_places" value="<?php echo esc_attr($decimal_places); ?>" min="0" max="4" class="form-control"> |
| 94 |
<p class="form-help"><?php esc_html_e('Number of decimal places to display', 'yatra'); ?></p> |
| 95 |
</div> |
| 96 |
</div> |
| 97 |
</div> |
| 98 |
|
| 99 |
<div class="wizard-footer"> |
| 100 |
<a href="<?php echo esc_url($this->get_step_url('communications')); ?>" class="btn btn-secondary wizard-footer-back"> |
| 101 |
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg> |
| 102 |
<?php esc_html_e('Back', 'yatra'); ?> |
| 103 |
</a> |
| 104 |
<div class="wizard-footer-actions"> |
| 105 |
<a href="<?php echo esc_url($this->get_next_step_link()); ?>" class="btn btn-secondary btn-skip"><?php esc_html_e('Skip', 'yatra'); ?></a> |
| 106 |
<button type="submit" class="btn btn-primary"> |
| 107 |
<?php esc_html_e('Continue', 'yatra'); ?> |
| 108 |
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg> |
| 109 |
</button> |
| 110 |
</div> |
| 111 |
</div> |
| 112 |
</form> |
| 113 |
|