Booster for WooCommerce - Version 2.0.10

Version Description

  • 04/01/2015 =
  • Fix - PRODUCTS - Product Info - id option bug, fixed.
  • Fix - CURRENCIES - Currencies - Empty symbol bug, fixed.
  • Dev - CHECKOUT - Custom Checkout Fields - Option to set clear after the field, added.
  • Dev - CURRENCIES - Prices and Currencies by Country - New table woojetpack_country_ip added to DB.
Download this release

Release Info

Developer algoritmika
Plugin Icon 128x128 Booster for WooCommerce
Version 2.0.10
Comparing to
See all releases

Code changes from version 2.0.9 to 2.0.10

includes/class-wcj-checkout-custom-fields.php CHANGED
@@ -213,7 +213,7 @@ class WCJ_Checkout_Custom_Fields {
213
  'placeholder' => get_option( 'wcj_checkout_custom_field_placeholder_' . $i ),
214
  'required' => ( 'yes' === get_option( 'wcj_checkout_custom_field_required_' . $i ) ) ? true : false,
215
  'custom_attributes' => $custom_attributes,
216
- 'clear' => true,
217
  'class' => array( get_option( 'wcj_checkout_custom_field_class_' . $i ), ),
218
  );
219
  }
@@ -381,6 +381,14 @@ class WCJ_Checkout_Custom_Fields {
381
  'form-row-last' => __( 'Last', 'woocommerce-jetpack' ),
382
  ),
383
  'css' => 'width:200px;',
 
 
 
 
 
 
 
 
384
  ),
385
 
386
  /**
213
  'placeholder' => get_option( 'wcj_checkout_custom_field_placeholder_' . $i ),
214
  'required' => ( 'yes' === get_option( 'wcj_checkout_custom_field_required_' . $i ) ) ? true : false,
215
  'custom_attributes' => $custom_attributes,
216
+ 'clear' => ( 'yes' === get_option( 'wcj_checkout_custom_field_clear_' . $i ) ) ? true : false,
217
  'class' => array( get_option( 'wcj_checkout_custom_field_class_' . $i ), ),
218
  );
219
  }
381
  'form-row-last' => __( 'Last', 'woocommerce-jetpack' ),
382
  ),
383
  'css' => 'width:200px;',
384
+ ),
385
+
386
+ array(
387
+ 'title' => '',
388
+ 'desc' => __( 'clear', 'woocommerce-jetpack' ),
389
+ 'id' => 'wcj_checkout_custom_field_clear_' . $i,
390
+ 'default' => 'yes',
391
+ 'type' => 'checkbox',
392
  ),
393
 
394
  /**
includes/class-wcj-currencies.php CHANGED
@@ -89,7 +89,7 @@ class WCJ_Currencies {
89
 
90
  array(
91
  'title' => __( 'Currencies', 'woocommerce-jetpack' ),
92
- 'desc' => __( 'Enable the Currencies feature', 'woocommerce-jetpack' ),
93
  'desc_tip' => __( 'Add all world currencies, change currency symbol.', 'woocommerce-jetpack' ),
94
  'id' => 'wcj_currency_enabled',
95
  'default' => 'yes',
@@ -148,7 +148,7 @@ class WCJ_Currencies {
148
  if ( 'yes' === get_option( 'wcj_currency_hide_symbol' ) )
149
  return '';
150
 
151
- return apply_filters( 'wcj_get_option_filter', $this->currencies_symbols[ $currency ], get_option( 'wcj_currency_' . $currency, $currency_symbol ) );
152
  }
153
 
154
  /*public function check_wooallcurpro_fields($input) {
89
 
90
  array(
91
  'title' => __( 'Currencies', 'woocommerce-jetpack' ),
92
+ 'desc' => '<strong>' . __( 'Enable Module', 'woocommerce-jetpack' ) . '</strong>',
93
  'desc_tip' => __( 'Add all world currencies, change currency symbol.', 'woocommerce-jetpack' ),
94
  'id' => 'wcj_currency_enabled',
95
  'default' => 'yes',
148
  if ( 'yes' === get_option( 'wcj_currency_hide_symbol' ) )
149
  return '';
150
 
151
+ return apply_filters( 'wcj_get_option_filter', $this->currency_symbols[ $currency ], get_option( 'wcj_currency_' . $currency, $currency_symbol ) );
152
  }
153
 
154
  /*public function check_wooallcurpro_fields($input) {
includes/class-wcj-price-by-country.php CHANGED
@@ -24,7 +24,7 @@ class WCJ_Price_By_Country {
24
  $this->customer_country = null;
25
  $this->customer_country_group_id = null;
26
 
27
- $this->current_db_file_version = 3;
28
 
29
  //$this->currency_symbols = include( 'currencies/wcj-currency-symbols.php' );
30
  /*$currencies = include( 'currencies/wcj-currencies.php' );
@@ -67,7 +67,7 @@ class WCJ_Price_By_Country {
67
  add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
68
  add_filter( 'wcj_settings_price_by_country', array( $this, 'get_settings' ), 100 );
69
  add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
70
- }
71
 
72
  public function reinstall_ip_db() {
73
  if ( isset( $_GET['wcj-install-ip-db'] ) && '1' == $_GET['wcj-install-ip-db'] ) {
@@ -210,6 +210,17 @@ class WCJ_Price_By_Country {
210
  return explode( ',', trim( $line ) );
211
  }
212
 
 
 
 
 
 
 
 
 
 
 
 
213
  /**
214
  * check_and_update_database.
215
  */
