WooCommerce MercadoPago - Version 3.0.6

Version Description

Download this release

Release Info

Developer mercadopago
Plugin Icon 128x128 WooCommerce MercadoPago
Version 3.0.6
Comparing to
See all releases

Code changes from version 3.0.5 to 3.0.6

i18n/languages/woocommerce-mercadopago-es_AR.mo CHANGED
Binary file
i18n/languages/woocommerce-mercadopago-es_AR.po CHANGED
@@ -1008,3 +1008,9 @@ msgstr "RAZÓN SOCIAL"
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
 
 
 
 
 
 
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
1011
+
1012
+ msgid "Your products have theirs dimensions well defined."
1013
+ msgstr "Sus productos tienen las dimensiones bien definidas."
1014
+
1015
+ msgid "You have product(s) with invalid dimensions."
1016
+ msgstr "Hay un o más productos que tienen dimensiones invalidas."
i18n/languages/woocommerce-mercadopago-es_CL.mo CHANGED
Binary file
i18n/languages/woocommerce-mercadopago-es_CL.po CHANGED
@@ -1008,3 +1008,9 @@ msgstr "RAZÓN SOCIAL"
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
 
 
 
 
 
 
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
1011
+
1012
+ msgid "Your products have theirs dimensions well defined."
1013
+ msgstr "Sus productos tienen las dimensiones bien definidas."
1014
+
1015
+ msgid "You have product(s) with invalid dimensions."
1016
+ msgstr "Hay un o más productos que tienen dimensiones invalidas."
i18n/languages/woocommerce-mercadopago-es_CO.mo CHANGED
Binary file
i18n/languages/woocommerce-mercadopago-es_CO.po CHANGED
@@ -1008,3 +1008,9 @@ msgstr "RAZÓN SOCIAL"
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
 
 
 
 
 
 
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
1011
+
1012
+ msgid "Your products have theirs dimensions well defined."
1013
+ msgstr "Sus productos tienen las dimensiones bien definidas."
1014
+
1015
+ msgid "You have product(s) with invalid dimensions."
1016
+ msgstr "Hay un o más productos que tienen dimensiones invalidas."
i18n/languages/woocommerce-mercadopago-es_ES.mo CHANGED
Binary file
i18n/languages/woocommerce-mercadopago-es_ES.po CHANGED
@@ -1008,3 +1008,9 @@ msgstr "RAZÓN SOCIAL"
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
 
 
 
 
 
 
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
1011
+
1012
+ msgid "Your products have theirs dimensions well defined."
1013
+ msgstr "Sus productos tienen las dimensiones bien definidas."
1014
+
1015
+ msgid "You have product(s) with invalid dimensions."
1016
+ msgstr "Hay un o más productos que tienen dimensiones invalidas."
i18n/languages/woocommerce-mercadopago-es_MX.mo CHANGED
Binary file
i18n/languages/woocommerce-mercadopago-es_MX.po CHANGED
@@ -1008,3 +1008,9 @@ msgstr "RAZÓN SOCIAL"
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
 
 
 
 
 
 
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
1011
+
1012
+ msgid "Your products have theirs dimensions well defined."
1013
+ msgstr "Sus productos tienen las dimensiones bien definidas."
1014
+
1015
+ msgid "You have product(s) with invalid dimensions."
1016
+ msgstr "Hay un o más productos que tienen dimensiones invalidas."
i18n/languages/woocommerce-mercadopago-es_PE.mo CHANGED
Binary file
i18n/languages/woocommerce-mercadopago-es_PE.po CHANGED
@@ -1008,3 +1008,9 @@ msgstr "RAZÓN SOCIAL"
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
 
 
 
 
 
 
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
1011
+
1012
+ msgid "Your products have theirs dimensions well defined."
1013
+ msgstr "Sus productos tienen las dimensiones bien definidas."
1014
+
1015
+ msgid "You have product(s) with invalid dimensions."
1016
+ msgstr "Hay un o más productos que tienen dimensiones invalidas."
i18n/languages/woocommerce-mercadopago-es_UY.mo CHANGED
Binary file
i18n/languages/woocommerce-mercadopago-es_UY.po CHANGED
@@ -1008,3 +1008,9 @@ msgstr "RAZÓN SOCIAL"
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
 
 
 
 
 
 
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
1011
+
1012
+ msgid "Your products have theirs dimensions well defined."
1013
+ msgstr "Sus productos tienen las dimensiones bien definidas."
1014
+
1015
+ msgid "You have product(s) with invalid dimensions."
1016
+ msgstr "Hay un o más productos que tienen dimensiones invalidas."
i18n/languages/woocommerce-mercadopago-es_VE.mo CHANGED
Binary file
i18n/languages/woocommerce-mercadopago-es_VE.po CHANGED
@@ -1008,3 +1008,9 @@ msgstr "RAZÓN SOCIAL"
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
 
 
 
 
 
 
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
1011
+
1012
+ msgid "Your products have theirs dimensions well defined."
1013
+ msgstr "Sus productos tienen las dimensiones bien definidas."
1014
+
1015
+ msgid "You have product(s) with invalid dimensions."
1016
+ msgstr "Hay un o más productos que tienen dimensiones invalidas."
i18n/languages/woocommerce-mercadopago-pt_BR.mo CHANGED
Binary file
i18n/languages/woocommerce-mercadopago-pt_BR.po CHANGED
@@ -1008,3 +1008,9 @@ msgstr "RAZÃO SOCIAL"
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
 
 
 
 
 
 
1008
 
