WooCommerce Multilingual – run WooCommerce with WPML - Version 3.6.7

Version Description

  • Bug fix: Converted prices in secondary currencies were incorrect in some situations. e.g. For VND with an VND:EUR exchange rate of 30,000:1
  • Bug fix: Wrong urls were displayed in the language switcher for product category or product tag urls
Download this release

Release Info

Developer mihaimihai
Plugin Icon 128x128 WooCommerce Multilingual – run WooCommerce with WPML
Version 3.6.7
Comparing to
See all releases

Code changes from version 3.6.6 to 3.6.7

inc/multi-currency.class.php CHANGED
@@ -25,6 +25,8 @@ class WCML_WC_MultiCurrency{
25
  add_filter('wcml_price_currency', array($this, 'price_currency_filter'));
26
 
27
  add_filter('wcml_raw_price_amount', array($this, 'raw_price_filter'), 10, 2);
 
 
28
 
29
  add_filter('wcml_shipping_price_amount', array($this, 'shipping_price_filter'));
30
  add_filter('wcml_shipping_free_min_amount', array($this, 'shipping_free_min_amount'));
@@ -111,6 +113,35 @@ class WCML_WC_MultiCurrency{
111
  return $price;
112
 
113
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
 
115
  function apply_rounding_rules($price, $currency = false ){
116
  global $woocommerce_wpml;
@@ -201,8 +232,7 @@ class WCML_WC_MultiCurrency{
201
 
202
  }
203
 
204
- function convert_price_amount($amount, $currency = false, $decimals_num = false, $decimal_sep = false, $thousand_sep = false ){
205
- global $woocommerce_wpml;
206
 
207
  if(empty($currency)){
208
  $currency = $this->get_client_currency();
@@ -217,7 +247,7 @@ class WCML_WC_MultiCurrency{
217
  if(in_array($currency, $this->currencies_without_cents)){
218
 
219
  if(version_compare(PHP_VERSION, '5.3.0') >= 0){
220
- $amount = round($amount, $decimals_num, PHP_ROUND_HALF_UP);
221
  }else{
222
  if($amount - floor($amount) < 0.5){
223
  $amount = floor($amount);
@@ -232,29 +262,12 @@ class WCML_WC_MultiCurrency{
232
  $amount = 0;
233
  }
234
 
235
- $currency_details = $woocommerce_wpml->multi_currency_support->get_currency_details_by_code( $currency );
236
-
237
- if( is_bool( $decimals_num ) ){
238
- $decimals_num = $currency_details['num_decimals'];
239
- }
240
-
241
- if( !$decimal_sep ){
242
- $decimal_sep = $currency_details['decimal_sep'];
243
- }
244
-
245
- if( !$thousand_sep ){
246
- $thousand_sep = $currency_details['thousand_sep'];
247
- }
248
-
249
- $amount = number_format( (float)$amount, $decimals_num, $decimal_sep, $thousand_sep );
250
-
251
  return $amount;
252
 
253
  }
254
 
255
  // convert back to default currency
256
- function unconvert_price_amount($amount, $currency = false, $decimals_num = false, $decimal_sep = false, $thousand_sep = false){
257
- global $woocommerce_wpml;
258
 
259
  if(empty($currency)){
260
  $currency = $this->get_client_currency();
@@ -271,7 +284,7 @@ class WCML_WC_MultiCurrency{
271
  if(in_array($currency, $this->currencies_without_cents)){
272
 
273
  if(version_compare(PHP_VERSION, '5.3.0') >= 0){
274
- $amount = round($amount, $decimals_num, PHP_ROUND_HALF_UP);
275
  }else{
276
  if($amount - floor($amount) < 0.5){
277
  $amount = floor($amount);
@@ -288,22 +301,6 @@ class WCML_WC_MultiCurrency{
288
 
289
  }
290
 
291
- $currency_details = $woocommerce_wpml->multi_currency_support->get_currency_details_by_code( $currency );
292
-
293
- if( is_bool( $decimals_num ) ){
294
- $decimals_num = $currency_details['num_decimals'];
295
- }
296
-
297
- if( !$decimal_sep ){
298
- $decimal_sep = $currency_details['decimal_sep'];
299
- }
300
-
301
- if( !$thousand_sep ){
302
- $thousand_sep = $currency_details['thousand_sep'];
303
- }
304
-
305
- $amount = number_format( (float)$amount, $decimals_num, $decimal_sep, $thousand_sep );
306
-
307
  return $amount;
308
 
309
  }
25
  add_filter('wcml_price_currency', array($this, 'price_currency_filter'));
26
 
27
  add_filter('wcml_raw_price_amount', array($this, 'raw_price_filter'), 10, 2);
28
+
29
+ add_filter('wcml_formatted_price', array($this, 'formatted_price'), 10, 2);
30
 
31
  add_filter('wcml_shipping_price_amount', array($this, 'shipping_price_filter'));
32
  add_filter('wcml_shipping_free_min_amount', array($this, 'shipping_free_min_amount'));
113
  return $price;
114
 
115
  }
116
+
117
+ /*
118
+ * Converts the price from the default currency to the given currency and applies the format
119
+ */
120
+ function formatted_price($amount, $currency = false){
121
+ global $woocommerce_wpml;
122
+
123
+ if( $currency === false ){
124
+ $currency = $this->get_client_currency();
125
+ }
126
+
127
+ $amount = $this->raw_price_filter($amount, $currency);
128
+
129
+ $currency_details = $woocommerce_wpml->multi_currency_support->get_currency_details_by_code( $currency );
130
+
131
+ $wc_price_args = array(
132
+
133
+ 'currency' => $currency,
134
+ 'decimal_separator' => $currency_details['decimal_sep'],
135
+ 'thousand_separator' => $currency_details['thousand_sep'],
136
+ 'decimals' => $currency_details['num_decimals']
137
+
138
+
139
+ );
140
+
141
+ $price = wc_price($amount, $wc_price_args);
142
+
143
+ return $price;
144
+ }
145
 
146
  function apply_rounding_rules($price, $currency = false ){
147
  global $woocommerce_wpml;
232
 
233
  }
234
 
235
+ function convert_price_amount($amount, $currency = false){
 
236
 
237
  if(empty($currency)){
238
  $currency = $this->get_client_currency();
247
  if(in_array($currency, $this->currencies_without_cents)){
248
 
249
  if(version_compare(PHP_VERSION, '5.3.0') >= 0){
250
+ $amount = round($amount, 0, PHP_ROUND_HALF_UP);
251
  }else{
252
  if($amount - floor($amount) < 0.5){
253
  $amount = floor($amount);
262
  $amount = 0;
263
  }
264
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  return $amount;
266
 
267
  }
268
 
269
  // convert back to default currency
270
+ function unconvert_price_amount($amount, $currency = false){
 
271
 
272
  if(empty($currency)){
273
  $currency = $this->get_client_currency();
284
  if(in_array($currency, $this->currencies_without_cents)){
285
 
286
  if(version_compare(PHP_VERSION, '5.3.0') >= 0){
287
+ $amount = round($amount, 0, PHP_ROUND_HALF_UP);
288
  }else{
289
  if($amount - floor($amount) < 0.5){
290
  $amount = floor($amount);
301
 
302
  }
303
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  return $amount;
305
 
306
  }
inc/terms.class.php CHANGED
@@ -167,12 +167,12 @@ class WCML_Terms{
167
  foreach($wc_taxonomies_wc_format as $taxonomy ){
168
  $taxonomy_obj = get_taxonomy($taxonomy);
169
 
170
- if(isset($taxonomy_obj->rewrite['slug'])){
171
  $exp = explode('/', trim($taxonomy_obj->rewrite['slug'],'/'));
172
  $slug = join('/', array_slice($exp, 0, count($exp) - 1));
173
  }
174
 
175
- if($slug && $sitepress->get_current_language() != $strings_language){
176
 
177
  $slug_translation = $wpdb->get_var($wpdb->prepare("
178
  SELECT t.value
@@ -281,7 +281,7 @@ class WCML_Terms{
281
 
282
  if ( is_null( $slug_translation ) ) {
283
  // handle exception - default woocommerce category and tag bases used
284
- $slug_translation = $this->get_translation_from_woocommerce_mo_file( 'product-category', $language );
285
 
286
  }
287
 
@@ -344,9 +344,9 @@ class WCML_Terms{
344
  $no_recursion_flag = false;
345
 
346
  if( !is_null( $wpml_term_translations ) ){
347
- $term_language = $term->term_id ? $wpml_term_translations->get_element_lang_code($term->term_id) : false;
348
  }else{
349
- $term_language = $term->term_id ? $sitepress->get_language_for_element( $term->term_id, 'tax_'.$taxonomy ) : false;
350
  }
351
 
352
  if( $term_language ){
167
  foreach($wc_taxonomies_wc_format as $taxonomy ){
168
  $taxonomy_obj = get_taxonomy($taxonomy);
169
 
170
+ if( isset($taxonomy_obj->rewrite['slug'] ) ){
171
  $exp = explode('/', trim($taxonomy_obj->rewrite['slug'],'/'));
172
  $slug = join('/', array_slice($exp, 0, count($exp) - 1));
173
  }
174
 
175
+ if( isset( $slug ) && $sitepress->get_current_language() != $strings_language){
176
 
177
  $slug_translation = $wpdb->get_var($wpdb->prepare("
178
  SELECT t.value
281
 
282
  if ( is_null( $slug_translation ) ) {
283
  // handle exception - default woocommerce category and tag bases used
284
+ $slug_translation = $this->get_translation_from_woocommerce_mo_file( $slug, $language );
285
 
286
  }
287
 
344
  $no_recursion_flag = false;
345
 
346
  if( !is_null( $wpml_term_translations ) ){
347
+ $term_language = $term->term_id ? $wpml_term_translations->get_element_lang_code($term->term_taxonomy_id) : false;
348
  }else{
349
+ $term_language = $term->term_id ? $sitepress->get_language_for_element( $term->term_taxonomy_id, 'tax_'.$taxonomy ) : false;
350
  }
351
 
352
  if( $term_language ){
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: CMS, woocommerce, commerce, ecommerce, e-commerce, products, WPML, multili
5
  License: GPLv2
6
  Requires at least: 3.0
7
  Tested up to: 4.2.3
8
- Stable tag: 3.6.6
9
 
10
  Allows running fully multilingual e-commerce sites using WooCommerce and WPML.
11
 
@@ -78,6 +78,10 @@ In order for the checkout and store pages to appear translated, you need to crea
78
 
79
  == Changelog ==
80
 
 
 
 
 
81
  = 3.6.6 =
82
  * Fixed a bug that was causing a PHP warning when using a WPML version prior 3.2
83
 
5
  License: GPLv2
6
  Requires at least: 3.0
7
  Tested up to: 4.2.3
8
+ Stable tag: 3.6.7
9
 
10
  Allows running fully multilingual e-commerce sites using WooCommerce and WPML.
11
 
78
 
79
  == Changelog ==
80
 
81
+ = 3.6.7 =
82
+ * Bug fix: Converted prices in secondary currencies were incorrect in some situations. e.g. For VND with an VND:EUR exchange rate of 30,000:1
83
+ * Bug fix: Wrong urls were displayed in the language switcher for product category or product tag urls
84
+
85
  = 3.6.6 =
86
  * Fixed a bug that was causing a PHP warning when using a WPML version prior 3.2
87
 
woocommerce_wpml.class.php CHANGED
@@ -121,6 +121,7 @@ class woocommerce_wpml {
121
  add_filter( 'upgrader_pre_download', array( $this, 'version_update' ), 10, 2 );
122
  add_action( 'admin_notices', array( $this, 'translation_upgrade_notice' ) );
123
  add_action( 'wp_ajax_hide_wcml_translations_message', array($this, 'hide_wcml_translations_message') );
 
124
 
125
  }
126
 
@@ -848,4 +849,17 @@ class woocommerce_wpml {
848
 
849
  }
850
 
 
 
 
 
 
 
 
 
 
 
 
 
 
851
  }
121
  add_filter( 'upgrader_pre_download', array( $this, 'version_update' ), 10, 2 );
122
  add_action( 'admin_notices', array( $this, 'translation_upgrade_notice' ) );
123
  add_action( 'wp_ajax_hide_wcml_translations_message', array($this, 'hide_wcml_translations_message') );
124
+ add_action( 'woocommerce_settings_save_general', array( $this, 'currency_options_update_default_currency'));
125
 
126
  }
127
 
849
 
850
  }
851
 
852
+ function currency_options_update_default_currency(){
853
+ $current_currency = get_option('woocommerce_currency');
854
+ $new_currency = $_POST['woocommerce_currency'];
855
+
856
+ if( isset( $this->settings['currency_options'][ $current_currency ] )){
857
+ $currency_settings = $this->settings['currency_options'][ $current_currency ];
858
+ unset( $this->settings['currency_options'][ $current_currency ] );
859
+ $this->settings['currency_options'][$new_currency] = $currency_settings;
860
+ $this->update_settings();
861
+ }
862
+
863
+ }
864
+
865
  }
wpml-woocommerce.php CHANGED
@@ -5,12 +5,12 @@
5
  Description: Allows running fully multilingual e-Commerce sites with WooCommerce and WPML. <a href="http://wpml.org/documentation/related-projects/woocommerce-multilingual/">Documentation</a>.
6
  Author: OnTheGoSystems
7
  Author URI: http://www.onthegosystems.com/
8
- Version: 3.6.6
9
  */
10
 
11
 
12
  if(defined('WCML_VERSION')) return;
13
- define('WCML_VERSION', '3.6.6');
14
  define('WCML_PLUGIN_PATH', dirname(__FILE__));
15
  define('WCML_PLUGIN_FOLDER', basename(WCML_PLUGIN_PATH));
16
  define('WCML_PLUGIN_URL', plugins_url() . '/' . WCML_PLUGIN_FOLDER);
5
  Description: Allows running fully multilingual e-Commerce sites with WooCommerce and WPML. <a href="http://wpml.org/documentation/related-projects/woocommerce-multilingual/">Documentation</a>.
6
  Author: OnTheGoSystems
7
  Author URI: http://www.onthegosystems.com/
8
+ Version: 3.6.7
9
  */
10
 
11
 
12
  if(defined('WCML_VERSION')) return;
13
+ define('WCML_VERSION', '3.6.7');
14
  define('WCML_PLUGIN_PATH', dirname(__FILE__));
15
  define('WCML_PLUGIN_FOLDER', basename(WCML_PLUGIN_PATH));
16
  define('WCML_PLUGIN_URL', plugins_url() . '/' . WCML_PLUGIN_FOLDER);