Changeset 3431384
- Timestamp:
- 01/03/2026 02:15:25 AM (2 months ago)
- Location:
- abovewp-bulgarian-eurozone/trunk
- Files:
-
- 2 edited
-
abovewp-bulgarian-eurozone.php (modified) (5 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
abovewp-bulgarian-eurozone/trunk/abovewp-bulgarian-eurozone.php
r3421026 r3431384 3 3 * Plugin Name: AboveWP Bulgarian Eurozone 4 4 * Description: Adds bidirectional dual currency display (BGN ⇄ EUR) for WooCommerce as Bulgaria prepares to join the Eurozone 5 * Version: 2.0. 25 * Version: 2.0.3 6 6 * Author: AboveWP 7 7 * Author URI: https://abovewp.com … … 22 22 23 23 // Define plugin constants 24 define('ABOVEWP_BGE_VERSION', '2.0. 1');24 define('ABOVEWP_BGE_VERSION', '2.0.3'); 25 25 define('ABOVEWP_BGE_PLUGIN_DIR', plugin_dir_path(__FILE__)); 26 26 define('ABOVEWP_BGE_PLUGIN_URL', plugin_dir_url(__FILE__)); … … 81 81 add_action('abovewp_admin_dashboard_plugins', array($this, 'display_plugin_card')); 82 82 83 // Only proceed if dual currency display is enabled and currency is supported (BGN or EUR) 84 if (get_option('abovewp_bge_enabled', 'yes') !== 'yes' || !$this->is_site_currency_supported()) { 83 // Only proceed if dual currency display is enabled and should be displayed 84 // (BGN stores always show EUR, EUR stores only show BGN on Bulgarian locale) 85 if (get_option('abovewp_bge_enabled', 'yes') !== 'yes' || !$this->should_display_dual_currency()) { 85 86 return; 86 87 } … … 143 144 private function is_site_currency_supported() { 144 145 return $this->is_site_currency_bgn() || $this->is_site_currency_eur(); 146 } 147 148 /** 149 * Check if dual currency display should be active 150 * For BGN stores: always show EUR (everyone should see the EUR equivalent) 151 * For EUR stores: only show BGN on Bulgarian locale (for multilang/multicurrency compatibility) 152 * 153 * @return bool 154 */ 155 private function should_display_dual_currency() { 156 if (!$this->is_site_currency_supported()) { 157 return false; 158 } 159 160 // For BGN stores, always show EUR equivalent 161 if ($this->is_site_currency_bgn()) { 162 return true; 163 } 164 165 // For EUR stores, only show BGN equivalent on Bulgarian locale 166 if ($this->is_site_currency_eur()) { 167 $locale = get_locale(); 168 // Check for Bulgarian locale (bg_BG or just bg) 169 return strpos($locale, 'bg') === 0; 170 } 171 172 return false; 145 173 } 146 174 … … 661 689 public function convert_eur_to_bgn($price_eur) { 662 690 // Always use the official EUR to BGN conversion rate 663 $price_bgn = $price_eur * $this->conversion_rate;691 $price_bgn_raw = $price_eur * $this->conversion_rate; 664 692 665 693 // Check if within 0.05 of a whole number 666 $nearest_int = round($price_bgn); 667 if (abs($price_bgn - $nearest_int) <= 0.05) { 668 return $nearest_int; 669 } 670 671 // Otherwise round to nearest 0.10 672 return round($price_bgn, 1); 694 $nearest_int = round($price_bgn_raw); 695 if (abs($price_bgn_raw - $nearest_int) <= 0.05) { 696 $price_bgn = $nearest_int; 697 } else { 698 // Otherwise round to nearest 0.10 699 $price_bgn = round($price_bgn_raw, 1); 700 } 701 702 /** 703 * Filter the converted BGN price from EUR 704 * 705 * Allows developers to customize the rounding logic for EUR to BGN conversion. 706 * 707 * @since 2.0.3 708 * @param float $price_bgn The rounded BGN price (after smart rounding) 709 * @param float $price_eur The original EUR price (input) 710 * @param float $price_bgn_raw The raw unrounded BGN price (before rounding) 711 */ 712 return apply_filters('abovewp_bge_convert_eur_to_bgn', $price_bgn, $price_eur, $price_bgn_raw); 673 713 } 674 714 -
abovewp-bulgarian-eurozone/trunk/readme.txt
r3421026 r3431384 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.2 7 Stable tag: 2.0. 27 Stable tag: 2.0.3 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 108 108 == Changelog == 109 109 110 = 2.0.3 = 111 * NEW: Locale-aware dual currency display - BGN prices now only appear alongside EUR on Bulgarian locale (bg_BG) for better multilang/multicurrency compatibility 112 * NEW: Filter `abovewp_bge_convert_eur_to_bgn` - developers can now customize the EUR to BGN rounding logic 113 110 114 = 2.0.2 = 111 115 Improved rounding on bgn currency while euro is the main one … … 190 194 == Upgrade Notice == 191 195 196 = 2.0.3 = 197 Improved multilang/multicurrency support: BGN prices now only display on Bulgarian locale when store currency is EUR. Added developer filter for custom rounding logic. 198 192 199 = 2.0.2 = 193 200 Improved rounding
Note: See TracChangeset
for help on using the changeset viewer.