1009
  msgid "CNPJ"
1010
  msgstr "CNPJ"
1011
+
1012
+ msgid "Your products have theirs dimensions well defined."
1013
+ msgstr "Seus produtos estão com as dimensões bem definidas."
1014
+
1015
+ msgid "You have product(s) with invalid dimensions."
1016
+ msgstr "Um ou mais de seus produtos possuem dimensões inválidas."
i18n/languages/woocommerce-mercadopago.pot CHANGED
@@ -1008,3 +1008,9 @@ msgstr ""
1008
 
1009
  msgid "CNPJ"
1010
  msgstr ""
 
 
 
 
 
 
1008
 
1009
  msgid "CNPJ"
1010
  msgstr ""
1011
+
1012
+ msgid "Your products have theirs dimensions well defined."
1013
+ msgstr ""
1014
+
1015
+ msgid "You have product(s) with invalid dimensions."
1016
+ msgstr ""
includes/WC_WooMercadoPago_BasicGateway.php CHANGED
@@ -29,6 +29,9 @@ class WC_WooMercadoPago_BasicGateway extends WC_Payment_Gateway {
29
  );
30
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
31
  $this->mp->set_email( $email );
 
 
 
32
 
33
  // WooCommerce fields.
34
  $this->id = 'woo-mercado-pago-basic';
@@ -51,7 +54,7 @@ class WC_WooMercadoPago_BasicGateway extends WC_Payment_Gateway {
51
  $this->mp->sandbox_mode( $this->sandbox );
52
 
53
  // How checkout is shown.
54
- $this->title = $this->get_option( 'title' );
55
  $this->description = $this->get_option( 'description' );
56
  $this->method = $this->get_option( 'method', 'iframe' );
57
  $this->iframe_width = $this->get_option( 'iframe_width', '640' );
@@ -375,6 +378,9 @@ class WC_WooMercadoPago_BasicGateway extends WC_Payment_Gateway {
375
  );
376
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
377
  $mp->set_email( $email );
 
 
 
378
  // Analytics.
379
  if ( ! $is_test_user ) {
380
  $infra_data = WC_Woo_Mercado_Pago_Module::get_common_settings();
29
  );
30
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
31
  $this->mp->set_email( $email );
32
+ $locale = get_locale();
33
+ $locale = ( strpos( $locale, '_' ) !== false && strlen( $locale ) == 5 ) ? explode( '_', $locale ) : array('','');
34
+ $this->mp->set_locale( $locale[1] );
35
 
36
  // WooCommerce fields.
37
  $this->id = 'woo-mercado-pago-basic';
54
  $this->mp->sandbox_mode( $this->sandbox );
55
 
56
  // How checkout is shown.
57
+ $this->title = $this->get_option( 'title', __( 'Mercado Pago - Basic Checkout', 'woocommerce-mercadopago' ) );
58
  $this->description = $this->get_option( 'description' );
59
  $this->method = $this->get_option( 'method', 'iframe' );
60
  $this->iframe_width = $this->get_option( 'iframe_width', '640' );
378
  );
379
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
380
  $mp->set_email( $email );
381
+ $locale = get_locale();
382
+ $locale = ( strpos( $locale, '_' ) !== false && strlen( $locale ) == 5 ) ? explode( '_', $locale ) : array('','');
383
+ $mp->set_locale( $locale[1] );
384
  // Analytics.