@@ -222,8 +233,83 @@ class WCJ_Price_By_Country {
222
 
223
  // Get IPs from file
224
  // This product includes GeoLite data created by MaxMind, available from <a href="http://www.maxmind.com">http://www.maxmind.com</a>.
 
225
  $csv = array_map( array( $this, 'parse_csv_line' ), file( plugin_dir_path( __FILE__ ) . 'lib/ipdb.csv' ) );
226
- if ( ! empty ($csv) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
 
228
  /**
229
  update_option( 'wcj_geoipcountry_db_from', array() );
@@ -273,7 +359,7 @@ class WCJ_Price_By_Country {
273
  }
274
  /**/
275
 
276
- /**/
277
  // IPs from
278
  foreach ( $csv as $key => $data )
279
  $column[ $key ] = $data[0];
@@ -289,7 +375,7 @@ class WCJ_Price_By_Country {
289
  $column[ $key ] = $data[2];
290
  update_option( 'wcj_geoipcountry_db_country', $column );
291
  /**/
292
- /**/
293
  $count_db_from = count( get_option( 'wcj_geoipcountry_db_from', array() ) );
294
  $count_db_to = count( get_option( 'wcj_geoipcountry_db_to', array() ) );
295
  $count_db_country = count( get_option( 'wcj_geoipcountry_db_country', array() ) );
@@ -307,6 +393,7 @@ class WCJ_Price_By_Country {
307
 
308
  $output_buffer = ob_get_contents();
309
  ob_end_clean();
 
310
  update_option( 'wcj_geoipcountry_db_update_log', $output_buffer );
311
  }
312
 
@@ -424,6 +511,9 @@ class WCJ_Price_By_Country {
424
  // Update DB if needed
425
  $this->check_and_update_database();
426
 
 
 
 
427
  // Search for IP in DB
428
  $db = get_option( 'wcj_geoipcountry_db_from', array() );
429
  $index = $this->search_for_nearest_below_value( $db, $ip_as_int );
@@ -438,8 +528,9 @@ class WCJ_Price_By_Country {
438
  return $db[ $index ];
439
  }
440
  }
 
441
 
442
- return null;
443
  }
444
 
445
  public function get_user_country_by_ip_external() {
24
  $this->customer_country = null;
25
  $this->customer_country_group_id = null;
26
 
27
+ $this->current_db_file_version = 4;
28
 
29
  //$this->currency_symbols = include( 'currencies/wcj-currency-symbols.php' );
30
  /*$currencies = include( 'currencies/wcj-currencies.php' );
67
  add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
68
  add_filter( 'wcj_settings_price_by_country', array( $this, 'get_settings' ), 100 );
69
  add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
70
+ }
71
 
72
  public function reinstall_ip_db() {
73
  if ( isset( $_GET['wcj-install-ip-db'] ) && '1' == $_GET['wcj-install-ip-db'] ) {
210
  return explode( ',', trim( $line ) );
211
  }
212
 
213
+ /**
214
+ * get_country_by_ip_mysql.
215
+ */
216
+ public function get_country_by_ip_mysql( $ip ) {
217
+ global $wpdb;
218
+ $results = $wpdb->get_results( "SELECT `country_code` FROM `wp_woojetpack_country_ip` WHERE `ip_from` <= $ip AND `ip_to` >= $ip", OBJECT );
219
+ if ( 1 !== count( $results ) )
220
+ return null;
221
+ return $results[0]->country_code;
222
+ }
223
+
224
  /**
225
  * check_and_update_database.
226
  */
233
 
234
  // Get IPs from file
235
  // This product includes GeoLite data created by MaxMind, available from <a href="http://www.maxmind.com">http://www.maxmind.com</a>.
236
+ //$csv = array_map( array( $this, 'parse_csv_line' ), file( plugin_dir_path( __FILE__ ) . 'lib/ipdb.csv' ) );
237
  $csv = array_map( array( $this, 'parse_csv_line' ), file( plugin_dir_path( __FILE__ ) . 'lib/ipdb.csv' ) );
238
+ if ( ! empty ( $csv ) ) {
239
+ // $the_values = file_get_contents( plugin_dir_path( __FILE__ ) . 'lib/ipdb.sql' );
240
+ // if ( ! empty ( $the_values ) ) {
241
+
242
+ global $wpdb;
243
+
244
+ $charset_collate = $wpdb->get_charset_collate();
245
+
246
+ $table_name = $wpdb->prefix . 'woojetpack_country_ip';
247
+
248
+ //echo ( false === $wpdb->query( "DROP TABLE $table_name;" ) ) ? 'truncate-false' : 'truncate-true';
249
+ $wpdb->query( "DROP TABLE $table_name;" );
250
+
251
+ /*$sql = "CREATE TABLE $table_name (
252
+ ip_from BIGINT NOT NULL,
253
+ ip_to BIGINT NOT NULL,
254
+ country_code text NOT NULL,
255
+ UNIQUE KEY ip_from (ip_from)
256
+ ) $charset_collate;";*/
257
+
258
+ $sql = "CREATE TABLE $table_name (
259
+ ip_from BIGINT NOT NULL,
260
+ ip_to BIGINT NOT NULL,
261
+ country_code VARCHAR(2) NOT NULL,
262
+ UNIQUE KEY ip_from (ip_from)
263
+ ) $charset_collate;";
264
+ //echo ( false === $wpdb->query( $sql ) ) ? 'false' : 'true';
265
+ $wpdb->query( $sql );
266
+
267
+ //print_r( $wpdb->get_results("SELECT * FROM $table_name;") );
268
+
269
+ //require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
270
+ //dbDelta( $sql );
271
+
272
+ $i = 0;
273
+ $the_values = '';
274
+ $max_insert_size = 10000;
275
+ $the_size = count( $csv );
276
+ //echo $the_size;
277
+ foreach ( $csv as $key => $data ) {
278
+ $the_values .= "('$data[0]', '$data[1]', '$data[2]'), ";
279
+ //$the_values .= "('" . implode( "', '", $data ) . "'), ";
280
+ $i++;
281
+ if ( $i >= $max_insert_size ) {
282
+ $the_values = rtrim( $the_values, ', ' );
283
+ $wpdb->query( "INSERT INTO $table_name (`ip_from`, `ip_to`, `country_code`) VALUES $the_values;" );
284
+ $i = 0;
285
+ $the_values = '';
286
+ }
287
+ }
288
+ if ( '' != $the_values ) {
289
+ $the_values = rtrim( $the_values, ', ' );
290
+ $wpdb->query( "INSERT INTO $table_name (`ip_from`, `ip_to`, `country_code`) VALUES $the_values;" );
291
+ }
292
+
293
+ $count_db_table = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name;" );
294
+ //print_r( $count_db_table );
295
+
296
+ if ( $the_size != $count_db_table ) {
297
+ // Something went wrong
298
+ update_option( 'wcj_geoipcountry_db_version', -2 );
299
+ }
300
+ else {
301
+ // Finished
302
+ update_option( 'wcj_geoipcountry_db_version', $this->current_db_file_version );
303
+ }
304
+
305
+
306
+ // Depreciated - cleaning
307
+ update_option( 'wcj_geoipcountry_db_from', array() );
308
+ update_option( 'wcj_geoipcountry_db_to', array() );
309
+ update_option( 'wcj_geoipcountry_db_country', array() );
310
+
311
+
312
+
313
 
314
  /**
315
  update_option( 'wcj_geoipcountry_db_from', array() );
359
  }
360
  /**/
361
 
362
+ /**
363
  // IPs from
364
  foreach ( $csv as $key => $data )
365
  $column[ $key ] = $data[0];
375
  $column[ $key ] = $data[2];
376
  update_option( 'wcj_geoipcountry_db_country', $column );
377
  /**/
378
+ /**
379
  $count_db_from = count( get_option( 'wcj_geoipcountry_db_from', array() ) );
380
  $count_db_to = count( get_option( 'wcj_geoipcountry_db_to', array() ) );
381
  $count_db_country = count( get_option( 'wcj_geoipcountry_db_country', array() ) );
393
 
394
  $output_buffer = ob_get_contents();
395
  ob_end_clean();
396
+ //echo $output_buffer;
397
  update_option( 'wcj_geoipcountry_db_update_log', $output_buffer );
398
  }
399
 
511
  // Update DB if needed
512
  $this->check_and_update_database();
513
 
514
+ // Search for IP in DB
515
+ return $this->get_country_by_ip_mysql( $ip_as_int );
516
+ /*
517
  // Search for IP in DB
518
  $db = get_option( 'wcj_geoipcountry_db_from', array() );
519
  $index = $this->search_for_nearest_below_value( $db, $ip_as_int );
528
  return $db[ $index ];
529
  }
530
  }
531
+
532
 
533
+ return null;*/
534
  }
535
 
536
  public function get_user_country_by_ip_external() {
includes/class-wcj-product-info.php CHANGED
@@ -154,11 +154,12 @@ class WCJ_Product_Info {
154
  'before' => '',
155
  'after' => '',
156
  'visibility' => '',
 
157
  'options' => '',
158
  ), $atts, $shortcode );
159
  if ( 'admin' === $atts['visibility'] && ! is_super_admin() )
160
  return '';
161
- if ( '' != ( $result = $this->get_product_info_short_code( $shortcode, $atts['options'] ) ) )
162
  return $atts['before'] . $result . $atts['after'];
163
  return '';
164
  }
@@ -376,11 +377,22 @@ class WCJ_Product_Info {
376
  /**
377
  * get_product_info.
378
  */
379
- public function get_product_info_short_code( $short_code, $options = null ) {
380
 
381
- global $product;
 
 
 
 
 
 
 
 
382
 
383
- if ( ( '%list_attribute%' == $short_code ) && ( empty( $options ) || ! $product ) )
 
 
 
384
  return '';
385
 
386
  switch( $short_code ) {
@@ -701,7 +713,7 @@ class WCJ_Product_Info {
701
 
702
  array(
703
  'title' => __( 'Product Info', 'woocommerce-jetpack' ),
704
- 'desc' => __( 'Enable the Product Info feature', 'woocommerce-jetpack' ),
705
  'desc_tip' => __( 'Add additional info to product, change related products number.', 'woocommerce-jetpack' ),
706
  'id' => 'wcj_product_info_enabled',
707
  'default' => 'yes',
154
  'before' => '',
155
  'after' => '',
156
  'visibility' => '',
157
+ 'id' => 0,
158
  'options' => '',
159
  ), $atts, $shortcode );
160
  if ( 'admin' === $atts['visibility'] && ! is_super_admin() )
161
  return '';
162
+ if ( '' != ( $result = $this->get_product_info_short_code( $shortcode, $atts['id'], $atts['options'] ) ) )
163
  return $atts['before'] . $result . $atts['after'];
164
  return '';
165
  }
377
  /**
378
  * get_product_info.
379
  */
380
+ public function get_product_info_short_code( $short_code, $id = 0, $options = null ) {
381
 
382
+
383
+ if ( 0 != $id ) {
384
+ $product = wc_get_product( $id );
385
+ }
386
+ else {
387
+ if ( ! array_key_exists( 'product', $GLOBALS ) )
388
+ return '';
389
+ global $product;
390
+ }
391
 
392
+ if ( ! $product )
393
+ return '';
394
+
395
+ if ( '%list_attribute%' == $short_code && empty( $options ) )
396
  return '';
397
 
398
  switch( $short_code ) {
713
 
714
  array(
715
  'title' => __( 'Product Info', 'woocommerce-jetpack' ),
716
+ 'desc' => '<strong>' . __( 'Enable Module', 'woocommerce-jetpack' ) . '</strong>',
717
  'desc_tip' => __( 'Add additional info to product, change related products number.', 'woocommerce-jetpack' ),
718
  'id' => 'wcj_product_info_enabled',
719
  'default' => 'yes',
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://algoritmika.com/donate/
4
  Tags: woocommerce,woocommerce jetpack,custom price labels,call for price,currency symbol,remove sorting,remove old product slugs,add to cart text,order number,sequential order numbering,email pdf invoice,pdf invoice,pdf invoices,already in cart,empty cart,redirect to checkout,minimum order amount,customize checkout fields,checkout fields,email,customize product tabs,product tabs,related products number,empty cart,redirect add to cart,redirect to checkout,product already in cart,custom payment gateway,payment gateway icon,auto-complete all orders,custom order statuses,custom order status,remove text from price,custom css,hide categories count,hide subcategories count,hide category count,hide subcategory count,display total sales,custom product tabs,remove product tab,payment gateway fee,
5
  Requires at least: 3.9.1
6
  Tested up to: 4.1
7
- Stable tag: 2.0.9
8
  License: GNU General Public License v3.0
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -68,6 +68,12 @@ To unlock all WooCommerce Jetpack features, please install additional <a href="h
68
 
69
  == Changelog ==
70
 
 
 
 
 
 
 
71
  = 2.0.9 - 01/01/2015 =
72
  * Fix - PRODUCTS - **Bulk Price Coverter** - Not updating on empty price (was setting to zero before).
73
 
4
  Tags: woocommerce,woocommerce jetpack,custom price labels,call for price,currency symbol,remove sorting,remove old product slugs,add to cart text,order number,sequential order numbering,email pdf invoice,pdf invoice,pdf invoices,already in cart,empty cart,redirect to checkout,minimum order amount,customize checkout fields,checkout fields,email,customize product tabs,product tabs,related products number,empty cart,redirect add to cart,redirect to checkout,product already in cart,custom payment gateway,payment gateway icon,auto-complete all orders,custom order statuses,custom order status,remove text from price,custom css,hide categories count,hide subcategories count,hide category count,hide subcategory count,display total sales,custom product tabs,remove product tab,payment gateway fee,
5
  Requires at least: 3.9.1
6
  Tested up to: 4.1
7
+ Stable tag: 2.0.10
8
  License: GNU General Public License v3.0
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
68
 
69
  == Changelog ==
70
 
71
+ = 2.0.10 - 04/01/2015 =
72
+ * Fix - PRODUCTS - **Product Info** - `id` option bug, fixed.
73
+ * Fix - CURRENCIES - **Currencies** - Empty symbol bug, fixed.
74
+ * Dev - CHECKOUT - **Custom Checkout Fields** - Option to set *clear* after the field, added.
75
+ * Dev - CURRENCIES - **Prices and Currencies by Country** - New table `woojetpack_country_ip` added to DB.
76
+
77
  = 2.0.9 - 01/01/2015 =
78
  * Fix - PRODUCTS - **Bulk Price Coverter** - Not updating on empty price (was setting to zero before).
79
 
woocommerce-jetpack.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WooCommerce Jetpack
4
  Plugin URI: http://woojetpack.com
5
  Description: Supercharge your WooCommerce site with these awesome powerful features.
6
- Version: 2.0.9
7
  Author: Algoritmika Ltd
8
  Author URI: http://www.algoritmika.com
9
  Copyright: © 2014 Algoritmika Ltd.
3
  Plugin Name: WooCommerce Jetpack
4
  Plugin URI: http://woojetpack.com
5
  Description: Supercharge your WooCommerce site with these awesome powerful features.
6
+ Version: 2.0.10
7
  Author: Algoritmika Ltd
8
  Author URI: http://www.algoritmika.com
9
  Copyright: © 2014 Algoritmika Ltd.