Booster for WooCommerce - Version 2.5.2

Version Description

  • 21/06/2016 =
  • Dev - "Manage Settings" functionality added.
  • Dev - wcj_add_files_upload_form_to_checkout_frontend function added.
  • Dev - include_modules function code refactoring.
  • Fix - Cart calculate_totals() added on wp_loaded to fix mini cart currency and price issues.
  • Dev - Shortcodes - module (and module_name) attribute added.
  • Dev - Shortcodes - visibility attribute modified.
  • Fix - Shortcodes - Orders - [wcj_order_total_fees_tax] and [wcj_order_total_fees_incl_tax] - using get_line_tax() instead of calculating taxes manually - that should fix the issue with wrong taxes rounding.
  • Dev - Shortcodes - General and Products - [wcj_wholesale_price_table] and [wcj_product_wholesale_price_table] - Table class added.
  • Fix - Shortcodes - Products - [wcj_product_wholesale_price_table] - Price tax bug fixed.
  • Dev - Shortcodes - Products - [wcj_product_wholesale_price_table] - price_row_format attribute added.
  • Dev - PRICES & CURRENCIES - Currency Exchange Rates - "Logging" option added.
  • Dev - PRICES & CURRENCIES - Currency per Product - Initial module release.
  • Dev - PRICES & CURRENCIES - Multicurrency Product Base Price - Removed from currency reports.
  • Dev - PRICES & CURRENCIES - Prices and Currencies by Country - "Revert Currency to Default on Checkout" option added.
  • Fix - PRICES & CURRENCIES - Prices and Currencies by Country - Loading core on admin-ajax.php (caused issue in mini cart).
  • Dev - PRICES & CURRENCIES - Price by User Role - "Make Empty Price" option added.
  • Fix - PRICES & CURRENCIES - Price by User Role - change_price_by_role_shipping() fixed (produced an error if price by user role for shipping was disabled).
  • Dev - PRICES & CURRENCIES - Price Formats - Initial module release.
  • Fix - PRICES & CURRENCIES - Wholesale Price - Old price taxes fixed when displaying in cart.
  • Fix - PRODUCTS - Bookings - is_product and is_bookings_product checks added to enqueue_scripts function.
  • Dev - PRODUCTS - Bookings - "Labels and Messages" settings added.
  • Dev - PRODUCTS - Product Add to Cart - "Disable Quantity Field for All Products" option added.
  • Dev - PRODUCTS - Product Add to Cart - Disable Add to Cart Button (on Single Product Page and/or Loop) options added.
  • Dev - PRODUCTS - Product by User - Initial module release.
  • Dev - PRODUCTS - Product Images - Per product "Hide" options added.
  • Fix - PRODUCTS - Product Images - Meta boxes added only if section is enabled.
  • Dev - PRODUCTS - Product Input Fields - "File: Max size" option added.
  • Dev - PRODUCTS - Product Tabs - do_shortcode added to custom tab titles.
  • Dev - PRODUCTS - SKU - Sequential number generation option added.
  • Dev - PAYMENT GATEWAYS - Custom Gateways - Custom input fields (and [wcj_input_field] shortcode) added.
  • Dev - SHIPPING & ORDERS - Shipping - Custom Shipping - "By Total Cart Weight Table" option added.
  • Dev - SHIPPING & ORDERS - Shipping - "Left to free shipping" - do_shortcode added to all messages.
  • Dev - SHIPPING & ORDERS - Order Custom Statuses - Custom icon and icon color options added.
  • Dev - SHIPPING & ORDERS - Order Numbers - "Enable Order Tracking by Custom Number" option added.
  • Fix - PDF INVOICING & PACKING SLIPS - SetTitle fixed.
  • Fix - PDF INVOICING & PACKING SLIPS - Display & Misc. - Action buttons icons changed.
  • Dev - PDF INVOICING & PACKING SLIPS - Display & Misc. - Confirmation request added to the delete and create buttons.
  • Fix - PDF INVOICING & PACKING SLIPS - Report Tool - Querying by document date instead of order date.
  • Dev - EMAILS & MISC. - General - "PayPal Email per Product" option added.
  • Dev - EMAILS & MISC. - EU VAT Number - Option ("Display") to append EU VAT number to order and my account billing addresses added.
  • Fix - EMAILS & MISC. - EU VAT Number - woocommerce_matched_rates filter changed to woocommerce_find_rates - this fixes the issue with sipping tax not exempting.
  • Tweak - "Unlock all" link modified.
  • Tweak - "No active modules found." message added.
  • Tweak - PRODUCTS - Product Images - Module settings rearranged.
  • Tweak - PDF INVOICING & PACKING SLIPS - Numbering - Fields width and order modified.
  • Tweak - PDF INVOICING & PACKING SLIPS - Templates - "Available Shortcodes" info section modified.
Download this release

Release Info

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

Code changes from version 2.5.1 to 2.5.2

Files changed (46) hide show
  1. includes/admin/class-wc-settings-jetpack.php +81 -14
  2. includes/admin/wcj-modules-cats.php +5 -1
  3. includes/class-wcj-checkout-files-upload.php +20 -9
  4. includes/class-wcj-currency-exchange-rates.php +18 -2
  5. includes/class-wcj-currency-per-product.php +364 -0
  6. includes/class-wcj-eu-vat-number.php +80 -9
  7. includes/class-wcj-general.php +77 -28
  8. includes/class-wcj-multicurrency-product-base-price.php +4 -4
  9. includes/class-wcj-order-custom-statuses.php +55 -20
  10. includes/class-wcj-order-numbers.php +49 -6
  11. includes/class-wcj-payment-gateways.php +75 -2
  12. includes/class-wcj-price-by-country.php +13 -5
  13. includes/class-wcj-price-by-user-role.php +46 -15
  14. includes/class-wcj-price-formats.php +194 -0
  15. includes/class-wcj-product-add-to-cart.php +143 -3
  16. includes/class-wcj-product-bookings.php +88 -25
  17. includes/class-wcj-product-by-user.php +246 -0
  18. includes/class-wcj-product-images.php +158 -94
  19. includes/class-wcj-product-tabs.php +4 -4
  20. includes/class-wcj-shipping.php +7 -7
  21. includes/class-wcj-sku.php +86 -56
  22. includes/class-wcj-wholesale-price.php +7 -3
  23. includes/classes/class-wcj-pdf-invoice.php +12 -4
  24. includes/exchange-rates/class-wcj-exchange-rates-crons.php +18 -5
  25. includes/exchange-rates/class-wcj-exchange-rates.php +5 -3
  26. includes/functions/wcj-functions.php +19 -4
  27. includes/functions/wcj-invoicing-functions.php +7 -7
  28. includes/gateways/class-wc-gateway-wcj-custom.php +6 -5
  29. includes/input-fields/class-wcj-product-input-fields-abstract.php +18 -3
  30. includes/js/wcj-disable-quantity.js +11 -0
  31. includes/js/wcj-pdf-invoicing.js +11 -0
  32. includes/pdf-invoices/class-wcj-pdf-invoicing-report-tool.php +38 -11
  33. includes/pdf-invoices/settings/class-wcj-pdf-invoicing-display.php +37 -12
  34. includes/pdf-invoices/settings/class-wcj-pdf-invoicing-numbering.php +46 -43
  35. includes/pdf-invoices/settings/class-wcj-pdf-invoicing-templates.php +35 -28
  36. includes/price-by-country/class-wcj-price-by-country-core.php +7 -2
  37. includes/reports/class-wcj-currency-reports.php +4 -4
  38. includes/shipping/class-wc-shipping-wcj-custom.php +71 -9
  39. includes/shortcodes/class-wcj-general-shortcodes.php +4 -4
  40. includes/shortcodes/class-wcj-input-field-shortcodes.php +75 -0
  41. includes/shortcodes/class-wcj-orders-shortcodes.php +10 -7
  42. includes/shortcodes/class-wcj-products-add-form-shortcodes.php +225 -66
  43. includes/shortcodes/class-wcj-products-shortcodes.php +24 -8
  44. includes/shortcodes/class-wcj-shortcodes.php +46 -9
  45. readme.txt +52 -1
  46. woocommerce-jetpack.php +278 -123
includes/admin/class-wc-settings-jetpack.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Settings class.
6
  *
7
- * @version 2.4.8
8
  * @since 1.0.0
9
  * @author Algoritmika Ltd.
10
  */
@@ -187,7 +187,7 @@ class WC_Settings_Jetpack extends WC_Settings_Page {
187
  /**
188
  * Output sections (modules) sub menu
189
  *
190
- * @version 2.3.9
191
  */
192
  function output_sections_submenu() {
193
  global $current_section;
@@ -197,6 +197,7 @@ class WC_Settings_Jetpack extends WC_Settings_Page {
197
  $sections['alphabetically'] = __( 'Alphabetically', 'woocommerce-jetpack' );
198
  $sections['by_category'] = __( 'By Category', 'woocommerce-jetpack' );
199
  $sections['active'] = __( 'Active', 'woocommerce-jetpack' );
 
200
  if ( '' == $current_section ) {
201
  $current_section = 'by_category';
202
  }
@@ -238,7 +239,7 @@ class WC_Settings_Jetpack extends WC_Settings_Page {
238
  */
239
  function get_sections() {
240
  return apply_filters( 'wcj_settings_sections', array(
241
- '' => __( 'Dashboard', 'woocommerce-jetpack' ),
242
  ) );
243
  }
244
 
@@ -253,7 +254,7 @@ class WC_Settings_Jetpack extends WC_Settings_Page {
253
  /**
254
  * Output the settings.
255
  *
256
- * @version 2.4.0
257
  */
258
  function output() {
259
 
@@ -263,9 +264,10 @@ class WC_Settings_Jetpack extends WC_Settings_Page {
263
  echo '<div id="wcj_message" class="updated"><p><strong>' . $wcj_notice . '</strong></p></div>';
264
  }
265
 
266
- $is_dashboard = ( '' != $current_section && 'alphabetically' != $current_section && 'by_category' != $current_section && 'active' != $current_section )
267
  ? false : true;
268
 
 
269
  $depreciated_modules = array(
270
  'product_info' => 'Product Info V2',
271
  );
@@ -279,6 +281,60 @@ class WC_Settings_Jetpack extends WC_Settings_Page {
279
  echo '</div>';
280
  }
281
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  if ( 'yes' === get_option( 'wcj_admin_tools_enabled' ) && 'yes' === get_option( 'wcj_debuging_enabled', 'no' ) ) {
283
  // Breadcrumbs
284
  $breadcrumbs_html = '';
@@ -320,32 +376,40 @@ class WC_Settings_Jetpack extends WC_Settings_Page {
320
  /**
321
  * output_dashboard.
322
  *
323
- * @version 2.4.8
324
  */
325
  function output_dashboard( $current_section ) {
 
 
 
326
  $the_settings = $this->get_settings();
327
 
328
  echo '<h3>' . $the_settings[0]['title'] . '</h3>';
329
- echo '<p>' . $the_settings[0]['desc'] . '</p>';
330
-
331
- if ( '' == $current_section ) $current_section = 'by_category';
 
 
332
 
333
  $readme_html = '';
334
  $readme_html .= '<pre>';
335
 
336
  if ( 'alphabetically' === $current_section ) {
337
  $this->output_dashboard_modules( $the_settings );
338
- }
339
- elseif ( 'by_category' === $current_section ) {
340
  foreach ( $this->cats as $cat_id => $cat_label_info ) {
341
  if ( 'dashboard' === $cat_id ) continue;
342
  echo '<h4>' . $cat_label_info['label'] . '</h4>';
343
  $readme_html .= PHP_EOL . '**' . $cat_label_info['label'] . '**' . PHP_EOL . PHP_EOL;
344
  $readme_html .= $this->output_dashboard_modules( $the_settings, $cat_id );
345
  }
346
- }
347
- elseif ( 'active' === $current_section ) {
348
  $this->output_dashboard_modules( $the_settings, 'active_modules_only' );
 
 
 
 
 
349
  }
350
 
351
  echo '<p style="text-align:right;color:gray;font-size:x-small;font-style:italic;">' . __( 'Version' ) . ': ' . get_option( 'booster_for_woocommerce_version', 'N/A' ) . '</p>';
@@ -364,7 +428,7 @@ class WC_Settings_Jetpack extends WC_Settings_Page {
364
  /**
365
  * output_dashboard_modules.
366
  *
367
- * @version 2.4.8
368
  */
369
  function output_dashboard_modules( $settings, $cat_id = '' ) {
370
  $readme_html = '';
@@ -433,6 +497,9 @@ class WC_Settings_Jetpack extends WC_Settings_Page {
433
  $readme_html .= '* *' . $the_feature['title'] . '* - ' . ( ( isset( $the_feature['wcj_desc'] ) ) ? $the_feature['wcj_desc'] : $the_feature['desc_tip'] ) . PHP_EOL;
434
  }
435
  echo $html;
 
 
 
436
  ?></tbody>
437
  </table><p style="color:gray;font-size:x-small;font-style:italic;"><?php echo __( 'Total Modules:' ) . ' ' . $total_modules; ?></p><?php
438
  return $readme_html;
4
  *
5
  * The WooCommerce Jetpack Settings class.
6
  *
7
+ * @version 2.5.2
8
  * @since 1.0.0
9
  * @author Algoritmika Ltd.
10
  */
187
  /**
188
  * Output sections (modules) sub menu
189
  *
190
+ * @version 2.5.2
191
  */
192
  function output_sections_submenu() {
193
  global $current_section;
197
  $sections['alphabetically'] = __( 'Alphabetically', 'woocommerce-jetpack' );
198
  $sections['by_category'] = __( 'By Category', 'woocommerce-jetpack' );
199
  $sections['active'] = __( 'Active', 'woocommerce-jetpack' );
200
+ $sections['manager'] = __( 'Manage Settings', 'woocommerce-jetpack' );
201
  if ( '' == $current_section ) {
202
  $current_section = 'by_category';
203
  }
239
  */
240
  function get_sections() {
241
  return apply_filters( 'wcj_settings_sections', array(
242
+ '' => __( 'Dashboard', 'woocommerce-jetpack' ),
243
  ) );
244
  }
245
 
254
  /**
255
  * Output the settings.
256
  *
257
+ * @version 2.5.2
258
  */
259
  function output() {
260
 
264
  echo '<div id="wcj_message" class="updated"><p><strong>' . $wcj_notice . '</strong></p></div>';
265
  }
266
 
267
+ $is_dashboard = ( '' != $current_section && 'alphabetically' != $current_section && 'by_category' != $current_section && 'active' != $current_section && 'manager' != $current_section )
268
  ? false : true;
269
 
270
+ // Depreciated message
271
  $depreciated_modules = array(
272
  'product_info' => 'Product Info V2',
273
  );
281
  echo '</div>';
282
  }
283
 
284
+ // Multicurrency message
285
+ /* $multicurrency_modules_enabled = 0;
286
+ $multicurrency_modules_titles = array();
287
+ $multicurrency_modules = array( 'price_by_country', 'multicurrency', 'payment_gateways_currency' );
288
+ foreach ( $multicurrency_modules as $multicurrency_module ) {
289
+ if ( wcj_is_module_enabled( $multicurrency_module ) ) {
290
+ $multicurrency_modules_enabled++;
291
+ $multicurrency_modules_titles[] = WCJ()->modules[ $multicurrency_module ]->short_desc;
292
+ }
293
+ }
294
+ if ( $multicurrency_modules_enabled > 1 ) {
295
+ echo '<div id="wcj_message" class="error">';
296
+ echo '<p>';
297
+ echo '<strong>';
298
+ echo sprintf( __( 'Please note that only single multicurrency module can be enabled simultaneously. You have <em>%s</em> modules enabled, please choose one of them.', 'woocommerce-jetpack' ), implode( ', ', $multicurrency_modules_titles ) );
299
+ echo '</strong>';
300
+ echo '</p>';
301
+ echo '</div>';
302
+ } */
303
+
304
+ // Caching message
305
+ /* $known_caching_plugins = array( 'w3-total-cache/w3-total-cache.php' );
306
+ $no_caching_modules = array();
307
+ // $no_caching_modules = array_merge( $no_caching_modules, $multicurrency_modules );
308
+ $caching_plugin_is_active = false;
309
+ foreach ( $known_caching_plugins as $caching_plugin ) {
310
+ // Check if caching_plugin is active
311
+ if (
312
+ in_array( $caching_plugin, apply_filters( 'active_plugins', get_option( 'active_plugins', array() ) ) ) ||
313
+ ( is_multisite() && array_key_exists( $caching_plugin, get_site_option( 'active_sitewide_plugins', array() ) ) )
314
+ ) {
315
+ $caching_plugin_is_active = true;
316
+ break;
317
+ }
318
+ }
319
+ $no_caching_module_is_active = false;
320
+ $no_caching_modules_titles = array();
321
+ foreach ( $no_caching_modules as $no_caching_module ) {
322
+ if ( wcj_is_module_enabled( $no_caching_module ) ) {
323
+ $no_caching_module_is_active = true;
324
+ $no_caching_modules_titles[] = WCJ()->modules[ $no_caching_module ]->short_desc;
325
+ //break;
326
+ }
327
+ }
328
+ if ( $caching_plugin_is_active && $no_caching_module_is_active ) {
329
+ echo '<div id="wcj_message" class="error">';
330
+ echo '<p>';
331
+ echo '<strong>';
332
+ echo sprintf( __( 'Please note that <em>%s</em> modules require caching to be turned off.', 'woocommerce-jetpack' ), implode( ', ', $no_caching_modules_titles ) );
333
+ echo '</strong>';
334
+ echo '</p>';
335
+ echo '</div>';
336
+ } */
337
+
338
  if ( 'yes' === get_option( 'wcj_admin_tools_enabled' ) && 'yes' === get_option( 'wcj_debuging_enabled', 'no' ) ) {
339
  // Breadcrumbs
340
  $breadcrumbs_html = '';
376
  /**
377
  * output_dashboard.
378
  *
379
+ * @version 2.5.2
380
  */
381
  function output_dashboard( $current_section ) {
382
+
383
+ if ( '' == $current_section ) $current_section = 'by_category';
384
+
385
  $the_settings = $this->get_settings();
386
 
387
  echo '<h3>' . $the_settings[0]['title'] . '</h3>';
388
+ if ( 'manager' != $current_section ) {
389
+ echo '<p>' . $the_settings[0]['desc'] . '</p>';
390
+ } else {
391
+ echo '<p>' . __( 'This section lets you export, import or reset all Booster\'s modules settings.', 'woocommerce-jetpack' ) . '</p>';
392
+ }
393
 
394
  $readme_html = '';
395
  $readme_html .= '<pre>';
396
 
397
  if ( 'alphabetically' === $current_section ) {
398
  $this->output_dashboard_modules( $the_settings );
399
+ } elseif ( 'by_category' === $current_section ) {
 
400
  foreach ( $this->cats as $cat_id => $cat_label_info ) {
401
  if ( 'dashboard' === $cat_id ) continue;
402
  echo '<h4>' . $cat_label_info['label'] . '</h4>';
403
  $readme_html .= PHP_EOL . '**' . $cat_label_info['label'] . '**' . PHP_EOL . PHP_EOL;
404
  $readme_html .= $this->output_dashboard_modules( $the_settings, $cat_id );
405
  }
406
+ } elseif ( 'active' === $current_section ) {
 
407
  $this->output_dashboard_modules( $the_settings, 'active_modules_only' );
408
+ } elseif ( 'manager' === $current_section ) {
409
+ echo '<p><button class="button-primary" type="submit" name="booster_export_settings">' . __( 'Export', 'woocommerce-jetpack' ) . '</button></p>';
410
+ echo '<p><button class="button-primary" type="submit" name="booster_import_settings">' . __( 'Import', 'woocommerce-jetpack' ) . '</button>';
411
+ echo ' ' . '<input type="file" name="booster_import_settings_file"></p>';
412
+ echo '<p><button class="button-primary" type="submit" name="booster_reset_settings" onclick="return confirm(\'' . __( 'This will reset settings to defaults for all Booster modules. Are you sure?', 'woocommerce-jetpack' ) . '\')">' . __( 'Reset', 'woocommerce-jetpack' ) . '</button></p>';
413
  }
414
 
415
  echo '<p style="text-align:right;color:gray;font-size:x-small;font-style:italic;">' . __( 'Version' ) . ': ' . get_option( 'booster_for_woocommerce_version', 'N/A' ) . '</p>';
428
  /**
429
  * output_dashboard_modules.
430
  *
431
+ * @version 2.5.2
432
  */
433
  function output_dashboard_modules( $settings, $cat_id = '' ) {
434
  $readme_html = '';
497
  $readme_html .= '* *' . $the_feature['title'] . '* - ' . ( ( isset( $the_feature['wcj_desc'] ) ) ? $the_feature['wcj_desc'] : $the_feature['desc_tip'] ) . PHP_EOL;
498
  }
499
  echo $html;
500
+ if ( 0 == $total_modules && 'active_modules_only' === $cat_id ) {
501
+ echo '<tr><td colspan="3">' . '<em>' . __( 'No active modules found.', 'woocommerce-jetpack' ) . '</em>' . '</td></tr>';
502
+ }
503
  ?></tbody>
504
  </table><p style="color:gray;font-size:x-small;font-style:italic;"><?php echo __( 'Total Modules:' ) . ' ' . $total_modules; ?></p><?php
505
  return $readme_html;
includes/admin/wcj-modules-cats.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Modules Array.
6
  *
7
- * @version 2.5.0
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
@@ -18,6 +18,7 @@ return array(
18
  'alphabetically',
19
  'by_category',
20
  'active',
 
21
  ),
22
  ),
23
 
@@ -28,6 +29,7 @@ return array(
28
  'price_by_country',
29
  'multicurrency',
30
  'multicurrency_base_price',
 
31
  'currency',
32
  'currency_external_products',
33
  'bulk_price_converter',
@@ -36,6 +38,7 @@ return array(
36
  'price_by_user_role',
37
  'product_price_by_formula',
38
  'currency_exchange_rates',
 
39
  ),
40
  ),
41
 
@@ -68,6 +71,7 @@ return array(
68
  'crowdfunding',
69
  'product_images',
70
  'product_by_country',
 
71
  ),
72
  ),
73
 
4
  *
5
  * The WooCommerce Modules Array.
6
  *
7
+ * @version 2.5.2
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
18
  'alphabetically',
19
  'by_category',
20
  'active',
21
+ 'manager',
22
  ),
23
  ),
24
 
29
  'price_by_country',
30
  'multicurrency',
31
  'multicurrency_base_price',
32
+ 'currency_per_product',
33
  'currency',
34
  'currency_external_products',
35
  'bulk_price_converter',
38
  'price_by_user_role',
39
  'product_price_by_formula',
40
  'currency_exchange_rates',
41
+ 'price_formats',
42
  ),
43
  ),
44
 
71
  'crowdfunding',
72
  'product_images',
73
  'product_by_country',
74
+ 'product_by_user',
75
  ),
76
  ),
77
 
includes/class-wcj-checkout-files-upload.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Checkout Files Upload class.
6
  *
7
- * @version 2.5.0
8
  * @since 2.4.5
9
  * @author Algoritmika Ltd.
10
  * @todo styling options;
@@ -454,21 +454,32 @@ class WCJ_Checkout_Files_Upload extends WCJ_Module {
454
  /**
455
  * add_files_upload_form_to_checkout_frontend.
456
  *
457
- * @version 2.5.0
458
  * @since 2.4.5
459
  */
460
  function add_files_upload_form_to_checkout_frontend() {
 
 
 
 
 
 
 
 
 
 
461
  $html = '';
462
  $total_number = apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_checkout_files_upload_total_number', 1 ) );
463
- $current_filter = current_filter();
464
- $current_filter_priority = wcj_current_filter_priority();
 
 
465
  for ( $i = 1; $i <= $total_number; $i++ ) {
466
- if (
467
- 'yes' === get_option( 'wcj_checkout_files_upload_enabled_' . $i, 'yes' ) &&
468
  $current_filter === get_option( 'wcj_checkout_files_upload_hook_' . $i, 'woocommerce_before_checkout_form' ) &&
469
- $current_filter_priority == get_option( 'wcj_checkout_files_upload_hook_priority_' . $i, 10 ) &&
470
- $this->is_visible( $i )
471
- ) {
472
  $file_name = ( isset( $_SESSION[ 'wcj_checkout_files_upload_' . $i ] ) ) ? $_SESSION[ 'wcj_checkout_files_upload_' . $i ]['name'] : '';
473
  $html .= $this->get_the_form( $i, $file_name );
474
  }
4
  *
5
  * The WooCommerce Jetpack Checkout Files Upload class.
6
  *
7
+ * @version 2.5.2
8
  * @since 2.4.5
9
  * @author Algoritmika Ltd.
10
  * @todo styling options;
454
  /**
455
  * add_files_upload_form_to_checkout_frontend.
456
  *
457
+ * @version 2.5.2
458
  * @since 2.4.5
459
  */
460
  function add_files_upload_form_to_checkout_frontend() {
461
+ $this->add_files_upload_form_to_checkout_frontend_all();
462
+ }
463
+
464
+ /**
465
+ * add_files_upload_form_to_checkout_frontend_all.
466
+ *
467
+ * @version 2.5.2
468
+ * @since 2.5.2
469
+ */
470
+ function add_files_upload_form_to_checkout_frontend_all( $is_direct_call = false ) {
471
  $html = '';
472
  $total_number = apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_checkout_files_upload_total_number', 1 ) );
473
+ if ( ! $is_direct_call ) {
474
+ $current_filter = current_filter();
475
+ $current_filter_priority = wcj_current_filter_priority();
476
+ }
477
  for ( $i = 1; $i <= $total_number; $i++ ) {
478
+ $is_filter_ok = ( $is_direct_call ) ? true : (
 
479
  $current_filter === get_option( 'wcj_checkout_files_upload_hook_' . $i, 'woocommerce_before_checkout_form' ) &&
480
+ $current_filter_priority == get_option( 'wcj_checkout_files_upload_hook_priority_' . $i, 10 )
481
+ );
482
+ if ( 'yes' === get_option( 'wcj_checkout_files_upload_enabled_' . $i, 'yes' ) && $is_filter_ok && $this->is_visible( $i ) ) {
483
  $file_name = ( isset( $_SESSION[ 'wcj_checkout_files_upload_' . $i ] ) ) ? $_SESSION[ 'wcj_checkout_files_upload_' . $i ]['name'] : '';
484
  $html .= $this->get_the_form( $i, $file_name );
485
  }
includes/class-wcj-currency-exchange-rates.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Currency Exchange Rates class.
6
  *
7
- * @version 2.5.0
8
  * @since 2.3.0
9
  * @author Algoritmika Ltd.
10
  */
@@ -86,7 +86,7 @@ class WCJ_Currency_Exchange_Rates extends WCJ_Module {
86
  /**
87
  * add_currency_exchange_rates_settings.
88
  *
89
- * @version 2.4.8
90
  */
91
  function add_currency_exchange_rates_settings() {
92
 
@@ -140,6 +140,14 @@ class WCJ_Currency_Exchange_Rates extends WCJ_Module {
140
  }
141
  }
142
 
 
 
 
 
 
 
 
 
143
  if ( wcj_is_module_enabled( 'payment_gateways_currency' ) ) {
144
  // Currency Pairs - Gateway Currency
145
  global $woocommerce;
@@ -152,6 +160,14 @@ class WCJ_Currency_Exchange_Rates extends WCJ_Module {
152
  }
153
  }
154
 
 
 
 
 
 
 
 
 
155
  $settings[] = array(
156
  'type' => 'sectionend',
157
  'id' => 'wcj_currency_exchange_rates_options',
4
  *
5
  * The WooCommerce Jetpack Currency Exchange Rates class.
6
  *
7
+ * @version 2.5.2
8
  * @since 2.3.0
9
  * @author Algoritmika Ltd.
10
  */
86
  /**
87
  * add_currency_exchange_rates_settings.
88
  *
89
+ * @version 2.5.2
90
  */
91
  function add_currency_exchange_rates_settings() {
92
 
140
  }
141
  }
142
 
143
+ if ( wcj_is_module_enabled( 'currency_per_product' ) ) {
144
+ // Currency Pairs - Currency per Product
145
+ for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_currency_per_product_total_number', 1 ) ); $i++ ) {
146
+ $currency_to = get_option( 'wcj_currency_per_product_currency_' . $i );
147
+ $settings = $this->add_currency_pair_setting( $currency_from, $currency_to, $settings );
148
+ }
149
+ }
150
+
151
  if ( wcj_is_module_enabled( 'payment_gateways_currency' ) ) {
152
  // Currency Pairs - Gateway Currency
153
  global $woocommerce;
160
  }
161
  }
162
 
163
+ $settings[] = array(
164
+ 'title' => __( 'Logging', 'woocommerce-jetpack' ),
165
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
166
+ 'id' => 'wcj_currency_exchange_logging_enabled',
167
+ 'default' => 'no',
168
+ 'type' => 'checkbox',
169
+ );
170
+
171
  $settings[] = array(
172
  'type' => 'sectionend',
173
  'id' => 'wcj_currency_exchange_rates_options',
includes/class-wcj-currency-per-product.php ADDED
@@ -0,0 +1,364 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Jetpack Currency per Product
4
+ *
5
+ * The WooCommerce Jetpack Currency per Product class.
6
+ *
7
+ * @version 2.5.2
8
+ * @since 2.5.2
9
+ * @author Algoritmika Ltd.
10
+ */
11
+
12
+ if ( ! defined( 'ABSPATH' ) ) exit;
13
+
14
+ if ( ! class_exists( 'WCJ_Currency_Per_Product' ) ) :
15
+
16
+ class WCJ_Currency_Per_Product extends WCJ_Module {
17
+
18
+ /**
19
+ * Constructor.
20
+ *
21
+ * @version 2.5.2
22
+ * @since 2.5.2
23
+ */
24
+ function __construct() {
25
+
26
+ $this->id = 'currency_per_product';
27
+ $this->short_desc = __( 'Currency per Product', 'woocommerce-jetpack' );
28
+ $this->desc = __( 'Display prices for WooCommerce products in different currencies.', 'woocommerce-jetpack' );
29
+ $this->link = 'http://booster.io/features/woocommerce-currency-per-product/';
30
+ parent::__construct();
31
+
32
+ add_action( 'init', array( $this, 'add_settings_hook' ) );
33
+
34
+ if ( $this->is_enabled() ) {
35
+
36
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
37
+ add_action( 'save_post_product', array( $this, 'save_meta_box' ), PHP_INT_MAX, 2 );
38
+
39
+ //if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
40
+
41
+ // Currency code and symbol
42
+ add_filter( 'woocommerce_currency_symbol', array( $this, 'change_currency_symbol' ), PHP_INT_MAX, 2 );
43
+ add_filter( 'woocommerce_currency', array( $this, 'change_currency_code' ), PHP_INT_MAX );
44
+
45
+ // Add to cart
46
+ add_filter( 'woocommerce_add_cart_item_data', array( $this, 'add_cart_item_data' ), PHP_INT_MAX, 3 );
47
+ add_filter( 'woocommerce_add_cart_item', array( $this, 'add_cart_item' ), PHP_INT_MAX, 2 );
48
+ add_filter( 'woocommerce_get_cart_item_from_session', array( $this, 'get_cart_item_from_session' ), PHP_INT_MAX, 3 );
49
+
50
+ // Price
51
+ add_filter( 'woocommerce_get_price', array( $this, 'change_price' ), PHP_INT_MAX, 2 );
52
+
53
+ // Grouped
54
+ add_filter( 'woocommerce_grouped_price_html', array( $this, 'grouped_price_html' ), PHP_INT_MAX, 2 );
55
+
56
+ //}
57
+ }
58
+ }
59
+
60
+ /**
61
+ * grouped_price_html.
62
+ *
63
+ * @version 2.5.2
64
+ * @since 2.5.2
65
+ */
66
+ function grouped_price_html( $price_html, $_product ) {
67
+ $tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
68
+ $child_prices = array();
69
+
70
+ foreach ( $_product->get_children() as $child_id )
71
+ $child_prices[ $child_id ] = get_post_meta( $child_id, '_price', true );
72
+
73
+ // $child_prices = array_unique( $child_prices );
74
+ $get_price_method = 'get_price_' . $tax_display_mode . 'uding_tax';
75
+
76
+ if ( ! empty( $child_prices ) ) {
77
+ /* $min_price = min( $child_prices );
78
+ $max_price = max( $child_prices );
79
+ $min_price_id = min( array_keys( $child_prices, min( $child_prices ) ) );
80
+ $max_price_id = max( array_keys( $child_prices, max( $child_prices ) ) ); */
81
+ asort( $child_prices );
82
+ $min_price = current( $child_prices );
83
+ $min_price_id = key( $child_prices );
84
+ end( $child_prices );
85
+ $max_price = current( $child_prices );
86
+ $max_price_id = key( $child_prices );
87
+ $min_currency_per_product_currency = get_post_meta( $min_price_id, '_' . 'wcj_currency_per_product_currency', true );
88
+ $max_currency_per_product_currency = get_post_meta( $max_price_id, '_' . 'wcj_currency_per_product_currency', true );
89
+ } else {
90
+ $min_price = '';
91
+ $max_price = '';
92
+ }
93
+
94
+ if ( $min_price ) {
95
+ if ( $min_price == $max_price && $min_currency_per_product_currency === $max_currency_per_product_currency ) {
96
+ $display_price = wc_price( $_product->$get_price_method( 1, $min_price ), array( 'currency' => $min_currency_per_product_currency ) );
97
+ } else {
98
+ $from = wc_price( $_product->$get_price_method( 1, $min_price ), array( 'currency' => $min_currency_per_product_currency ) );
99
+ $to = wc_price( $_product->$get_price_method( 1, $max_price ), array( 'currency' => $max_currency_per_product_currency ) );
100
+ $display_price = sprintf( _x( '%1$s&ndash;%2$s', 'Price range: from-to', 'woocommerce' ), $from, $to );
101
+ }
102
+
103
+ $new_price_html = $display_price . $_product->get_price_suffix();
104
+
105
+ return $new_price_html;
106
+ }
107
+
108
+ return $price_html;
109
+ }
110
+
111
+ /**
112
+ * get_currency_exchange_rate.
113
+ *
114
+ * @version 2.5.2
115
+ * @since 2.5.2
116
+ */
117
+ function get_currency_exchange_rate( $currency_code ) {
118
+ $currency_exchange_rate = 1;
119
+ $total_number = apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_currency_per_product_total_number', 1 ) );
120
+ for ( $i = 1; $i <= $total_number; $i++ ) {
121
+ if ( $currency_code === get_option( 'wcj_currency_per_product_currency_' . $i ) ) {
122
+ $currency_exchange_rate = 1 / get_option( 'wcj_currency_per_product_exchange_rate_' . $i );
123
+ break;
124
+ }
125
+ }
126
+ return $currency_exchange_rate;
127
+ }
128
+
129
+ /**
130
+ * change_price.
131
+ *
132
+ * @version 2.5.2
133
+ * @since 2.5.2
134
+ */
135
+ function change_price( $price, $_product ) {
136
+ if ( isset( $_product->wcj_currency_per_product ) ) {
137
+ $exchange_rate = $this->get_currency_exchange_rate( $_product->wcj_currency_per_product );
138
+ return $price * $exchange_rate;
139
+ }
140
+ return $price;
141
+ }
142
+
143
+ /**
144
+ * get_cart_item_from_session.
145
+ *
146
+ * @version 2.5.2
147
+ * @since 2.5.2
148
+ */
149
+ function get_cart_item_from_session( $item, $values, $key ) {
150
+ if ( array_key_exists( 'wcj_currency_per_product', $values ) ) {
151
+ $item['data']->wcj_currency_per_product = $values['wcj_currency_per_product'];
152
+ }
153
+ return $item;
154
+ }
155
+
156
+ /**
157
+ * add_cart_item_data.
158
+ *
159
+ * @version 2.5.2
160
+ * @since 2.5.2
161
+ */
162
+ function add_cart_item_data( $cart_item_data, $product_id, $variation_id ) {
163
+ $currency_per_product_currency = get_post_meta( $product_id, '_' . 'wcj_currency_per_product_currency', true );
164
+ if ( '' != $currency_per_product_currency ) {
165
+ $cart_item_data['wcj_currency_per_product'] = $currency_per_product_currency;
166
+ }
167
+ return $cart_item_data;
168
+ }
169
+
170
+ /**
171
+ * add_cart_item.
172
+ *
173
+ * @version 2.5.2
174
+ * @since 2.5.2
175
+ */
176
+ function add_cart_item( $cart_item_data, $cart_item_key ) {
177
+ if ( isset( $cart_item_data['wcj_currency_per_product'] ) ) {
178
+ $cart_item_data['data']->wcj_currency_per_product = $cart_item_data['wcj_currency_per_product'];
179
+ }
180
+ return $cart_item_data;
181
+ }
182
+
183
+ /**
184
+ * change_currency_code.
185
+ *
186
+ * @version 2.5.2
187
+ * @since 2.5.2
188
+ */
189
+ public function change_currency_code( $currency ) {
190
+ $the_ID = get_the_ID();
191
+ if ( 0 != $the_ID && 'product' === get_post_type( $the_ID ) ) {
192
+ $currency_per_product_currency = get_post_meta( $the_ID, '_' . 'wcj_currency_per_product_currency', true );
193
+ if ( '' != $currency_per_product_currency ) {
194
+ return $currency_per_product_currency;
195
+ }
196
+ }
197
+ return $currency;
198
+ }
199
+
200
+ /**
201
+ * change_currency_symbol.
202
+ *
203
+ * @version 2.5.2
204
+ * @since 2.5.2
205
+ */
206
+ function change_currency_symbol( $currency_symbol, $currency ) {
207
+ $the_ID = get_the_ID();
208
+ if ( 0 != $the_ID && 'product' === get_post_type( $the_ID ) ) {
209
+ $currency_per_product_currency = get_post_meta( $the_ID, '_' . 'wcj_currency_per_product_currency', true );
210
+ if ( '' != $currency_per_product_currency ) {
211
+ return wcj_get_currency_symbol( $currency_per_product_currency );
212
+ }
213
+ }
214
+ return $currency_symbol;
215
+ }
216
+
217
+ /**
218
+ * get_meta_box_options.
219
+ *
220
+ * @version 2.5.2
221
+ * @since 2.5.2
222
+ */
223
+ function get_meta_box_options() {
224
+ $currency_codes = array();
225
+ $currency_codes[ get_woocommerce_currency() ] = get_woocommerce_currency();
226
+ $total_number = apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_currency_per_product_total_number', 1 ) );
227
+ for ( $i = 1; $i <= $total_number; $i++ ) {
228
+ $currency_codes[ get_option( 'wcj_currency_per_product_currency_' . $i ) ] = get_option( 'wcj_currency_per_product_currency_' . $i );
229
+ }
230
+ $options = array(
231
+ array(
232
+ 'name' => 'wcj_currency_per_product_currency',
233
+ 'default' => get_woocommerce_currency(),
234
+ 'type' => 'select',
235
+ 'title' => __( 'Product Currency', 'woocommerce-jetpack' ),
236
+ 'options' => $currency_codes,
237
+ ),
238
+ );
239
+ return $options;
240
+ }
241
+
242
+ /**
243
+ * add_settings_hook.
244
+ *
245
+ * @version 2.5.2
246
+ * @since 2.5.2
247
+ */
248
+ function add_settings_hook() {
249
+ add_filter( 'wcj_currency_per_product_settings', array( $this, 'add_settings' ) );
250
+ }
251
+
252
+ /**
253
+ * get_settings.
254
+ *
255
+ * @version 2.5.2
256
+ * @since 2.5.2
257
+ */
258
+ function get_settings() {
259
+ $settings = apply_filters( 'wcj_currency_per_product_settings', array() );
260
+ return $this->add_standard_settings( $settings );
261
+ }
262
+
263
+ /**
264
+ * add_settings.
265
+ *
266
+ * @version 2.5.2
267
+ * @since 2.5.2
268
+ */
269
+ function add_settings() {
270
+ $currency_from = get_woocommerce_currency();
271
+ $all_currencies = wcj_get_currencies_names_and_symbols();
272
+ foreach ( $all_currencies as $currency_key => $currency_name ) {
273
+ if ( $currency_from == $currency_key ) {
274
+ unset( $all_currencies[ $currency_key ] );
275
+ }
276
+ }
277
+ $settings = array(
278
+ array(
279
+ 'title' => __( 'Options', 'woocommerce-jetpack' ),
280
+ 'type' => 'title',
281
+ 'id' => 'wcj_currency_per_product_options',
282
+ ),
283
+ array(
284
+ 'title' => __( 'Exchange Rates Updates', 'woocommerce-jetpack' ),
285
+ 'id' => 'wcj_currency_per_product_exchange_rate_update',
286
+ 'default' => 'manual',
287
+ 'type' => 'select',
288
+ 'options' => array(
289
+ 'manual' => __( 'Enter Rates Manually', 'woocommerce-jetpack' ),
290
+ 'auto' => __( 'Automatically via Currency Exchange Rates module', 'woocommerce-jetpack' ),
291
+ ),
292
+ 'desc' => ( '' == apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ) ) ?
293
+ __( 'Visit', 'woocommerce-jetpack' ) . ' <a href="' . admin_url( 'admin.php?page=wc-settings&tab=jetpack&wcj-cat=prices_and_currencies&section=currency_exchange_rates' ) . '">' . __( 'Currency Exchange Rates module', 'woocommerce-jetpack' ) . '</a>'
294
+ :
295
+ apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
296
+ 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
297
+ ),
298
+ array(
299
+ 'type' => 'sectionend',
300
+ 'id' => 'wcj_currency_per_product_options',
301
+ ),
302
+ array(
303
+ 'title' => __( 'Currencies Options', 'woocommerce-jetpack' ),
304
+ 'type' => 'title',
305
+ 'id' => 'wcj_currency_per_product_currencies_options',
306
+ ),
307
+ array(
308
+ 'title' => __( 'Total Currencies', 'woocommerce-jetpack' ),
309
+ 'id' => 'wcj_currency_per_product_total_number',
310
+ 'default' => 1,
311
+ 'type' => 'custom_number',
312
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
313
+ 'custom_attributes' => array_merge(
314
+ is_array( apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) ) ? apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) : array(),
315
+ array( 'step' => '1', 'min' => '1', )
316
+ ),
317
+ ),
318
+ );
319
+ $total_number = apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_currency_per_product_total_number', 1 ) );
320
+ for ( $i = 1; $i <= $total_number; $i++ ) {
321
+ $currency_to = get_option( 'wcj_currency_per_product_currency_' . $i, $currency_from );
322
+ $custom_attributes = array(
323
+ 'currency_from' => $currency_from,
324
+ 'currency_to' => $currency_to,
325
+ 'multiply_by_field_id' => 'wcj_currency_per_product_exchange_rate_' . $i,
326
+ );
327
+ if ( $currency_from == $currency_to ) {
328
+ $custom_attributes['disabled'] = 'disabled';
329
+ }
330
+ $settings = array_merge( $settings, array(
331
+ array(
332
+ 'title' => __( 'Currency', 'woocommerce-jetpack' ) . ' #' . $i,
333
+ 'id' => 'wcj_currency_per_product_currency_' . $i,
334
+ 'default' => $currency_from,
335
+ 'type' => 'select',
336
+ 'options' => $all_currencies,
337
+ 'css' => 'width:250px;',
338
+ ),
339
+ array(
340
+ 'title' => '',
341
+ 'id' => 'wcj_currency_per_product_exchange_rate_' . $i,
342
+ 'default' => 1,
343
+ 'type' => 'exchange_rate',
344
+ 'custom_attributes' => array( 'step' => '0.000001', 'min' => '0', ),
345
+ 'custom_attributes_button' => $custom_attributes,
346
+ 'css' => 'width:100px;',
347
+ 'value' => $currency_from . '/' . $currency_to,
348
+ 'value_title' => sprintf( __( 'Grab %s rate from Yahoo.com', 'woocommerce-jetpack' ), $currency_from . '/' . $currency_to ),
349
+ ),
350
+ ) );
351
+ }
352
+ $settings = array_merge( $settings, array(
353
+ array(
354
+ 'type' => 'sectionend',
355
+ 'id' => 'wcj_currency_per_product_currencies_options',
356
+ ),
357
+ ) );
358
+ return $settings;
359
+ }
360
+ }
361
+
362
+ endif;
363
+
364
+ return new WCJ_Currency_Per_Product();
includes/class-wcj-eu-vat-number.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack EU VAT Number class.
6
  *
7
- * @version 2.5.0
8
  * @since 2.3.9
9
  * @author Algoritmika Ltd.
10
  */
@@ -18,7 +18,7 @@ class WCJ_EU_VAT_Number extends WCJ_Module {
18
  /**
19
  * Constructor.
20
  *
21
- * @version 2.5.0
22
  */
23
  function __construct() {
24
 
@@ -46,17 +46,78 @@ class WCJ_EU_VAT_Number extends WCJ_Module {
46
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
47
  // add_filter( 'woocommerce_form_field_text', array( $this, 'add_eu_vat_verify_button' ), PHP_INT_MAX, 4 );
48
  add_action( 'init', array( $this, 'wcj_validate_eu_vat_number' ) );
49
- add_filter( 'woocommerce_matched_rates', array( $this, 'maybe_exclude_vat' ), PHP_INT_MAX, 2 );
50
  add_action( 'woocommerce_after_checkout_validation', array( $this, 'checkout_validate_vat' ), PHP_INT_MAX );
51
  add_filter( 'woocommerce_customer_meta_fields', array( $this, 'add_eu_vat_number_customer_meta_field' ) );
52
  add_filter( 'default_checkout_billing_eu_vat_number', array( $this, 'add_default_checkout_billing_eu_vat_number' ), PHP_INT_MAX, 2 );
53
- add_action( 'woocommerce_order_details_after_order_table', array( $this, 'add_eu_vat_number_to_order_display' ), PHP_INT_MAX );
54
- add_action( 'woocommerce_email_after_order_table', array( $this, 'add_eu_vat_number_to_order_display' ), PHP_INT_MAX );
 
 
 
 
 
 
 
 
55
 
56
  $this->eu_countries_vat_rates_tool = include_once( 'tools/class-wcj-eu-countries-vat-rates-tool.php' );
57
  }
58
  }
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  /**
61
  * add_eu_vat_number_to_order_display.
62
  *
@@ -167,10 +228,10 @@ class WCJ_EU_VAT_Number extends WCJ_Module {
167
 
168
  /**
169
  * maybe_exclude_vat.
 
 
170
  */
171
- function maybe_exclude_vat( $matched_tax_rates, $tax_class ) {
172
- /* wcj_log( explode( '&', $_POST['post_data'] ) ); */
173
- /* if ( ! isset( $_POST['billing_eu_vat_number'] ) ) return $matched_tax_rates; */
174
  if (
175
  'yes' === get_option( 'wcj_eu_vat_number_validate', 'yes' ) &&
176
  'yes' === get_option( 'wcj_eu_vat_number_disable_for_valid', 'yes' ) &&
@@ -265,7 +326,7 @@ class WCJ_EU_VAT_Number extends WCJ_Module {
265
  /**
266
  * get_settings.
267
  *
268
- * @version 2.4.0
269
  */
270
  function get_settings() {
271
  $settings = array(
@@ -384,6 +445,16 @@ class WCJ_EU_VAT_Number extends WCJ_Module {
384
  'type' => 'textarea',
385
  'css' => 'width:300px;',
386
  ), */
 
 
 
 
 
 
 
 
 
 
387
  array(
388
  'type' => 'sectionend',
389
  'id' => 'wcj_eu_vat_number_options'
4
  *
5
  * The WooCommerce Jetpack EU VAT Number class.
6
  *
7
+ * @version 2.5.2
8
  * @since 2.3.9
9
  * @author Algoritmika Ltd.
10
  */
18
  /**
19
  * Constructor.
20
  *
21
+ * @version 2.5.2
22
  */
23
  function __construct() {
24
 
46
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
47
  // add_filter( 'woocommerce_form_field_text', array( $this, 'add_eu_vat_verify_button' ), PHP_INT_MAX, 4 );
48
  add_action( 'init', array( $this, 'wcj_validate_eu_vat_number' ) );
49
+ add_filter( 'woocommerce_find_rates', array( $this, 'maybe_exclude_vat' ), PHP_INT_MAX, 2 );
50
  add_action( 'woocommerce_after_checkout_validation', array( $this, 'checkout_validate_vat' ), PHP_INT_MAX );
51
  add_filter( 'woocommerce_customer_meta_fields', array( $this, 'add_eu_vat_number_customer_meta_field' ) );
52
  add_filter( 'default_checkout_billing_eu_vat_number', array( $this, 'add_default_checkout_billing_eu_vat_number' ), PHP_INT_MAX, 2 );
53
+
54
+ if ( 'after_order_table' === get_option( 'wcj_eu_vat_number_display_position', 'after_order_table' ) ) {
55
+ add_action( 'woocommerce_order_details_after_order_table', array( $this, 'add_eu_vat_number_to_order_display' ), PHP_INT_MAX );
56
+ add_action( 'woocommerce_email_after_order_table', array( $this, 'add_eu_vat_number_to_order_display' ), PHP_INT_MAX );
57
+ } else {
58
+ add_filter( 'woocommerce_order_formatted_billing_address', array( $this, 'add_eu_vat_number_to_order_billing_address' ), PHP_INT_MAX, 2 );
59
+ add_filter( 'woocommerce_my_account_my_address_formatted_address', array( $this, 'add_eu_vat_number_to_my_account_billing_address' ), PHP_INT_MAX, 3 );
60
+ add_filter( 'woocommerce_localisation_address_formats', array( $this, 'add_eu_vat_number_to_address_formats' ) );
61
+ add_filter( 'woocommerce_formatted_address_replacements', array( $this, 'replace_eu_vat_number_in_address_formats' ), PHP_INT_MAX, 2 );
62
+ }
63
 
64
  $this->eu_countries_vat_rates_tool = include_once( 'tools/class-wcj-eu-countries-vat-rates-tool.php' );
65
  }
66
  }
67
 
68
+ /**
69
+ * replace_eu_vat_number_in_address_formats.
70
+ *
71
+ * @version 2.5.2
72
+ * @since 2.5.2
73
+ */
74
+ function replace_eu_vat_number_in_address_formats( $replacements, $args ) {
75
+ $field_name = 'billing_' . $this->id;
76
+ $replacements['{' . $field_name . '}'] = ( isset( $args[ $field_name ] ) ) ? $args[ $field_name ] : '';
77
+ return $replacements;
78
+ }
79
+
80
+ /**
81
+ * add_eu_vat_number_to_address_formats.
82
+ *
83
+ * @version 2.5.2
84
+ * @since 2.5.2
85
+ */
86
+ function add_eu_vat_number_to_address_formats( $address_formats ) {
87
+ $field_name = 'billing_' . $this->id;
88
+ $modified_address_formats = array();
89
+ foreach ( $address_formats as $country => $address_format ) {
90
+ $modified_address_formats[ $country ] = $address_format . "\n{" . $field_name . '}';
91
+ }
92
+ return $modified_address_formats;
93
+ }
94
+
95
+ /**
96
+ * add_eu_vat_number_to_my_account_billing_address.
97
+ *
98
+ * @version 2.5.2
99
+ * @since 2.5.2
100
+ */
101
+ function add_eu_vat_number_to_my_account_billing_address( $fields, $customer_id, $name ) {
102
+ if ( 'billing' === $name ) {
103
+ $field_name = 'billing_' . $this->id;
104
+ $fields[ $field_name ] = get_user_meta( $customer_id, $field_name, true );
105
+ }
106
+ return $fields;
107
+ }
108
+
109
+ /**
110
+ * add_eu_vat_number_to_order_billing_address.
111
+ *
112
+ * @version 2.5.2
113
+ * @since 2.5.2
114
+ */
115
+ function add_eu_vat_number_to_order_billing_address( $fields, $_order ) {
116
+ $field_name = 'billing_' . $this->id;
117
+ $fields[ $field_name ] = get_post_meta( $_order->id, '_' . $field_name, true );
118
+ return $fields;
119
+ }
120
+
121
  /**
122
  * add_eu_vat_number_to_order_display.
123
  *
228
 
229
  /**
230
  * maybe_exclude_vat.
231
+ *
232
+ * @version 2.5.2
233
  */
234
+ function maybe_exclude_vat( $matched_tax_rates, $args ) {
 
 
235
  if (
236
  'yes' === get_option( 'wcj_eu_vat_number_validate', 'yes' ) &&
237
  'yes' === get_option( 'wcj_eu_vat_number_disable_for_valid', 'yes' ) &&
326
  /**
327
  * get_settings.
328
  *
329
+ * @version 2.5.2
330
  */
331
  function get_settings() {
332
  $settings = array(
445
  'type' => 'textarea',
446
  'css' => 'width:300px;',
447
  ), */
448
+ array(
449
+ 'title' => __( 'Display', 'woocommerce-jetpack' ),
450
+ 'id' => 'wcj_eu_vat_number_display_position',
451
+ 'default' => 'after_order_table',
452
+ 'type' => 'select',
453
+ 'options' => array(
454
+ 'after_order_table' => __( 'After order table', 'woocommerce-jetpack' ),
455
+ 'in_billing_address' => __( 'In billing address', 'woocommerce-jetpack' ),
456
+ ),
457
+ ),
458
  array(
459
  'type' => 'sectionend',
460
  'id' => 'wcj_eu_vat_number_options'
includes/class-wcj-general.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack General class.
6
  *
7
- * @version 2.5.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -17,7 +17,7 @@ class WCJ_General extends WCJ_Module {
17
  /**
18
  * Constructor.
19
  *
20
- * @version 2.5.0
21
  */
22
  public function __construct() {
23
 
@@ -64,7 +64,57 @@ class WCJ_General extends WCJ_Module {
64
  }
65
 
66
  add_action( 'init', array( $this, 'export_csv' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  }
 
68
  }
69
 
70
  /**
@@ -382,11 +432,10 @@ class WCJ_General extends WCJ_Module {
382
  /**
383
  * get_settings.
384
  *
385
- * @version 2.4.8
386
  * @todo add link to Booster's shortcodes list
387
  */
388
  function get_settings() {
389
-
390
  /* $links_html = '';
391
  if ( class_exists( 'RecursiveIteratorIterator' ) && class_exists( 'RecursiveDirectoryIterator' ) ) {
392
  $dir = untrailingslashit( realpath( plugin_dir_path( __FILE__ ) . '/../../woocommerce/templates' ) );
@@ -404,15 +453,12 @@ class WCJ_General extends WCJ_Module {
404
  } else {
405
  $links_html = __( 'PHP 5 is required.', 'woocommerce-jetpack' );
406
  } */
407
-
408
  $settings = array(
409
-
410
  array(
411
  'title' => __( 'Shortcodes Options', 'woocommerce-jetpack' ),
412
  'type' => 'title',
413
  'id' => 'wcj_general_shortcodes_options',
414
  ),
415
-
416
  array(
417
  'title' => __( 'Enable All Shortcodes in WordPress Text Widgets', 'woocommerce-jetpack' ),
418
  'desc_tip' => __( 'This will enable all (including non Booster\'s) shortcodes in WordPress text widgets.', 'woocommerce-jetpack' ),
@@ -421,7 +467,6 @@ class WCJ_General extends WCJ_Module {
421
  'default' => 'no',
422
  'type' => 'checkbox',
423
  ),
424
-
425
  array(
426
  'title' => __( 'Disable Booster\'s Shortcodes', 'woocommerce-jetpack' ),
427
  'desc_tip' => __( 'Disable all Booster\'s shortcodes (for memory saving).', 'woocommerce-jetpack' ),
@@ -430,19 +475,16 @@ class WCJ_General extends WCJ_Module {
430
  'default' => 'no',
431
  'type' => 'checkbox',
432
  ),
433
-
434
  array(
435
  'type' => 'sectionend',
436
  'id' => 'wcj_general_shortcodes_options',
437
  ),
438
-
439
  array(
440
  'title' => __( 'Custom CSS Options', 'woocommerce-jetpack' ),
441
  'type' => 'title',
442
  'desc' => __( 'Another custom CSS, if you need one.', 'woocommerce-jetpack' ),
443
  'id' => 'wcj_general_custom_css_options',
444
  ),
445
-
446
  array(
447
  'title' => __( 'Custom CSS - Front end (Customers)', 'woocommerce-jetpack' ),
448
  'id' => 'wcj_general_custom_css',
@@ -450,7 +492,6 @@ class WCJ_General extends WCJ_Module {
450
  'type' => 'custom_textarea',
451
  'css' => 'width:66%;min-width:300px;min-height:300px;',
452
  ),
453
-
454
  array(
455
  'title' => __( 'Custom CSS - Back end (Admin)', 'woocommerce-jetpack' ),
456
  'id' => 'wcj_general_custom_admin_css',
@@ -458,18 +499,15 @@ class WCJ_General extends WCJ_Module {
458
  'type' => 'custom_textarea',
459
  'css' => 'width:66%;min-width:300px;min-height:300px;',
460
  ),
461
-
462
  array(
463
  'type' => 'sectionend',
464
  'id' => 'wcj_general_custom_css_options',
465
  ),
466
-
467
  array(
468
  'title' => __( 'Product Revisions', 'woocommerce-jetpack' ),
469
  'type' => 'title',
470
  'id' => 'wcj_product_revisions_options',
471
  ),
472
-
473
  array(
474
  'title' => __( 'Product Revisions', 'woocommerce-jetpack' ),
475
  'desc' => __( 'Enable', 'woocommerce-jetpack' ),
@@ -477,18 +515,22 @@ class WCJ_General extends WCJ_Module {
477
  'default' => 'no',
478
  'type' => 'checkbox',
479
  ),
480
-
481
  array(
482
  'type' => 'sectionend',
483
  'id' => 'wcj_product_revisions_options',
484
  ),
485
-
486
  array(
487
  'title' => __( 'Advanced Options', 'woocommerce-jetpack' ),
488
  'type' => 'title',
489
  'id' => 'wcj_general_advanced_options',
490
  ),
491
-
 
 
 
 
 
 
492
  array(
493
  'title' => __( 'Disable Loading Datepicker/Weekpicker CSS', 'woocommerce-jetpack' ),
494
  'desc' => __( 'Disable', 'woocommerce-jetpack' ),
@@ -496,7 +538,6 @@ class WCJ_General extends WCJ_Module {
496
  'default' => 'no',
497
  'type' => 'checkbox',
498
  ),
499
-
500
  array(
501
  'title' => __( 'Datepicker/Weekpicker CSS', 'woocommerce-jetpack' ),
502
  'id' => 'wcj_general_advanced_datepicker_css',
@@ -504,7 +545,6 @@ class WCJ_General extends WCJ_Module {
504
  'type' => 'text',
505
  'css' => 'width:66%;min-width:300px;',
506
  ),
507
-
508
  array(
509
  'title' => __( 'Disable Loading Datepicker/Weekpicker JavaScript', 'woocommerce-jetpack' ),
510
  'desc' => __( 'Disable', 'woocommerce-jetpack' ),
@@ -512,7 +552,6 @@ class WCJ_General extends WCJ_Module {
512
  'default' => 'no',
513
  'type' => 'checkbox',
514
  ),
515
-
516
  array(
517
  'title' => __( 'Disable Loading Timepicker CSS', 'woocommerce-jetpack' ),
518
  'desc' => __( 'Disable', 'woocommerce-jetpack' ),
@@ -520,7 +559,6 @@ class WCJ_General extends WCJ_Module {
520
  'default' => 'no',
521
  'type' => 'checkbox',
522
  ),
523
-
524
  array(
525
  'title' => __( 'Disable Loading Timepicker JavaScript', 'woocommerce-jetpack' ),
526
  'desc' => __( 'Disable', 'woocommerce-jetpack' ),
@@ -528,7 +566,6 @@ class WCJ_General extends WCJ_Module {
528
  'default' => 'no',
529
  'type' => 'checkbox',
530
  ),
531
-
532
  array(
533
  'title' => __( 'Disable Saving PDFs in PHP directory for temporary files', 'woocommerce-jetpack' ),
534
  'desc' => __( 'Disable', 'woocommerce-jetpack' ),
@@ -536,31 +573,43 @@ class WCJ_General extends WCJ_Module {
536
  'default' => 'no',
537
  'type' => 'checkbox',
538
  ),
539
-
540
  array(
541
  'type' => 'sectionend',
542
  'id' => 'wcj_general_advanced_options',
543
  ),
544
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
545
  /* array(
546
  'title' => __( 'WooCommerce Templates Editor Links', 'woocommerce-jetpack' ),
547
  'type' => 'title',
548
  'id' => 'wcj_general_wc_templates_editor_links_options',
549
  ),
550
-
551
  array(
552
  'title' => __( 'Templates', 'woocommerce-jetpack' ),
553
  'id' => 'wcj_general_wc_templates_editor_links',
554
  'type' => 'custom_link',
555
  'link' => '<pre>' . $links_html . '</pre>',
556
  ),
557
-
558
  array(
559
  'type' => 'sectionend',
560
  'id' => 'wcj_general_wc_templates_editor_links_options',
561
  ), */
562
  );
563
-
564
  return $this->add_standard_settings( $settings );
565
  }
566
  }
4
  *
5
  * The WooCommerce Jetpack General class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
17
  /**
18
  * Constructor.
19
  *
20
+ * @version 2.5.2
21
  */
22
  public function __construct() {
23
 
64
  }
65
 
66
  add_action( 'init', array( $this, 'export_csv' ) );
67
+
68
+ if ( 'yes' === get_option( 'wcj_paypal_email_per_product_enabled', 'no' ) ) {
69
+
70
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
71
+ add_action( 'save_post_product', array( $this, 'save_meta_box' ), PHP_INT_MAX, 2 );
72
+
73
+ add_filter( 'woocommerce_payment_gateways', array( $this, 'maybe_change_paypal_email' ) );
74
+ }
75
+ }
76
+ }
77
+
78
+ /**
79
+ * get_meta_box_options.
80
+ *
81
+ * @version 2.5.2
82
+ * @since 2.5.2
83
+ */
84
+ function get_meta_box_options() {
85
+ $options = array(
86
+ array(
87
+ 'name' => 'wcj_paypal_per_product_email',
88
+ 'default' => '',
89
+ 'type' => 'text',
90
+ 'title' => __( 'PayPal Email', 'woocommerce-jetpack' ),
91
+ ),
92
+ );
93
+ return $options;
94
+ }
95
+
96
+ /**
97
+ * maybe_change_paypal_email.
98
+ *
99
+ * @version 2.5.2
100
+ * @since 2.5.2
101
+ */
102
+ function maybe_change_paypal_email( $load_gateways ) {
103
+ if ( isset( WC()->cart ) ) {
104
+ foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
105
+ if ( '' != ( $email = get_post_meta( $values['product_id'], '_' . 'wcj_paypal_per_product_email', true ) ) ) {
106
+ foreach ( $load_gateways as $key => $gateway ) {
107
+ if ( is_string( $gateway ) && 'WC_Gateway_Paypal' === $gateway ) {
108
+ $load_gateway = new $gateway();
109
+ $load_gateway->receiver_email = $load_gateway->email = $load_gateway->settings['receiver_email'] = $load_gateway->settings['email'] = $email;
110
+ $load_gateways[ $key ] = $load_gateway;
111
+ }
112
+ }
113
+ break;
114
+ }
115
+ }
116
  }
117
+ return $load_gateways;
118
  }
119
 
120
  /**
432
  /**
433
  * get_settings.
434
  *
435
+ * @version 2.5.2
436
  * @todo add link to Booster's shortcodes list
437
  */
438
  function get_settings() {
 
439
  /* $links_html = '';
440
  if ( class_exists( 'RecursiveIteratorIterator' ) && class_exists( 'RecursiveDirectoryIterator' ) ) {
441
  $dir = untrailingslashit( realpath( plugin_dir_path( __FILE__ ) . '/../../woocommerce/templates' ) );
453
  } else {
454
  $links_html = __( 'PHP 5 is required.', 'woocommerce-jetpack' );
455
  } */
 
456
  $settings = array(
 
457
  array(
458
  'title' => __( 'Shortcodes Options', 'woocommerce-jetpack' ),
459
  'type' => 'title',
460
  'id' => 'wcj_general_shortcodes_options',
461
  ),
 
462
  array(
463
  'title' => __( 'Enable All Shortcodes in WordPress Text Widgets', 'woocommerce-jetpack' ),
464
  'desc_tip' => __( 'This will enable all (including non Booster\'s) shortcodes in WordPress text widgets.', 'woocommerce-jetpack' ),
467
  'default' => 'no',
468
  'type' => 'checkbox',
469
  ),
 
470
  array(
471
  'title' => __( 'Disable Booster\'s Shortcodes', 'woocommerce-jetpack' ),
472
  'desc_tip' => __( 'Disable all Booster\'s shortcodes (for memory saving).', 'woocommerce-jetpack' ),
475
  'default' => 'no',
476
  'type' => 'checkbox',
477
  ),
 
478
  array(
479
  'type' => 'sectionend',
480
  'id' => 'wcj_general_shortcodes_options',
481
  ),
 
482
  array(
483
  'title' => __( 'Custom CSS Options', 'woocommerce-jetpack' ),
484
  'type' => 'title',
485
  'desc' => __( 'Another custom CSS, if you need one.', 'woocommerce-jetpack' ),
486
  'id' => 'wcj_general_custom_css_options',
487
  ),
 
488
  array(
489
  'title' => __( 'Custom CSS - Front end (Customers)', 'woocommerce-jetpack' ),
490
  'id' => 'wcj_general_custom_css',
492
  'type' => 'custom_textarea',
493
  'css' => 'width:66%;min-width:300px;min-height:300px;',
494
  ),
 
495
  array(
496
  'title' => __( 'Custom CSS - Back end (Admin)', 'woocommerce-jetpack' ),
497
  'id' => 'wcj_general_custom_admin_css',
499
  'type' => 'custom_textarea',
500
  'css' => 'width:66%;min-width:300px;min-height:300px;',
501
  ),
 
502
  array(
503
  'type' => 'sectionend',
504
  'id' => 'wcj_general_custom_css_options',
505
  ),
 
506
  array(
507
  'title' => __( 'Product Revisions', 'woocommerce-jetpack' ),
508
  'type' => 'title',
509
  'id' => 'wcj_product_revisions_options',
510
  ),
 
511
  array(
512
  'title' => __( 'Product Revisions', 'woocommerce-jetpack' ),
513
  'desc' => __( 'Enable', 'woocommerce-jetpack' ),
515
  'default' => 'no',
516
  'type' => 'checkbox',
517
  ),
 
518
  array(
519
  'type' => 'sectionend',
520
  'id' => 'wcj_product_revisions_options',
521
  ),
 
522
  array(
523
  'title' => __( 'Advanced Options', 'woocommerce-jetpack' ),
524
  'type' => 'title',
525
  'id' => 'wcj_general_advanced_options',
526
  ),
527
+ array(
528
+ 'title' => __( 'Recalculate Cart Totals on Every Page Load', 'woocommerce-jetpack' ),
529
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
530
+ 'id' => 'wcj_general_advanced_recalculate_cart_totals',
531
+ 'default' => 'no',
532
+ 'type' => 'checkbox',
533
+ ),
534
  array(
535
  'title' => __( 'Disable Loading Datepicker/Weekpicker CSS', 'woocommerce-jetpack' ),
536
  'desc' => __( 'Disable', 'woocommerce-jetpack' ),
538
  'default' => 'no',
539
  'type' => 'checkbox',
540
  ),
 
541
  array(
542
  'title' => __( 'Datepicker/Weekpicker CSS', 'woocommerce-jetpack' ),
543
  'id' => 'wcj_general_advanced_datepicker_css',
545
  'type' => 'text',
546
  'css' => 'width:66%;min-width:300px;',
547
  ),
 
548
  array(
549
  'title' => __( 'Disable Loading Datepicker/Weekpicker JavaScript', 'woocommerce-jetpack' ),
550
  'desc' => __( 'Disable', 'woocommerce-jetpack' ),
552
  'default' => 'no',
553
  'type' => 'checkbox',
554
  ),
 
555
  array(
556
  'title' => __( 'Disable Loading Timepicker CSS', 'woocommerce-jetpack' ),
557
  'desc' => __( 'Disable', 'woocommerce-jetpack' ),
559
  'default' => 'no',
560
  'type' => 'checkbox',
561
  ),
 
562
  array(
563
  'title' => __( 'Disable Loading Timepicker JavaScript', 'woocommerce-jetpack' ),
564
  'desc' => __( 'Disable', 'woocommerce-jetpack' ),
566
  'default' => 'no',
567
  'type' => 'checkbox',
568
  ),
 
569
  array(
570
  'title' => __( 'Disable Saving PDFs in PHP directory for temporary files', 'woocommerce-jetpack' ),
571
  'desc' => __( 'Disable', 'woocommerce-jetpack' ),
573
  'default' => 'no',
574
  'type' => 'checkbox',
575
  ),
 
576
  array(
577
  'type' => 'sectionend',
578
  'id' => 'wcj_general_advanced_options',
579
  ),
580
+ array(
581
+ 'title' => __( 'PayPal Email per Product Options', 'woocommerce-jetpack' ),
582
+ 'type' => 'title',
583
+ 'id' => 'wcj_paypal_email_per_product_options',
584
+ ),
585
+ array(
586
+ 'title' => __( 'PayPal Email per Product', 'woocommerce-jetpack' ),
587
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
588
+ 'desc_tip' => __( 'This will add new meta box to each product\'s edit page.', 'woocommerce-jetpack' ),
589
+ 'id' => 'wcj_paypal_email_per_product_enabled',
590
+ 'default' => 'no',
591
+ 'type' => 'checkbox',
592
+ ),
593
+ array(
594
+ 'type' => 'sectionend',
595
+ 'id' => 'wcj_paypal_email_per_product_options',
596
+ ),
597
  /* array(
598
  'title' => __( 'WooCommerce Templates Editor Links', 'woocommerce-jetpack' ),
599
  'type' => 'title',
600
  'id' => 'wcj_general_wc_templates_editor_links_options',
601
  ),
 
602
  array(
603
  'title' => __( 'Templates', 'woocommerce-jetpack' ),
604
  'id' => 'wcj_general_wc_templates_editor_links',
605
  'type' => 'custom_link',
606
  'link' => '<pre>' . $links_html . '</pre>',
607
  ),
 
608
  array(
609
  'type' => 'sectionend',
610
  'id' => 'wcj_general_wc_templates_editor_links_options',
611
  ), */
612
  );
 
613
  return $this->add_standard_settings( $settings );
614
  }
615
  }
includes/class-wcj-multicurrency-product-base-price.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Multicurrency Product Base Price class.
6
  *
7
- * @version 2.5.0
8
  * @since 2.4.8
9
  * @author Algoritmika Ltd.
10
  */
@@ -18,7 +18,7 @@ class WCJ_Multicurrency_Base_Price extends WCJ_Module {
18
  /**
19
  * Constructor.
20
  *
21
- * @version 2.5.0
22
  * @since 2.4.8
23
  */
24
  function __construct() {
@@ -53,9 +53,9 @@ class WCJ_Multicurrency_Base_Price extends WCJ_Module {
53
  add_filter( 'woocommerce_get_price_excluding_tax', array( $this, 'change_price_by_currency_grouped' ), PHP_INT_MAX - 10, 3 );
54
  }
55
 
56
- if ( is_admin() ) {
57
  include_once( 'reports/class-wcj-currency-reports.php' );
58
- }
59
  }
60
  }
61
 
4
  *
5
  * The WooCommerce Jetpack Multicurrency Product Base Price class.
6
  *
7
+ * @version 2.5.2
8
  * @since 2.4.8
9
  * @author Algoritmika Ltd.
10
  */
18
  /**
19
  * Constructor.
20
  *
21
+ * @version 2.5.2
22
  * @since 2.4.8
23
  */
24
  function __construct() {
53
  add_filter( 'woocommerce_get_price_excluding_tax', array( $this, 'change_price_by_currency_grouped' ), PHP_INT_MAX - 10, 3 );
54
  }
55
 
56
+ /* if ( is_admin() ) {
57
  include_once( 'reports/class-wcj-currency-reports.php' );
58
+ } */
59
  }
60
  }
61
 
includes/class-wcj-order-custom-statuses.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Order Custom Statuses class.
6
  *
7
- * @version 2.3.10
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
@@ -116,34 +116,46 @@ class WCJ_Order_Custom_Statuses extends WCJ_Module {
116
  /**
117
  * hook_statuses_icons_css.
118
  *
119
- * @todo content, color
120
  */
121
  public function hook_statuses_icons_css() {
122
  $output = '<style>';
123
  $statuses = function_exists( 'wc_get_order_statuses' ) ? wc_get_order_statuses() : array();
124
  foreach( $statuses as $status => $status_name ) {
125
  if ( ! array_key_exists( $status, $this->default_statuses ) ) {
126
- $output .= 'mark.' . substr( $status, 3 ) . '::after { content: "\e011"; color: #999; }';
 
 
 
 
 
 
 
127
  $output .= 'mark.' . substr( $status, 3 ) . ':after {font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;margin:0;text-indent:0;position:absolute;top:0;left:0;width:100%;height:100%;text-align:center}';
128
  }
129
  }
130
- $output .= '.close:after { content: "\e011"; }';
131
  $output .= '</style>';
132
  echo $output;
133
  }
134
 
135
  /**
136
  * Add new custom status to wcj_orders_custom_statuses_array.
 
 
137
  */
138
- public function add_custom_status( $new_status, $new_status_label ) {
139
 
140
  // Checking function arguments
141
- if ( ! isset( $new_status ) || '' == $new_status )
142
  return '<div class="error"><p>' . __( 'Status slug is empty. Status not added.', 'woocommerce-jetpack' ) . '</p></div>';
143
- if ( strlen( $new_status ) > 17 )
 
144
  return '<div class="error"><p>' . __( 'The length of status slug must be 17 or less characters.', 'woocommerce-jetpack' ) . '</p></div>';
145
- if ( ! isset( $new_status_label ) || '' == $new_status_label )
 
146
  return '<div class="error"><p>' . __( 'Status label is empty. Status not added.', 'woocommerce-jetpack' ) . '</p></div>';
 
147
 
148
  // Checking status
149
  $statuses_updated = ( '' == get_option( 'wcj_orders_custom_statuses_array' ) ) ? array() : get_option( 'wcj_orders_custom_statuses_array' );
@@ -154,29 +166,35 @@ class WCJ_Order_Custom_Statuses extends WCJ_Module {
154
 
155
  // Adding custom status
156
  $result = update_option( 'wcj_orders_custom_statuses_array', $statuses_updated );
157
- if ( true === $result )
 
 
 
 
158
  return '<div class="updated"><p>' . __( 'New status have been successfully added!', 'woocommerce-jetpack' ) . '</p></div>';
159
- else
160
  return '<div class="error"><p>' . __( 'Status was not added.', 'woocommerce-jetpack' ) . '</p></div>';
 
161
  }
162
 
163
  /**
164
  * create_custom_statuses_tool.
165
  *
166
- * @version 2.3.8
167
  */
168
  public function create_custom_statuses_tool() {
169
  $result_message = '';
170
- if ( isset( $_POST['add_custom_status'] ) )
171
- $result_message = $this->add_custom_status( $_POST['new_status'], $_POST['new_status_label'] );
172
- else if ( isset( $_GET['delete'] ) && ( '' != $_GET['delete'] ) ) {
173
  $statuses_updated = apply_filters( 'wc_order_statuses', $statuses_updated );
174
  unset( $statuses_updated[ $_GET['delete'] ] );
175
  $result = update_option( 'wcj_orders_custom_statuses_array', $statuses_updated );
176
- if ( true === $result )
177
  $result_message = '<div class="updated"><p>' . __( 'Status have been successfully deleted.', 'woocommerce-jetpack' ) . '</p></div>';
178
- else
179
  $result_message = '<div class="error"><p>' . __( 'Delete failed.', 'woocommerce-jetpack' ) . '</p></div>';
 
180
  }
181
  echo $this->get_back_to_settings_link_html() . '<br>';
182
  ?><div>
@@ -188,6 +206,8 @@ class WCJ_Order_Custom_Statuses extends WCJ_Module {
188
  echo '<tr>';
189
  echo '<th>' . __( 'Slug', 'woocommerce-jetpack' ) . '</th>';
190
  echo '<th>' . __( 'Label', 'woocommerce-jetpack' ) . '</th>';
 
 
191
  echo '<th>' . __( 'Delete', 'woocommerce-jetpack' ) . '</th>';
192
  echo '</tr>';
193
  $statuses = function_exists( 'wc_get_order_statuses' ) ? wc_get_order_statuses() : array();
@@ -195,10 +215,22 @@ class WCJ_Order_Custom_Statuses extends WCJ_Module {
195
  echo '<tr>';
196
  echo '<td>' . esc_attr( $status ) . '</td>';
197
  echo '<td>' . esc_html( $status_name ) . '</td>';
198
- if ( array_key_exists( $status, $this->default_statuses ) )
 
 
199
  echo '<td></td>';
200
- else
 
 
 
 
 
 
 
 
 
201
  echo '<td>' . '<a href="' . add_query_arg( 'delete', $status ) . '">' . __( 'Delete', 'woocommerce-jetpack' ) . '</a>' . '</td>';
 
202
  echo '</tr>';
203
  }
204
  ?></table>
@@ -210,8 +242,11 @@ class WCJ_Order_Custom_Statuses extends WCJ_Module {
210
  <div class="inside">
211
  <form method="post" action="<?php echo remove_query_arg( 'delete' ); ?>">
212
  <ul>
213
- <li><?php _e( 'Slug (without wc- prefix)', 'woocommerce-jetpack' ); ?><input type="text" name="new_status" style="width:100%;"></li>
214
- <li><?php _e( 'Label', 'woocommerce-jetpack' ); ?><input type="text" name="new_status_label" style="width:100%;"></li>
 
 
 
215
  </ul>
216
  <input class="button-primary" type="submit" name="add_custom_status" value="Add new custom status">
217
  </form>
4
  *
5
  * The WooCommerce Jetpack Order Custom Statuses class.
6
  *
7
+ * @version 2.5.2
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
116
  /**
117
  * hook_statuses_icons_css.
118
  *
119
+ * @verison 2.5.2
120
  */
121
  public function hook_statuses_icons_css() {
122
  $output = '<style>';
123
  $statuses = function_exists( 'wc_get_order_statuses' ) ? wc_get_order_statuses() : array();
124
  foreach( $statuses as $status => $status_name ) {
125
  if ( ! array_key_exists( $status, $this->default_statuses ) ) {
126
+ if ( '' != ( $icon_data = get_option( 'wcj_orders_custom_status_icon_data_' . substr( $status, 3 ), '' ) ) ) {
127
+ $content = $icon_data['content'];
128
+ $color = $icon_data['color'];
129
+ } else {
130
+ $content = 'e011';
131
+ $color = '#999999';
132
+ }
133
+ $output .= 'mark.' . substr( $status, 3 ) . '::after { content: "\\' . $content . '"; color: ' . $color . '; }';
134
  $output .= 'mark.' . substr( $status, 3 ) . ':after {font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;margin:0;text-indent:0;position:absolute;top:0;left:0;width:100%;height:100%;text-align:center}';
135
  }
136
  }
137
+ // $output .= '.close:after { content: "\e011"; }';
138
  $output .= '</style>';
139
  echo $output;
140
  }
141
 
142
  /**
143
  * Add new custom status to wcj_orders_custom_statuses_array.
144
+ *
145
+ * @version 2.5.2
146
  */
147
+ public function add_custom_status( $new_status, $new_status_label, $new_status_icon_content, $new_status_icon_color ) {
148
 
149
  // Checking function arguments
150
+ if ( ! isset( $new_status ) || '' == $new_status ) {
151
  return '<div class="error"><p>' . __( 'Status slug is empty. Status not added.', 'woocommerce-jetpack' ) . '</p></div>';
152
+ }
153
+ if ( strlen( $new_status ) > 17 ) {
154
  return '<div class="error"><p>' . __( 'The length of status slug must be 17 or less characters.', 'woocommerce-jetpack' ) . '</p></div>';
155
+ }
156
+ if ( ! isset( $new_status_label ) || '' == $new_status_label ) {
157
  return '<div class="error"><p>' . __( 'Status label is empty. Status not added.', 'woocommerce-jetpack' ) . '</p></div>';
158
+ }
159
 
160
  // Checking status
161
  $statuses_updated = ( '' == get_option( 'wcj_orders_custom_statuses_array' ) ) ? array() : get_option( 'wcj_orders_custom_statuses_array' );
166
 
167
  // Adding custom status
168
  $result = update_option( 'wcj_orders_custom_statuses_array', $statuses_updated );
169
+ $result = update_option( 'wcj_orders_custom_status_icon_data_' . $new_status, array(
170
+ 'content' => $new_status_icon_content,
171
+ 'color' => $new_status_icon_color,
172
+ ) );
173
+ if ( true === $result ) {
174
  return '<div class="updated"><p>' . __( 'New status have been successfully added!', 'woocommerce-jetpack' ) . '</p></div>';
175
+ } else {
176
  return '<div class="error"><p>' . __( 'Status was not added.', 'woocommerce-jetpack' ) . '</p></div>';
177
+ }
178
  }
179
 
180
  /**
181
  * create_custom_statuses_tool.
182
  *
183
+ * @version 2.5.2
184
  */
185
  public function create_custom_statuses_tool() {
186
  $result_message = '';
187
+ if ( isset( $_POST['add_custom_status'] ) ) {
188
+ $result_message = $this->add_custom_status( $_POST['new_status'], $_POST['new_status_label'], $_POST['new_status_icon_content'], $_POST['new_status_icon_color'] );
189
+ } elseif ( isset( $_GET['delete'] ) && ( '' != $_GET['delete'] ) ) {
190
  $statuses_updated = apply_filters( 'wc_order_statuses', $statuses_updated );
191
  unset( $statuses_updated[ $_GET['delete'] ] );
192
  $result = update_option( 'wcj_orders_custom_statuses_array', $statuses_updated );
193
+ if ( true === $result ) {
194
  $result_message = '<div class="updated"><p>' . __( 'Status have been successfully deleted.', 'woocommerce-jetpack' ) . '</p></div>';
195
+ } else {
196
  $result_message = '<div class="error"><p>' . __( 'Delete failed.', 'woocommerce-jetpack' ) . '</p></div>';
197
+ }
198
  }
199
  echo $this->get_back_to_settings_link_html() . '<br>';
200
  ?><div>
206
  echo '<tr>';
207
  echo '<th>' . __( 'Slug', 'woocommerce-jetpack' ) . '</th>';
208
  echo '<th>' . __( 'Label', 'woocommerce-jetpack' ) . '</th>';
209
+ echo '<th>' . __( 'Icon Code', 'woocommerce-jetpack' ) . '</th>';
210
+ echo '<th>' . __( 'Icon Color', 'woocommerce-jetpack' ) . '</th>';
211
  echo '<th>' . __( 'Delete', 'woocommerce-jetpack' ) . '</th>';
212
  echo '</tr>';
213
  $statuses = function_exists( 'wc_get_order_statuses' ) ? wc_get_order_statuses() : array();
215
  echo '<tr>';
216
  echo '<td>' . esc_attr( $status ) . '</td>';
217
  echo '<td>' . esc_html( $status_name ) . '</td>';
218
+ if ( array_key_exists( $status, $this->default_statuses ) ) {
219
+ echo '<td></td>';
220
+ echo '<td></td>';
221
  echo '<td></td>';
222
+ } else {
223
+ if ( '' != ( $icon_data = get_option( 'wcj_orders_custom_status_icon_data_' . substr( $status, 3 ), '' ) ) ) {
224
+ $content = $icon_data['content'];
225
+ $color = $icon_data['color'];
226
+ } else {
227
+ $content = 'e011';
228
+ $color = '#999999';
229
+ }
230
+ echo '<td>' . $content . '</td>';
231
+ echo '<td>' . '<input disabled type="color" value="' . $color . '">' . '</td>';
232
  echo '<td>' . '<a href="' . add_query_arg( 'delete', $status ) . '">' . __( 'Delete', 'woocommerce-jetpack' ) . '</a>' . '</td>';
233
+ }
234
  echo '</tr>';
235
  }
236
  ?></table>
242
  <div class="inside">
243
  <form method="post" action="<?php echo remove_query_arg( 'delete' ); ?>">
244
  <ul>
245
+ <li><?php _e( 'Slug (without wc- prefix)', 'woocommerce-jetpack' ); ?> <input type="text" name="new_status" style="width:100%;"></li>
246
+ <li><?php _e( 'Label', 'woocommerce-jetpack' ); ?> <input type="text" name="new_status_label" style="width:100%;"></li>
247
+ <li><?php _e( 'Icon Code', 'woocommerce-jetpack' ); ?> <input type="text" name="new_status_icon_content" value="e011"></li>
248
+ <li><?php _e( 'Icon Color', 'woocommerce-jetpack' ); ?> <input type="color" name="new_status_icon_color" value="#999999"><br><?php
249
+ echo sprintf( __( 'You can check icon codes <a target="_blank" href="%s">here</a>.', 'woocommerce-jetpack' ), 'https://rawgit.com/woothemes/woocommerce-icons/master/demo.html' ); ?></li>
250
  </ul>
251
  <input class="button-primary" type="submit" name="add_custom_status" value="Add new custom status">
252
  </form>
includes/class-wcj-order-numbers.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Order Numbers class.
6
  *
7
- * @version 2.5.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -17,7 +17,7 @@ class WCJ_Order_Numbers extends WCJ_Module {
17
  /**
18
  * Constructor.
19
  *
20
- * @version 2.5.0
21
  */
22
  public function __construct() {
23
 
@@ -36,12 +36,48 @@ class WCJ_Order_Numbers extends WCJ_Module {
36
  ) );
37
 
38
  if ( $this->is_enabled() ) {
39
- // add_action( 'woocommerce_new_order', array( $this, 'add_new_order_number' ), PHP_INT_MAX );
40
- add_action( 'wp_insert_post', array( $this, 'add_new_order_number' ), PHP_INT_MAX );
41
- add_filter( 'woocommerce_order_number', array( $this, 'display_order_number' ), PHP_INT_MAX, 2 );
 
 
 
42
  }
43
  }
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  /**
46
  * Display order number.
47
  *
@@ -159,7 +195,7 @@ class WCJ_Order_Numbers extends WCJ_Module {
159
  /**
160
  * get_settings.
161
  *
162
- * @version 2.4.4
163
  */
164
  function get_settings() {
165
  $settings = array(
@@ -240,6 +276,13 @@ class WCJ_Order_Numbers extends WCJ_Module {
240
  'default' => 'no',
241
  'type' => 'checkbox',
242
  ),
 
 
 
 
 
 
 
243
  array(
244
  'type' => 'sectionend',
245
  'id' => 'wcj_order_numbers_options',
4
  *
5
  * The WooCommerce Jetpack Order Numbers class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
17
  /**
18
  * Constructor.
19
  *
20
+ * @version 2.5.2
21
  */
22
  public function __construct() {
23
 
36
  ) );
37
 
38
  if ( $this->is_enabled() ) {
39
+ // add_action( 'woocommerce_new_order', array( $this, 'add_new_order_number' ), PHP_INT_MAX );
40
+ add_action( 'wp_insert_post', array( $this, 'add_new_order_number' ), PHP_INT_MAX );
41
+ add_filter( 'woocommerce_order_number', array( $this, 'display_order_number' ), PHP_INT_MAX, 2 );
42
+ if ( 'yes' === get_option( 'wcj_order_number_order_tracking_enabled', 'yes' ) ) {
43
+ add_filter( 'woocommerce_shortcode_order_tracking_order_id', array( $this, 'add_order_number_to_tracking' ), PHP_INT_MAX );
44
+ }
45
  }
46
  }
47
 
48
+ /**
49
+ * add_order_number_to_tracking.
50
+ *
51
+ * @version 2.5.2
52
+ * @since 2.5.2
53
+ */
54
+ function add_order_number_to_tracking( $order_number ) {
55
+ $offset = 0;
56
+ $block_size = 96;
57
+ while( true ) {
58
+ $args = array(
59
+ 'post_type' => 'shop_order',
60
+ 'post_status' => 'any',
61
+ 'posts_per_page' => $block_size,
62
+ 'orderby' => 'date',
63
+ 'order' => 'DESC',
64
+ 'offset' => $offset,
65
+ );
66
+ $loop = new WP_Query( $args );
67
+ if ( ! $loop->have_posts() ) break;
68
+ while ( $loop->have_posts() ) : $loop->the_post();
69
+ $_order_id = $loop->post->ID;
70
+ $_order = wc_get_order( $_order_id );
71
+ $_order_number = $this->display_order_number( $_order_id, $_order );
72
+ if ( $_order_number === $order_number ) {
73
+ return $_order_id;
74
+ }
75
+ endwhile;
76
+ $offset += $block_size;
77
+ }
78
+ return $order_number;
79
+ }
80
+
81
  /**
82
  * Display order number.
83
  *
195
  /**
196
  * get_settings.
197
  *
198
+ * @version 2.5.2
199
  */
200
  function get_settings() {
201
  $settings = array(
276
  'default' => 'no',
277
  'type' => 'checkbox',
278
  ),
279
+ array(
280
+ 'title' => __( 'Enable Order Tracking by Custom Number', 'woocommerce-jetpack' ),
281
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
282
+ 'id' => 'wcj_order_number_order_tracking_enabled',
283
+ 'default' => 'yes',
284
+ 'type' => 'checkbox',
285
+ ),
286
  array(
287
  'type' => 'sectionend',
288
  'id' => 'wcj_order_numbers_options',
includes/class-wcj-payment-gateways.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Payment Gateways class.
6
  *
7
- * @version 2.4.8
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -17,7 +17,7 @@ class WCJ_Payment_Gateways extends WCJ_Module {
17
  /**
18
  * Constructor.
19
  *
20
- * @version 2.4.8
21
  */
22
  public function __construct() {
23
 
@@ -30,6 +30,79 @@ class WCJ_Payment_Gateways extends WCJ_Module {
30
  if ( $this->is_enabled() ) {
31
  // Include custom payment gateway
32
  include_once( 'gateways/class-wc-gateway-wcj-custom.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  }
34
  }
35
 
4
  *
5
  * The WooCommerce Jetpack Payment Gateways class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
17
  /**
18
  * Constructor.
19
  *
20
+ * @version 2.5.2
21
  */
22
  public function __construct() {
23
 
30
  if ( $this->is_enabled() ) {
31
  // Include custom payment gateway
32
  include_once( 'gateways/class-wc-gateway-wcj-custom.php' );
33
+
34
+ add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'update_custom_payment_gateways_fields_order_meta' ), PHP_INT_MAX, 2 );
35
+ add_action( 'add_meta_boxes', array( $this, 'add_custom_payment_gateways_fields_admin_order_meta_box' ) );
36
+ }
37
+ }
38
+
39
+ /**
40
+ * add_custom_payment_gateways_fields_admin_order_meta_box.
41
+ *
42
+ * @version 2.5.2
43
+ * @since 2.5.2
44
+ */
45
+ function add_custom_payment_gateways_fields_admin_order_meta_box() {
46
+ $order_id = get_the_ID();
47
+ $input_fields = get_post_meta( $order_id, '_wcj_custom_payment_gateway_input_fields', true );
48
+ if ( ! empty( $input_fields ) ) {
49
+ $payment_method_title = get_post_meta( $order_id, '_payment_method_title', true );
50
+ $screen = 'shop_order';
51
+ $context = 'side';
52
+ $priority = 'high';
53
+ add_meta_box(
54
+ 'wc-jetpack-' . $this->id,
55
+ __( 'Booster', 'woocommerce-jetpack' ) . ': ' . sprintf( __( '%s Fields', 'woocommerce-jetpack' ), $payment_method_title ),
56
+ array( $this, 'create_custom_payment_gateways_fields_admin_order_meta_box' ),
57
+ $screen,
58
+ $context,
59
+ $priority
60
+ );
61
+ }
62
+ }
63
+
64
+ /**
65
+ * create_custom_payment_gateways_fields_admin_order_meta_box.
66
+ *
67
+ * @version 2.5.2
68
+ * @since 2.5.2
69
+ */
70
+ function create_custom_payment_gateways_fields_admin_order_meta_box() {
71
+ $order_id = get_the_ID();
72
+ $html = '';
73
+ $input_fields = get_post_meta( $order_id, '_wcj_custom_payment_gateway_input_fields', true );
74
+ $table_data = array();
75
+ foreach ( $input_fields as $name => $value ) {
76
+ $table_data[] = array( $name, $value );
77
+ }
78
+ $html .= wcj_get_table_html( $table_data, array( 'table_class' => 'widefat striped', 'table_heading_type' => 'vertical', ) );
79
+ echo $html;
80
+ }
81
+
82
+ /**
83
+ * update_custom_payment_gateways_fields_order_meta.
84
+ *
85
+ * @version 2.5.2
86
+ * @since 2.5.2
87
+ */
88
+ function update_custom_payment_gateways_fields_order_meta( $order_id, $posted ) {
89
+ $payment_method = get_post_meta( $order_id, '_payment_method', true );
90
+ if ( 'jetpack_custom_gateway' === substr( $payment_method, 0, 22 ) ) {
91
+ $input_fields = array();
92
+ foreach ( $_POST as $key => $value ) {
93
+ if ( 'wcj_input_field_' === substr( $key, 0, 16 ) ) {
94
+ if ( isset( $_POST[ 'for_' . $key ] ) && $payment_method === $_POST[ 'for_' . $key ] ) {
95
+ if ( isset( $_POST[ 'label_for_' . $key ] ) ) {
96
+ $input_fields[ $_POST[ 'label_for_' . $key ] ] = $value;
97
+ } else {
98
+ $input_fields[ substr( $key, 16 ) ] = $value;
99
+ }
100
+ }
101
+ }
102
+ }
103
+ if ( ! empty( $input_fields ) ) {
104
+ update_post_meta( $order_id, '_wcj_custom_payment_gateway_input_fields', $input_fields );
105
+ }
106
  }
107
  }
108
 
includes/class-wcj-price-by-country.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Price by Country class.
6
  *
7
- * @version 2.5.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -17,7 +17,7 @@ class WCJ_Price_By_Country extends WCJ_Module {
17
  /**
18
  * Constructor.
19
  *
20
- * @version 2.4.8
21
  */
22
  public function __construct() {
23
 
@@ -34,12 +34,12 @@ class WCJ_Price_By_Country extends WCJ_Module {
34
 
35
  if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
36
  $do_load_core = true;
37
- if ( is_admin() ) {
38
  global $pagenow;
39
  if ( 'admin-ajax.php' === $pagenow ) {
40
  $do_load_core = false;
41
  }
42
- }
43
  if ( ! defined( 'DOING_AJAX' ) && '/wc-api/WC_Gateway_Paypal/' == $_SERVER['REQUEST_URI'] ) {
44
  // "Wrong currency in emails" bug fix
45
  $do_load_core = false;
@@ -66,7 +66,7 @@ class WCJ_Price_By_Country extends WCJ_Module {
66
  /**
67
  * get_settings.
68
  *
69
- * @version 2.5.0
70
  */
71
  function get_settings() {
72
 
@@ -114,6 +114,14 @@ class WCJ_Price_By_Country extends WCJ_Module {
114
  'type' => 'checkbox',
115
  ),
116
 
 
 
 
 
 
 
 
 
117
  array(
118
  'title' => __( 'Price Rounding', 'woocommerce-jetpack' ),
119
  'desc' => __( 'If you choose to multiply price, set rounding options here.', 'woocommerce-jetpack' ),
4
  *
5
  * The WooCommerce Jetpack Price by Country class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
17
  /**
18
  * Constructor.
19
  *
20
+ * @version 2.5.2
21
  */
22
  public function __construct() {
23
 
34
 
35
  if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
36
  $do_load_core = true;
37
+ /* if ( is_admin() ) {
38
  global $pagenow;
39
  if ( 'admin-ajax.php' === $pagenow ) {
40
  $do_load_core = false;
41
  }
42
+ } */
43
  if ( ! defined( 'DOING_AJAX' ) && '/wc-api/WC_Gateway_Paypal/' == $_SERVER['REQUEST_URI'] ) {
44
  // "Wrong currency in emails" bug fix
45
  $do_load_core = false;
66
  /**
67
  * get_settings.
68
  *
69
+ * @version 2.5.2
70
  */
71
  function get_settings() {
72
 
114
  'type' => 'checkbox',
115
  ),
116
 
117
+ array(
118
+ 'title' => __( 'Revert Currency to Default on Checkout', 'woocommerce-jetpack' ),
119
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
120
+ 'id' => 'wcj_price_by_country_revert',
121
+ 'default' => 'no',
122
+ 'type' => 'checkbox',
123
+ ),
124
+
125
  array(
126
  'title' => __( 'Price Rounding', 'woocommerce-jetpack' ),
127
  'desc' => __( 'If you choose to multiply price, set rounding options here.', 'woocommerce-jetpack' ),
includes/class-wcj-price-by-user-role.php CHANGED
@@ -4,9 +4,10 @@
4
  *
5
  * The WooCommerce Jetpack Price by User Role class.
6
  *
7
- * @version 2.5.0
8
  * @since 2.5.0
9
  * @author Algoritmika Ltd.
 
10
  */
11
 
12
  if ( ! defined( 'ABSPATH' ) ) exit;
@@ -115,7 +116,7 @@ class WCJ_Price_By_User_Role extends WCJ_Module {
115
  /**
116
  * get_meta_box_options.
117
  *
118
- * @version 2.5.0
119
  * @since 2.5.0
120
  */
121
  function get_meta_box_options() {
@@ -173,6 +174,19 @@ class WCJ_Price_By_User_Role extends WCJ_Module {
173
  'product_id' => $product_id,
174
  'meta_name' => '_' . 'wcj_price_by_user_role_sale_price_' . $role_key,
175
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  ) );
177
  }
178
  }
@@ -263,7 +277,7 @@ class WCJ_Price_By_User_Role extends WCJ_Module {
263
  /**
264
  * change_price_by_role_shipping.
265
  *
266
- * @version 2.5.0
267
  * @since 2.5.0
268
  */
269
  function change_price_by_role_shipping( $package_rates, $package ) {
@@ -282,8 +296,9 @@ class WCJ_Price_By_User_Role extends WCJ_Module {
282
  }
283
  $modified_package_rates[ $id ] = $package_rate;
284
  }
 
285
  }
286
- return $modified_package_rates;
287
  }
288
 
289
  /**
@@ -314,7 +329,7 @@ class WCJ_Price_By_User_Role extends WCJ_Module {
314
  /**
315
  * change_price_by_role.
316
  *
317
- * @version 2.5.0
318
  * @since 2.5.0
319
  */
320
  function change_price_by_role( $price, $_product ) {
@@ -325,6 +340,9 @@ class WCJ_Price_By_User_Role extends WCJ_Module {
325
  if ( 'yes' === get_option( 'wcj_price_by_user_role_per_product_enabled', 'yes' ) ) {
326
  if ( 'yes' === get_post_meta( $_product->id, '_' . 'wcj_price_by_user_role_per_product_settings_enabled', true ) ) {
327
  $the_product_id = ( isset( $_product->variation_id ) ) ? $_product->variation_id : $_product->id;
 
 
 
328
  if ( '' != ( $regular_price_per_product = get_post_meta( $the_product_id, '_' . 'wcj_price_by_user_role_regular_price_' . $current_user_role, true ) ) ) {
329
  $the_current_filter = current_filter();
330
  if ( 'woocommerce_get_price_including_tax' == $the_current_filter || 'woocommerce_get_price_excluding_tax' == $the_current_filter ) {
@@ -344,6 +362,9 @@ class WCJ_Price_By_User_Role extends WCJ_Module {
344
  }
345
 
346
  // Global
 
 
 
347
  if ( 1 != ( $koef = get_option( 'wcj_price_by_user_role_' . $current_user_role, 1 ) ) ) {
348
  return ( '' === $price ) ? $price : $price * $koef;
349
  }
@@ -355,15 +376,17 @@ class WCJ_Price_By_User_Role extends WCJ_Module {
355
  /**
356
  * get_variation_prices_hash.
357
  *
358
- * @version 2.5.0
359
  * @since 2.5.0
360
  */
361
  function get_variation_prices_hash( $price_hash, $_product, $display ) {
362
  $user_role = $this->get_current_user_role();
363
  $koef = get_option( 'wcj_price_by_user_role_' . $user_role, 1 );
 
364
  $price_hash['wcj_user_role'] = array(
365
  $user_role,
366
  $koef,
 
367
  get_option( 'wcj_price_by_user_role_per_product_enabled', 'yes' ),
368
  );
369
  return $price_hash;
@@ -381,7 +404,7 @@ class WCJ_Price_By_User_Role extends WCJ_Module {
381
  }
382
 
383
  /**
384
- * get_settings.
385
  *
386
  * @version 2.5.0
387
  * @since 2.5.0
@@ -422,7 +445,7 @@ class WCJ_Price_By_User_Role extends WCJ_Module {
422
  /**
423
  * add_settings.
424
  *
425
- * @version 2.5.0
426
  * @since 2.5.0
427
  */
428
  function add_settings() {
@@ -460,13 +483,21 @@ class WCJ_Price_By_User_Role extends WCJ_Module {
460
  'id' => 'wcj_price_by_user_role_multipliers_options',
461
  );
462
  foreach ( $this->get_user_roles() as $role_key => $role_data ) {
463
- $settings[] = array(
464
- 'title' => $role_data['name'],
465
- 'id' => 'wcj_price_by_user_role_' . $role_key,
466
- 'default' => 1,
467
- 'type' => 'number',
468
- 'custom_attributes' => array( 'step' => '0.000001', 'min' => '0', ),
469
- );
 
 
 
 
 
 
 
 
470
  }
471
  $settings[] = array(
472
  'type' => 'sectionend',
4
  *
5
  * The WooCommerce Jetpack Price by User Role class.
6
  *
7
+ * @version 2.5.2
8
  * @since 2.5.0
9
  * @author Algoritmika Ltd.
10
+ * @todo Fix "Make Empty Price" option for variable products
11
  */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) exit;
116
  /**
117
  * get_meta_box_options.
118
  *
119
+ * @version 2.5.2
120
  * @since 2.5.0
121
  */
122
  function get_meta_box_options() {
174
  'product_id' => $product_id,
175
  'meta_name' => '_' . 'wcj_price_by_user_role_sale_price_' . $role_key,
176
  ),
177
+ array(
178
+ 'name' => 'wcj_price_by_user_role_empty_price_' . $role_key . '_' . $product_id,
179
+ 'default' => 'no',
180
+ 'type' => 'select',
181
+ 'options' => array(
182
+ 'yes' => __( 'Yes', 'woocommerce-jetpack' ),
183
+ 'no' => __( 'No', 'woocommerce-jetpack' ),
184
+ ),
185
+ 'title' => __( 'Make Empty Price', 'woocommerce-jetpack' ),
186
+ 'desc' => $desc,
187
+ 'product_id' => $product_id,
188
+ 'meta_name' => '_' . 'wcj_price_by_user_role_empty_price_' . $role_key,
189
+ ),
190
  ) );
191
  }
192
  }
277
  /**
278
  * change_price_by_role_shipping.
279
  *
280
+ * @version 2.5.2
281
  * @since 2.5.0
282
  */
283
  function change_price_by_role_shipping( $package_rates, $package ) {
296
  }
297
  $modified_package_rates[ $id ] = $package_rate;
298
  }
299
+ return $modified_package_rates;
300
  }
301
+ return $package_rates;
302
  }
303
 
304
  /**
329
  /**
330
  * change_price_by_role.
331
  *
332
+ * @version 2.5.2
333
  * @since 2.5.0
334
  */
335
  function change_price_by_role( $price, $_product ) {
340
  if ( 'yes' === get_option( 'wcj_price_by_user_role_per_product_enabled', 'yes' ) ) {
341
  if ( 'yes' === get_post_meta( $_product->id, '_' . 'wcj_price_by_user_role_per_product_settings_enabled', true ) ) {
342
  $the_product_id = ( isset( $_product->variation_id ) ) ? $_product->variation_id : $_product->id;
343
+ if ( 'yes' === get_post_meta( $the_product_id, '_' . 'wcj_price_by_user_role_empty_price_' . $current_user_role, true ) ) {
344
+ return '';
345
+ }
346
  if ( '' != ( $regular_price_per_product = get_post_meta( $the_product_id, '_' . 'wcj_price_by_user_role_regular_price_' . $current_user_role, true ) ) ) {
347
  $the_current_filter = current_filter();
348
  if ( 'woocommerce_get_price_including_tax' == $the_current_filter || 'woocommerce_get_price_excluding_tax' == $the_current_filter ) {
362
  }
363
 
364
  // Global
365
+ if ( 'yes' === get_option( 'wcj_price_by_user_role_empty_price_' . $current_user_role, 'no' ) ) {
366
+ return '';
367
+ }
368
  if ( 1 != ( $koef = get_option( 'wcj_price_by_user_role_' . $current_user_role, 1 ) ) ) {
369
  return ( '' === $price ) ? $price : $price * $koef;
370
  }
376
  /**
377
  * get_variation_prices_hash.
378
  *
379
+ * @version 2.5.2
380
  * @since 2.5.0
381
  */
382
  function get_variation_prices_hash( $price_hash, $_product, $display ) {
383
  $user_role = $this->get_current_user_role();
384
  $koef = get_option( 'wcj_price_by_user_role_' . $user_role, 1 );
385
+ $is_empty = get_option( 'wcj_price_by_user_role_empty_price_' . $user_role, 'no' );
386
  $price_hash['wcj_user_role'] = array(
387
  $user_role,
388
  $koef,
389
+ $is_empty,
390
  get_option( 'wcj_price_by_user_role_per_product_enabled', 'yes' ),
391
  );
392
  return $price_hash;
404
  }
405
 
406
  /**
407
+ * get_user_roles.
408
  *
409
  * @version 2.5.0
410
  * @since 2.5.0
445
  /**
446
  * add_settings.
447
  *
448
+ * @version 2.5.2
449
  * @since 2.5.0
450
  */
451
  function add_settings() {
483
  'id' => 'wcj_price_by_user_role_multipliers_options',
484
  );
485
  foreach ( $this->get_user_roles() as $role_key => $role_data ) {
486
+ $settings = array_merge( $settings, array(
487
+ array(
488
+ 'title' => $role_data['name'],
489
+ 'id' => 'wcj_price_by_user_role_' . $role_key,
490
+ 'default' => 1,
491
+ 'type' => 'number',
492
+ 'custom_attributes' => array( 'step' => '0.000001', 'min' => '0', ),
493
+ ),
494
+ array(
495
+ 'desc' => __( 'Make Empty Price', 'woocommerce-jetpack' ),
496
+ 'id' => 'wcj_price_by_user_role_empty_price_' . $role_key,
497
+ 'default' => 'no',
498
+ 'type' => 'checkbox',
499
+ ),
500
+ ) );
501
  }
502
  $settings[] = array(
503
  'type' => 'sectionend',
includes/class-wcj-price-formats.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Jetpack Price Formats
4
+ *
5
+ * The WooCommerce Jetpack Price Formats class.
6
+ *
7
+ * @version 2.5.2
8
+ * @since 2.5.2
9
+ * @author Algoritmika Ltd.
10
+ */
11
+
12
+ if ( ! defined( 'ABSPATH' ) ) exit;
13
+
14
+ if ( ! class_exists( 'WCJ_Price_Formats' ) ) :
15
+
16
+ class WCJ_Price_Formats extends WCJ_Module {
17
+
18
+ /**
19
+ * Constructor.
20
+ *
21
+ * @version 2.5.2
22
+ * @since 2.5.2
23
+ */
24
+ function __construct() {
25
+
26
+ $this->id = 'price_formats';
27
+ $this->short_desc = __( 'Price Formats', 'woocommerce-jetpack' );
28
+ $this->desc = __( 'Set different WooCommerce price formats for different currencies.', 'woocommerce-jetpack' );
29
+ $this->link = 'http://booster.io/features/woocommerce-price-formats/';
30
+ parent::__construct();
31
+
32
+ add_action( 'init', array( $this, 'add_settings_hook' ) );
33
+
34
+ if ( $this->is_enabled() ) {
35
+ add_filter( 'wc_price_args', array( $this, 'price_format' ), PHP_INT_MAX );
36
+ }
37
+ }
38
+
39
+ /**
40
+ * price_format.
41
+ *
42
+ * @version 2.5.2
43
+ * @since 2.5.2
44
+ */
45
+ function price_format( $args ) {
46
+ for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_price_formats_total_number', 1 ) ); $i++ ) {
47
+ if ( get_woocommerce_currency() === get_option( 'wcj_price_formats_currency_' . $i ) ) {
48
+ $args['price_format'] = $this->get_woocommerce_price_format( get_option( 'wcj_price_formats_currency_position_' . $i ) );
49
+ $args['decimal_separator'] = get_option( 'wcj_price_formats_decimal_separator_' . $i );
50
+ $args['thousand_separator'] = get_option( 'wcj_price_formats_thousand_separator_' . $i );
51
+ $args['decimals'] = absint( get_option( 'wcj_price_formats_number_of_decimals_' . $i ) );
52
+ }
53
+ }
54
+ return $args;
55
+ }
56
+
57
+ /**
58
+ * get_woocommerce_price_format.
59
+ *
60
+ * @version 2.5.2
61
+ * @since 2.5.2
62
+ */
63
+ function get_woocommerce_price_format( $currency_pos ) {
64
+ $format = '%1$s%2$s';
65
+
66
+ switch ( $currency_pos ) {
67
+ case 'left' :
68
+ $format = '%1$s%2$s';
69
+ break;
70
+ case 'right' :
71
+ $format = '%2$s%1$s';
72
+ break;
73
+ case 'left_space' :
74
+ $format = '%1$s&nbsp;%2$s';
75
+ break;
76
+ case 'right_space' :
77
+ $format = '%2$s&nbsp;%1$s';
78
+ break;
79
+ }
80
+
81
+ return apply_filters( 'woocommerce_price_format', $format, $currency_pos );
82
+ }
83
+
84
+ /**
85
+ * add_settings_hook.
86
+ *
87
+ * @version 2.5.2
88
+ * @since 2.5.2
89
+ */
90
+ function add_settings_hook() {
91
+ add_filter( 'wcj_price_formats_settings', array( $this, 'add_settings' ) );
92
+ }
93
+
94
+ /**
95
+ * get_settings.
96
+ *
97
+ * @version 2.5.2
98
+ * @since 2.5.2
99
+ */
100
+ function get_settings() {
101
+ $settings = apply_filters( 'wcj_price_formats_settings', array() );
102
+ return $this->add_standard_settings( $settings );
103
+ }
104
+
105
+ /**
106
+ * add_settings.
107
+ *
108
+ * @version 2.5.2
109
+ * @since 2.5.2
110
+ */
111
+ function add_settings() {
112
+ $settings = array(
113
+ array(
114
+ 'title' => __( 'Formats', 'woocommerce-jetpack' ),
115
+ 'type' => 'title',
116
+ 'id' => 'wcj_price_formats_options',
117
+ ),
118
+ array(
119
+ 'title' => __( 'Total Number', 'woocommerce-jetpack' ),
120
+ 'id' => 'wcj_price_formats_total_number',
121
+ 'default' => 1,
122
+ 'type' => 'custom_number',
123
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
124
+ 'custom_attributes' => array_merge(
125
+ is_array( apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) ) ? apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) : array(),
126
+ array( 'step' => '1', 'min' => '0', )
127
+ ),
128
+ ),
129
+ );
130
+ for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_price_formats_total_number', 1 ) ); $i++ ) {
131
+ $currency_symbol = wcj_get_currency_symbol( get_option( 'wcj_price_formats_currency_' . $i, get_woocommerce_currency() ) );
132
+ $settings = array_merge( $settings, array(
133
+ array(
134
+ 'title' => __( 'Format', 'woocommerce-jetpack' ) . ' #' . $i,
135
+ 'desc' => __( 'Currency', 'woocommerce-jetpack' ),
136
+ 'id' => 'wcj_price_formats_currency_' . $i,
137
+ 'default' => get_woocommerce_currency(),
138
+ 'type' => 'select',
139
+ 'options' => wcj_get_currencies_names_and_symbols(),
140
+ 'css' => 'width:300px;',
141
+ ),
142
+ array(
143
+ 'desc' => __( 'Currency Position', 'woocommerce-jetpack' ),
144
+ 'id' => 'wcj_price_formats_currency_position_' . $i,
145
+ 'default' => get_option( 'woocommerce_currency_pos' ),
146
+ 'type' => 'select',
147
+ 'options' => array(
148
+ 'left' => __( 'Left', 'woocommerce' ) . ' (' . $currency_symbol . '99.99)',
149
+ 'right' => __( 'Right', 'woocommerce' ) . ' (99.99' . $currency_symbol . ')',
150
+ 'left_space' => __( 'Left with space', 'woocommerce' ) . ' (' . $currency_symbol . ' 99.99)',
151
+ 'right_space' => __( 'Right with space', 'woocommerce' ) . ' (99.99 ' . $currency_symbol . ')'
152
+ ),
153
+ 'css' => 'width:300px;',
154
+ ),
155
+ array(
156
+ 'desc' => __( 'Thousand Separator', 'woocommerce-jetpack' ),
157
+ 'id' => 'wcj_price_formats_thousand_separator_' . $i,
158
+ 'default' => wc_get_price_thousand_separator(),
159
+ 'type' => 'text',
160
+ 'css' => 'width:300px;',
161
+ ),
162
+ array(
163
+ 'desc' => __( 'Decimal Separator', 'woocommerce-jetpack' ),
164
+ 'id' => 'wcj_price_formats_decimal_separator_' . $i,
165
+ 'default' => wc_get_price_decimal_separator(),
166
+ 'type' => 'text',
167
+ 'css' => 'width:300px;',
168
+ ),
169
+ array(
170
+ 'desc' => __( 'Number of Decimals', 'woocommerce-jetpack' ),
171
+ 'id' => 'wcj_price_formats_number_of_decimals_' . $i,
172
+ 'default' => wc_get_price_decimals(),
173
+ 'type' => 'number',
174
+ 'custom_attributes' => array(
175
+ 'min' => 0,
176
+ 'step' => 1
177
+ ),
178
+ 'css' => 'width:300px;',
179
+ ),
180
+ ) );
181
+ }
182
+ $settings = array_merge( $settings, array(
183
+ array(
184
+ 'type' => 'sectionend',
185
+ 'id' => 'wcj_price_formats_options',
186
+ ),
187
+ ) );
188
+ return $settings;
189
+ }
190
+ }
191
+
192
+ endif;
193
+
194
+ return new WCJ_Price_Formats();
includes/class-wcj-product-add-to-cart.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Product Add To Cart class.
6
  *
7
- * @version 2.5.0
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
@@ -18,7 +18,7 @@ class WCJ_Product_Add_To_Cart extends WCJ_Module {
18
  /**
19
  * Constructor.
20
  *
21
- * @version 2.5.0
22
  */
23
  public function __construct() {
24
 
@@ -43,6 +43,105 @@ class WCJ_Product_Add_To_Cart extends WCJ_Module {
43
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_variable_add_to_cart_scripts' ) );
44
  add_filter( 'wc_get_template', array( $this, 'change_variable_add_to_cart_template' ), PHP_INT_MAX, 5 );
45
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
47
  }
48
 
@@ -110,7 +209,7 @@ class WCJ_Product_Add_To_Cart extends WCJ_Module {
110
  /**
111
  * get_settings.
112
  *
113
- * @version 2.4.8
114
  */
115
  function get_settings() {
116
  $settings = array(
@@ -175,6 +274,47 @@ class WCJ_Product_Add_To_Cart extends WCJ_Module {
175
  'type' => 'sectionend',
176
  'id' => 'wcj_add_to_cart_variable_options',
177
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  );
179
  return $this->add_standard_settings( $settings );
180
  }
4
  *
5
  * The WooCommerce Jetpack Product Add To Cart class.
6
  *
7
+ * @version 2.5.2
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
18
  /**
19
  * Constructor.
20
  *
21
+ * @version 2.5.2
22
  */
23
  public function __construct() {
24
 
43
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_variable_add_to_cart_scripts' ) );
44
  add_filter( 'wc_get_template', array( $this, 'change_variable_add_to_cart_template' ), PHP_INT_MAX, 5 );
45
  }
46
+
47
+ // Quantity
48
+ if ( 'yes' === get_option( 'wcj_add_to_cart_quantity_disable', 'no' ) || 'yes' === get_option( 'wcj_add_to_cart_quantity_disable_cart', 'no' ) ) {
49
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_disable_quantity_add_to_cart_script' ) );
50
+ }
51
+
52
+ // Button per product
53
+ if ( 'yes' === get_option( 'wcj_add_to_cart_button_per_product_enabled', 'no' ) ) {
54
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
55
+ add_action( 'save_post_product', array( $this, 'save_meta_box' ), PHP_INT_MAX, 2 );
56
+
57
+ add_action( 'woocommerce_before_add_to_cart_button', array( $this, 'add_to_cart_button_disable_start' ), PHP_INT_MAX, 0 );
58
+ add_action( 'woocommerce_after_add_to_cart_button', array( $this, 'add_to_cart_button_disable_end' ), PHP_INT_MAX, 0 );
59
+ add_filter( 'woocommerce_loop_add_to_cart_link', array( $this, 'add_to_cart_button_loop_disable' ), PHP_INT_MAX, 2 );
60
+ }
61
+ }
62
+ }
63
+
64
+ /**
65
+ * add_to_cart_button_loop_disable.
66
+ *
67
+ * @version 2.5.2
68
+ * @since 2.5.2
69
+ */
70
+ function add_to_cart_button_loop_disable( $link, $_product ) {
71
+ if ( 0 != get_the_ID() && 'yes' === get_post_meta( get_the_ID(), '_' . 'wcj_add_to_cart_button_loop_disable', true ) ) {
72
+ return '';
73
+ }
74
+ return $link;
75
+ }
76
+
77
+ /**
78
+ * add_to_cart_button_disable_end.
79
+ *
80
+ * @version 2.5.2
81
+ * @since 2.5.2
82
+ */
83
+ function add_to_cart_button_disable_end() {
84
+ if ( 0 != get_the_ID() && 'yes' === get_post_meta( get_the_ID(), '_' . 'wcj_add_to_cart_button_disable', true ) ) {
85
+ ob_end_clean();
86
+ }
87
+ }
88
+
89
+ /**
90
+ * add_to_cart_button_disable_start.
91
+ *
92
+ * @version 2.5.2
93
+ * @since 2.5.2
94
+ */
95
+ function add_to_cart_button_disable_start() {
96
+ if ( 0 != get_the_ID() && 'yes' === get_post_meta( get_the_ID(), '_' . 'wcj_add_to_cart_button_disable', true ) ) {
97
+ ob_start();
98
+ }
99
+ }
100
+
101
+ /**
102
+ * get_meta_box_options.
103
+ *
104
+ * @version 2.5.2
105
+ * @since 2.5.2
106
+ */
107
+ function get_meta_box_options() {
108
+ $options = array(
109
+ array(
110
+ 'name' => 'wcj_add_to_cart_button_disable',
111
+ 'default' => 'no',
112
+ 'type' => 'select',
113
+ 'options' => array(
114
+ 'yes' => __( 'Yes', 'woocommerce-jetpack' ),
115
+ 'no' => __( 'No', 'woocommerce-jetpack' ),
116
+ ),
117
+ 'title' => __( 'Disable Add to Cart Button (Single Product Page)', 'woocommerce-jetpack' ),
118
+ ),
119
+ array(
120
+ 'name' => 'wcj_add_to_cart_button_loop_disable',
121
+ 'default' => 'no',
122
+ 'type' => 'select',
123
+ 'options' => array(
124
+ 'yes' => __( 'Yes', 'woocommerce-jetpack' ),
125
+ 'no' => __( 'No', 'woocommerce-jetpack' ),
126
+ ),
127
+ 'title' => __( 'Disable Add to Cart Button (Category/Archives)', 'woocommerce-jetpack' ),
128
+ ),
129
+ );
130
+ return $options;
131
+ }
132
+
133
+ /**
134
+ * enqueue_disable_quantity_add_to_cart_script.
135
+ *
136
+ * @version 2.5.2
137
+ * @since 2.5.2
138
+ */
139
+ function enqueue_disable_quantity_add_to_cart_script() {
140
+ if (
141
+ ( 'yes' === get_option( 'wcj_add_to_cart_quantity_disable', 'no' ) && is_product() ) ||
142
+ ( 'yes' === get_option( 'wcj_add_to_cart_quantity_disable_cart', 'no' ) && is_cart() )
143
+ ) {
144
+ wp_enqueue_script( 'wcj-disable-quantity', wcj_plugin_url() . '/includes/js/wcj-disable-quantity.js', array( 'jquery' ) );
145
  }
146
  }
147
 
209
  /**
210
  * get_settings.
211
  *
212
+ * @version 2.5.2
213
  */
214
  function get_settings() {
215
  $settings = array(
274
  'type' => 'sectionend',
275
  'id' => 'wcj_add_to_cart_variable_options',
276
  ),
277
+ array(
278
+ 'title' => __( 'Add to Cart Quantity', 'woocommerce-jetpack' ),
279
+ 'type' => 'title',
280
+ 'id' => 'wcj_add_to_cart_quantity_options',
281
+ ),
282
+ array(
283
+ 'title' => __( 'Disable Quantity Field for All Products', 'woocommerce-jetpack' ),
284
+ 'desc' => __( 'Disable on Single Product Page', 'woocommerce-jetpack' ),
285
+ 'id' => 'wcj_add_to_cart_quantity_disable',
286
+ 'default' => 'no',
287
+ 'type' => 'checkbox',
288
+ 'checkboxgroup' => 'start',
289
+ ),
290
+ array(
291
+ 'desc' => __( 'Disable on Cart Page', 'woocommerce-jetpack' ),
292
+ 'id' => 'wcj_add_to_cart_quantity_disable_cart',
293
+ 'default' => 'no',
294
+ 'type' => 'checkbox',
295
+ 'checkboxgroup' => 'end',
296
+ ),
297
+ array(
298
+ 'type' => 'sectionend',
299
+ 'id' => 'wcj_add_to_cart_quantity_options',
300
+ ),
301
+ array(
302
+ 'title' => __( 'Add to Cart Button', 'woocommerce-jetpack' ),
303
+ 'type' => 'title',
304
+ 'id' => 'wcj_add_to_cart_button_options',
305
+ ),
306
+ array(
307
+ 'title' => __( 'Add to Cart Buttons on per Product Basis', 'woocommerce-jetpack' ),
308
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
309
+ 'desc_tip' => __( 'This will add meta box to each product\'s edit page', 'woocommerce-jetpack' ),
310
+ 'id' => 'wcj_add_to_cart_button_per_product_enabled',
311
+ 'default' => 'no',
312
+ 'type' => 'checkbox',
313
+ ),
314
+ array(
315
+ 'type' => 'sectionend',
316
+ 'id' => 'wcj_add_to_cart_button_options',
317
+ ),
318
  );
319
  return $this->add_standard_settings( $settings );
320
  }
includes/class-wcj-product-bookings.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Product Bookings class.
6
  *
7
- * @version 2.5.0
8
  * @since 2.5.0
9
  * @author Algoritmika Ltd.
10
  */
@@ -115,18 +115,22 @@ class WCJ_Product_Bookings extends WCJ_Module {
115
  /**
116
  * enqueue_scripts.
117
  *
118
- * @version 2.5.0
119
  * @since 2.5.0
120
  */
121
  function enqueue_scripts() {
122
- wp_enqueue_script( 'wcj-bookings', wcj_plugin_url() . '/includes/js/wcj-bookings.js', array(), false, true );
123
- $the_product = wc_get_product();
124
- wp_localize_script( 'wcj-bookings', 'ajax_object', array(
125
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
126
- 'product_id' => get_the_ID(),
127
- 'wrong_dates_message' => __( '"Date to" must be after "Date from"', 'woocommerce-jetpack' ),
128
- 'original_price_html' => $the_product->get_price_html(),
129
- ) );
 
 
 
 
130
  }
131
 
132
  /**
@@ -166,7 +170,7 @@ class WCJ_Product_Bookings extends WCJ_Module {
166
  /**
167
  * Adds info to order details (and emails).
168
  *
169
- * @version 2.5.0
170
  * @since 2.5.0
171
  */
172
  function add_info_to_order_item_name( $name, $item, $is_cart = false ) {
@@ -175,7 +179,7 @@ class WCJ_Product_Bookings extends WCJ_Module {
175
  }
176
  if ( isset( $item['wcj_bookings_price'] ) ) {
177
  if ( $is_cart ) {
178
- $name .= '<dt>' . __( 'Period', 'woocommerce-jetpack' ) . ':' . '</dt>';
179
  $name .= '<dd>' . $item['wcj_bookings_date_from'] . ' - ' . $item['wcj_bookings_date_to'] . '</dd>';
180
  } else {
181
  $name .= ' | ' . $item['wcj_bookings_date_from'] . ' - ' . $item['wcj_bookings_date_to'];
@@ -200,24 +204,24 @@ class WCJ_Product_Bookings extends WCJ_Module {
200
  /**
201
  * validate_bookings_on_add_to_cart.
202
  *
203
- * @version 2.5.0
204
  * @since 2.5.0
205
  */
206
  function validate_bookings_on_add_to_cart( $passed, $product_id ) {
207
  $the_product = wc_get_product( $product_id );
208
  if ( $this->is_bookings_product( $the_product ) ) {
209
  if ( ! isset( $_POST['wcj_product_bookings_date_from'] ) || '' == $_POST['wcj_product_bookings_date_from'] ) {
210
- wc_add_notice( __( '"Date from" must be set', 'woocommerce-jetpack' ), 'error' );
211
  return false;
212
  }
213
  if ( ! isset( $_POST['wcj_product_bookings_date_to'] ) || '' == $_POST['wcj_product_bookings_date_to'] ) {
214
- wc_add_notice( __( '"Date to" must be set', 'woocommerce-jetpack' ), 'error' );
215
  return false;
216
  }
217
  $date_to = strtotime( $_POST['wcj_product_bookings_date_to'] );
218
  $date_from = strtotime( $_POST['wcj_product_bookings_date_from'] );
219
  if ( $date_from >= $date_to ) {
220
- wc_add_notice( __( '"Date to" must be after "Date from"', 'woocommerce-jetpack' ), 'error' );
221
  return false;
222
  }
223
  }
@@ -281,7 +285,7 @@ class WCJ_Product_Bookings extends WCJ_Module {
281
  /**
282
  * add_input_fields_to_frontend.
283
  *
284
- * @version 2.5.0
285
  * @since 2.5.0
286
  */
287
  function add_input_fields_to_frontend() {
@@ -290,12 +294,12 @@ class WCJ_Product_Bookings extends WCJ_Module {
290
  $date_from_value = ( isset( $_POST['wcj_product_bookings_date_from'] ) ) ? $_POST['wcj_product_bookings_date_from'] : '';
291
  $date_to_value = ( isset( $_POST['wcj_product_bookings_date_to'] ) ) ? $_POST['wcj_product_bookings_date_to'] : '';
292
  $data_table[] = array(
293
- __( 'Date from' ),
294
- '<input firstday="0" dateformat="mm/dd/yy" mindate="0" type="datepicker" display="date" name="wcj_product_bookings_date_from" placeholder="" value="' . $date_from_value . '">',
295
  );
296
  $data_table[] = array(
297
- __( 'Date to' ),
298
- '<input firstday="0" dateformat="mm/dd/yy" mindate="0" type="datepicker" display="date" name="wcj_product_bookings_date_to" placeholder="" value="' . $date_to_value . '">',
299
  );
300
  echo wcj_get_table_html( $data_table, array( 'table_heading_type' => 'none', ) );
301
  echo '<div style="display:none !important;" name="wcj_bookings_message"><p style="color:red;"></p></div>';
@@ -305,11 +309,11 @@ class WCJ_Product_Bookings extends WCJ_Module {
305
  /**
306
  * add_per_day_label.
307
  *
308
- * @version 2.5.0
309
  * @since 2.5.0
310
  */
311
  function add_per_day_label( $price_html, $_product ) {
312
- return ( $this->is_bookings_product( $_product ) ) ? $price_html . ' / ' . __( 'day', 'woocommerce-jetpack' ) : $price_html;
313
  }
314
 
315
  /**
@@ -417,11 +421,70 @@ class WCJ_Product_Bookings extends WCJ_Module {
417
  /**
418
  * get_settings.
419
  *
420
- * @version 2.5.0
421
  * @since 2.5.0
422
  */
423
  function get_settings() {
424
- $settings = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
425
  return $this->add_standard_settings( $settings, __( 'When enabled, module will add new "Booster: Bookings" meta box to each product\'s edit page.', 'woocommerce-jetpack' ) );
426
  }
427
  }
4
  *
5
  * The WooCommerce Jetpack Product Bookings class.
6
  *
7
+ * @version 2.5.2
8
  * @since 2.5.0
9
  * @author Algoritmika Ltd.
10
  */
115
  /**
116
  * enqueue_scripts.
117
  *
118
+ * @version 2.5.2
119
  * @since 2.5.0
120
  */
121
  function enqueue_scripts() {
122
+ if ( is_product() ) {
123
+ $the_product = wc_get_product();
124
+ if ( $this->is_bookings_product( $the_product ) ) {
125
+ wp_enqueue_script( 'wcj-bookings', wcj_plugin_url() . '/includes/js/wcj-bookings.js', array(), false, true );
126
+ wp_localize_script( 'wcj-bookings', 'ajax_object', array(
127
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
128
+ 'product_id' => get_the_ID(),
129
+ 'wrong_dates_message' => get_option( 'wcj_product_bookings_message_date_to_before_date_from', __( '"Date to" must be after "Date from"', 'woocommerce-jetpack' ) ),
130
+ 'original_price_html' => $the_product->get_price_html(),
131
+ ) );
132
+ }
133
+ }
134
  }
135
 
136
  /**
170
  /**
171
  * Adds info to order details (and emails).
172
  *
173
+ * @version 2.5.2
174
  * @since 2.5.0
175
  */
176
  function add_info_to_order_item_name( $name, $item, $is_cart = false ) {
179
  }
180
  if ( isset( $item['wcj_bookings_price'] ) ) {
181
  if ( $is_cart ) {
182
+ $name .= '<dt>' . get_option( 'wcj_product_bookings_label_period', __( 'Period', 'woocommerce-jetpack' ) ) . ':' . '</dt>';
183
  $name .= '<dd>' . $item['wcj_bookings_date_from'] . ' - ' . $item['wcj_bookings_date_to'] . '</dd>';
184
  } else {
185
  $name .= ' | ' . $item['wcj_bookings_date_from'] . ' - ' . $item['wcj_bookings_date_to'];
204
  /**
205
  * validate_bookings_on_add_to_cart.
206
  *
207
+ * @version 2.5.2
208
  * @since 2.5.0
209
  */
210
  function validate_bookings_on_add_to_cart( $passed, $product_id ) {
211
  $the_product = wc_get_product( $product_id );
212
  if ( $this->is_bookings_product( $the_product ) ) {
213
  if ( ! isset( $_POST['wcj_product_bookings_date_from'] ) || '' == $_POST['wcj_product_bookings_date_from'] ) {
214
+ wc_add_notice( get_option( 'wcj_product_bookings_message_no_date_from', __( '"Date from" must be set', 'woocommerce-jetpack' ) ), 'error' );
215
  return false;
216
  }
217
  if ( ! isset( $_POST['wcj_product_bookings_date_to'] ) || '' == $_POST['wcj_product_bookings_date_to'] ) {
218
+ wc_add_notice( get_option( 'wcj_product_bookings_message_no_date_to', __( '"Date to" must be set', 'woocommerce-jetpack' ) ), 'error' );
219
  return false;
220
  }
221
  $date_to = strtotime( $_POST['wcj_product_bookings_date_to'] );
222
  $date_from = strtotime( $_POST['wcj_product_bookings_date_from'] );
223
  if ( $date_from >= $date_to ) {
224
+ wc_add_notice( get_option( 'wcj_product_bookings_message_date_to_before_date_from', __( '"Date to" must be after "Date from"', 'woocommerce-jetpack' ) ), 'error' );
225
  return false;
226
  }
227
  }
285
  /**
286
  * add_input_fields_to_frontend.
287
  *
288
+ * @version 2.5.2
289
  * @since 2.5.0
290
  */
291
  function add_input_fields_to_frontend() {
294
  $date_from_value = ( isset( $_POST['wcj_product_bookings_date_from'] ) ) ? $_POST['wcj_product_bookings_date_from'] : '';
295
  $date_to_value = ( isset( $_POST['wcj_product_bookings_date_to'] ) ) ? $_POST['wcj_product_bookings_date_to'] : '';
296
  $data_table[] = array(
297
+ '<label for="wcj_product_bookings_date_to">' . get_option( 'wcj_product_bookings_label_date_from', __( 'Date from' ) ) . '</label>',
298
+ '<input firstday="0" dateformat="mm/dd/yy" mindate="0" type="datepicker" display="date" id="wcj_product_bookings_date_from" name="wcj_product_bookings_date_from" placeholder="" value="' . $date_from_value . '">',
299
  );
300
  $data_table[] = array(
301
+ '<label for="wcj_product_bookings_date_to">' . get_option( 'wcj_product_bookings_label_date_to', __( 'Date to' ) ) . '</label>',
302
+ '<input firstday="0" dateformat="mm/dd/yy" mindate="0" type="datepicker" display="date" id="wcj_product_bookings_date_to" name="wcj_product_bookings_date_to" placeholder="" value="' . $date_to_value . '">',
303
  );
304
  echo wcj_get_table_html( $data_table, array( 'table_heading_type' => 'none', ) );
305
  echo '<div style="display:none !important;" name="wcj_bookings_message"><p style="color:red;"></p></div>';
309
  /**
310
  * add_per_day_label.
311
  *
312
+ * @version 2.5.2
313
  * @since 2.5.0
314
  */
315
  function add_per_day_label( $price_html, $_product ) {
316
+ return ( $this->is_bookings_product( $_product ) ) ? $price_html . ' ' . get_option( 'wcj_product_bookings_label_per_day', __( '/ day', 'woocommerce-jetpack' ) ) : $price_html;
317
  }
318
 
319
  /**
421
  /**
422
  * get_settings.
423
  *
424
+ * @version 2.5.2
425
  * @since 2.5.0
426
  */
427
  function get_settings() {
428
+ $settings = array(
429
+ array(
430
+ 'title' => __( 'Labels and Messages', 'woocommerce-jetpack' ),
431
+ 'type' => 'title',
432
+ 'id' => 'wcj_product_bookings_labels_and_messages_options',
433
+ ),
434
+ array(
435
+ 'title' => __( 'Frontend Label: "Date from"', 'woocommerce-jetpack' ),
436
+ 'id' => 'wcj_product_bookings_label_date_from',
437
+ 'default' => __( 'Date from', 'woocommerce-jetpack' ),
438
+ 'type' => 'text',
439
+ 'css' => 'width:250px;',
440
+ ),
441
+ array(
442
+ 'title' => __( 'Frontend Label: "Date to"', 'woocommerce-jetpack' ),
443
+ 'id' => 'wcj_product_bookings_label_date_to',
444
+ 'default' => __( 'Date to', 'woocommerce-jetpack' ),
445
+ 'type' => 'text',
446
+ 'css' => 'width:250px;',
447
+ ),
448
+ array(
449
+ 'title' => __( 'Frontend Label: Period', 'woocommerce-jetpack' ),
450
+ 'id' => 'wcj_product_bookings_label_period',
451
+ 'default' => __( 'Period', 'woocommerce-jetpack' ),
452
+ 'type' => 'text',
453
+ 'css' => 'width:250px;',
454
+ ),
455
+ array(
456
+ 'title' => __( 'Frontend Label: Price per Day', 'woocommerce-jetpack' ),
457
+ 'id' => 'wcj_product_bookings_label_per_day',
458
+ 'default' => __( '/ day', 'woocommerce-jetpack' ),
459
+ 'type' => 'text',
460
+ 'css' => 'width:250px;',
461
+ ),
462
+ array(
463
+ 'title' => __( 'Message: "Date from" is missing', 'woocommerce-jetpack' ),
464
+ 'id' => 'wcj_product_bookings_message_no_date_from',
465
+ 'default' => __( '"Date from" must be set', 'woocommerce-jetpack' ),
466
+ 'type' => 'text',
467
+ 'css' => 'width:250px;',
468
+ ),
469
+ array(
470
+ 'title' => __( 'Message: "Date to" is missing', 'woocommerce-jetpack' ),
471
+ 'id' => 'wcj_product_bookings_message_no_date_to',
472
+ 'default' => __( '"Date to" must be set', 'woocommerce-jetpack' ),
473
+ 'type' => 'text',
474
+ 'css' => 'width:250px;',
475
+ ),
476
+ array(
477
+ 'title' => __( 'Message: "Date to" is missing', 'woocommerce-jetpack' ),
478
+ 'id' => 'wcj_product_bookings_message_date_to_before_date_from',
479
+ 'default' => __( '"Date to" must be after "Date from"', 'woocommerce-jetpack' ),
480
+ 'type' => 'text',
481
+ 'css' => 'width:250px;',
482
+ ),
483
+ array(
484
+ 'type' => 'sectionend',
485
+ 'id' => 'wcj_product_bookings_labels_and_messages_options',
486
+ ),
487
+ );
488
  return $this->add_standard_settings( $settings, __( 'When enabled, module will add new "Booster: Bookings" meta box to each product\'s edit page.', 'woocommerce-jetpack' ) );
489
  }
490
  }
includes/class-wcj-product-by-user.php ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Jetpack Product by User
4
+ *
5
+ * The WooCommerce Jetpack Product by User class.
6
+ *
7
+ * @version 2.5.2
8
+ * @since 2.5.2
9
+ * @author Algoritmika Ltd.
10
+ */
11
+
12
+ if ( ! defined( 'ABSPATH' ) ) exit;
13
+
14
+ if ( ! class_exists( 'WCJ_Product_By_User' ) ) :
15
+
16
+ class WCJ_Product_By_User extends WCJ_Module {
17
+
18
+ /**
19
+ * Constructor.
20
+ *
21
+ * @version 2.5.2
22
+ * @since 2.5.2
23
+ */
24
+ public function __construct() {
25
+
26
+ $this->id = 'product_by_user';
27
+ $this->short_desc = __( 'Product by User', 'woocommerce-jetpack' );
28
+ $this->desc = __( 'Let users to add new WooCommerce products from frontend.', 'woocommerce-jetpack' );
29
+ $this->link = 'http://booster.io/features/woocommerce-product-by-user/';
30
+ parent::__construct();
31
+
32
+ if ( $this->is_enabled() ) {
33
+ if ( 'yes' === get_option( 'wcj_product_by_user_add_to_my_account', 'yes' ) ) {
34
+ add_filter( 'woocommerce_account_menu_items', array( $this, 'add_my_products_tab_my_account_page' ) );
35
+ add_action( 'woocommerce_account_content', array( $this, 'add_my_products_content_my_account_page' ) );
36
+ }
37
+ }
38
+ }
39
+
40
+ /**
41
+ * add_my_products_tab_my_account_page.
42
+ *
43
+ * @version 2.5.2
44
+ * @since 2.5.2
45
+ * @todo check if user's products exist
46
+ */
47
+ function add_my_products_tab_my_account_page( $items ) {
48
+ $items['wcj-my-products'] = __( 'My Products', 'woocommerce-jetpack' );
49
+ return $items;
50
+ }
51
+
52
+ /**
53
+ * add_my_products_content_my_account_page.
54
+ *
55
+ * @version 2.5.2
56
+ * @since 2.5.2
57
+ */
58
+ function add_my_products_content_my_account_page() {
59
+ if ( ! isset( $_GET['wcj-my-products'] ) ) {
60
+ return;
61
+ }
62
+ $user_ID = get_current_user_id();
63
+ if ( 0 == $user_ID ) {
64
+ return;
65
+ }
66
+ if ( isset( $_GET['wcj_delete_product'] ) ) {
67
+ $product_id = $_GET['wcj_delete_product'];
68
+ $post_author_id = get_post_field( 'post_author', $product_id );
69
+ if ( $user_ID != $post_author_id ) {
70
+ echo '<p>' . __( 'Wrong user ID!', 'woocommerce-jetpack' ) . '</p>';
71
+ } else {
72
+ wp_delete_post( $product_id, true );
73
+ }
74
+ }
75
+ if ( isset( $_GET['wcj_edit_product'] ) ) {
76
+ $product_id = $_GET['wcj_edit_product'];
77
+ $post_author_id = get_post_field( 'post_author', $product_id );
78
+ if ( $user_ID != $post_author_id ) {
79
+ echo '<p>' . __( 'Wrong user ID!', 'woocommerce-jetpack' ) . '</p>';
80
+ } else {
81
+ echo do_shortcode( '[wcj_product_add_new product_id="' . $product_id . '"]' );
82
+ }
83
+ }
84
+ $offset = 0;
85
+ $block_size = 96;
86
+ $products = array();
87
+ while( true ) {
88
+ $args = array(
89
+ 'post_type' => 'product',
90
+ 'post_status' => 'any',
91
+ 'posts_per_page' => $block_size,
92
+ 'offset' => $offset,
93
+ 'orderby' => 'date',
94
+ 'order' => 'DESC',
95
+ 'author' => $user_ID,
96
+ );
97
+ $loop = new WP_Query( $args );
98
+ if ( ! $loop->have_posts() ) break;
99
+ while ( $loop->have_posts() ) : $loop->the_post();
100
+ $products[ strval( $loop->post->ID ) ] = array(
101
+ 'title' => get_the_title( $loop->post->ID ),
102
+ 'status' => get_post_status( $loop->post->ID ),
103
+ );
104
+ endwhile;
105
+ $offset += $block_size;
106
+ }
107
+ wp_reset_postdata();
108
+ if ( 0 != count( $products ) ) {
109
+ echo '<h2>' . __( 'My Products', 'woocommerce-jetpack' ) . '</h2>';
110
+ $table_data = array();
111
+ $table_data[] = array( '', __( 'Status', 'woocommerce-jetpack' ), __( 'Title', 'woocommerce-jetpack' ), __( 'Actions', 'woocommerce-jetpack' ) );
112
+ $i = 0;
113
+ foreach ( $products as $_product_id => $_product_data ) {
114
+ $i++;
115
+ $table_data[] = array(
116
+ /* $i . ' [' . $_product_id . ']' . */ get_the_post_thumbnail( $_product_id, array( 25, 25 ) ),
117
+ '<code>'. $_product_data['status'] . '</code>',
118
+ $_product_data['title'],
119
+ '<a class="button" href="' . add_query_arg( 'wcj_edit_product', $_product_id, remove_query_arg( array( 'wcj_edit_product_image_delete', 'wcj_delete_product' ) ) ) . '">' . __( 'Edit', 'woocommerce-jetpack' ) . '</a>' . ' ' .
120
+ '<a class="button" href="' . add_query_arg( 'wcj_delete_product', $_product_id, remove_query_arg( array( 'wcj_edit_product_image_delete', 'wcj_edit_product' ) ) ) . '" onclick="return confirm(\'' . __( 'Are you sure?', 'woocommerce-jetpack' ) . '\')">' . __( 'Delete', 'woocommerce-jetpack' ) . '</a>',
121
+ );
122
+ }
123
+ echo wcj_get_table_html( $table_data, array( 'table_class' => 'shop_table shop_table_responsive my_account_orders' ) );
124
+ }
125
+ }
126
+
127
+ /**
128
+ * get_user_roles.
129
+ *
130
+ * @version 2.5.2
131
+ * @since 2.5.2
132
+ */
133
+ function get_user_roles() {
134
+ global $wp_roles;
135
+ $all_roles = ( isset( $wp_roles ) && is_object( $wp_roles ) ) ? $wp_roles->roles : array();
136
+ $all_roles = apply_filters( 'editable_roles', $all_roles );
137
+ $all_roles = array_merge( array(
138
+ 'guest' => array(
139
+ 'name' => __( 'Guest', 'woocommerce-jetpack' ),
140
+ 'capabilities' => array(),
141
+ ) ), $all_roles );
142
+ $all_roles_options = array();
143
+ foreach ( $all_roles as $_role_key => $_role ) {
144
+ $all_roles_options[ $_role_key ] = $_role['name'];
145
+ }
146
+ return $all_roles_options;
147
+ }
148
+
149
+ /**
150
+ * get_settings.
151
+ *
152
+ * @version 2.5.2
153
+ * @since 2.5.2
154
+ */
155
+ function get_settings() {
156
+
157
+ $fields = array(
158
+ 'desc' => __( 'Description', 'woocommerce-jetpack' ),
159
+ 'short_desc' => __( 'Short Description', 'woocommerce-jetpack' ),
160
+ 'image' => __( 'Image', 'woocommerce-jetpack' ),
161
+ 'regular_price' => __( 'Regular Price', 'woocommerce-jetpack' ),
162
+ 'sale_price' => __( 'Sale Price', 'woocommerce-jetpack' ),
163
+ 'cats' => __( 'Categories', 'woocommerce-jetpack' ),
164
+ 'tags' => __( 'Tags', 'woocommerce-jetpack' ),
165
+ );
166
+ $fields_enabled_options = array();
167
+ $fields_required_options = array();
168
+ $i = 0;
169
+ $total_fields = count( $fields );
170
+ foreach ( $fields as $field_id => $field_desc ) {
171
+ $i++;
172
+ $checkboxgroup = '';
173
+ if ( 1 === $i ) {
174
+ $checkboxgroup = 'start';
175
+ } elseif ( $total_fields === $i ) {
176
+ $checkboxgroup = 'end';
177
+ }
178
+ $fields_enabled_options[] = array(
179
+ 'title' => ( ( 1 === $i ) ? __( 'Additional Fields', 'woocommerce-jetpack' ) : '' ),
180
+ 'desc' => $field_desc,
181
+ 'id' => 'wcj_product_by_user_' . $field_id . '_enabled',
182
+ 'default' => 'no',
183
+ 'type' => 'checkbox',
184
+ 'checkboxgroup' => $checkboxgroup,
185
+ 'custom_attributes' => ( ( 'image' === $field_id ) ? apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ) : '' ),
186
+ 'desc_tip' => ( ( 'image' === $field_id ) ? apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ) : '' ),
187
+ );
188
+ $fields_required_options[] = array(
189
+ 'title' => ( ( 1 === $i ) ? __( 'Is Required', 'woocommerce-jetpack' ) : '' ),
190
+ 'desc' => $field_desc,
191
+ 'id' => 'wcj_product_by_user_' . $field_id . '_required',
192
+ 'default' => 'no',
193
+ 'type' => 'checkbox',
194
+ 'checkboxgroup' => $checkboxgroup,
195
+ 'custom_attributes' => ( ( 'image' === $field_id ) ? apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ) : '' ),
196
+ 'desc_tip' => ( ( 'image' === $field_id ) ? apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ) : '' ),
197
+ );
198
+ }
199
+
200
+ $settings = array_merge(
201
+ array(
202
+ array(
203
+ 'title' => __( 'Options', 'woocommerce-jetpack' ),
204
+ 'type' => 'title',
205
+ 'desc' => __( '<em>Title</em> field is always enabled and required.', 'woocommerce-jetpack' ),
206
+ 'id' => 'wcj_product_by_user_options',
207
+ ),
208
+ ),
209
+ $fields_enabled_options,
210
+ $fields_required_options,
211
+ array(
212
+ array(
213
+ 'title' => __( 'User Visibility', 'woocommerce-jetpack' ),
214
+ 'id' => 'wcj_product_by_user_user_visibility',
215
+ 'default' => array(),
216
+ 'type' => 'multiselect',
217
+ 'class' => 'chosen_select',
218
+ 'options' => $this->get_user_roles(),
219
+ ),
220
+ array(
221
+ 'title' => __( 'Product Status', 'woocommerce-jetpack' ),
222
+ 'id' => 'wcj_product_by_user_status',
223
+ 'default' => 'draft',
224
+ 'type' => 'select',
225
+ 'options' => get_post_statuses(),
226
+ ),
227
+ array(
228
+ 'title' => __( 'Add "My Products" Tab to User\'s My Account Page', 'woocommerce-jetpack' ),
229
+ 'desc ' => __( 'Add', 'woocommerce-jetpack' ),
230
+ 'id' => 'wcj_product_by_user_add_to_my_account',
231
+ 'default' => 'yes',
232
+ 'type' => 'checkbox',
233
+ ),
234
+ array(
235
+ 'type' => 'sectionend',
236
+ 'id' => 'wcj_product_by_user_options',
237
+ ),
238
+ )
239
+ );
240
+ return $this->add_standard_settings( $settings, __( 'Use [wcj_product_add_new] shortcode.', 'woocommerce-jetpack' ) );
241
+ }
242
+ }
243
+
244
+ endif;
245
+
246
+ return new WCJ_Product_By_User();
includes/class-wcj-product-images.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Product Images class.
6
  *
7
- * @version 2.4.8
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
@@ -18,7 +18,7 @@ class WCJ_Product_Images extends WCJ_Module {
18
  /**
19
  * Constructor.
20
  *
21
- * @version 2.4.8
22
  */
23
  function __construct() {
24
 
@@ -44,13 +44,16 @@ class WCJ_Product_Images extends WCJ_Module {
44
  // Archives
45
  add_action( 'woocommerce_before_shop_loop_item', array( $this, 'product_images_hide_on_archive' ) );
46
  add_action( 'woocommerce_before_shop_loop_item_title', array( $this, 'customize_archive_product_image_html' ), 10 );
 
 
47
 
48
  // Single Product Thumbnails Columns Number
49
  add_filter( 'woocommerce_product_thumbnails_columns', array( $this, 'change_product_thumbnails_columns_number' ) );
50
- }
51
 
52
- add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
53
- add_action( 'save_post_product', array( $this, 'save_meta_box' ), PHP_INT_MAX, 2 );
 
 
54
 
55
  // Sale flash
56
  if ( 'yes' === get_option( 'wcj_product_images_sale_flash_enabled', 'no' ) ) {
@@ -60,45 +63,44 @@ class WCJ_Product_Images extends WCJ_Module {
60
  }
61
 
62
  /**
63
- * customize_archive_product_image_html.
64
  *
65
- * @since 2.2.6
 
66
  */
67
- function customize_archive_product_image_html() {
68
- if ( ( $post_id = get_the_ID() ) > 0 && '' != get_post_meta( $post_id, '_' . 'wcj_product_images_meta_custom_on_archives', true ) ) {
69
- echo get_post_meta( $post_id, '_' . 'wcj_product_images_meta_custom_on_archives', true );
70
- } elseif ( '' != get_option( 'wcj_product_images_custom_on_archives', '' ) ) {
71
- echo get_option( 'wcj_product_images_custom_on_archives' );
72
  }
73
  }
74
 
75
  /**
76
- * get_meta_box_options.
77
  *
78
- * @since 2.2.6
 
79
  */
80
- function get_meta_box_options() {
81
- return array(
82
- array(
83
- 'name' => 'wcj_product_images_meta_custom_on_single',
84
- 'default' => '',
85
- 'type' => 'textarea',
86
- 'title' => __( 'Replace image with custom HTML on single product page', 'woocommerce-jetpack' ),
87
- ),
88
- array(
89
- 'name' => 'wcj_product_images_meta_custom_on_archives',
90
- 'default' => '',
91
- 'type' => 'textarea',
92
- 'title' => __( 'Replace image with custom HTML on archives', 'woocommerce-jetpack' ),
93
- ),
94
- );
95
  }
96
 
97
  /**
98
- * product_images_and_thumbnails_hide_on_single.
 
 
 
99
  */
100
- function product_images_and_thumbnails_hide_on_single() {
101
- remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
 
 
 
 
 
102
  }
103
 
104
  /**
@@ -112,54 +114,50 @@ class WCJ_Product_Images extends WCJ_Module {
112
  '' != get_option( 'wcj_product_images_custom_on_archives', '' ) ||
113
  ( ( $post_id = get_the_ID() ) > 0 && '' != get_post_meta( $post_id, '_' . 'wcj_product_images_meta_custom_on_archives', true ) )
114
  ) {
115
-
116
  remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
117
-
118
  }
119
  }
120
 
121
  /**
122
- * customize_sale_flash.
123
  */
124
- function customize_sale_flash( $sale_flash_html, $post, $product ) {
125
-
126
- // Hiding
127
- if ( 'yes' === get_option( 'wcj_product_images_sale_flash_hide_on_archives', 'no' ) && is_archive() ) return '';
128
- if ( 'yes' === get_option( 'wcj_product_images_sale_flash_hide_on_single', 'no' ) && is_single() && get_the_ID() === $product->id ) return '';
129
-
130
- // Content
131
- return do_shortcode(
132
- get_option( 'wcj_product_images_sale_flash_html' ,
133
- '<span class="onsale">' . __( 'Sale!', 'woocommerce' ) . '</span>' )
134
- );
135
-
136
  }
137
 
138
  /**
139
  * customize_single_product_image_html.
140
  *
141
- * @version 2.2.6
142
  */
143
  function customize_single_product_image_html( $image_link, $post_id ) {
144
-
145
  if ( '' != get_post_meta( $post_id, '_' . 'wcj_product_images_meta_custom_on_single', true ) ) {
146
  return get_post_meta( $post_id, '_' . 'wcj_product_images_meta_custom_on_single', true );
147
  } elseif ( '' != get_option( 'wcj_product_images_custom_on_single', '' ) ) {
148
  return get_option( 'wcj_product_images_custom_on_single' );
 
 
 
 
149
  }
150
- return ( 'yes' === get_option( 'wcj_product_images_hide_on_single', 'no' ) ) ? '' : $image_link;
151
  }
152
 
153
  /**
154
  * customize_single_product_image_thumbnail_html.
155
  *
156
- * @version 2.2.6
157
  */
158
  function customize_single_product_image_thumbnail_html( $image_link ) {
 
159
  if ( '' != get_option( 'wcj_product_images_thumbnails_custom_on_single', '' ) ) {
160
  return get_option( 'wcj_product_images_thumbnails_custom_on_single' );
 
 
 
 
161
  }
162
- return ( 'yes' === get_option( 'wcj_product_images_thumbnails_hide_on_single', 'no' ) ) ? '' : $image_link;
163
  }
164
 
165
  /**
@@ -169,24 +167,93 @@ class WCJ_Product_Images extends WCJ_Module {
169
  return get_option( 'wcj_product_images_thumbnails_columns', 3 );
170
  }
171
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  /**
173
  * get_settings.
174
  *
175
- * @version 2.4.8
176
  */
177
  function get_settings() {
178
-
179
  $settings = array(
180
 
181
- array( 'title' => __( 'Product Image and Thumbnails', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_product_images_and_thumbnails_options' ),
182
-
 
 
 
183
  array(
184
  'title' => __( 'Enable Section', 'woocommerce-jetpack' ),
185
  'id' => 'wcj_product_images_and_thumbnails_enabled',
186
  'default' => 'no',
187
  'type' => 'checkbox',
188
  ),
189
-
190
  array(
191
  'title' => __( 'Image and Thumbnails on Single', 'woocommerce-jetpack' ),
192
  'desc' => __( 'Hide', 'woocommerce-jetpack' ),
@@ -194,7 +261,27 @@ class WCJ_Product_Images extends WCJ_Module {
194
  'default' => 'no',
195
  'type' => 'checkbox',
196
  ),
197
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  array(
199
  'title' => __( 'Replace Image on Single', 'woocommerce-jetpack' ),
200
  'desc' => __( 'Replace image on single product page with custom HTML. Leave blank to disable.', 'woocommerce-jetpack' ),
@@ -203,7 +290,6 @@ class WCJ_Product_Images extends WCJ_Module {
203
  'type' => 'textarea',
204
  'css' => 'width:66%; min-width:300px;',
205
  ),
206
-
207
  array(
208
  'title' => __( 'Replace Thumbnails on Single', 'woocommerce-jetpack' ),
209
  'desc' => __( 'Replace thumbnails on single product page with custom HTML. Leave blank to disable.', 'woocommerce-jetpack' ),
@@ -212,23 +298,6 @@ class WCJ_Product_Images extends WCJ_Module {
212
  'type' => 'textarea',
213
  'css' => 'width:66%; min-width:300px;',
214
  ),
215
-
216
- array(
217
- 'title' => __( 'Image on Single', 'woocommerce-jetpack' ),
218
- 'desc' => __( 'Hide', 'woocommerce-jetpack' ),
219
- 'id' => 'wcj_product_images_hide_on_single',
220
- 'default' => 'no',
221
- 'type' => 'checkbox',
222
- ),
223
-
224
- array(
225
- 'title' => __( 'Thumbnails on Single', 'woocommerce-jetpack' ),
226
- 'desc' => __( 'Hide', 'woocommerce-jetpack' ),
227
- 'id' => 'wcj_product_images_thumbnails_hide_on_single',
228
- 'default' => 'no',
229
- 'type' => 'checkbox',
230
- ),
231
-
232
  array(
233
  'title' => __( 'Replace Image on Archive', 'woocommerce-jetpack' ),
234
  'desc' => __( 'Replace image on archive pages with custom HTML. Leave blank to disable.', 'woocommerce-jetpack' ),
@@ -237,33 +306,28 @@ class WCJ_Product_Images extends WCJ_Module {
237
  'type' => 'textarea',
238
  'css' => 'width:66%; min-width:300px;',
239
  ),
240
-
241
- array(
242
- 'title' => __( 'Image on Archives', 'woocommerce-jetpack' ),
243
- 'desc' => __( 'Hide', 'woocommerce-jetpack' ),
244
- 'id' => 'wcj_product_images_hide_on_archive',
245
- 'default' => 'no',
246
- 'type' => 'checkbox',
247
- ),
248
-
249
  array(
250
  'title' => __( 'Single Product Thumbnails Columns', 'woocommerce-jetpack' ),
251
  'id' => 'wcj_product_images_thumbnails_columns',
252
  'default' => 3,
253
  'type' => 'number',
254
  ),
 
 
 
 
255
 
256
- array( 'type' => 'sectionend', 'id' => 'wcj_product_images_and_thumbnails_options' ),
257
-
258
- array( 'title' => __( 'Product Images Sale Flash', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_product_images_sale_flash_options' ),
259
-
 
260
  array(
261
  'title' => __( 'Enable Section', 'woocommerce-jetpack' ),
262
  'id' => 'wcj_product_images_sale_flash_enabled',
263
  'default' => 'no',
264
  'type' => 'checkbox',
265
  ),
266
-
267
  array(
268
  'title' => __( 'HTML', 'woocommerce-jetpack' ),
269
  'id' => 'wcj_product_images_sale_flash_html',
@@ -271,22 +335,22 @@ class WCJ_Product_Images extends WCJ_Module {
271
  'type' => 'textarea',
272
  'css' => 'width:300px;height:100px;',
273
  ),
274
-
275
  array(
276
  'title' => __( 'Hide on Archives (Categories)', 'woocommerce-jetpack' ),
277
  'id' => 'wcj_product_images_sale_flash_hide_on_archives',
278
  'default' => 'no',
279
  'type' => 'checkbox',
280
  ),
281
-
282
  array(
283
  'title' => __( 'Hide on Single', 'woocommerce-jetpack' ),
284
  'id' => 'wcj_product_images_sale_flash_hide_on_single',
285
  'default' => 'no',
286
  'type' => 'checkbox',
287
  ),
288
-
289
- array( 'type' => 'sectionend', 'id' => 'wcj_product_images_sale_flash_options' ),
 
 
290
  );
291
 
292
  return $this->add_standard_settings( $settings );
4
  *
5
  * The WooCommerce Jetpack Product Images class.
6
  *
7
+ * @version 2.5.2
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
18
  /**
19
  * Constructor.
20
  *
21
+ * @version 2.5.2
22
  */
23
  function __construct() {
24
 
44
  // Archives
45
  add_action( 'woocommerce_before_shop_loop_item', array( $this, 'product_images_hide_on_archive' ) );
46
  add_action( 'woocommerce_before_shop_loop_item_title', array( $this, 'customize_archive_product_image_html' ), 10 );
47
+ add_action( 'woocommerce_before_shop_loop_item_title', array( $this, 'hide_per_product_image_on_archives_start' ), 1 );
48
+ add_action( 'woocommerce_before_shop_loop_item_title', array( $this, 'hide_per_product_image_on_archives_end' ), PHP_INT_MAX );
49
 
50
  // Single Product Thumbnails Columns Number
51
  add_filter( 'woocommerce_product_thumbnails_columns', array( $this, 'change_product_thumbnails_columns_number' ) );
 
52
 
53
+ // Per product options
54
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) );
55
+ add_action( 'save_post_product', array( $this, 'save_meta_box' ), PHP_INT_MAX, 2 );
56
+ }
57
 
58
  // Sale flash
59
  if ( 'yes' === get_option( 'wcj_product_images_sale_flash_enabled', 'no' ) ) {
63
  }
64
 
65
  /**
66
+ * hide_per_product_image_on_archives_start.
67
  *
68
+ * @version 2.5.2
69
+ * @since 2.5.2
70
  */
71
+ function hide_per_product_image_on_archives_start() {
72
+ $post_id = get_the_ID();
73
+ if ( $post_id > 0 && 'yes' === get_post_meta( $post_id, '_' . 'wcj_product_images_hide_image_on_archives', true ) ) {
74
+ remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
 
75
  }
76
  }
77
 
78
  /**
79
+ * hide_per_product_image_on_archives_end.
80
  *
81
+ * @version 2.5.2
82
+ * @since 2.5.2
83
  */
84
+ function hide_per_product_image_on_archives_end() {
85
+ $post_id = get_the_ID();
86
+ if ( $post_id > 0 && 'yes' === get_post_meta( $post_id, '_' . 'wcj_product_images_hide_image_on_archives', true ) ) {
87
+ add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
88
+ }
 
 
 
 
 
 
 
 
 
 
89
  }
90
 
91
  /**
92
+ * customize_archive_product_image_html.
93
+ *
94
+ * @version 2.5.2
95
+ * @since 2.2.6
96
  */
97
+ function customize_archive_product_image_html() {
98
+ $post_id = get_the_ID();
99
+ if ( $post_id > 0 && '' != get_post_meta( $post_id, '_' . 'wcj_product_images_meta_custom_on_archives', true ) ) {
100
+ echo get_post_meta( $post_id, '_' . 'wcj_product_images_meta_custom_on_archives', true );
101
+ } elseif ( '' != get_option( 'wcj_product_images_custom_on_archives', '' ) ) {
102
+ echo get_option( 'wcj_product_images_custom_on_archives' );
103
+ }
104
  }
105
 
106
  /**
114
  '' != get_option( 'wcj_product_images_custom_on_archives', '' ) ||
115
  ( ( $post_id = get_the_ID() ) > 0 && '' != get_post_meta( $post_id, '_' . 'wcj_product_images_meta_custom_on_archives', true ) )
116
  ) {
 
117
  remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
 
118
  }
119
  }
120
 
121
  /**
122
+ * product_images_and_thumbnails_hide_on_single.
123
  */
124
+ function product_images_and_thumbnails_hide_on_single() {
125
+ remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
 
 
 
 
 
 
 
 
 
 
126
  }
127
 
128
  /**
129
  * customize_single_product_image_html.
130
  *
131
+ * @version 2.5.2
132
  */
133
  function customize_single_product_image_html( $image_link, $post_id ) {
 
134
  if ( '' != get_post_meta( $post_id, '_' . 'wcj_product_images_meta_custom_on_single', true ) ) {
135
  return get_post_meta( $post_id, '_' . 'wcj_product_images_meta_custom_on_single', true );
136
  } elseif ( '' != get_option( 'wcj_product_images_custom_on_single', '' ) ) {
137
  return get_option( 'wcj_product_images_custom_on_single' );
138
+ } elseif ( 'yes' === get_option( 'wcj_product_images_hide_on_single', 'no' ) ) {
139
+ return '';
140
+ } elseif ( 'yes' === get_post_meta( $post_id, '_' . 'wcj_product_images_hide_image_on_single', true ) ) {
141
+ return '';
142
  }
143
+ return $image_link;
144
  }
145
 
146
  /**
147
  * customize_single_product_image_thumbnail_html.
148
  *
149
+ * @version 2.5.2
150
  */
151
  function customize_single_product_image_thumbnail_html( $image_link ) {
152
+ $post_id = get_the_ID();
153
  if ( '' != get_option( 'wcj_product_images_thumbnails_custom_on_single', '' ) ) {
154
  return get_option( 'wcj_product_images_thumbnails_custom_on_single' );
155
+ } elseif ( 'yes' === get_option( 'wcj_product_images_thumbnails_hide_on_single', 'no' ) ) {
156
+ return '';
157
+ } elseif ( $post_id > 0 && 'yes' === get_post_meta( $post_id, '_' . 'wcj_product_images_hide_thumb_on_single', true ) ) {
158
+ return '';
159
  }
160
+ return $image_link;
161
  }
162
 
163
  /**
167
  return get_option( 'wcj_product_images_thumbnails_columns', 3 );
168
  }
169
 
170
+ /**
171
+ * customize_sale_flash.
172
+ */
173
+ function customize_sale_flash( $sale_flash_html, $post, $product ) {
174
+ // Hiding
175
+ if ( 'yes' === get_option( 'wcj_product_images_sale_flash_hide_on_archives', 'no' ) && is_archive() ) {
176
+ return '';
177
+ }
178
+ if ( 'yes' === get_option( 'wcj_product_images_sale_flash_hide_on_single', 'no' ) && is_single() && get_the_ID() === $product->id ) {
179
+ return '';
180
+ }
181
+ // Content
182
+ return do_shortcode( get_option( 'wcj_product_images_sale_flash_html' , '<span class="onsale">' . __( 'Sale!', 'woocommerce' ) . '</span>' ) );
183
+ }
184
+
185
+ /**
186
+ * get_meta_box_options.
187
+ *
188
+ * @version 2.5.2
189
+ * @since 2.2.6
190
+ */
191
+ function get_meta_box_options() {
192
+ return array(
193
+ array(
194
+ 'name' => 'wcj_product_images_meta_custom_on_single',
195
+ 'default' => '',
196
+ 'type' => 'textarea',
197
+ 'title' => __( 'Replace image with custom HTML on single product page', 'woocommerce-jetpack' ),
198
+ ),
199
+ array(
200
+ 'name' => 'wcj_product_images_meta_custom_on_archives',
201
+ 'default' => '',
202
+ 'type' => 'textarea',
203
+ 'title' => __( 'Replace image with custom HTML on archives', 'woocommerce-jetpack' ),
204
+ ),
205
+ array(
206
+ 'name' => 'wcj_product_images_hide_image_on_single',
207
+ 'default' => 'no',
208
+ 'type' => 'select',
209
+ 'options' => array(
210
+ 'yes' => __( 'Yes', 'woocommerce-jetpack' ),
211
+ 'no' => __( 'No', 'woocommerce-jetpack' ),
212
+ ),
213
+ 'title' => __( 'Hide Image on Single', 'woocommerce-jetpack' ),
214
+ ),
215
+ array(
216
+ 'name' => 'wcj_product_images_hide_thumb_on_single',
217
+ 'default' => 'no',
218
+ 'type' => 'select',
219
+ 'options' => array(
220
+ 'yes' => __( 'Yes', 'woocommerce-jetpack' ),
221
+ 'no' => __( 'No', 'woocommerce-jetpack' ),
222
+ ),
223
+ 'title' => __( 'Hide Thumbnails on Single', 'woocommerce-jetpack' ),
224
+ ),
225
+ array(
226
+ 'name' => 'wcj_product_images_hide_image_on_archives',
227
+ 'default' => 'no',
228
+ 'type' => 'select',
229
+ 'options' => array(
230
+ 'yes' => __( 'Yes', 'woocommerce-jetpack' ),
231
+ 'no' => __( 'No', 'woocommerce-jetpack' ),
232
+ ),
233
+ 'title' => __( 'Hide Image on Archives', 'woocommerce-jetpack' ),
234
+ ),
235
+ );
236
+ }
237
+
238
  /**
239
  * get_settings.
240
  *
241
+ * @version 2.5.2
242
  */
243
  function get_settings() {
 
244
  $settings = array(
245
 
246
+ array(
247
+ 'title' => __( 'Product Image and Thumbnails', 'woocommerce-jetpack' ),
248
+ 'type' => 'title',
249
+ 'id' => 'wcj_product_images_and_thumbnails_options',
250
+ ),
251
  array(
252
  'title' => __( 'Enable Section', 'woocommerce-jetpack' ),
253
  'id' => 'wcj_product_images_and_thumbnails_enabled',
254
  'default' => 'no',
255
  'type' => 'checkbox',
256
  ),
 
257
  array(
258
  'title' => __( 'Image and Thumbnails on Single', 'woocommerce-jetpack' ),
259
  'desc' => __( 'Hide', 'woocommerce-jetpack' ),
261
  'default' => 'no',
262
  'type' => 'checkbox',
263
  ),
264
+ array(
265
+ 'title' => __( 'Image on Single', 'woocommerce-jetpack' ),
266
+ 'desc' => __( 'Hide', 'woocommerce-jetpack' ),
267
+ 'id' => 'wcj_product_images_hide_on_single',
268
+ 'default' => 'no',
269
+ 'type' => 'checkbox',
270
+ ),
271
+ array(
272
+ 'title' => __( 'Thumbnails on Single', 'woocommerce-jetpack' ),
273
+ 'desc' => __( 'Hide', 'woocommerce-jetpack' ),
274
+ 'id' => 'wcj_product_images_thumbnails_hide_on_single',
275
+ 'default' => 'no',
276
+ 'type' => 'checkbox',
277
+ ),
278
+ array(
279
+ 'title' => __( 'Image on Archives', 'woocommerce-jetpack' ),
280
+ 'desc' => __( 'Hide', 'woocommerce-jetpack' ),
281
+ 'id' => 'wcj_product_images_hide_on_archive',
282
+ 'default' => 'no',
283
+ 'type' => 'checkbox',
284
+ ),
285
  array(
286
  'title' => __( 'Replace Image on Single', 'woocommerce-jetpack' ),
287
  'desc' => __( 'Replace image on single product page with custom HTML. Leave blank to disable.', 'woocommerce-jetpack' ),
290
  'type' => 'textarea',
291
  'css' => 'width:66%; min-width:300px;',
292
  ),
 
293
  array(
294
  'title' => __( 'Replace Thumbnails on Single', 'woocommerce-jetpack' ),
295
  'desc' => __( 'Replace thumbnails on single product page with custom HTML. Leave blank to disable.', 'woocommerce-jetpack' ),
298
  'type' => 'textarea',
299
  'css' => 'width:66%; min-width:300px;',
300
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  array(
302
  'title' => __( 'Replace Image on Archive', 'woocommerce-jetpack' ),
303
  'desc' => __( 'Replace image on archive pages with custom HTML. Leave blank to disable.', 'woocommerce-jetpack' ),
306
  'type' => 'textarea',
307
  'css' => 'width:66%; min-width:300px;',
308
  ),
 
 
 
 
 
 
 
 
 
309
  array(
310
  'title' => __( 'Single Product Thumbnails Columns', 'woocommerce-jetpack' ),
311
  'id' => 'wcj_product_images_thumbnails_columns',
312
  'default' => 3,
313
  'type' => 'number',
314
  ),
315
+ array(
316
+ 'type' => 'sectionend',
317
+ 'id' => 'wcj_product_images_and_thumbnails_options',
318
+ ),
319
 
320
+ array(
321
+ 'title' => __( 'Product Images Sale Flash', 'woocommerce-jetpack' ),
322
+ 'type' => 'title',
323
+ 'id' => 'wcj_product_images_sale_flash_options',
324
+ ),
325
  array(
326
  'title' => __( 'Enable Section', 'woocommerce-jetpack' ),
327
  'id' => 'wcj_product_images_sale_flash_enabled',
328
  'default' => 'no',
329
  'type' => 'checkbox',
330
  ),
 
331
  array(
332
  'title' => __( 'HTML', 'woocommerce-jetpack' ),
333
  'id' => 'wcj_product_images_sale_flash_html',
335
  'type' => 'textarea',
336
  'css' => 'width:300px;height:100px;',
337
  ),
 
338
  array(
339
  'title' => __( 'Hide on Archives (Categories)', 'woocommerce-jetpack' ),
340
  'id' => 'wcj_product_images_sale_flash_hide_on_archives',
341
  'default' => 'no',
342
  'type' => 'checkbox',
343
  ),
 
344
  array(
345
  'title' => __( 'Hide on Single', 'woocommerce-jetpack' ),
346
  'id' => 'wcj_product_images_sale_flash_hide_on_single',
347
  'default' => 'no',
348
  'type' => 'checkbox',
349
  ),
350
+ array(
351
+ 'type' => 'sectionend',
352
+ 'id' => 'wcj_product_images_sale_flash_options',
353
+ ),
354
  );
355
 
356
  return $this->add_standard_settings( $settings );
includes/class-wcj-product-tabs.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Product Tabs class.
6
  *
7
- * @version 2.5.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -39,7 +39,7 @@ class WCJ_Product_Tabs extends WCJ_Module {
39
  /**
40
  * Customize the product tabs.
41
  *
42
- * @version 2.4.7
43
  */
44
  function customize_product_tabs( $tabs ) {
45
 
@@ -192,7 +192,7 @@ class WCJ_Product_Tabs extends WCJ_Module {
192
 
193
  // Adding the tab
194
  $tabs[ $key ] = array(
195
- 'title' => get_option( 'wcj_custom_product_tabs_title_' . $key ),
196
  'priority' => get_option( 'wcj_custom_product_tabs_priority_' . $key, 40 ),
197
  'callback' => array( $this, 'create_new_custom_product_tab_global' ),
198
  );
@@ -217,7 +217,7 @@ class WCJ_Product_Tabs extends WCJ_Module {
217
 
218
  if ( '' != get_post_meta( $current_post_id, '_' . 'wcj_custom_product_tabs_title_' . $key, true ) && '' != get_post_meta( $current_post_id, '_' . 'wcj_custom_product_tabs_content_' . $key, true ) ) {
219
  $tabs[ $key ] = array(
220
- 'title' => get_post_meta( $current_post_id, '_' . 'wcj_custom_product_tabs_title_' . $key, true ),
221
  'priority' => $tab_priority,
222
  'callback' => array( $this, 'create_new_custom_product_tab_local' ),
223
  );
4
  *
5
  * The WooCommerce Jetpack Product Tabs class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
39
  /**
40
  * Customize the product tabs.
41
  *
42
+ * @version 2.5.2
43
  */
44
  function customize_product_tabs( $tabs ) {
45
 
192
 
193
  // Adding the tab
194
  $tabs[ $key ] = array(
195
+ 'title' => do_shortcode( get_option( 'wcj_custom_product_tabs_title_' . $key ) ),
196
  'priority' => get_option( 'wcj_custom_product_tabs_priority_' . $key, 40 ),
197
  'callback' => array( $this, 'create_new_custom_product_tab_global' ),
198
  );
217
 
218
  if ( '' != get_post_meta( $current_post_id, '_' . 'wcj_custom_product_tabs_title_' . $key, true ) && '' != get_post_meta( $current_post_id, '_' . 'wcj_custom_product_tabs_content_' . $key, true ) ) {
219
  $tabs[ $key ] = array(
220
+ 'title' => do_shortcode( get_post_meta( $current_post_id, '_' . 'wcj_custom_product_tabs_title_' . $key, true ) ),
221
  'priority' => $tab_priority,
222
  'callback' => array( $this, 'create_new_custom_product_tab_local' ),
223
  );
includes/class-wcj-shipping.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Shipping class.
6
  *
7
- * @version 2.5.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -64,31 +64,31 @@ class WCJ_Shipping extends WCJ_Module {
64
  /**
65
  * show_left_to_free_shipping_info_checkout.
66
  *
67
- * @version 2.4.4
68
  * @since 2.4.4
69
  */
70
  function show_left_to_free_shipping_info_checkout() {
71
- $this->show_left_to_free_shipping_info( get_option( 'wcj_shipping_left_to_free_info_content_checkout', __( '%left_to_free% left to free shipping', 'woocommerce-jetpack' ) ) );
72
  }
73
 
74
  /**
75
  * show_left_to_free_shipping_info_mini_cart.
76
  *
77
- * @version 2.4.4
78
  * @since 2.4.4
79
  */
80
  function show_left_to_free_shipping_info_mini_cart() {
81
- $this->show_left_to_free_shipping_info( get_option( 'wcj_shipping_left_to_free_info_content_mini_cart', __( '%left_to_free% left to free shipping', 'woocommerce-jetpack' ) ) );
82
  }
83
 
84
  /**
85
  * show_left_to_free_shipping_info_cart.
86
  *
87
- * @version 2.4.4
88
  * @since 2.4.4
89
  */
90
  function show_left_to_free_shipping_info_cart() {
91
- $this->show_left_to_free_shipping_info( get_option( 'wcj_shipping_left_to_free_info_content_cart', __( '%left_to_free% left to free shipping', 'woocommerce-jetpack' ) ) );
92
  }
93
 
94
  /**
4
  *
5
  * The WooCommerce Jetpack Shipping class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
64
  /**
65
  * show_left_to_free_shipping_info_checkout.
66
  *
67
+ * @version 2.5.2
68
  * @since 2.4.4
69
  */
70
  function show_left_to_free_shipping_info_checkout() {
71
+ $this->show_left_to_free_shipping_info( do_shortcode( get_option( 'wcj_shipping_left_to_free_info_content_checkout', __( '%left_to_free% left to free shipping', 'woocommerce-jetpack' ) ) ) );
72
  }
73
 
74
  /**
75
  * show_left_to_free_shipping_info_mini_cart.
76
  *
77
+ * @version 2.5.2
78
  * @since 2.4.4
79
  */
80
  function show_left_to_free_shipping_info_mini_cart() {
81
+ $this->show_left_to_free_shipping_info( do_shortcode( get_option( 'wcj_shipping_left_to_free_info_content_mini_cart', __( '%left_to_free% left to free shipping', 'woocommerce-jetpack' ) ) ) );
82
  }
83
 
84
  /**
85
  * show_left_to_free_shipping_info_cart.
86
  *
87
+ * @version 2.5.2
88
  * @since 2.4.4
89
  */
90
  function show_left_to_free_shipping_info_cart() {
91
+ $this->show_left_to_free_shipping_info( do_shortcode( get_option( 'wcj_shipping_left_to_free_info_content_cart', __( '%left_to_free% left to free shipping', 'woocommerce-jetpack' ) ) ) );
92
  }
93
 
94
  /**
includes/class-wcj-sku.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack SKU class.
6
  *
7
- * @version 2.4.8
8
  * @author Algoritmika Ltd.
9
  * @todo add "random number" option
10
  */
@@ -58,12 +58,22 @@ class WCJ_SKU extends WCJ_Module {
58
  /**
59
  * set_sku_with_variable.
60
  *
61
- * @version 2.4.8
62
  * @todo Handle cases with more than 26 variations
63
  */
64
  function set_sku_with_variable( $product_id, $is_preview ) {
65
 
66
- $this->set_sku( $product_id, $product_id, '', $is_preview, $product_id );
 
 
 
 
 
 
 
 
 
 
67
 
68
  // Handling variable products
69
  $variation_handling = apply_filters( 'wcj_get_option_filter', 'as_variable', get_option( 'wcj_sku_variations_handling', 'as_variable' ) );
@@ -72,19 +82,25 @@ class WCJ_SKU extends WCJ_Module {
72
  $variations = $this->get_all_variations( $product );
73
  if ( 'as_variable' === $variation_handling ) {
74
  foreach ( $variations as $variation ) {
75
- $this->set_sku( $variation['variation_id'], $product_id, '', $is_preview, $product_id );
76
  }
77
  }
78
  else if ( 'as_variation' === $variation_handling ) {
79
  foreach ( $variations as $variation ) {
80
- $this->set_sku( $variation['variation_id'], $variation['variation_id'], '', $is_preview, $product_id );
 
 
 
 
 
 
81
  }
82
  }
83
  else if ( 'as_variable_with_suffix' === $variation_handling ) {
84
  $variation_suffixes = 'abcdefghijklmnopqrstuvwxyz';
85
  $abc = 0;
86
  foreach ( $variations as $variation ) {
87
- $this->set_sku( $variation['variation_id'], $product_id, $variation_suffixes[ $abc++ ], $is_preview, $product_id );
88
  if ( 26 == $abc ) {
89
  $abc = 0;
90
  }
@@ -113,10 +129,6 @@ class WCJ_SKU extends WCJ_Module {
113
  }
114
  }
115
 
116
- /* if ( 'random' === get_option( 'wcj_sku_number_generation', 'product_id' ) ) {
117
- $sku_number = rand();
118
- } */
119
-
120
  $the_sku = sprintf( '%s%s%0' . get_option( 'wcj_sku_minimum_number_length', 0 ) . 'd%s%s%s',
121
  apply_filters( 'wcj_get_option_filter', '', $category_prefix ),
122
  get_option( 'wcj_sku_prefix', '' ),
@@ -142,9 +154,12 @@ class WCJ_SKU extends WCJ_Module {
142
  /**
143
  * set_all_products_skus.
144
  *
145
- * @version 2.4.0
146
  */
147
  function set_all_products_skus( $is_preview ) {
 
 
 
148
  $limit = 96;
149
  $offset = 0;
150
  while ( TRUE ) {
@@ -153,6 +168,8 @@ class WCJ_SKU extends WCJ_Module {
153
  'offset' => $offset,
154
  'post_type' => 'product',
155
  'post_status' => 'any',
 
 
156
  ));
157
  if ( ! $posts->have_posts() ) break;
158
  while ( $posts->have_posts() ) {
@@ -162,19 +179,28 @@ class WCJ_SKU extends WCJ_Module {
162
  $offset += $limit;
163
  }
164
  wp_reset_postdata();
 
 
 
165
  }
166
 
167
  /**
168
  * set_sku_for_new_product.
169
  *
170
- * @version 2.3.10
171
  */
172
  function set_sku_for_new_product( $post_ID, $post, $update ) {
173
  if ( 'product' != $post->post_type ) {
174
  return;
175
  }
176
  if ( false === $update ) {
 
 
 
177
  $this->set_sku_with_variable( $post_ID, false );
 
 
 
178
  }
179
  }
180
 
@@ -216,46 +242,51 @@ class WCJ_SKU extends WCJ_Module {
216
  /**
217
  * get_settings.
218
  *
219
- * @version 2.4.5
220
  */
221
  function get_settings() {
222
-
223
  $settings = array(
224
-
225
  array(
226
  'title' => __( 'SKU Format Options', 'woocommerce-jetpack' ),
227
  'type' => 'title',
228
- 'desc' => '',
229
  'id' => 'wcj_sku_format_options',
230
  ),
231
-
232
- /* array(
233
  'title' => __( 'Number Generation', 'woocommerce-jetpack' ),
234
  'id' => 'wcj_sku_number_generation',
235
  'default' => 'product_id',
236
  'type' => 'select',
237
  'options' => array(
238
- 'product_id' => __( 'From product ID (recommended)', 'woocommerce-jetpack' ),
239
- 'random' => __( 'Random (including variations)', 'woocommerce-jetpack' ),
 
240
  ),
241
- // 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
242
- // 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
243
- ), */
244
-
 
 
 
 
 
 
 
 
 
 
245
  array(
246
  'title' => __( 'Prefix', 'woocommerce-jetpack' ),
247
  'id' => 'wcj_sku_prefix',
248
  'default' => '',
249
  'type' => 'text',
250
  ),
251
-
252
  array(
253
  'title' => __( 'Minimum Number Length', 'woocommerce-jetpack' ),
254
  'id' => 'wcj_sku_minimum_number_length',
255
  'default' => 0,
256
  'type' => 'number',
257
  ),
258
-
259
  array(
260
  'title' => __( 'Suffix', 'woocommerce-jetpack' ),
261
  'id' => 'wcj_sku_suffix',
@@ -264,7 +295,6 @@ class WCJ_SKU extends WCJ_Module {
264
  // 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
265
  // 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
266
  ),
267
-
268
  array(
269
  'title' => __( 'Variable Products Variations', 'woocommerce-jetpack' ),
270
  'desc_tip' => __( 'Please note, that on new variable product creation, variations will get same SKUs as parent product, and if you want variations to have different SKUs, you will need to run "Autogenerate SKUs" tool manually.' ),
@@ -279,49 +309,49 @@ class WCJ_SKU extends WCJ_Module {
279
  'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
280
  'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
281
  ),
282
-
283
  array(
284
  'type' => 'sectionend',
285
  'id' => 'wcj_sku_format_options',
286
  ),
287
  );
288
-
289
- $settings[] = array(
290
  'title' => __( 'Categories Options', 'woocommerce-jetpack' ),
291
  'type' => 'title',
292
- 'desc' => '',
293
  'id' => 'wcj_sku_categories_options',
294
- );
295
-
296
  $product_categories = get_terms( 'product_cat', 'orderby=name&hide_empty=0' );
297
  if ( ! empty( $product_categories ) && ! is_wp_error( $product_categories ) ){
298
  foreach ( $product_categories as $product_category ) {
299
- $settings[] = array(
300
- 'title' => $product_category->name,
301
- 'desc' => __( 'Prefix', 'woocommerce-jetpack' ),
302
- 'id' => 'wcj_sku_prefix_cat_' . $product_category->term_id,
303
- 'default' => '',
304
- 'type' => 'text',
305
- 'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc_no_link' ),
306
- 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
307
- );
308
- $settings[] = array(
309
- 'title' => '',
310
- 'desc' => __( 'Suffix', 'woocommerce-jetpack' ),
311
- 'id' => 'wcj_sku_suffix_cat_' . $product_category->term_id,
312
- 'default' => '',
313
- 'type' => 'text',
314
- // 'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc_no_link' ),
315
- // 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
316
- );
 
 
317
  }
318
  }
319
-
320
- $settings[] = array(
321
  'type' => 'sectionend',
322
- 'id' => 'wcj_sku_format_options',
323
- );
324
-
325
  return $this->add_standard_settings(
326
  $settings,
327
  __( 'When enabled - all new products will be given (autogenerated) SKU.', 'woocommerce-jetpack' ) . '<br>' .
4
  *
5
  * The WooCommerce Jetpack SKU class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  * @todo add "random number" option
10
  */
58
  /**
59
  * set_sku_with_variable.
60
  *
61
+ * @version 2.5.2
62
  * @todo Handle cases with more than 26 variations
63
  */
64
  function set_sku_with_variable( $product_id, $is_preview ) {
65
 
66
+ /* if ( 'random' === apply_filters( 'wcj_get_option_filter', 'product_id', get_option( 'wcj_sku_number_generation', 'product_id' ) ) ) {
67
+ $sku_number = rand();
68
+ } */
69
+ if ( 'sequential' === apply_filters( 'wcj_get_option_filter', 'product_id', get_option( 'wcj_sku_number_generation', 'product_id' ) ) ) {
70
+ $sku_number = $this->sequential_counter;
71
+ $this->sequential_counter++;
72
+ } else { // if 'product_id'
73
+ $sku_number = $product_id;
74
+ }
75
+
76
+ $this->set_sku( $product_id, $sku_number, '', $is_preview, $product_id );
77
 
78
  // Handling variable products
79
  $variation_handling = apply_filters( 'wcj_get_option_filter', 'as_variable', get_option( 'wcj_sku_variations_handling', 'as_variable' ) );
82
  $variations = $this->get_all_variations( $product );
83
  if ( 'as_variable' === $variation_handling ) {
84
  foreach ( $variations as $variation ) {
85
+ $this->set_sku( $variation['variation_id'], $sku_number, '', $is_preview, $product_id );
86
  }
87
  }
88
  else if ( 'as_variation' === $variation_handling ) {
89
  foreach ( $variations as $variation ) {
90
+ if ( 'sequential' === apply_filters( 'wcj_get_option_filter', 'product_id', get_option( 'wcj_sku_number_generation', 'product_id' ) ) ) {
91
+ $sku_number = $this->sequential_counter;
92
+ $this->sequential_counter++;
93
+ } else { // if 'product_id'
94
+ $sku_number = $variation['variation_id'];
95
+ }
96
+ $this->set_sku( $variation['variation_id'], $sku_number, '', $is_preview, $product_id );
97
  }
98
  }
99
  else if ( 'as_variable_with_suffix' === $variation_handling ) {
100
  $variation_suffixes = 'abcdefghijklmnopqrstuvwxyz';
101
  $abc = 0;
102
  foreach ( $variations as $variation ) {
103
+ $this->set_sku( $variation['variation_id'], $sku_number, $variation_suffixes[ $abc++ ], $is_preview, $product_id );
104
  if ( 26 == $abc ) {
105
  $abc = 0;
106
  }
129
  }
130
  }
131
 
 
 
 
 
132
  $the_sku = sprintf( '%s%s%0' . get_option( 'wcj_sku_minimum_number_length', 0 ) . 'd%s%s%s',
133
  apply_filters( 'wcj_get_option_filter', '', $category_prefix ),
134
  get_option( 'wcj_sku_prefix', '' ),
154
  /**
155
  * set_all_products_skus.
156
  *
157
+ * @version 2.5.2
158
  */
159
  function set_all_products_skus( $is_preview ) {
160
+ if ( 'sequential' === apply_filters( 'wcj_get_option_filter', 'product_id', get_option( 'wcj_sku_number_generation', 'product_id' ) ) ) {
161
+ $this->sequential_counter = apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_sku_number_generation_sequential', 1 ) );
162
+ }
163
  $limit = 96;
164
  $offset = 0;
165
  while ( TRUE ) {
168
  'offset' => $offset,
169
  'post_type' => 'product',
170
  'post_status' => 'any',
171
+ 'order' => 'ASC',
172
+ 'orderby' => 'date',
173
  ));
174
  if ( ! $posts->have_posts() ) break;
175
  while ( $posts->have_posts() ) {
179
  $offset += $limit;
180
  }
181
  wp_reset_postdata();
182
+ if ( 'sequential' === apply_filters( 'wcj_get_option_filter', 'product_id', get_option( 'wcj_sku_number_generation', 'product_id' ) ) && ! $is_preview ) {
183
+ update_option( 'wcj_sku_number_generation_sequential', $this->sequential_counter );
184
+ }
185
  }
186
 
187
  /**
188
  * set_sku_for_new_product.
189
  *
190
+ * @version 2.5.2
191
  */
192
  function set_sku_for_new_product( $post_ID, $post, $update ) {
193
  if ( 'product' != $post->post_type ) {
194
  return;
195
  }
196
  if ( false === $update ) {
197
+ if ( 'sequential' === apply_filters( 'wcj_get_option_filter', 'product_id', get_option( 'wcj_sku_number_generation', 'product_id' ) ) ) {
198
+ $this->sequential_counter = apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_sku_number_generation_sequential', 1 ) );
199
+ }
200
  $this->set_sku_with_variable( $post_ID, false );
201
+ if ( 'sequential' === apply_filters( 'wcj_get_option_filter', 'product_id', get_option( 'wcj_sku_number_generation', 'product_id' ) ) ) {
202
+ update_option( 'wcj_sku_number_generation_sequential', $this->sequential_counter );
203
+ }
204
  }
205
  }
206
 
242
  /**
243
  * get_settings.
244
  *
245
+ * @version 2.5.2
246
  */
247
  function get_settings() {
 
248
  $settings = array(
 
249
  array(
250
  'title' => __( 'SKU Format Options', 'woocommerce-jetpack' ),
251
  'type' => 'title',
 
252
  'id' => 'wcj_sku_format_options',
253
  ),
254
+ array(
 
255
  'title' => __( 'Number Generation', 'woocommerce-jetpack' ),
256
  'id' => 'wcj_sku_number_generation',
257
  'default' => 'product_id',
258
  'type' => 'select',
259
  'options' => array(
260
+ 'product_id' => __( 'From product ID', 'woocommerce-jetpack' ),
261
+ 'sequential' => __( 'Sequential', 'woocommerce-jetpack' ),
262
+ // 'random' => __( 'Random (including variations)', 'woocommerce-jetpack' ),
263
  ),
264
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
265
+ 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
266
+ ),
267
+ array(
268
+ 'title' => __( 'Sequential Number Generation Counter', 'woocommerce-jetpack' ),
269
+ 'id' => 'wcj_sku_number_generation_sequential',
270
+ 'default' => 1,
271
+ 'type' => 'number',
272
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
273
+ 'custom_attributes' => array_merge(
274
+ is_array( apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) ) ? apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) : array(),
275
+ array( 'step' => '1', 'min' => '0', )
276
+ ),
277
+ ),
278
  array(
279
  'title' => __( 'Prefix', 'woocommerce-jetpack' ),
280
  'id' => 'wcj_sku_prefix',
281
  'default' => '',
282
  'type' => 'text',
283
  ),
 
284
  array(
285
  'title' => __( 'Minimum Number Length', 'woocommerce-jetpack' ),
286
  'id' => 'wcj_sku_minimum_number_length',
287
  'default' => 0,
288
  'type' => 'number',
289
  ),
 
290
  array(
291
  'title' => __( 'Suffix', 'woocommerce-jetpack' ),
292
  'id' => 'wcj_sku_suffix',
295
  // 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
296
  // 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
297
  ),
 
298
  array(
299
  'title' => __( 'Variable Products Variations', 'woocommerce-jetpack' ),
300
  'desc_tip' => __( 'Please note, that on new variable product creation, variations will get same SKUs as parent product, and if you want variations to have different SKUs, you will need to run "Autogenerate SKUs" tool manually.' ),
309
  'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
310
  'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
311
  ),
 
312
  array(
313
  'type' => 'sectionend',
314
  'id' => 'wcj_sku_format_options',
315
  ),
316
  );
317
+ $settings = array_merge( $settings, array(
318
+ array(
319
  'title' => __( 'Categories Options', 'woocommerce-jetpack' ),
320
  'type' => 'title',
 
321
  'id' => 'wcj_sku_categories_options',
322
+ ),
323
+ ) );
324
  $product_categories = get_terms( 'product_cat', 'orderby=name&hide_empty=0' );
325
  if ( ! empty( $product_categories ) && ! is_wp_error( $product_categories ) ){
326
  foreach ( $product_categories as $product_category ) {
327
+ $settings = array_merge( $settings, array(
328
+ array(
329
+ 'title' => $product_category->name,
330
+ 'desc' => __( 'Prefix', 'woocommerce-jetpack' ),
331
+ 'id' => 'wcj_sku_prefix_cat_' . $product_category->term_id,
332
+ 'default' => '',
333
+ 'type' => 'text',
334
+ 'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc_no_link' ),
335
+ 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
336
+ ),
337
+ array(
338
+ 'title' => '',
339
+ 'desc' => __( 'Suffix', 'woocommerce-jetpack' ),
340
+ 'id' => 'wcj_sku_suffix_cat_' . $product_category->term_id,
341
+ 'default' => '',
342
+ 'type' => 'text',
343
+ // 'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc_no_link' ),
344
+ // 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
345
+ ),
346
+ ) );
347
  }
348
  }
349
+ $settings = array_merge( $settings, array(
350
+ array(
351
  'type' => 'sectionend',
352
+ 'id' => 'wcj_sku_categories_options',
353
+ ),
354
+ ) );
355
  return $this->add_standard_settings(
356
  $settings,
357
  __( 'When enabled - all new products will be given (autogenerated) SKU.', 'woocommerce-jetpack' ) . '<br>' .
includes/class-wcj-wholesale-price.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Wholesale Price class.
6
  *
7
- * @version 2.5.0
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  * @todo per variation;
@@ -148,7 +148,7 @@ class WCJ_Wholesale_Price extends WCJ_Module {
148
  /**
149
  * calculate_totals.
150
  *
151
- * @version 2.5.0
152
  * @since 2.5.0
153
  */
154
  function calculate_totals( $cart ) {
@@ -172,6 +172,10 @@ class WCJ_Wholesale_Price extends WCJ_Module {
172
 
173
  $price = $_product->get_price();
174
 
 
 
 
 
175
  // If other discount was applied in cart...
176
  if ( 'yes' === get_option( 'wcj_wholesale_price_apply_only_if_no_other_discounts', 'no' ) ) {
177
  if ( WC()->cart->get_total_discount() > 0 || sizeof( WC()->cart->applied_coupons ) > 0 ) {
@@ -191,7 +195,7 @@ class WCJ_Wholesale_Price extends WCJ_Module {
191
  $wcj_wholesale_price = round( $wholesale_price, $precision );
192
  WC()->cart->cart_contents[ $item_key ]['data']->wcj_wholesale_price = $wcj_wholesale_price;
193
  WC()->cart->cart_contents[ $item_key ]['wcj_wholesale_price'] = $wcj_wholesale_price;
194
- WC()->cart->cart_contents[ $item_key ]['wcj_wholesale_price_old'] = $price;
195
  }
196
  }
197
 
4
  *
5
  * The WooCommerce Jetpack Wholesale Price class.
6
  *
7
+ * @version 2.5.2
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  * @todo per variation;
148
  /**
149
  * calculate_totals.
150
  *
151
+ * @version 2.5.2
152
  * @since 2.5.0
153
  */
154
  function calculate_totals( $cart ) {
172
 
173
  $price = $_product->get_price();
174
 
175
+ $tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
176
+ $get_price_method = 'get_price_' . $tax_display_mode . 'uding_tax';
177
+ $price_old = $_product->$get_price_method(); // used for display only
178
+
179
  // If other discount was applied in cart...
180
  if ( 'yes' === get_option( 'wcj_wholesale_price_apply_only_if_no_other_discounts', 'no' ) ) {
181
  if ( WC()->cart->get_total_discount() > 0 || sizeof( WC()->cart->applied_coupons ) > 0 ) {
195
  $wcj_wholesale_price = round( $wholesale_price, $precision );
196
  WC()->cart->cart_contents[ $item_key ]['data']->wcj_wholesale_price = $wcj_wholesale_price;
197
  WC()->cart->cart_contents[ $item_key ]['wcj_wholesale_price'] = $wcj_wholesale_price;
198
+ WC()->cart->cart_contents[ $item_key ]['wcj_wholesale_price_old'] = $price_old;
199
  }
200
  }
201
 
includes/classes/class-wcj-pdf-invoice.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack PDF Invoice class.
6
  *
7
- * @version 2.4.8
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -24,7 +24,7 @@ class WCJ_PDF_Invoice extends WCJ_Invoice {
24
  /**
25
  * prepare_pdf.
26
  *
27
- * @version 2.3.9
28
  */
29
  function prepare_pdf() {
30
 
@@ -46,8 +46,16 @@ class WCJ_PDF_Invoice extends WCJ_Invoice {
46
 
47
  // Set document information
48
  $pdf->SetCreator( PDF_CREATOR );
49
- //$pdf->SetAuthor( 'Algoritmika Ltd.' );
50
- $pdf->SetTitle( 'Invoice' );
 
 
 
 
 
 
 
 
51
  $pdf->SetSubject( 'Invoice PDF' );
52
  $pdf->SetKeywords( 'invoice, PDF' );
53
 
4
  *
5
  * The WooCommerce Jetpack PDF Invoice class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
24
  /**
25
  * prepare_pdf.
26
  *
27
+ * @version 2.5.2
28
  */
29
  function prepare_pdf() {
30
 
46
 
47
  // Set document information
48
  $pdf->SetCreator( PDF_CREATOR );
49
+ // $pdf->SetAuthor( 'Algoritmika Ltd.' );
50
+ $invoice_title = $invoice_type;
51
+ $invoice_types = /* ( 'yes' === get_option( 'wcj_invoicing_hide_disabled_docs_settings', 'no' ) ) ? wcj_get_enabled_invoice_types() : */ wcj_get_invoice_types();
52
+ foreach ( $invoice_types as $invoice_type_data ) {
53
+ if ( $invoice_type === $invoice_type_data['id'] ) {
54
+ $invoice_title = $invoice_type_data['title'];
55
+ break;
56
+ }
57
+ }
58
+ $pdf->SetTitle( $invoice_title );
59
  $pdf->SetSubject( 'Invoice PDF' );
60
  $pdf->SetKeywords( 'invoice, PDF' );
61
 
includes/exchange-rates/class-wcj-exchange-rates-crons.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Exchange Rates Crons class.
6
  *
7
- * @version 2.4.8
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -64,8 +64,9 @@ class WCJ_Exchange_Rates_Crons {
64
  }
65
 
66
  /*
67
- * Functions gets currency exchange rate from rate-exchange.appspot.com server.
68
- * returns rate on success, else 0
 
69
  */
70
  function get_exchange_rate( $currency_from, $currency_to ) {
71
 
@@ -110,7 +111,7 @@ class WCJ_Exchange_Rates_Crons {
110
  /**
111
  * On the scheduled action hook, run a function.
112
  *
113
- * @version 2.4.8
114
  */
115
  function update_the_exchange_rates( $interval ) {
116
 
@@ -146,6 +147,16 @@ class WCJ_Exchange_Rates_Crons {
146
  }
147
  }
148
 
 
 
 
 
 
 
 
 
 
 
149
  if ( wcj_is_module_enabled( 'payment_gateways_currency' ) ) {
150
  // Currency Pairs - Preparation - Gateway Currency
151
  if ( 'manual' != apply_filters( 'wcj_get_option_filter', 'manual', get_option( 'wcj_gateways_currency_exchange_rate_update_auto', 'manual' ) ) ) {
@@ -179,7 +190,9 @@ class WCJ_Exchange_Rates_Crons {
179
  } else {
180
  $result_message = __( 'Cron job: exchange rates update failed', 'woocommerce-jetpack' );
181
  }
182
- //wcj_log( $result_message . ': ' . $currency_from . $currency_to . ': ' . $the_rate . ': ' . 'update_the_exchange_rates: ' . $interval );
 
 
183
  }
184
  }
185
 
4
  *
5
  * The WooCommerce Jetpack Exchange Rates Crons class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
64
  }
65
 
66
  /*
67
+ * get_exchange_rate.
68
+ *
69
+ * @return float rate on success, else 0
70
  */
71
  function get_exchange_rate( $currency_from, $currency_to ) {
72
 
111
  /**
112
  * On the scheduled action hook, run a function.
113
  *
114
+ * @version 2.5.2
115
  */
116
  function update_the_exchange_rates( $interval ) {
117
 
147
  }
148
  }
149
 
150
+ if ( wcj_is_module_enabled( 'currency_per_product' ) ) {
151
+ // Currency Pairs - Preparation - Currency per Product
152
+ if ( 'manual' != apply_filters( 'wcj_get_option_filter', 'manual', get_option( 'wcj_currency_per_product_exchange_rate_update', 'manual' ) ) ) {
153
+ for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_currency_per_product_total_number', 1 ) ); $i++ ) {
154
+ $currency_to = get_option( 'wcj_currency_per_product_currency_' . $i );
155
+ $currency_pairs = $this->get_currency_pair( $currency_pairs, $currency_to, 'wcj_currency_per_product_exchange_rate_' . $i );
156
+ }
157
+ }
158
+ }
159
+
160
  if ( wcj_is_module_enabled( 'payment_gateways_currency' ) ) {
161
  // Currency Pairs - Preparation - Gateway Currency
162
  if ( 'manual' != apply_filters( 'wcj_get_option_filter', 'manual', get_option( 'wcj_gateways_currency_exchange_rate_update_auto', 'manual' ) ) ) {
190
  } else {
191
  $result_message = __( 'Cron job: exchange rates update failed', 'woocommerce-jetpack' );
192
  }
193
+ if ( 'yes' === get_option( 'wcj_currency_exchange_logging_enabled', 'no' ) ) {
194
+ wcj_log( $result_message . ': ' . $currency_from . $currency_to . ': ' . $the_rate . ': ' . 'update_the_exchange_rates: ' . $interval );
195
+ }
196
  }
197
  }
198
 
includes/exchange-rates/class-wcj-exchange-rates.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Exchange Rates class.
6
  *
7
- * @version 2.4.8
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -28,7 +28,7 @@ class WCJ_Exchange_Rates {
28
  /**
29
  * register_script.
30
  *
31
- * @version 2.4.8
32
  */
33
  public function register_script() {
34
  if (
@@ -36,6 +36,7 @@ class WCJ_Exchange_Rates {
36
  in_array( $_GET['section'], array(
37
  'multicurrency',
38
  'multicurrency_base_price',
 
39
  'price_by_country',
40
  'payment_gateways_currency',
41
  'currency_exchange_rates',
@@ -48,7 +49,7 @@ class WCJ_Exchange_Rates {
48
  /**
49
  * enqueue_exchange_rates_script.
50
  *
51
- * @version 2.4.8
52
  */
53
  public function enqueue_exchange_rates_script() {
54
  if (
@@ -56,6 +57,7 @@ class WCJ_Exchange_Rates {
56
  in_array( $_GET['section'], array(
57
  'multicurrency',
58
  'multicurrency_base_price',
 
59
  'price_by_country',
60
  'payment_gateways_currency',
61
  'currency_exchange_rates',
4
  *
5
  * The WooCommerce Jetpack Exchange Rates class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
28
  /**
29
  * register_script.
30
  *
31
+ * @version 2.5.2
32
  */
33
  public function register_script() {
34
  if (
36
  in_array( $_GET['section'], array(
37
  'multicurrency',
38
  'multicurrency_base_price',
39
+ 'currency_per_product',
40
  'price_by_country',
41
  'payment_gateways_currency',
42
  'currency_exchange_rates',
49
  /**
50
  * enqueue_exchange_rates_script.
51
  *
52
+ * @version 2.5.2
53
  */
54
  public function enqueue_exchange_rates_script() {
55
  if (
57
  in_array( $_GET['section'], array(
58
  'multicurrency',
59
  'multicurrency_base_price',
60
+ 'currency_per_product',
61
  'price_by_country',
62
  'payment_gateways_currency',
63
  'currency_exchange_rates',
includes/functions/wcj-functions.php CHANGED
@@ -4,10 +4,22 @@
4
  *
5
  * The WooCommerce Jetpack Functions.
6
  *
7
- * @version 2.5.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  if ( ! function_exists( 'wcj_get_current_currency_code' ) ) {
12
  /**
13
  * wcj_get_current_currency_code.
@@ -140,7 +152,7 @@ if ( ! function_exists( 'wcj_get_product_input_fields' ) ) {
140
  /*
141
  * wcj_get_left_to_free_shipping.
142
  *
143
- * @version 2.4.8
144
  * @since 2.4.4
145
  * @return string
146
  */
@@ -157,7 +169,7 @@ if ( ! function_exists( 'wcj_get_left_to_free_shipping' ) ) {
157
  $total = WC()->cart->cart_contents_total;
158
  }
159
  if ( $total >= $free_shipping->min_amount ) {
160
- return get_option( 'wcj_shipping_left_to_free_info_content_reached', __( 'You have Free delivery', 'woocommerce-jetpack' ) );
161
  } else {
162
  $content = str_replace( '%left_to_free%', wc_price( $free_shipping->min_amount - $total ), $content );
163
  $content = str_replace( '%free_shipping_min_amount%', wc_price( $free_shipping->min_amount ), $content );
@@ -416,13 +428,16 @@ if ( ! function_exists( 'is_shop_manager' ) ) {
416
  /**
417
  * wcj_is_user_role.
418
  *
419
- * @version 2.5.0
420
  * @since 2.5.0
421
  * @return bool
422
  */
423
  if ( ! function_exists( 'wcj_is_user_role' ) ) {
424
  function wcj_is_user_role( $user_role, $user_id = 0 ) {
425
  $the_user = ( 0 == $user_id ) ? wp_get_current_user() : get_user_by( 'id', $user_id );
 
 
 
426
  return ( isset( $the_user->roles ) && is_array( $the_user->roles ) && in_array( $user_role, $the_user->roles ) ) ? true : false;
427
  }
428
  }
4
  *
5
  * The WooCommerce Jetpack Functions.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
11
+ if ( ! function_exists( 'wcj_add_files_upload_form_to_checkout_frontend' ) ) {
12
+ /**
13
+ * wcj_add_files_upload_form_to_checkout_frontend.
14
+ *
15
+ * @version 2.5.2
16
+ * @since 2.5.2
17
+ */
18
+ function wcj_add_files_upload_form_to_checkout_frontend() {
19
+ WCJ()->modules['checkout_files_upload']->add_files_upload_form_to_checkout_frontend_all( true );
20
+ }
21
+ }
22
+
23
  if ( ! function_exists( 'wcj_get_current_currency_code' ) ) {
24
  /**
25
  * wcj_get_current_currency_code.
152
  /*
153
  * wcj_get_left_to_free_shipping.
154
  *
155
+ * @version 2.5.2
156
  * @since 2.4.4
157
  * @return string
158
  */
169
  $total = WC()->cart->cart_contents_total;
170
  }
171
  if ( $total >= $free_shipping->min_amount ) {
172
+ return do_shortcode( get_option( 'wcj_shipping_left_to_free_info_content_reached', __( 'You have Free delivery', 'woocommerce-jetpack' ) ) );
173
  } else {
174
  $content = str_replace( '%left_to_free%', wc_price( $free_shipping->min_amount - $total ), $content );
175
  $content = str_replace( '%free_shipping_min_amount%', wc_price( $free_shipping->min_amount ), $content );
428
  /**
429
  * wcj_is_user_role.
430
  *
431
+ * @version 2.5.2
432
  * @since 2.5.0
433
  * @return bool
434
  */
435
  if ( ! function_exists( 'wcj_is_user_role' ) ) {
436
  function wcj_is_user_role( $user_role, $user_id = 0 ) {
437
  $the_user = ( 0 == $user_id ) ? wp_get_current_user() : get_user_by( 'id', $user_id );
438
+ if ( ! isset( $the_user->roles ) || empty( $the_user->roles ) ) {
439
+ $the_user->roles = array( 'guest' );
440
+ }
441
  return ( isset( $the_user->roles ) && is_array( $the_user->roles ) && in_array( $user_role, $the_user->roles ) ) ? true : false;
442
  }
443
  }
includes/functions/wcj-invoicing-functions.php CHANGED
@@ -2,14 +2,14 @@
2
  /**
3
  * WooCommerce Jetpack Invoicing Functions
4
  *
5
- * @version 2.2.7
6
  * @author Algoritmika Ltd.
7
  */
8
 
9
  /*
10
  * wcj_get_invoice_types.
11
  *
12
- * @version 2.2.7
13
  */
14
  if ( ! function_exists( 'wcj_get_invoice_types' ) ) {
15
  function wcj_get_invoice_types() {
@@ -19,7 +19,7 @@ if ( ! function_exists( 'wcj_get_invoice_types' ) ) {
19
  'title' => __( 'Invoice', 'woocommerce-jetpack' ),
20
  'desc' => __( 'Invoices', 'woocommerce-jetpack' ),
21
  'defaults' => array( 'init' => 'disabled', ),
22
- 'icon' => '\e028',
23
  ),
24
 
25
  array(
@@ -27,7 +27,7 @@ if ( ! function_exists( 'wcj_get_invoice_types' ) ) {
27
  'title' => __( 'Proforma Invoice', 'woocommerce-jetpack' ),
28
  'desc' => __( 'Proforma Invoices', 'woocommerce-jetpack' ),
29
  'defaults' => array( 'init' => 'disabled', ),
30
- 'icon' => '\e030',
31
  ),
32
 
33
  array(
@@ -35,7 +35,7 @@ if ( ! function_exists( 'wcj_get_invoice_types' ) ) {
35
  'title' => __( 'Packing Slip', 'woocommerce-jetpack' ),
36
  'desc' => __( 'Packing Slips', 'woocommerce-jetpack' ),
37
  'defaults' => array( 'init' => 'disabled', ),
38
- 'icon' => '\e019',
39
  ),
40
 
41
  array(
@@ -43,7 +43,7 @@ if ( ! function_exists( 'wcj_get_invoice_types' ) ) {
43
  'title' => __( 'Credit Note', 'woocommerce-jetpack' ),
44
  'desc' => __( 'Credit Notes', 'woocommerce-jetpack' ),
45
  'defaults' => array( 'init' => 'disabled', ),
46
- 'icon' => '\e019',
47
  ),
48
 
49
  array(
@@ -51,7 +51,7 @@ if ( ! function_exists( 'wcj_get_invoice_types' ) ) {
51
  'title' => __( 'Custom Document', 'woocommerce-jetpack' ),
52
  'desc' => __( 'Custom Documents', 'woocommerce-jetpack' ),
53
  'defaults' => array( 'init' => 'disabled', ),
54
- 'icon' => '\e019',
55
  ),
56
  );
57
  return $invoice_types;
2
  /**
3
  * WooCommerce Jetpack Invoicing Functions
4
  *
5
+ * @version 2.5.2
6
  * @author Algoritmika Ltd.
7
  */
8
 
9
  /*
10
  * wcj_get_invoice_types.
11
  *
12
+ * @version 2.5.2
13
  */
14
  if ( ! function_exists( 'wcj_get_invoice_types' ) ) {
15
  function wcj_get_invoice_types() {
19
  'title' => __( 'Invoice', 'woocommerce-jetpack' ),
20
  'desc' => __( 'Invoices', 'woocommerce-jetpack' ),
21
  'defaults' => array( 'init' => 'disabled', ),
22
+ // 'icon' => '\e028',
23
  ),
24
 
25
  array(
27
  'title' => __( 'Proforma Invoice', 'woocommerce-jetpack' ),
28
  'desc' => __( 'Proforma Invoices', 'woocommerce-jetpack' ),
29
  'defaults' => array( 'init' => 'disabled', ),
30
+ // 'icon' => '\e030',
31
  ),
32
 
33
  array(
35
  'title' => __( 'Packing Slip', 'woocommerce-jetpack' ),
36
  'desc' => __( 'Packing Slips', 'woocommerce-jetpack' ),
37
  'defaults' => array( 'init' => 'disabled', ),
38
+ // 'icon' => '\e019',
39
  ),
40
 
41
  array(
43
  'title' => __( 'Credit Note', 'woocommerce-jetpack' ),
44
  'desc' => __( 'Credit Notes', 'woocommerce-jetpack' ),
45
  'defaults' => array( 'init' => 'disabled', ),
46
+ // 'icon' => '\e019',
47
  ),
48
 
49
  array(
51
  'title' => __( 'Custom Document', 'woocommerce-jetpack' ),
52
  'desc' => __( 'Custom Documents', 'woocommerce-jetpack' ),
53
  'defaults' => array( 'init' => 'disabled', ),
54
+ // 'icon' => '\e019',
55
  ),
56
  );
57
  return $invoice_types;
includes/gateways/class-wc-gateway-wcj-custom.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Custom Payment Gateway class.
6
  *
7
- * @version 2.4.8
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -31,7 +31,7 @@ if ( ! function_exists( 'init_wc_gateway_wcj_custom_class' ) ) {
31
  /**
32
  * Initialise Gateway Settings Form Fields
33
  *
34
- * @version 2.4.0
35
  */
36
  public function init_form_fields() {
37
  global $woocommerce;
@@ -70,7 +70,8 @@ if ( ! function_exists( 'init_wc_gateway_wcj_custom_class' ) ) {
70
  'description' => array(
71
  'title' => __( 'Description', 'woocommerce' ),
72
  'type' => 'textarea',
73
- 'description' => __( 'Payment method description that the customer will see on your checkout.', 'woocommerce' ),
 
74
  'default' => __( 'Custom Payment Description.', 'woocommerce' ),
75
  'desc_tip' => true,
76
  ),
@@ -337,7 +338,7 @@ if ( ! function_exists( 'init_wc_gateway_wcj_custom_class' ) ) {
337
  /**
338
  * init.
339
  *
340
- * @version 2.4.8
341
  */
342
  public function init( $id_count ) {
343
  $this->id = ( 1 === $id_count ) ? 'jetpack_custom_gateway' : 'jetpack_custom_gateway_' . $id_count;
@@ -350,7 +351,7 @@ if ( ! function_exists( 'init_wc_gateway_wcj_custom_class' ) ) {
350
  $this->init_settings();
351
  // Define user set variables
352
  $this->title = $this->get_option( 'title' );
353
- $this->description = $this->get_option( 'description' );
354
  $this->instructions = $this->get_option( 'instructions', '' );//$this->description );
355
  $this->instructions_in_email = $this->get_option( 'instructions_in_email', '' );
356
  $this->icon = $this->get_option( 'icon', '' );//apply_filters( 'woocommerce_wcj_custom_icon', $this->get_option( 'icon', '' ) );
4
  *
5
  * The WooCommerce Jetpack Custom Payment Gateway class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
31
  /**
32
  * Initialise Gateway Settings Form Fields
33
  *
34
+ * @version 2.5.2
35
  */
36
  public function init_form_fields() {
37
  global $woocommerce;
70
  'description' => array(
71
  'title' => __( 'Description', 'woocommerce' ),
72
  'type' => 'textarea',
73
+ 'description' => __( 'Payment method description that the customer will see on your checkout.', 'woocommerce' ) . ' ' .
74
+ __( 'You can add input fields with [wcj_input_field] shortcode.', 'woocommerce' ),
75
  'default' => __( 'Custom Payment Description.', 'woocommerce' ),
76
  'desc_tip' => true,
77
  ),
338
  /**
339
  * init.
340
  *
341
+ * @version 2.5.2
342
  */
343
  public function init( $id_count ) {
344
  $this->id = ( 1 === $id_count ) ? 'jetpack_custom_gateway' : 'jetpack_custom_gateway_' . $id_count;
351
  $this->init_settings();
352
  // Define user set variables
353
  $this->title = $this->get_option( 'title' );
354
+ $this->description = do_shortcode( str_replace( '[wcj_input_field', '[wcj_input_field attach_to="' . $this->id . '"', $this->get_option( 'description' ) ) );
355
  $this->instructions = $this->get_option( 'instructions', '' );//$this->description );
356
  $this->instructions_in_email = $this->get_option( 'instructions_in_email', '' );
357
  $this->icon = $this->get_option( 'icon', '' );//apply_filters( 'woocommerce_wcj_custom_icon', $this->get_option( 'icon', '' ) );
includes/input-fields/class-wcj-product-input-fields-abstract.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Product Input Fields abstract class.
6
  *
7
- * @version 2.5.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -27,7 +27,7 @@ class WCJ_Product_Input_Fields_Abstract {
27
  /**
28
  * get_options.
29
  *
30
- * @version 2.4.7
31
  */
32
  public function get_options() {
33
  $options = array(
@@ -111,6 +111,14 @@ class WCJ_Product_Input_Fields_Abstract {
111
  'default' => __( '.jpg,.jpeg,.png', 'woocommerce-jetpack' ),
112
  ),
113
 
 
 
 
 
 
 
 
 
114
  array(
115
  'id' => 'wcj_product_input_fields_type_datepicker_format_' . $this->scope . '_',
116
  'title' => __( 'If datepicker/weekpicker is selected, set date format here. Visit <a href="https://codex.wordpress.org/Formatting_Date_and_Time" target="_blank">documentation on date and time formatting</a> for valid date formats.', 'woocommerce-jetpack' ),
@@ -411,7 +419,7 @@ class WCJ_Product_Input_Fields_Abstract {
411
  /**
412
  * validate_product_input_fields_on_add_to_cart.
413
  *
414
- * @version 2.4.5
415
  */
416
  public function validate_product_input_fields_on_add_to_cart( $passed, $product_id ) {
417
  $total_number = apply_filters( 'wcj_get_option_filter', 1, $this->get_value( 'wcj_' . 'product_input_fields' . '_' . $this->scope . '_total_number', $product_id, 1 ) );
@@ -458,6 +466,13 @@ class WCJ_Product_Input_Fields_Abstract {
458
  }
459
  }
460
  }
 
 
 
 
 
 
 
461
  }
462
  }
463
 
4
  *
5
  * The WooCommerce Jetpack Product Input Fields abstract class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
27
  /**
28
  * get_options.
29
  *
30
+ * @version 2.5.2
31
  */
32
  public function get_options() {
33
  $options = array(
111
  'default' => __( '.jpg,.jpeg,.png', 'woocommerce-jetpack' ),
112
  ),
113
 
114
+ array(
115
+ 'id' => 'wcj_product_input_fields_type_file_max_size_' . $this->scope . '_',
116
+ 'title' => __( 'If file is selected, set max file size here. Set to zero to accept all files', 'woocommerce-jetpack' ),
117
+ 'short_title' => __( 'File: Max size', 'woocommerce-jetpack' ),
118
+ 'type' => 'number',
119
+ 'default' => 0,
120
+ ),
121
+
122
  array(
123
  'id' => 'wcj_product_input_fields_type_datepicker_format_' . $this->scope . '_',
124
  'title' => __( 'If datepicker/weekpicker is selected, set date format here. Visit <a href="https://codex.wordpress.org/Formatting_Date_and_Time" target="_blank">documentation on date and time formatting</a> for valid date formats.', 'woocommerce-jetpack' ),
419
  /**
420
  * validate_product_input_fields_on_add_to_cart.
421
  *
422
+ * @version 2.5.2
423
  */
424
  public function validate_product_input_fields_on_add_to_cart( $passed, $product_id ) {
425
  $total_number = apply_filters( 'wcj_get_option_filter', 1, $this->get_value( 'wcj_' . 'product_input_fields' . '_' . $this->scope . '_total_number', $product_id, 1 ) );
466
  }
467
  }
468
  }
469
+ // Validate file max size
470
+ if ( ( $max_file_size = $this->get_value( 'wcj_product_input_fields_type_file_max_size_' . $this->scope . '_' . $i, $product_id, '' ) ) > 0 ) {
471
+ if ( $_FILES[ $field_name ]['size'] > $max_file_size ) {
472
+ $passed = false;
473
+ wc_add_notice( __( 'File is too big!', 'woocommerce-jetpack' ), 'error' );
474
+ }
475
+ }
476
  }
477
  }
478
 
includes/js/wcj-disable-quantity.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * wcj-disable-quantity.
3
+ *
4
+ * version 2.5.2
5
+ * since 2.5.2
6
+ */
7
+ jQuery(document).ready(function() {
8
+ jQuery("div.quantity input.qty").each( function () {
9
+ jQuery(this).attr("disabled", "disabled");
10
+ });
11
+ });
includes/js/wcj-pdf-invoicing.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * wcj-pdf-invoicing.
3
+ *
4
+ * version 2.5.2
5
+ * since 2.5.2
6
+ */
7
+ jQuery(document).ready(function() {
8
+ jQuery('a.wcj_need_confirmation').click(function() {
9
+ return confirm("Are you sure?");
10
+ });
11
+ });
includes/pdf-invoices/class-wcj-pdf-invoicing-report-tool.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack PDF Invoices Report Tool class.
6
  *
7
- * @version 2.5.0
8
  * @since 2.2.1
9
  * @author Algoritmika Ltd.
10
  */
@@ -117,7 +117,7 @@ class WCJ_PDF_Invoicing_Report_Tool {
117
  /**
118
  * get_invoices_report_zip.
119
  *
120
- * @version 2.3.10
121
  * @since 2.3.10
122
  */
123
  function get_invoices_report_zip( $year, $month, $invoice_type_id ) {
@@ -131,6 +131,9 @@ class WCJ_PDF_Invoicing_Report_Tool {
131
  return false;
132
  }
133
 
 
 
 
134
  $offset = 0;
135
  $block_size = 96;
136
  while( true ) {
@@ -138,10 +141,19 @@ class WCJ_PDF_Invoicing_Report_Tool {
138
  'post_type' => 'shop_order',
139
  'post_status' => 'any',
140
  'posts_per_page' => $block_size,
141
- 'orderby' => 'date',
 
142
  'order' => 'ASC',
143
- 'year' => $year,
144
- 'monthnum' => $month,
 
 
 
 
 
 
 
 
145
  'offset' => $offset,
146
  );
147
  $loop = new WP_Query( $args );
@@ -183,7 +195,7 @@ class WCJ_PDF_Invoicing_Report_Tool {
183
  /**
184
  * Invoices Report function.
185
  *
186
- * @version 2.3.11
187
  */
188
  function get_invoices_report( $year, $month, $invoice_type_id ) {
189
 
@@ -191,8 +203,8 @@ class WCJ_PDF_Invoicing_Report_Tool {
191
 
192
  $data = array();
193
  $data[] = array(
194
- __( 'Invoice Nr.', 'woocommerce-jetpack' ),
195
- __( 'Invoice Date', 'woocommerce-jetpack' ),
196
  __( 'Order ID', 'woocommerce-jetpack' ),
197
  __( 'Customer Country', 'woocommerce-jetpack' ),
198
  __( 'Customer VAT ID', 'woocommerce-jetpack' ),
@@ -207,6 +219,9 @@ class WCJ_PDF_Invoicing_Report_Tool {
207
  $total_sum_excl_tax = 0;
208
  $total_tax = 0;
209
 
 
 
 
210
  $offset = 0;
211
  $block_size = 96;
212
  while( true ) {
@@ -214,10 +229,19 @@ class WCJ_PDF_Invoicing_Report_Tool {
214
  'post_type' => 'shop_order',
215
  'post_status' => 'any',
216
  'posts_per_page' => $block_size,
217
- 'orderby' => 'date',
 
218
  'order' => 'ASC',
219
- 'year' => $year,
220
- 'monthnum' => $month,
 
 
 
 
 
 
 
 
221
  'offset' => $offset,
222
  );
223
  $loop = new WP_Query( $args );
@@ -263,6 +287,7 @@ class WCJ_PDF_Invoicing_Report_Tool {
263
  $order_tax_html,
264
  sprintf( '%.2f', $order_total ),
265
  $the_order->get_order_currency(),
 
266
  );
267
  }
268
  endwhile;
@@ -274,6 +299,8 @@ class WCJ_PDF_Invoicing_Report_Tool {
274
  $output .= '<h3>' . 'Total Tax: ' . sprintf( '$ %.2f', $total_tax ) . '</h3>'; */
275
  $output .= wcj_get_table_html( $data, array( 'table_class' => 'widefat', ) );
276
 
 
 
277
  return $output;
278
  }
279
  }
4
  *
5
  * The WooCommerce Jetpack PDF Invoices Report Tool class.
6
  *
7
+ * @version 2.5.2
8
  * @since 2.2.1
9
  * @author Algoritmika Ltd.
10
  */
117
  /**
118
  * get_invoices_report_zip.
119
  *
120
+ * @version 2.5.2
121
  * @since 2.3.10
122
  */
123
  function get_invoices_report_zip( $year, $month, $invoice_type_id ) {
131
  return false;
132
  }
133
 
134
+ $first_minute = mktime( 0, 0, 0, $month, 1, $year );
135
+ $last_minute = mktime( 23, 59, 59, $month, date( 't', $first_minute ), $year );
136
+
137
  $offset = 0;
138
  $block_size = 96;
139
  while( true ) {
141
  'post_type' => 'shop_order',
142
  'post_status' => 'any',
143
  'posts_per_page' => $block_size,
144
+ 'orderby' => 'meta_value_num',
145
+ 'meta_key' => '_wcj_invoicing_' . $invoice_type_id . '_date',
146
  'order' => 'ASC',
147
+ // 'year' => $year,
148
+ // 'monthnum' => $month,
149
+ 'meta_query' => array(
150
+ array(
151
+ 'key' => '_wcj_invoicing_' . $invoice_type_id . '_date',
152
+ 'value' => array( $first_minute , $last_minute ),
153
+ 'type' => 'numeric',
154
+ 'compare' => 'BETWEEN',
155
+ ),
156
+ ),
157
  'offset' => $offset,
158
  );
159
  $loop = new WP_Query( $args );
195
  /**
196
  * Invoices Report function.
197
  *
198
+ * @version 2.5.2
199
  */
200
  function get_invoices_report( $year, $month, $invoice_type_id ) {
201
 
203
 
204
  $data = array();
205
  $data[] = array(
206
+ __( 'Document Nr.', 'woocommerce-jetpack' ),
207
+ __( 'Document Date', 'woocommerce-jetpack' ),
208
  __( 'Order ID', 'woocommerce-jetpack' ),
209
  __( 'Customer Country', 'woocommerce-jetpack' ),
210
  __( 'Customer VAT ID', 'woocommerce-jetpack' ),
219
  $total_sum_excl_tax = 0;
220
  $total_tax = 0;
221
 
222
+ $first_minute = mktime( 0, 0, 0, $month, 1, $year );
223
+ $last_minute = mktime( 23, 59, 59, $month, date( 't', $first_minute ), $year );
224
+
225
  $offset = 0;
226
  $block_size = 96;
227
  while( true ) {
229
  'post_type' => 'shop_order',
230
  'post_status' => 'any',
231
  'posts_per_page' => $block_size,
232
+ 'orderby' => 'meta_value_num',
233
+ 'meta_key' => '_wcj_invoicing_' . $invoice_type_id . '_date',
234
  'order' => 'ASC',
235
+ // 'year' => $year,
236
+ // 'monthnum' => $month,
237
+ 'meta_query' => array(
238
+ array(
239
+ 'key' => '_wcj_invoicing_' . $invoice_type_id . '_date',
240
+ 'value' => array( $first_minute , $last_minute ),
241
+ 'type' => 'numeric',
242
+ 'compare' => 'BETWEEN',
243
+ ),
244
+ ),
245
  'offset' => $offset,
246
  );
247
  $loop = new WP_Query( $args );
287
  $order_tax_html,
288
  sprintf( '%.2f', $order_total ),
289
  $the_order->get_order_currency(),
290
+ //'<pre>' . print_r( get_post_meta( $order_id ), true ) . '</pre>',
291
  );
292
  }
293
  endwhile;
299
  $output .= '<h3>' . 'Total Tax: ' . sprintf( '$ %.2f', $total_tax ) . '</h3>'; */
300
  $output .= wcj_get_table_html( $data, array( 'table_class' => 'widefat', ) );
301
 
302
+ // $output .= date( "Y-m-d H:i:s", $first_minute ) . ' -> ' . date( "Y-m-d H:i:s", $last_minute );
303
+
304
  return $output;
305
  }
306
  }
includes/pdf-invoices/settings/class-wcj-pdf-invoicing-display.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing Display class.
6
  *
7
- * @version 2.4.7
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -17,7 +17,7 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
17
  /**
18
  * Constructor.
19
  *
20
- * @version 2.4.7
21
  */
22
  function __construct() {
23
 
@@ -36,13 +36,24 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
36
  // Action Buttons to Admin's Orders list
37
  add_filter( 'woocommerce_admin_order_actions', array( $this, 'add_pdf_invoices_admin_actions' ), PHP_INT_MAX, 2 );
38
  add_filter( 'admin_head', array( $this, 'add_pdf_invoices_admin_actions_buttons_css' ) );
 
39
  }
40
  }
41
 
 
 
 
 
 
 
 
 
 
 
42
  /**
43
  * add_pdf_invoices_admin_actions_buttons_css.
44
  *
45
- * @version 2.4.7
46
  * @since 2.4.7
47
  */
48
  function add_pdf_invoices_admin_actions_buttons_css() {
@@ -69,9 +80,9 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
69
  echo '.view.' . $invoice_type['id'] . '{ color: ' . $color . ' !important; }' . PHP_EOL;
70
  echo '.view.' . $invoice_type['id'] . '_' . 'create' . '{ color: ' . $color . ' !important; }' . PHP_EOL;
71
  echo '.view.' . $invoice_type['id'] . '_' . 'delete' . '{ color: ' . $color . ' !important; }' . PHP_EOL;
72
- echo '.view.' . $invoice_type['id'] . '::after { content: "\e028" !important; }' . PHP_EOL;
73
- echo '.view.' . $invoice_type['id'] . '_' . 'create' . '::after { content: "\e027" !important; }' . PHP_EOL;
74
- echo '.view.' . $invoice_type['id'] . '_' . 'delete' . '::after { content: "\e030" !important; }' . PHP_EOL;
75
  }
76
  echo '</style>' . PHP_EOL;
77
  }
@@ -79,7 +90,7 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
79
  /**
80
  * add_pdf_invoices_admin_actions.
81
  *
82
- * @version 2.4.7
83
  * @since 2.4.7
84
  */
85
  function add_pdf_invoices_admin_actions( $actions, $the_order ) {
@@ -103,7 +114,7 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
103
  $query_args = array( 'delete_invoice_for_order_id' => $the_order->id, 'invoice_type_id' => $invoice_type['id'] );
104
  $the_url = add_query_arg( $query_args, remove_query_arg( 'create_invoice_for_order_id' ) );
105
  $the_name = __( 'Delete', 'woocommerce-jetpack' ) . ' ' . $invoice_type['title'];
106
- $the_action = 'view ' . $invoice_type['id'] . '_' . 'delete';
107
  $the_action_id = $invoice_type['id'] . '_' . 'delete';
108
  $actions[ $the_action_id ] = array( 'url' => $the_url, 'name' => $the_name, 'action' => $the_action, );
109
  }
@@ -113,7 +124,7 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
113
  $query_args = array( 'create_invoice_for_order_id' => $the_order->id, 'invoice_type_id' => $invoice_type['id'] );
114
  $the_url = add_query_arg( $query_args, remove_query_arg( 'delete_invoice_for_order_id' ) );
115
  $the_name = __( 'Create', 'woocommerce-jetpack' ) . ' ' . $invoice_type['title'];
116
- $the_action = 'view ' . $invoice_type['id'] . '_' . 'create';
117
  $the_action_id = $invoice_type['id'] . '_' . 'create';
118
  $actions[ $the_action_id ] = array( 'url' => $the_url, 'name' => $the_name, 'action' => $the_action, );
119
  }
@@ -138,7 +149,7 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
138
  }
139
 
140
  /**
141
- * Ouput custom columns for products
142
  *
143
  * @param string $column
144
  * @version 2.4.7
@@ -226,8 +237,8 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
226
  /**
227
  * get_settings.
228
  *
229
- * @version 2.4.7
230
- * @todo "edit order" metabox; confirmation on create/delete;
231
  */
232
  function get_settings() {
233
 
@@ -298,6 +309,20 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
298
  'type' => 'checkbox',
299
  ),
300
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
  array(
302
  'title' => __( 'Customer\'s "My Account" Page', 'woocommerce-jetpack' ),
303
  'desc' => __( 'Add link', 'woocommerce-jetpack' ),
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing Display class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
17
  /**
18
  * Constructor.
19
  *
20
+ * @version 2.5.2
21
  */
22
  function __construct() {
23
 
36
  // Action Buttons to Admin's Orders list
37
  add_filter( 'woocommerce_admin_order_actions', array( $this, 'add_pdf_invoices_admin_actions' ), PHP_INT_MAX, 2 );
38
  add_filter( 'admin_head', array( $this, 'add_pdf_invoices_admin_actions_buttons_css' ) );
39
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
40
  }
41
  }
42
 
43
+ /**
44
+ * enqueue_scripts.
45
+ *
46
+ * @version 2.5.2
47
+ * @since 2.5.2
48
+ */
49
+ function enqueue_scripts() {
50
+ wp_enqueue_script( 'wcj-pdf-invoicing', wcj_plugin_url() . '/includes/js/wcj-pdf-invoicing.js', array(), false, true );
51
+ }
52
+
53
  /**
54
  * add_pdf_invoices_admin_actions_buttons_css.
55
  *
56
+ * @version 2.5.2
57
  * @since 2.4.7
58
  */
59
  function add_pdf_invoices_admin_actions_buttons_css() {
80
  echo '.view.' . $invoice_type['id'] . '{ color: ' . $color . ' !important; }' . PHP_EOL;
81
  echo '.view.' . $invoice_type['id'] . '_' . 'create' . '{ color: ' . $color . ' !important; }' . PHP_EOL;
82
  echo '.view.' . $invoice_type['id'] . '_' . 'delete' . '{ color: ' . $color . ' !important; }' . PHP_EOL;
83
+ echo '.view.' . $invoice_type['id'] . '::after { content: "\f159" !important; }' . PHP_EOL;
84
+ echo '.view.' . $invoice_type['id'] . '_' . 'create' . '::after { content: "\f132" !important; }' . PHP_EOL;
85
+ echo '.view.' . $invoice_type['id'] . '_' . 'delete' . '::after { content: "\f460" !important; }' . PHP_EOL;
86
  }
87
  echo '</style>' . PHP_EOL;
88
  }
90
  /**
91
  * add_pdf_invoices_admin_actions.
92
  *
93
+ * @version 2.5.2
94
  * @since 2.4.7
95
  */
96
  function add_pdf_invoices_admin_actions( $actions, $the_order ) {
114
  $query_args = array( 'delete_invoice_for_order_id' => $the_order->id, 'invoice_type_id' => $invoice_type['id'] );
115
  $the_url = add_query_arg( $query_args, remove_query_arg( 'create_invoice_for_order_id' ) );
116
  $the_name = __( 'Delete', 'woocommerce-jetpack' ) . ' ' . $invoice_type['title'];
117
+ $the_action = 'view ' . $invoice_type['id'] . '_' . 'delete' . ( ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_admin_orders_delete_btn_confirm', 'yes' ) ) ? ' wcj_need_confirmation' : '' );
118
  $the_action_id = $invoice_type['id'] . '_' . 'delete';
119
  $actions[ $the_action_id ] = array( 'url' => $the_url, 'name' => $the_name, 'action' => $the_action, );
120
  }
124
  $query_args = array( 'create_invoice_for_order_id' => $the_order->id, 'invoice_type_id' => $invoice_type['id'] );
125
  $the_url = add_query_arg( $query_args, remove_query_arg( 'delete_invoice_for_order_id' ) );
126
  $the_name = __( 'Create', 'woocommerce-jetpack' ) . ' ' . $invoice_type['title'];
127
+ $the_action = 'view ' . $invoice_type['id'] . '_' . 'create' . ( ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_admin_orders_create_btn_confirm', 'yes' ) ) ? ' wcj_need_confirmation' : '' );
128
  $the_action_id = $invoice_type['id'] . '_' . 'create';
129
  $actions[ $the_action_id ] = array( 'url' => $the_url, 'name' => $the_name, 'action' => $the_action, );
130
  }
149
  }
150
 
151
  /**
152
+ * Output custom columns for products
153
  *
154
  * @param string $column
155
  * @version 2.4.7
237
  /**
238
  * get_settings.
239
  *
240
+ * @version 2.5.2
241
+ * @todo "edit order" metabox;
242
  */
243
  function get_settings() {
244
 
309
  'type' => 'checkbox',
310
  ),
311
 
312
+ array(
313
+ 'desc' => __( 'Create Button Requires Confirmation', 'woocommerce-jetpack' ),
314
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_admin_orders_create_btn_confirm',
315
+ 'default' => 'yes',
316
+ 'type' => 'checkbox',
317
+ ),
318
+
319
+ array(
320
+ 'desc' => __( 'Delete Button Requires Confirmation', 'woocommerce-jetpack' ),
321
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_admin_orders_delete_btn_confirm',
322
+ 'default' => 'yes',
323
+ 'type' => 'checkbox',
324
+ ),
325
+
326
  array(
327
  'title' => __( 'Customer\'s "My Account" Page', 'woocommerce-jetpack' ),
328
  'desc' => __( 'Add link', 'woocommerce-jetpack' ),
includes/pdf-invoices/settings/class-wcj-pdf-invoicing-numbering.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack PDF Invoices Numbering class.
6
  *
7
- * @version 2.4.7
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -17,64 +17,67 @@ class WCJ_PDF_Invoicing_Numbering extends WCJ_Module {
17
  /**
18
  * Constructor.
19
  *
20
- * @version 2.3.10
21
  */
22
  public function __construct() {
23
  $this->id = 'pdf_invoicing_numbering';
24
  $this->parent_id = 'pdf_invoicing';
25
  $this->short_desc = __( 'Numbering', 'woocommerce-jetpack' );
26
- $this->desc = '';
27
  parent::__construct( 'submodule' );
28
  }
29
 
30
  /**
31
  * get_settings.
32
  *
33
- * @version 2.4.7
34
  */
35
  function get_settings() {
36
  $settings = array();
37
  $invoice_types = ( 'yes' === get_option( 'wcj_invoicing_hide_disabled_docs_settings', 'no' ) ) ? wcj_get_enabled_invoice_types() : wcj_get_invoice_types();
38
  foreach ( $invoice_types as $invoice_type ) {
39
- $settings[] = array(
40
- 'title' => strtoupper( $invoice_type['desc'] ),
41
- 'type' => 'title',
42
- 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_options',
43
- );
44
- $settings[] = array(
45
- 'title' => __( 'Sequential', 'woocommerce-jetpack' ),
46
- 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_sequential_enabled',
47
- 'default' => 'no',
48
- 'type' => 'checkbox',
49
- );
50
- $settings[] = array(
51
- 'title' => __( 'Counter', 'woocommerce-jetpack' ),
52
- 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_counter',
53
- 'default' => 1,
54
- 'type' => 'number',
55
- );
56
- $settings[] = array(
57
- 'title' => __( 'Prefix', 'woocommerce-jetpack' ),
58
- 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_prefix',
59
- 'default' => '',
60
- 'type' => 'text',
61
- );
62
- $settings[] = array(
63
- 'title' => __( 'Counter Width', 'woocommerce-jetpack' ),
64
- 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_counter_width',
65
- 'default' => 0,
66
- 'type' => 'number',
67
- );
68
- $settings[] = array(
69
- 'title' => __( 'Suffix', 'woocommerce-jetpack' ),
70
- 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_suffix',
71
- 'default' => '',
72
- 'type' => 'text',
73
- );
74
- $settings[] = array(
75
- 'type' => 'sectionend',
76
- 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_options',
77
- );
 
 
 
 
78
  }
79
  return $this->add_standard_settings( $settings );
80
  }
4
  *
5
  * The WooCommerce Jetpack PDF Invoices Numbering class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
17
  /**
18
  * Constructor.
19
  *
20
+ * @version 2.5.2
21
  */
22
  public function __construct() {
23
  $this->id = 'pdf_invoicing_numbering';
24
  $this->parent_id = 'pdf_invoicing';
25
  $this->short_desc = __( 'Numbering', 'woocommerce-jetpack' );
 
26
  parent::__construct( 'submodule' );
27
  }
28
 
29
  /**
30
  * get_settings.
31
  *
32
+ * @version 2.5.2
33
  */
34
  function get_settings() {
35
  $settings = array();
36
  $invoice_types = ( 'yes' === get_option( 'wcj_invoicing_hide_disabled_docs_settings', 'no' ) ) ? wcj_get_enabled_invoice_types() : wcj_get_invoice_types();
37
  foreach ( $invoice_types as $invoice_type ) {
38
+ $settings = array_merge( $settings, array(
39
+ array(
40
+ 'title' => strtoupper( $invoice_type['desc'] ),
41
+ 'type' => 'title',
42
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_options',
43
+ ),
44
+ array(
45
+ 'title' => __( 'Sequential', 'woocommerce-jetpack' ),
46
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_sequential_enabled',
47
+ 'default' => 'no',
48
+ 'type' => 'checkbox',
49
+ ),
50
+ array(
51
+ 'title' => __( 'Counter', 'woocommerce-jetpack' ),
52
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_counter',
53
+ 'default' => 1,
54
+ 'type' => 'number',
55
+ ),
56
+ array(
57
+ 'title' => __( 'Counter Width', 'woocommerce-jetpack' ),
58
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_counter_width',
59
+ 'default' => 0,
60
+ 'type' => 'number',
61
+ ),
62
+ array(
63
+ 'title' => __( 'Prefix', 'woocommerce-jetpack' ),
64
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_prefix',
65
+ 'default' => '',
66
+ 'type' => 'text',
67
+ 'css' => 'width:300px',
68
+ ),
69
+ array(
70
+ 'title' => __( 'Suffix', 'woocommerce-jetpack' ),
71
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_suffix',
72
+ 'default' => '',
73
+ 'type' => 'text',
74
+ 'css' => 'width:300px',
75
+ ),
76
+ array(
77
+ 'type' => 'sectionend',
78
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_options',
79
+ ),
80
+ ) );
81
  }
82
  return $this->add_standard_settings( $settings );
83
  }
includes/pdf-invoices/settings/class-wcj-pdf-invoicing-templates.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack PDF Invoices Templates class.
6
  *
7
- * @version 2.4.7
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -30,7 +30,7 @@ class WCJ_PDF_Invoicing_Templates extends WCJ_Module {
30
  /**
31
  * get_settings.
32
  *
33
- * @version 2.4.7
34
  */
35
  function get_settings() {
36
 
@@ -43,34 +43,41 @@ class WCJ_PDF_Invoicing_Templates extends WCJ_Module {
43
  include( 'defaults/wcj-content-template-' . $invoice_type['id'] . '.php' );
44
  $default_template = ob_get_clean();
45
 
46
- $settings[] = array(
47
- 'title' => strtoupper( $invoice_type['desc'] ),
48
- 'type' => 'title',
49
- 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_templates_options',
50
- );
51
- $settings[] = array(
52
- 'title' => __( 'HTML Template', 'woocommerce-jetpack' ),
53
- 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_template',
54
- 'default' => $default_template,
55
- 'type' => 'textarea',
56
- 'css' => 'width:66%;min-width:300px;height:500px;',
57
- );
58
- $settings[] = array(
59
- 'type' => 'sectionend',
60
- 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_templates_options',
61
- );
 
 
62
  }
63
 
64
- $settings[] = array(
65
- 'title' => __( 'Available Shortcodes', 'woocommerce-jetpack' ),
66
- 'type' => 'title',
67
- 'desc' => wcj_get_shortcodes_list(),
68
- 'id' => 'wcj_invoicing_templates_desc',
69
- );
70
- $settings[] = array(
71
- 'type' => 'sectionend',
72
- 'id' => 'wcj_invoicing_templates_desc',
73
- );
 
 
 
 
 
74
 
75
  return $this->add_standard_settings( $settings );
76
  }
4
  *
5
  * The WooCommerce Jetpack PDF Invoices Templates class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
30
  /**
31
  * get_settings.
32
  *
33
+ * @version 2.5.2
34
  */
35
  function get_settings() {
36
 
43
  include( 'defaults/wcj-content-template-' . $invoice_type['id'] . '.php' );
44
  $default_template = ob_get_clean();
45
 
46
+ $settings = array_merge( $settings, array(
47
+ array(
48
+ 'title' => strtoupper( $invoice_type['desc'] ),
49
+ 'type' => 'title',
50
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_templates_options',
51
+ ),
52
+ array(
53
+ 'title' => __( 'HTML Template', 'woocommerce-jetpack' ),
54
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_template',
55
+ 'default' => $default_template,
56
+ 'type' => 'textarea',
57
+ 'css' => 'width:66%;min-width:300px;height:500px;',
58
+ ),
59
+ array(
60
+ 'type' => 'sectionend',
61
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_templates_options',
62
+ ),
63
+ ) );
64
  }
65
 
66
+ $settings = array_merge( $settings, array(
67
+ array(
68
+ 'title' => __( 'Available Shortcodes', 'woocommerce-jetpack' ),
69
+ 'type' => 'title',
70
+ 'desc' => sprintf(
71
+ __( 'For the list of available shortcodes, please visit %s.', 'woocommerce-jetpack' ),
72
+ '<a target="_blank" href="http://booster.io/category/shortcodes/?utm_source=shortcodes_list&utm_medium=module_button&utm_campaign=booster_documentation">http://booster.io/category/shortcodes/</a>'
73
+ ),
74
+ 'id' => 'wcj_invoicing_templates_desc',
75
+ ),
76
+ array(
77
+ 'type' => 'sectionend',
78
+ 'id' => 'wcj_invoicing_templates_desc',
79
+ ),
80
+ ) );
81
 
82
  return $this->add_standard_settings( $settings );
83
  }
includes/price-by-country/class-wcj-price-by-country-core.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Price by Country Core class.
6
  *
7
- * @version 2.5.1
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -143,10 +143,15 @@ class WCJ_Price_by_Country_Core {
143
  /**
144
  * get_customer_country_group_id.
145
  *
146
- * @version 2.5.0
147
  */
148
  public function get_customer_country_group_id() {
149
 
 
 
 
 
 
150
  // We already know the group - nothing to calculate - return group
151
  if ( null != $this->customer_country_group_id && $this->customer_country_group_id > 0 ) {
152
  return $this->customer_country_group_id;
4
  *
5
  * The WooCommerce Jetpack Price by Country Core class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
143
  /**
144
  * get_customer_country_group_id.
145
  *
146
+ * @version 2.5.2
147
  */
148
  public function get_customer_country_group_id() {
149
 
150
+ if ( 'yes' === get_option( 'wcj_price_by_country_revert', 'no' ) && is_checkout() ) {
151
+ $this->customer_country_group_id = -1;
152
+ return null;
153
+ }
154
+
155
  // We already know the group - nothing to calculate - return group
156
  if ( null != $this->customer_country_group_id && $this->customer_country_group_id > 0 ) {
157
  return $this->customer_country_group_id;
includes/reports/class-wcj-currency-reports.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Currency Reports class.
6
  *
7
- * @version 2.4.8
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -26,7 +26,7 @@ class WCJ_Currency_Reports {
26
  /**
27
  * add_reports_currency_to_admin_bar.
28
  *
29
- * @version 2.4.8
30
  */
31
  function add_reports_currency_to_admin_bar( $wp_admin_bar ) {
32
 
@@ -58,12 +58,12 @@ class WCJ_Currency_Reports {
58
  $currency_symbols[ $the_code ] = $the_code;
59
  }
60
  }
61
- if ( wcj_is_module_enabled( 'multicurrency_base_price' ) ) {
62
  for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_multicurrency_base_price_total_number', 1 ) ); $i++ ) {
63
  $the_code = get_option( 'wcj_multicurrency_base_price_currency_' . $i );
64
  $currency_symbols[ $the_code ] = $the_code;
65
  }
66
- }
67
  if ( wcj_is_module_enabled( 'payment_gateways_currency' ) ) {
68
  global $woocommerce;
69
  $available_gateways = $woocommerce->payment_gateways->payment_gateways();
4
  *
5
  * The WooCommerce Jetpack Currency Reports class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
26
  /**
27
  * add_reports_currency_to_admin_bar.
28
  *
29
+ * @version 2.5.2
30
  */
31
  function add_reports_currency_to_admin_bar( $wp_admin_bar ) {
32
 
58
  $currency_symbols[ $the_code ] = $the_code;
59
  }
60
  }
61
+ /* if ( wcj_is_module_enabled( 'multicurrency_base_price' ) ) {
62
  for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_multicurrency_base_price_total_number', 1 ) ); $i++ ) {
63
  $the_code = get_option( 'wcj_multicurrency_base_price_currency_' . $i );
64
  $currency_symbols[ $the_code ] = $the_code;
65
  }
66
+ } */
67
  if ( wcj_is_module_enabled( 'payment_gateways_currency' ) ) {
68
  global $woocommerce;
69
  $available_gateways = $woocommerce->payment_gateways->payment_gateways();
includes/shipping/class-wc-shipping-wcj-custom.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Custom Shipping class.
6
  *
7
- * @version 2.4.8
8
  * @since 2.4.8
9
  * @author Algoritmika Ltd.
10
  */
@@ -31,8 +31,9 @@ if ( ! function_exists( 'init_wc_shipping_wcj_custom_class' ) ) {
31
  /**
32
  * Init settings
33
  *
34
- * @access public
35
- * @return void
 
36
  */
37
  function init( $id_count ) {
38
 
@@ -49,6 +50,13 @@ if ( ! function_exists( 'init_wc_shipping_wcj_custom_class' ) ) {
49
  $this->title = $this->get_option( 'title' );
50
  $this->cost = $this->get_option( 'cost' );
51
  $this->type = $this->get_option( 'type' );
 
 
 
 
 
 
 
52
 
53
  // Save settings in admin
54
  add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) );
@@ -56,6 +64,8 @@ if ( ! function_exists( 'init_wc_shipping_wcj_custom_class' ) ) {
56
 
57
  /**
58
  * Initialise Settings Form Fields
 
 
59
  */
60
  function init_form_fields() {
61
  $this->form_fields = array(
@@ -79,9 +89,10 @@ if ( ! function_exists( 'init_wc_shipping_wcj_custom_class' ) ) {
79
  'default' => 'flat_rate',
80
  'desc_tip' => true,
81
  'options' => array(
82
- 'flat_rate' => __( 'Flat Rate', 'woocommerce-jetpack' ),
83
- 'by_total_cart_weight' => __( 'By Total Cart Weight', 'woocommerce-jetpack' ),
84
- 'by_total_cart_quantity' => __( 'By Total Cart Quantity', 'woocommerce-jetpack' ),
 
85
  ),
86
  ),
87
  'cost' => array(
@@ -92,15 +103,63 @@ if ( ! function_exists( 'init_wc_shipping_wcj_custom_class' ) ) {
92
  'desc_tip' => true,
93
  'custom_attributes' => array( 'step' => '0.000001', 'min' => '0', ),
94
  ),
 
 
 
 
 
 
 
 
95
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  }
97
 
98
  /**
99
  * calculate_shipping function.
100
  *
101
- * @access public
102
- * @param mixed $package
103
- * @return void
 
104
  */
105
  function calculate_shipping( $package ) {
106
  switch ( $this->type ) {
@@ -114,6 +173,9 @@ if ( ! function_exists( 'init_wc_shipping_wcj_custom_class' ) ) {
114
  case 'by_total_cart_weight':
115
  $cost = $this->cost * WC()->cart->get_cart_contents_weight();
116
  break;
 
 
 
117
  default: // 'flat_rate'
118
  $cost = $this->cost;
119
  break;
4
  *
5
  * The WooCommerce Jetpack Custom Shipping class.
6
  *
7
+ * @version 2.5.2
8
  * @since 2.4.8
9
  * @author Algoritmika Ltd.
10
  */
31
  /**
32
  * Init settings
33
  *
34
+ * @version 2.5.2
35
+ * @access public
36
+ * @return void
37
  */
38
  function init( $id_count ) {
39
 
50
  $this->title = $this->get_option( 'title' );
51
  $this->cost = $this->get_option( 'cost' );
52
  $this->type = $this->get_option( 'type' );
53
+ $this->weight_table_total_rows = $this->get_option( 'weight_table_total_rows' );
54
+ for ( $i = 1; $i <= $this->weight_table_total_rows; $i++ ) {
55
+ $option_name = 'weight_table_weight_row_' . $i;
56
+ $this->$option_name = $this->get_option( $option_name );
57
+ $option_name = 'weight_table_cost_row_' . $i;
58
+ $this->$option_name = $this->get_option( $option_name );
59
+ }
60
 
61
  // Save settings in admin
62
  add_action( 'woocommerce_update_options_shipping_' . $this->id, array( $this, 'process_admin_options' ) );
64
 
65
  /**
66
  * Initialise Settings Form Fields
67
+ *
68
+ * @version 2.5.2
69
  */
70
  function init_form_fields() {
71
  $this->form_fields = array(
89
  'default' => 'flat_rate',
90
  'desc_tip' => true,
91
  'options' => array(
92
+ 'flat_rate' => __( 'Flat Rate', 'woocommerce-jetpack' ),
93
+ 'by_total_cart_weight' => __( 'By Total Cart Weight', 'woocommerce-jetpack' ),
94
+ 'by_total_cart_weight_table' => __( 'By Total Cart Weight Table', 'woocommerce-jetpack' ),
95
+ 'by_total_cart_quantity' => __( 'By Total Cart Quantity', 'woocommerce-jetpack' ),
96
  ),
97
  ),
98
  'cost' => array(
103
  'desc_tip' => true,
104
  'custom_attributes' => array( 'step' => '0.000001', 'min' => '0', ),
105
  ),
106
+ 'weight_table_total_rows' => array(
107
+ 'title' => __( 'Weight Table Total Rows', 'woocommerce' ),
108
+ 'type' => 'number',
109
+ 'description' => __( 'Press Save changes after you change this number.', 'woocommerce-jetpack' ),
110
+ 'default' => 0,
111
+ 'desc_tip' => true,
112
+ 'custom_attributes' => array( 'min' => '0', ),
113
+ ),
114
  );
115
+ for ( $i = 1; $i <= $this->get_option( 'weight_table_total_rows' ); $i++ ) {
116
+ $this->form_fields = array_merge( $this->form_fields, array(
117
+ 'weight_table_weight_row_' . $i => array(
118
+ 'title' => __( 'Max Weight', 'woocommerce' ) . ' #' . $i,
119
+ 'type' => 'number',
120
+ 'default' => 0,
121
+ 'desc_tip' => true,
122
+ 'custom_attributes' => array( 'step' => '0.000001', 'min' => '0', ),
123
+ ),
124
+ 'weight_table_cost_row_' . $i => array(
125
+ 'title' => __( 'Cost', 'woocommerce' ) . ' #' . $i,
126
+ 'type' => 'number',
127
+ 'default' => 0,
128
+ 'desc_tip' => true,
129
+ 'custom_attributes' => array( 'step' => '0.000001', 'min' => '0', ),
130
+ ),
131
+ ) );
132
+ }
133
+ }
134
+
135
+ /**
136
+ * calculate_shipping_by_weight_table.
137
+ *
138
+ * @version 2.5.2
139
+ * @since 2.5.2
140
+ */
141
+ function calculate_shipping_by_weight_table( $weight ) {
142
+ if ( 0 == $this->weight_table_total_rows ) {
143
+ return $this->cost * $weight; // fallback
144
+ }
145
+ $option_name_weight = $option_name_cost = '';
146
+ for ( $i = 1; $i <= $this->weight_table_total_rows; $i++ ) {
147
+ $option_name_weight = 'weight_table_weight_row_' . $i;
148
+ $option_name_cost = 'weight_table_cost_row_' . $i;
149
+ if ( $weight <= $this->$option_name_weight ) {
150
+ return $this->$option_name_cost;
151
+ }
152
+ }
153
+ return $this->$option_name_cost; // fallback - last row
154
  }
155
 
156
  /**
157
  * calculate_shipping function.
158
  *
159
+ * @version 2.5.2
160
+ * @access public
161
+ * @param mixed $package
162
+ * @return void
163
  */
164
  function calculate_shipping( $package ) {
165
  switch ( $this->type ) {
173
  case 'by_total_cart_weight':
174
  $cost = $this->cost * WC()->cart->get_cart_contents_weight();
175
  break;
176
+ case 'by_total_cart_weight_table':
177
+ $cost = $this->calculate_shipping_by_weight_table( WC()->cart->get_cart_contents_weight() );
178
+ break;
179
  default: // 'flat_rate'
180
  $cost = $this->cost;
181
  break;
includes/shortcodes/class-wcj-general-shortcodes.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack General Shortcodes class.
6
  *
7
- * @version 2.5.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -38,7 +38,7 @@ class WCJ_General_Shortcodes extends WCJ_Shortcodes {
38
  );
39
 
40
  $this->the_atts = array(
41
- 'date_format' => get_option( 'date_format' ),
42
  'lang' => '',
43
  'form_method' => 'post',//'get',
44
  'class' => '',
@@ -81,7 +81,7 @@ class WCJ_General_Shortcodes extends WCJ_Shortcodes {
81
  /**
82
  * wcj_wholesale_price_table (global only).
83
  *
84
- * @version 2.5.0
85
  * @since 2.4.8
86
  */
87
  function wcj_wholesale_price_table( $atts ) {
@@ -108,7 +108,7 @@ class WCJ_General_Shortcodes extends WCJ_Shortcodes {
108
  }
109
 
110
  $table_rows = array( $data_qty, $data_discount, );
111
- return wcj_get_table_html( $table_rows, array( 'columns_styles' => $columns_styles ) );
112
  }
113
 
114
  /**
4
  *
5
  * The WooCommerce Jetpack General Shortcodes class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
38
  );
39
 
40
  $this->the_atts = array(
41
+ 'date_format' => get_option( 'date_format' ),
42
  'lang' => '',
43
  'form_method' => 'post',//'get',
44
  'class' => '',
81
  /**
82
  * wcj_wholesale_price_table (global only).
83
  *
84
+ * @version 2.5.2
85
  * @since 2.4.8
86
  */
87
  function wcj_wholesale_price_table( $atts ) {
108
  }
109
 
110
  $table_rows = array( $data_qty, $data_discount, );
111
+ return wcj_get_table_html( $table_rows, array( 'table_class' => 'wcj_wholesale_price_table', 'columns_styles' => $columns_styles ) );
112
  }
113
 
114
  /**
includes/shortcodes/class-wcj-input-field-shortcodes.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Jetpack Input Field Shortcodes
4
+ *
5
+ * The WooCommerce Jetpack Input Field Shortcodes class.
6
+ *
7
+ * @version 2.5.2
8
+ * @since 2.5.2
9
+ * @author Algoritmika Ltd.
10
+ */
11
+
12
+ if ( ! defined( 'ABSPATH' ) ) exit;
13
+
14
+ if ( ! class_exists( 'WCJ_Input_Field_Shortcodes' ) ) :
15
+
16
+ class WCJ_Input_Field_Shortcodes extends WCJ_Shortcodes {
17
+
18
+ /**
19
+ * Constructor.
20
+ *
21
+ * @version 2.5.2
22
+ * @since 2.5.2
23
+ */
24
+ function __construct() {
25
+
26
+ $this->the_shortcodes = array(
27
+ 'wcj_input_field',
28
+ );
29
+
30
+ $this->the_atts = array(
31
+ 'type' => 'text',
32
+ 'class' => '',
33
+ 'value' => '',
34
+ 'placeholder' => '',
35
+ 'name' => '',
36
+ 'attach_to' => '',
37
+ 'label' => '',
38
+ );
39
+
40
+ parent::__construct();
41
+
42
+ }
43
+
44
+ /**
45
+ * wcj_input_field.
46
+ *
47
+ * @version 2.5.2
48
+ * @since 2.5.2
49
+ */
50
+ function wcj_input_field( $atts, $content ) {
51
+ if ( '' == $atts['name'] ) {
52
+ return __( 'Attribute "name" is required!', 'woocommerce-jetpack' );
53
+ }
54
+ $the_field = '';
55
+ $the_field .= '<input' .
56
+ ' type="' . $atts['type'] . '"' .
57
+ ' class="' . $atts['class'] . '"' .
58
+ ' value="' . $atts['value'] . '"' .
59
+ ' placeholder="' . $atts['placeholder'] . '"' .
60
+ ' name="wcj_input_field_' . $atts['name'] . '"' .
61
+ ' id="wcj_input_field_' . $atts['name'] . '">';
62
+ if ( '' != $atts['attach_to'] ) {
63
+ $the_field .= '<input type="hidden" name="for_wcj_input_field_' . $atts['name'] . '" value="' . $atts['attach_to'] . '">';
64
+ }
65
+ if ( '' != $atts['label'] ) {
66
+ $the_field .= '<input type="hidden" name="label_for_wcj_input_field_' . $atts['name'] . '" value="' . $atts['label'] . '">';
67
+ }
68
+ return $the_field;
69
+ }
70
+
71
+ }
72
+
73
+ endif;
74
+
75
+ return new WCJ_Input_Field_Shortcodes();
includes/shortcodes/class-wcj-orders-shortcodes.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Orders Shortcodes class.
6
  *
7
- * @version 2.5.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -146,19 +146,20 @@ class WCJ_Orders_Shortcodes extends WCJ_Shortcodes {
146
  /**
147
  * wcj_order_total_fees_tax.
148
  *
149
- * @version 2.4.8
150
  * @since 2.4.8
151
  */
152
  function wcj_order_total_fees_tax( $atts ) {
153
  $total_fees_tax = 0;
154
  $the_fees = $this->the_order->get_fees();
155
  foreach ( $the_fees as $the_fee ) {
156
- $taxes = maybe_unserialize( $the_fee['line_tax_data'] );
157
  if ( ! empty( $taxes ) && is_array( $taxes ) && isset( $taxes['total'] ) && is_array( $taxes['total'] ) ) {
158
  foreach ( $taxes['total'] as $tax ) {
159
  $total_fees_tax += $tax;
160
  }
161
- }
 
162
  }
163
  return $this->wcj_price_shortcode( $total_fees_tax, $atts );
164
  }
@@ -166,20 +167,22 @@ class WCJ_Orders_Shortcodes extends WCJ_Shortcodes {
166
  /**
167
  * wcj_order_total_fees_incl_tax.
168
  *
169
- * @version 2.4.8
170
  * @since 2.4.8
 
171
  */
172
  function wcj_order_total_fees_incl_tax( $atts ) {
173
  $total_fees = 0;
174
  $the_fees = $this->the_order->get_fees();
175
  foreach ( $the_fees as $the_fee ) {
176
  $total_fees += $the_fee['line_total'];
177
- $taxes = maybe_unserialize( $the_fee['line_tax_data'] );
178
  if ( ! empty( $taxes ) && is_array( $taxes ) && isset( $taxes['total'] ) && is_array( $taxes['total'] ) ) {
179
  foreach ( $taxes['total'] as $tax ) {
180
  $total_fees += $tax;
181
  }
182
- }
 
183
  }
184
  return $this->wcj_price_shortcode( $total_fees, $atts );
185
  }
4
  *
5
  * The WooCommerce Jetpack Orders Shortcodes class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
146
  /**
147
  * wcj_order_total_fees_tax.
148
  *
149
+ * @version 2.5.2
150
  * @since 2.4.8
151
  */
152
  function wcj_order_total_fees_tax( $atts ) {
153
  $total_fees_tax = 0;
154
  $the_fees = $this->the_order->get_fees();
155
  foreach ( $the_fees as $the_fee ) {
156
+ /* $taxes = maybe_unserialize( $the_fee['line_tax_data'] );
157
  if ( ! empty( $taxes ) && is_array( $taxes ) && isset( $taxes['total'] ) && is_array( $taxes['total'] ) ) {
158
  foreach ( $taxes['total'] as $tax ) {
159
  $total_fees_tax += $tax;
160
  }
161
+ } */
162
+ $total_fees_tax += $this->the_order->get_line_tax( $the_fee );
163
  }
164
  return $this->wcj_price_shortcode( $total_fees_tax, $atts );
165
  }
167
  /**
168
  * wcj_order_total_fees_incl_tax.
169
  *
170
+ * @version 2.5.2
171
  * @since 2.4.8
172
+ * @todo probably should use get_line_total
173
  */
174
  function wcj_order_total_fees_incl_tax( $atts ) {
175
  $total_fees = 0;
176
  $the_fees = $this->the_order->get_fees();
177
  foreach ( $the_fees as $the_fee ) {
178
  $total_fees += $the_fee['line_total'];
179
+ /* $taxes = maybe_unserialize( $the_fee['line_tax_data'] );
180
  if ( ! empty( $taxes ) && is_array( $taxes ) && isset( $taxes['total'] ) && is_array( $taxes['total'] ) ) {
181
  foreach ( $taxes['total'] as $tax ) {
182
  $total_fees += $tax;
183
  }
184
+ } */
185
+ $total_fees += $this->the_order->get_line_tax( $the_fee );
186
  }
187
  return $this->wcj_price_shortcode( $total_fees, $atts );
188
  }
includes/shortcodes/class-wcj-products-add-form-shortcodes.php CHANGED
@@ -4,9 +4,10 @@
4
  *
5
  * The WooCommerce Jetpack Products Add Form Shortcodes class.
6
  *
7
- * @version 2.5.0
8
  * @since 2.5.0
9
  * @author Algoritmika Ltd.
 
10
  */
11
 
12
  if ( ! defined( 'ABSPATH' ) ) exit;
@@ -18,7 +19,7 @@ class WCJ_Products_Add_Form_Shortcodes extends WCJ_Shortcodes {
18
  /**
19
  * Constructor.
20
  *
21
- * @version 2.5.0
22
  * @since 2.5.0
23
  */
24
  function __construct() {
@@ -28,72 +29,148 @@ class WCJ_Products_Add_Form_Shortcodes extends WCJ_Shortcodes {
28
  );
29
 
30
  $this->the_atts = array(
31
- 'product_id' => 0, // todo (for editing?)
32
- 'post_status' => 'publish', // todo (for editing?)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  );
34
 
35
  parent::__construct();
36
  }
37
 
38
- /**
39
- * Inits shortcode atts and properties.
40
- *
41
- * @version 2.5.0
42
- * @since 2.5.0
43
- */
44
- function init_atts( $atts ) {
45
- return $atts;
46
- }
47
-
48
  /**
49
  * wc_add_new_product.
50
  *
51
- * @version 2.5.0
52
  * @since 2.5.0
53
  */
54
  function wc_add_new_product( $args, $shortcode_atts ) {
55
 
56
- $new_product_post = array(
57
  'post_title' => $args['title'],
58
- 'post_content' => $args['description'],
59
- 'post_excerpt' => $args['short_description'],
60
  'post_type' => 'product',
61
  'post_status' => 'draft',
62
  );
63
 
 
 
 
 
 
 
 
64
  // Insert the post into the database
65
- if ( 0 != ( $new_product_id = wp_insert_post( $new_product_post ) ) ) {
66
 
67
- wp_set_object_terms( $new_product_id, 'simple', 'product_type' );
68
- wp_set_object_terms( $new_product_id, $args['cats'], 'product_cat' );
69
- wp_set_object_terms( $new_product_id, $args['tags'], 'product_tag' );
 
 
 
 
 
 
 
 
 
 
70
 
71
- update_post_meta( $new_product_id, '_visibility', 'visible' );
72
- update_post_meta( $new_product_id, '_stock_status', 'instock' );
 
 
 
 
73
 
74
- wp_update_post( array( 'ID' => $new_product_id, 'post_status' => $shortcode_atts['post_status'] ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
76
 
77
- return $new_product_id;
78
  }
79
 
80
  /**
81
  * validate_args.
82
  *
83
- * @version 2.5.0
84
  * @since 2.5.0
85
  */
86
  function validate_args( $args, $shortcode_atts ) {
 
87
  if ( '' == $args['title'] ) {
88
- return false;
89
  }
90
- return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  }
92
 
93
  /**
94
  * wcj_product_add_new.
95
  *
96
- * @version 2.5.0
97
  * @since 2.5.0
98
  */
99
  function wcj_product_add_new( $atts ) {
@@ -105,60 +182,142 @@ class WCJ_Products_Add_Form_Shortcodes extends WCJ_Shortcodes {
105
 
106
  if ( isset( $_REQUEST['wcj_add_new_product'] ) ) {
107
  $args = array(
108
- 'title' => $_REQUEST['wcj_add_new_product_title'],
109
- 'description' => $_REQUEST['wcj_add_new_product_desc'],
110
- 'short_description' => $_REQUEST['wcj_add_new_product_short_desc'],
111
- 'cats' => isset( $_REQUEST['wcj_add_new_product_cats'] ) ? $_REQUEST['wcj_add_new_product_cats'] : array(),
112
- 'tags' => isset( $_REQUEST['wcj_add_new_product_tags'] ) ? $_REQUEST['wcj_add_new_product_tags'] : array(),
 
 
 
113
  );
114
- if ( $this->validate_args( $args, $atts ) ) {
115
  $result = $this->wc_add_new_product( $args, $atts );
116
  $notice_html .= ( 0 == $result )
117
  ? '<div class="woocommerce"><ul class="woocommerce-error"><li>' . __( 'Error!', 'woocommerce-jetpack' ) . '</li></ul></div>'
118
  : '<div class="woocommerce"><div class="woocommerce-message">' . __( 'Success!', 'woocommerce-jetpack' ) . '</div></div>';
119
  } else {
120
- $notice_html .= '<div class="woocommerce"><ul class="woocommerce-error"><li>' . __( 'Error Validating!', 'woocommerce-jetpack' ) . '</li></ul></div>';
 
 
 
 
 
 
 
 
 
 
 
 
121
  }
122
  }
123
 
124
- $header_html .= '<h3>' . __( 'Add New Product', 'woocommerce-jetpack' ) . '</h3>';
125
- $header_html .= '<form method="post" action="">';
 
 
 
 
126
 
127
  $table_data = array();
128
  $input_style = 'width:100%;';
129
  $table_data[] = array(
130
- __( 'Title', 'woocommerce-jetpack' ),
131
- '<input type="text" style="' . $input_style . '" name="wcj_add_new_product_title">'
132
- );
133
- $table_data[] = array(
134
- __( 'Description', 'woocommerce-jetpack' ),
135
- '<textarea style="' . $input_style . '" name="wcj_add_new_product_desc"></textarea>'
136
  );
137
- $table_data[] = array(
138
- __( 'Short Description', 'woocommerce-jetpack' ),
139
- '<textarea style="' . $input_style . '" name="wcj_add_new_product_short_desc"></textarea>'
140
- );
141
- $product_categories = get_terms( 'product_cat', 'orderby=name&hide_empty=0' );
142
- $product_categories_as_select_options = '';
143
- foreach ( $product_categories as $product_category ) {
144
- $product_categories_as_select_options .= '<option value="' . $product_category->slug . '">' . $product_category->name .'</option>';
145
  }
146
- $table_data[] = array(
147
- __( 'Categories', 'woocommerce-jetpack' ),
148
- '<select multiple style="' . $input_style . '" name="wcj_add_new_product_cats[]">' . $product_categories_as_select_options . '</select>'
149
- );
150
- $products_tags = get_terms( 'product_tag', 'orderby=name&hide_empty=0' );
151
- $products_tags_as_select_options = '';
152
- foreach ( $products_tags as $products_tag ) {
153
- $products_tags_as_select_options .= '<option value="' . $products_tag->slug . '">' . $products_tag->name .'</option>';
154
  }
155
- $table_data[] = array(
156
- __( 'Tags', 'woocommerce-jetpack' ),
157
- '<select multiple style="' . $input_style . '" name="wcj_add_new_product_tags[]">' . $products_tags_as_select_options . '</select>'
158
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  $input_fields_html .= wcj_get_table_html( $table_data, array( 'table_class' => 'widefat', 'table_heading_type' => 'vertical', ) );
160
 
161
- $footer_html .= '<input type="submit" class="button" name="wcj_add_new_product" value="' . __( 'Add', 'woocommerce-jetpack' ) . '">';
162
  $footer_html .= '</form>';
163
 
164
  return $notice_html . $header_html . $input_fields_html . $footer_html;
4
  *
5
  * The WooCommerce Jetpack Products Add Form Shortcodes class.
6
  *
7
+ * @version 2.5.2
8
  * @since 2.5.0
9
  * @author Algoritmika Ltd.
10
+ * @todo refill on not validated; titles and messages; fields ids and label tags; other styling; custom fields;
11
  */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) exit;
19
  /**
20
  * Constructor.
21
  *
22
+ * @version 2.5.2
23
  * @since 2.5.0
24
  */
25
  function __construct() {
29
  );
30
 
31
  $this->the_atts = array(
32
+ 'product_id' => /* ( isset( $_GET['wcj_edit_product'] ) ) ? $_GET['wcj_edit_product'] : */ 0, // todo?
33
+ 'post_status' => get_option( 'wcj_product_by_user_status', 'draft' ),
34
+
35
+ 'desc_enabled' => get_option( 'wcj_product_by_user_desc_enabled', 'no' ),
36
+ 'short_desc_enabled' => get_option( 'wcj_product_by_user_short_desc_enabled', 'no' ),
37
+ 'regular_price_enabled' => get_option( 'wcj_product_by_user_regular_price_enabled', 'no' ),
38
+ 'sale_price_enabled' => get_option( 'wcj_product_by_user_sale_price_enabled', 'no' ),
39
+ 'cats_enabled' => get_option( 'wcj_product_by_user_cats_enabled', 'no' ),
40
+ 'tags_enabled' => get_option( 'wcj_product_by_user_tags_enabled', 'no' ),
41
+ 'image_enabled' => apply_filters( 'wcj_get_option_filter', 'no', get_option( 'wcj_product_by_user_image_enabled', 'no' ) ),
42
+
43
+ 'desc_required' => get_option( 'wcj_product_by_user_desc_required', 'no' ),
44
+ 'short_desc_required' => get_option( 'wcj_product_by_user_short_desc_required', 'no' ),
45
+ 'regular_price_required' => get_option( 'wcj_product_by_user_regular_price_required', 'no' ),
46
+ 'sale_price_required' => get_option( 'wcj_product_by_user_sale_price_required', 'no' ),
47
+ 'cats_required' => get_option( 'wcj_product_by_user_cats_required', 'no' ),
48
+ 'tags_required' => get_option( 'wcj_product_by_user_tags_required', 'no' ),
49
+ 'image_required' => apply_filters( 'wcj_get_option_filter', 'no', get_option( 'wcj_product_by_user_image_required', 'no' ) ),
50
+
51
+ 'visibility' => implode( ',', get_option( 'wcj_product_by_user_user_visibility', array() ) ),
52
+ 'module' => 'product_by_user',
53
+ 'module_name' => __( 'Product by User', 'woocommerce-jetpack' ),
54
  );
55
 
56
  parent::__construct();
57
  }
58
 
 
 
 
 
 
 
 
 
 
 
59
  /**
60
  * wc_add_new_product.
61
  *
62
+ * @version 2.5.2
63
  * @since 2.5.0
64
  */
65
  function wc_add_new_product( $args, $shortcode_atts ) {
66
 
67
+ $product_post = array(
68
  'post_title' => $args['title'],
69
+ 'post_content' => $args['desc'],
70
+ 'post_excerpt' => $args['short_desc'],
71
  'post_type' => 'product',
72
  'post_status' => 'draft',
73
  );
74
 
75
+ if ( 0 == $shortcode_atts['product_id'] ) {
76
+ $product_id = wp_insert_post( $product_post );
77
+ } else {
78
+ $product_id = $shortcode_atts['product_id'];
79
+ wp_update_post( array_merge( array( 'ID' => $product_id ), $product_post ) );
80
+ }
81
+
82
  // Insert the post into the database
83
+ if ( 0 != $product_id ) {
84
 
85
+ wp_set_object_terms( $product_id, 'simple', 'product_type' );
86
+ wp_set_object_terms( $product_id, $args['cats'], 'product_cat' );
87
+ wp_set_object_terms( $product_id, $args['tags'], 'product_tag' );
88
+
89
+ update_post_meta( $product_id, '_regular_price', $args['regular_price'] );
90
+ update_post_meta( $product_id, '_sale_price', $args['sale_price'] );
91
+ if ( '' == $args['sale_price'] ) {
92
+ update_post_meta( $product_id, '_price', $args['regular_price'] );
93
+ } else {
94
+ update_post_meta( $product_id, '_price', $args['sale_price'] );
95
+ }
96
+ update_post_meta( $product_id, '_visibility', 'visible' );
97
+ update_post_meta( $product_id, '_stock_status', 'instock' );
98
 
99
+ // Image
100
+ if ( '' != $args['image'] && '' != $args['image']['tmp_name'] ) {
101
+ $upload_dir = wp_upload_dir();
102
+ $filename = $args['image']['name'];
103
+ $file = ( wp_mkdir_p( $upload_dir['path'] ) ) ? $upload_dir['path'] : $upload_dir['basedir'];
104
+ $file .= '/' . $filename;
105
 
106
+ move_uploaded_file( $args['image']['tmp_name'], $file );
107
+
108
+ $wp_filetype = wp_check_filetype( $filename, null );
109
+ $attachment = array(
110
+ 'post_mime_type' => $wp_filetype['type'],
111
+ 'post_title' => sanitize_file_name( $filename ),
112
+ 'post_content' => '',
113
+ 'post_status' => 'inherit'
114
+ );
115
+ $attach_id = wp_insert_attachment( $attachment, $file, $product_id );
116
+ require_once( ABSPATH . 'wp-admin/includes/image.php' );
117
+ $attach_data = wp_generate_attachment_metadata( $attach_id, $file );
118
+ wp_update_attachment_metadata( $attach_id, $attach_data );
119
+
120
+ set_post_thumbnail( $product_id, $attach_id );
121
+ }
122
+
123
+ wp_update_post( array( 'ID' => $product_id, 'post_status' => $shortcode_atts['post_status'] ) );
124
  }
125
 
126
+ return $product_id;
127
  }
128
 
129
  /**
130
  * validate_args.
131
  *
132
+ * @version 2.5.2
133
  * @since 2.5.0
134
  */
135
  function validate_args( $args, $shortcode_atts ) {
136
+ $errors = '';
137
  if ( '' == $args['title'] ) {
138
+ $errors .= '<li>' . __( 'Title is required!', 'woocommerce-jetpack' ) . '</li>';
139
  }
140
+
141
+ $fields = array(
142
+ 'desc' => __( 'Description', 'woocommerce-jetpack' ),
143
+ 'short_desc' => __( 'Short Description', 'woocommerce-jetpack' ),
144
+ 'image' => __( 'Image', 'woocommerce-jetpack' ),
145
+ 'regular_price' => __( 'Regular Price', 'woocommerce-jetpack' ),
146
+ 'sale_price' => __( 'Sale Price', 'woocommerce-jetpack' ),
147
+ 'cats' => __( 'Categories', 'woocommerce-jetpack' ),
148
+ 'tags' => __( 'Tags', 'woocommerce-jetpack' ),
149
+ );
150
+ foreach ( $fields as $field_id => $field_desc ) {
151
+ if ( 'yes' === $shortcode_atts[ $field_id . '_enabled' ] && 'yes' === $shortcode_atts[ $field_id . '_required' ] ) {
152
+ $is_missing = false;
153
+ if ( 'image' === $field_id && ( '' == $args[ $field_id ] || ! isset( $args[ $field_id ]['tmp_name'] ) || '' == $args[ $field_id ]['tmp_name'] ) ) {
154
+ $is_missing = true;
155
+ } elseif ( empty( $args[ $field_id ] ) ) {
156
+ $is_missing = true;
157
+ }
158
+ if ( $is_missing ) {
159
+ $errors .= '<li>' . sprintf( __( '%s is required!', 'woocommerce-jetpack' ), $field_desc ) . '</li>';
160
+ }
161
+ }
162
+ }
163
+
164
+ if ( $args['sale_price'] > $args['regular_price'] ) {
165
+ $errors .= '<li>' . __( 'Sale price must be less than the regular price!', 'woocommerce-jetpack' ) . '</li>';
166
+ }
167
+ return ( '' === $errors ) ? true : $errors;
168
  }
169
 
170
  /**
171
  * wcj_product_add_new.
172
  *
173
+ * @version 2.5.2
174
  * @since 2.5.0
175
  */
176
  function wcj_product_add_new( $atts ) {
182
 
183
  if ( isset( $_REQUEST['wcj_add_new_product'] ) ) {
184
  $args = array(
185
+ 'title' => isset( $_REQUEST['wcj_add_new_product_title'] ) ? $_REQUEST['wcj_add_new_product_title'] : '',
186
+ 'desc' => isset( $_REQUEST['wcj_add_new_product_desc'] ) ? $_REQUEST['wcj_add_new_product_desc'] : '',
187
+ 'short_desc' => isset( $_REQUEST['wcj_add_new_product_short_desc'] ) ? $_REQUEST['wcj_add_new_product_short_desc'] : '',
188
+ 'regular_price' => isset( $_REQUEST['wcj_add_new_product_regular_price'] ) ? $_REQUEST['wcj_add_new_product_regular_price'] : '',
189
+ 'sale_price' => isset( $_REQUEST['wcj_add_new_product_sale_price'] ) ? $_REQUEST['wcj_add_new_product_sale_price'] : '',
190
+ 'cats' => isset( $_REQUEST['wcj_add_new_product_cats'] ) ? $_REQUEST['wcj_add_new_product_cats'] : array(),
191
+ 'tags' => isset( $_REQUEST['wcj_add_new_product_tags'] ) ? $_REQUEST['wcj_add_new_product_tags'] : array(),
192
+ 'image' => isset( $_FILES['wcj_add_new_product_image'] ) ? $_FILES['wcj_add_new_product_image'] : '',
193
  );
194
+ if ( true === ( $validate_args = $this->validate_args( $args, $atts ) ) ) {
195
  $result = $this->wc_add_new_product( $args, $atts );
196
  $notice_html .= ( 0 == $result )
197
  ? '<div class="woocommerce"><ul class="woocommerce-error"><li>' . __( 'Error!', 'woocommerce-jetpack' ) . '</li></ul></div>'
198
  : '<div class="woocommerce"><div class="woocommerce-message">' . __( 'Success!', 'woocommerce-jetpack' ) . '</div></div>';
199
  } else {
200
+ $notice_html .= '<div class="woocommerce"><ul class="woocommerce-error">' . $validate_args . '</ul></div>';
201
+ }
202
+ }
203
+
204
+ if ( isset( $_GET['wcj_edit_product_image_delete'] ) ) {
205
+ $product_id = $_GET['wcj_edit_product_image_delete'];
206
+ $post_author_id = get_post_field( 'post_author', $product_id );
207
+ $user_ID = get_current_user_id();
208
+ if ( $user_ID != $post_author_id ) {
209
+ echo '<p>' . __( 'Wrong user ID!', 'woocommerce-jetpack' ) . '</p>';
210
+ } else {
211
+ $image_id = get_post_thumbnail_id( $product_id );
212
+ wp_delete_post( $image_id, true );
213
  }
214
  }
215
 
216
+ $this->the_product = wc_get_product( $atts['product_id'] );
217
+
218
+ $header_html .= '<h3>';
219
+ $header_html .= ( 0 == $atts['product_id'] ) ? __( 'Add New Product', 'woocommerce-jetpack' ) : __( 'Edit Product', 'woocommerce-jetpack' );
220
+ $header_html .= '</h3>';
221
+ $header_html .= '<form method="post" action="' . remove_query_arg( array( 'wcj_edit_product_image_delete', 'wcj_delete_product' ) ) . '" enctype="multipart/form-data">'; // todo multipart only if image...
222
 
223
  $table_data = array();
224
  $input_style = 'width:100%;';
225
  $table_data[] = array(
226
+ __( 'Title', 'woocommerce-jetpack' ) . '&nbsp;<abbr class="required" title="required">*</abbr>',
227
+ '<input required type="text" style="' . $input_style . '" name="wcj_add_new_product_title" value="' . ( ( 0 != $atts['product_id'] ) ? $this->the_product->get_title() : '' ) . '">'
 
 
 
 
228
  );
229
+ if ( 'yes' === $atts['desc_enabled'] ) {
230
+ $required_html = ( 'yes' === $atts['desc_required'] ) ? ' required' : '';
231
+ $required_mark_html = ( 'yes' === $atts['desc_required'] ) ? '&nbsp;<abbr class="required" title="required">*</abbr>' : '';
232
+ $table_data[] = array(
233
+ __( 'Description', 'woocommerce-jetpack' ) . $required_mark_html,
234
+ '<textarea' . $required_html . ' style="' . $input_style . '" name="wcj_add_new_product_desc">' . ( ( 0 != $atts['product_id'] ) ? get_post_field( 'post_content', $atts['product_id'] ) : '' ) . '</textarea>'
235
+ );
 
236
  }
237
+ if ( 'yes' === $atts['short_desc_enabled'] ) {
238
+ $required_html = ( 'yes' === $atts['short_desc_required'] ) ? ' required' : '';
239
+ $required_mark_html = ( 'yes' === $atts['short_desc_required'] ) ? '&nbsp;<abbr class="required" title="required">*</abbr>' : '';
240
+ $table_data[] = array(
241
+ __( 'Short Description', 'woocommerce-jetpack' ) . $required_mark_html,
242
+ '<textarea' . $required_html . ' style="' . $input_style . '" name="wcj_add_new_product_short_desc">' . ( ( 0 != $atts['product_id'] ) ? get_post_field( 'post_excerpt', $atts['product_id'] ) : '' ) . '</textarea>'
243
+ );
 
244
  }
245
+ if ( 'yes' === $atts['image_enabled'] ) {
246
+ $required_html = ( 'yes' === $atts['image_required'] ) ? ' required' : '';
247
+ $required_mark_html = ( 'yes' === $atts['image_required'] ) ? '&nbsp;<abbr class="required" title="required">*</abbr>' : '';
248
+ $new_image_field = '<input' . $required_html . ' type="file" name="wcj_add_new_product_image" accept="image/*">';
249
+ if ( 0 != $atts['product_id'] ) {
250
+ $the_field = ( '' == get_post_thumbnail_id( $atts['product_id'] ) ) ?
251
+ $new_image_field :
252
+ '<a href="' . add_query_arg( 'wcj_edit_product_image_delete', $atts['product_id'] ) . '" onclick="return confirm(\'' . __( 'Are you sure?', 'woocommerce-jetpack' ) . '\')">' . __( 'Delete', 'woocommerce-jetpack' ) . '</a><br>' . get_the_post_thumbnail( $atts['product_id'], array( 50, 50 ) , array( 'class' => 'alignleft' ) );
253
+ } else {
254
+ $the_field = $new_image_field;
255
+ }
256
+ $table_data[] = array(
257
+ __( 'Image', 'woocommerce-jetpack' ) . $required_mark_html,
258
+ $the_field
259
+ );
260
+ }
261
+ if ( 'yes' === $atts['regular_price_enabled'] ) {
262
+ $required_html = ( 'yes' === $atts['regular_price_required'] ) ? ' required' : '';
263
+ $required_mark_html = ( 'yes' === $atts['regular_price_required'] ) ? '&nbsp;<abbr class="required" title="required">*</abbr>' : '';
264
+ $table_data[] = array(
265
+ __( 'Regular Price', 'woocommerce-jetpack' ) . $required_mark_html,
266
+ '<input' . $required_html . ' type="number" min="0" step="0.01" name="wcj_add_new_product_regular_price" value="' . ( ( 0 != $atts['product_id'] ) ? get_post_meta( $atts['product_id'], '_regular_price', true ) : '' ) . '">'
267
+ );
268
+ }
269
+ if ( 'yes' === $atts['sale_price_enabled'] ) {
270
+ $required_html = ( 'yes' === $atts['sale_price_required'] ) ? ' required' : '';
271
+ $required_mark_html = ( 'yes' === $atts['sale_price_required'] ) ? '&nbsp;<abbr class="required" title="required">*</abbr>' : '';
272
+ $table_data[] = array(
273
+ __( 'Sale Price', 'woocommerce-jetpack' ) . $required_mark_html,
274
+ '<input' . $required_html . ' type="number" min="0" step="0.01" name="wcj_add_new_product_sale_price" value="' . ( ( 0 != $atts['product_id'] ) ? get_post_meta( $atts['product_id'], '_sale_price', true ) : '' ) . '">'
275
+ );
276
+ }
277
+ if ( 'yes' === $atts['cats_enabled'] ) {
278
+ $required_html = ( 'yes' === $atts['cats_required'] ) ? ' required' : '';
279
+ $required_mark_html = ( 'yes' === $atts['cats_required'] ) ? '&nbsp;<abbr class="required" title="required">*</abbr>' : '';
280
+ $current_product_categories = ( 0 != $atts['product_id'] ) ? get_the_terms( $atts['product_id'], 'product_cat' ) : array();
281
+ $product_categories = get_terms( 'product_cat', 'orderby=name&hide_empty=0' );
282
+ $product_categories_as_select_options = '';
283
+ foreach ( $product_categories as $product_category ) {
284
+ $selected = '';
285
+ if ( ! empty( $current_product_categories ) ) {
286
+ foreach ( $current_product_categories as $current_product_category ) {
287
+ $selected .= selected( $current_product_category->term_id, $product_category->term_id, false );
288
+ }
289
+ }
290
+ $product_categories_as_select_options .= '<option value="' . $product_category->slug . '" ' . $selected . '>' . $product_category->name .'</option>';
291
+ }
292
+ $table_data[] = array(
293
+ __( 'Categories', 'woocommerce-jetpack' ) . $required_mark_html,
294
+ '<select' . $required_html . ' multiple style="' . $input_style . '" name="wcj_add_new_product_cats[]">' . $product_categories_as_select_options . '</select>'
295
+ );
296
+ }
297
+ if ( 'yes' === $atts['tags_enabled'] ) {
298
+ $required_html = ( 'yes' === $atts['tags_required'] ) ? ' required' : '';
299
+ $required_mark_html = ( 'yes' === $atts['tags_required'] ) ? '&nbsp;<abbr class="required" title="required">*</abbr>' : '';
300
+ $current_product_tags = ( 0 != $atts['product_id'] ) ? get_the_terms( $atts['product_id'], 'product_tag' ) : array();
301
+ $products_tags = get_terms( 'product_tag', 'orderby=name&hide_empty=0' );
302
+ $products_tags_as_select_options = '';
303
+ foreach ( $products_tags as $products_tag ) {
304
+ $selected = '';
305
+ if ( ! empty( $current_product_tags ) ) {
306
+ foreach ( $current_product_tags as $current_product_tag ) {
307
+ $selected .= selected( $current_product_tag->term_id, $products_tag->term_id, false );
308
+ }
309
+ }
310
+ $products_tags_as_select_options .= '<option value="' . $products_tag->slug . '" ' . $selected . '>' . $products_tag->name .'</option>';
311
+ }
312
+ $table_data[] = array(
313
+ __( 'Tags', 'woocommerce-jetpack' ) . $required_mark_html,
314
+ '<select' . $required_html . ' multiple style="' . $input_style . '" name="wcj_add_new_product_tags[]">' . $products_tags_as_select_options . '</select>'
315
+ );
316
+ }
317
+
318
  $input_fields_html .= wcj_get_table_html( $table_data, array( 'table_class' => 'widefat', 'table_heading_type' => 'vertical', ) );
319
 
320
+ $footer_html .= '<input type="submit" class="button" name="wcj_add_new_product" value="' . ( ( 0 == $atts['product_id'] ) ? __( 'Add', 'woocommerce-jetpack' ) : __( 'Edit', 'woocommerce-jetpack' ) ) . '">';
321
  $footer_html .= '</form>';
322
 
323
  return $notice_html . $header_html . $input_fields_html . $footer_html;
includes/shortcodes/class-wcj-products-shortcodes.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Products Shortcodes class.
6
  *
7
- * @version 2.5.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -17,7 +17,7 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
17
  /**
18
  * Constructor.
19
  *
20
- * @version 2.5.0
21
  */
22
  public function __construct() {
23
 
@@ -71,6 +71,7 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
71
  'excerpt_length' => 0,
72
  'name' => '',
73
  'heading_format' => 'from %level_qty% pcs.',
 
74
  'sep' => ', ',
75
  'add_links' => 'yes',
76
  'add_percent_row' => 'no',
@@ -713,7 +714,7 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
713
  /**
714
  * wcj_product_wholesale_price_table.
715
  *
716
- * @version 2.5.0
717
  */
718
  function wcj_product_wholesale_price_table( $atts ) {
719
 
@@ -747,8 +748,17 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
747
 
748
  if ( $this->the_product->is_type( 'variable' ) ) {
749
  // Variable
750
- $min = $this->the_product->get_variation_price( 'min', false );
751
- $max = $this->the_product->get_variation_price( 'max', false );
 
 
 
 
 
 
 
 
 
752
  if ( 'fixed' === $discount_type ) {
753
  $min = $min - $wholesale_price_level['discount'];
754
  $max = $max - $wholesale_price_level['discount'];
@@ -760,11 +770,16 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
760
  if ( 'yes' !== $atts['hide_currency'] ) {
761
  $min = wc_price( $min );
762
  $max = wc_price( $max );
 
 
763
  }
764
  $the_price = ( $min != $max ) ? sprintf( '%s-%s', $min, $max ) : $min;
 
765
  } else {
766
  // Simple etc.
767
- $the_price = $this->the_product->get_price();
 
 
768
  if ( 'fixed' === $discount_type ) {
769
  $the_price = $the_price - $wholesale_price_level['discount'];
770
  } else {
@@ -773,12 +788,13 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
773
  }
774
  if ( 'yes' !== $atts['hide_currency'] ) {
775
  $the_price = wc_price( $the_price );
 
776
  }
777
  }
778
 
779
  $data_qty[] = str_replace( '%level_qty%', $wholesale_price_level['quantity'], $atts['heading_format'] ) ;
780
  if ( 'yes' === $atts['add_price_row'] ) {
781
- $data_price[] = $the_price;
782
  }
783
  if ( 'yes' === $atts['add_percent_row'] ) {
784
  if ( 'fixed' === $discount_type ) {
@@ -806,7 +822,7 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
806
  $table_rows[] = $data_discount;
807
  }
808
 
809
- return wcj_get_table_html( $table_rows, array( 'columns_styles' => $columns_styles ) );
810
  }
811
 
812
  /**
4
  *
5
  * The WooCommerce Jetpack Products Shortcodes class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
17
  /**
18
  * Constructor.
19
  *
20
+ * @version 2.5.2
21
  */
22
  public function __construct() {
23
 
71
  'excerpt_length' => 0,
72
  'name' => '',
73
  'heading_format' => 'from %level_qty% pcs.',
74
+ 'price_row_format' => '<del>%old_price%</del> %price%',
75
  'sep' => ', ',
76
  'add_links' => 'yes',
77
  'add_percent_row' => 'no',
714
  /**
715
  * wcj_product_wholesale_price_table.
716
  *
717
+ * @version 2.5.2
718
  */
719
  function wcj_product_wholesale_price_table( $atts ) {
720
 
748
 
749
  if ( $this->the_product->is_type( 'variable' ) ) {
750
  // Variable
751
+ $prices = $this->the_product->get_variation_prices( false );
752
+ $min_key = key( $prices['price'] );
753
+ end( $prices['price'] );
754
+ $max_key = key( $prices['price'] );
755
+ $min_product = wc_get_product( $min_key );
756
+ $max_product = wc_get_product( $max_key );
757
+ $get_price_method = 'get_price_' . get_option( 'woocommerce_tax_display_shop' ) . 'uding_tax';
758
+ $min = $min_product->$get_price_method();
759
+ $max = $max_product->$get_price_method();
760
+ $min_original = $min;
761
+ $max_original = $max;
762
  if ( 'fixed' === $discount_type ) {
763
  $min = $min - $wholesale_price_level['discount'];
764
  $max = $max - $wholesale_price_level['discount'];
770
  if ( 'yes' !== $atts['hide_currency'] ) {
771
  $min = wc_price( $min );
772
  $max = wc_price( $max );
773
+ $min_original = wc_price( $min_original );
774
+ $max_original = wc_price( $max_original );
775
  }
776
  $the_price = ( $min != $max ) ? sprintf( '%s-%s', $min, $max ) : $min;
777
+ $the_price_original = ( $min_original != $max_original ) ? sprintf( '%s-%s', $min_original, $max_original ) : $min_original;
778
  } else {
779
  // Simple etc.
780
+ $get_price_method = 'get_price_' . get_option( 'woocommerce_tax_display_shop' ) . 'uding_tax';
781
+ $the_price = $this->the_product->$get_price_method();
782
+ $the_price_original = $the_price;
783
  if ( 'fixed' === $discount_type ) {
784
  $the_price = $the_price - $wholesale_price_level['discount'];
785
  } else {
788
  }
789
  if ( 'yes' !== $atts['hide_currency'] ) {
790
  $the_price = wc_price( $the_price );
791
+ $the_price_original = wc_price( $the_price_original );
792
  }
793
  }
794
 
795
  $data_qty[] = str_replace( '%level_qty%', $wholesale_price_level['quantity'], $atts['heading_format'] ) ;
796
  if ( 'yes' === $atts['add_price_row'] ) {
797
+ $data_price[] = str_replace( array( '%old_price%', '%price%' ), array( $the_price_original, $the_price ), $atts['price_row_format'] );
798
  }
799
  if ( 'yes' === $atts['add_percent_row'] ) {
800
  if ( 'fixed' === $discount_type ) {
822
  $table_rows[] = $data_discount;
823
  }
824
 
825
+ return wcj_get_table_html( $table_rows, array( 'table_class' => 'wcj_product_wholesale_price_table', 'columns_styles' => $columns_styles ) );
826
  }
827
 
828
  /**
includes/shortcodes/class-wcj-shortcodes.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Shortcodes class.
6
  *
7
- * @version 2.5.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -28,8 +28,13 @@ class WCJ_Shortcodes {
28
 
29
  /**
30
  * add_extra_atts.
 
 
31
  */
32
  function add_extra_atts( $atts ) {
 
 
 
33
  $final_atts = array_merge( $this->the_atts, $atts );
34
  return $final_atts;
35
  }
@@ -54,27 +59,65 @@ class WCJ_Shortcodes {
54
  /**
55
  * wcj_shortcode.
56
  *
57
- * @version 2.5.0
58
  */
59
  function wcj_shortcode( $atts, $content, $shortcode ) {
60
 
61
  // Init
62
  if ( empty( $atts ) ) $atts = array();
 
 
 
 
 
63
  $global_defaults = array(
64
  'before' => '',
65
  'after' => '',
66
  'visibility' => '',//user_visibility
 
67
  'site_visibility' => '',
68
  'location' => '',//user_location
69
  'wpml_language' => '',
70
  'wpml_not_language' => '',
71
  'billing_country' => '',
72
  'not_billing_country' => '',
 
73
  );
74
  $atts = array_merge( $global_defaults, $atts );
75
 
 
 
 
 
 
 
 
 
76
  // Check if privileges are ok
77
- if ( 'admin' === $atts['visibility'] && ! wcj_is_user_role( 'administrator' ) ) return '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
  // Check if site visibility is ok
80
  if ( '' != $atts['site_visibility'] ) {
@@ -117,12 +160,6 @@ class WCJ_Shortcodes {
117
  }
118
  }
119
 
120
- // Add child class specific atts
121
- $atts = $this->add_extra_atts( $atts );
122
-
123
- // Check for required atts
124
- if ( false === ( $atts = $this->init_atts( $atts ) ) ) return '';
125
-
126
  // Run the shortcode function
127
  $shortcode_function = $shortcode;
128
  if ( '' !== ( $result = $this->$shortcode_function( $atts, $content ) ) )
4
  *
5
  * The WooCommerce Jetpack Shortcodes class.
6
  *
7
+ * @version 2.5.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
28
 
29
  /**
30
  * add_extra_atts.
31
+ *
32
+ * @version 2.5.2
33
  */
34
  function add_extra_atts( $atts ) {
35
+ if ( ! isset( $this->the_atts ) ) {
36
+ $this->the_atts = array();
37
+ }
38
  $final_atts = array_merge( $this->the_atts, $atts );
39
  return $final_atts;
40
  }
59
  /**
60
  * wcj_shortcode.
61
  *
62
+ * @version 2.5.2
63
  */
64
  function wcj_shortcode( $atts, $content, $shortcode ) {
65
 
66
  // Init
67
  if ( empty( $atts ) ) $atts = array();
68
+
69
+ // Add child class specific atts
70
+ $atts = $this->add_extra_atts( $atts );
71
+
72
+ // Merge atts with global defaults
73
  $global_defaults = array(
74
  'before' => '',
75
  'after' => '',
76
  'visibility' => '',//user_visibility
77
+ // 'login_text' => __( 'Login', 'woocommerce-jetpack' ),
78
  'site_visibility' => '',
79
  'location' => '',//user_location
80
  'wpml_language' => '',
81
  'wpml_not_language' => '',
82
  'billing_country' => '',
83
  'not_billing_country' => '',
84
+ 'module' => '',
85
  );
86
  $atts = array_merge( $global_defaults, $atts );
87
 
88
+ // Check for required atts
89
+ if ( false === ( $atts = $this->init_atts( $atts ) ) ) return '';
90
+
91
+ // Check for module enabled
92
+ if ( '' != $atts['module'] && ! wcj_is_module_enabled( $atts['module'] ) ) {
93
+ return '<p>' . sprintf( __( '%s module not enabled!', 'woocommerce-jetpack' ), $atts['module_name'] ) . '</p>';
94
+ }
95
+
96
  // Check if privileges are ok
97
+ if ( '' != $atts['visibility'] ) {
98
+ $visibilities = str_replace( ' ', '', $atts['visibility'] );
99
+ $visibilities = explode( ',', $visibilities );
100
+ $is_iser_visibility_ok = false;
101
+ foreach ( $visibilities as $visibility ) {
102
+ if ( 'admin' === $visibility ) {
103
+ $visibility = 'administrator';
104
+ }
105
+ if ( wcj_is_user_role( $visibility ) ) {
106
+ $is_iser_visibility_ok = true;
107
+ break;
108
+ }
109
+ }
110
+ if ( ! $is_iser_visibility_ok ) {
111
+ // return '<p><a href="' . wp_login_url( get_permalink() ) . '" title="' . $atts['login_text'] . '">' . $atts['login_text'] . '</a></p>';
112
+ if ( ! is_user_logged_in() ) {
113
+ ob_start();
114
+ woocommerce_login_form();
115
+ return ob_get_clean();
116
+ } else {
117
+ return '<p>' . __( 'Wrong user role!', 'woocommerce-jetpack' ) . '</p>';
118
+ }
119
+ }
120
+ }
121
 
122
  // Check if site visibility is ok
123
  if ( '' != $atts['site_visibility'] ) {
160
  }
161
  }
162
 
 
 
 
 
 
 
163
  // Run the shortcode function
164
  $shortcode_function = $shortcode;
165
  if ( '' !== ( $result = $this->$shortcode_function( $atts, $content ) ) )
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: algoritmika,anbinder
3
  Tags: woocommerce,booster for 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,vat,gateway by country,price by country,currency switcher
4
  Requires at least: 4.1
5
  Tested up to: 4.5
6
- Stable tag: 2.5.1
7
  License: GNU General Public License v3.0
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -21,8 +21,10 @@ Booster for WooCommerce is a WordPress plugin that supercharges your site with a
21
  * *Currencies* - Add all world currencies to your WooCommerce store; change currency symbol.
22
  * *Currency Exchange Rates* - Automatic currency exchange rates for WooCommerce.
23
  * *Currency for External Products* - Set different currency for external WooCommerce products.
 
24
  * *Multicurrency (Currency Switcher)* - Add multiple currencies (currency switcher) to WooCommerce.
25
  * *Multicurrency Product Base Price* - Enter prices for WooCommerce products in different currencies.
 
26
  * *Price by User Role* - Display WooCommerce products prices by user roles.
27
  * *Prices and Currencies by Country* - Change WooCommerce product price and currency automatically by customer's country.
28
  * *Product Open Pricing (Name Your Price)* - Let your WooCommerce store customers enter price for the product manually.
@@ -48,6 +50,7 @@ Booster for WooCommerce is a WordPress plugin that supercharges your site with a
48
  * *Product Listings* - Change WooCommerce display options for shop and category pages: show/hide categories count, exclude categories, show/hide empty categories.
49
  * *Product Tabs* - Add custom product tabs - globally or per product. Customize or completely remove WooCommerce default product tabs.
50
  * *Product by Country* - Display WooCommerce products by customers country.
 
51
  * *Related Products* - Change displayed WooCommerce related products number, columns, order, relate by tag and/or category, or hide related products completely.
52
  * *SKU* - Generate WooCommerce SKUs automatically.
53
  * *Sorting* - Add more WooCommerce sorting options or remove all sorting including default.
@@ -121,6 +124,54 @@ To unlock all Booster for WooCommerce features, please install additional [Boost
121
 
122
  == Changelog ==
123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  = 2.5.1 - 24/05/2016 =
125
  * Dev - PRICES & CURRENCIES - Product Price by Formula - No more using `namespace` (as it required PHP 5 >= 5.3.0).
126
  * Dev - PRICES & CURRENCIES - Product Open Pricing (Name Your Price) - "Frontend Template" option added.
3
  Tags: woocommerce,booster for 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,vat,gateway by country,price by country,currency switcher
4
  Requires at least: 4.1
5
  Tested up to: 4.5
6
+ Stable tag: 2.5.2
7
  License: GNU General Public License v3.0
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
21
  * *Currencies* - Add all world currencies to your WooCommerce store; change currency symbol.
22
  * *Currency Exchange Rates* - Automatic currency exchange rates for WooCommerce.
23
  * *Currency for External Products* - Set different currency for external WooCommerce products.
24
+ * *Currency per Product* - Display prices for WooCommerce products in different currencies.
25
  * *Multicurrency (Currency Switcher)* - Add multiple currencies (currency switcher) to WooCommerce.
26
  * *Multicurrency Product Base Price* - Enter prices for WooCommerce products in different currencies.
27
+ * *Price Formats* - Set different WooCommerce price formats for different currencies.
28
  * *Price by User Role* - Display WooCommerce products prices by user roles.
29
  * *Prices and Currencies by Country* - Change WooCommerce product price and currency automatically by customer's country.
30
  * *Product Open Pricing (Name Your Price)* - Let your WooCommerce store customers enter price for the product manually.
50
  * *Product Listings* - Change WooCommerce display options for shop and category pages: show/hide categories count, exclude categories, show/hide empty categories.
51
  * *Product Tabs* - Add custom product tabs - globally or per product. Customize or completely remove WooCommerce default product tabs.
52
  * *Product by Country* - Display WooCommerce products by customers country.
53
+ * *Product by User* - Let users to add new WooCommerce products from frontend.
54
  * *Related Products* - Change displayed WooCommerce related products number, columns, order, relate by tag and/or category, or hide related products completely.
55
  * *SKU* - Generate WooCommerce SKUs automatically.
56
  * *Sorting* - Add more WooCommerce sorting options or remove all sorting including default.
124
 
125
  == Changelog ==
126
 
127
+ = 2.5.2 - 21/06/2016 =
128
+ * Dev - "Manage Settings" functionality added.
129
+ * Dev - `wcj_add_files_upload_form_to_checkout_frontend` function added.
130
+ * Dev - `include_modules` function code refactoring.
131
+ * Fix - Cart `calculate_totals()` added on `wp_loaded` to fix mini cart currency and price issues.
132
+ * Dev - Shortcodes - `module` (and `module_name`) attribute added.
133
+ * Dev - Shortcodes - `visibility` attribute modified.
134
+ * Fix - Shortcodes - Orders - `[wcj_order_total_fees_tax]` and `[wcj_order_total_fees_incl_tax]` - using `get_line_tax()` instead of calculating taxes manually - that should fix the issue with wrong taxes rounding.
135
+ * Dev - Shortcodes - General and Products - `[wcj_wholesale_price_table]` and `[wcj_product_wholesale_price_table]` - Table class added.
136
+ * Fix - Shortcodes - Products - `[wcj_product_wholesale_price_table]` - Price tax bug fixed.
137
+ * Dev - Shortcodes - Products - `[wcj_product_wholesale_price_table]` - `price_row_format` attribute added.
138
+ * Dev - PRICES & CURRENCIES - Currency Exchange Rates - "Logging" option added.
139
+ * Dev - PRICES & CURRENCIES - Currency per Product - Initial module release.
140
+ * Dev - PRICES & CURRENCIES - Multicurrency Product Base Price - Removed from currency reports.
141
+ * Dev - PRICES & CURRENCIES - Prices and Currencies by Country - "Revert Currency to Default on Checkout" option added.
142
+ * Fix - PRICES & CURRENCIES - Prices and Currencies by Country - Loading core on `admin-ajax.php` (caused issue in mini cart).
143
+ * Dev - PRICES & CURRENCIES - Price by User Role - "Make Empty Price" option added.
144
+ * Fix - PRICES & CURRENCIES - Price by User Role - `change_price_by_role_shipping()` fixed (produced an error if price by user role for shipping was disabled).
145
+ * Dev - PRICES & CURRENCIES - Price Formats - Initial module release.
146
+ * Fix - PRICES & CURRENCIES - Wholesale Price - Old price taxes fixed when displaying in cart.
147
+ * Fix - PRODUCTS - Bookings - `is_product` and `is_bookings_product` checks added to `enqueue_scripts` function.
148
+ * Dev - PRODUCTS - Bookings - "Labels and Messages" settings added.
149
+ * Dev - PRODUCTS - Product Add to Cart - "Disable Quantity Field for All Products" option added.
150
+ * Dev - PRODUCTS - Product Add to Cart - Disable Add to Cart Button (on Single Product Page and/or Loop) options added.
151
+ * Dev - PRODUCTS - Product by User - Initial module release.
152
+ * Dev - PRODUCTS - Product Images - Per product "Hide" options added.
153
+ * Fix - PRODUCTS - Product Images - Meta boxes added only if section is enabled.
154
+ * Dev - PRODUCTS - Product Input Fields - "File: Max size" option added.
155
+ * Dev - PRODUCTS - Product Tabs - `do_shortcode` added to custom tab titles.
156
+ * Dev - PRODUCTS - SKU - Sequential number generation option added.
157
+ * Dev - PAYMENT GATEWAYS - Custom Gateways - Custom input fields (and `[wcj_input_field]` shortcode) added.
158
+ * Dev - SHIPPING & ORDERS - Shipping - Custom Shipping - "By Total Cart Weight Table" option added.
159
+ * Dev - SHIPPING & ORDERS - Shipping - "Left to free shipping" - `do_shortcode` added to all messages.
160
+ * Dev - SHIPPING & ORDERS - Order Custom Statuses - Custom icon and icon color options added.
161
+ * Dev - SHIPPING & ORDERS - Order Numbers - "Enable Order Tracking by Custom Number" option added.
162
+ * Fix - PDF INVOICING & PACKING SLIPS - `SetTitle` fixed.
163
+ * Fix - PDF INVOICING & PACKING SLIPS - Display & Misc. - Action buttons icons changed.
164
+ * Dev - PDF INVOICING & PACKING SLIPS - Display & Misc. - Confirmation request added to the delete and create buttons.
165
+ * Fix - PDF INVOICING & PACKING SLIPS - Report Tool - Querying by document date instead of order date.
166
+ * Dev - EMAILS & MISC. - General - "PayPal Email per Product" option added.
167
+ * Dev - EMAILS & MISC. - EU VAT Number - Option ("Display") to append EU VAT number to order and my account billing addresses added.
168
+ * Fix - EMAILS & MISC. - EU VAT Number - `woocommerce_matched_rates` filter changed to `woocommerce_find_rates` - this fixes the issue with sipping tax not exempting.
169
+ * Tweak - "Unlock all" link modified.
170
+ * Tweak - "No active modules found." message added.
171
+ * Tweak - PRODUCTS - Product Images - Module settings rearranged.
172
+ * Tweak - PDF INVOICING & PACKING SLIPS - Numbering - Fields width and order modified.
173
+ * Tweak - PDF INVOICING & PACKING SLIPS - Templates - "Available Shortcodes" info section modified.
174
+
175
  = 2.5.1 - 24/05/2016 =
176
  * Dev - PRICES & CURRENCIES - Product Price by Formula - No more using `namespace` (as it required PHP 5 >= 5.3.0).
177
  * Dev - PRICES & CURRENCIES - Product Open Pricing (Name Your Price) - "Frontend Template" option added.
woocommerce-jetpack.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Booster for WooCommerce
4
  Plugin URI: http://booster.io
5
  Description: Supercharge your WooCommerce site with these awesome powerful features.
6
- Version: 2.5.1
7
  Author: Algoritmika Ltd
8
  Author URI: http://www.algoritmika.com
9
  Text Domain: woocommerce-jetpack
@@ -28,7 +28,7 @@ if ( ! class_exists( 'WC_Jetpack' ) ) :
28
  * Main WC_Jetpack Class
29
  *
30
  * @class WC_Jetpack
31
- * @version 2.5.0
32
  */
33
 
34
  final class WC_Jetpack {
@@ -39,7 +39,7 @@ final class WC_Jetpack {
39
  * @var string
40
  * @since 2.4.7
41
  */
42
- public $version = '2.5.1';
43
 
44
  /**
45
  * @var WC_Jetpack The single instance of the class
@@ -78,7 +78,7 @@ final class WC_Jetpack {
78
  /**
79
  * WC_Jetpack Constructor.
80
  *
81
- * @version 2.5.0
82
  * @access public
83
  */
84
  public function __construct() {
@@ -121,10 +121,53 @@ final class WC_Jetpack {
121
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_scripts' ) );
122
  }
123
 
 
 
 
 
 
 
124
  // Loaded action
125
  do_action( 'wcj_loaded' );
126
  }
127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  /**
129
  * enqueue_frontend_scripts.
130
  *
@@ -284,16 +327,19 @@ final class WC_Jetpack {
284
  /**
285
  * Show action links on the plugin screen
286
  *
287
- * @version 2.3.8
288
  * @param mixed $links
289
  * @return array
290
  */
291
  public function action_links( $links ) {
292
- return array_merge( array(
293
  '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=jetpack' ) . '">' . __( 'Settings', 'woocommerce' ) . '</a>',
294
  '<a href="' . esc_url( 'http://booster.io/' ) . '">' . __( 'Docs', 'woocommerce' ) . '</a>',
295
- '<a href="' . esc_url( 'http://booster.io/plus/' ) . '">' . __( 'Unlock all', 'woocommerce' ) . '</a>',
296
- ), $links );
 
 
 
297
  }
298
 
299
  /**
@@ -394,7 +440,7 @@ final class WC_Jetpack {
394
  /**
395
  * include_shortcodes.
396
  *
397
- * @version 2.5.0
398
  */
399
  private function include_shortcodes() {
400
  //if ( 'yes' === get_option( 'wcj_shortcodes_enabled', 'no' ) ) {
@@ -406,144 +452,253 @@ final class WC_Jetpack {
406
  include_once( 'includes/shortcodes/class-wcj-order-items-shortcodes.php' );
407
  include_once( 'includes/shortcodes/class-wcj-products-shortcodes.php' );
408
  include_once( 'includes/shortcodes/class-wcj-products-add-form-shortcodes.php' );
 
409
  }
410
  }
411
 
412
  /**
413
  * Include modules and submodules
414
  *
415
- * @version 2.5.0
416
  */
417
- private function include_modules() {
418
- $settings = array();
419
- $settings[] = include_once( 'includes/class-wcj-price-labels.php' );
420
- $settings[] = include_once( 'includes/class-wcj-call-for-price.php' );
421
- $settings[] = include_once( 'includes/class-wcj-product-listings.php' );
422
- $settings[] = include_once( 'includes/class-wcj-sorting.php' );
423
- $settings[] = include_once( 'includes/class-wcj-product-custom-info.php' );
424
- $settings[] = include_once( 'includes/class-wcj-product-info.php' );
425
- $settings[] = include_once( 'includes/class-wcj-product-add-to-cart.php' );
426
- $settings[] = include_once( 'includes/class-wcj-related-products.php' );
427
- $settings[] = include_once( 'includes/class-wcj-sku.php' );
428
- $settings[] = include_once( 'includes/class-wcj-product-tabs.php' );
429
- $settings[] = include_once( 'includes/class-wcj-product-input-fields.php' );
430
- $settings[] = include_once( 'includes/class-wcj-product-bulk-price-converter.php' );
431
- $settings[] = include_once( 'includes/class-wcj-purchase-data.php' );
432
- $settings[] = include_once( 'includes/class-wcj-product-bookings.php' );
433
- $settings[] = include_once( 'includes/class-wcj-crowdfunding.php' );
434
- $settings[] = include_once( 'includes/class-wcj-wholesale-price.php' );
435
- $settings[] = include_once( 'includes/class-wcj-product-open-pricing.php' );
436
- $settings[] = include_once( 'includes/class-wcj-price-by-user-role.php' );
437
- $settings[] = include_once( 'includes/class-wcj-product-price-by-formula.php' );
438
- $settings[] = include_once( 'includes/class-wcj-product-images.php' );
439
- $settings[] = include_once( 'includes/class-wcj-product-by-country.php' );
440
- $settings[] = include_once( 'includes/class-wcj-add-to-cart.php' );
441
- $settings[] = include_once( 'includes/class-wcj-more-button-labels.php' );
442
- $settings[] = include_once( 'includes/class-wcj-cart.php' );
443
- $settings[] = include_once( 'includes/class-wcj-empty-cart-button.php' );
444
- $settings[] = include_once( 'includes/class-wcj-mini-cart.php' );
445
- $settings[] = include_once( 'includes/class-wcj-checkout-core-fields.php' );
446
- $settings[] = include_once( 'includes/class-wcj-checkout-custom-fields.php' );
447
- $settings[] = include_once( 'includes/class-wcj-checkout-files-upload.php' );
448
- $settings[] = include_once( 'includes/class-wcj-checkout-custom-info.php' );
449
- $settings[] = include_once( 'includes/class-wcj-payment-gateways.php' );
450
- $settings[] = include_once( 'includes/class-wcj-payment-gateways-icons.php' );
451
- $settings[] = include_once( 'includes/class-wcj-payment-gateways-fees.php' );
452
- $settings[] = include_once( 'includes/class-wcj-payment-gateways-per-category.php' );
453
- $settings[] = include_once( 'includes/class-wcj-payment-gateways-currency.php' );
454
- $settings[] = include_once( 'includes/class-wcj-payment-gateways-min-max.php' );
455
- $settings[] = include_once( 'includes/class-wcj-payment-gateways-by-country.php' );
456
- $settings[] = include_once( 'includes/class-wcj-shipping.php' );
457
- $settings[] = include_once( 'includes/class-wcj-shipping-calculator.php' );
458
- $settings[] = include_once( 'includes/class-wcj-address-formats.php' );
459
- $settings[] = include_once( 'includes/class-wcj-orders.php' );
460
- $settings[] = include_once( 'includes/class-wcj-order-numbers.php' );
461
- $settings[] = include_once( 'includes/class-wcj-order-custom-statuses.php' );
462
- // $settings[] = include_once( 'includes/class-wcj-pdf-invoices.php' );
463
- $settings[] = include_once( 'includes/class-wcj-pdf-invoicing.php' );
464
- $settings[] = include_once( 'includes/class-wcj-emails.php' );
465
- $settings[] = include_once( 'includes/class-wcj-currencies.php' );
466
- $settings[] = include_once( 'includes/class-wcj-multicurrency.php' );
467
- $settings[] = include_once( 'includes/class-wcj-multicurrency-product-base-price.php' );
468
- $settings[] = include_once( 'includes/class-wcj-currency-external-products.php' );
469
- $settings[] = include_once( 'includes/class-wcj-price-by-country.php' );
470
- $settings[] = include_once( 'includes/class-wcj-currency-exchange-rates.php' );
471
- $settings[] = include_once( 'includes/class-wcj-general.php' );
472
- // $settings[] = include_once( 'includes/class-wcj-shortcodes-module.php' );
473
- $settings[] = include_once( 'includes/class-wcj-eu-vat-number.php' );
474
- $settings[] = include_once( 'includes/class-wcj-old-slugs.php' );
475
- $settings[] = include_once( 'includes/class-wcj-reports.php' );
476
- $settings[] = include_once( 'includes/class-wcj-admin-tools.php' );
477
- $settings[] = include_once( 'includes/class-wcj-wpml.php' );
478
- $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-numbering.php' );
479
- $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-templates.php' );
480
- $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-styling.php' );
481
- $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-header.php' );
482
- $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-footer.php' );
483
- $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-page.php' );
484
- $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-emails.php' );
485
- $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-display.php' );
486
- // $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-general.php' );
 
 
 
 
 
 
 
 
 
 
487
 
488
  // do_action( 'woojetpack_modules', $settings );
489
 
490
- // Add options
491
  if ( is_admin() ) {
 
 
 
492
 
493
- // Modules statuses
494
- $submodules_classes = array(
495
- 'WCJ_PDF_Invoicing_Display',
496
- 'WCJ_PDF_Invoicing_Emails',
497
- 'WCJ_PDF_Invoicing_Footer',
498
- 'WCJ_PDF_Invoicing_Header',
499
- 'WCJ_PDF_Invoicing_Numbering',
500
- 'WCJ_PDF_Invoicing_Page',
501
- 'WCJ_PDF_Invoicing_Styling',
502
- 'WCJ_PDF_Invoicing_Templates',
503
- );
504
-
505
- foreach ( $settings as $section ) {
506
-
507
- if ( ! in_array( get_class( $section ), $submodules_classes ) ) {
508
- // $this->module_statuses[] = $values[1];
509
- $status_settings = $section->add_enable_module_setting( array() );
510
- $this->module_statuses[] = $status_settings[1];
511
- }
512
 
513
- // if ( ! $section->is_enabled() && ! isset ( $_GET['woojetpack_admin_options_reset'] ) ) {
514
- if ( get_option( 'booster_for_woocommerce_version' ) === $this->version && ! isset ( $_GET['woojetpack_admin_options_reset'] ) ) {
515
- continue;
516
- }
517
 
518
- $values = $section->get_settings();
 
 
 
519
 
520
- // Adding options
521
- foreach ( $values as $value ) {
522
- if ( isset( $value['default'] ) && isset( $value['id'] ) ) {
523
 
524
- // Admin reset
525
- if ( isset ( $_GET['woojetpack_admin_options_reset'] ) ) {
526
- require_once( ABSPATH . 'wp-includes/pluggable.php' );
527
- if ( wcj_is_user_role( 'administrator' ) ) {
528
- delete_option( $value['id'] );
529
- }
530
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
531
 
532
- // Finally adding options
533
- $autoload = isset( $value['autoload'] ) ? (bool) $value['autoload'] : true;
534
- add_option( $value['id'], $value['default'], '', ( $autoload ? 'yes' : 'no' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
535
 
536
- /* if ( $this->is_wpml_value( $section, $value ) ) {
537
- $wpml_keys[] = $value['id'];
538
- } */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
539
  }
540
  }
541
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
542
 
543
- if ( get_option( 'booster_for_woocommerce_version' ) !== $this->version ) {
544
- update_option( 'booster_for_woocommerce_version', $this->version );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
545
  }
546
  }
 
 
 
547
  }
548
 
549
  /**
3
  Plugin Name: Booster for WooCommerce
4
  Plugin URI: http://booster.io
5
  Description: Supercharge your WooCommerce site with these awesome powerful features.
6
+ Version: 2.5.2
7
  Author: Algoritmika Ltd
8
  Author URI: http://www.algoritmika.com
9
  Text Domain: woocommerce-jetpack
28
  * Main WC_Jetpack Class
29
  *
30
  * @class WC_Jetpack
31
+ * @version 2.5.2
32
  */
33
 
34
  final class WC_Jetpack {
39
  * @var string
40
  * @since 2.4.7
41
  */
42
+ public $version = '2.5.2';
43
 
44
  /**
45
  * @var WC_Jetpack The single instance of the class
78
  /**
79
  * WC_Jetpack Constructor.
80
  *
81
+ * @version 2.5.2
82
  * @access public
83
  */
84
  public function __construct() {
121
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_scripts' ) );
122
  }
123
 
124
+ if ( wcj_is_module_enabled( 'general' ) && 'yes' === get_option( 'wcj_general_advanced_recalculate_cart_totals', 'no' ) ) {
125
+ add_action( 'wp_loaded', array( $this, 'fix_mini_cart' ), PHP_INT_MAX );
126
+ }
127
+
128
+ add_action( 'wp_loaded', array( $this, 'manage_options' ), PHP_INT_MAX );
129
+
130
  // Loaded action
131
  do_action( 'wcj_loaded' );
132
  }
133
 
134
+ /**
135
+ * manage_options.
136
+ *
137
+ * @version 2.5.2
138
+ * @since 2.5.2
139
+ */
140
+ function manage_options() {
141
+ if ( is_admin() ) {
142
+ if ( isset( $_POST['booster_import_settings'] ) ) {
143
+ $this->manage_options_import();
144
+ }
145
+ if ( isset( $_POST['booster_export_settings'] ) ) {
146
+ $this->manage_options_export();
147
+ }
148
+ if ( isset( $_POST['booster_reset_settings'] ) ) {
149
+ $this->manage_options_reset();
150
+ }
151
+ }
152
+ }
153
+
154
+ /**
155
+ * fix_mini_cart.
156
+ *
157
+ * @version 2.5.2
158
+ * @since 2.5.2
159
+ * @todo this is only temporary solution!
160
+ */
161
+ function fix_mini_cart() {
162
+ if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
163
+ if ( null !== ( $wc = WC() ) ) {
164
+ if ( isset( $wc->cart ) ) {
165
+ $wc->cart->calculate_totals();
166
+ }
167
+ }
168
+ }
169
+ }
170
+
171
  /**
172
  * enqueue_frontend_scripts.
173
  *
327
  /**
328
  * Show action links on the plugin screen
329
  *
330
+ * @version 2.5.2
331
  * @param mixed $links
332
  * @return array
333
  */
334
  public function action_links( $links ) {
335
+ $custom_links = array(
336
  '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=jetpack' ) . '">' . __( 'Settings', 'woocommerce' ) . '</a>',
337
  '<a href="' . esc_url( 'http://booster.io/' ) . '">' . __( 'Docs', 'woocommerce' ) . '</a>',
338
+ );
339
+ if ( 1 === apply_filters( 'wcj_get_option_filter', 1, '' ) ) {
340
+ $custom_links[] = '<a href="' . esc_url( 'http://booster.io/plus/' ) . '">' . __( 'Unlock all', 'woocommerce' ) . '</a>';
341
+ }
342
+ return array_merge( $custom_links, $links );
343
  }
344
 
345
  /**
440
  /**
441
  * include_shortcodes.
442
  *
443
+ * @version 2.5.2
444
  */
445
  private function include_shortcodes() {
446
  //if ( 'yes' === get_option( 'wcj_shortcodes_enabled', 'no' ) ) {
452
  include_once( 'includes/shortcodes/class-wcj-order-items-shortcodes.php' );
453
  include_once( 'includes/shortcodes/class-wcj-products-shortcodes.php' );
454
  include_once( 'includes/shortcodes/class-wcj-products-add-form-shortcodes.php' );
455
+ include_once( 'includes/shortcodes/class-wcj-input-field-shortcodes.php' );
456
  }
457
  }
458
 
459
  /**
460
  * Include modules and submodules
461
  *
462
+ * @version 2.5.2
463
  */
464
+ function include_modules() {
465
+ $modules_files = array(
466
+ 'includes/class-wcj-price-labels.php',
467
+ 'includes/class-wcj-call-for-price.php',
468
+ 'includes/class-wcj-product-listings.php',
469
+ 'includes/class-wcj-sorting.php',
470
+ 'includes/class-wcj-product-custom-info.php',
471
+ 'includes/class-wcj-product-info.php',
472
+ 'includes/class-wcj-product-add-to-cart.php',
473
+ 'includes/class-wcj-related-products.php',
474
+ 'includes/class-wcj-sku.php',
475
+ 'includes/class-wcj-product-tabs.php',
476
+ 'includes/class-wcj-product-input-fields.php',
477
+ 'includes/class-wcj-product-bulk-price-converter.php',
478
+ 'includes/class-wcj-purchase-data.php',
479
+ 'includes/class-wcj-product-bookings.php',
480
+ 'includes/class-wcj-crowdfunding.php',
481
+ 'includes/class-wcj-wholesale-price.php',
482
+ 'includes/class-wcj-product-open-pricing.php',
483
+ 'includes/class-wcj-price-by-user-role.php',
484
+ 'includes/class-wcj-product-price-by-formula.php',
485
+ 'includes/class-wcj-product-images.php',
486
+ 'includes/class-wcj-product-by-country.php',
487
+ 'includes/class-wcj-product-by-user.php',
488
+ 'includes/class-wcj-add-to-cart.php',
489
+ 'includes/class-wcj-more-button-labels.php',
490
+ 'includes/class-wcj-cart.php',
491
+ 'includes/class-wcj-empty-cart-button.php',
492
+ 'includes/class-wcj-mini-cart.php',
493
+ 'includes/class-wcj-checkout-core-fields.php',
494
+ 'includes/class-wcj-checkout-custom-fields.php',
495
+ 'includes/class-wcj-checkout-files-upload.php',
496
+ 'includes/class-wcj-checkout-custom-info.php',
497
+ 'includes/class-wcj-payment-gateways.php',
498
+ 'includes/class-wcj-payment-gateways-icons.php',
499
+ 'includes/class-wcj-payment-gateways-fees.php',
500
+ 'includes/class-wcj-payment-gateways-per-category.php',
501
+ 'includes/class-wcj-payment-gateways-currency.php',
502
+ 'includes/class-wcj-payment-gateways-min-max.php',
503
+ 'includes/class-wcj-payment-gateways-by-country.php',
504
+ 'includes/class-wcj-shipping.php',
505
+ 'includes/class-wcj-shipping-calculator.php',
506
+ 'includes/class-wcj-address-formats.php',
507
+ 'includes/class-wcj-orders.php',
508
+ 'includes/class-wcj-order-numbers.php',
509
+ 'includes/class-wcj-order-custom-statuses.php',
510
+ // 'includes/class-wcj-pdf-invoices.php',
511
+ 'includes/class-wcj-pdf-invoicing.php',
512
+ 'includes/class-wcj-emails.php',
513
+ 'includes/class-wcj-currencies.php',
514
+ 'includes/class-wcj-multicurrency.php',
515
+ 'includes/class-wcj-multicurrency-product-base-price.php',
516
+ 'includes/class-wcj-currency-per-product.php',
517
+ 'includes/class-wcj-currency-external-products.php',
518
+ 'includes/class-wcj-price-by-country.php',
519
+ 'includes/class-wcj-currency-exchange-rates.php',
520
+ 'includes/class-wcj-price-formats.php',
521
+ 'includes/class-wcj-general.php',
522
+ // 'includes/class-wcj-shortcodes-module.php',
523
+ 'includes/class-wcj-eu-vat-number.php',
524
+ 'includes/class-wcj-old-slugs.php',
525
+ 'includes/class-wcj-reports.php',
526
+ 'includes/class-wcj-admin-tools.php',
527
+ 'includes/class-wcj-wpml.php',
528
+ 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-numbering.php',
529
+ 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-templates.php',
530
+ 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-styling.php',
531
+ 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-header.php',
532
+ 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-footer.php',
533
+ 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-page.php',
534
+ 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-emails.php',
535
+ 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-display.php',
536
+ // 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-general.php',
537
+ );
538
+
539
+ $this->modules = array();
540
+ foreach ( $modules_files as $module_file ) {
541
+ $module = include_once( $module_file );
542
+ $this->modules[ $module->id ] = $module;
543
+ }
544
 
545
  // do_action( 'woojetpack_modules', $settings );
546
 
547
+ // Add and Manage options
548
  if ( is_admin() ) {
549
+ $this->add_options();
550
+ }
551
+ }
552
 
553
+ /**
554
+ * add_options.
555
+ *
556
+ * @version 2.5.2
557
+ * @since 2.5.2
558
+ */
559
+ function add_options() {
560
+
561
+ // Modules statuses
562
+ $submodules_classes = array(
563
+ 'WCJ_PDF_Invoicing_Display',
564
+ 'WCJ_PDF_Invoicing_Emails',
565
+ 'WCJ_PDF_Invoicing_Footer',
566
+ 'WCJ_PDF_Invoicing_Header',
567
+ 'WCJ_PDF_Invoicing_Numbering',
568
+ 'WCJ_PDF_Invoicing_Page',
569
+ 'WCJ_PDF_Invoicing_Styling',
570
+ 'WCJ_PDF_Invoicing_Templates',
571
+ );
572
 
573
+ foreach ( $this->modules as $module ) {
 
 
 
574
 
575
+ if ( ! in_array( get_class( $module ), $submodules_classes ) ) {
576
+ $status_settings = $module->add_enable_module_setting( array() );
577
+ $this->module_statuses[] = $status_settings[1];
578
+ }
579
 
580
+ if ( get_option( 'booster_for_woocommerce_version' ) === $this->version ) {
581
+ continue;
582
+ }
583
 
584
+ $values = $module->get_settings();
585
+
586
+ // Adding options
587
+ foreach ( $values as $value ) {
588
+ if ( isset( $value['default'] ) && isset( $value['id'] ) ) {
589
+
590
+ $autoload = isset( $value['autoload'] ) ? (bool) $value['autoload'] : true;
591
+ add_option( $value['id'], $value['default'], '', ( $autoload ? 'yes' : 'no' ) );
592
+
593
+ /* if ( $this->is_wpml_value( $module, $value ) ) {
594
+ $wpml_keys[] = $value['id'];
595
+ } */
596
+ }
597
+ }
598
+ }
599
+
600
+ if ( get_option( 'booster_for_woocommerce_version' ) !== $this->version ) {
601
+ update_option( 'booster_for_woocommerce_version', $this->version );
602
+ }
603
+ }
604
 
605
+ /**
606
+ * manage_options_import.
607
+ *
608
+ * @version 2.5.2
609
+ * @since 2.5.2
610
+ */
611
+ function manage_options_import() {
612
+ global $wcj_notice;
613
+ if( ! isset( $_FILES['booster_import_settings_file']['tmp_name'] ) || '' == $_FILES['booster_import_settings_file']['tmp_name'] ) {
614
+ $wcj_notice .= __( 'Please upload a file to import!', 'woocommerce-jetpack' );
615
+ $import_settings = array();
616
+ unset( $_POST['booster_import_settings'] );
617
+ } else {
618
+ $import_counter = 0;
619
+ $import_settings = file_get_contents( $_FILES['booster_import_settings_file']['tmp_name'] );
620
+ $import_settings = explode( PHP_EOL, $import_settings );
621
+ if ( ! is_array( $import_settings ) || 2 !== count( $import_settings ) ) {
622
+ $wcj_notice .= __( 'Wrong file format!', 'woocommerce-jetpack' );
623
+ } else {
624
+ $import_header = $import_settings[0];
625
+ $required_header = 'Booster for WooCommerce';
626
+ if ( $required_header !== substr( $import_header, 0, strlen( $required_header ) ) ) {
627
+ $wcj_notice .= __( 'Wrong file format!', 'woocommerce-jetpack' );
628
+ } else {
629
+ $import_settings = json_decode( $import_settings[1], true );
630
+ foreach ( $import_settings as $import_key => $import_setting ) {
631
+ update_option( $import_key, $import_setting );
632
+ $import_counter++;
633
+ }
634
+ $wcj_notice .= sprintf( __( '%d options successfully imported.', 'woocommerce-jetpack' ), $import_counter );
635
+ }
636
+ }
637
+ }
638
+ }
639
 
640
+ /**
641
+ * manage_options_export.
642
+ *
643
+ * @version 2.5.2
644
+ * @since 2.5.2
645
+ */
646
+ function manage_options_export() {
647
+ $export_settings = array();
648
+ $export_counter = array();
649
+ foreach ( $this->modules as $module ) {
650
+ $values = $module->get_settings();
651
+ foreach ( $values as $value ) {
652
+ if ( isset( $value['default'] ) && isset( $value['id'] ) ) {
653
+ if ( isset ( $_POST['booster_export_settings'] ) ) {
654
+ $export_settings[ $value['id'] ] = get_option( $value['id'], $value['default'] );
655
+ if ( ! isset( $export_counter[ $module->short_desc ] ) ) {
656
+ $export_counter[ $module->short_desc ] = 0;
657
+ }
658
+ $export_counter[ $module->short_desc ]++;
659
  }
660
  }
661
  }
662
+ }
663
+ $export_settings = json_encode( $export_settings );
664
+ $export_settings = 'Booster for WooCommerce v' . get_option( 'booster_for_woocommerce_version', 'NA' ) . PHP_EOL . $export_settings;
665
+ header( "Content-Type: application/octet-stream" );
666
+ header( "Content-Disposition: attachment; filename=booster_settings.txt" );
667
+ header( "Content-Type: application/octet-stream" );
668
+ header( "Content-Type: application/download" );
669
+ header( "Content-Description: File Transfer" );
670
+ header( "Content-Length: " . strlen( $export_settings ) );
671
+ echo $export_settings;
672
+ wcj_log( $export_counter );
673
+ die();
674
+ }
675
 
676
+ /**
677
+ * manage_options_reset.
678
+ *
679
+ * @version 2.5.2
680
+ * @since 2.5.2
681
+ */
682
+ function manage_options_reset() {
683
+ global $wcj_notice;
684
+ $delete_counter = 0;
685
+ foreach ( $this->modules as $module ) {
686
+ $values = $module->get_settings();
687
+ foreach ( $values as $value ) {
688
+ if ( isset( $value['id'] ) ) {
689
+ if ( isset ( $_POST['booster_reset_settings'] ) ) {
690
+ require_once( ABSPATH . 'wp-includes/pluggable.php' );
691
+ if ( wcj_is_user_role( 'administrator' ) ) {
692
+ delete_option( $value['id'] );
693
+ $delete_counter++;
694
+ }
695
+ }
696
+ }
697
  }
698
  }
699
+ if ( $delete_counter > 0 ) {
700
+ $wcj_notice .= sprintf( __( '%d options successfully deleted.', 'woocommerce-jetpack' ), $delete_counter );
701
+ }
702
  }
703
 
704
  /**