385
  if ( ! $is_test_user ) {
386
  $infra_data = WC_Woo_Mercado_Pago_Module::get_common_settings();
includes/WC_WooMercadoPago_CustomGateway.php CHANGED
@@ -28,6 +28,9 @@ class WC_WooMercadoPago_CustomGateway extends WC_Payment_Gateway {
28
  );
29
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
30
  $this->mp->set_email( $email );
 
 
 
31
 
32
  // WooCommerce fields.
33
  $this->id = 'woo-mercado-pago-custom';
@@ -48,7 +51,7 @@ class WC_WooMercadoPago_CustomGateway extends WC_Payment_Gateway {
48
  $this->mp->sandbox_mode( $this->sandbox );
49
 
50
  // How checkout is shown.
51
- $this->title = $this->get_option( 'title' );
52
  $this->description = $this->get_option( 'description' );
53
  // How checkout payment behaves.
54
  $this->coupon_mode = $this->get_option( 'coupon_mode', 'no' );
@@ -247,6 +250,9 @@ class WC_WooMercadoPago_CustomGateway extends WC_Payment_Gateway {
247
  );
248
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
249
  $mp->set_email( $email );
 
 
 
250
  // Analytics.
251
  $infra_data = WC_Woo_Mercado_Pago_Module::get_common_settings();
252
  $infra_data['checkout_custom_credit_card'] = ( $this->settings['enabled'] == 'yes' ? 'true' : 'false' );
28
  );
29
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
30
  $this->mp->set_email( $email );
31
+ $locale = get_locale();
32
+ $locale = ( strpos( $locale, '_' ) !== false && strlen( $locale ) == 5 ) ? explode( '_', $locale ) : array('','');
33
+ $this->mp->set_locale( $locale[1] );
34
 
35
  // WooCommerce fields.
36
  $this->id = 'woo-mercado-pago-custom';
51
  $this->mp->sandbox_mode( $this->sandbox );
52
 
53
  // How checkout is shown.
54
+ $this->title = $this->get_option( 'title', __( 'Mercado Pago - Custom Checkout', 'woocommerce-mercadopago' ) );
55
  $this->description = $this->get_option( 'description' );
56
  // How checkout payment behaves.
57
  $this->coupon_mode = $this->get_option( 'coupon_mode', 'no' );
250
  );
251
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
252
  $mp->set_email( $email );
253
+ $locale = get_locale();
254
+ $locale = ( strpos( $locale, '_' ) !== false && strlen( $locale ) == 5 ) ? explode( '_', $locale ) : array('','');
255
+ $mp->set_locale( $locale[1] );
256
  // Analytics.
257
  $infra_data = WC_Woo_Mercado_Pago_Module::get_common_settings();
258
  $infra_data['checkout_custom_credit_card'] = ( $this->settings['enabled'] == 'yes' ? 'true' : 'false' );
includes/WC_WooMercadoPago_SubscriptionGateway.php CHANGED
@@ -29,6 +29,9 @@ class WC_WooMercadoPago_SubscriptionGateway extends WC_Payment_Gateway {
29
  );
30
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
31
  $this->mp->set_email( $email );
 
 
 
32
 
33
  // WooCommerce fields.
34
  $this->id = 'woo-mercado-pago-subscription';
@@ -49,7 +52,7 @@ class WC_WooMercadoPago_SubscriptionGateway extends WC_Payment_Gateway {
49
  $this->mp->sandbox_mode( false );
50
 
51
  // How checkout is shown.
52
- $this->title = $this->get_option( 'title' );
53
  $this->description = $this->get_option( 'description' );
54
  $this->method = $this->get_option( 'method', 'iframe' );
55
  $this->iframe_width = $this->get_option( 'iframe_width', '640' );
@@ -357,6 +360,9 @@ class WC_WooMercadoPago_SubscriptionGateway extends WC_Payment_Gateway {
357
  );
358
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
359
  $mp->set_email( $email );
 
 
 
360
  // Analytics.
361
  $infra_data = WC_Woo_Mercado_Pago_Module::get_common_settings();
362
  $infra_data['checkout_subscription'] = ( $this->settings['enabled'] == 'yes' ? 'true' : 'false' );
29
  );
30
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
31
  $this->mp->set_email( $email );
32
+ $locale = get_locale();
33
+ $locale = ( strpos( $locale, '_' ) !== false && strlen( $locale ) == 5 ) ? explode( '_', $locale ) : array('','');
34
+ $this->mp->set_locale( $locale[1] );
35
 
36
  // WooCommerce fields.
37
  $this->id = 'woo-mercado-pago-subscription';
52
  $this->mp->sandbox_mode( false );
53
 
54
  // How checkout is shown.
55
+ $this->title = $this->get_option( 'title', __( 'Mercado Pago - Subscription', 'woocommerce-mercadopago' ) );
56
  $this->description = $this->get_option( 'description' );
57
  $this->method = $this->get_option( 'method', 'iframe' );
58
  $this->iframe_width = $this->get_option( 'iframe_width', '640' );
360
  );
361
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
362
  $mp->set_email( $email );
363
+ $locale = get_locale();
364
+ $locale = ( strpos( $locale, '_' ) !== false && strlen( $locale ) == 5 ) ? explode( '_', $locale ) : array('','');
365
+ $mp->set_locale( $locale[1] );
366
  // Analytics.
367
  $infra_data = WC_Woo_Mercado_Pago_Module::get_common_settings();
368
  $infra_data['checkout_subscription'] = ( $this->settings['enabled'] == 'yes' ? 'true' : 'false' );
includes/WC_WooMercadoPago_TicketGateway.php CHANGED
@@ -28,6 +28,9 @@ class WC_WooMercadoPago_TicketGateway extends WC_Payment_Gateway {
28
  );
29
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
30
  $this->mp->set_email( $email );
 
 
 
31
 
32
  // WooCommerce fields.
33
  $this->id = 'woo-mercado-pago-ticket';
@@ -49,7 +52,7 @@ class WC_WooMercadoPago_TicketGateway extends WC_Payment_Gateway {
49
  $this->mp->sandbox_mode( $this->sandbox );
50
 
51
  // How checkout is shown.
52
- $this->title = $this->get_option( 'title' );
53
  $this->description = $this->get_option( 'description' );
54
  // How checkout payment behaves.
55
  $this->coupon_mode = $this->get_option( 'coupon_mode', 'no' );
@@ -248,6 +251,9 @@ class WC_WooMercadoPago_TicketGateway extends WC_Payment_Gateway {
248
  );
249
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
250
  $mp->set_email( $email );
 
 
 
251
  // Analytics.
252
  $infra_data = WC_Woo_Mercado_Pago_Module::get_common_settings();
253
  $infra_data['checkout_custom_ticket'] = ( $this->settings['enabled'] == 'yes' ? 'true' : 'false' );
28
  );
29
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
30
  $this->mp->set_email( $email );
31
+ $locale = get_locale();
32
+ $locale = ( strpos( $locale, '_' ) !== false && strlen( $locale ) == 5 ) ? explode( '_', $locale ) : array('','');
33
+ $this->mp->set_locale( $locale[1] );
34
 
35
  // WooCommerce fields.
36
  $this->id = 'woo-mercado-pago-ticket';
52
  $this->mp->sandbox_mode( $this->sandbox );
53
 
54
  // How checkout is shown.
55
+ $this->title = $this->get_option( 'title', __( 'Mercado Pago - Ticket', 'woocommerce-mercadopago' ) );
56
  $this->description = $this->get_option( 'description' );
57
  // How checkout payment behaves.
58
  $this->coupon_mode = $this->get_option( 'coupon_mode', 'no' );
251
  );
252
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
253
  $mp->set_email( $email );
254
+ $locale = get_locale();
255
+ $locale = ( strpos( $locale, '_' ) !== false && strlen( $locale ) == 5 ) ? explode( '_', $locale ) : array('','');
256
+ $mp->set_locale( $locale[1] );
257
  // Analytics.
258
  $infra_data = WC_Woo_Mercado_Pago_Module::get_common_settings();
259
  $infra_data['checkout_custom_ticket'] = ( $this->settings['enabled'] == 'yes' ? 'true' : 'false' );
includes/sdk/lib/mercadopago.php CHANGED
@@ -12,7 +12,7 @@ $GLOBALS['LIB_LOCATION'] = dirname( __FILE__ );
12
 
13
  class MP {
14
 
15
- private $version = '3.0.5';
16
  private $client_id;
17
  private $client_secret;
18
  private $ll_access_token;
@@ -49,6 +49,11 @@ class MP {
49
  MPRestClient::set_email( $email );
50
  MeliRestClient::set_email( $email );
51
  }
 
 
 
 
 
52
 
53
  public function sandbox_mode( $enable = NULL ) {
54
  if ( ! is_null( $enable ) ) {
@@ -766,6 +771,7 @@ class MPRestClient {
766
 
767
  const API_BASE_URL = 'https://api.mercadopago.com';
768
  private static $email_admin = '';
 
769
  private static $check_loop = 0;
770
 
771
  private static function build_request( $request, $version ) {
@@ -947,7 +953,8 @@ class MPRestClient {
947
  'module_version' => $version,
948
  'url_store' => $_SERVER['HTTP_HOST'],
949
  'errors' => $errors,
950
- 'email_admin' => self::$email_admin
 
951
  );
952
  $request = array(
953
  'uri' => '/modules/log',
@@ -997,6 +1004,10 @@ class MPRestClient {
997
  public static function set_email( $email ) {
998
  self::$email_admin = $email;
999
  }
 
 
 
 
1000
 
1001
  }
1002
 
@@ -1004,6 +1015,7 @@ class MeliRestClient {
1004
 
1005
  const API_BASE_URL = 'https://api.mercadolibre.com';
1006
  private static $email_admin = '';
 
1007
  private static $check_loop = 0;
1008
 
1009
  private static function build_request( $request, $version ) {
@@ -1184,7 +1196,8 @@ class MeliRestClient {
1184
  'module_version' => $version,
1185
  'url_store' => $_SERVER['HTTP_HOST'],
1186
  'errors' => $errors,
1187
- 'email_admin' => self::$email_admin
 
1188
  );
1189
  $request = array(
1190
  'uri' => '/modules/log',
@@ -1234,6 +1247,10 @@ class MeliRestClient {
1234
  public static function set_email( $email ) {
1235
  self::$email_admin = $email;
1236
  }
 
 
 
 
1237
 
1238
  }
1239
 
12
 
13
  class MP {
14
 
15
+ private $version = '3.0.6';
16
  private $client_id;
17
  private $client_secret;
18
  private $ll_access_token;
49
  MPRestClient::set_email( $email );
50
  MeliRestClient::set_email( $email );
51
  }
52
+
53
+ public function set_locale( $country_code ) {
54
+ MPRestClient::set_locale( $country_code );
55
+ MeliRestClient::set_locale( $country_code );
56
+ }
57
 
58
  public function sandbox_mode( $enable = NULL ) {
59
  if ( ! is_null( $enable ) ) {
771
 
772
  const API_BASE_URL = 'https://api.mercadopago.com';
773
  private static $email_admin = '';
774
+ private static $site_locale = '';
775
  private static $check_loop = 0;
776
 
777
  private static function build_request( $request, $version ) {
953
  'module_version' => $version,
954
  'url_store' => $_SERVER['HTTP_HOST'],
955
  'errors' => $errors,
956
+ 'email_admin' => self::$email_admin,
957
+ 'country_initial' => self::$site_locale
958
  );
959
  $request = array(
960
  'uri' => '/modules/log',
1004
  public static function set_email( $email ) {
1005
  self::$email_admin = $email;
1006
  }
1007
+
1008
+ public static function set_locale( $country_code ) {
1009
+ self::$site_locale = $country_code;
1010
+ }
1011
 
1012
  }
1013
 
1015
 
1016
  const API_BASE_URL = 'https://api.mercadolibre.com';
1017
  private static $email_admin = '';
1018
+ private static $site_locale = '';
1019
  private static $check_loop = 0;
1020
 
1021
  private static function build_request( $request, $version ) {
1196
  'module_version' => $version,
1197
  'url_store' => $_SERVER['HTTP_HOST'],
1198
  'errors' => $errors,
1199
+ 'email_admin' => self::$email_admin,
1200
+ 'country_initial' => self::$site_locale
1201
  );
1202
  $request = array(
1203
  'uri' => '/modules/log',
1247
  public static function set_email( $email ) {
1248
  self::$email_admin = $email;
1249
  }
1250
+
1251
+ public static function set_locale( $country_code ) {
1252
+ self::$site_locale = $country_code;
1253
+ }
1254
 
1255
  }
1256
 
includes/shipment/abstract-wc-mercadoenvios-shipping.php CHANGED
@@ -118,6 +118,22 @@ abstract class WC_MercadoEnvios_Shipping extends WC_Shipping_Method {
118
  return;
119
  }
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  $shipping_method_id = $this->get_shipping_method_id( $site_id );
122
  $mp = new MP(
123
  WC_Woo_Mercado_Pago_Module::get_module_version(),
@@ -126,11 +142,9 @@ abstract class WC_MercadoEnvios_Shipping extends WC_Shipping_Method {
126
  );
127
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
128
  $mp->set_email( $email );
129
-
130
- // Object package and zipcode.
131
- $me_package = new WC_MercadoEnvios_Package( $package );
132
- $dimensions = $me_package->get_data();
133
- $zip_code = $package['destination']['postcode'];
134
 
135
  // Height x width x length (centimeters), weight (grams).
136
  $params = array(
@@ -342,6 +356,9 @@ abstract class WC_MercadoEnvios_Shipping extends WC_Shipping_Method {
342
  );
343
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
344
  $mp->set_email( $email );
 
 
 
345
 
346
  // Get default data.
347
  $infra_data = WC_Woo_Mercado_Pago_Module::get_common_settings();
118
  return;
119
  }
120
 
121
+ // Object package and zipcode.
122
+ $me_package = new WC_MercadoEnvios_Package( $package );
123
+ $dimensions = $me_package->get_data();
124
+ $zip_code = $package['destination']['postcode'];
125
+
126
+ // An empty zipcode indicates that customer haven't set it yet
127
+ if ( empty( $zip_code ) ) {
128
+ return;
129
+ }
130
+
131
+ // Check validity of dimensions
132
+ if ( ! is_numeric( $dimensions['height'] ) || ! is_numeric( $dimensions['width'] ) ||
133
+ ! is_numeric( $dimensions['length'] ) || ! is_numeric( $dimensions['weight'] ) ) {
134
+ return;
135
+ }
136
+
137
  $shipping_method_id = $this->get_shipping_method_id( $site_id );
138
  $mp = new MP(
139
  WC_Woo_Mercado_Pago_Module::get_module_version(),
142
  );
143
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
144
  $mp->set_email( $email );
145
+ $locale = get_locale();
146
+ $locale = ( strpos( $locale, '_' ) !== false && strlen( $locale ) == 5 ) ? explode( '_', $locale ) : array('','');
147
+ $mp->set_locale( $locale[1] );
 
 
148
 
149
  // Height x width x length (centimeters), weight (grams).
150
  $params = array(
356
  );
357
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
358
  $mp->set_email( $email );
359
+ $locale = get_locale();
360
+ $locale = ( strpos( $locale, '_' ) !== false && strlen( $locale ) == 5 ) ? explode( '_', $locale ) : array('','');
361
+ $mp->set_locale( $locale[1] );
362
 
363
  // Get default data.
364
  $infra_data = WC_Woo_Mercado_Pago_Module::get_common_settings();
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: ecommerce, mercadopago, woocommerce
4
  Requires at least: 4.8
5
  Tested up to: 4.8
6
  Requires PHP: 5.6
7
- Stable tag: 3.0.5
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -215,6 +215,13 @@ Features: LatAm Basic Checkout support. Great for merchants who want to get goin
215
 
216
  == Changelog ==
217
 
 
 
 
 
 
 
 
218
  = v3.0.5 (22/11/2017) =
219
  * Bug fixes
220
  - Fixed a bug in the URL of javascript source for light-box window.
4
  Requires at least: 4.8
5
  Tested up to: 4.8
6
  Requires PHP: 5.6
7
+ Stable tag: 3.0.6
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
10
 
215
 
216
  == Changelog ==
217
 
218
+ = v3.0.6 (13/12/2017) =
219
+ * Improvements
220
+ - Added validation for dimensions of products;
221
+ - Added country code for analytics.
222
+ * Bug fixes
223
+ - Fixed a problem related to the title of payment method, that were in blank when configuring the module for the first time.
224
+
225
  = v3.0.5 (22/11/2017) =
226
  * Bug fixes
227
  - Fixed a bug in the URL of javascript source for light-box window.
templates/mp_main_settings.php CHANGED
@@ -16,6 +16,8 @@
16
  <?php echo $curl_message; ?>
17
  <br>
18
  <?php echo $is_ssl_message; ?>
 
 
19
  </td>
20
  <th scope="row">
21
  <?php echo $mp_logo; ?>
16
  <?php echo $curl_message; ?>
17
  <br>
18
  <?php echo $is_ssl_message; ?>
19
+ <br>
20
+ <?php echo $is_all_products_with_valid_dimensions ?>
21
  </td>
22
  <th scope="row">
23
  <?php echo $mp_logo; ?>
woocommerce-mercadopago.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WooCommerce MercadoPago
4
  * Plugin URI: https://github.com/mercadopago/cart-woocommerce
5
  * Description: This is the <strong>oficial</strong> module of Mercado Pago for WooCommerce plugin. This module enables WooCommerce to use Mercado Pago as a payment Gateway for purchases made in your e-commerce store.
6
- * Version: 3.0.5
7
  * Author: Mercado Pago
8
  * Author URI: https://www.mercadopago.com.br/developers/
9
  * Text Domain: woocommerce-mercadopago
@@ -80,6 +80,7 @@ if ( ! class_exists( 'WC_Woo_Mercado_Pago_Module' ) ) :
80
  * - get_wc_status_for_mp_status( $mp_status )
81
  * - get_map( $selector_id )
82
  * - generate_refund_cancel_subscription( $domain, $success_msg, $fail_msg, $options, $str1, $str2, $str3, $str4 )
 
83
  * @since 3.0.0
84
  */
85
  class WC_Woo_Mercado_Pago_Module {
@@ -87,7 +88,7 @@ if ( ! class_exists( 'WC_Woo_Mercado_Pago_Module' ) ) :
87
  // ============================================================
88
 
89
  // General constants.
90
- const VERSION = '3.0.5';
91
  const MIN_PHP = 5.6;
92
 
93
  // Arrays to hold configurations for LatAm environment.
@@ -310,6 +311,9 @@ if ( ! class_exists( 'WC_Woo_Mercado_Pago_Module' ) ) :
310
  $mp_v0 = new MP( WC_Woo_Mercado_Pago_Module::VERSION, $client_id, $client_secret );
311
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
312
  $mp_v0->set_email( $email );
 
 
 
313
  $access_token = $mp_v0->get_access_token();
314
  $get_request = $mp_v0->get( '/users/me?access_token=' . $access_token );
315
  if ( isset( $get_request['response']['site_id'] ) && ! empty( $access_token ) ) {
@@ -371,6 +375,9 @@ if ( ! class_exists( 'WC_Woo_Mercado_Pago_Module' ) ) :
371
  $mp_v1 = new MP( WC_Woo_Mercado_Pago_Module::VERSION, $access_token );
372
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
373
  $mp_v1->set_email( $email );
 
 
 
374
  $access_token = $mp_v1->get_access_token();
375
  $get_request = $mp_v1->get( '/users/me?access_token=' . $access_token );
376
  if ( isset( $get_request['response']['site_id'] ) && ! empty( $public_key ) ) {
@@ -833,6 +840,34 @@ if ( ! class_exists( 'WC_Woo_Mercado_Pago_Module' ) ) :
833
  '</table>';
834
  return $subscription_js . $subscription_meta_box;
835
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
836
 
837
  }
838
 
@@ -1000,6 +1035,16 @@ if ( ! class_exists( 'WC_Woo_Mercado_Pago_Module' ) ) :
1000
  __( 'SSL is missing in your site.', 'woocommerce-mercadopago' ) :
1001
  '<img width="14" height="14" src="' . plugins_url( 'assets/images/check.png', __FILE__ ) . '"> ' .
1002
  __( 'Your site has SSL enabled.', 'woocommerce-mercadopago' );
 
 
 
 
 
 
 
 
 
 
1003
  // Create links for internal redirections to each payment solution.
1004
  $gateway_buttons = '<strong>' .
1005
  '<a class="button button-primary" href="' . esc_url( admin_url(
3
  * Plugin Name: WooCommerce MercadoPago
4
  * Plugin URI: https://github.com/mercadopago/cart-woocommerce
5
  * Description: This is the <strong>oficial</strong> module of Mercado Pago for WooCommerce plugin. This module enables WooCommerce to use Mercado Pago as a payment Gateway for purchases made in your e-commerce store.
6
+ * Version: 3.0.6
7
  * Author: Mercado Pago
8
  * Author URI: https://www.mercadopago.com.br/developers/
9
  * Text Domain: woocommerce-mercadopago
80
  * - get_wc_status_for_mp_status( $mp_status )
81
  * - get_map( $selector_id )
82
  * - generate_refund_cancel_subscription( $domain, $success_msg, $fail_msg, $options, $str1, $str2, $str3, $str4 )
83
+ * - is_product_dimensions_valid( $all_product_data )
84
  * @since 3.0.0
85
  */
86
  class WC_Woo_Mercado_Pago_Module {
88
  // ============================================================
89
 
90
  // General constants.
91
+ const VERSION = '3.0.6';
92
  const MIN_PHP = 5.6;
93
 
94
  // Arrays to hold configurations for LatAm environment.
311
  $mp_v0 = new MP( WC_Woo_Mercado_Pago_Module::VERSION, $client_id, $client_secret );
312
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
313
  $mp_v0->set_email( $email );
314
+ $locale = get_locale();
315
+ $locale = ( strpos( $locale, '_' ) !== false && strlen( $locale ) == 5 ) ? explode( '_', $locale ) : array('','');
316
+ $mp_v0->set_locale( $locale[1] );
317
  $access_token = $mp_v0->get_access_token();
318
  $get_request = $mp_v0->get( '/users/me?access_token=' . $access_token );
319
  if ( isset( $get_request['response']['site_id'] ) && ! empty( $access_token ) ) {
375
  $mp_v1 = new MP( WC_Woo_Mercado_Pago_Module::VERSION, $access_token );
376
  $email = ( wp_get_current_user()->ID != 0 ) ? wp_get_current_user()->user_email : null;
377
  $mp_v1->set_email( $email );
378
+ $locale = get_locale();
379
+ $locale = ( strpos( $locale, '_' ) !== false && strlen( $locale ) == 5 ) ? explode( '_', $locale ) : array('','');
380
+ $mp_v1->set_locale( $locale[1] );
381
  $access_token = $mp_v1->get_access_token();
382
  $get_request = $mp_v1->get( '/users/me?access_token=' . $access_token );
383
  if ( isset( $get_request['response']['site_id'] ) && ! empty( $public_key ) ) {
840
  '</table>';
841
  return $subscription_js . $subscription_meta_box;
842
  }
843
+
844
+ /**
845
+ * Check if product dimensions are well defined
846
+ */
847
+ public static function is_product_dimensions_valid( $all_product_data ) {
848
+ if ( empty( $all_product_data ) ) {
849
+ return true;
850
+ }
851
+ foreach ( $all_product_data as $p ) {
852
+ $product = wc_get_product( $p->ID );
853
+ if ( ! $product->is_virtual() ) {
854
+ $dimensions = $product->get_dimensions( false );
855
+ if ( ! is_numeric( $dimensions['height'] ) ) {
856
+ return false;
857
+ }
858
+ if ( ! is_numeric( $dimensions['width'] ) ) {
859
+ return false;
860
+ }
861
+ if ( ! is_numeric( $dimensions['length'] ) ) {
862
+ return false;
863
+ }
864
+ if ( empty( $product->get_weight() ) || ! is_numeric( $product->get_weight() ) ) {
865
+ return false;
866
+ }
867
+ }
868
+ }
869
+ return true;
870
+ }
871
 
872
  }
873
 
1035
  __( 'SSL is missing in your site.', 'woocommerce-mercadopago' ) :
1036
  '<img width="14" height="14" src="' . plugins_url( 'assets/images/check.png', __FILE__ ) . '"> ' .
1037
  __( 'Your site has SSL enabled.', 'woocommerce-mercadopago' );
1038
+ // Check porduct dimensions.
1039
+ global $wpdb;
1040
+ $all_product_data = $wpdb->get_results(
1041
+ 'SELECT ID FROM `' . $wpdb->prefix . 'posts` where post_type="product" and post_status = "publish"'
1042
+ );
1043
+ $is_all_products_with_valid_dimensions = WC_Woo_Mercado_Pago_Module::is_product_dimensions_valid( $all_product_data ) ?
1044
+ '<img width="14" height="14" src="' . plugins_url( 'assets/images/check.png', __FILE__ ) . '"> ' .
1045
+ __( 'Your products have theirs dimensions well defined.', 'woocommerce-mercadopago' ) :
1046
+ '<img width="14" height="14" src="' . plugins_url( 'assets/images/warning.png', __FILE__ ) . '"> ' .
1047
+ __( 'You have product(s) with invalid dimensions.', 'woocommerce-mercadopago' );
1048
  // Create links for internal redirections to each payment solution.
1049
  $gateway_buttons = '<strong>' .
1050
  '<a class="button button-primary" href="' . esc_url( admin_url(