Booster for WooCommerce - Version 2.3.0

Version Description

  • 01/10/2015 =
  • Fix - time function calls replaced with current_time in: crowdfunding module and shortcode, invoicing, stock report.
  • Dev - WCJ_Module code refactoring.
  • Dev - Shortcodes - Orders - [wcj_order_checkout_field] shortcode modified. [wcj_order_custom_meta_field] depreciated (now duplicates [wcj_order_checkout_field]).
  • Dev - PAYMENT GATEWAYS category added and modules renamed.
  • Dev - PAYMENT GATEWAYS - Gateways Currency - Initial module release.
  • Dev - PAYMENT GATEWAYS - Gateways Fees and Discounts - "Fee (or discount) type" option unlocked.
  • Dev - PAYMENT GATEWAYS - Custom Gateways - Renaming Jetpack to Booster continued.
  • Fix - PRICES & CURRENCIES - Currency for External Products - Additional product object validation added.
  • Fix - PRICES & CURRENCIES - Prices and Currencies by Country - Variable product price bug fixed.
  • Fix - PRICES & CURRENCIES - Prices and Currencies by Country - Price by Country on per Product Basis - Variable product bug fixed.
  • Dev - PRICES & CURRENCIES - Prices and Currencies by Country - Exchange rates moved to new module.
  • Dev - PRICES & CURRENCIES - Prices and Currencies by Country - [wcj_country_select_drop_down_list] shortcode - option to limit country list added.
  • Dev - PRICES & CURRENCIES - Prices and Currencies by Country - Code refactoring.
  • Dev - PRICES & CURRENCIES - Currency Exchange Rates - Initial module release (works with Gateways Currency and Prices and Currencies by Country modules).
  • Dev - PRICES & CURRENCIES - Bulk Price Converter - Code refactoring; tool link added to module settings; tool visualisation html slightly modified.
  • Dev - PRICES & CURRENCIES - Currency for External Products - Code refactoring.
  • Fix - BUTTON & PRICE LABELS - Custom Price Labels - Labels not showing in ajax, fixed.
  • Dev - PRODUCTS - Product Input Fields - List of available field types extended (select, radio, datepicker, timepicker etc.).
  • Fix - CART & CHECKOUT - Checkout Custom Fields - Add new order from back end bug fixed.
  • Dev - CART & CHECKOUT - Checkout Custom Fields - List of available field types extended (select, radio etc.).
  • Dev - CART & CHECKOUT - Checkout Custom Fields - Major code refactoring.
  • Fix - PDF Invoicing - "Cannot redeclare class TCPDF_FONT_DATA" warning fixed.
  • Fix - PDF Invoicing - "TCPDF ERROR: [Image] Unable to get the size of the image" fixed.
  • Dev - PDF Invoicing - Manual invoice creation option added (in invoicing display).
  • Dev - PDF Invoicing - Code refactoring.
  • Dev - PDF Invoicing - "powered by" removed in invoicing header.
  • Dev - PDF Invoicing - Manual invoice create/delete option added.
  • Dev - PDF Invoicing - Numbering - Code refactoring; "Renumerate Invoices" tool link added to submodule settings.
  • Dev - PDF Invoicing - Renaming from Jetpack continued in "Booster - Renumerate Invoices".
  • Dev - PDF Invoicing - TCPDF library loading only on PDF creation.
  • Fix - EMAILS & MISC. - Reports - Stock reports - Code refactoring in gather_orders_data function - now no errors on gathering data in shops with large number of orders.
  • Dev - EMAILS & MISC. - Reports - Stock reports - Category column added.
  • Dev - EMAILS & MISC. - Reports - "Booster: Product Sales" report added.
Download this release

Release Info

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

Code changes from version 2.2.9 to 2.3.0

Files changed (48) hide show
  1. includes/admin/wcj-modules-cats.php +10 -1
  2. includes/class-wcj-add-to-cart.php +1 -1
  3. includes/class-wcj-checkout-custom-fields.php +206 -119
  4. includes/class-wcj-crowdfunding.php +5 -3
  5. includes/class-wcj-currency-exchange-rates.php +134 -0
  6. includes/class-wcj-currency-external-products.php +73 -86
  7. includes/class-wcj-payment-gateways-currency.php +234 -0
  8. includes/class-wcj-payment-gateways-fees.php +16 -15
  9. includes/class-wcj-payment-gateways-icons.php +4 -2
  10. includes/class-wcj-payment-gateways-per-category.php +21 -19
  11. includes/class-wcj-payment-gateways.php +3 -3
  12. includes/class-wcj-pdf-invoicing.php +103 -55
  13. includes/class-wcj-price-by-country.php +55 -62
  14. includes/class-wcj-price-labels.php +8 -7
  15. includes/class-wcj-product-bulk-price-converter.php +114 -141
  16. includes/class-wcj-product-input-fields.php +97 -96
  17. includes/class-wcj-product-tabs.php +1 -1
  18. includes/class-wcj-reports.php +41 -13
  19. includes/classes/class-wcj-invoice.php +35 -25
  20. includes/classes/class-wcj-module.php +15 -8
  21. includes/classes/class-wcj-pdf-invoice.php +9 -53
  22. includes/classes/class-wcj-tcpdf.php +66 -0
  23. includes/css/jquery.timepicker.min.css +11 -0
  24. includes/exchange-rates/class-wcj-exchange-rates-crons.php +181 -0
  25. includes/{price-by-country → exchange-rates}/class-wcj-exchange-rates.php +27 -23
  26. includes/functions/wcj-functions.php +26 -7
  27. includes/gateways/class-wc-gateway-wcj-custom.php +8 -3
  28. includes/input-fields/class-wcj-product-input-fields-abstract.php +143 -28
  29. includes/js/checkout.js +3 -3
  30. includes/js/jquery.timepicker.min.js +10 -0
  31. includes/js/wcj-datepicker.js +1 -0
  32. includes/lib/tcpdf_min/config/tcpdf_config.php +2 -1
  33. includes/lib/tcpdf_min/include/tcpdf_font_data.php +4 -0
  34. includes/pdf-invoices/class-wcj-pdf-invoicing-renumerate-tool.php +8 -6
  35. includes/pdf-invoices/settings/class-wcj-pdf-invoicing-display.php +84 -66
  36. includes/pdf-invoices/settings/class-wcj-pdf-invoicing-footer.php +9 -10
  37. includes/pdf-invoices/settings/class-wcj-pdf-invoicing-header.php +49 -56
  38. includes/pdf-invoices/settings/class-wcj-pdf-invoicing-numbering.php +47 -44
  39. includes/price-by-country/class-wcj-exchange-rates-crons.php +0 -130
  40. includes/price-by-country/class-wcj-price-by-country-core.php +42 -17
  41. includes/price-by-country/class-wcj-price-by-country-local.php +0 -2
  42. includes/reports/wcj-class-reports-sales.php +168 -0
  43. includes/reports/wcj-class-reports-stock.php +56 -39
  44. includes/shortcodes/class-wcj-general-shortcodes.php +19 -4
  45. includes/shortcodes/class-wcj-orders-shortcodes.php +9 -9
  46. includes/shortcodes/class-wcj-products-shortcodes.php +3 -3
  47. readme.txt +42 -2
  48. woocommerce-jetpack.php +51 -7
includes/admin/wcj-modules-cats.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Modules Array.
6
  *
7
- * @version 2.2.6
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
@@ -30,6 +30,7 @@ return array(
30
  'currency_external_products',
31
  'bulk_price_converter',
32
  'wholesale_price',
 
33
  ),
34
  ),
35
 
@@ -72,10 +73,18 @@ return array(
72
  'checkout_core_fields',
73
  'checkout_custom_fields',
74
  'checkout_custom_info',
 
 
 
 
 
 
 
75
  'payment_gateways',
76
  'payment_gateways_icons',
77
  'payment_gateways_fees',
78
  'payment_gateways_per_category',
 
79
  ),
80
  ),
81
 
4
  *
5
  * The WooCommerce Modules Array.
6
  *
7
+ * @version 2.3.0
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
30
  'currency_external_products',
31
  'bulk_price_converter',
32
  'wholesale_price',
33
+ 'currency_exchange_rates',
34
  ),
35
  ),
36
 
73
  'checkout_core_fields',
74
  'checkout_custom_fields',
75
  'checkout_custom_info',
76
+ ),
77
+ ),
78
+
79
+ 'payment_gateways' => array(
80
+ 'label' => __( 'Payment Gateways', 'woocommerce-jetpack' ),
81
+ 'default_cat_id' => 'payment_gateways',
82
+ 'all_cat_ids' => array(
83
  'payment_gateways',
84
  'payment_gateways_icons',
85
  'payment_gateways_fees',
86
  'payment_gateways_per_category',
87
+ 'payment_gateways_currency',
88
  ),
89
  ),
90
 
includes/class-wcj-add-to-cart.php CHANGED
@@ -241,7 +241,7 @@ class WCJ_Add_To_Cart {
241
  ),
242
  'css' => 'width:100px;',
243
  ),
244
- );
245
 
246
  $product_cats = array();
247
  $product_categories = get_terms( 'product_cat', 'orderby=name&hide_empty=0' );
241
  ),
242
  'css' => 'width:100px;',
243
  ),
244
+ );
245
 
246
  $product_cats = array();
247
  $product_categories = get_terms( 'product_cat', 'orderby=name&hide_empty=0' );
includes/class-wcj-checkout-custom-fields.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Checkout Custom Fields class.
6
  *
7
- * @version 2.2.7
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -16,8 +16,10 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
16
 
17
  /**
18
  * Constructor.
 
 
19
  */
20
- public function __construct() {
21
 
22
  $this->id = 'checkout_custom_fields';
23
  $this->short_desc = __( 'Checkout Custom Fields', 'woocommerce-jetpack' );
@@ -26,60 +28,77 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
26
 
27
  if ( $this->is_enabled() ) {
28
 
29
- add_filter( 'woocommerce_checkout_fields', array( $this, 'add_custom_checkout_fields' ), PHP_INT_MAX );
30
 
31
- add_action( 'woocommerce_admin_order_data_after_billing_address', array( $this, 'add_custom_billing_fields_to_admin_order_display' ), PHP_INT_MAX );
32
- add_action( 'woocommerce_admin_order_data_after_shipping_address', array( $this, 'add_custom_shipping_fields_to_admin_order_display' ), PHP_INT_MAX );
33
- // add_action( 'woocommerce_admin_order_data_after_order_details', array( $this, 'add_custom_order_and_account_fields_to_admin_order_display' ), PHP_INT_MAX );
34
- add_action( 'woocommerce_admin_order_data_after_shipping_address', array( $this, 'add_custom_order_and_account_fields_to_admin_order_display' ), PHP_INT_MAX );
35
 
36
- add_action( 'woocommerce_order_details_after_order_table', array( $this, 'add_custom_billing_fields_to_admin_order_display' ), PHP_INT_MAX );
37
- add_action( 'woocommerce_order_details_after_order_table', array( $this, 'add_custom_shipping_fields_to_admin_order_display' ), PHP_INT_MAX );
38
- add_action( 'woocommerce_order_details_after_order_table', array( $this, 'add_custom_order_and_account_fields_to_admin_order_display' ), PHP_INT_MAX );
39
 
40
- add_action( 'woocommerce_email_after_order_table', array( $this, 'add_custom_fields_to_emails' ), PHP_INT_MAX, 2 );
 
41
 
42
- add_filter( 'woo_ce_order_fields', array( $this, 'add_custom_fields_to_store_exporter' ) );
43
- add_filter( 'woo_ce_order', array( $this, 'add_custom_fields_to_store_exporter_order' ), PHP_INT_MAX, 2 );
44
 
45
- add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'update_custom_checkout_fields_order_meta' ) );
 
 
 
 
46
 
47
- add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
48
- add_action( 'wp_head', array( $this, 'add_datepicker_script' ) );
 
 
49
 
50
- // add_action( 'woocommerce_order_formatted_shipping_address', array( $this, 'add_custom_shipping_fields_to_formatted_address' ), PHP_INT_MAX, 2 );
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  }
 
52
  }
53
 
54
  /**
55
  * add_custom_fields_to_admin_emails.
 
 
56
  */
57
- public function add_custom_fields_to_emails( $order, $sent_to_admin ) {
58
- if ( ( $sent_to_admin && 'yes' === get_option( 'wcj_checkout_custom_fields_email_all_to_admin' ) ) ||
59
- ( ! $sent_to_admin && 'yes' === get_option( 'wcj_checkout_custom_fields_email_all_to_customer' ) ) ) {
60
- $this->add_custom_billing_fields_to_admin_order_display( $order );
61
- $this->add_custom_shipping_fields_to_admin_order_display( $order );
62
- $this->add_custom_order_and_account_fields_to_admin_order_display( $order );
63
  }
64
  }
65
 
66
  /**
67
  * add_custom_fields_to_store_exporter_order.
68
  *
69
- * since 2.2.7
 
70
  */
71
- public function add_custom_fields_to_store_exporter_order( $order, $order_id ) {
72
-
73
- for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_checkout_custom_fields_total_number', 1 ) ); $i++ ) {
74
- if ( 'yes' === get_option( 'wcj_checkout_custom_field_enabled_' . $i ) ) {
75
-
76
- $the_section = get_option( 'wcj_checkout_custom_field_section_' . $i );
77
- $the_key = 'wcj_checkout_field_' . $i;
78
- $the_field = $the_section . '_' . $the_key;
79
- $the_value = get_post_meta( $order_id, '_' . $the_field, true );
80
- $the_value = ( isset( $the_value['value'] ) ) ? $the_value['value'] : $the_value;
81
-
82
- $order->$the_field = $the_value;
83
  }
84
  }
85
 
@@ -92,10 +111,8 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
92
  public function add_custom_fields_to_store_exporter( $fields ) {
93
  for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_checkout_custom_fields_total_number', 1 ) ); $i++ ) {
94
  if ( 'yes' === get_option( 'wcj_checkout_custom_field_enabled_' . $i ) ) {
95
-
96
  $the_section = get_option( 'wcj_checkout_custom_field_section_' . $i );
97
  $the_key = 'wcj_checkout_field_' . $i;
98
-
99
  $fields[] = array(
100
  'name' => $the_section . '_' . $the_key,
101
  'label' => get_option( 'wcj_checkout_custom_field_label_' . $i ),
@@ -107,17 +124,40 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
107
 
108
  /**
109
  * enqueue_scripts.
110
- */
111
- public function enqueue_scripts() {
112
- wp_enqueue_script('jquery-ui-datepicker');
 
 
 
 
 
 
 
 
113
  wp_enqueue_style( 'jquery-ui-css', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  }
115
 
116
  /**
117
  * Convert the php date format string to a js date format
118
  *
119
- * https://gist.github.com/clubduece/4053820
120
- */
121
  public function date_format_php_to_js( $php_date_format ) {
122
  $date_formats_php_to_js = array(
123
  'F j, Y' => 'MM dd, yy',
@@ -130,7 +170,9 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
130
 
131
  /**
132
  * add_datepicker_script.
133
- */
 
 
134
  public function add_datepicker_script() {
135
  ?>
136
  <script>
@@ -139,6 +181,11 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
139
  dateFormat : '<?php echo $this->date_format_php_to_js( get_option( 'date_format' ) ); ?>'
140
  });
141
  });
 
 
 
 
 
142
  </script>
143
  <?php
144
  }
@@ -161,78 +208,107 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
161
 
162
  /**
163
  * update_custom_checkout_fields_order_meta.
 
 
164
  */
165
  public function update_custom_checkout_fields_order_meta( $order_id ) {
166
  for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_checkout_custom_fields_total_number', 1 ) ); $i++ ) {
167
  if ( 'yes' === get_option( 'wcj_checkout_custom_field_enabled_' . $i ) ) {
168
  $the_section = get_option( 'wcj_checkout_custom_field_section_' . $i );
169
- $option_name = $the_section . '_' . 'wcj_checkout_field_' . $i;
 
170
  if ( ! empty( $_POST[ $option_name ] ) ) {
171
- // update_post_meta( $order_id, '_' . $option_name, sanitize_text_field( $_POST[ $option_name ] ) );
172
- update_post_meta(
173
- $order_id,
174
- '_' . $option_name,
175
- array(
176
- 'value' => sanitize_text_field( $_POST[ $option_name ] ),
177
- 'label' => get_option( 'wcj_checkout_custom_field_label_' . $i ),
178
- 'section' => get_option( 'wcj_checkout_custom_field_section_' . $i ),
179
- )
180
- );
181
  }
182
  }
183
  }
184
  }
185
 
186
  /**
187
- * add_custom_billing_fields_to_admin_order_display.
 
 
 
188
  */
189
- public function add_custom_billing_fields_to_admin_order_display( $order ) {
190
- $this->add_custom_fields_to_admin_order_display( $order, 'billing' );
 
 
 
 
 
 
 
 
 
 
 
191
  }
192
 
193
  /**
194
- * add_custom_shipping_fields_to_admin_order_display.
195
  */
196
- public function add_custom_shipping_fields_to_admin_order_display( $order ) {
197
- $this->add_custom_fields_to_admin_order_display( $order, 'shipping' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
198
  }
199
 
200
  /**
201
- * add_custom_order_and_account_fields_to_admin_order_display.
202
  */
203
- public function add_custom_order_and_account_fields_to_admin_order_display( $order ) {
204
- $this->add_custom_fields_to_admin_order_display( $order, 'order' );
205
- $this->add_custom_fields_to_admin_order_display( $order, 'account' );
206
  }
207
 
208
  /**
209
- * add_custom_fields_to_admin_order_display.
210
  */
211
- public function add_custom_fields_to_admin_order_display( $order, $section ) {
 
 
212
 
213
- $post_meta = get_post_meta( $order->id );//, $post_meta_name, false );
214
- foreach( $post_meta as $key => $values ) {
215
- // $value = unserialize( $values[0] );
216
- $value = maybe_unserialize( $values[0] );
217
- // foreach( $values as $value ) {
218
- if ( isset( $value['section'] ) && $section === $value['section'] ) {
219
- if ( isset( $value['value'] ) && '' != $value['value'] ) {
220
- $the_label = $value['label'];
221
- if ( '' != $the_label )
222
- $the_label = '<strong>' . $the_label . ':</strong> ';
223
- echo '<p>' . $the_label . $value['value'] . '</p>';
224
- }
225
- }
226
- // }
227
- }
228
  }
229
 
230
  /**
231
  * add_custom_checkout_fields.
 
 
232
  */
233
  public function add_custom_checkout_fields( $fields ) {
234
 
235
- for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_checkout_custom_fields_total_number', 1 ) ); $i++ ) {
236
 
237
  if ( 'yes' === get_option( 'wcj_checkout_custom_field_enabled_' . $i ) ) {
238
 
@@ -244,7 +320,6 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
244
  $product_categories = get_the_terms( $values['product_id'], 'product_cat' );
245
  if ( empty( $product_categories ) ) continue;
246
  foreach( $product_categories as $product_category ) {
247
- // if ( in_array( $product_category->term_id, $cats_in ) ) {
248
  if ( in_array( $product_category->term_id, $categories_in ) ) {
249
  $do_skip = false;
250
  break;
@@ -257,23 +332,38 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
257
 
258
  $the_type = get_option( 'wcj_checkout_custom_field_type_' . $i );
259
  $custom_attributes = array();
260
- if ( 'datepicker' === $the_type ) {
 
 
 
 
 
261
  $the_type = 'text';
262
- $custom_attributes['display'] = 'date';
263
  }
264
  $the_section = get_option( 'wcj_checkout_custom_field_section_' . $i );
265
  $the_key = 'wcj_checkout_field_' . $i;
266
 
267
- $fields[ $the_section ][ $the_section . '_' . $the_key ] =
268
- array(
269
- 'type' => $the_type,
270
- 'label' => get_option( 'wcj_checkout_custom_field_label_' . $i ),
271
- 'placeholder' => get_option( 'wcj_checkout_custom_field_placeholder_' . $i ),
272
- 'required' => ( 'yes' === get_option( 'wcj_checkout_custom_field_required_' . $i ) ) ? true : false,
273
- 'custom_attributes' => $custom_attributes,
274
- 'clear' => ( 'yes' === get_option( 'wcj_checkout_custom_field_clear_' . $i ) ) ? true : false,
275
- 'class' => array( get_option( 'wcj_checkout_custom_field_class_' . $i ), ),
276
- );
 
 
 
 
 
 
 
 
 
 
 
277
  }
278
  }
279
  return $fields;
@@ -281,6 +371,8 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
281
 
282
  /**
283
  * get_settings.
 
 
284
  */
285
  public function get_settings() {
286
 
@@ -363,14 +455,28 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
363
  'options' => array(
364
  'text' => __( 'Text', 'woocommerce-jetpack' ),
365
  'textarea' => __( 'Textarea', 'woocommerce-jetpack' ),
366
- //'number' => __( 'Number', 'woocommerce-jetpack' ),
367
- 'datepicker' => __( 'Datepicker', 'woocommerce-jetpack' ),
368
  'checkbox' => __( 'Checkbox', 'woocommerce-jetpack' ),
369
- //'select' => __( 'Select', 'woocommerce-jetpack' ),
 
 
 
 
370
  'password' => __( 'Password', 'woocommerce-jetpack' ),
 
 
 
 
371
  ),
372
  'css' => 'width:200px;',
373
  ),
 
 
 
 
 
 
 
374
  array(
375
  'title' => '',
376
  'desc' => __( 'required', 'woocommerce-jetpack' ),
@@ -446,16 +552,6 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
446
  'type' => 'checkbox',
447
  ),
448
 
449
- /* array(
450
- 'title' => '',
451
- 'desc' => __( 'categories', 'woocommerce-jetpack' ),
452
- 'desc_tip' => __( 'Comma separated list of product categories IDs', 'woocommerce-jetpack' ),
453
- 'id' => 'wcj_checkout_custom_field_cats_in_' . $i,
454
- 'default' => '',
455
- 'css' => 'width:400px;',
456
- 'type' => 'text',
457
- ), */
458
-
459
  array(
460
  'title' => '',
461
  'desc' => __( 'categories', 'woocommerce-jetpack' ),
@@ -468,15 +564,6 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
468
  'options' => $product_cats,
469
  ),
470
 
471
- /**
472
- array(
473
- 'title' => '',
474
- 'desc' => __( 'position', 'woocommerce-jetpack' ),
475
- 'id' => 'wcj_checkout_custom_field_position_' . $i,
476
- 'default' => 20,
477
- 'type' => 'number',
478
- ),
479
- /**/
480
  )
481
  );
482
  }
@@ -490,4 +577,4 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
490
 
491
  endif;
492
 
493
- return new WCJ_Checkout_Custom_Fields();
4
  *
5
  * The WooCommerce Jetpack Checkout Custom Fields class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
16
 
17
  /**
18
  * Constructor.
19
+ *
20
+ * @version 2.3.0
21
  */
22
+ function __construct() {
23
 
24
  $this->id = 'checkout_custom_fields';
25
  $this->short_desc = __( 'Checkout Custom Fields', 'woocommerce-jetpack' );
28
 
29
  if ( $this->is_enabled() ) {
30
 
31
+ add_filter( 'woocommerce_checkout_fields', array( $this, 'add_custom_checkout_fields' ), PHP_INT_MAX );
32
 
33
+ add_action( 'woocommerce_admin_billing_fields', array( $this, 'add_custom_billing_fields_to_admin_order_display' ), PHP_INT_MAX );
34
+ add_action( 'woocommerce_admin_shipping_fields', array( $this, 'add_custom_shipping_fields_to_admin_order_display' ), PHP_INT_MAX );
35
+ add_action( 'woocommerce_admin_shipping_fields', array( $this, 'add_custom_order_and_account_fields_to_admin_order_display' ), PHP_INT_MAX );
 
36
 
37
+ add_action( 'woocommerce_order_details_after_order_table', array( $this, 'add_custom_fields_to_order_display' ), PHP_INT_MAX );
38
+ add_action( 'woocommerce_email_after_order_table', array( $this, 'add_custom_fields_to_emails' ), PHP_INT_MAX, 2 );
 
39
 
40
+ add_filter( 'woo_ce_order_fields', array( $this, 'add_custom_fields_to_store_exporter' ) );
41
+ add_filter( 'woo_ce_order', array( $this, 'add_custom_fields_to_store_exporter_order' ), PHP_INT_MAX, 2 );
42
 
43
+ add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'update_custom_checkout_fields_order_meta' ) );
 
44
 
45
+ /* add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
46
+ // add_action( 'wp_head', array( $this, 'add_datepicker_script' ) );
47
+ add_action( 'init', array( $this, 'register_script' ) );
48
+ */
49
+ // add_action( 'woocommerce_order_formatted_shipping_address', array( $this, 'add_custom_shipping_fields_to_formatted_address' ), PHP_INT_MAX, 2 );
50
 
51
+ // add_filter( 'woocommerce_form_field_' . 'number', array( $this, 'woocommerce_form_field_type_number' ), PHP_INT_MAX, 4 );
52
+ add_filter( 'woocommerce_form_field_' . 'text', array( $this, 'woocommerce_form_field_type_number' ), PHP_INT_MAX, 4 );
53
+ }
54
+ }
55
 
56
+ /**
57
+ * woocommerce_form_field_type_number.
58
+ *
59
+ * @version 2.3.0
60
+ * @since 2.3.0
61
+ */
62
+ function woocommerce_form_field_type_number( $field, $key, $args, $value ) {
63
+ /* $args['input_class'] = array();
64
+ $args['maxlength'] = '';
65
+ $custom_attributes = array();
66
+ $field = '<input type="number" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) .'" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" '.$args['maxlength'].' value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
67
+ return $field; */
68
+ if ( isset( $args['custom_attributes']['display'] ) && 'number' === $args['custom_attributes']['display'] ) {
69
+ $field = str_replace( '<input type="text" ', '<input type="number" ', $field );
70
  }
71
+ return $field;
72
  }
73
 
74
  /**
75
  * add_custom_fields_to_admin_emails.
76
+ *
77
+ * @version 2.3.0
78
  */
79
+ function add_custom_fields_to_emails( $order, $sent_to_admin ) {
80
+ if (
81
+ ( $sent_to_admin && 'yes' === get_option( 'wcj_checkout_custom_fields_email_all_to_admin' ) ) ||
82
+ ( ! $sent_to_admin && 'yes' === get_option( 'wcj_checkout_custom_fields_email_all_to_customer' ) )
83
+ ) {
84
+ $this->add_custom_fields_to_order_display( $order );
85
  }
86
  }
87
 
88
  /**
89
  * add_custom_fields_to_store_exporter_order.
90
  *
91
+ * @version 2.3.0
92
+ * @since 2.2.7
93
  */
94
+ function add_custom_fields_to_store_exporter_order( $order, $order_id ) {
95
+ $post_meta = get_post_meta( $order_id );
96
+ foreach( $post_meta as $key => $values ) {
97
+ if ( false !== strpos( $key, 'wcj_checkout_field_' ) && isset( $values[0] ) ) {
98
+ if ( false !== strpos( $key, '_label_' ) ) {
99
+ continue;
100
+ }
101
+ $order->$key = isset( $values[0]['value'] ) ? $values[0]['value'] : $values[0];
 
 
 
 
102
  }
103
  }
104
 
111
  public function add_custom_fields_to_store_exporter( $fields ) {
112
  for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_checkout_custom_fields_total_number', 1 ) ); $i++ ) {
113
  if ( 'yes' === get_option( 'wcj_checkout_custom_field_enabled_' . $i ) ) {
 
114
  $the_section = get_option( 'wcj_checkout_custom_field_section_' . $i );
115
  $the_key = 'wcj_checkout_field_' . $i;
 
116
  $fields[] = array(
117
  'name' => $the_section . '_' . $the_key,
118
  'label' => get_option( 'wcj_checkout_custom_field_label_' . $i ),
124
 
125
  /**
126
  * enqueue_scripts.
127
+ *
128
+ * @version 2.3.0
129
+ *
130
+ function enqueue_scripts() {
131
+ wp_enqueue_script( 'jquery-ui-datepicker' );
132
+ wp_enqueue_script( 'jquery-ui-timepicker' );
133
+ wp_enqueue_script( 'wcj-datepicker', wcj_plugin_url() . '/includes/js/wcj-datepicker.js',
134
+ array( 'jquery' ),
135
+ false,
136
+ true );
137
+
138
  wp_enqueue_style( 'jquery-ui-css', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
139
+ wp_enqueue_style( 'wcj-timepicker', wcj_plugin_url() . '/includes/css/jquery.timepicker.min.css' );
140
+ }
141
+
142
+ /**
143
+ * register_script.
144
+ *
145
+ * @version 2.3.0
146
+ * @since 2.3.0
147
+ *
148
+ public function register_script() {
149
+ wp_register_script(
150
+ 'jquery-ui-timepicker',
151
+ wcj_plugin_url() . '/includes/js/jquery.timepicker.min.js',
152
+ array( 'jquery' ),
153
+ false,
154
+ true
155
+ );
156
  }
157
 
158
  /**
159
  * Convert the php date format string to a js date format
160
  *
 
 
161
  public function date_format_php_to_js( $php_date_format ) {
162
  $date_formats_php_to_js = array(
163
  'F j, Y' => 'MM dd, yy',
170
 
171
  /**
172
  * add_datepicker_script.
173
+ *
174
+ * @version 2.3.0
175
+ *
176
  public function add_datepicker_script() {
177
  ?>
178
  <script>
181
  dateFormat : '<?php echo $this->date_format_php_to_js( get_option( 'date_format' ) ); ?>'
182
  });
183
  });
184
+ jQuery(document).ready(function() {
185
+ jQuery('input[display=\'time\']').timepicker({
186
+ timeFormat: 'h:mm:ss p'
187
+ });
188
+ });
189
  </script>
190
  <?php
191
  }
208
 
209
  /**
210
  * update_custom_checkout_fields_order_meta.
211
+ *
212
+ * @version 2.3.0
213
  */
214
  public function update_custom_checkout_fields_order_meta( $order_id ) {
215
  for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_checkout_custom_fields_total_number', 1 ) ); $i++ ) {
216
  if ( 'yes' === get_option( 'wcj_checkout_custom_field_enabled_' . $i ) ) {
217
  $the_section = get_option( 'wcj_checkout_custom_field_section_' . $i );
218
+ $option_name = $the_section . '_' . 'wcj_checkout_field_' . $i;
219
+ $option_name_label = $the_section . '_' . 'wcj_checkout_field_label_' . $i;
220
  if ( ! empty( $_POST[ $option_name ] ) ) {
221
+ update_post_meta( $order_id, '_' . $option_name_label, get_option( 'wcj_checkout_custom_field_label_' . $i ) );
222
+ update_post_meta( $order_id, '_' . $option_name, wc_clean( $_POST[ $option_name ] ) );
 
 
 
 
 
 
 
 
223
  }
224
  }
225
  }
226
  }
227
 
228
  /**
229
+ * add_custom_fields_to_order_display.
230
+ *
231
+ * @version 2.3.0
232
+ * @since 2.3.0
233
  */
234
+ function add_custom_fields_to_order_display( $order ) {
235
+ $post_meta = get_post_meta( $order->id );
236
+ foreach( $post_meta as $key => $values ) {
237
+ if ( false !== strpos( $key, 'wcj_checkout_field_' ) && isset( $values[0] ) ) {
238
+ if ( false !== strpos( $key, '_label_' ) ) {
239
+ continue;
240
+ }
241
+ $the_label_key = str_replace( 'wcj_checkout_field_', 'wcj_checkout_field_label_', $key );
242
+ if ( isset( $post_meta[ $the_label_key ][0] ) ) echo $post_meta[ $the_label_key ][0] . ': ';
243
+ else if ( isset( $post_meta[ $the_label_key ][0]['label'] ) ) echo $post_meta[ $the_label_key ][0]['label'] . ': ';
244
+ echo isset( $values[0]['value'] ) ? $values[0]['value'] : $values[0];
245
+ }
246
+ }
247
  }
248
 
249
  /**
250
+ * add_woocommerce_admin_fields.
251
  */
252
+ public function add_woocommerce_admin_fields( $fields, $section ) {
253
+ for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_checkout_custom_fields_total_number', 1 ) ); $i++ ) {
254
+ if ( 'yes' === get_option( 'wcj_checkout_custom_field_enabled_' . $i ) ) {
255
+ $the_type = get_option( 'wcj_checkout_custom_field_type_' . $i );
256
+ if ( 'datepicker' === $the_type || 'timepicker' === $the_type || 'number' === $the_type ) {
257
+ $the_type = 'text';
258
+ }
259
+ $the_section = get_option( 'wcj_checkout_custom_field_section_' . $i );
260
+ if ( $section != $the_section ) continue;
261
+ $the_key = 'wcj_checkout_field_' . $i;
262
+ $the_key_label = 'wcj_checkout_field_label_' . $i;
263
+
264
+ $the_meta = get_post_meta( get_the_ID(), '_' . $section . '_' . $the_key, true );
265
+ if ( is_array( $the_meta ) ) {
266
+ // Converting from before v2.3.0
267
+ if ( isset( $the_meta['value'] ) ) update_post_meta( get_the_ID(), '_' . $section . '_' . $the_key, $the_meta['value'] );
268
+ if ( isset( $the_meta['label'] ) ) update_post_meta( get_the_ID(), '_' . $section . '_' . $the_key_label, $the_meta['label'] );
269
+ }
270
+
271
+ $fields[ $the_key ] = array(
272
+ 'type' => $the_type,
273
+ 'label' => get_option( 'wcj_checkout_custom_field_label_' . $i ),//@todo label from post meta?
274
+ 'show' => true,
275
+ );
276
+ }
277
+ }
278
+ return $fields;
279
  }
280
 
281
  /**
282
+ * add_custom_billing_fields_to_admin_order_display.
283
  */
284
+ public function add_custom_billing_fields_to_admin_order_display( $fields ) {
285
+ return $this->add_woocommerce_admin_fields( $fields, 'billing' );
 
286
  }
287
 
288
  /**
289
+ * add_custom_shipping_fields_to_admin_order_display.
290
  */
291
+ public function add_custom_shipping_fields_to_admin_order_display( $fields ) {
292
+ return $this->add_woocommerce_admin_fields( $fields, 'shipping' );
293
+ }
294
 
295
+ /**
296
+ * add_custom_order_and_account_fields_to_admin_order_display
297
+ */
298
+ public function add_custom_order_and_account_fields_to_admin_order_display( $fields ) {
299
+ $fields = $this->add_woocommerce_admin_fields( $fields, 'order' );
300
+ $fields = $this->add_woocommerce_admin_fields( $fields, 'account' );
301
+ return $fields;
 
 
 
 
 
 
 
 
302
  }
303
 
304
  /**
305
  * add_custom_checkout_fields.
306
+ *
307
+ * @version 2.3.0
308
  */
309
  public function add_custom_checkout_fields( $fields ) {
310
 
311
+ for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_checkout_custom_fields_total_number', 1 ) ); $i++ ) {
312
 
313
  if ( 'yes' === get_option( 'wcj_checkout_custom_field_enabled_' . $i ) ) {
314
 
320
  $product_categories = get_the_terms( $values['product_id'], 'product_cat' );
321
  if ( empty( $product_categories ) ) continue;
322
  foreach( $product_categories as $product_category ) {
 
323
  if ( in_array( $product_category->term_id, $categories_in ) ) {
324
  $do_skip = false;
325
  break;
332
 
333
  $the_type = get_option( 'wcj_checkout_custom_field_type_' . $i );
334
  $custom_attributes = array();
335
+ if ( 'datepicker' === $the_type || 'timepicker' === $the_type || 'number' === $the_type ) {
336
+ if ( 'datepicker' === $the_type || 'timepicker' === $the_type ) {
337
+ $custom_attributes['display'] = ( 'datepicker' === $the_type ) ? 'date' : 'time';
338
+ } else/* if ( 'number' === $the_type ) */ {
339
+ $custom_attributes['display'] = $the_type;
340
+ }
341
  $the_type = 'text';
 
342
  }
343
  $the_section = get_option( 'wcj_checkout_custom_field_section_' . $i );
344
  $the_key = 'wcj_checkout_field_' . $i;
345
 
346
+ $the_field = array(
347
+ 'type' => $the_type,
348
+ 'label' => get_option( 'wcj_checkout_custom_field_label_' . $i ),
349
+ 'placeholder' => get_option( 'wcj_checkout_custom_field_placeholder_' . $i ),
350
+ 'required' => ( 'yes' === get_option( 'wcj_checkout_custom_field_required_' . $i ) ) ? true : false,
351
+ 'custom_attributes' => $custom_attributes,
352
+ 'clear' => ( 'yes' === get_option( 'wcj_checkout_custom_field_clear_' . $i ) ) ? true : false,
353
+ 'class' => array( get_option( 'wcj_checkout_custom_field_class_' . $i ), ),
354
+ );
355
+
356
+ if ( 'select' === $the_type || 'radio' === $the_type ) {
357
+ $select_options_raw = get_option( 'wcj_checkout_custom_field_select_options_' . $i );
358
+ $select_options = wcj_get_select_options( $select_options_raw );
359
+ $the_field['options'] = $select_options;
360
+ if ( ! empty( $select_options ) ) {
361
+ reset( $select_options );
362
+ $the_field['default'] = key( $select_options );
363
+ }
364
+ }
365
+
366
+ $fields[ $the_section ][ $the_section . '_' . $the_key ] = $the_field;
367
  }
368
  }
369
  return $fields;
371
 
372
  /**
373
  * get_settings.
374
+ *
375
+ * @version 2.3.0
376
  */
377
  public function get_settings() {
378
 
455
  'options' => array(
456
  'text' => __( 'Text', 'woocommerce-jetpack' ),
457
  'textarea' => __( 'Textarea', 'woocommerce-jetpack' ),
458
+ 'number' => __( 'Number', 'woocommerce-jetpack' ),//custom-todo - filter
 
459
  'checkbox' => __( 'Checkbox', 'woocommerce-jetpack' ),
460
+ // 'file' => __( 'File', 'woocommerce-jetpack' ),//todo
461
+ 'datepicker' => __( 'Datepicker', 'woocommerce-jetpack' ),//custom (passed as `text`)
462
+ 'timepicker' => __( 'Timepicker', 'woocommerce-jetpack' ),//custom (passed as `text`)
463
+ 'select' => __( 'Select', 'woocommerce-jetpack' ),//?
464
+ 'radio' => __( 'Radio', 'woocommerce-jetpack' ),//?
465
  'password' => __( 'Password', 'woocommerce-jetpack' ),
466
+ 'country' => __( 'Country', 'woocommerce-jetpack' ),//
467
+ 'state' => __( 'State', 'woocommerce-jetpack' ),//
468
+ 'email' => __( 'Email', 'woocommerce-jetpack' ),//
469
+ 'tel' => __( 'Phone', 'woocommerce-jetpack' ),//
470
  ),
471
  'css' => 'width:200px;',
472
  ),
473
+ array(
474
+ 'title' => '',
475
+ 'desc' => __( 'options (only if "select" or "radio" type is selected)', 'woocommerce-jetpack' ),
476
+ 'id' => 'wcj_checkout_custom_field_select_options_' . $i,
477
+ 'default' => '',
478
+ 'type' => 'textarea',
479
+ ),
480
  array(
481
  'title' => '',
482
  'desc' => __( 'required', 'woocommerce-jetpack' ),
552
  'type' => 'checkbox',
553
  ),
554
 
 
 
 
 
 
 
 
 
 
 
555
  array(
556
  'title' => '',
557
  'desc' => __( 'categories', 'woocommerce-jetpack' ),
564
  'options' => $product_cats,
565
  ),
566
 
 
 
 
 
 
 
 
 
 
567
  )
568
  );
569
  }
577
 
578
  endif;
579
 
580
+ return new WCJ_Checkout_Custom_Fields();
includes/class-wcj-crowdfunding.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Crowdfunding class.
6
  *
7
- * @version 2.2.6
8
  * @since 2.2.6
9
  * @author Algoritmika Ltd.
10
  */
@@ -36,6 +36,8 @@ class WCJ_Crowdfunding extends WCJ_Module {
36
 
37
  /**
38
  * check_dates.
 
 
39
  */
40
  function check_dates( $purchasable, $_product ) {
41
  $goal = get_post_meta( $_product->id, '_' . 'wcj_crowdfunding_goal_sum', true );
@@ -44,8 +46,8 @@ class WCJ_Crowdfunding extends WCJ_Module {
44
  $end_date_str = get_post_meta( $_product->id, '_' . 'wcj_crowdfunding_deadline', true );
45
  $start_date = ( '' != $start_date_str ) ? strtotime( $start_date_str ) : 0;
46
  $end_date = ( '' != $end_date_str ) ? strtotime( $end_date_str ) : 0;
47
- if ( $start_date > 0 && ( $start_date - time() ) > 0 ) $purchasable = false;
48
- if ( $end_date > 0 && ( $end_date - time() ) < 0 ) $purchasable = false;
49
  }
50
  return $purchasable;
51
  }
4
  *
5
  * The WooCommerce Jetpack Crowdfunding class.
6
  *
7
+ * @version 2.3.0
8
  * @since 2.2.6
9
  * @author Algoritmika Ltd.
10
  */
36
 
37
  /**
38
  * check_dates.
39
+ *
40
+ * @version 2.3.0
41
  */
42
  function check_dates( $purchasable, $_product ) {
43
  $goal = get_post_meta( $_product->id, '_' . 'wcj_crowdfunding_goal_sum', true );
46
  $end_date_str = get_post_meta( $_product->id, '_' . 'wcj_crowdfunding_deadline', true );
47
  $start_date = ( '' != $start_date_str ) ? strtotime( $start_date_str ) : 0;
48
  $end_date = ( '' != $end_date_str ) ? strtotime( $end_date_str ) : 0;
49
+ if ( $start_date > 0 && ( $start_date - current_time( 'timestamp' ) ) > 0 ) $purchasable = false;
50
+ if ( $end_date > 0 && ( $end_date - current_time( 'timestamp' ) ) < 0 ) $purchasable = false;
51
  }
52
  return $purchasable;
53
  }
includes/class-wcj-currency-exchange-rates.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Jetpack Currency Exchange Rates
4
+ *
5
+ * The WooCommerce Jetpack Currency Exchange Rates class.
6
+ *
7
+ * @version 2.3.0
8
+ * @since 2.3.0
9
+ * @author Algoritmika Ltd.
10
+ */
11
+
12
+ if ( ! defined( 'ABSPATH' ) ) exit;
13
+
14
+ if ( ! class_exists( 'WCJ_Currency_Exchange_Rates' ) ) :
15
+
16
+ class WCJ_Currency_Exchange_Rates extends WCJ_Module {
17
+
18
+ /**
19
+ * Constructor.
20
+ */
21
+ function __construct() {
22
+
23
+ $this->id = 'currency_exchange_rates';
24
+ $this->short_desc = __( 'Currency Exchange Rates', 'woocommerce-jetpack' );
25
+ $this->desc = __( 'Automatic currency exchange rates for WooCommerce.', 'woocommerce-jetpack' );
26
+ parent::__construct();
27
+
28
+ add_filter( 'init', array( $this, 'add_hooks' ) );
29
+
30
+ if ( $this->is_enabled() ) {
31
+ include_once( 'exchange-rates/class-wcj-exchange-rates-crons.php' );
32
+ }
33
+ include_once( 'exchange-rates/class-wcj-exchange-rates.php' );
34
+ }
35
+
36
+ /**
37
+ * get_settings.
38
+ */
39
+ function get_settings() {
40
+ $settings = array();
41
+ $settings = apply_filters( 'wcj_currency_exchange_rates_settings', $settings );
42
+ return $this->add_enable_module_setting( $settings );
43
+ }
44
+
45
+ /**
46
+ * add_hooks.
47
+ */
48
+ function add_hooks() {
49
+ add_filter( 'wcj_currency_exchange_rates_settings', array( $this, 'add_currency_exchange_rates_settings' ) );
50
+ }
51
+
52
+ /**
53
+ * add_currency_pair_setting.
54
+ */
55
+ function add_currency_pair_setting( $currency_from, $currency_to, $settings ) {
56
+ if ( $currency_from != $currency_to ) {
57
+ $field_id = 'wcj_currency_exchange_rates_' . sanitize_title( $currency_from . $currency_to );
58
+ foreach ( $settings as $setting ) {
59
+ if ( $setting['id'] === $field_id ) return $settings;
60
+ }
61
+ $custom_attributes = array(
62
+ 'currency_from' => $currency_from,
63
+ 'currency_to' => $currency_to,
64
+ 'multiply_by_field_id' => $field_id,
65
+ );
66
+ $settings[] = array(
67
+ 'title' => $currency_from . ' / ' . $currency_to,
68
+ 'id' => $field_id,
69
+ 'default' => 0,
70
+ 'type' => 'exchange_rate',
71
+ 'custom_attributes' => array( 'step' => '0.000001', 'min' => '0', ),
72
+ 'custom_attributes_button' => $custom_attributes,
73
+ 'css' => 'width:100px;',
74
+ 'value' => $currency_from . '/' . $currency_to,
75
+ 'value_title' => sprintf( __( 'Grab %s rate from Yahoo.com', 'woocommerce-jetpack' ), $currency_from . '/' . $currency_to ),
76
+ );
77
+ }
78
+ return $settings;
79
+ }
80
+
81
+ /**
82
+ * add_currency_exchange_rates_settings.
83
+ */
84
+ function add_currency_exchange_rates_settings() {
85
+
86
+ $settings = array();
87
+
88
+ $settings[] = array(
89
+ 'title' => __( 'Exchange Rates', 'woocommerce-jetpack' ),
90
+ 'type' => 'title',
91
+ 'id' => 'wcj_currency_exchange_rates_options',
92
+ );
93
+
94
+ $settings[] = array(
95
+ 'title' => __( 'Exchange Rates Updates', 'woocommerce-jetpack' ),
96
+ 'id' => 'wcj_currency_exchange_rates_auto',
97
+ 'default' => 'daily',
98
+ 'type' => 'select',
99
+ 'options' => array(
100
+ // 'manual' => __( 'Enter Rates Manually', 'woocommerce-jetpack' ),
101
+ 'minutely' => __( 'Update Every Minute', 'woocommerce-jetpack' ),
102
+ 'hourly' => __( 'Update Hourly', 'woocommerce-jetpack' ),
103
+ 'twicedaily' => __( 'Update Twice Daily', 'woocommerce-jetpack' ),
104
+ 'daily' => __( 'Update Daily', 'woocommerce-jetpack' ),
105
+ 'weekly' => __( 'Update Weekly', 'woocommerce-jetpack' ),
106
+ ),
107
+ );
108
+
109
+ // Currency Pairs - Price by Country
110
+ $currency_from = get_option( 'woocommerce_currency' );
111
+ for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_price_by_country_total_groups_number', 1 ) ); $i++ ) {
112
+ $currency_to = get_option( 'wcj_price_by_country_exchange_rate_currency_group_' . $i );
113
+ $settings = $this->add_currency_pair_setting( $currency_from, $currency_to, $settings );
114
+ }
115
+ // Currency Pairs - Gateway Currency
116
+ global $woocommerce;
117
+ $available_gateways = $woocommerce->payment_gateways->payment_gateways();
118
+ foreach ( $available_gateways as $key => $gateway ) {
119
+ $currency_to = get_option( 'wcj_gateways_currency_' . $key );
120
+ $settings = $this->add_currency_pair_setting( $currency_from, $currency_to, $settings );
121
+ }
122
+
123
+ $settings[] = array(
124
+ 'type' => 'sectionend',
125
+ 'id' => 'wcj_currency_exchange_rates_options',
126
+ );
127
+
128
+ return $settings;
129
+ }
130
+ }
131
+
132
+ endif;
133
+
134
+ return new WCJ_Currency_Exchange_Rates();
includes/class-wcj-currency-external-products.php CHANGED
@@ -4,103 +4,90 @@
4
  *
5
  * The WooCommerce Jetpack Currency for External Products class.
6
  *
7
- * @class WCJ_Currency_External_Products
8
- * @version 1.0.0
9
- * @category Class
10
- * @author Algoritmika Ltd.
11
  */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
-
15
  if ( ! class_exists( 'WCJ_Currency_External_Products' ) ) :
16
-
17
- class WCJ_Currency_External_Products {
18
-
19
- /**
20
- * Constructor.
21
- */
22
- public function __construct() {
23
-
 
 
 
 
 
 
 
24
  $currencies = include( 'currencies/wcj-currencies.php' );
25
  foreach( $currencies as $data ) {
26
- $this->currency_symbols[ $data['code'] ] = $data['symbol'];
27
- $this->currency_names_and_symbols[ $data['code'] ] = $data['name'] . ' (' . $data['symbol'] . ')';
28
- }
29
-
30
- // Main hooks
31
- if ( 'yes' === get_option( 'wcj_currency_external_products_enabled' ) ) {
32
- if ( '' != get_option( 'wcj_currency_external_products_symbol' ) )
33
  add_filter( 'woocommerce_currency_symbol', array( $this, 'change_currency_symbol' ), 100, 2 );
34
- }
35
-
36
- // Settings hooks
37
- add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
38
- add_filter( 'wcj_settings_currency_external_products', array( $this, 'get_settings' ), 100 );
39
- add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
40
- }
41
-
42
- /**
43
- * change_currency_symbol.
44
- */
45
- public function change_currency_symbol( $currency_symbol, $currency ) {
46
  global $product;
47
- if ( $product && 'external' === $product->product_type )
48
  return $this->currency_symbols[ get_option( 'wcj_currency_external_products_symbol' ) ];
 
49
  return $currency_symbol;
50
- }
51
-
52
- /**
53
- * add_enabled_option.
54
- */
55
- public function add_enabled_option( $settings ) {
56
- $all_settings = $this->get_settings();
57
- $settings[] = $all_settings[1];
58
- return $settings;
59
- }
60
-
61
- /**
62
- * get_settings.
63
- */
64
- function get_settings() {
65
-
66
- $settings = array(
67
-
68
- array( 'title' => __( 'Currency for External Products Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_currency_external_products_options' ),
69
-
70
- array(
71
- 'title' => __( 'Currency for External Products', 'woocommerce-jetpack' ),
72
- 'desc' => '<strong>' . __( 'Enable Module', 'woocommerce-jetpack' ) . '</strong>',
73
- 'desc_tip' => __( 'Set different currency for external WooCommerce products.', 'woocommerce-jetpack' ),
74
- 'id' => 'wcj_currency_external_products_enabled',
75
- 'default' => 'no',
76
- 'type' => 'checkbox',
77
- ),
78
-
79
- array(
80
- 'title' => __( 'Currency Symbol', 'woocommerce-jetpack' ),
81
- 'desc' => __( 'Set currency symbol for all external products.', 'woocommerce-jetpack' ),
82
- 'desc_tip' => __( 'Set currency symbol for all external products.', 'woocommerce-jetpack' ),
83
- 'id' => 'wcj_currency_external_products_symbol',
84
- 'default' => 'EUR',
85
- 'type' => 'select',
86
  'options' => $this->currency_names_and_symbols,
87
- ),
88
-
89
- array( 'type' => 'sectionend', 'id' => 'wcj_currency_external_products_options' ),
90
- );
91
-
92
- return $settings;
93
- }
94
-
95
- /**
96
- * settings_section.
97
- */
98
- function settings_section( $sections ) {
99
- $sections['currency_external_products'] = __( 'Currency for External Products', 'woocommerce-jetpack' );
100
- return $sections;
101
- }
102
  }
103
-
104
  endif;
105
-
106
  return new WCJ_Currency_External_Products();
4
  *
5
  * The WooCommerce Jetpack Currency for External Products class.
6
  *
7
+ * @version 2.3.0
8
+ * @author Algoritmika Ltd.
 
 
9
  */
10
 
11
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
12
+
13
  if ( ! class_exists( 'WCJ_Currency_External_Products' ) ) :
14
+
15
+ class WCJ_Currency_External_Products extends WCJ_Module {
16
+
17
+ /**
18
+ * Constructor.
19
+ *
20
+ * @version 2.3.0
21
+ */
22
+ public function __construct() {
23
+
24
+ $this->id = 'currency_external_products';
25
+ $this->short_desc = __( 'Currency for External Products', 'woocommerce-jetpack' );
26
+ $this->desc = __( 'Set different currency for external WooCommerce products.', 'woocommerce-jetpack' );
27
+ parent::__construct();
28
+
29
  $currencies = include( 'currencies/wcj-currencies.php' );
30
  foreach( $currencies as $data ) {
31
+ $this->currency_symbols[ $data['code'] ] = $data['symbol'];
32
+ $this->currency_names_and_symbols[ $data['code'] ] = $data['name'] . ' (' . $data['symbol'] . ')';
33
+ }
34
+
35
+ if ( $this->is_enabled() ) {
36
+ if ( '' != get_option( 'wcj_currency_external_products_symbol' ) ) {
 
37
  add_filter( 'woocommerce_currency_symbol', array( $this, 'change_currency_symbol' ), 100, 2 );
38
+ }
39
+ }
40
+ }
41
+
42
+ /**
43
+ * change_currency_symbol.
44
+ *
45
+ * @version 2.3.0
46
+ */
47
+ public function change_currency_symbol( $currency_symbol, $currency ) {
 
 
48
  global $product;
49
+ if ( is_object( $product ) && isset( $product->product_type ) && 'external' === $product->product_type ) {
50
  return $this->currency_symbols[ get_option( 'wcj_currency_external_products_symbol' ) ];
51
+ }
52
  return $currency_symbol;
53
+ }
54
+
55
+ /**
56
+ * get_settings.
57
+ *
58
+ * @version 2.3.0
59
+ */
60
+ function get_settings() {
61
+
62
+ $settings = array(
63
+
64
+ array(
65
+ 'title' => __( 'Currency for External Products Options', 'woocommerce-jetpack' ),
66
+ 'type' => 'title',
67
+ 'desc' => '',
68
+ 'id' => 'wcj_currency_external_products_options',
69
+ ),
70
+
71
+ array(
72
+ 'title' => __( 'Currency Symbol', 'woocommerce-jetpack' ),
73
+ 'desc' => __( 'Set currency symbol for all external products.', 'woocommerce-jetpack' ),
74
+ 'desc_tip' => __( 'Set currency symbol for all external products.', 'woocommerce-jetpack' ),
75
+ 'id' => 'wcj_currency_external_products_symbol',
76
+ 'default' => 'EUR',
77
+ 'type' => 'select',
 
 
 
 
 
 
 
 
 
 
 
78
  'options' => $this->currency_names_and_symbols,
79
+ ),
80
+
81
+ array(
82
+ 'type' => 'sectionend',
83
+ 'id' => 'wcj_currency_external_products_options',
84
+ ),
85
+ );
86
+
87
+ return $this->add_enable_module_setting( $settings );
88
+ }
 
 
 
 
 
89
  }
90
+
91
  endif;
92
+
93
  return new WCJ_Currency_External_Products();
includes/class-wcj-payment-gateways-currency.php ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Jetpack Payment Gateways Currency
4
+ *
5
+ * The WooCommerce Jetpack Payment Gateways Currency class.
6
+ *
7
+ * @version 2.3.0
8
+ * @since 2.3.0
9
+ * @author Algoritmika Ltd.
10
+ */
11
+
12
+ if ( ! defined( 'ABSPATH' ) ) exit;
13
+
14
+ if ( ! class_exists( 'WCJ_Payment_Gateways_Currency' ) ) :
15
+
16
+ class WCJ_Payment_Gateways_Currency extends WCJ_Module {
17
+
18
+ /**
19
+ * Constructor.
20
+ */
21
+ function __construct() {
22
+
23
+ $this->id = 'payment_gateways_currency';
24
+ $this->short_desc = __( 'Gateways Currency', 'woocommerce-jetpack' );
25
+ $this->desc = __( 'Currency per WooCommerce payment gateway.', 'woocommerce-jetpack' );
26
+ parent::__construct();
27
+
28
+ add_filter( 'init', array( $this, 'add_hooks' ) );
29
+
30
+ if ( $this->is_enabled() ) {
31
+ add_filter( 'woocommerce_currency_symbol', array( $this, 'change_currency_symbol' ), PHP_INT_MAX, 2 );
32
+ add_filter( 'woocommerce_currency', array( $this, 'change_currency_code' ), PHP_INT_MAX, 1 );
33
+
34
+ add_filter( 'woocommerce_paypal_supported_currencies', array( $this, 'extend_paypal_supported_currencies' ), PHP_INT_MAX, 1 );
35
+
36
+ add_filter( 'woocommerce_get_price', array( $this, 'change_price_by_gateway' ), PHP_INT_MAX, 2 );
37
+
38
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_checkout_script' ) );
39
+ add_action( 'init', array( $this, 'register_script' ) );
40
+ }
41
+ }
42
+
43
+ /**
44
+ * is_cart_or_checkout.
45
+ */
46
+ function is_cart_or_checkout() {
47
+ if ( wcj_is_frontend() ) {
48
+ if ( is_cart() || is_checkout() ) return true;
49
+ }
50
+ return false;
51
+ }
52
+
53
+ /**
54
+ * change_price_by_gateway.
55
+ */
56
+ function change_price_by_gateway( $price, $product ) {
57
+ if ( $this->is_cart_or_checkout() ) {
58
+ global $woocommerce;
59
+ $current_gateway = $woocommerce->session->chosen_payment_method;
60
+ if ( '' != $current_gateway ) {
61
+ $gateway_currency_exchange_rate = get_option( 'wcj_gateways_currency_exchange_rate_' . $current_gateway );
62
+ $price = $price * $gateway_currency_exchange_rate;
63
+ }
64
+ }
65
+ return $price;
66
+ }
67
+
68
+ /**
69
+ * extend_paypal_supported_currencies.
70
+ */
71
+ function extend_paypal_supported_currencies( $supported_currencies ) {
72
+ if ( $this->is_cart_or_checkout() ) {
73
+ global $woocommerce;
74
+ $current_gateway = $woocommerce->session->chosen_payment_method;
75
+ if ( '' != $current_gateway ) {
76
+ $gateway_currency = get_option( 'wcj_gateways_currency_' . $current_gateway );
77
+ $supported_currencies[] = $gateway_currency;
78
+ }
79
+ }
80
+ return $supported_currencies;
81
+ }
82
+
83
+ /**
84
+ * change_currency_symbol.
85
+ */
86
+ public function change_currency_symbol( $currency_symbol, $currency ) {
87
+ if ( $this->is_cart_or_checkout() ) {
88
+ global $woocommerce;
89
+ $current_gateway = $woocommerce->session->chosen_payment_method;
90
+ if ( '' != $current_gateway ) {
91
+ $gateway_currency = get_option( 'wcj_gateways_currency_' . $current_gateway );
92
+ return wcj_get_currency_symbol( $gateway_currency );
93
+ }
94
+ }
95
+ return $currency_symbol;
96
+ }
97
+
98
+ /**
99
+ * change_currency_code.
100
+ */
101
+ public function change_currency_code( $currency ) {
102
+ if ( $this->is_cart_or_checkout() ) {
103
+ global $woocommerce;
104
+ $current_gateway = $woocommerce->session->chosen_payment_method;
105
+ /* $available_gateways = WC()->payment_gateways->get_available_payment_gateways();
106
+ if ( ! array_key_exists( $current_gateway, $available_gateways ) ) {
107
+ $current_gateway = get_option( 'woocommerce_default_gateway', '' );
108
+ if ( '' == $current_gateway ) {
109
+ $current_gateway = current( $available_gateways );
110
+ $current_gateway = isset( $current_gateway->id ) ? $current_gateway->id : '';
111
+ }
112
+ } */
113
+ if ( '' != $current_gateway ) {
114
+ $gateway_currency = get_option( 'wcj_gateways_currency_' . $current_gateway );
115
+ return $gateway_currency;
116
+ }
117
+ }
118
+ return $currency;
119
+ }
120
+
121
+ /**
122
+ * get_settings.
123
+ */
124
+ function get_settings() {
125
+ $settings = array();
126
+ $settings = apply_filters( 'wcj_payment_gateways_currency_settings', $settings );
127
+ return $this->add_enable_module_setting( $settings );
128
+ }
129
+
130
+ /**
131
+ * add_hooks.
132
+ */
133
+ function add_hooks() {
134
+ add_filter( 'wcj_payment_gateways_currency_settings', array( $this, 'add_currency_settings' ) );
135
+ }
136
+
137
+ /**
138
+ * register_script.
139
+ */
140
+ public function register_script() {
141
+ wp_register_script( 'wcj-payment-gateways-checkout', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/checkout.js', array( 'jquery' ), false, true );
142
+ }
143
+
144
+ /**
145
+ * enqueue_checkout_script.
146
+ */
147
+ public function enqueue_checkout_script() {
148
+ if( ! is_checkout() )
149
+ return;
150
+ wp_enqueue_script( 'wcj-payment-gateways-checkout' );
151
+ }
152
+
153
+ /**
154
+ * add_currency_settings.
155
+ */
156
+ function add_currency_settings( $settings ) {
157
+
158
+ $settings[] = array(
159
+ 'title' => __( 'Payment Gateways Currency Options', 'woocommerce-jetpack' ),
160
+ 'type' => 'title',
161
+ 'desc' => __( 'This section lets you set different currency for each payment gateway.', 'woocommerce-jetpack' ),
162
+ 'id' => 'wcj_payment_gateways_currency_options'
163
+ );
164
+
165
+ $currency_from = get_woocommerce_currency();
166
+
167
+ global $woocommerce;
168
+ $available_gateways = $woocommerce->payment_gateways->payment_gateways();
169
+ foreach ( $available_gateways as $key => $gateway ) {
170
+
171
+ $currency_to = get_option( 'wcj_gateways_currency_' . $key, get_woocommerce_currency() );
172
+ $custom_attributes = array(
173
+ 'currency_from' => $currency_from,
174
+ 'currency_to' => $currency_to,
175
+ 'multiply_by_field_id' => 'wcj_gateways_currency_exchange_rate_' . $key,
176
+ );
177
+ if ( $currency_from == $currency_to ) $custom_attributes['disabled'] = 'disabled';
178
+
179
+ $settings = array_merge( $settings, array(
180
+
181
+ array(
182
+ 'title' => $gateway->title,
183
+ // 'desc' => __( 'currency', 'woocommerce-jetpack' ),
184
+ 'id' => 'wcj_gateways_currency_' . $key,
185
+ 'default' => get_woocommerce_currency(),
186
+ 'type' => 'select',
187
+ 'options' => wcj_get_currencies_names_and_symbols(),
188
+ ),
189
+
190
+ array(
191
+ 'title' => '',
192
+ // 'desc' => __( 'exchange rate', 'woocommerce-jetpack' ) . ' ' . $currency_from . ' / ' . $currency_to,
193
+ 'id' => 'wcj_gateways_currency_exchange_rate_' . $key,
194
+ 'default' => 1,
195
+ 'type' => 'exchange_rate',
196
+ 'custom_attributes' => array( 'step' => '0.000001', 'min' => '0', ),
197
+ 'custom_attributes_button' => $custom_attributes,
198
+ 'css' => 'width:100px;',
199
+ 'value' => $currency_from . '/' . $currency_to,
200
+ 'value_title' => sprintf( __( 'Grab %s rate from Yahoo.com', 'woocommerce-jetpack' ), $currency_from . '/' . $currency_to ),
201
+ ),
202
+
203
+ ) );
204
+ }
205
+
206
+ $settings[] = array(
207
+ 'title' => __( 'Exchange Rates Updates', 'woocommerce-jetpack' ),
208
+ 'id' => 'wcj_gateways_currency_exchange_rate_update_auto',
209
+ 'default' => 'manual',
210
+ 'type' => 'select',
211
+ 'options' => array(
212
+ 'manual' => __( 'Enter Rates Manually', 'woocommerce-jetpack' ),
213
+ 'auto' => __( 'Automatically via Currency Exchange Rates module', 'woocommerce-jetpack' ),
214
+ ),
215
+ 'desc' => ( '' == apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ) ) ?
216
+ __( '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>'
217
+ :
218
+ apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
219
+ 'custom_attributes'
220
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
221
+ );
222
+
223
+ $settings[] = array(
224
+ 'type' => 'sectionend',
225
+ 'id' => 'wcj_payment_gateways_currency_options'
226
+ );
227
+
228
+ return $settings;
229
+ }
230
+ }
231
+
232
+ endif;
233
+
234
+ return new WCJ_Payment_Gateways_Currency();
includes/class-wcj-payment-gateways-fees.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Payment Gateways Fees class.
6
  *
7
- * @version 2.2.9
8
  * @since 2.2.2
9
  * @author Algoritmika Ltd.
10
  */
@@ -18,12 +18,12 @@ class WCJ_Payment_Gateways_Fees extends WCJ_Module {
18
  /**
19
  * Constructor.
20
  *
21
- * @version 2.2.6
22
  */
23
  function __construct() {
24
 
25
  $this->id = 'payment_gateways_fees';
26
- $this->short_desc = __( 'Payment Gateways Fees and Discounts', 'woocommerce-jetpack' );
27
  $this->desc = __( 'Enable extra fees or discounts for WooCommerce payment gateways.', 'woocommerce-jetpack' );
28
  parent::__construct();
29
 
@@ -31,7 +31,7 @@ class WCJ_Payment_Gateways_Fees extends WCJ_Module {
31
 
32
  if ( $this->is_enabled() ) {
33
  add_action( 'woocommerce_cart_calculate_fees', array( $this, 'gateways_fees' ) );
34
- add_action( 'wp_enqueue_scripts' , array( $this, 'enqueue_checkout_script' ) );
35
  // add_filter( 'woocommerce_payment_gateways_settings', array( $this, 'add_fees_settings' ), 100 );
36
  add_action( 'init', array( $this, 'register_script' ) );
37
  }
@@ -51,7 +51,7 @@ class WCJ_Payment_Gateways_Fees extends WCJ_Module {
51
  * add_hooks.
52
  */
53
  function add_hooks() {
54
- add_filter( 'wcj_payment_gateways_fees_settings', array( $this, 'add_fees_settings' ) );
55
  }
56
 
57
  /**
@@ -73,7 +73,7 @@ class WCJ_Payment_Gateways_Fees extends WCJ_Module {
73
  /**
74
  * gateways_fees.
75
  *
76
- * @version 2.2.9
77
  */
78
  function gateways_fees() {
79
  global $woocommerce;
@@ -93,7 +93,7 @@ class WCJ_Payment_Gateways_Fees extends WCJ_Module {
93
  $total_in_cart = $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total;
94
  if ( '' != $fee_text && $total_in_cart >= $min_cart_amount && ( 0 == $max_cart_amount || $total_in_cart <= $max_cart_amount ) ) {
95
  $fee_value = get_option( 'wcj_gateways_fees_value_' . $current_gateway );
96
- $fee_type = apply_filters( 'wcj_get_option_filter', 'fixed', get_option( 'wcj_gateways_fees_type_' . $current_gateway ) );
97
  $final_fee_to_add = 0;
98
  switch ( $fee_type ) {
99
  case 'fixed':
@@ -123,16 +123,17 @@ class WCJ_Payment_Gateways_Fees extends WCJ_Module {
123
  /**
124
  * add_fees_settings.
125
  *
126
- * @version 2.2.9
127
  */
128
  function add_fees_settings( $settings ) {
129
  // Gateway's Extra Fees
130
  $settings[] = array(
131
  'title' => __( 'Payment Gateways Fees and Discounts Options', 'woocommerce-jetpack' ),
132
- 'type' => 'title',
133
- 'desc' => __( 'This section lets you set extra fees for payment gateways.', 'woocommerce-jetpack' ),
134
- // __( 'Fees are applied BEFORE taxes.', 'woocommerce-jetpack' ),
135
- 'id' => 'wcj_payment_gateways_fees_options' );
 
136
 
137
  //$available_gateways = WC()->payment_gateways->payment_gateways();
138
  global $woocommerce;
@@ -159,9 +160,9 @@ class WCJ_Payment_Gateways_Fees extends WCJ_Module {
159
  array(
160
  'title' => '',
161
  'desc' => __( 'Fee (or discount) type.', 'woocommerce-jetpack' ),
162
- 'desc_tip' => __( 'Percent or fixed value.', 'woocommerce-jetpack' ) . ' ' . apply_filters( 'get_wc_jetpack_plus_message', '', 'desc_no_link' ),
163
- 'custom_attributes'
164
- => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
165
  'id' => 'wcj_gateways_fees_type_' . $key,
166
  'default' => 'fixed',
167
  'type' => 'select',
4
  *
5
  * The WooCommerce Jetpack Payment Gateways Fees class.
6
  *
7
+ * @version 2.3.0
8
  * @since 2.2.2
9
  * @author Algoritmika Ltd.
10
  */
18
  /**
19
  * Constructor.
20
  *
21
+ * @version 2.3.0
22
  */
23
  function __construct() {
24
 
25
  $this->id = 'payment_gateways_fees';
26
+ $this->short_desc = __( 'Gateways Fees and Discounts', 'woocommerce-jetpack' );
27
  $this->desc = __( 'Enable extra fees or discounts for WooCommerce payment gateways.', 'woocommerce-jetpack' );
28
  parent::__construct();
29
 
31
 
32
  if ( $this->is_enabled() ) {
33
  add_action( 'woocommerce_cart_calculate_fees', array( $this, 'gateways_fees' ) );
34
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_checkout_script' ) );
35
  // add_filter( 'woocommerce_payment_gateways_settings', array( $this, 'add_fees_settings' ), 100 );
36
  add_action( 'init', array( $this, 'register_script' ) );
37
  }
51
  * add_hooks.
52
  */
53
  function add_hooks() {
54
+ add_filter( 'wcj_payment_gateways_fees_settings', array( $this, 'add_fees_settings' ) );
55
  }
56
 
57
  /**
73
  /**
74
  * gateways_fees.
75
  *
76
+ * @version 2.3.0
77
  */
78
  function gateways_fees() {
79
  global $woocommerce;
93
  $total_in_cart = $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total;
94
  if ( '' != $fee_text && $total_in_cart >= $min_cart_amount && ( 0 == $max_cart_amount || $total_in_cart <= $max_cart_amount ) ) {
95
  $fee_value = get_option( 'wcj_gateways_fees_value_' . $current_gateway );
96
+ $fee_type = get_option( 'wcj_gateways_fees_type_' . $current_gateway );
97
  $final_fee_to_add = 0;
98
  switch ( $fee_type ) {
99
  case 'fixed':
123
  /**
124
  * add_fees_settings.
125
  *
126
+ * @version 2.3.0
127
  */
128
  function add_fees_settings( $settings ) {
129
  // Gateway's Extra Fees
130
  $settings[] = array(
131
  'title' => __( 'Payment Gateways Fees and Discounts Options', 'woocommerce-jetpack' ),
132
+ 'type' => 'title',
133
+ 'desc' => __( 'This section lets you set extra fees for payment gateways.', 'woocommerce-jetpack' ),
134
+ // __( 'Fees are applied BEFORE taxes.', 'woocommerce-jetpack' ),
135
+ 'id' => 'wcj_payment_gateways_fees_options'
136
+ );
137
 
138
  //$available_gateways = WC()->payment_gateways->payment_gateways();
139
  global $woocommerce;
160
  array(
161
  'title' => '',
162
  'desc' => __( 'Fee (or discount) type.', 'woocommerce-jetpack' ),
163
+ 'desc_tip' => __( 'Percent or fixed value.', 'woocommerce-jetpack' )/* . ' ' . apply_filters( 'get_wc_jetpack_plus_message', '', 'desc_no_link' ) */,
164
+ /* 'custom_attributes'
165
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ), */
166
  'id' => 'wcj_gateways_fees_type_' . $key,
167
  'default' => 'fixed',
168
  'type' => 'select',
includes/class-wcj-payment-gateways-icons.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Payment Gateways Icons class.
6
  *
7
- * @version 2.2.2
8
  * @since 2.2.2
9
  * @author Algoritmika Ltd.
10
  */
@@ -17,11 +17,13 @@ class WCJ_Payment_Gateways_Icons extends WCJ_Module {
17
 
18
  /**
19
  * Constructor.
 
 
20
  */
21
  function __construct() {
22
 
23
  $this->id = 'payment_gateways_icons';
24
- $this->short_desc = __( 'Payment Gateways Icons', 'woocommerce-jetpack' );
25
  $this->desc = __( 'Change icons (images) for all default WooCommerce payment gateways.', 'woocommerce-jetpack' );
26
  parent::__construct();
27
 
4
  *
5
  * The WooCommerce Jetpack Payment Gateways Icons class.
6
  *
7
+ * @version 2.3.0
8
  * @since 2.2.2
9
  * @author Algoritmika Ltd.
10
  */
17
 
18
  /**
19
  * Constructor.
20
+ *
21
+ * @version 2.3.0
22
  */
23
  function __construct() {
24
 
25
  $this->id = 'payment_gateways_icons';
26
+ $this->short_desc = __( 'Gateways Icons', 'woocommerce-jetpack' );
27
  $this->desc = __( 'Change icons (images) for all default WooCommerce payment gateways.', 'woocommerce-jetpack' );
28
  parent::__construct();
29
 
includes/class-wcj-payment-gateways-per-category.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Payment Gateways per Category class.
6
  *
7
- * @version 2.2.2
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
@@ -15,13 +15,15 @@ if ( ! class_exists( 'WCJ_Payment_Gateways_Per_Category' ) ) :
15
 
16
  class WCJ_Payment_Gateways_Per_Category extends WCJ_Module {
17
 
18
- /**
19
- * Constructor.
20
- */
21
- function __construct() {
 
 
22
 
23
  $this->id = 'payment_gateways_per_category';
24
- $this->short_desc = __( 'Payment Gateways per Category', 'woocommerce-jetpack' );
25
  $this->desc = __( 'Show gateway only if there is product of selected category in WooCommerce cart.', 'woocommerce-jetpack' );
26
  parent::__construct();
27
 
@@ -44,17 +46,17 @@ class WCJ_Payment_Gateways_Per_Category extends WCJ_Module {
44
  return $this->add_enable_module_setting( $settings );
45
  }
46
 
47
- /**
48
- * add_hooks.
49
- */
50
- function add_hooks() {
51
  add_filter( 'wcj_payment_gateways_per_category_settings', array( $this, 'add_per_category_settings' ) );
52
  }
53
 
54
- /**
55
- * filter_available_payment_gateways_per_category.
56
- */
57
- function filter_available_payment_gateways_per_category( $available_gateways ) {
58
  //if ( ! is_checkout() ) return $available_gateways;
59
  foreach ( $available_gateways as $gateway_id => $gateway ) {
60
  $categories_in = get_option( 'wcj_gateways_per_category_' . $gateway_id );
@@ -84,10 +86,10 @@ class WCJ_Payment_Gateways_Per_Category extends WCJ_Module {
84
  return $available_gateways;
85
  }
86
 
87
- /**
88
- * add_per_category_settings.
89
- */
90
- function add_per_category_settings( $settings ) {
91
 
92
  $settings[] = array(
93
  'title' => __( 'WooCommerce Jetpack: Payment Gateways per Category Options', 'woocommerce-jetpack' ),
@@ -121,7 +123,7 @@ class WCJ_Payment_Gateways_Per_Category extends WCJ_Module {
121
  $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_gateways_per_category_options' );
122
 
123
  return $settings;
124
- }
125
  }
126
 
127
  endif;
4
  *
5
  * The WooCommerce Jetpack Payment Gateways per Category class.
6
  *
7
+ * @version 2.3.0
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
15
 
16
  class WCJ_Payment_Gateways_Per_Category extends WCJ_Module {
17
 
18
+ /**
19
+ * Constructor.
20
+ *
21
+ * @version 2.3.0
22
+ */
23
+ function __construct() {
24
 
25
  $this->id = 'payment_gateways_per_category';
26
+ $this->short_desc = __( 'Gateways per Category', 'woocommerce-jetpack' );
27
  $this->desc = __( 'Show gateway only if there is product of selected category in WooCommerce cart.', 'woocommerce-jetpack' );
28
  parent::__construct();
29
 
46
  return $this->add_enable_module_setting( $settings );
47
  }
48
 
49
+ /**
50
+ * add_hooks.
51
+ */
52
+ function add_hooks() {
53
  add_filter( 'wcj_payment_gateways_per_category_settings', array( $this, 'add_per_category_settings' ) );
54
  }
55
 
56
+ /**
57
+ * filter_available_payment_gateways_per_category.
58
+ */
59
+ function filter_available_payment_gateways_per_category( $available_gateways ) {
60
  //if ( ! is_checkout() ) return $available_gateways;
61
  foreach ( $available_gateways as $gateway_id => $gateway ) {
62
  $categories_in = get_option( 'wcj_gateways_per_category_' . $gateway_id );
86
  return $available_gateways;
87
  }
88
 
89
+ /**
90
+ * add_per_category_settings.
91
+ */
92
+ function add_per_category_settings( $settings ) {
93
 
94
  $settings[] = array(
95
  'title' => __( 'WooCommerce Jetpack: Payment Gateways per Category Options', 'woocommerce-jetpack' ),
123
  $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_gateways_per_category_options' );
124
 
125
  return $settings;
126
+ }
127
  }
128
 
129
  endif;
includes/class-wcj-payment-gateways.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Payment Gateways class.
6
  *
7
- * @version 2.2.4
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -17,12 +17,12 @@ class WCJ_Payment_Gateways extends WCJ_Module {
17
  /**
18
  * Constructor.
19
  *
20
- * @version 2.2.4
21
  */
22
  public function __construct() {
23
 
24
  $this->id = 'payment_gateways';
25
- $this->short_desc = __( 'Custom Payment Gateways', 'woocommerce-jetpack' );
26
  $this->desc = __( 'Add multiple custom payment gateways to WooCommerce.', 'woocommerce-jetpack' );
27
  parent::__construct();
28
 
4
  *
5
  * The WooCommerce Jetpack Payment Gateways class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
17
  /**
18
  * Constructor.
19
  *
20
+ * @version 2.3.0
21
  */
22
  public function __construct() {
23
 
24
  $this->id = 'payment_gateways';
25
+ $this->short_desc = __( 'Custom Gateways', 'woocommerce-jetpack' );
26
  $this->desc = __( 'Add multiple custom payment gateways to WooCommerce.', 'woocommerce-jetpack' );
27
  parent::__construct();
28
 
includes/class-wcj-pdf-invoicing.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing class.
6
  *
7
- * @version 2.2.7
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -12,14 +12,22 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
12
 
13
  if ( ! class_exists( 'WCJ_PDF_Invoicing' ) ) :
14
 
15
- class WCJ_PDF_Invoicing {
16
 
17
  /**
18
  * Constructor.
 
 
19
  */
20
  public function __construct() {
21
 
22
- if ( get_option( 'wcj_pdf_invoicing_enabled' ) == 'yes' ) {
 
 
 
 
 
 
23
 
24
  include_once( 'pdf-invoices/class-wcj-pdf-invoicing-renumerate-tool.php' );
25
  include_once( 'pdf-invoices/class-wcj-pdf-invoicing-report-tool.php' );
@@ -27,21 +35,61 @@ class WCJ_PDF_Invoicing {
27
  add_action( 'init', array( $this, 'catch_args' ) );
28
  add_action( 'init', array( $this, 'generate_pdf_on_init' ) );
29
 
30
- //define ( 'K_PATH_IMAGES', $_SERVER['DOCUMENT_ROOT'] );
31
 
32
  $invoice_types = wcj_get_enabled_invoice_types();
33
  foreach ( $invoice_types as $invoice_type ) {
34
  $the_hook = get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_create_on', 'woocommerce_new_order' );
35
- if ( 'disabled' != $the_hook ) {
36
  add_action( $the_hook, array( $this, 'create_' . $invoice_type['id'] ) );
37
  }
38
  }
39
- }
40
 
41
- // Settings hooks
42
- add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
43
- add_filter( 'wcj_settings_pdf_invoicing', array( $this, 'get_settings' ), 100 );
44
- add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  }
46
 
47
  * create_invoice.
@@ -74,7 +122,8 @@ class WCJ_PDF_Invoicing {
74
  /**
75
  * create_custom_doc.
76
  *
77
- * @since 2.2.7
 
78
  */
79
  function create_custom_doc( $order_id ) {
80
  return $this->create_document( $order_id, 'custom_doc' );
@@ -100,14 +149,35 @@ class WCJ_PDF_Invoicing {
100
  }
101
  */
102
  }
 
 
 
 
 
 
 
 
 
 
 
 
103
 
104
  * catch_args.
 
 
105
  */
106
  function catch_args() {
107
  $this->order_id = ( isset( $_GET['order_id'] ) ) ? $_GET['order_id'] : 0;
108
  $this->invoice_type_id = ( isset( $_GET['invoice_type_id'] ) ) ? $_GET['invoice_type_id'] : '';
109
  $this->save_as_pdf = ( isset( $_GET['save_pdf_invoice'] ) && '1' == $_GET['save_pdf_invoice'] ) ? true : false;
110
  $this->get_invoice = ( isset( $_GET['get_invoice'] ) && '1' == $_GET['get_invoice'] ) ? true : false;
 
 
 
 
 
 
 
111
  }
112
 
113
  * generate_pdf_on_init.
@@ -116,43 +186,27 @@ class WCJ_PDF_Invoicing {
116
 
117
  // Check if all is OK
118
  if ( ( true !== $this->get_invoice ) ||
119
- ( 0 == $this->order_id ) ||
120
- ( ! is_user_logged_in() ) ||
121
- ( ! current_user_can( 'administrator' ) && ! is_shop_manager() && get_current_user_id() != intval( get_post_meta( $this->order_id, '_customer_user', true ) ) ) )
122
  return;
123
 
124
  $the_invoice = wcj_get_pdf_invoice( $this->order_id, $this->invoice_type_id );
125
- //$invoice = new WCJ_PDF_Invoice();
126
  $dest = ( true === $this->save_as_pdf ) ? 'D' : 'I';
127
- //$invoice->get_pdf( $this->order_id, $this->invoice_type_id, '', $dest );//, $this->invoice_type_id );
128
  $the_invoice->get_pdf( $dest );
129
- //echo $invoice_html;
130
  }
131
-
132
- * add_enabled_option.
133
- */
134
- public function add_enabled_option( $settings ) {
135
- $all_settings = $this->get_settings();
136
- $settings[] = $all_settings[1];
137
- return $settings;
138
- }
139
 
140
  * get_settings.
 
 
141
  */
142
- function get_settings() {
143
-
144
- $settings = array(
145
 
146
- array( 'title' => __( 'PDF Invoicing General Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_pdf_invoicing_options' ),
147
-
148
- array(
149
- 'title' => __( 'PDF Invoicing', 'woocommerce-jetpack' ),
150
- 'desc' => '<strong>' . __( 'Enable Module', 'woocommerce-jetpack' ) . '</strong>',
151
- 'desc_tip' => __( 'WooCommerce Invoices, Proforma Invoices, Credit Notes and Packing Slips.', 'woocommerce-jetpack' ),
152
- 'id' => 'wcj_pdf_invoicing_enabled',
153
- 'default' => 'no',
154
- 'type' => 'checkbox',
155
- ),
156
  );
157
 
158
  // Hooks Array
@@ -163,34 +217,28 @@ class WCJ_PDF_Invoicing {
163
  foreach ( $order_statuses as $status => $desc ) {
164
  $create_on_array[ 'woocommerce_order_status_' . $status ] = __( 'Create on Order Status', 'woocommerce-jetpack' ) . ' ' . $desc;
165
  }
 
166
 
167
  // Settings
168
  $invoice_types = wcj_get_invoice_types();
169
  foreach ( $invoice_types as $k => $invoice_type ) {
170
  $settings[] = array(
171
- 'title' => $invoice_type['title'],
172
- 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_create_on',
173
- 'default' => 'disabled',
174
- 'type' => 'select',
175
  'class' => 'chosen_select',
176
- 'options' => $create_on_array,
177
- 'desc' => ( 0 === $k ) ? '' : apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
178
  'custom_attributes'
179
- => ( 0 === $k ) ? '' : apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
180
- );
181
  }
182
 
183
  $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoicing_options' );
184
 
185
- return $settings;
186
- }
187
-
188
- * settings_section.
189
- */
190
- function settings_section( $sections ) {
191
- $sections['pdf_invoicing'] = __( 'General', 'woocommerce-jetpack' );
192
- return $sections;
193
- }
194
  }
195
 
196
  endif;
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
12
 
13
  if ( ! class_exists( 'WCJ_PDF_Invoicing' ) ) :
14
 
15
+ class WCJ_PDF_Invoicing extends WCJ_Module {
16
 
17
  /**
18
  * Constructor.
19
+ *
20
+ * @version 2.3.0
21
  */
22
  public function __construct() {
23
 
24
+ $this->id = 'pdf_invoicing';
25
+ $this->short_desc = __( 'PDF Invoicing', 'woocommerce-jetpack' );
26
+ $this->section_title = __( 'General', 'woocommerce-jetpack' );
27
+ $this->desc = __( 'WooCommerce Invoices, Proforma Invoices, Credit Notes and Packing Slips.', 'woocommerce-jetpack' );
28
+ parent::__construct();
29
+
30
+ if ( $this->is_enabled() ) {
31
 
32
  include_once( 'pdf-invoices/class-wcj-pdf-invoicing-renumerate-tool.php' );
33
  include_once( 'pdf-invoices/class-wcj-pdf-invoicing-report-tool.php' );
35
  add_action( 'init', array( $this, 'catch_args' ) );
36
  add_action( 'init', array( $this, 'generate_pdf_on_init' ) );
37
 
38
+ // define ( 'K_PATH_IMAGES', $_SERVER['DOCUMENT_ROOT'] );
39
 
40
  $invoice_types = wcj_get_enabled_invoice_types();
41
  foreach ( $invoice_types as $invoice_type ) {
42
  $the_hook = get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_create_on', 'woocommerce_new_order' );
43
+ if ( 'disabled' != $the_hook && 'manual' != $the_hook && '' != $the_hook ) {
44
  add_action( $the_hook, array( $this, 'create_' . $invoice_type['id'] ) );
45
  }
46
  }
 
47
 
48
+ /* $this->meta_box_screen = 'shop_order';
49
+ $this->meta_box_context = 'side';
50
+ $this->meta_box_priority = 'default';
51
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) ); */
52
+ }
53
+ }
54
+
55
+ /**
56
+ * create_meta_box.
57
+ *
58
+ * @version 2.3.0
59
+ * @since 2.3.0
60
+ *
61
+ public function create_meta_box() {
62
+
63
+ $current_post_id = get_the_ID();
64
+
65
+ $html = '';
66
+ $html .= '<table>';
67
+ $invoice_types = wcj_get_invoice_types();
68
+ foreach ( $invoice_types as $invoice_type ) {
69
+ $the_hook = get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_create_on', 'woocommerce_new_order' );
70
+ if ( 'disabled' != $the_hook && '' != $the_hook ) {
71
+ $html .= '<tr>';
72
+
73
+ $html .= '<th style="text-align:left;">';
74
+ $html .= $invoice_type['title'];
75
+ $html .= '</th>';
76
+
77
+ $html .= '<td style="text-align:right;">';
78
+ $html .= '<a href="';
79
+ if ( false == wcj_is_invoice_created( $current_post_id, $invoice_type['id'] ) ) {
80
+ $html .= add_query_arg( array( 'create_invoice_for_order_id' => $current_post_id, 'invoice_type_id' => $invoice_type['id'] ), remove_query_arg( 'delete_invoice_for_order_id' ) );
81
+ $html .= '">' . __( 'Create', 'woocommerce-jetpack' ) . '</a>';
82
+ } else {
83
+ $html .= add_query_arg( array( 'delete_invoice_for_order_id' => $current_post_id, 'invoice_type_id' => $invoice_type['id'] ), remove_query_arg( 'create_invoice_for_order_id' ) );
84
+ $html .= '">' . __( 'Delete', 'woocommerce-jetpack' ) . '</a>';
85
+ }
86
+ $html .= '</td>';
87
+
88
+ $html .= '</tr>';
89
+ }
90
+ }
91
+ $html .= '</table>';
92
+ echo $html;
93
  }
94
 
95
  * create_invoice.
122
  /**
123
  * create_custom_doc.
124
  *
125
+ * @version 2.2.7
126
+ * @since 2.2.7
127
  */
128
  function create_custom_doc( $order_id ) {
129
  return $this->create_document( $order_id, 'custom_doc' );
149
  }
150
  */
151
  }
152
+
153
+ /**
154
+ * delete_document.
155
+ *
156
+ * @version 2.3.0
157
+ * @since 2.3.0
158
+ */
159
+ function delete_document( $order_id, $invoice_type ) {
160
+ if ( true == wcj_is_invoice_created( $order_id, $invoice_type ) ) {
161
+ wcj_delete_invoice( $order_id, $invoice_type );
162
+ }
163
+ }
164
 
165
  * catch_args.
166
+ *
167
+ * @version 2.3.0
168
  */
169
  function catch_args() {
170
  $this->order_id = ( isset( $_GET['order_id'] ) ) ? $_GET['order_id'] : 0;
171
  $this->invoice_type_id = ( isset( $_GET['invoice_type_id'] ) ) ? $_GET['invoice_type_id'] : '';
172
  $this->save_as_pdf = ( isset( $_GET['save_pdf_invoice'] ) && '1' == $_GET['save_pdf_invoice'] ) ? true : false;
173
  $this->get_invoice = ( isset( $_GET['get_invoice'] ) && '1' == $_GET['get_invoice'] ) ? true : false;
174
+
175
+ if ( isset( $_GET['create_invoice_for_order_id'] ) && ( is_super_admin() || is_shop_manager() ) ) {
176
+ $this->create_document( $_GET['create_invoice_for_order_id'], $this->invoice_type_id );
177
+ }
178
+ if ( isset( $_GET['delete_invoice_for_order_id'] ) && ( is_super_admin() || is_shop_manager() ) ) {
179
+ $this->delete_document( $_GET['delete_invoice_for_order_id'], $this->invoice_type_id );
180
+ }
181
  }
182
 
183
  * generate_pdf_on_init.
186
 
187
  // Check if all is OK
188
  if ( ( true !== $this->get_invoice ) ||
189
+ ( 0 == $this->order_id ) ||
190
+ ( ! is_user_logged_in() ) ||
191
+ ( ! current_user_can( 'administrator' ) && ! is_shop_manager() && get_current_user_id() != intval( get_post_meta( $this->order_id, '_customer_user', true ) ) ) )
192
  return;
193
 
194
  $the_invoice = wcj_get_pdf_invoice( $this->order_id, $this->invoice_type_id );
195
+ // $invoice = new WCJ_PDF_Invoice();
196
  $dest = ( true === $this->save_as_pdf ) ? 'D' : 'I';
197
+ // $invoice->get_pdf( $this->order_id, $this->invoice_type_id, '', $dest );//, $this->invoice_type_id );
198
  $the_invoice->get_pdf( $dest );
199
+ // echo $invoice_html;
200
  }
 
 
 
 
 
 
 
 
201
 
202
  * get_settings.
203
+ *
204
+ * @version 2.3.0
205
  */
206
+ function get_settings() {
 
 
207
 
208
+ $settings = array(
209
+ array( 'title' => __( 'PDF Invoicing General Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_pdf_invoicing_options' ),
 
 
 
 
 
 
 
 
210
  );
211
 
212
  // Hooks Array
217
  foreach ( $order_statuses as $status => $desc ) {
218
  $create_on_array[ 'woocommerce_order_status_' . $status ] = __( 'Create on Order Status', 'woocommerce-jetpack' ) . ' ' . $desc;
219
  }
220
+ $create_on_array['manual'] = __( 'Manual Only', 'woocommerce-jetpack' );
221
 
222
  // Settings
223
  $invoice_types = wcj_get_invoice_types();
224
  foreach ( $invoice_types as $k => $invoice_type ) {
225
  $settings[] = array(
226
+ 'title' => $invoice_type['title'],
227
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_create_on',
228
+ 'default' => 'disabled',
229
+ 'type' => 'select',
230
  'class' => 'chosen_select',
231
+ 'options' => $create_on_array,
232
+ 'desc' => ( 0 === $k ) ? '' : apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
233
  'custom_attributes'
234
+ => ( 0 === $k ) ? '' : apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
235
+ );
236
  }
237
 
238
  $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoicing_options' );
239
 
240
+ return $this->add_enable_module_setting( $settings );
241
+ }
 
 
 
 
 
 
 
242
  }
243
 
244
  endif;
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.2.6
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -12,67 +12,53 @@ if ( ! defined( 'ABSPATH' ) ) exit;
12
 
13
  if ( ! class_exists( 'WCJ_Price_By_Country' ) ) :
14
 
15
- class WCJ_Price_By_Country {
16
 
17
  /**
18
  * Constructor.
 
 
19
  */
20
  public function __construct() {
21
 
22
- // Main hooks
23
- if ( 'yes' === get_option( 'wcj_price_by_country_enabled' ) ) {
24
- if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
25
- //wcj_log( 'WCJ_Price_By_Country: frontend' );
 
 
 
 
 
26
  include_once( 'price-by-country/class-wcj-price-by-country-core.php' );
27
- } else {
28
- //wcj_log( 'WCJ_Price_By_Country: backend' );
29
- //include_once( 'price-by-country/class-wcj-exchange-rates.php' );
 
30
  include_once( 'price-by-country/class-wcj-price-by-country-reports.php' );
31
  if ( 'yes' === get_option( 'wcj_price_by_country_local_enabled' ) ) {
32
  include_once( 'price-by-country/class-wcj-price-by-country-local.php' );
33
  }
34
  }
35
  }
36
- include_once( 'price-by-country/class-wcj-exchange-rates.php' );
37
- include_once( 'price-by-country/class-wcj-exchange-rates-crons.php' );
38
-
39
- // Settings hooks
40
- add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
41
- add_filter( 'wcj_settings_price_by_country', array( $this, 'get_settings' ), 100 );
42
- add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
43
- }
44
-
45
- /**
46
- * add_enabled_option.
47
- */
48
- public function add_enabled_option( $settings ) {
49
- $all_settings = $this->get_settings();
50
- $settings[] = $all_settings[1];
51
- return $settings;
52
  }
53
 
54
  /**
55
  * get_settings.
56
  *
57
- * @version 2.2.6
58
  */
59
  function get_settings() {
60
 
61
  $settings = array(
62
 
63
  array(
64
- 'title' => __( 'Price by Country Options', 'woocommerce-jetpack' ),
65
- 'type' => 'title',
66
- 'desc' => __( 'Change product\'s price and currency by customer\'s country. Customer\'s country is detected automatically by IP, or selected by customer manually.', 'woocommerce-jetpack' ),
67
- 'id' => 'wcj_price_by_country_options' ),
68
-
69
- array(
70
- 'title' => __( 'Prices and Currencies by Country', 'woocommerce-jetpack' ),
71
- 'desc' => '<strong>' . __( 'Enable Module', 'woocommerce-jetpack' ) . '</strong>',
72
- 'desc_tip' => __( 'Change WooCommerce product price and currency automatically by customer\'s country.', 'woocommerce-jetpack' ),
73
- 'id' => 'wcj_price_by_country_enabled',
74
- 'default' => 'no',
75
- 'type' => 'checkbox',
76
  ),
77
 
78
  array(
@@ -84,10 +70,21 @@ class WCJ_Price_By_Country {
84
  'options' => array(
85
  'by_ip' => __( 'by IP', 'woocommerce-jetpack' ),
86
  'by_user_selection' => __( 'by user selection', 'woocommerce-jetpack' ),
87
- //'by_wpml' => __( 'by WPML', 'woocommerce-jetpack' ),
88
  ),
89
  ),
90
 
 
 
 
 
 
 
 
 
 
 
 
91
  array(
92
  'title' => __( 'Override Country on Checkout with Billing Country', 'woocommerce-jetpack' ),
93
  'id' => 'wcj_price_by_country_override_on_checkout_with_billing_country',
@@ -132,7 +129,7 @@ class WCJ_Price_By_Country {
132
  'custom_attributes' => array_merge(
133
  is_array( apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) ) ? apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) : array(),
134
  array('step' => '1', 'min' => '1', ) ),
135
- 'css' => 'width:100px;',
136
  ),
137
  );
138
 
@@ -140,11 +137,11 @@ class WCJ_Price_By_Country {
140
 
141
  $settings[] = array(
142
  'title' => __( 'Group', 'woocommerce-jetpack' ) . ' #' . $i,
143
- 'desc' => __( 'Countries. List of comma separated country codes.<br>For country codes and predifined sets visit <a href="http://boostwoo.com/features/prices-and-currencies-by-customers-country">BoostWoo.com</a>', 'woocommerce-jetpack' ),
144
  'id' => 'wcj_price_by_country_exchange_rate_countries_group_' . $i,
145
  'default' => '',
146
  'type' => 'textarea',
147
- 'css' => 'width:50%;min-width:300px;height:100px;',
148
  );
149
 
150
  /* TODO: Multiselect instead of comma separated list.
@@ -161,7 +158,7 @@ class WCJ_Price_By_Country {
161
 
162
  $settings[] = array(
163
  'title' => '',
164
- 'desc' => __( 'Currency', 'woocommerce-jetpack' ),
165
  'id' => 'wcj_price_by_country_exchange_rate_currency_group_' . $i,
166
  'default' => 'EUR',
167
  'type' => 'select',
@@ -180,15 +177,19 @@ class WCJ_Price_By_Country {
180
  'type' => 'select',
181
  'options' => array(
182
  'manual' => __( 'Enter Rates Manually', 'woocommerce-jetpack' ),
183
- 'hourly' => __( 'Automatically: Update Hourly', 'woocommerce-jetpack' ),
 
184
  'twicedaily' => __( 'Automatically: Update Twice Daily', 'woocommerce-jetpack' ),
185
  'daily' => __( 'Automatically: Update Daily', 'woocommerce-jetpack' ),
186
  'weekly' => __( 'Automatically: Update Weekly', 'woocommerce-jetpack' ),
187
- 'minutely' => __( 'Automatically: Update Every Minute', 'woocommerce-jetpack' ),
188
  ),
189
- 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
 
 
 
190
  'custom_attributes'
191
- => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
192
  );
193
 
194
  $currency_from = apply_filters( 'woocommerce_currency', get_option('woocommerce_currency') );
@@ -206,13 +207,13 @@ class WCJ_Price_By_Country {
206
 
207
  $settings[] = array(
208
  'title' => __( 'Group', 'woocommerce-jetpack' ) . ' #' . $i,
209
- 'desc' => __( 'Multiply Price by', 'woocommerce-jetpack' ),
210
  'id' => 'wcj_price_by_country_exchange_rate_group_' . $i,
211
  'default' => 1,
212
  'type' => 'exchange_rate',
213
- 'css' => 'width:100px;',
214
- 'custom_attributes' => array( 'step' => '0.000001', 'min' => '0', ),
215
- 'custom_attributes_button' => $custom_attributes,
216
  'value' => $currency_from . '/' . $currency_to,
217
  'value_title' => sprintf( __( 'Grab %s rate from Yahoo.com', 'woocommerce-jetpack' ), $currency_from . '/' . $currency_to ),
218
  );
@@ -222,14 +223,14 @@ class WCJ_Price_By_Country {
222
  //'id' => 'wcj_price_by_country_exchange_rate_refresh_group_' . $i,
223
  'class' => 'exchage_rate_button',
224
  'type' => 'custom_number',
225
- 'css' => 'width:300px;',
226
  'value' => sprintf( __( '%s rate from Yahoo.com', 'woocommerce-jetpack' ), $currency_from . '/' . $currency_to ),
227
  'custom_attributes' => $custom_attributes,
228
  ); */
229
 
230
  $settings[] = array(
231
  'title' => '',
232
- 'desc' => __( 'Make empty price', 'woocommerce-jetpack' ),
233
  'id' => 'wcj_price_by_country_make_empty_price_group_' . $i,
234
  'default' => 'no',
235
  'type' => 'checkbox',
@@ -295,15 +296,7 @@ class WCJ_Price_By_Country {
295
  ),
296
  ) ); */
297
 
298
- return $settings;
299
- }
300
-
301
- /**
302
- * settings_section.
303
- */
304
- function settings_section( $sections ) {
305
- $sections['price_by_country'] = __( 'Prices and Currencies by Country', 'woocommerce-jetpack' );
306
- return $sections;
307
  }
308
  }
309
 
4
  *
5
  * The WooCommerce Jetpack Price by Country class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
12
 
13
  if ( ! class_exists( 'WCJ_Price_By_Country' ) ) :
14
 
15
+ class WCJ_Price_By_Country extends WCJ_Module {
16
 
17
  /**
18
  * Constructor.
19
+ *
20
+ * @version 2.3.0
21
  */
22
  public function __construct() {
23
 
24
+ $this->id = 'price_by_country';
25
+ $this->short_desc = __( 'Prices and Currencies by Country', 'woocommerce-jetpack' );
26
+ $this->desc = __( 'Change WooCommerce product price and currency automatically by customer\'s country.', 'woocommerce-jetpack' );
27
+ parent::__construct();
28
+
29
+ if ( $this->is_enabled() ) {
30
+
31
+ // if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
32
+ // Frontend
33
  include_once( 'price-by-country/class-wcj-price-by-country-core.php' );
34
+ // } else {
35
+ if ( is_admin() ) {
36
+ // Backend
37
+ // include_once( 'price-by-country/class-wcj-exchange-rates.php' );
38
  include_once( 'price-by-country/class-wcj-price-by-country-reports.php' );
39
  if ( 'yes' === get_option( 'wcj_price_by_country_local_enabled' ) ) {
40
  include_once( 'price-by-country/class-wcj-price-by-country-local.php' );
41
  }
42
  }
43
  }
44
+ // include_once( 'price-by-country/class-wcj-exchange-rates.php' );
45
+ // include_once( 'price-by-country/class-wcj-exchange-rates-crons.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
47
 
48
  /**
49
  * get_settings.
50
  *
51
+ * @version 2.3.0
52
  */
53
  function get_settings() {
54
 
55
  $settings = array(
56
 
57
  array(
58
+ 'title' => __( 'Price by Country Options', 'woocommerce-jetpack' ),
59
+ 'type' => 'title',
60
+ 'desc' => __( 'Change product\'s price and currency by customer\'s country. Customer\'s country is detected automatically by IP, or selected by customer manually.', 'woocommerce-jetpack' ),
61
+ 'id' => 'wcj_price_by_country_options',
 
 
 
 
 
 
 
 
62
  ),
63
 
64
  array(
70
  'options' => array(
71
  'by_ip' => __( 'by IP', 'woocommerce-jetpack' ),
72
  'by_user_selection' => __( 'by user selection', 'woocommerce-jetpack' ),
73
+ // 'by_wpml' => __( 'by WPML', 'woocommerce-jetpack' ),
74
  ),
75
  ),
76
 
77
+ /* array(
78
+ 'title' => __( 'Countries in [wcj_country_select_drop_down_list] shortcode\'s list', 'woocommerce-jetpack' ),
79
+ 'desc' => __( 'Leave blank to list all countries', 'woocommerce-jetpack' ),
80
+ 'id' => 'wcj_price_by_country_shortcode_countries',
81
+ 'default' => '',
82
+ 'type' => 'multiselect',
83
+ 'options' => wcj_get_countries(),
84
+ 'class' => 'chosen_select',
85
+ // 'css' => 'width:50%;min-width:300px;height:100px;',
86
+ ), */
87
+
88
  array(
89
  'title' => __( 'Override Country on Checkout with Billing Country', 'woocommerce-jetpack' ),
90
  'id' => 'wcj_price_by_country_override_on_checkout_with_billing_country',
129
  'custom_attributes' => array_merge(
130
  is_array( apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) ) ? apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) : array(),
131
  array('step' => '1', 'min' => '1', ) ),
132
+ 'css' => 'width:100px;',
133
  ),
134
  );
135
 
137
 
138
  $settings[] = array(
139
  'title' => __( 'Group', 'woocommerce-jetpack' ) . ' #' . $i,
140
+ 'desc' => __( 'Countries. List of comma separated country codes.<br>For country codes and predifined sets visit <a href="http://boostwoo.com/features/prices-and-currencies-by-customers-country">BoostWoo.com</a>', 'woocommerce-jetpack' ),
141
  'id' => 'wcj_price_by_country_exchange_rate_countries_group_' . $i,
142
  'default' => '',
143
  'type' => 'textarea',
144
+ 'css' => 'width:50%;min-width:300px;height:100px;',
145
  );
146
 
147
  /* TODO: Multiselect instead of comma separated list.
158
 
159
  $settings[] = array(
160
  'title' => '',
161
+ 'desc' => __( 'Currency', 'woocommerce-jetpack' ),
162
  'id' => 'wcj_price_by_country_exchange_rate_currency_group_' . $i,
163
  'default' => 'EUR',
164
  'type' => 'select',
177
  'type' => 'select',
178
  'options' => array(
179
  'manual' => __( 'Enter Rates Manually', 'woocommerce-jetpack' ),
180
+ 'auto' => __( 'Automatically via Currency Exchange Rates module', 'woocommerce-jetpack' ),
181
+ /* 'hourly' => __( 'Automatically: Update Hourly', 'woocommerce-jetpack' ),
182
  'twicedaily' => __( 'Automatically: Update Twice Daily', 'woocommerce-jetpack' ),
183
  'daily' => __( 'Automatically: Update Daily', 'woocommerce-jetpack' ),
184
  'weekly' => __( 'Automatically: Update Weekly', 'woocommerce-jetpack' ),
185
+ 'minutely' => __( 'Automatically: Update Every Minute', 'woocommerce-jetpack' ), */
186
  ),
187
+ 'desc' => ( '' == apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ) ) ?
188
+ __( '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>'
189
+ :
190
+ apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
191
  'custom_attributes'
192
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
193
  );
194
 
195
  $currency_from = apply_filters( 'woocommerce_currency', get_option('woocommerce_currency') );
207
 
208
  $settings[] = array(
209
  'title' => __( 'Group', 'woocommerce-jetpack' ) . ' #' . $i,
210
+ 'desc' => __( 'Multiply Price by', 'woocommerce-jetpack' ),
211
  'id' => 'wcj_price_by_country_exchange_rate_group_' . $i,
212
  'default' => 1,
213
  'type' => 'exchange_rate',
214
+ 'css' => 'width:100px;',
215
+ 'custom_attributes' => array( 'step' => '0.000001', 'min' => '0', ),
216
+ 'custom_attributes_button' => $custom_attributes,
217
  'value' => $currency_from . '/' . $currency_to,
218
  'value_title' => sprintf( __( 'Grab %s rate from Yahoo.com', 'woocommerce-jetpack' ), $currency_from . '/' . $currency_to ),
219
  );
223
  //'id' => 'wcj_price_by_country_exchange_rate_refresh_group_' . $i,
224
  'class' => 'exchage_rate_button',
225
  'type' => 'custom_number',
226
+ 'css' => 'width:300px;',
227
  'value' => sprintf( __( '%s rate from Yahoo.com', 'woocommerce-jetpack' ), $currency_from . '/' . $currency_to ),
228
  'custom_attributes' => $custom_attributes,
229
  ); */
230
 
231
  $settings[] = array(
232
  'title' => '',
233
+ 'desc' => __( 'Make empty price', 'woocommerce-jetpack' ),
234
  'id' => 'wcj_price_by_country_make_empty_price_group_' . $i,
235
  'default' => 'no',
236
  'type' => 'checkbox',
296
  ),
297
  ) ); */
298
 
299
+ return $this->add_enable_module_setting( $settings );
 
 
 
 
 
 
 
 
300
  }
301
  }
302
 
includes/class-wcj-price-labels.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Price Labels class.
6
  *
7
- * @version 2.2.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -414,12 +414,13 @@ class WCJ_Price_Labels {
414
  }
415
 
416
  /*
417
- * front end
 
 
418
  */
419
  public function custom_price( $price, $product ) {
420
 
421
- if ( is_admin() )
422
- return $price;
423
 
424
  //if ( 'simple' === $product->product_type )
425
  // return $price;
@@ -483,10 +484,10 @@ class WCJ_Price_Labels {
483
  if ( 'on' === $labels_array[ 'variation_enabled' ] ) {
484
 
485
  if (
486
- ( ( 'off' === $labels_array['variation_home'] ) && ( is_front_page() ) ) ||
487
  ( ( 'off' === $labels_array['variation_products'] ) && ( is_archive() ) ) ||
488
- ( ( 'off' === $labels_array['variation_single'] ) && ( is_single() ) ) ||
489
- ( ( 'off' === $labels_array['variation_page'] ) && ( is_page() ) )
490
  )
491
  {
492
  //$current_filter_name = current_filter();
4
  *
5
  * The WooCommerce Jetpack Price Labels class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
414
  }
415
 
416
  /*
417
+ * front end.
418
+ *
419
+ * @version 2.3.0
420
  */
421
  public function custom_price( $price, $product ) {
422
 
423
+ if ( ! wcj_is_frontend() ) return $price;
 
424
 
425
  //if ( 'simple' === $product->product_type )
426
  // return $price;
484
  if ( 'on' === $labels_array[ 'variation_enabled' ] ) {
485
 
486
  if (
487
+ ( ( 'off' === $labels_array['variation_home'] ) && ( is_front_page() ) ) ||
488
  ( ( 'off' === $labels_array['variation_products'] ) && ( is_archive() ) ) ||
489
+ ( ( 'off' === $labels_array['variation_single'] ) && ( is_single() ) ) ||
490
+ ( ( 'off' === $labels_array['variation_page'] ) && ( is_page() ) )
491
  )
492
  {
493
  //$current_filter_name = current_filter();
includes/class-wcj-product-bulk-price-converter.php CHANGED
@@ -4,37 +4,37 @@
4
  *
5
  * The WooCommerce Jetpack Bulk Price Converter class.
6
  *
7
- * @class WCJ_Bulk_Price_Converter
8
- * @version 1.0.0
9
- * @category Class
10
- * @author Algoritmika Ltd.
11
  */
12
-
13
  if ( ! defined( 'ABSPATH' ) ) exit;
14
-
15
  if ( ! class_exists( 'WCJ_Bulk_Price_Converter' ) ) :
16
-
17
- class WCJ_Bulk_Price_Converter {
18
-
19
- /**
20
- * Constructor.
21
- */
22
- public function __construct() {
23
-
24
- $the_priority = 100;
25
- // Main hooks
26
- if ( 'yes' === get_option( 'wcj_bulk_price_converter_enabled' ) ) {
27
- add_filter( 'wcj_tools_tabs', array( $this, 'add_bulk_price_converter_tool_tab' ), $the_priority );
28
- add_action( 'wcj_tools_bulk_price_converter', array( $this, 'create_bulk_price_converter_tool' ), $the_priority );
29
- }
30
- add_action( 'wcj_tools_dashboard', array( $this, 'add_bulk_price_converter_tool_info_to_tools_dashboard' ), $the_priority );
31
-
32
- // Settings hooks
33
- add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
34
- add_filter( 'wcj_settings_bulk_price_converter', array( $this, 'get_settings' ), 100 );
35
- add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
36
- }
37
-
 
 
38
  /**
39
  * add_bulk_price_converter_tool_tab.
40
  */
@@ -44,13 +44,16 @@ class WCJ_Bulk_Price_Converter {
44
  'title' => __( 'Bulk Price Converter', 'woocommerce-jetpack' ),
45
  );
46
  return $tabs;
47
- }
48
-
49
  /**
50
  * change_price_by_type.
51
- */
 
 
52
  public function change_price_by_type( $product_id, $multiply_price_by, $price_type, $is_preview ) {
53
  $the_price = get_post_meta( $product_id, '_' . $price_type, true );
 
54
  if ( '' != $the_price ) {
55
  $precision = get_option( 'woocommerce_price_num_decimals', 2 );
56
  $the_modified_price = round( $the_price * $multiply_price_by, $precision );
@@ -59,15 +62,15 @@ class WCJ_Bulk_Price_Converter {
59
  if ( ! $is_preview )
60
  update_post_meta( $product_id, '_' . $price_type, $the_modified_price );
61
  }
62
-
63
- echo '<tr>' .
64
- '<td>' . get_the_title( $product_id ) . '</td>' .
65
- '<td><em>' . $price_type . '</em></td>' .
66
- '<td>' . $the_price . '</td>' .
67
- '<td>' . $the_modified_price . '</td>' .
68
- '</tr>';
69
  }
70
-
71
  /**
72
  * change_price_all_types.
73
  */
@@ -75,7 +78,7 @@ class WCJ_Bulk_Price_Converter {
75
  $this->change_price_by_type( $product_id, $multiply_price_by, 'price', $is_preview );
76
  $this->change_price_by_type( $product_id, $multiply_price_by, 'sale_price', $is_preview );
77
  $this->change_price_by_type( $product_id, $multiply_price_by, 'regular_price', $is_preview );
78
- }
79
 
80
  /**
81
  * change_product_price.
@@ -90,56 +93,63 @@ class WCJ_Bulk_Price_Converter {
90
  $this->change_price_all_types( $variation['variation_id'], $multiply_price_by, $is_preview );
91
  }
92
  }
93
- }
94
 
95
- /**
96
- * change_all_products_prices
97
- */
98
- public function change_all_products_prices( $multiply_prices_by, $is_preview ) {
99
  $multiply_prices_by = floatval( $multiply_prices_by );
100
  if ( $multiply_prices_by <= 0 )
101
- return;
102
-
103
  ob_start();
104
 
105
  $args = array(
106
- 'post_type' => 'product',
107
- 'post_status' => 'any',
108
- 'posts_per_page' => -1,
109
  );
110
  $loop = new WP_Query( $args );
111
  echo '<table class="widefat" style="width:50%; min-width: 300px;">';
112
- echo '<tr>' .
113
- '<th>' . __( 'Product', 'woocommerce-jetpack' ) . '</th>' .
114
- '<th>' . __( 'Price Type', 'woocommerce-jetpack' ) . '</th>' .
115
- '<th>' . __( 'Price', 'woocommerce-jetpack' ) . '</th>' .
116
- '<th>' . __( 'Modified Price', 'woocommerce-jetpack' ) . '</th>' .
117
- '</tr>';
118
- while ( $loop->have_posts() ) : $loop->the_post();
119
  $this->change_product_price( $loop->post->ID, $multiply_prices_by, $is_preview );
120
- endwhile;
121
  echo '</table>';
122
-
123
  return ob_get_clean();
124
  }
125
 
126
- /**
127
- * create_bulk_price_converter_tool
128
- */
 
 
129
  public function create_bulk_price_converter_tool() {
130
-
131
- $result_message = '';
 
 
 
132
  $multiply_prices_by = isset( $_POST['multiply_prices_by'] ) ? $_POST['multiply_prices_by'] : 1;
133
  $is_preview = isset( $_POST['bulk_change_prices_preview'] ) ? true : false;
134
-
 
 
135
  if ( $multiply_prices_by <= 0 ) {
136
  $result_message = '<p><div class="error"><p><strong>' . __( 'Multiply value must be above zero.', 'woocommerce-jetpack' ) . '</strong></p></div></p>';
137
  $multiply_prices_by = 1;
138
  }
139
- else {
140
- if ( isset( $_POST['bulk_change_prices'] ) || isset( $_POST['bulk_change_prices_preview'] ) ) {
141
  $result_changing_prices = $this->change_all_products_prices( $multiply_prices_by, $is_preview );
142
- if ( ! $is_preview ) {
143
  $result_message = '<p><div class="updated"><p><strong>' . __( 'Prices changed successfully!', 'woocommerce-jetpack' ) . '</strong></p></div></p>';
144
  $multiply_prices_by = 1;
145
  }
@@ -147,13 +157,11 @@ class WCJ_Bulk_Price_Converter {
147
  }
148
  ?>
149
  <div>
150
- <h2><?php echo __( 'WooCommerce Jetpack - Bulk Price Converter', 'woocommerce-jetpack' ); ?></h2>
151
- <p><?php echo __( 'Bulk Price Converter Tool.', 'woocommerce-jetpack' ); ?></p>
152
  <?php echo $result_message; ?>
153
  <p><form method="post" action="">
154
- <?php echo __( 'Multiply all product prices by', 'woocommerce-jetpack' ); ?> <input class="" type="text" name="multiply_prices_by" id="multiply_prices_by" value="<?php echo $multiply_prices_by; ?>">
155
  <input class="button-primary" type="submit" name="bulk_change_prices_preview" id="bulk_change_prices_preview" value="Preview Prices">
156
- <input class="button-primary" type="submit" name="bulk_change_prices" id="bulk_change_prices" value="Change Prices">
157
  <?php /*<input type="checkbox" name="make_pretty_prices" id="make_pretty_prices" value="">Make Pretty Prices*/ ?>
158
  </form></p>
159
  <?php if ( $is_preview ) echo $result_changing_prices; ?>
@@ -161,52 +169,52 @@ class WCJ_Bulk_Price_Converter {
161
  <?php
162
  }
163
 
164
-
165
  /**
166
  * make_pretty_price.
167
  *
168
  function make_pretty_price( $price ) {
169
-
170
  if ( 0 == $price )
171
  return $price;
172
 
173
  $the_price = $price;
174
  $the_multiplied_price = $price;
175
-
176
  if ( $the_price < 20 ) {
177
-
178
-
179
  $mod_10_cents = ( $the_multiplied_price * 10 - floor( $the_multiplied_price * 10 ) ) / 10;
180
  // E.g. 14.44 -> 14.39
181
  if ( $mod_10_cents < 0.05 )
182
- $the_multiplied_price = $the_multiplied_price - ( $mod_10_cents + 0.01 );
183
  // E.g. 14.45 -> 14.49
184
  else if ( $mod_10_cents >= 0.05 )
185
- $the_multiplied_price = $the_multiplied_price + ( 0.1 - ( $mod_10_cents + 0.01 ) );
186
-
187
  $mod_100_cents = ( $the_multiplied_price - floor( $the_multiplied_price ) );
188
  // E.g. 14.09 -> 13.99
189
  if ( $mod_100_cents < 0.10 )
190
  $the_multiplied_price = $the_multiplied_price - ( $mod_100_cents + 0.01 );
191
  }
192
 
193
-
194
  if ( $the_price < 99 && $the_price >= 20 )
195
  // E.g. 45.36 -> 44.99
196
  // E.g. 45.60 -> 45.99
197
  $the_multiplied_price = round( $the_multiplied_price ) - 0.01;
198
-
199
  if ( $the_price >= 100 ) {
200
-
201
  $the_multiplied_price = round( $the_multiplied_price );
202
-
203
  $mod_10 = $the_multiplied_price % 10;
204
  if ( $mod_10 < 5 )
205
  // E.g. 114.00 -> 109.00
206
- $the_multiplied_price = $the_multiplied_price - ( $mod_10 + 1 );
207
  else if ( $mod_10 >= 5 )
208
  // E.g. 115.00 -> 119.00
209
- $the_multiplied_price = $the_multiplied_price + ( 10 - ( $mod_10 + 1 ) );
210
 
211
  if ( $the_price >= 200 ) {
212
  $mod_100 = $the_multiplied_price % 100;
@@ -214,73 +222,38 @@ class WCJ_Bulk_Price_Converter {
214
  // E.g. 209.00 -> 199.00
215
  $the_multiplied_price = $the_multiplied_price - ( $mod_100 + 1 );
216
  }
217
- }
218
-
219
  return $the_multiplied_price;
220
- }
221
-
222
  /**
223
  * add_bulk_price_converter_tool_info_to_tools_dashboard.
224
  */
225
  public function add_bulk_price_converter_tool_info_to_tools_dashboard() {
226
  echo '<tr>';
227
- if ( 'yes' === get_option( 'wcj_bulk_price_converter_enabled') )
228
  $is_enabled = '<span style="color:green;font-style:italic;">' . __( 'enabled', 'woocommerce-jetpack' ) . '</span>';
229
  else
230
  $is_enabled = '<span style="color:gray;font-style:italic;">' . __( 'disabled', 'woocommerce-jetpack' ) . '</span>';
231
  echo '<td>' . __( 'Bulk Price Converter', 'woocommerce-jetpack' ) . '</td>';
232
  echo '<td>' . $is_enabled . '</td>';
233
  echo '<td>' . __( 'Bulk Price Converter Tool.', 'woocommerce-jetpack' ) . '</td>';
234
- echo '</tr>';
235
- }
236
-
237
- /**
238
- * add_enabled_option.
239
- */
240
- public function add_enabled_option( $settings ) {
241
- $all_settings = $this->get_settings();
242
- $settings[] = $all_settings[1];
243
- return $settings;
244
- }
245
-
246
- /**
247
- * get_settings.
248
- */
249
- function get_settings() {
250
-
251
- $settings = array(
252
-
253
- array(
254
- 'title' => __( 'Bulk Price Converter Options', 'woocommerce-jetpack' ),
255
- 'type' => 'title',
256
- 'desc' => __( 'When enabled, the tool is accessible through WooCommerce > Jetpack Tools > Bulk Price Converter.', 'woocommerce-jetpack' ),
257
- 'id' => 'wcj_bulk_price_converter_options'
258
- ),
259
-
260
- array(
261
- 'title' => __( 'Bulk Price Converter', 'woocommerce-jetpack' ),
262
- 'desc' => '<strong>' . __( 'Enable Module', 'woocommerce-jetpack' ) . '</strong>',
263
- 'desc_tip' => __( 'Multiply all WooCommerce products prices by set value.', 'woocommerce-jetpack' ),
264
- 'id' => 'wcj_bulk_price_converter_enabled',
265
- 'default' => 'no',
266
- 'type' => 'checkbox',
267
- ),
268
-
269
- array( 'type' => 'sectionend', 'id' => 'wcj_bulk_price_converter_options' ),
270
- );
271
-
272
- return $settings;
273
- }
274
-
275
- /**
276
- * settings_section.
277
- */
278
- function settings_section( $sections ) {
279
- $sections['bulk_price_converter'] = __( 'Bulk Price Converter', 'woocommerce-jetpack' );
280
- return $sections;
281
- }
282
  }
283
-
284
  endif;
285
-
286
  return new WCJ_Bulk_Price_Converter();
4
  *
5
  * The WooCommerce Jetpack Bulk Price Converter class.
6
  *
7
+ * @version 2.3.0
8
+ * @author Algoritmika Ltd.
 
 
9
  */
10
+
11
  if ( ! defined( 'ABSPATH' ) ) exit;
12
+
13
  if ( ! class_exists( 'WCJ_Bulk_Price_Converter' ) ) :
14
+
15
+ class WCJ_Bulk_Price_Converter extends WCJ_Module {
16
+
17
+ /**
18
+ * Constructor.
19
+ *
20
+ * @version 2.3.0
21
+ */
22
+ public function __construct() {
23
+
24
+ $this->id = 'bulk_price_converter';
25
+ $this->short_desc = __( 'Bulk Price Converter', 'woocommerce-jetpack' );
26
+ $this->desc = __( 'Multiply all WooCommerce products prices by set value.', 'woocommerce-jetpack' );
27
+ parent::__construct();
28
+
29
+ $this->add_tools( array( 'bulk_price_converter' => __( 'Bulk Price Converter Tool', 'woocommerce-jetpack' ), ) );
30
+
31
+ if ( $this->is_enabled() ) {
32
+ add_filter( 'wcj_tools_tabs', array( $this, 'add_bulk_price_converter_tool_tab' ), 100 );
33
+ add_action( 'wcj_tools_bulk_price_converter', array( $this, 'create_bulk_price_converter_tool' ), 100 );
34
+ }
35
+ add_action( 'wcj_tools_dashboard', array( $this, 'add_bulk_price_converter_tool_info_to_tools_dashboard' ), 100 );
36
+ }
37
+
38
  /**
39
  * add_bulk_price_converter_tool_tab.
40
  */
44
  'title' => __( 'Bulk Price Converter', 'woocommerce-jetpack' ),
45
  );
46
  return $tabs;
47
+ }
48
+
49
  /**
50
  * change_price_by_type.
51
+ *
52
+ * @version 2.3.0
53
+ */
54
  public function change_price_by_type( $product_id, $multiply_price_by, $price_type, $is_preview ) {
55
  $the_price = get_post_meta( $product_id, '_' . $price_type, true );
56
+ $the_modified_price = $the_price;
57
  if ( '' != $the_price ) {
58
  $precision = get_option( 'woocommerce_price_num_decimals', 2 );
59
  $the_modified_price = round( $the_price * $multiply_price_by, $precision );
62
  if ( ! $is_preview )
63
  update_post_meta( $product_id, '_' . $price_type, $the_modified_price );
64
  }
65
+
66
+ echo '<tr>' .
67
+ '<td>' . get_the_title( $product_id ) . '</td>' .
68
+ '<td><em>' . $price_type . '</em></td>' .
69
+ '<td>' . $the_price . '</td>' .
70
+ '<td>' . $the_modified_price . '</td>' .
71
+ '</tr>';
72
  }
73
+
74
  /**
75
  * change_price_all_types.
76
  */
78
  $this->change_price_by_type( $product_id, $multiply_price_by, 'price', $is_preview );
79
  $this->change_price_by_type( $product_id, $multiply_price_by, 'sale_price', $is_preview );
80
  $this->change_price_by_type( $product_id, $multiply_price_by, 'regular_price', $is_preview );
81
+ }
82
 
83
  /**
84
  * change_product_price.
93
  $this->change_price_all_types( $variation['variation_id'], $multiply_price_by, $is_preview );
94
  }
95
  }
96
+ }
97
 
98
+ /**
99
+ * change_all_products_prices
100
+ */
101
+ public function change_all_products_prices( $multiply_prices_by, $is_preview ) {
102
  $multiply_prices_by = floatval( $multiply_prices_by );
103
  if ( $multiply_prices_by <= 0 )
104
+ return;
105
+
106
  ob_start();
107
 
108
  $args = array(
109
+ 'post_type' => 'product',
110
+ 'post_status' => 'any',
111
+ 'posts_per_page' => -1,
112
  );
113
  $loop = new WP_Query( $args );
114
  echo '<table class="widefat" style="width:50%; min-width: 300px;">';
115
+ echo '<tr>' .
116
+ '<th>' . __( 'Product', 'woocommerce-jetpack' ) . '</th>' .
117
+ '<th>' . __( 'Price Type', 'woocommerce-jetpack' ) . '</th>' .
118
+ '<th>' . __( 'Price', 'woocommerce-jetpack' ) . '</th>' .
119
+ '<th>' . __( 'Modified Price', 'woocommerce-jetpack' ) . '</th>' .
120
+ '</tr>';
121
+ while ( $loop->have_posts() ) : $loop->the_post();
122
  $this->change_product_price( $loop->post->ID, $multiply_prices_by, $is_preview );
123
+ endwhile;
124
  echo '</table>';
125
+
126
  return ob_get_clean();
127
  }
128
 
129
+ /**
130
+ * create_bulk_price_converter_tool.
131
+ *
132
+ * @version 2.3.0
133
+ */
134
  public function create_bulk_price_converter_tool() {
135
+
136
+ echo $this->get_back_to_settings_link_html();
137
+
138
+ $result_message = '';
139
+
140
  $multiply_prices_by = isset( $_POST['multiply_prices_by'] ) ? $_POST['multiply_prices_by'] : 1;
141
  $is_preview = isset( $_POST['bulk_change_prices_preview'] ) ? true : false;
142
+
143
+ $result_changing_prices = '';
144
+
145
  if ( $multiply_prices_by <= 0 ) {
146
  $result_message = '<p><div class="error"><p><strong>' . __( 'Multiply value must be above zero.', 'woocommerce-jetpack' ) . '</strong></p></div></p>';
147
  $multiply_prices_by = 1;
148
  }
149
+ else {
150
+ if ( isset( $_POST['bulk_change_prices'] ) || isset( $_POST['bulk_change_prices_preview'] ) ) {
151
  $result_changing_prices = $this->change_all_products_prices( $multiply_prices_by, $is_preview );
152
+ if ( ! $is_preview ) {
153
  $result_message = '<p><div class="updated"><p><strong>' . __( 'Prices changed successfully!', 'woocommerce-jetpack' ) . '</strong></p></div></p>';
154
  $multiply_prices_by = 1;
155
  }
157
  }
158
  ?>
159
  <div>
 
 
160
  <?php echo $result_message; ?>
161
  <p><form method="post" action="">
162
+ <?php echo __( 'Multiply all product prices by', 'woocommerce-jetpack' ); ?> <input class="" type="number" step="0.000001" min="0.000001" name="multiply_prices_by" id="multiply_prices_by" value="<?php echo $multiply_prices_by; ?>">
163
  <input class="button-primary" type="submit" name="bulk_change_prices_preview" id="bulk_change_prices_preview" value="Preview Prices">
164
+ <?php if ( isset( $_POST['bulk_change_prices_preview'] ) ) { ?><input class="button-primary" type="submit" name="bulk_change_prices" id="bulk_change_prices" value="Change Prices"><?php } ?>
165
  <?php /*<input type="checkbox" name="make_pretty_prices" id="make_pretty_prices" value="">Make Pretty Prices*/ ?>
166
  </form></p>
167
  <?php if ( $is_preview ) echo $result_changing_prices; ?>
169
  <?php
170
  }
171
 
172
+
173
  /**
174
  * make_pretty_price.
175
  *
176
  function make_pretty_price( $price ) {
177
+
178
  if ( 0 == $price )
179
  return $price;
180
 
181
  $the_price = $price;
182
  $the_multiplied_price = $price;
183
+
184
  if ( $the_price < 20 ) {
185
+
186
+
187
  $mod_10_cents = ( $the_multiplied_price * 10 - floor( $the_multiplied_price * 10 ) ) / 10;
188
  // E.g. 14.44 -> 14.39
189
  if ( $mod_10_cents < 0.05 )
190
+ $the_multiplied_price = $the_multiplied_price - ( $mod_10_cents + 0.01 );
191
  // E.g. 14.45 -> 14.49
192
  else if ( $mod_10_cents >= 0.05 )
193
+ $the_multiplied_price = $the_multiplied_price + ( 0.1 - ( $mod_10_cents + 0.01 ) );
194
+
195
  $mod_100_cents = ( $the_multiplied_price - floor( $the_multiplied_price ) );
196
  // E.g. 14.09 -> 13.99
197
  if ( $mod_100_cents < 0.10 )
198
  $the_multiplied_price = $the_multiplied_price - ( $mod_100_cents + 0.01 );
199
  }
200
 
201
+
202
  if ( $the_price < 99 && $the_price >= 20 )
203
  // E.g. 45.36 -> 44.99
204
  // E.g. 45.60 -> 45.99
205
  $the_multiplied_price = round( $the_multiplied_price ) - 0.01;
206
+
207
  if ( $the_price >= 100 ) {
208
+
209
  $the_multiplied_price = round( $the_multiplied_price );
210
+
211
  $mod_10 = $the_multiplied_price % 10;
212
  if ( $mod_10 < 5 )
213
  // E.g. 114.00 -> 109.00
214
+ $the_multiplied_price = $the_multiplied_price - ( $mod_10 + 1 );
215
  else if ( $mod_10 >= 5 )
216
  // E.g. 115.00 -> 119.00
217
+ $the_multiplied_price = $the_multiplied_price + ( 10 - ( $mod_10 + 1 ) );
218
 
219
  if ( $the_price >= 200 ) {
220
  $mod_100 = $the_multiplied_price % 100;
222
  // E.g. 209.00 -> 199.00
223
  $the_multiplied_price = $the_multiplied_price - ( $mod_100 + 1 );
224
  }
225
+ }
226
+
227
  return $the_multiplied_price;
228
+ }
229
+
230
  /**
231
  * add_bulk_price_converter_tool_info_to_tools_dashboard.
232
  */
233
  public function add_bulk_price_converter_tool_info_to_tools_dashboard() {
234
  echo '<tr>';
235
+ if ( 'yes' === get_option( 'wcj_bulk_price_converter_enabled') )
236
  $is_enabled = '<span style="color:green;font-style:italic;">' . __( 'enabled', 'woocommerce-jetpack' ) . '</span>';
237
  else
238
  $is_enabled = '<span style="color:gray;font-style:italic;">' . __( 'disabled', 'woocommerce-jetpack' ) . '</span>';
239
  echo '<td>' . __( 'Bulk Price Converter', 'woocommerce-jetpack' ) . '</td>';
240
  echo '<td>' . $is_enabled . '</td>';
241
  echo '<td>' . __( 'Bulk Price Converter Tool.', 'woocommerce-jetpack' ) . '</td>';
242
+ echo '</tr>';
243
+ }
244
+
245
+ /**
246
+ * get_settings.
247
+ *
248
+ * @version 2.3.0
249
+ */
250
+ function get_settings() {
251
+ $settings = array();
252
+ $settings = $this->add_tools_list( $settings );
253
+ return $this->add_enable_module_setting( $settings );
254
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
  }
256
+
257
  endif;
258
+
259
  return new WCJ_Bulk_Price_Converter();
includes/class-wcj-product-input-fields.php CHANGED
@@ -18,12 +18,12 @@ class WCJ_Product_Input_Fields {
18
  * Constructor.
19
  * @version 2.2.2
20
  */
21
- public function __construct() {
22
 
23
  include_once( 'input-fields/class-wcj-product-input-fields-abstract.php' );
24
 
25
- // Main hooks
26
- if ( 'yes' === get_option( 'wcj_product_input_fields_enabled' ) ) {
27
 
28
  add_action( 'woocommerce_delete_order_items', array( $this, 'delete_file_uploads' ) );
29
 
@@ -36,20 +36,21 @@ class WCJ_Product_Input_Fields {
36
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
37
  add_action( 'init', array( $this, 'register_scripts' ) );
38
  }
39
- }
40
 
41
- // Settings hooks
42
- add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
43
- add_filter( 'wcj_settings_product_input_fields', array( $this, 'get_settings' ), 100 );
44
- add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
45
- }
46
 
47
  /**
48
  * delete_file_uploads.
 
49
  * @version 2.2.2
50
  * @since 2.2.2
51
  */
52
- public function delete_file_uploads( $postid ) {
53
  $the_order = wc_get_order( $postid );
54
  $the_items = $the_order->get_items();
55
  foreach ( $the_items as $item ) {
@@ -68,7 +69,7 @@ class WCJ_Product_Input_Fields {
68
  * @version 2.2.2
69
  * @since 2.2.2
70
  */
71
- public function handle_downloads() {
72
  if ( isset ( $_GET['wcj_download_file'] ) ) {
73
  $file_name = $_GET['wcj_download_file'];
74
  $upload_dir = wcj_get_wcj_uploads_dir( 'input_fields_uploads' );
@@ -87,107 +88,107 @@ class WCJ_Product_Input_Fields {
87
  }
88
 
89
  /**
90
- * register_script.
91
- */
92
- public function register_scripts() {
93
- wp_register_script( 'wcj-product-input-fields', WCJ()->plugin_url() . '/includes/js/product-input-fields.js', array( 'jquery' ), false, true );
94
- }
95
-
96
- /**
97
- * enqueue_checkout_script.
98
- */
99
- public function enqueue_scripts() {
100
- if( ! is_product() ) return;
101
  wp_enqueue_script( 'wcj-product-input-fields' );
102
- }
103
 
104
- /**
105
- * get_options.
106
- */
107
  public function get_options() {
108
  $product_input_fields_abstract = new WCJ_Product_Input_Fields_Abstract();
109
  $product_input_fields_abstract->scope = 'global';
110
  return $product_input_fields_abstract->get_options();
111
  }
112
 
113
- /**
114
- * add_enabled_option.
115
- */
116
- public function add_enabled_option( $settings ) {
117
- $all_settings = $this->get_settings();
118
- $settings[] = $all_settings[1];
119
- return $settings;
120
- }
121
 
122
- /**
123
- * get_settings.
124
- */
125
- function get_settings() {
126
 
127
- $settings = array(
128
 
129
- array( 'title' => __( 'Product Input Fields Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_product_input_fields_options' ),
130
 
131
- array(
132
- 'title' => __( 'Product Input Fields', 'woocommerce-jetpack' ),
133
- 'desc' => '<strong>' . __( 'Enable Module', 'woocommerce-jetpack' ) . '</strong>',
134
- 'desc_tip' => __( 'WooCommerce product input fields.', 'woocommerce-jetpack' ),
135
- 'id' => 'wcj_product_input_fields_enabled',
136
- 'default' => 'no',
137
- 'type' => 'checkbox',
138
- ),
139
 
140
- array( 'type' => 'sectionend', 'id' => 'wcj_product_input_fields_options' ),
141
 
142
- array(
143
  'title' => __( 'Product Input Fields per Product Options', 'woocommerce-jetpack' ),
144
  'type' => 'title',
145
  'desc' => __( 'Add custom input fields to product\'s single page for customer to fill before adding product to cart.', 'woocommerce-jetpack' )
146
- . ' '
147
  . __( 'When enabled this module will add "Product Input Fields" tab to product\'s "Edit" page.', 'woocommerce-jetpack' ),
148
  'id' => 'wcj_product_input_fields_local_options',
149
  ),
150
 
151
- array(
152
- 'title' => __( 'Product Input Fields - per Product', 'woocommerce-jetpack' ),
153
- 'desc' => '<strong>' . __( 'Enable', 'woocommerce-jetpack' ) . '</strong>',
154
- 'desc_tip' => __( 'Add custom input field on per product basis.', 'woocommerce-jetpack' ),
155
- 'id' => 'wcj_product_input_fields_local_enabled',
156
- 'default' => 'no',
157
- 'type' => 'checkbox',
158
- ),
159
-
160
- array(
161
- 'title' => __( 'Default Number of Product Input Fields per Product', 'woocommerce-jetpack' ),
162
- 'id' => 'wcj_product_input_fields_local_total_number_default',
163
  'desc_tip' => __( 'You will be able to change this number later as well as define the fields, for each product individually, in product\'s "Edit".', 'woocommerce-jetpack' ),
164
- 'default' => 1,
165
- 'type' => 'number',
166
  'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
167
  'custom_attributes'
168
  => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
169
- ),
170
 
171
- array(
172
  'type' => 'sectionend',
173
  'id' => 'wcj_product_input_fields_local_options',
174
  ),
175
 
176
- array(
177
  'title' => __( 'Product Input Fields Global Options', 'woocommerce-jetpack' ),
178
  'type' => 'title',
179
  'desc' => __( 'Add custom input fields to product\'s single page for customer to fill before adding product to cart.', 'woocommerce-jetpack' ),
180
  'id' => 'wcj_product_input_fields_global_options',
181
  ),
182
 
183
- array(
184
- 'title' => __( 'Product Input Fields - All Products', 'woocommerce-jetpack' ),
185
- 'desc' => '<strong>' . __( 'Enable', 'woocommerce-jetpack' ) . '</strong>',
186
- 'desc_tip' => __( 'Add custom input fields to all products.', 'woocommerce-jetpack' ),
187
- 'id' => 'wcj_product_input_fields_global_enabled',
188
- 'default' => 'no',
189
- 'type' => 'checkbox',
190
- ),
191
 
192
  array(
193
  'title' => __( 'Product Input Fields Number', 'woocommerce-jetpack' ),
@@ -199,7 +200,7 @@ class WCJ_Product_Input_Fields {
199
  'custom_attributes'
200
  => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
201
  ),
202
- );
203
 
204
  $options = $this->get_options();
205
  for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_product_input_fields_global_total_number', 1 ) ); $i++ ) {
@@ -212,7 +213,7 @@ class WCJ_Product_Input_Fields {
212
  'default' => $option['default'],
213
  'type' => $option['type'],
214
  'options' => isset( $option['options'] ) ? $option['options'] : '',
215
- 'css' => 'width:30%;min-width:300px;',
216
  );
217
  }
218
  }
@@ -224,29 +225,29 @@ class WCJ_Product_Input_Fields {
224
  );
225
 
226
  $settings = array_merge( $settings, array(
227
- array( 'title' => __( 'Admin Order View Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_product_input_fields_admin_view_options' ),
228
 
229
- array(
230
- 'title' => __( 'Replace Field ID with Field Label', 'woocommerce-jetpack' ),
231
- 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
232
- 'id' => 'wcj_product_input_fields_make_nicer_name_enabled',
233
- 'default' => 'yes',
234
- 'type' => 'checkbox',
235
- ),
236
 
237
- array( 'type' => 'sectionend', 'id' => 'wcj_product_input_fields_admin_view_options' ),
238
  ) );
239
 
240
- return $settings;
241
- }
242
 
243
- /**
244
- * settings_section.
245
- */
246
- function settings_section( $sections ) {
247
- $sections['product_input_fields'] = __( 'Product Input Fields', 'woocommerce-jetpack' );
248
- return $sections;
249
- }
250
  }
251
 
252
  endif;
18
  * Constructor.
19
  * @version 2.2.2
20
  */
21
+ public function __construct() {
22
 
23
  include_once( 'input-fields/class-wcj-product-input-fields-abstract.php' );
24
 
25
+ // Main hooks
26
+ if ( 'yes' === get_option( 'wcj_product_input_fields_enabled' ) ) {
27
 
28
  add_action( 'woocommerce_delete_order_items', array( $this, 'delete_file_uploads' ) );
29
 
36
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
37
  add_action( 'init', array( $this, 'register_scripts' ) );
38
  }
39
+ }
40
 
41
+ // Settings hooks
42
+ add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
43
+ add_filter( 'wcj_settings_product_input_fields', array( $this, 'get_settings' ), 100 );
44
+ add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
45
+ }
46
 
47
  /**
48
  * delete_file_uploads.
49
+ *
50
  * @version 2.2.2
51
  * @since 2.2.2
52
  */
53
+ public function delete_file_uploads( $postid ) {
54
  $the_order = wc_get_order( $postid );
55
  $the_items = $the_order->get_items();
56
  foreach ( $the_items as $item ) {
69
  * @version 2.2.2
70
  * @since 2.2.2
71
  */
72
+ public function handle_downloads() {
73
  if ( isset ( $_GET['wcj_download_file'] ) ) {
74
  $file_name = $_GET['wcj_download_file'];
75
  $upload_dir = wcj_get_wcj_uploads_dir( 'input_fields_uploads' );
88
  }
89
 
90
  /**
91
+ * register_script.
92
+ */
93
+ public function register_scripts() {
94
+ wp_register_script( 'wcj-product-input-fields', WCJ()->plugin_url() . '/includes/js/product-input-fields.js', array( 'jquery' ), false, true );
95
+ }
96
+
97
+ /**
98
+ * enqueue_checkout_script.
99
+ */
100
+ public function enqueue_scripts() {
101
+ if( ! is_product() ) return;
102
  wp_enqueue_script( 'wcj-product-input-fields' );
103
+ }
104
 
105
+ /**
106
+ * get_options.
107
+ */
108
  public function get_options() {
109
  $product_input_fields_abstract = new WCJ_Product_Input_Fields_Abstract();
110
  $product_input_fields_abstract->scope = 'global';
111
  return $product_input_fields_abstract->get_options();
112
  }
113
 
114
+ /**
115
+ * add_enabled_option.
116
+ */
117
+ public function add_enabled_option( $settings ) {
118
+ $all_settings = $this->get_settings();
119
+ $settings[] = $all_settings[1];
120
+ return $settings;
121
+ }
122
 
123
+ /**
124
+ * get_settings.
125
+ */
126
+ function get_settings() {
127
 
128
+ $settings = array(
129
 
130
+ array( 'title' => __( 'Product Input Fields Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_product_input_fields_options' ),
131
 
132
+ array(
133
+ 'title' => __( 'Product Input Fields', 'woocommerce-jetpack' ),
134
+ 'desc' => '<strong>' . __( 'Enable Module', 'woocommerce-jetpack' ) . '</strong>',
135
+ 'desc_tip' => __( 'WooCommerce product input fields.', 'woocommerce-jetpack' ),
136
+ 'id' => 'wcj_product_input_fields_enabled',
137
+ 'default' => 'no',
138
+ 'type' => 'checkbox',
139
+ ),
140
 
141
+ array( 'type' => 'sectionend', 'id' => 'wcj_product_input_fields_options' ),
142
 
143
+ array(
144
  'title' => __( 'Product Input Fields per Product Options', 'woocommerce-jetpack' ),
145
  'type' => 'title',
146
  'desc' => __( 'Add custom input fields to product\'s single page for customer to fill before adding product to cart.', 'woocommerce-jetpack' )
147
+ . ' '
148
  . __( 'When enabled this module will add "Product Input Fields" tab to product\'s "Edit" page.', 'woocommerce-jetpack' ),
149
  'id' => 'wcj_product_input_fields_local_options',
150
  ),
151
 
152
+ array(
153
+ 'title' => __( 'Product Input Fields - per Product', 'woocommerce-jetpack' ),
154
+ 'desc' => '<strong>' . __( 'Enable', 'woocommerce-jetpack' ) . '</strong>',
155
+ 'desc_tip' => __( 'Add custom input field on per product basis.', 'woocommerce-jetpack' ),
156
+ 'id' => 'wcj_product_input_fields_local_enabled',
157
+ 'default' => 'no',
158
+ 'type' => 'checkbox',
159
+ ),
160
+
161
+ array(
162
+ 'title' => __( 'Default Number of Product Input Fields per Product', 'woocommerce-jetpack' ),
163
+ 'id' => 'wcj_product_input_fields_local_total_number_default',
164
  'desc_tip' => __( 'You will be able to change this number later as well as define the fields, for each product individually, in product\'s "Edit".', 'woocommerce-jetpack' ),
165
+ 'default' => 1,
166
+ 'type' => 'number',
167
  'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
168
  'custom_attributes'
169
  => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
170
+ ),
171
 
172
+ array(
173
  'type' => 'sectionend',
174
  'id' => 'wcj_product_input_fields_local_options',
175
  ),
176
 
177
+ array(
178
  'title' => __( 'Product Input Fields Global Options', 'woocommerce-jetpack' ),
179
  'type' => 'title',
180
  'desc' => __( 'Add custom input fields to product\'s single page for customer to fill before adding product to cart.', 'woocommerce-jetpack' ),
181
  'id' => 'wcj_product_input_fields_global_options',
182
  ),
183
 
184
+ array(
185
+ 'title' => __( 'Product Input Fields - All Products', 'woocommerce-jetpack' ),
186
+ 'desc' => '<strong>' . __( 'Enable', 'woocommerce-jetpack' ) . '</strong>',
187
+ 'desc_tip' => __( 'Add custom input fields to all products.', 'woocommerce-jetpack' ),
188
+ 'id' => 'wcj_product_input_fields_global_enabled',
189
+ 'default' => 'no',
190
+ 'type' => 'checkbox',
191
+ ),
192
 
193
  array(
194
  'title' => __( 'Product Input Fields Number', 'woocommerce-jetpack' ),
200
  'custom_attributes'
201
  => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
202
  ),
203
+ );
204
 
205
  $options = $this->get_options();
206
  for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_product_input_fields_global_total_number', 1 ) ); $i++ ) {
213
  'default' => $option['default'],
214
  'type' => $option['type'],
215
  'options' => isset( $option['options'] ) ? $option['options'] : '',
216
+ 'css' => 'width:30%;min-width:300px;',
217
  );
218
  }
219
  }
225
  );
226
 
227
  $settings = array_merge( $settings, array(
228
+ array( 'title' => __( 'Admin Order View Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_product_input_fields_admin_view_options' ),
229
 
230
+ array(
231
+ 'title' => __( 'Replace Field ID with Field Label', 'woocommerce-jetpack' ),
232
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
233
+ 'id' => 'wcj_product_input_fields_make_nicer_name_enabled',
234
+ 'default' => 'yes',
235
+ 'type' => 'checkbox',
236
+ ),
237
 
238
+ array( 'type' => 'sectionend', 'id' => 'wcj_product_input_fields_admin_view_options' ),
239
  ) );
240
 
241
+ return $settings;
242
+ }
243
 
244
+ /**
245
+ * settings_section.
246
+ */
247
+ function settings_section( $sections ) {
248
+ $sections['product_input_fields'] = __( 'Product Input Fields', 'woocommerce-jetpack' );
249
+ return $sections;
250
+ }
251
  }
252
 
253
  endif;
includes/class-wcj-product-tabs.php CHANGED
@@ -29,7 +29,7 @@ class WCJ_Product_Tabs extends WCJ_Module {
29
  if ( $this->is_enabled() ) {
30
  add_filter( 'woocommerce_product_tabs', array( $this, 'customize_product_tabs' ), 98 );
31
  if ( 'yes' === get_option( 'wcj_custom_product_tabs_local_enabled' ) ) {
32
- add_action( 'add_meta_boxes', array( $this, 'add_custom_tabs_meta_box' ) );
33
  add_action( 'save_post_product', array( $this, 'save_custom_tabs_meta_box' ), 100, 2 );
34
  }
35
  }
29
  if ( $this->is_enabled() ) {
30
  add_filter( 'woocommerce_product_tabs', array( $this, 'customize_product_tabs' ), 98 );
31
  if ( 'yes' === get_option( 'wcj_custom_product_tabs_local_enabled' ) ) {
32
+ add_action( 'add_meta_boxes', array( $this, 'add_custom_tabs_meta_box' ) );
33
  add_action( 'save_post_product', array( $this, 'save_custom_tabs_meta_box' ), 100, 2 );
34
  }
35
  }
includes/class-wcj-reports.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Reports class.
6
  *
7
- * @version 2.2.4
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -33,10 +33,12 @@ class WCJ_Reports {
33
  if ( is_admin() ) {
34
  add_filter( 'woocommerce_admin_reports', array( $this, 'add_customers_by_country_report' ) );
35
  add_filter( 'woocommerce_admin_reports', array( $this, 'add_stock_reports' ) );
 
36
  add_action( 'init', array( $this, 'catch_arguments' ) );
37
 
38
  include_once( 'reports/wcj-class-reports-customers.php' );
39
  include_once( 'reports/wcj-class-reports-stock.php' );
 
40
 
41
  add_action( 'admin_bar_menu', array( $this, 'add_custom_order_reports_ranges_to_admin_bar' ), PHP_INT_MAX );
42
  add_action( 'admin_bar_menu', array( $this, 'add_custom_order_reports_ranges_by_month_to_admin_bar' ), PHP_INT_MAX );
@@ -64,7 +66,7 @@ class WCJ_Reports {
64
  $args = array(
65
  'parent' => false,
66
  'id' => $parent,
67
- 'title' => __( 'WooJetpack: More Ranges - Months', 'woocommerce-jetpack' ),
68
  'href' => false,
69
  'meta' => array( 'title' => __( 'Select Range', 'woocommerce-jetpack' ), ),
70
  );
@@ -99,7 +101,7 @@ class WCJ_Reports {
99
  $args = array(
100
  'parent' => false,
101
  'id' => $parent,
102
- 'title' => __( 'WooJetpack: More Ranges', 'woocommerce-jetpack' ),
103
  'href' => false,
104
  'meta' => array( 'title' => __( 'Select Range', 'woocommerce-jetpack' ), ),
105
  );
@@ -185,6 +187,14 @@ class WCJ_Reports {
185
  $this->group_countries = ( 'customers_by_country_sets' === $this->report_id ) ? 'yes' : 'no';
186
  }
187
 
 
 
 
 
 
 
 
 
188
  /**
189
  * get_report_stock.
190
  */
@@ -204,27 +214,45 @@ class WCJ_Reports {
204
  echo $report->get_report();
205
  }
206
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  /**
208
  * Add reports to WooCommerce > Reports > Stock
209
  */
210
  public function add_stock_reports( $reports ) {
211
 
212
  $reports['stock']['reports']['on_stock'] = array(
213
- 'title' => __( 'WooJetpack: All in stock', 'woocommerce-jetpack' ),
214
  'description' => '',
215
  'hide_title' => true,
216
  'callback' => array( $this, 'get_report_stock' ),
217
  );
218
 
219
  $reports['stock']['reports']['understocked'] = array(
220
- 'title' => __( 'WooJetpack: Understocked', 'woocommerce-jetpack' ),
221
  'description' => '',
222
  'hide_title' => true,
223
  'callback' => array( $this, 'get_report_stock' ),
224
  );
225
 
226
  $reports['stock']['reports']['overstocked'] = array(
227
- 'title' => __( 'WooJetpack: Overstocked', 'woocommerce-jetpack' ),
228
  'description' => '',
229
  'hide_title' => true,
230
  'callback' => array( $this, 'get_report_stock' ),
@@ -239,14 +267,14 @@ class WCJ_Reports {
239
  public function add_customers_by_country_report( $reports ) {
240
 
241
  $reports['customers']['reports']['customers_by_country'] = array(
242
- 'title' => __( 'WooJetpack: Customers by Country', 'woocommerce-jetpack' ),
243
  'description' => '',
244
  'hide_title' => true,
245
  'callback' => array( $this, 'get_report_customers' ),
246
  );
247
 
248
  $reports['customers']['reports']['customers_by_country_sets'] = array(
249
- 'title' => __( 'WooJetpack: Customers by Country Sets', 'woocommerce-jetpack' ),
250
  'description' => '',
251
  'hide_title' => true,
252
  'callback' => array( $this, 'get_report_customers' ),
@@ -288,15 +316,15 @@ class WCJ_Reports {
288
  'title' => __( 'Available Reports', 'woocommerce-jetpack' ),
289
  'type' => 'title',
290
  'desc' => '<p>'
291
- . __( 'WooJetpack: Customers by Country. Available in WooCommerce > Reports > Customers.', 'woocommerce-jetpack' )
292
  . '</p><p>'
293
- . __( 'WooJetpack: Customers by Country Sets. Available in WooCommerce > Reports > Customers.', 'woocommerce-jetpack' )
294
  . '</p><p>'
295
- . __( 'WooJetpack: All in Stock with sales data. Available in WooCommerce > Reports > Stock.', 'woocommerce-jetpack' )
296
  . '</p><p>'
297
- . __( 'WooJetpack: Understocked products (calculated by sales data). Available in WooCommerce > Reports > Stock.', 'woocommerce-jetpack' )
298
  . '</p><p>'
299
- . __( 'WooJetpack: Overstocked products (calculated by sales data). Available in WooCommerce > Reports > Stock.', 'woocommerce-jetpack' )
300
  . '</p>',
301
  'id' => 'wcj_reports_more_options'
302
  ),
4
  *
5
  * The WooCommerce Jetpack Reports class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
33
  if ( is_admin() ) {
34
  add_filter( 'woocommerce_admin_reports', array( $this, 'add_customers_by_country_report' ) );
35
  add_filter( 'woocommerce_admin_reports', array( $this, 'add_stock_reports' ) );
36
+ add_filter( 'woocommerce_admin_reports', array( $this, 'add_sales_reports' ) );
37
  add_action( 'init', array( $this, 'catch_arguments' ) );
38
 
39
  include_once( 'reports/wcj-class-reports-customers.php' );
40
  include_once( 'reports/wcj-class-reports-stock.php' );
41
+ include_once( 'reports/wcj-class-reports-sales.php' );
42
 
43
  add_action( 'admin_bar_menu', array( $this, 'add_custom_order_reports_ranges_to_admin_bar' ), PHP_INT_MAX );
44
  add_action( 'admin_bar_menu', array( $this, 'add_custom_order_reports_ranges_by_month_to_admin_bar' ), PHP_INT_MAX );
66
  $args = array(
67
  'parent' => false,
68
  'id' => $parent,
69
+ 'title' => __( 'Booster: More Ranges - Months', 'woocommerce-jetpack' ),
70
  'href' => false,
71
  'meta' => array( 'title' => __( 'Select Range', 'woocommerce-jetpack' ), ),
72
  );
101
  $args = array(
102
  'parent' => false,
103
  'id' => $parent,
104
+ 'title' => __( 'Booster: More Ranges', 'woocommerce-jetpack' ),
105
  'href' => false,
106
  'meta' => array( 'title' => __( 'Select Range', 'woocommerce-jetpack' ), ),
107
  );
187
  $this->group_countries = ( 'customers_by_country_sets' === $this->report_id ) ? 'yes' : 'no';
188
  }
189
 
190
+ /**
191
+ * get_report_sales.
192
+ */
193
+ public function get_report_sales() {
194
+ $report = new WCJ_Reports_Sales();
195
+ echo $report->get_report();
196
+ }
197
+
198
  /**
199
  * get_report_stock.
200
  */
214
  echo $report->get_report();
215
  }
216
 
217
+ /**
218
+ * Add reports to WooCommerce > Reports > Sales
219
+ *
220
+ * @version 2.3.0
221
+ * @since 2.3.0
222
+ */
223
+ public function add_sales_reports( $reports ) {
224
+
225
+ $reports['orders']['reports']['booster_products_sales'] = array(
226
+ 'title' => __( 'Booster: Product Sales', 'woocommerce-jetpack' ),
227
+ 'description' => '',
228
+ 'hide_title' => true,
229
+ 'callback' => array( $this, 'get_report_sales' ),
230
+ );
231
+
232
+ return $reports;
233
+ }
234
+
235
  /**
236
  * Add reports to WooCommerce > Reports > Stock
237
  */
238
  public function add_stock_reports( $reports ) {
239
 
240
  $reports['stock']['reports']['on_stock'] = array(
241
+ 'title' => __( 'Booster: All in stock', 'woocommerce-jetpack' ),
242
  'description' => '',
243
  'hide_title' => true,
244
  'callback' => array( $this, 'get_report_stock' ),
245
  );
246
 
247
  $reports['stock']['reports']['understocked'] = array(
248
+ 'title' => __( 'Booster: Understocked', 'woocommerce-jetpack' ),
249
  'description' => '',
250
  'hide_title' => true,
251
  'callback' => array( $this, 'get_report_stock' ),
252
  );
253
 
254
  $reports['stock']['reports']['overstocked'] = array(
255
+ 'title' => __( 'Booster: Overstocked', 'woocommerce-jetpack' ),
256
  'description' => '',
257
  'hide_title' => true,
258
  'callback' => array( $this, 'get_report_stock' ),
267
  public function add_customers_by_country_report( $reports ) {
268
 
269
  $reports['customers']['reports']['customers_by_country'] = array(
270
+ 'title' => __( 'Booster: Customers by Country', 'woocommerce-jetpack' ),
271
  'description' => '',
272
  'hide_title' => true,
273
  'callback' => array( $this, 'get_report_customers' ),
274
  );
275
 
276
  $reports['customers']['reports']['customers_by_country_sets'] = array(
277
+ 'title' => __( 'Booster: Customers by Country Sets', 'woocommerce-jetpack' ),
278
  'description' => '',
279
  'hide_title' => true,
280
  'callback' => array( $this, 'get_report_customers' ),
316
  'title' => __( 'Available Reports', 'woocommerce-jetpack' ),
317
  'type' => 'title',
318
  'desc' => '<p>'
319
+ . __( 'Booster: Customers by Country. Available in WooCommerce > Reports > Customers.', 'woocommerce-jetpack' )
320
  . '</p><p>'
321
+ . __( 'Booster: Customers by Country Sets. Available in WooCommerce > Reports > Customers.', 'woocommerce-jetpack' )
322
  . '</p><p>'
323
+ . __( 'Booster: All in Stock with sales data. Available in WooCommerce > Reports > Stock.', 'woocommerce-jetpack' )
324
  . '</p><p>'
325
+ . __( 'Booster: Understocked products (calculated by sales data). Available in WooCommerce > Reports > Stock.', 'woocommerce-jetpack' )
326
  . '</p><p>'
327
+ . __( 'Booster: Overstocked products (calculated by sales data). Available in WooCommerce > Reports > Stock.', 'woocommerce-jetpack' )
328
  . '</p>',
329
  'id' => 'wcj_reports_more_options'
330
  ),
includes/classes/class-wcj-invoice.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Invoice class.
6
  *
7
- * @version 2.2.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -17,33 +17,43 @@ class WCJ_Invoice {
17
  public $order_id;
18
  public $invoice_type;
19
 
20
- /**
21
- * Constructor.
22
- */
23
- public function __construct( $order_id, $invoice_type ) {
24
  $this->order_id = $order_id;
25
  $this->invoice_type = $invoice_type;
26
- }
27
 
28
- /**
29
- * is_created.
30
- */
31
  function is_created() {
32
  return ( '' != get_post_meta( $this->order_id, '_wcj_invoicing_' . $this->invoice_type . '_date', true ) ) ? true : false;
33
  }
34
 
35
- /**
36
- * delete.
37
- */
 
 
38
  function delete() {
39
  update_post_meta( $this->order_id, '_wcj_invoicing_' . $this->invoice_type . '_number_id', 0 );
40
  //update_post_meta( $this->order_id, '_wcj_invoicing_' . $this->invoice_type . '_number', 0 );
41
  update_post_meta( $this->order_id, '_wcj_invoicing_' . $this->invoice_type . '_date', '' );
 
 
 
 
 
 
42
  }
43
 
44
- /**
45
- * create.
46
- */
 
 
47
  function create( $date = '' ) {
48
  $order_id = $this->order_id;
49
  $invoice_type = $this->invoice_type;
@@ -54,7 +64,7 @@ class WCJ_Invoice {
54
  } else {
55
  $the_invoice_number = $order_id;
56
  }
57
- $the_date = ( '' == $date ) ? time() : $date;
58
  update_post_meta( $order_id, '_wcj_invoicing_' . $invoice_type . '_number_id', $the_invoice_number );
59
  //update_post_meta( $order_id, '_wcj_invoicing_' . $invoice_type . '_number', $this->get_invoice_full_number( $the_invoice_number ) );
60
  update_post_meta( $order_id, '_wcj_invoicing_' . $invoice_type . '_date', $the_date );
@@ -62,8 +72,8 @@ class WCJ_Invoice {
62
  }
63
 
64
  /**
65
- * get_file_name.
66
- */
67
  function get_file_name() {
68
  $the_file_name = do_shortcode( get_option( 'wcj_invoicing_' . $this->invoice_type . '_file_name', 'invoice-' . $this->order_id ) . '.pdf' );
69
  if ( '' == $the_file_name ) $the_file_name = 'invoice';
@@ -72,16 +82,16 @@ class WCJ_Invoice {
72
  }
73
 
74
  /**
75
- * get_invoice_date.
76
- */
77
  function get_invoice_date() {
78
  $the_date = get_post_meta( $this->order_id, '_wcj_invoicing_' . $this->invoice_type . '_date', true );
79
  return apply_filters( 'wcj_get_' . $this->invoice_type . '_date', $the_date, $this->order_id );
80
  }
81
 
82
  /**
83
- * get_invoice_number.
84
- */
85
  function get_invoice_number() {
86
  //$the_number = get_post_meta( $this->order_id, '_wcj_invoicing_' . $this->invoice_type . '_number', true );
87
  $the_number_id = get_post_meta( $this->order_id, '_wcj_invoicing_' . $this->invoice_type . '_number_id', true );
@@ -95,9 +105,9 @@ class WCJ_Invoice {
95
  return apply_filters( 'wcj_get_' . $this->invoice_type . '_number', $the_number, $this->order_id );
96
  }
97
 
98
- /**
99
- * get_invoice_full_number.
100
- *
101
  private function get_invoice_full_number( $the_number ) {
102
  $the_prefix = get_option( 'wcj_invoicing_' . $this->invoice_type . '_numbering_prefix' );
103
  $the_suffix = get_option( 'wcj_invoicing_' . $this->invoice_type . '_numbering_suffix' );
4
  *
5
  * The WooCommerce Jetpack Invoice class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
17
  public $order_id;
18
  public $invoice_type;
19
 
20
+ /**
21
+ * Constructor.
22
+ */
23
+ public function __construct( $order_id, $invoice_type ) {
24
  $this->order_id = $order_id;
25
  $this->invoice_type = $invoice_type;
26
+ }
27
 
28
+ /**
29
+ * is_created.
30
+ */
31
  function is_created() {
32
  return ( '' != get_post_meta( $this->order_id, '_wcj_invoicing_' . $this->invoice_type . '_date', true ) ) ? true : false;
33
  }
34
 
35
+ /**
36
+ * delete.
37
+ *
38
+ * @version 2.3.0
39
+ */
40
  function delete() {
41
  update_post_meta( $this->order_id, '_wcj_invoicing_' . $this->invoice_type . '_number_id', 0 );
42
  //update_post_meta( $this->order_id, '_wcj_invoicing_' . $this->invoice_type . '_number', 0 );
43
  update_post_meta( $this->order_id, '_wcj_invoicing_' . $this->invoice_type . '_date', '' );
44
+
45
+ if ( 'yes' === get_option( 'wcj_invoicing_' . $this->invoice_type . '_sequential_enabled' ) ) {
46
+ $option_name = 'wcj_invoicing_' . $this->invoice_type . '_numbering_counter';
47
+ $the_invoice_counter = get_option( $option_name, 1 );
48
+ update_option( $option_name, ( $the_invoice_counter - 1 ) );
49
+ }
50
  }
51
 
52
+ /**
53
+ * create.
54
+ *
55
+ * @version 2.3.0
56
+ */
57
  function create( $date = '' ) {
58
  $order_id = $this->order_id;
59
  $invoice_type = $this->invoice_type;
64
  } else {
65
  $the_invoice_number = $order_id;
66
  }
67
+ $the_date = ( '' == $date ) ? current_time( 'timestamp' ) : $date;
68
  update_post_meta( $order_id, '_wcj_invoicing_' . $invoice_type . '_number_id', $the_invoice_number );
69
  //update_post_meta( $order_id, '_wcj_invoicing_' . $invoice_type . '_number', $this->get_invoice_full_number( $the_invoice_number ) );
70
  update_post_meta( $order_id, '_wcj_invoicing_' . $invoice_type . '_date', $the_date );
72
  }
73
 
74
  /**
75
+ * get_file_name.
76
+ */
77
  function get_file_name() {
78
  $the_file_name = do_shortcode( get_option( 'wcj_invoicing_' . $this->invoice_type . '_file_name', 'invoice-' . $this->order_id ) . '.pdf' );
79
  if ( '' == $the_file_name ) $the_file_name = 'invoice';
82
  }
83
 
84
  /**
85
+ * get_invoice_date.
86
+ */
87
  function get_invoice_date() {
88
  $the_date = get_post_meta( $this->order_id, '_wcj_invoicing_' . $this->invoice_type . '_date', true );
89
  return apply_filters( 'wcj_get_' . $this->invoice_type . '_date', $the_date, $this->order_id );
90
  }
91
 
92
  /**
93
+ * get_invoice_number.
94
+ */
95
  function get_invoice_number() {
96
  //$the_number = get_post_meta( $this->order_id, '_wcj_invoicing_' . $this->invoice_type . '_number', true );
97
  $the_number_id = get_post_meta( $this->order_id, '_wcj_invoicing_' . $this->invoice_type . '_number_id', true );
105
  return apply_filters( 'wcj_get_' . $this->invoice_type . '_number', $the_number, $this->order_id );
106
  }
107
 
108
+ /**
109
+ * get_invoice_full_number.
110
+ *
111
  private function get_invoice_full_number( $the_number ) {
112
  $the_prefix = get_option( 'wcj_invoicing_' . $this->invoice_type . '_numbering_prefix' );
113
  $the_suffix = get_option( 'wcj_invoicing_' . $this->invoice_type . '_numbering_suffix' );
includes/classes/class-wcj-module.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Module class.
6
  *
7
- * @version 2.2.7
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
@@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
13
 
14
  if ( ! class_exists( 'WCJ_Module' ) ) :
15
 
16
- class WCJ_Module {
17
 
18
  public $id;
19
  public $short_desc;
@@ -63,16 +63,21 @@ class WCJ_Module {
63
  /**
64
  * add_meta_box.
65
  *
66
- * @since 2.2.6
 
67
  */
68
  function add_meta_box() {
 
 
 
69
  add_meta_box(
70
  'wc-jetpack-' . $this->id,
71
  __( 'WooCommerce Jetpack', 'woocommerce-jetpack' ) . ': ' . $this->short_desc,
72
  array( $this, 'create_meta_box' ),
73
- 'product',
74
- 'normal',
75
- 'high' );
 
76
  }
77
 
78
  /**
@@ -133,9 +138,11 @@ class WCJ_Module {
133
 
134
  /**
135
  * settings_section.
 
 
136
  */
137
  function settings_section( $sections ) {
138
- $sections[ $this->id ] = $this->short_desc;
139
  return $sections;
140
  }
141
 
@@ -211,7 +218,7 @@ class WCJ_Module {
211
  * add_tool_link.
212
  *
213
  * @version 2.2.3
214
- * @since 2.2.3
215
  */
216
  function add_tool_link() {
217
  //echo '<ul>';
4
  *
5
  * The WooCommerce Jetpack Module class.
6
  *
7
+ * @version 2.3.0
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
13
 
14
  if ( ! class_exists( 'WCJ_Module' ) ) :
15
 
16
+ /* abstract */ class WCJ_Module {
17
 
18
  public $id;
19
  public $short_desc;
63
  /**
64
  * add_meta_box.
65
  *
66
+ * @version 2.3.0
67
+ * @since 2.2.6
68
  */
69
  function add_meta_box() {
70
+ $screen = ( isset( $this->meta_box_screen ) ) ? $this->meta_box_screen : 'product';
71
+ $context = ( isset( $this->meta_box_context ) ) ? $this->meta_box_context : 'normal';
72
+ $priority = ( isset( $this->meta_box_priority ) ) ? $this->meta_box_priority : 'high';
73
  add_meta_box(
74
  'wc-jetpack-' . $this->id,
75
  __( 'WooCommerce Jetpack', 'woocommerce-jetpack' ) . ': ' . $this->short_desc,
76
  array( $this, 'create_meta_box' ),
77
+ $screen,
78
+ $context,
79
+ $priority
80
+ );
81
  }
82
 
83
  /**
138
 
139
  /**
140
  * settings_section.
141
+ *
142
+ * @version 2.3.0
143
  */
144
  function settings_section( $sections ) {
145
+ $sections[ $this->id ] = isset( $this->section_title ) ? $this->section_title : $this->short_desc;
146
  return $sections;
147
  }
148
 
218
  * add_tool_link.
219
  *
220
  * @version 2.2.3
221
+ * @since 2.2.3
222
  */
223
  function add_tool_link() {
224
  //echo '<ul>';
includes/classes/class-wcj-pdf-invoice.php CHANGED
@@ -4,60 +4,12 @@
4
  *
5
  * The WooCommerce Jetpack PDF Invoice class.
6
  *
7
- * @version 2.2.9
8
  * @author Algoritmika Ltd.
9
  */
10
 
11
  if ( ! defined( 'ABSPATH' ) ) exit;
12
 
13
- if ( ! class_exists( 'WCJ_TCPDF' ) ) :
14
-
15
- // Include the main TCPDF library
16
- require_once( wcj_plugin_path() . '/includes/lib/tcpdf_min/tcpdf.php' );
17
-
18
- class WCJ_TCPDF extends TCPDF {
19
-
20
- public function set_invoice_type( $invoice_type ) {
21
- $this->invoice_type = $invoice_type;
22
- }
23
-
24
- /* //Page header
25
- public function Header() {
26
- // Logo
27
- $image_file = K_PATH_IMAGES.'logo_example.jpg';
28
- $this->Image($image_file, 10, 10, 15, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
29
- // Set font
30
- $this->SetFont('helvetica', 'B', 20);
31
- // Title
32
- $this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M');
33
- } */
34
-
35
- /**/ // Page footer
36
- public function Footer() {
37
- // Position at 15 mm from bottom
38
- //$this->SetY(-15);
39
- // Set font
40
- //$this->SetFont('helvetica', 'I', 8);
41
-
42
- $invoice_type = $this->invoice_type;
43
- $footer_text = apply_filters( 'wcj_get_option_filter', 'Page %page_number% / %total_pages%', get_option( 'wcj_invoicing_' . $invoice_type . '_footer_text' ) );
44
- //$this->Cell( 0, 0, do_shortcode( $footer_text ), 0, false, 'L', 0, '', 0, false, 'T', 'M' );
45
- $footer_text = str_replace( '%page_number%', $this->getAliasNumPage(), $footer_text );
46
- $footer_text = str_replace( '%total_pages%', $this->getAliasNbPages(), $footer_text );
47
- $border_desc = array(
48
- 'T' => array(
49
- 'color' => wcj_hex2rgb( get_option( 'wcj_invoicing_' . $invoice_type . '_footer_line_color' ) ),
50
- 'width' => 0,
51
- ),
52
- );
53
- $footer_text_color_rgb = wcj_hex2rgb( get_option( 'wcj_invoicing_' . $invoice_type . '_footer_text_color' ) );
54
- $this->SetTextColor( $footer_text_color_rgb[0], $footer_text_color_rgb[1], $footer_text_color_rgb[2] );
55
- $this->writeHTMLCell( 0, 0, '', '', do_shortcode( $footer_text ), $border_desc, 1, 0, true, '', true );
56
- } /**/
57
- }
58
-
59
- endif;
60
-
61
  if ( ! class_exists( 'WCJ_PDF_Invoice' ) ) :
62
 
63
  class WCJ_PDF_Invoice extends WCJ_Invoice {
@@ -66,15 +18,20 @@ class WCJ_PDF_Invoice extends WCJ_Invoice {
66
  * Constructor.
67
  */
68
  public function __construct( $order_id, $invoice_type ) {
69
-
70
  parent::__construct( $order_id, $invoice_type );
71
  }
72
 
 
 
 
 
 
73
  function prepare_pdf() {
74
 
75
  $invoice_type = $this->invoice_type;
76
 
77
  // Create new PDF document
 
78
  $pdf = new WCJ_TCPDF(
79
  get_option( 'wcj_invoicing_' . $invoice_type . '_page_orientation', 'P' ),
80
  PDF_UNIT,
@@ -99,15 +56,14 @@ class WCJ_PDF_Invoice extends WCJ_Invoice {
99
  $the_logo = '';
100
  $the_logo_width_mm = 0;
101
  if ( '' != get_option( 'wcj_invoicing_' . $invoice_type . '_header_image' ) ) {
102
- $the_logo = parse_url( get_option( 'wcj_invoicing_' . $invoice_type . '_header_image' ) );
103
- $the_logo = $the_logo['path'];
104
  $the_logo_width_mm = get_option( 'wcj_invoicing_' . $invoice_type . '_header_image_width_mm' );
105
  }
106
  $pdf->SetHeaderData(
107
  $the_logo,
108
  $the_logo_width_mm,
109
  do_shortcode( get_option( 'wcj_invoicing_' . $invoice_type . '_header_title_text' ) ),
110
- do_shortcode( get_option( 'wcj_invoicing_' . $invoice_type . '_header_text' ) . apply_filters( 'wcj_get_option_filter', ' - ' . 'powered by ' . 'woojetpack' . '.com', '' ) ),
111
  wcj_hex2rgb( get_option( 'wcj_invoicing_' . $invoice_type . '_header_text_color' ) ),
112
  wcj_hex2rgb( get_option( 'wcj_invoicing_' . $invoice_type . '_header_line_color' ) ) );
113
  } else {
4
  *
5
  * The WooCommerce Jetpack PDF Invoice class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
11
  if ( ! defined( 'ABSPATH' ) ) exit;
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  if ( ! class_exists( 'WCJ_PDF_Invoice' ) ) :
14
 
15
  class WCJ_PDF_Invoice extends WCJ_Invoice {
18
  * Constructor.
19
  */
20
  public function __construct( $order_id, $invoice_type ) {
 
21
  parent::__construct( $order_id, $invoice_type );
22
  }
23
 
24
+ /**
25
+ * prepare_pdf.
26
+ *
27
+ * @version 2.3.0
28
+ */
29
  function prepare_pdf() {
30
 
31
  $invoice_type = $this->invoice_type;
32
 
33
  // Create new PDF document
34
+ require_once( wcj_plugin_path() . '/includes/classes/class-wcj-tcpdf.php' );
35
  $pdf = new WCJ_TCPDF(
36
  get_option( 'wcj_invoicing_' . $invoice_type . '_page_orientation', 'P' ),
37
  PDF_UNIT,
56
  $the_logo = '';
57
  $the_logo_width_mm = 0;
58
  if ( '' != get_option( 'wcj_invoicing_' . $invoice_type . '_header_image' ) ) {
59
+ $the_logo = parse_url( get_option( 'wcj_invoicing_' . $invoice_type . '_header_image' ), PHP_URL_PATH );
 
60
  $the_logo_width_mm = get_option( 'wcj_invoicing_' . $invoice_type . '_header_image_width_mm' );
61
  }
62
  $pdf->SetHeaderData(
63
  $the_logo,
64
  $the_logo_width_mm,
65
  do_shortcode( get_option( 'wcj_invoicing_' . $invoice_type . '_header_title_text' ) ),
66
+ do_shortcode( get_option( 'wcj_invoicing_' . $invoice_type . '_header_text' ) ),
67
  wcj_hex2rgb( get_option( 'wcj_invoicing_' . $invoice_type . '_header_text_color' ) ),
68
  wcj_hex2rgb( get_option( 'wcj_invoicing_' . $invoice_type . '_header_line_color' ) ) );
69
  } else {
includes/classes/class-wcj-tcpdf.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Jetpack TCPDF
4
+ *
5
+ * The WooCommerce Jetpack TCPDF class.
6
+ *
7
+ * @version 2.3.0
8
+ * @author Algoritmika Ltd.
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) exit;
12
+
13
+ if ( ! class_exists( 'WCJ_TCPDF' ) ) :
14
+
15
+ // Include the main TCPDF library
16
+ require_once( wcj_plugin_path() . '/includes/lib/tcpdf_min/tcpdf.php' );
17
+
18
+ class WCJ_TCPDF extends TCPDF {
19
+
20
+ /**
21
+ * set_invoice_type.
22
+ */
23
+ public function set_invoice_type( $invoice_type ) {
24
+ $this->invoice_type = $invoice_type;
25
+ }
26
+
27
+ /**
28
+ * Page header.
29
+ *
30
+ public function Header() {
31
+ // Logo
32
+ $image_file = K_PATH_IMAGES.'logo_example.jpg';
33
+ $this->Image($image_file, 10, 10, 15, '', 'JPG', '', 'T', false, 300, '', false, false, 0, false, false, false);
34
+ // Set font
35
+ $this->SetFont('helvetica', 'B', 20);
36
+ // Title
37
+ $this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M');
38
+ }
39
+
40
+ /**
41
+ * Page footer.
42
+ */
43
+ public function Footer() {
44
+ // Position at 15 mm from bottom
45
+ //$this->SetY(-15);
46
+ // Set font
47
+ //$this->SetFont('helvetica', 'I', 8);
48
+
49
+ $invoice_type = $this->invoice_type;
50
+ $footer_text = apply_filters( 'wcj_get_option_filter', 'Page %page_number% / %total_pages%', get_option( 'wcj_invoicing_' . $invoice_type . '_footer_text' ) );
51
+ //$this->Cell( 0, 0, do_shortcode( $footer_text ), 0, false, 'L', 0, '', 0, false, 'T', 'M' );
52
+ $footer_text = str_replace( '%page_number%', $this->getAliasNumPage(), $footer_text );
53
+ $footer_text = str_replace( '%total_pages%', $this->getAliasNbPages(), $footer_text );
54
+ $border_desc = array(
55
+ 'T' => array(
56
+ 'color' => wcj_hex2rgb( get_option( 'wcj_invoicing_' . $invoice_type . '_footer_line_color' ) ),
57
+ 'width' => 0,
58
+ ),
59
+ );
60
+ $footer_text_color_rgb = wcj_hex2rgb( get_option( 'wcj_invoicing_' . $invoice_type . '_footer_text_color' ) );
61
+ $this->SetTextColor( $footer_text_color_rgb[0], $footer_text_color_rgb[1], $footer_text_color_rgb[2] );
62
+ $this->writeHTMLCell( 0, 0, '', '', do_shortcode( $footer_text ), $border_desc, 1, 0, true, '', true );
63
+ }
64
+ }
65
+
66
+ endif;
includes/css/jquery.timepicker.min.css ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * jQuery Timepicker - v1.3.2 - 2014-09-13
3
+ * http://timepicker.co
4
+ *
5
+ * Enhances standard form input fields helping users to select (or type) times.
6
+ *
7
+ * Copyright (c) 2014 Willington Vega; Licensed MIT, GPL
8
+ */
9
+
10
+
11
+ .ui-timepicker-container{position:absolute;overflow:hidden;box-sizing:border-box}.ui-timepicker{box-sizing:content-box;display:block;height:205px;list-style:none outside none;margin:0;padding:0 1px;text-align:center}.ui-timepicker-viewport{box-sizing:content-box;display:block;height:205px;margin:0;padding:0;overflow:auto;overflow-x:hidden}.ui-timepicker-standard{font-family:Verdana,Arial,sans-serif;font-size:1.1em;background-color:#FFF;border:1px solid #AAA;color:#222;margin:0;padding:2px}.ui-timepicker-standard a{border:1px solid transparent;color:#222;display:block;padding:.2em .4em;text-decoration:none}.ui-timepicker-standard .ui-state-hover{background-color:#DADADA;border:1px solid #999;font-weight:400;color:#212121}.ui-timepicker-standard .ui-menu-item{margin:0;padding:0}.ui-timepicker-corners,.ui-timepicker-corners .ui-corner-all{-moz-border-radius:4px;-webkit-border-radius:4px;border-radius:4px}.ui-timepicker-hidden{display:none}.ui-timepicker-no-scrollbar .ui-timepicker{border:0}
includes/exchange-rates/class-wcj-exchange-rates-crons.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Jetpack Exchange Rates Crons
4
+ *
5
+ * The WooCommerce Jetpack Exchange Rates Crons class.
6
+ *
7
+ * @version 2.3.0
8
+ * @author Algoritmika Ltd.
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) exit;
12
+
13
+ if ( ! class_exists( 'WCJ_Exchange_Rates_Crons' ) ) :
14
+
15
+ class WCJ_Exchange_Rates_Crons {
16
+
17
+ /**
18
+ * Constructor.
19
+ *
20
+ * @version 2.3.0
21
+ */
22
+ public function __construct() {
23
+
24
+ add_action( 'wp', array( $this, 'schedule_the_events' ) );
25
+ $this->update_intervals = array(
26
+ //'manual' => __( 'Enter Rates Manually', 'woocommerce-jetpack' ),
27
+ 'minutely' => __( 'Update Every Minute', 'woocommerce-jetpack' ),
28
+ 'hourly' => __( 'Update Hourly', 'woocommerce-jetpack' ),
29
+ 'twicedaily' => __( 'Update Twice Daily', 'woocommerce-jetpack' ),
30
+ 'daily' => __( 'Update Daily', 'woocommerce-jetpack' ),
31
+ 'weekly' => __( 'Update Weekly', 'woocommerce-jetpack' ),
32
+ );
33
+ /*foreach ( $this->update_intervals as $interval => $desc ) {
34
+ if ( 'manual' === $interval )
35
+ continue;
36
+ add_action( 'auto_update_exchange_rates_hook_' . $interval, array( $this, 'update_the_exchange_rates' ) );
37
+ }*/
38
+ //$selected_interval = get_option( 'wcj_currency_exchange_rates_auto', 'daily' );
39
+ //if ( 'manual' != $selected_interval ) {
40
+ //add_action( 'auto_update_exchange_rates_hook_' . $selected_interval,
41
+ add_action( 'auto_update_exchange_rates_hook', array( $this, 'update_the_exchange_rates' ) );
42
+ //}
43
+ add_filter( 'cron_schedules', array( $this, 'cron_add_custom_intervals' ) );
44
+ }
45
+
46
+ /**
47
+ * On an early action hook, check if the hook is scheduled - if not, schedule it.
48
+ *
49
+ * @version 2.3.0
50
+ */
51
+ function schedule_the_events() {
52
+ $selected_interval = get_option( 'wcj_currency_exchange_rates_auto', 'daily' );
53
+ foreach ( $this->update_intervals as $interval => $desc ) {
54
+ /* if ( 'manual' === $interval )
55
+ continue; */
56
+ $event_hook = 'auto_update_exchange_rates_hook';//_' . $interval;
57
+ $event_timestamp = wp_next_scheduled( $event_hook, array( $interval ) );
58
+ if ( ! $event_timestamp && $selected_interval === $interval ) {
59
+ wp_schedule_event( time(), $selected_interval, $event_hook, array( $selected_interval ) );
60
+ } elseif ( $event_timestamp && $selected_interval !== $interval ) {
61
+ wp_unschedule_event( $event_timestamp, $event_hook, array( $interval ) );
62
+ }
63
+ }
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
+
72
+ $url = "http://query.yahooapis.com/v1/public/yql?q=select%20rate%2Cname%20from%20csv%20where%20url%3D'http%3A%2F%2Fdownload.finance.yahoo.com%2Fd%2Fquotes%3Fs%3D" . $currency_from . $currency_to . "%253DX%26f%3Dl1n'%20and%20columns%3D'rate%2Cname'&format=json";
73
+ //$url = 'http://rate-exchange.appspot.com/currency?from=' . $currency_from . '&to=' . $currency_to;
74
+
75
+ ob_start();
76
+ $max_execution_time = ini_get( 'max_execution_time' );
77
+ set_time_limit( 2 );
78
+
79
+ $exchange_rate = json_decode( file_get_contents( $url ) );
80
+
81
+ set_time_limit( $max_execution_time );
82
+ ob_end_clean();
83
+
84
+ return ( isset( $exchange_rate->query->results->row->rate ) ) ? floatval( $exchange_rate->query->results->row->rate ) : 0;
85
+ //return ( isset( $exchange_rate->rate ) ) ? $exchange_rate->rate : 0;
86
+ }
87
+
88
+ /**
89
+ * get_currency_pair.
90
+ *
91
+ * @version 2.3.0
92
+ * @since 2.3.0
93
+ */
94
+ function get_currency_pair( $currency_pairs, $currency_to, $option_name ) {
95
+
96
+ foreach ( $currency_pairs as $k => $currency_pair ) {
97
+ if ( $currency_pair['currency_to'] == $currency_to ) {
98
+ $currency_pairs[ $k ]['option_name'][] = $option_name;
99
+ return $currency_pairs;
100
+ }
101
+ }
102
+ $currency_pairs[] = array(
103
+ 'currency_from' => get_option( 'woocommerce_currency' ),
104
+ 'currency_to' => $currency_to,
105
+ 'option_name' => array( $option_name, ),
106
+ );
107
+ return $currency_pairs;
108
+ }
109
+
110
+ /**
111
+ * On the scheduled action hook, run a function.
112
+ *
113
+ * @version 2.3.0
114
+ */
115
+ function update_the_exchange_rates( $interval ) {
116
+
117
+ $currency_pairs[] = array();
118
+
119
+ // Currency Pairs - Preparation - Price by Country
120
+ if ( 'manual' != apply_filters( 'wcj_get_option_filter', 'manual', get_option( 'wcj_price_by_country_auto_exchange_rates', 'manual' ) ) ) {
121
+ for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_price_by_country_total_groups_number', 1 ) ); $i++ ) {
122
+ $currency_to = get_option( 'wcj_price_by_country_exchange_rate_currency_group_' . $i );
123
+ $currency_pairs = $this->get_currency_pair( $currency_pairs, $currency_to, 'wcj_price_by_country_exchange_rate_group_' . $i );
124
+ }
125
+ }
126
+
127
+ // Currency Pairs - Preparation - Gateway Currency
128
+ if ( 'manual' != apply_filters( 'wcj_get_option_filter', 'manual', get_option( 'wcj_gateways_currency_exchange_rate_update_auto', 'manual' ) ) ) {
129
+ global $woocommerce;
130
+ $available_gateways = $woocommerce->payment_gateways->payment_gateways();
131
+ foreach ( $available_gateways as $key => $gateway ) {
132
+ $currency_to = get_option( 'wcj_gateways_currency_' . $key );
133
+ $currency_pairs = $this->get_currency_pair( $currency_pairs, $currency_to, 'wcj_gateways_currency_exchange_rate_' . $key );
134
+ }
135
+ }
136
+
137
+ // Currency Pairs - Final
138
+ foreach ( $currency_pairs as $currency_pair ) {
139
+ $currency_from = $currency_pair['currency_from'];
140
+ $currency_to = $currency_pair['currency_to'];
141
+ $the_rate = $this->get_exchange_rate( $currency_from, $currency_to );
142
+ if ( 0 != $the_rate ) {
143
+ if ( $currency_from != $currency_to ) {
144
+ foreach ( $currency_pair['option_name'] as $option_name ) {
145
+ update_option( $option_name, $the_rate );
146
+ }
147
+ $field_id = 'wcj_currency_exchange_rates_' . sanitize_title( $currency_from . $currency_to );
148
+ update_option( $field_id, $the_rate );
149
+ $result_message = __( 'Cron job: exchange rates successfully updated', 'woocommerce-jetpack' );
150
+ } else {
151
+ $result_message = __( 'Cron job: exchange rates not updated, as currency_from == currency_to', 'woocommerce-jetpack' );
152
+ }
153
+ } else {
154
+ $result_message = __( 'Cron job: exchange rates update failed', 'woocommerce-jetpack' );
155
+ }
156
+ //wcj_log( $result_message . ': ' . $currency_from . $currency_to . ': ' . $the_rate . ': ' . 'update_the_exchange_rates: ' . $interval );
157
+ }
158
+ }
159
+
160
+ /**
161
+ * cron_add_custom_intervals.
162
+ */
163
+ function cron_add_custom_intervals( $schedules ) {
164
+
165
+ $schedules['weekly'] = array(
166
+ 'interval' => 604800,
167
+ 'display' => __( 'Once Weekly', 'woocommerce-jetpack' )
168
+ );
169
+
170
+ $schedules['minutely'] = array(
171
+ 'interval' => 60,
172
+ 'display' => __( 'Once a Minute', 'woocommerce-jetpack' )
173
+ );
174
+
175
+ return $schedules;
176
+ }
177
+ }
178
+
179
+ endif;
180
+
181
+ return new WCJ_Exchange_Rates_Crons();
includes/{price-by-country → exchange-rates}/class-wcj-exchange-rates.php RENAMED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Exchange Rates class.
6
  *
7
- * @version 2.2.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -14,39 +14,43 @@ if ( ! class_exists( 'WCJ_Exchange_Rates' ) ) :
14
 
15
  class WCJ_Exchange_Rates {
16
 
17
- /**
18
- * Constructor.
19
- */
20
- public function __construct() {
21
 
22
- add_action( 'admin_enqueue_scripts' , array( $this, 'enqueue_exchange_rates_script' ) );
23
- add_action( 'admin_init', array( $this, 'register_script' ) );
24
 
25
  add_action( 'woocommerce_admin_field_exchange_rate', array( $this, 'output_settings_button' ) );
26
- }
27
 
28
  /**
29
- * register_script.
30
- */
31
- public function register_script() {
32
- if( isset( $_GET['section'] ) && 'price_by_country' === $_GET['section'] ) {
 
 
33
  wp_register_script( 'wcj-exchange-rates', trailingslashit( WCJ()->plugin_url() ) . 'includes/js/exchange_rates.js', array( 'jquery' ), false, true );
34
  }
35
- }
36
 
37
- /**
38
- * enqueue_exchange_rates_script.
39
- */
40
- public function enqueue_exchange_rates_script() {
41
- if( isset( $_GET['section'] ) && 'price_by_country' === $_GET['section'] ) {
 
 
42
  wp_enqueue_script( 'wcj-exchange-rates' );
43
  }
44
- }
45
 
46
- /**
47
- * output_settings_button.
48
- */
49
- function output_settings_button( $value ) {
50
 
51
  $value['type'] = 'number';
52
 
4
  *
5
  * The WooCommerce Jetpack Exchange Rates class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
14
 
15
  class WCJ_Exchange_Rates {
16
 
17
+ /**
18
+ * Constructor.
19
+ */
20
+ public function __construct() {
21
 
22
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_exchange_rates_script' ) );
23
+ add_action( 'admin_init', array( $this, 'register_script' ) );
24
 
25
  add_action( 'woocommerce_admin_field_exchange_rate', array( $this, 'output_settings_button' ) );
26
+ }
27
 
28
  /**
29
+ * register_script.
30
+ *
31
+ * @version 2.3.0
32
+ */
33
+ public function register_script() {
34
+ if ( isset( $_GET['section'] ) && in_array( $_GET['section'], array( 'price_by_country', 'payment_gateways_currency', 'currency_exchange_rates', ) ) ) {
35
  wp_register_script( 'wcj-exchange-rates', trailingslashit( WCJ()->plugin_url() ) . 'includes/js/exchange_rates.js', array( 'jquery' ), false, true );
36
  }
37
+ }
38
 
39
+ /**
40
+ * enqueue_exchange_rates_script.
41
+ *
42
+ * @version 2.3.0
43
+ */
44
+ public function enqueue_exchange_rates_script() {
45
+ if ( isset( $_GET['section'] ) && in_array( $_GET['section'], array( 'price_by_country', 'payment_gateways_currency', 'currency_exchange_rates', ) ) ) {
46
  wp_enqueue_script( 'wcj-exchange-rates' );
47
  }
48
+ }
49
 
50
+ /**
51
+ * output_settings_button.
52
+ */
53
+ function output_settings_button( $value ) {
54
 
55
  $value['type'] = 'number';
56
 
includes/functions/wcj-functions.php CHANGED
@@ -4,10 +4,29 @@
4
  *
5
  * The WooCommerce Jetpack Functions.
6
  *
7
- * @version 2.2.7
8
  * @author Algoritmika Ltd.
9
  */
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  /*
12
  * is_frontend()
13
  *
@@ -16,7 +35,7 @@
16
  */
17
  if ( ! function_exists( 'wcj_is_frontend' ) ) {
18
  function wcj_is_frontend() {
19
- return ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) ? true : false;
20
  }
21
  }
22
 
@@ -31,7 +50,7 @@ if ( ! function_exists( 'wcj_get_wcj_uploads_dir' ) ) {
31
  if ( '' != $subdir ) $upload_dir = $upload_dir . '/' . $subdir;
32
  return $upload_dir;
33
  }
34
- }
35
 
36
  /**
37
  * wcj_is_product_wholesale_enabled.
@@ -259,12 +278,12 @@ if ( ! function_exists( 'convert_number_to_words' ) ) {
259
  /**
260
  * wcj_plugin_url.
261
  *
262
- * @todo
263
- *
264
  if ( ! function_exists( 'wcj_plugin_url' ) ) {
265
  function wcj_plugin_url() {
266
- return untrailingslashit( plugin_dir_url( __FILE__ ) );
267
- //return untrailingslashit( realpath( dirname(__FILE__) . '/..' ) );
268
  }
269
  }
270
 
4
  *
5
  * The WooCommerce Jetpack Functions.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
11
+ /*
12
+ * wcj_get_select_options()
13
+ *
14
+ * @version 2.3.0
15
+ * @since 2.3.0
16
+ * @return array
17
+ */
18
+ if ( ! function_exists( 'wcj_get_select_options' ) ) {
19
+ function wcj_get_select_options( $select_options_raw ) {
20
+ $select_options_raw = explode( PHP_EOL, $select_options_raw );
21
+ $select_options = array();
22
+ foreach ( $select_options_raw as $select_options_title ) {
23
+ $select_options_key = sanitize_title( $select_options_title );
24
+ $select_options[ $select_options_key ] = $select_options_title;
25
+ }
26
+ return $select_options;
27
+ }
28
+ }
29
+
30
  /*
31
  * is_frontend()
32
  *
35
  */
36
  if ( ! function_exists( 'wcj_is_frontend' ) ) {
37
  function wcj_is_frontend() {
38
+ return ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) ? true : false;
39
  }
40
  }
41
 
50
  if ( '' != $subdir ) $upload_dir = $upload_dir . '/' . $subdir;
51
  return $upload_dir;
52
  }
53
+ }
54
 
55
  /**
56
  * wcj_is_product_wholesale_enabled.
278
  /**
279
  * wcj_plugin_url.
280
  *
281
+ * @version 2.3.0
282
+ */
283
  if ( ! function_exists( 'wcj_plugin_url' ) ) {
284
  function wcj_plugin_url() {
285
+ return untrailingslashit( plugin_dir_url( realpath( dirname( __FILE__ ) . '/..' ) ) );
286
+ //return untrailingslashit( realpath( dirname( __FILE__ ) . '/..' ) );
287
  }
288
  }
289
 
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.2.3
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -308,12 +308,17 @@ function init_wc_gateway_wcj_custom_class() {
308
  'redirect' => $this->get_return_url( $order ),
309
  );
310
  }
311
-
 
 
 
 
 
312
  public function init( $id_count ) {
313
  $this->id = ( 1 === $id_count ) ? 'jetpack_custom_gateway' : 'jetpack_custom_gateway_' . $id_count;
314
  $this->has_fields = false;
315
  $this->method_title = __( 'Custom Gateway', 'woocommerce-jetpack' ) . ' #' . $id_count;
316
- $this->method_description = __( 'WooCommerce Jetpack: Custom Payment Gateway', 'woocommerce-jetpack' ) . ' #' . $id_count;
317
  $this->id_count = $id_count;
318
  // Load the settings.
319
  $this->init_form_fields();
4
  *
5
  * The WooCommerce Jetpack Custom Payment Gateway class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
308
  'redirect' => $this->get_return_url( $order ),
309
  );
310
  }
311
+
312
+ /**
313
+ * init.
314
+ *
315
+ * @version 2.3.0
316
+ */
317
  public function init( $id_count ) {
318
  $this->id = ( 1 === $id_count ) ? 'jetpack_custom_gateway' : 'jetpack_custom_gateway_' . $id_count;
319
  $this->has_fields = false;
320
  $this->method_title = __( 'Custom Gateway', 'woocommerce-jetpack' ) . ' #' . $id_count;
321
+ $this->method_description = __( 'Booster for WooCommerce: Custom Payment Gateway', 'woocommerce-jetpack' ) . ' #' . $id_count;
322
  $this->id_count = $id_count;
323
  // Load the settings.
324
  $this->init_form_fields();
includes/input-fields/class-wcj-product-input-fields-abstract.php CHANGED
@@ -17,16 +17,16 @@ class WCJ_Product_Input_Fields_Abstract {
17
  /** @var string scope. */
18
  public $scope = '';
19
 
20
- /**
21
- * Constructor.
22
- */
23
- public function __construct() {
24
 
25
- }
26
 
27
- /**
28
- * get_options.
29
- */
30
  public function get_options() {
31
  $options = array(
32
  array(
@@ -39,39 +39,49 @@ class WCJ_Product_Input_Fields_Abstract {
39
  'id' => 'wcj_product_input_fields_type_' . $this->scope . '_',
40
  'title' => __( 'Type', 'woocommerce-jetpack' ),
41
  'type' => 'select',
42
- 'default' => 'text',
43
  'options' => array(
44
- 'text' => __( 'Text', 'woocommerce-jetpack' ),
45
- 'textarea' => __( 'Textarea', 'woocommerce-jetpack' ),
46
- 'number' => __( 'Number', 'woocommerce-jetpack' ),
47
- 'checkbox' => __( 'Checkbox', 'woocommerce-jetpack' ),
48
- 'file' => __( 'File', 'woocommerce-jetpack' ),
49
- ),
 
 
 
 
 
 
 
 
 
 
50
  ),
51
 
52
  /* array(
53
  'id' => 'wcj_product_input_fields_type_checkbox_' . $this->scope . '_',
54
  'title' => __( 'If checkbox is selected, set possible pairs here.', 'woocommerce-jetpack' ),
55
  'type' => 'select',
56
- 'default' => 'yes_no',
57
  'options' => array(
58
  'yes_no' => __( 'Yes / No', 'woocommerce-jetpack' ),
59
  'on_off' => __( 'On / Off', 'woocommerce-jetpack' ),
60
- ),
61
  ), */
62
  array(
63
  'id' => 'wcj_product_input_fields_type_checkbox_yes_' . $this->scope . '_',
64
  'title' => __( 'If checkbox is selected, set value for ON here', 'woocommerce-jetpack' ),
65
  'short_title' => __( 'Checkbox: ON', 'woocommerce-jetpack' ),
66
  'type' => 'text',
67
- 'default' => __( 'Yes', 'woocommerce-jetpack' ),
68
  ),
69
  array(
70
  'id' => 'wcj_product_input_fields_type_checkbox_no_' . $this->scope . '_',
71
  'title' => __( 'If checkbox is selected, set value for OFF here', 'woocommerce-jetpack' ),
72
  'short_title' => __( 'Checkbox: OFF', 'woocommerce-jetpack' ),
73
  'type' => 'text',
74
- 'default' => __( 'No', 'woocommerce-jetpack' ),
75
  ),
76
 
77
  // TODO: http://www.w3schools.com/tags/att_input_accept.asp
@@ -80,32 +90,40 @@ class WCJ_Product_Input_Fields_Abstract {
80
  'title' => __( 'If file is selected, set accepted file types here. E.g.: ".jpg,.jpeg,.png". Leave blank to accept all files', 'woocommerce-jetpack' ),
81
  'short_title' => __( 'File: Accepted types', 'woocommerce-jetpack' ),
82
  'type' => 'text',
83
- 'default' => __( '.jpg,.jpeg,.png', 'woocommerce-jetpack' ),
 
 
 
 
 
 
 
 
84
  ),
85
 
86
  array(
87
  'id' => 'wcj_product_input_fields_required_' . $this->scope . '_',
88
  'title' => __( 'Required', 'woocommerce-jetpack' ),
89
  'type' => 'checkbox',
90
- 'default' => 'no',
91
  ),
92
  array(
93
  'id' => 'wcj_product_input_fields_title_' . $this->scope . '_',
94
  'title' => __( 'Title', 'woocommerce-jetpack' ),
95
  'type' => 'textarea',
96
- 'default' => '',
97
  ),
98
  array(
99
  'id' => 'wcj_product_input_fields_placeholder_' . $this->scope . '_',
100
  'title' => __( 'Placeholder', 'woocommerce-jetpack' ),
101
  'type' => 'textarea',
102
- 'default' => '',
103
  ),
104
  array(
105
  'id' => 'wcj_product_input_fields_required_message_' . $this->scope . '_',
106
  'title' => __( 'Message on required', 'woocommerce-jetpack' ),
107
  'type' => 'textarea',
108
- 'default' => '',
109
  ),
110
  );
111
  return $options;
@@ -319,8 +337,7 @@ class WCJ_Product_Input_Fields_Abstract {
319
  */
320
  public function add_product_input_fields_to_frontend() {
321
  global $product;
322
- //if ( ! $product )
323
- // return;
324
  $total_number = apply_filters( 'wcj_get_option_filter', 1, $this->get_value( 'wcj_' . 'product_input_fields' . '_' . $this->scope . '_total_number', $product->id, 1 ) );
325
 
326
  for ( $i = 1; $i <= $total_number; $i++ ) {
@@ -337,23 +354,121 @@ class WCJ_Product_Input_Fields_Abstract {
337
 
338
  if ( 'on' === $is_enabled || 'yes' === $is_enabled ) {
339
  switch ( $type ) {
 
340
  case 'number':
341
  case 'text':
342
  case 'checkbox':
343
  case 'file':
 
 
 
 
344
  echo '<p>' . $title . '<input type="' . $type . '" name="' . $field_name . '" placeholder="' . $placeholder . '"' . $custom_attributes . '>' . '</p>';
345
  break;
 
 
 
 
 
 
 
 
 
 
 
346
  case 'textarea':
 
347
  echo '<p>' . $title . '<textarea name="' . $field_name . '" placeholder="' . $placeholder . '">' . '</textarea>' . '</p>';
348
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
  }
350
  }
351
  }
352
  }
353
 
354
  /**
355
- * add_product_input_fields_to_cart_item_data.
356
- * from $_POST to $cart_item_data
357
  */
358
  public function add_product_input_fields_to_cart_item_data( $cart_item_data, $product_id, $variation_id ) {
359
  $total_number = apply_filters( 'wcj_get_option_filter', 1, $this->get_value( 'wcj_' . 'product_input_fields' . '_' . $this->scope . '_total_number', $product_id, 1 ) );
17
  /** @var string scope. */
18
  public $scope = '';
19
 
20
+ /**
21
+ * Constructor.
22
+ */
23
+ public function __construct() {
24
 
25
+ }
26
 
27
+ /**
28
+ * get_options.
29
+ */
30
  public function get_options() {
31
  $options = array(
32
  array(
39
  'id' => 'wcj_product_input_fields_type_' . $this->scope . '_',
40
  'title' => __( 'Type', 'woocommerce-jetpack' ),
41
  'type' => 'select',
42
+ 'default' => 'text',
43
  'options' => array(
44
+ 'text' => __( 'Text', 'woocommerce-jetpack' ),
45
+ 'textarea' => __( 'Textarea', 'woocommerce-jetpack' ),
46
+ 'number' => __( 'Number', 'woocommerce-jetpack' ),
47
+ 'checkbox' => __( 'Checkbox', 'woocommerce-jetpack' ),
48
+ 'file' => __( 'File', 'woocommerce-jetpack' ),
49
+ 'datepicker' => __( 'Datepicker', 'woocommerce-jetpack' ),
50
+ 'timepicker' => __( 'Timepicker', 'woocommerce-jetpack' ),
51
+ 'select' => __( 'Select', 'woocommerce-jetpack' ),
52
+ 'radio' => __( 'Radio', 'woocommerce-jetpack' ),
53
+ 'password' => __( 'Password', 'woocommerce-jetpack' ),
54
+ 'country' => __( 'Country', 'woocommerce-jetpack' ),
55
+ // 'state' => __( 'State', 'woocommerce-jetpack' ),
56
+ 'email' => __( 'Email', 'woocommerce-jetpack' ),
57
+ 'tel' => __( 'Phone', 'woocommerce-jetpack' ),
58
+
59
+ ),
60
  ),
61
 
62
  /* array(
63
  'id' => 'wcj_product_input_fields_type_checkbox_' . $this->scope . '_',
64
  'title' => __( 'If checkbox is selected, set possible pairs here.', 'woocommerce-jetpack' ),
65
  'type' => 'select',
66
+ 'default' => 'yes_no',
67
  'options' => array(
68
  'yes_no' => __( 'Yes / No', 'woocommerce-jetpack' ),
69
  'on_off' => __( 'On / Off', 'woocommerce-jetpack' ),
70
+ ),
71
  ), */
72
  array(
73
  'id' => 'wcj_product_input_fields_type_checkbox_yes_' . $this->scope . '_',
74
  'title' => __( 'If checkbox is selected, set value for ON here', 'woocommerce-jetpack' ),
75
  'short_title' => __( 'Checkbox: ON', 'woocommerce-jetpack' ),
76
  'type' => 'text',
77
+ 'default' => __( 'Yes', 'woocommerce-jetpack' ),
78
  ),
79
  array(
80
  'id' => 'wcj_product_input_fields_type_checkbox_no_' . $this->scope . '_',
81
  'title' => __( 'If checkbox is selected, set value for OFF here', 'woocommerce-jetpack' ),
82
  'short_title' => __( 'Checkbox: OFF', 'woocommerce-jetpack' ),
83
  'type' => 'text',
84
+ 'default' => __( 'No', 'woocommerce-jetpack' ),
85
  ),
86
 
87
  // TODO: http://www.w3schools.com/tags/att_input_accept.asp
90
  'title' => __( 'If file is selected, set accepted file types here. E.g.: ".jpg,.jpeg,.png". Leave blank to accept all files', 'woocommerce-jetpack' ),
91
  'short_title' => __( 'File: Accepted types', 'woocommerce-jetpack' ),
92
  'type' => 'text',
93
+ 'default' => __( '.jpg,.jpeg,.png', 'woocommerce-jetpack' ),
94
+ ),
95
+
96
+ array(
97
+ 'id' => 'wcj_product_input_fields_type_select_options_' . $this->scope . '_',
98
+ 'title' => __( 'If select/radio is selected, set options here. One option per line', 'woocommerce-jetpack' ),
99
+ 'short_title' => __( 'Select/Radio: Options', 'woocommerce-jetpack' ),
100
+ 'type' => 'textarea',
101
+ 'default' => '',
102
  ),
103
 
104
  array(
105
  'id' => 'wcj_product_input_fields_required_' . $this->scope . '_',
106
  'title' => __( 'Required', 'woocommerce-jetpack' ),
107
  'type' => 'checkbox',
108
+ 'default' => 'no',
109
  ),
110
  array(
111
  'id' => 'wcj_product_input_fields_title_' . $this->scope . '_',
112
  'title' => __( 'Title', 'woocommerce-jetpack' ),
113
  'type' => 'textarea',
114
+ 'default' => '',
115
  ),
116
  array(
117
  'id' => 'wcj_product_input_fields_placeholder_' . $this->scope . '_',
118
  'title' => __( 'Placeholder', 'woocommerce-jetpack' ),
119
  'type' => 'textarea',
120
+ 'default' => '',
121
  ),
122
  array(
123
  'id' => 'wcj_product_input_fields_required_message_' . $this->scope . '_',
124
  'title' => __( 'Message on required', 'woocommerce-jetpack' ),
125
  'type' => 'textarea',
126
+ 'default' => '',
127
  ),
128
  );
129
  return $options;
337
  */
338
  public function add_product_input_fields_to_frontend() {
339
  global $product;
340
+ //if ( ! $product ) // return;
 
341
  $total_number = apply_filters( 'wcj_get_option_filter', 1, $this->get_value( 'wcj_' . 'product_input_fields' . '_' . $this->scope . '_total_number', $product->id, 1 ) );
342
 
343
  for ( $i = 1; $i <= $total_number; $i++ ) {
354
 
355
  if ( 'on' === $is_enabled || 'yes' === $is_enabled ) {
356
  switch ( $type ) {
357
+
358
  case 'number':
359
  case 'text':
360
  case 'checkbox':
361
  case 'file':
362
+ case 'password':
363
+ case 'email':
364
+ case 'tel':
365
+
366
  echo '<p>' . $title . '<input type="' . $type . '" name="' . $field_name . '" placeholder="' . $placeholder . '"' . $custom_attributes . '>' . '</p>';
367
  break;
368
+
369
+ case 'datepicker':
370
+
371
+ echo '<p>' . $title . '<input type="' . $type . '" display="date" name="' . $field_name . '" placeholder="' . $placeholder . '"' . $custom_attributes . '>' . '</p>';
372
+ break;
373
+
374
+ case 'timepicker':
375
+
376
+ echo '<p>' . $title . '<input type="' . $type . '" display="time" name="' . $field_name . '" placeholder="' . $placeholder . '"' . $custom_attributes . '>' . '</p>';
377
+ break;
378
+
379
  case 'textarea':
380
+
381
  echo '<p>' . $title . '<textarea name="' . $field_name . '" placeholder="' . $placeholder . '">' . '</textarea>' . '</p>';
382
  break;
383
+
384
+ case 'select':
385
+
386
+ $select_options_raw = $this->get_value( 'wcj_product_input_fields_type_select_options_' . $this->scope . '_' . $i, $product->id, '' );
387
+ $select_options = wcj_get_select_options( $select_options_raw );
388
+ $select_options_html = '';
389
+ if ( ! empty( $select_options ) ) {
390
+ reset( $select_options );
391
+ $value = key( $select_options );
392
+ foreach ( $select_options as $select_option_key => $select_option_title ) {
393
+ $select_options_html .= '<option value="' . $select_option_key . '" ' . selected( $value, $select_option_key, false ) . '>';
394
+ $select_options_html .= $select_option_title;
395
+ $select_options_html .= '</option>';
396
+ }
397
+ }
398
+ echo '<p>' . $title . '<select name="' . $field_name . '">' . $select_options_html . '</select>' . '</p>';
399
+ break;
400
+
401
+ case 'radio' :
402
+
403
+ $select_options_raw = $this->get_value( 'wcj_product_input_fields_type_select_options_' . $this->scope . '_' . $i, $product->id, '' );
404
+ $select_options = wcj_get_select_options( $select_options_raw );
405
+ $select_options_html = '';
406
+ //$label_id = current( array_keys( $args['options'] ) );
407
+ if ( ! empty( $select_options ) ) {
408
+ reset( $select_options );
409
+ $value = key( $select_options );
410
+ foreach ( $select_options as $option_key => $option_text ) {
411
+ $select_options_html .= '<input type="radio" class="input-radio" value="' . esc_attr( $option_key ) .
412
+ '" name="' . $field_name . '" id="' . $field_name . '_' . esc_attr( $option_key ) . '"' . checked( $value, $option_key, false ) . ' />';
413
+ $select_options_html .= '<label for="' . $field_name . '_' . esc_attr( $option_key ) .
414
+ '" class="radio">' . $option_text . '</label><br>';
415
+ }
416
+ echo '<p>' . $title . $select_options_html . '</p>';
417
+ }
418
+ break;
419
+
420
+ case 'country' :
421
+ $countries = WC()->countries->get_allowed_countries();
422
+ if ( sizeof( $countries ) > 1 ) {
423
+ $value = key( $countries );
424
+ $field = '<select name="' . $field_name . '" id="' . $field_name . '" class="country_to_state country_select">' .
425
+ '<option value="">'.__( 'Select a country&hellip;', 'woocommerce' ) .'</option>';
426
+ foreach ( $countries as $ckey => $cvalue ) {
427
+ $field .= '<option value="' . esc_attr( $ckey ) . '" '.selected( $value, $ckey, false ) .'>'.__( $cvalue, 'woocommerce' ) .'</option>';
428
+ }
429
+ $field .= '</select>';
430
+ echo '<p>' . $title . $field . '</p>';
431
+ }
432
+ break;
433
+
434
+ /* case 'state' : // from woocommerce_form_field()
435
+
436
+ // Get Country
437
+ $country_key = $key == 'billing_state'? 'billing_country' : 'shipping_country';
438
+ $current_cc = WC()->checkout->get_value( $country_key );
439
+ $states = WC()->countries->get_states( $current_cc );
440
+
441
+ if ( is_array( $states ) && empty( $states ) ) {
442
+
443
+ $field_container = '<p class="form-row %1$s" id="%2$s" style="display: none">%3$s</p>';
444
+
445
+ $field .= '<input type="hidden" class="hidden" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" value="" ' . implode( ' ', $custom_attributes ) . ' placeholder="' . esc_attr( $args['placeholder'] ) . '" />';
446
+
447
+ } elseif ( is_array( $states ) ) {
448
+
449
+ $field .= '<select name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" class="state_select ' . esc_attr( implode( ' ', $args['input_class'] ) ) .'" ' . implode( ' ', $custom_attributes ) . ' placeholder="' . esc_attr( $args['placeholder'] ) . '">
450
+ <option value="">'.__( 'Select a state&hellip;', 'woocommerce' ) .'</option>';
451
+
452
+ foreach ( $states as $ckey => $cvalue ) {
453
+ $field .= '<option value="' . esc_attr( $ckey ) . '" '.selected( $value, $ckey, false ) .'>'.__( $cvalue, 'woocommerce' ) .'</option>';
454
+ }
455
+
456
+ $field .= '</select>';
457
+
458
+ } else {
459
+
460
+ $field .= '<input type="text" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) .'" value="' . esc_attr( $value ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" ' . implode( ' ', $custom_attributes ) . ' />';
461
+
462
+ }
463
+
464
+ break; */
465
  }
466
  }
467
  }
468
  }
469
 
470
  /**
471
+ * add_product_input_fields_to_cart_item_data - from $_POST to $cart_item_data
 
472
  */
473
  public function add_product_input_fields_to_cart_item_data( $cart_item_data, $product_id, $variation_id ) {
474
  $total_number = apply_filters( 'wcj_get_option_filter', 1, $this->get_value( 'wcj_' . 'product_input_fields' . '_' . $this->scope . '_total_number', $product_id, 1 ) );
includes/js/checkout.js CHANGED
@@ -1,8 +1,8 @@
1
  jQuery( function( $ ) {
2
  // Define that JavaScript code should be executed in "strict mode"
3
- "use strict";
4
  // Trigger WooCommerce's `update_checkout` function, when customer changes payment method
5
- $('body').on('change', 'input[name="payment_method"]', function() {
6
- $('body').trigger('update_checkout');
7
  });
8
  });
1
  jQuery( function( $ ) {
2
  // Define that JavaScript code should be executed in "strict mode"
3
+ "use strict";
4
  // Trigger WooCommerce's `update_checkout` function, when customer changes payment method
5
+ $('body').on('change', 'input[name="payment_method"]', function() {
6
+ $('body').trigger('update_checkout');
7
  });
8
  });
includes/js/jquery.timepicker.min.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * jQuery Timepicker - v1.3.2 - 2014-09-13
3
+ * http://timepicker.co
4
+ *
5
+ * Enhances standard form input fields helping users to select (or type) times.
6
+ *
7
+ * Copyright (c) 2014 Willington Vega; Licensed MIT, GPL
8
+ */
9
+
10
+ "undefined"!=typeof jQuery&&function(e){function t(e,t,i){return Array(i+1-e.length).join(t)+e}function i(){if(1===arguments.length){var t=arguments[0];return"string"==typeof t&&(t=e.fn.timepicker.parseTime(t)),new Date(0,0,0,t.getHours(),t.getMinutes(),t.getSeconds())}return 3===arguments.length?new Date(0,0,0,arguments[0],arguments[1],arguments[2]):2===arguments.length?new Date(0,0,0,arguments[0],arguments[1],0):new Date(0,0,0)}e.TimePicker=function(){var t=this;t.container=e(".ui-timepicker-container"),t.ui=t.container.find(".ui-timepicker"),0===t.container.length&&(t.container=e("<div></div>").addClass("ui-timepicker-container").addClass("ui-timepicker-hidden ui-helper-hidden").appendTo("body").hide(),t.ui=e("<div></div>").addClass("ui-timepicker").addClass("ui-widget ui-widget-content ui-menu").addClass("ui-corner-all").appendTo(t.container),t.viewport=e("<ul></ul>").addClass("ui-timepicker-viewport").appendTo(t.ui),e.fn.jquery>="1.4.2"&&t.ui.delegate("a","mouseenter.timepicker",function(){t.activate(!1,e(this).parent())}).delegate("a","mouseleave.timepicker",function(){t.deactivate(!1)}).delegate("a","click.timepicker",function(i){i.preventDefault(),t.select(!1,e(this).parent())}),t.ui.bind("click.timepicker, scroll.timepicker",function(){clearTimeout(t.closing)}))},e.TimePicker.count=0,e.TimePicker.instance=function(){return e.TimePicker._instance||(e.TimePicker._instance=new e.TimePicker),e.TimePicker._instance},e.TimePicker.prototype={keyCode:{ALT:18,BLOQ_MAYUS:20,CTRL:17,DOWN:40,END:35,ENTER:13,HOME:36,LEFT:37,NUMPAD_ENTER:108,PAGE_DOWN:34,PAGE_UP:33,RIGHT:39,SHIFT:16,TAB:9,UP:38},_items:function(t,n){var r,a,s=this,o=e("<ul></ul>"),u=null;for(-1===t.options.timeFormat.indexOf("m")&&0!==t.options.interval%60&&(t.options.interval=60*Math.max(Math.round(t.options.interval/60),1)),r=n?i(n):t.options.startTime?i(t.options.startTime):i(t.options.startHour,t.options.startMinutes),a=new Date(r.getTime()+864e5);a>r;)s._isValidTime(t,r)&&(u=e("<li>").addClass("ui-menu-item").appendTo(o),e("<a>").addClass("ui-corner-all").text(e.fn.timepicker.formatTime(t.options.timeFormat,r)).appendTo(u),u.data("time-value",r)),r=new Date(r.getTime()+1e3*60*t.options.interval);return o.children()},_isValidTime:function(e,t){var n=null,r=null;return t=i(t),null!==e.options.minTime?n=i(e.options.minTime):(null!==e.options.minHour||null!==e.options.minMinutes)&&(n=i(e.options.minHour,e.options.minMinutes)),null!==e.options.maxTime?r=i(e.options.maxTime):(null!==e.options.maxHour||null!==e.options.maxMinutes)&&(r=i(e.options.maxHour,e.options.maxMinutes)),null!==n&&null!==r?t>=n&&r>=t:null!==n?t>=n:null!==r?r>=t:!0},_hasScroll:function(){var e=this.ui.prop!==undefined?"prop":"attr";return this.ui.height()<this.ui[e]("scrollHeight")},_move:function(e,t,i){var n=this;if(n.closed()&&n.open(e),!n.active)return n.activate(e,n.viewport.children(i)),undefined;var r=n.active[t+"All"](".ui-menu-item").eq(0);r.length?n.activate(e,r):n.activate(e,n.viewport.children(i))},register:function(t,i){var n=this,r={};r.element=e(t),r.element.data("TimePicker")||(r.options=e.metadata?e.extend({},i,r.element.metadata()):e.extend({},i),r.widget=n,e.extend(r,{next:function(){return n.next(r)},previous:function(){return n.previous(r)},first:function(){return n.first(r)},last:function(){return n.last(r)},selected:function(){return n.selected(r)},open:function(){return n.open(r)},close:function(e){return n.close(r,e)},closed:function(){return n.closed(r)},destroy:function(){return n.destroy(r)},parse:function(e){return n.parse(r,e)},format:function(e,t){return n.format(r,e,t)},getTime:function(){return n.getTime(r)},setTime:function(e,t){return n.setTime(r,e,t)},option:function(e,t){return n.option(r,e,t)}}),n._setDefaultTime(r),n._addInputEventsHandlers(r),r.element.data("TimePicker",r))},_setDefaultTime:function(t){"now"===t.options.defaultTime?t.setTime(i(new Date)):t.options.defaultTime&&t.options.defaultTime.getFullYear?t.setTime(i(t.options.defaultTime)):t.options.defaultTime&&t.setTime(e.fn.timepicker.parseTime(t.options.defaultTime))},_addInputEventsHandlers:function(t){var i=this;t.element.bind("keydown.timepicker",function(e){switch(e.which||e.keyCode){case i.keyCode.ENTER:case i.keyCode.NUMPAD_ENTER:e.preventDefault(),i.closed()?t.element.trigger("change.timepicker"):i.select(t,i.active);break;case i.keyCode.UP:t.previous();break;case i.keyCode.DOWN:t.next();break;default:i.closed()||t.close(!0)}}).bind("focus.timepicker",function(){t.open()}).bind("blur.timepicker",function(){t.close()}).bind("change.timepicker",function(){t.closed()&&t.setTime(e.fn.timepicker.parseTime(t.element.val()))})},select:function(t,i){var n=this,r=t===!1?n.instance:t;clearTimeout(n.closing),n.setTime(r,e.fn.timepicker.parseTime(i.children("a").text())),n.close(r,!0)},activate:function(e,t){var i=this,n=e===!1?i.instance:e;if(n===i.instance){if(i.deactivate(),i._hasScroll()){var r=t.offset().top-i.ui.offset().top,a=i.ui.scrollTop(),s=i.ui.height();0>r?i.ui.scrollTop(a+r):r>=s&&i.ui.scrollTop(a+r-s+t.height())}i.active=t.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-item").end()}},deactivate:function(){var e=this;e.active&&(e.active.children("a").removeClass("ui-state-hover").removeAttr("id"),e.active=null)},next:function(e){return(this.closed()||this.instance===e)&&this._move(e,"next",".ui-menu-item:first"),e.element},previous:function(e){return(this.closed()||this.instance===e)&&this._move(e,"prev",".ui-menu-item:last"),e.element},first:function(e){return this.instance===e?this.active&&0===this.active.prevAll(".ui-menu-item").length:!1},last:function(e){return this.instance===e?this.active&&0===this.active.nextAll(".ui-menu-item").length:!1},selected:function(e){return this.instance===e?this.active?this.active:null:null},open:function(t){var i=this,n=t.getTime(),r=t.options.dynamic&&n;if(!t.options.dropdown)return t.element;switch((t.rebuild||!t.items||r)&&(t.items=i._items(t,r?n:null)),(t.rebuild||i.instance!==t||r)&&("1.4.2">e.fn.jquery?(i.viewport.children().remove(),i.viewport.append(t.items),i.viewport.find("a").bind("mouseover.timepicker",function(){i.activate(t,e(this).parent())}).bind("mouseout.timepicker",function(){i.deactivate(t)}).bind("click.timepicker",function(n){n.preventDefault(),i.select(t,e(this).parent())})):(i.viewport.children().detach(),i.viewport.append(t.items))),t.rebuild=!1,i.container.removeClass("ui-helper-hidden ui-timepicker-hidden ui-timepicker-standard ui-timepicker-corners").show(),t.options.theme){case"standard":i.container.addClass("ui-timepicker-standard");break;case"standard-rounded-corners":i.container.addClass("ui-timepicker-standard ui-timepicker-corners");break;default:}i.container.hasClass("ui-timepicker-no-scrollbar")||t.options.scrollbar||(i.container.addClass("ui-timepicker-no-scrollbar"),i.viewport.css({paddingRight:40}));var a=i.container.outerHeight()-i.container.height(),s=t.options.zindex?t.options.zindex:t.element.offsetParent().css("z-index"),o=t.element.offset();i.container.css({top:o.top+t.element.outerHeight(),left:o.left}),i.container.show(),i.container.css({left:t.element.offset().left,height:i.ui.outerHeight()+a,width:t.element.outerWidth(),zIndex:s,cursor:"default"});var u=i.container.width()-(i.ui.outerWidth()-i.ui.width());return i.ui.css({width:u}),i.viewport.css({width:u}),t.items.css({width:u}),i.instance=t,n?t.items.each(function(){var r,a=e(this);return r="1.4.2">e.fn.jquery?e.fn.timepicker.parseTime(a.find("a").text()):a.data("time-value"),r.getTime()===n.getTime()?(i.activate(t,a),!1):!0}):i.deactivate(t),t.element},close:function(e,t){var i=this;return i.closed()||t?(clearTimeout(i.closing),i.instance===e&&(i.container.addClass("ui-helper-hidden ui-timepicker-hidden").hide(),i.ui.scrollTop(0),i.ui.children().removeClass("ui-state-hover"))):i.closing=setTimeout(function(){i.close(e,!0)},150),e.element},closed:function(){return this.ui.is(":hidden")},destroy:function(e){var t=this;return t.close(e,!0),e.element.unbind(".timepicker").data("TimePicker",null)},parse:function(t,i){return e.fn.timepicker.parseTime(i)},format:function(t,i,n){return n=n||t.options.timeFormat,e.fn.timepicker.formatTime(n,i)},getTime:function(t){var i=this,n=e.fn.timepicker.parseTime(t.element.val());return n instanceof Date&&!i._isValidTime(t,n)?null:n instanceof Date&&t.selectedTime?t.format(n)===t.format(t.selectedTime)?t.selectedTime:n:n instanceof Date?n:null},setTime:function(t,n,r){var a=this,s=t.selectedTime;if("string"==typeof n&&(n=t.parse(n)),n&&n.getMinutes&&a._isValidTime(t,n)){if(n=i(n),t.selectedTime=n,t.element.val(t.format(n,t.options.timeFormat)),r)return t}else t.selectedTime=null;return(null!==s||null!==t.selectedTime)&&(t.element.trigger("time-change",[n]),e.isFunction(t.options.change)&&t.options.change.apply(t.element,[n])),t.element},option:function(t,i,n){if(n===undefined)return t.options[i];var r,a,s=t.getTime();"string"==typeof i?(r={},r[i]=n):r=i,a=["minHour","minMinutes","minTime","maxHour","maxMinutes","maxTime","startHour","startMinutes","startTime","timeFormat","interval","dropdown"],e.each(r,function(i){t.options[i]=r[i],t.rebuild=t.rebuild||e.inArray(i,a)>-1}),t.rebuild&&t.setTime(s)}},e.TimePicker.defaults={timeFormat:"hh:mm p",minHour:null,minMinutes:null,minTime:null,maxHour:null,maxMinutes:null,maxTime:null,startHour:null,startMinutes:null,startTime:null,interval:30,dynamic:!0,theme:"standard",zindex:null,dropdown:!0,scrollbar:!1,change:function(){}},e.TimePicker.methods={chainable:["next","previous","open","close","destroy","setTime"]},e.fn.timepicker=function(t){if("string"==typeof t){var i,n,r=Array.prototype.slice.call(arguments,1);return i="option"===t&&arguments.length>2?"each":-1!==e.inArray(t,e.TimePicker.methods.chainable)?"each":"map",n=this[i](function(){var i=e(this),n=i.data("TimePicker");return"object"==typeof n?n[t].apply(n,r):undefined}),"map"===i&&1===this.length?e.makeArray(n).shift():"map"===i?e.makeArray(n):n}if(1===this.length&&this.data("TimePicker"))return this.data("TimePicker");var a=e.extend({},e.TimePicker.defaults,t);return this.each(function(){e.TimePicker.instance().register(this,a)})},e.fn.timepicker.formatTime=function(e,i){var n=i.getHours(),r=n%12,a=i.getMinutes(),s=i.getSeconds(),o={hh:t(""+(0===r?12:r),"0",2),HH:t(""+n,"0",2),mm:t(""+a,"0",2),ss:t(""+s,"0",2),h:0===r?12:r,H:n,m:a,s:s,p:n>11?"PM":"AM"},u=e,c="";for(c in o)o.hasOwnProperty(c)&&(u=u.replace(RegExp(c,"g"),o[c]));return u=u.replace(RegExp("a","g"),n>11?"pm":"am")},e.fn.timepicker.parseTime=function(){var t=[[/^(\d+)$/,"$1"],[/^:(\d)$/,"$10"],[/^:(\d+)/,"$1"],[/^(\d):([7-9])$/,"0$10$2"],[/^(\d):(\d\d)$/,"$1$2"],[/^(\d):(\d{1,})$/,"0$1$20"],[/^(\d\d):([7-9])$/,"$10$2"],[/^(\d\d):(\d)$/,"$1$20"],[/^(\d\d):(\d*)$/,"$1$2"],[/^(\d{3,}):(\d)$/,"$10$2"],[/^(\d{3,}):(\d{2,})/,"$1$2"],[/^(\d):(\d):(\d)$/,"0$10$20$3"],[/^(\d{1,2}):(\d):(\d\d)/,"$10$2$3"]],n=t.length;return function(r){var a=i(new Date),s=!1,o=!1,u=!1,c=!1,l=!1;if(r===undefined||!r.toLowerCase)return null;r=r.toLowerCase(),s=/a/.test(r),o=s?!1:/p/.test(r),r=r.replace(/[^0-9:]/g,"").replace(/:+/g,":");for(var m=0;n>m;m+=1)if(t[m][0].test(r)){r=r.replace(t[m][0],t[m][1]);break}return r=r.replace(/:/g,""),1===r.length?u=r:2===r.length?u=r:3===r.length||5===r.length?(u=r.substr(0,1),c=r.substr(1,2),l=r.substr(3,2)):(4===r.length||r.length>5)&&(u=r.substr(0,2),c=r.substr(2,2),l=r.substr(4,2)),r.length>0&&5>r.length&&(3>r.length&&(c=0),l=0),u===!1||c===!1||l===!1?!1:(u=parseInt(u,10),c=parseInt(c,10),l=parseInt(l,10),s&&12===u?u=0:o&&12>u&&(u+=12),u>24?r.length>=6?e.fn.timepicker.parseTime(r.substr(0,5)):e.fn.timepicker.parseTime(r+"0"+(s?"a":"")+(o?"p":"")):(a.setHours(u,c,l),a))}}()}(jQuery);
includes/js/wcj-datepicker.js CHANGED
@@ -2,4 +2,5 @@ jQuery(document).ready(function() {
2
  jQuery("input[display='date']").datepicker({
3
  dateFormat : 'yy/mm/dd'
4
  });
 
5
  });
2
  jQuery("input[display='date']").datepicker({
3
  dateFormat : 'yy/mm/dd'
4
  });
5
+ jQuery("input[display='time']").timepicker();
6
  });
includes/lib/tcpdf_min/config/tcpdf_config.php CHANGED
@@ -64,7 +64,8 @@
64
  * By default it is automatically set but you can also set it as a fixed string to improve performances.
65
  */
66
  //define ('K_PATH_IMAGES', '');
67
- define ( 'K_PATH_IMAGES', $_SERVER['DOCUMENT_ROOT'] );
 
68
 
69
  /**
70
  * Deafult image logo used be the default Header() method.
64
  * By default it is automatically set but you can also set it as a fixed string to improve performances.
65
  */
66
  //define ('K_PATH_IMAGES', '');
67
+ //define ( 'K_PATH_IMAGES', $_SERVER['DOCUMENT_ROOT'] );
68
+ define ( 'K_PATH_IMAGES', ABSPATH ); // Algoritmika - WCJ version 2.3.0
69
 
70
  /**
71
  * Deafult image logo used be the default Header() method.
includes/lib/tcpdf_min/include/tcpdf_font_data.php CHANGED
@@ -45,6 +45,10 @@
45
  * @version 1.0.001
46
  * @author Nicola Asuni - info@tecnick.com
47
  */
 
 
 
 
48
  class TCPDF_FONT_DATA {
49
 
50
  /**
45
  * @version 1.0.001
46
  * @author Nicola Asuni - info@tecnick.com
47
  */
48
+
49
+ // Added by Algoritmika
50
+ if ( class_exists( 'TCPDF_FONT_DATA' ) ) return;
51
+
52
  class TCPDF_FONT_DATA {
53
 
54
  /**
includes/pdf-invoices/class-wcj-pdf-invoicing-renumerate-tool.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack PDF Invoices Renumerate Tool class.
6
  *
7
- * @version 2.2.1
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -18,9 +18,9 @@ class WCJ_PDF_Invoicing_Renumerate_Tool {
18
  * Constructor.
19
  */
20
  public function __construct() {
21
- add_filter( 'wcj_tools_tabs', array( $this, 'add_renumerate_invoices_tool_tab' ), 100 );
22
- add_action( 'wcj_tools_renumerate_invoices', array( $this, 'create_renumerate_invoices_tool' ), 100 );
23
- add_action( 'wcj_tools_dashboard', array( $this, 'add_renumerate_invoices_tool_info_to_tools_dashboard' ), 100 );
24
  }
25
 
26
  /**
@@ -60,6 +60,8 @@ class WCJ_PDF_Invoicing_Renumerate_Tool {
60
 
61
  /**
62
  * Add Renumerate Invoices tool to WooCommerce menu (the content).
 
 
63
  */
64
  public function create_renumerate_invoices_tool() {
65
  $result_message = '';
@@ -81,8 +83,8 @@ class WCJ_PDF_Invoicing_Renumerate_Tool {
81
  //$result_message .= '<p>' . $renumerate_result . '</p>';
82
  }
83
  ?><div>
84
- <h2><?php echo __( 'WooCommerce Jetpack - Renumerate Invoices', 'woocommerce-jetpack' ); ?></h2>
85
- <p><?php echo __( 'The tool renumerates invoices from choosen date. Invoice number format is set in WooCommerce > Settings > Jetpack > PDF Invoices (v2) > Numbering.', 'woocommerce-jetpack' ); ?></p>
86
  <?php echo $result_message; ?>
87
  <p><form method="post" action="">
88
  <?php
4
  *
5
  * The WooCommerce Jetpack PDF Invoices Renumerate Tool class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
18
  * Constructor.
19
  */
20
  public function __construct() {
21
+ add_filter( 'wcj_tools_tabs', array( $this, 'add_renumerate_invoices_tool_tab' ), 100 );
22
+ add_action( 'wcj_tools_renumerate_invoices', array( $this, 'create_renumerate_invoices_tool' ), 100 );
23
+ add_action( 'wcj_tools_dashboard', array( $this, 'add_renumerate_invoices_tool_info_to_tools_dashboard' ), 100 );
24
  }
25
 
26
  /**
60
 
61
  /**
62
  * Add Renumerate Invoices tool to WooCommerce menu (the content).
63
+ *
64
+ * @version 2.3.0
65
  */
66
  public function create_renumerate_invoices_tool() {
67
  $result_message = '';
83
  //$result_message .= '<p>' . $renumerate_result . '</p>';
84
  }
85
  ?><div>
86
+ <h2><?php echo __( 'Booster - Renumerate Invoices', 'woocommerce-jetpack' ); ?></h2>
87
+ <p><?php echo __( 'The tool renumerates invoices from choosen date. Invoice number format is set in WooCommerce > Settings > Booster > PDF Invoicing & Packing Slips > Numbering.', 'woocommerce-jetpack' ); ?></p>
88
  <?php echo $result_message; ?>
89
  <p><form method="post" action="">
90
  <?php
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.2.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -12,35 +12,39 @@ if ( ! defined( 'ABSPATH' ) ) exit;
12
 
13
  if ( ! class_exists( 'WCJ_PDF_Invoicing_Display' ) ) :
14
 
15
- class WCJ_PDF_Invoicing_Display {
16
 
17
- /**
18
- * Constructor.
19
- */
20
- function __construct() {
 
 
 
 
 
 
 
 
21
 
22
- if ( 'yes' === get_option( 'wcj_pdf_invoicing_enabled' ) ) {
23
 
24
  // Columns on Admin's Orders page
25
- add_filter( 'manage_edit-shop_order_columns', array( $this, 'add_order_column' ), PHP_INT_MAX );
26
- add_action( 'manage_shop_order_posts_custom_column', array( $this, 'render_order_columns' ), 2 );
27
 
28
  // Action Links on Admin's Orders page
29
- //add_filter( 'woocommerce_admin_order_actions', array( $this, 'add_pdf_invoices_action_links' ), PHP_INT_MAX, 2 );
30
- //add_action( 'admin_head', array( $this, 'add_pdf_invoice_icon_css' ) );
31
 
32
  // Action Links on Customer's My Account page
33
  add_filter( 'woocommerce_my_account_my_orders_actions', array( $this, 'add_pdf_invoices_action_links' ), PHP_INT_MAX, 2 );
34
  }
 
35
 
36
- // Settings hooks
37
- add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
38
- add_filter( 'wcj_settings_pdf_invoicing_display', array( $this, 'get_settings' ), 100 );
39
- }
40
-
41
- /**
42
- * add_order_column.
43
- */
44
  function add_order_column( $columns ) {
45
  $invoice_types = wcj_get_enabled_invoice_types();
46
  foreach ( $invoice_types as $invoice_type ) {
@@ -53,7 +57,9 @@ class WCJ_PDF_Invoicing_Display {
53
 
54
  /**
55
  * Ouput custom columns for products
56
- * @param string $column
 
 
57
  */
58
  public function render_order_columns( $column ) {
59
 
@@ -65,25 +71,46 @@ class WCJ_PDF_Invoicing_Display {
65
  $order_id = get_the_ID();
66
  $invoice_type_id = $column;
67
 
68
- if ( ! wcj_is_invoice_created( $order_id, $invoice_type_id ) )
69
- return;
 
 
 
 
70
 
71
- $the_invoice = wcj_get_invoice( $order_id, $invoice_type_id );
72
- $the_number = $the_invoice->get_invoice_number();
73
- //$the_url = $the_invoice->get_invoice_url();
74
- //$the_link = $the_invoice->get_invoice_link();
75
- $query_args = array( 'order_id' => $order_id, 'invoice_type_id' => $invoice_type_id, 'get_invoice' => '1', );
76
- if ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type_id . '_save_as_enabled', 'no' ) ) {
77
- $query_args['save_pdf_invoice'] = '1';
78
- }
79
- $the_link = '<a href="' . add_query_arg( $query_args ) . '">' . $the_number . '</a>';
80
 
81
- echo $the_link;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  }
83
 
84
- /**
85
- * add_pdf_invoice_icon_css.
86
- *
87
  function add_pdf_invoice_icon_css() {
88
  $invoice_types = wcj_get_enabled_invoice_types();
89
  foreach ( $invoice_types as $invoice_type ) {
@@ -91,12 +118,10 @@ class WCJ_PDF_Invoicing_Display {
91
  }
92
  }
93
 
94
- /**
95
- * add_pdf_invoices_action_links.
96
- */
97
- function add_pdf_invoices_action_links( $actions, $the_order ) {
98
-
99
-
100
 
101
  $invoice_types = wcj_get_enabled_invoice_types();
102
  foreach ( $invoice_types as $invoice_type ) {
@@ -108,7 +133,7 @@ class WCJ_PDF_Invoicing_Display {
108
  $my_account_option_name = 'wcj_invoicing_' . $invoice_type['id'] . '_enabled_for_customers';
109
 
110
  /*if ( ( 'woocommerce_admin_order_actions' === current_filter() && 'add_action_link' === get_option( $admin_option_name, 'add_column' ) ) ||
111
- ( 'woocommerce_my_account_my_orders_actions' === current_filter() && 'yes' === apply_filters( 'wcj_get_option_filter', 'no', get_option( $my_account_option_name, 'no' ) ) ) ) {*/
112
 
113
  //if ( 'woocommerce_my_account_my_orders_actions' === current_filter() && 'yes' === apply_filters( 'wcj_get_option_filter', 'no', get_option( $my_account_option_name, 'no' ) ) ) {
114
  if ( 'yes' === get_option( $my_account_option_name, 'no' ) ) {
@@ -134,12 +159,12 @@ class WCJ_PDF_Invoicing_Display {
134
  }
135
 
136
  return $actions;
137
- }
138
 
139
- /**
140
- * get_settings.
141
- */
142
- function get_settings() {
143
 
144
  $settings = array();
145
  $invoice_types = wcj_get_invoice_types();
@@ -148,39 +173,40 @@ class WCJ_PDF_Invoicing_Display {
148
  $settings[] = array( 'title' => strtoupper( $invoice_type['desc'] ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_display_options' );
149
 
150
  $settings = array_merge( $settings, array(
 
151
  array(
152
  'title' => __( 'Admin\'s "Orders" Page', 'woocommerce-jetpack' ),
153
  'desc' => __( 'Add Column', 'woocommerce-jetpack' ),
154
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_admin_orders_page_column',
155
  'default' => 'yes',
156
  'type' => 'checkbox',
157
- /*'class' => 'chosen_select',
158
  'options' => array(
159
  'add_column' => __( 'Add Column', 'woocommerce-jetpack' ),
160
  'add_action_link' => __( 'Add Action Link', 'woocommerce-jetpack' ),
161
- ),*/
162
  ),
163
 
164
  array(
165
  'title' => __( 'Customer\'s "My Account" Page', 'woocommerce-jetpack' ),
166
- //'desc' => __( 'Enable the PDF Invoices in customers account', 'woocommerce-jetpack' ),
167
  'desc' => __( 'Add link', 'woocommerce-jetpack' ),
168
- 'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
169
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_enabled_for_customers',
170
  'default' => 'no',
171
  'type' => 'checkbox',
172
- 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
173
  ),
174
 
175
  array(
176
  'title' => __( 'Enable "Save as"', 'woocommerce-jetpack' ),
177
  'desc' => __( 'Enable', 'woocommerce-jetpack' ),
178
- 'desc_tip' => __( 'Enable "save as" pdf instead of view pdf in browser', 'woocommerce-jetpack' ),
179
- //'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
180
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_save_as_enabled',
181
  'default' => 'yes',
182
  'type' => 'checkbox',
183
- //'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
184
  ),
185
 
186
  array(
@@ -195,18 +221,10 @@ class WCJ_PDF_Invoicing_Display {
195
  $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_display_options' );
196
  }
197
 
198
- return $settings;
199
- }
200
-
201
- /**
202
- * settings_section.
203
- */
204
- function settings_section( $sections ) {
205
- $sections['pdf_invoicing_display'] = __( 'Misc.', 'woocommerce-jetpack' );
206
- return $sections;
207
- }
208
  }
209
 
210
  endif;
211
 
212
- return new WCJ_PDF_Invoicing_Display();
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing Display class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
12
 
13
  if ( ! class_exists( 'WCJ_PDF_Invoicing_Display' ) ) :
14
 
15
+ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
16
 
17
+ /**
18
+ * Constructor.
19
+ *
20
+ * @version 2.3.0
21
+ */
22
+ function __construct() {
23
+
24
+ $this->id = 'pdf_invoicing_display';
25
+ $this->parent_id = 'pdf_invoicing';
26
+ $this->short_desc = __( 'Misc.', 'woocommerce-jetpack' );
27
+ $this->desc = '';
28
+ parent::__construct( 'submodule' );
29
 
30
+ if ( $this->is_enabled() ) {
31
 
32
  // Columns on Admin's Orders page
33
+ add_filter( 'manage_edit-shop_order_columns', array( $this, 'add_order_column' ), PHP_INT_MAX );
34
+ add_action( 'manage_shop_order_posts_custom_column', array( $this, 'render_order_columns' ), 2 );
35
 
36
  // Action Links on Admin's Orders page
37
+ // add_filter( 'woocommerce_admin_order_actions', array( $this, 'add_pdf_invoices_action_links' ), PHP_INT_MAX, 2 );
38
+ // add_action( 'admin_head', array( $this, 'add_pdf_invoice_icon_css' ) );
39
 
40
  // Action Links on Customer's My Account page
41
  add_filter( 'woocommerce_my_account_my_orders_actions', array( $this, 'add_pdf_invoices_action_links' ), PHP_INT_MAX, 2 );
42
  }
43
+ }
44
 
45
+ /**
46
+ * add_order_column.
47
+ */
 
 
 
 
 
48
  function add_order_column( $columns ) {
49
  $invoice_types = wcj_get_enabled_invoice_types();
50
  foreach ( $invoice_types as $invoice_type ) {
57
 
58
  /**
59
  * Ouput custom columns for products
60
+ *
61
+ * @param string $column
62
+ * @version 2.3.0
63
  */
64
  public function render_order_columns( $column ) {
65
 
71
  $order_id = get_the_ID();
72
  $invoice_type_id = $column;
73
 
74
+ $html = '';
75
+ if ( wcj_is_invoice_created( $order_id, $invoice_type_id ) ) {
76
+ $the_invoice = wcj_get_invoice( $order_id, $invoice_type_id );
77
+ $the_number = $the_invoice->get_invoice_number();
78
+ // $the_url = $the_invoice->get_invoice_url();
79
+ // $the_link = $the_invoice->get_invoice_link();
80
 
81
+ //$html .= ' ';
 
 
 
 
 
 
 
 
82
 
83
+ $query_args = array( 'order_id' => $order_id, 'invoice_type_id' => $invoice_type_id, 'get_invoice' => '1', );
84
+ if ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type_id . '_save_as_enabled', 'no' ) ) {
85
+ $query_args['save_pdf_invoice'] = '1';
86
+ }
87
+ $html .= '<a href="' . add_query_arg( $query_args ) . '">' . $the_number . '</a>';
88
+
89
+ $html .= ' ';
90
+
91
+ $html .= '<a href="';
92
+ $html .= add_query_arg(
93
+ array( 'delete_invoice_for_order_id' => $order_id, 'invoice_type_id' => $invoice_type_id ),
94
+ remove_query_arg( 'create_invoice_for_order_id' )
95
+ );
96
+ $html .= '"><span style="color:gray;font-style:italic;font-size:x-small;text-decoration:underline;">' . __( 'Delete', 'woocommerce-jetpack' ) . '</span></a>';
97
+ //$html .= '">' . '<img src="http://icons.iconarchive.com/icons/double-j-design/origami-colored-pencil/16/red-cross-icon.png">' . '</a>';
98
+
99
+ } else {
100
+ $html .= '<a href="';
101
+ $html .= add_query_arg(
102
+ array( 'create_invoice_for_order_id' => $order_id, 'invoice_type_id' => $invoice_type_id ),
103
+ remove_query_arg( 'delete_invoice_for_order_id' )
104
+ );
105
+ $html .= '"><span style="color:gray;font-style:italic;font-size:x-small;text-decoration:underline;">' . __( 'Create', 'woocommerce-jetpack' ) . '</span></a>';
106
+ //$html .= '">' . '<img src="http://icons.iconarchive.com/icons/double-j-design/origami-colored-pencil/16/blue-plus-icon.png">' . '</a>';
107
+ }
108
+ echo $html;
109
  }
110
 
111
+ /**
112
+ * add_pdf_invoice_icon_css.
113
+ *
114
  function add_pdf_invoice_icon_css() {
115
  $invoice_types = wcj_get_enabled_invoice_types();
116
  foreach ( $invoice_types as $invoice_type ) {
118
  }
119
  }
120
 
121
+ /**
122
+ * add_pdf_invoices_action_links.
123
+ */
124
+ function add_pdf_invoices_action_links( $actions, $the_order ) {
 
 
125
 
126
  $invoice_types = wcj_get_enabled_invoice_types();
127
  foreach ( $invoice_types as $invoice_type ) {
133
  $my_account_option_name = 'wcj_invoicing_' . $invoice_type['id'] . '_enabled_for_customers';
134
 
135
  /*if ( ( 'woocommerce_admin_order_actions' === current_filter() && 'add_action_link' === get_option( $admin_option_name, 'add_column' ) ) ||
136
+ ( 'woocommerce_my_account_my_orders_actions' === current_filter() && 'yes' === apply_filters( 'wcj_get_option_filter', 'no', get_option( $my_account_option_name, 'no' ) ) ) ) {*/
137
 
138
  //if ( 'woocommerce_my_account_my_orders_actions' === current_filter() && 'yes' === apply_filters( 'wcj_get_option_filter', 'no', get_option( $my_account_option_name, 'no' ) ) ) {
139
  if ( 'yes' === get_option( $my_account_option_name, 'no' ) ) {
159
  }
160
 
161
  return $actions;
162
+ }
163
 
164
+ /**
165
+ * get_settings.
166
+ */
167
+ function get_settings() {
168
 
169
  $settings = array();
170
  $invoice_types = wcj_get_invoice_types();
173
  $settings[] = array( 'title' => strtoupper( $invoice_type['desc'] ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_display_options' );
174
 
175
  $settings = array_merge( $settings, array(
176
+
177
  array(
178
  'title' => __( 'Admin\'s "Orders" Page', 'woocommerce-jetpack' ),
179
  'desc' => __( 'Add Column', 'woocommerce-jetpack' ),
180
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_admin_orders_page_column',
181
  'default' => 'yes',
182
  'type' => 'checkbox',
183
+ /* 'class' => 'chosen_select',
184
  'options' => array(
185
  'add_column' => __( 'Add Column', 'woocommerce-jetpack' ),
186
  'add_action_link' => __( 'Add Action Link', 'woocommerce-jetpack' ),
187
+ ), */
188
  ),
189
 
190
  array(
191
  'title' => __( 'Customer\'s "My Account" Page', 'woocommerce-jetpack' ),
192
+ // 'desc' => __( 'Enable the PDF Invoices in customers account', 'woocommerce-jetpack' ),
193
  'desc' => __( 'Add link', 'woocommerce-jetpack' ),
194
+ 'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
195
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_enabled_for_customers',
196
  'default' => 'no',
197
  'type' => 'checkbox',
198
+ 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
199
  ),
200
 
201
  array(
202
  'title' => __( 'Enable "Save as"', 'woocommerce-jetpack' ),
203
  'desc' => __( 'Enable', 'woocommerce-jetpack' ),
204
+ 'desc_tip' => __( 'Enable "save as" pdf instead of view pdf in browser', 'woocommerce-jetpack' ),
205
+ // 'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
206
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_save_as_enabled',
207
  'default' => 'yes',
208
  'type' => 'checkbox',
209
+ // 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
210
  ),
211
 
212
  array(
221
  $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_display_options' );
222
  }
223
 
224
+ return $settings;
225
+ }
 
 
 
 
 
 
 
 
226
  }
227
 
228
  endif;
229
 
230
+ return new WCJ_PDF_Invoicing_Display();
includes/pdf-invoices/settings/class-wcj-pdf-invoicing-footer.php CHANGED
@@ -14,22 +14,21 @@ if ( ! class_exists( 'WCJ_PDF_Invoicing_Footer' ) ) :
14
 
15
  class WCJ_PDF_Invoicing_Footer extends WCJ_Module {
16
 
17
- /**
18
- * Constructor.
19
- */
20
- public function __construct() {
21
-
22
  $this->id = 'pdf_invoicing_footer';
23
  $this->parent_id = 'pdf_invoicing';
24
  $this->short_desc = __( 'Footer', 'woocommerce-jetpack' );
25
  $this->desc = '';
26
  parent::__construct( 'submodule' );
27
- }
28
 
29
- /**
30
- * get_settings.
31
- */
32
- function get_settings() {
33
 
34
  $settings = array();
35
  $invoice_types = wcj_get_invoice_types();
14
 
15
  class WCJ_PDF_Invoicing_Footer extends WCJ_Module {
16
 
17
+ /**
18
+ * Constructor.
19
+ */
20
+ public function __construct() {
 
21
  $this->id = 'pdf_invoicing_footer';
22
  $this->parent_id = 'pdf_invoicing';
23
  $this->short_desc = __( 'Footer', 'woocommerce-jetpack' );
24
  $this->desc = '';
25
  parent::__construct( 'submodule' );
26
+ }
27
 
28
+ /**
29
+ * get_settings.
30
+ */
31
+ function get_settings() {
32
 
33
  $settings = array();
34
  $invoice_types = wcj_get_invoice_types();
includes/pdf-invoices/settings/class-wcj-pdf-invoicing-header.php CHANGED
@@ -4,47 +4,51 @@
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing Header class.
6
  *
7
- * @class WCJ_PDF_Invoicing_Header
8
- * @version 1.0.0
9
- * @category Class
10
  * @author Algoritmika Ltd.
11
  */
12
-
13
  if ( ! defined( 'ABSPATH' ) ) exit;
14
-
15
  if ( ! class_exists( 'WCJ_PDF_Invoicing_Header' ) ) :
16
-
17
- class WCJ_PDF_Invoicing_Header {
18
-
19
- /**
20
- * Constructor.
21
- */
22
- public function __construct() {
23
- // Settings hooks
24
- add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
25
- add_filter( 'wcj_settings_pdf_invoicing_header', array( $this, 'get_settings' ), 100 );
26
- }
27
-
28
- /**
29
- * get_settings.
30
- */
31
- function get_settings() {
32
-
33
- $settings = array();
 
 
 
 
 
 
34
  $invoice_types = wcj_get_invoice_types();
35
- foreach ( $invoice_types as $invoice_type ) {
 
 
36
 
37
- $settings[] = array( 'title' => strtoupper( $invoice_type['desc'] ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_options' );
38
-
39
  $settings = array_merge( $settings, array(
40
-
41
  array(
42
  'title' => __( 'Enable Header', 'woocommerce-jetpack' ),
43
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_enabled',
44
  'default' => 'yes',
45
  'type' => 'checkbox',
46
- ),
47
-
48
  array(
49
  'title' => __( 'Header Image', 'woocommerce-jetpack' ),
50
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_image',
@@ -52,33 +56,30 @@ class WCJ_PDF_Invoicing_Header {
52
  'type' => 'text',
53
  'css' => 'width:33%;min-width:300px;',
54
  'desc' => __( 'Enter a URL to an image you want to show in the invoice\'s header. Upload your image using the <a href="/wp-admin/media-new.php">media uploader</a>.', 'woocommerce-jetpack' ),
55
- 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
56
- ),
57
 
58
  array(
59
  'title' => __( 'Header Image Width in mm', 'woocommerce-jetpack' ),
60
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_image_width_mm',
61
  'default' => 50,
62
  'type' => 'number',
63
- ),
64
-
65
  array(
66
  'title' => __( 'Header Title', 'woocommerce-jetpack' ),
67
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_title_text',
68
  'default' => $invoice_type['title'],
69
  'type' => 'text',
70
- //'css' => 'width:66%;min-width:300px;height:165px;',
71
- ),
72
 
73
  array(
74
  'title' => __( 'Header Text', 'woocommerce-jetpack' ),
75
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_text',
76
  'default' => __( 'Company Name', 'woocommerce-jetpack' ),
77
  'type' => 'text',
78
- //'css' => 'width:66%;min-width:300px;height:165px;',
79
- 'desc' => apply_filters( 'wcj_get_option_filter', __( 'free version will add "powered by woojetpack.com" to heading text', 'woocommerce-jetpack' ), '' ),
80
- ),
81
-
82
  array(
83
  'title' => __( 'Header Text Color', 'woocommerce-jetpack' ),
84
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_text_color',
@@ -86,7 +87,7 @@ class WCJ_PDF_Invoicing_Header {
86
  'type' => 'color',
87
  'css' => 'width:6em;',
88
  ),
89
-
90
  array(
91
  'title' => __( 'Header Line Color', 'woocommerce-jetpack' ),
92
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_line_color',
@@ -102,22 +103,14 @@ class WCJ_PDF_Invoicing_Header {
102
  'type' => 'number',
103
  ),
104
  ) );
105
-
106
- $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_options' );
107
- }
108
-
109
- return $settings;
110
- }
111
-
112
- /**
113
- * settings_section.
114
- */
115
- function settings_section( $sections ) {
116
- $sections['pdf_invoicing_header'] = __( 'Header', 'woocommerce-jetpack' );
117
- return $sections;
118
- }
119
  }
120
-
121
  endif;
122
-
123
  return new WCJ_PDF_Invoicing_Header();
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing Header class.
6
  *
7
+ * @version 2.3.0
 
 
8
  * @author Algoritmika Ltd.
9
  */
10
+
11
  if ( ! defined( 'ABSPATH' ) ) exit;
12
+
13
  if ( ! class_exists( 'WCJ_PDF_Invoicing_Header' ) ) :
14
+
15
+ class WCJ_PDF_Invoicing_Header extends WCJ_Module {
16
+
17
+ /**
18
+ * Constructor.
19
+ *
20
+ * @version 2.3.0
21
+ */
22
+ public function __construct() {
23
+ $this->id = 'pdf_invoicing_header';
24
+ $this->parent_id = 'pdf_invoicing';
25
+ $this->short_desc = __( 'Header', 'woocommerce-jetpack' );
26
+ $this->desc = '';
27
+ parent::__construct( 'submodule' );
28
+ }
29
+
30
+ /**
31
+ * get_settings.
32
+ *
33
+ * @version 2.3.0
34
+ */
35
+ function get_settings() {
36
+
37
+ $settings = array();
38
  $invoice_types = wcj_get_invoice_types();
39
+ foreach ( $invoice_types as $invoice_type ) {
40
+
41
+ $settings[] = array( 'title' => strtoupper( $invoice_type['desc'] ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_options' );
42
 
 
 
43
  $settings = array_merge( $settings, array(
44
+
45
  array(
46
  'title' => __( 'Enable Header', 'woocommerce-jetpack' ),
47
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_enabled',
48
  'default' => 'yes',
49
  'type' => 'checkbox',
50
+ ),
51
+
52
  array(
53
  'title' => __( 'Header Image', 'woocommerce-jetpack' ),
54
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_image',
56
  'type' => 'text',
57
  'css' => 'width:33%;min-width:300px;',
58
  'desc' => __( 'Enter a URL to an image you want to show in the invoice\'s header. Upload your image using the <a href="/wp-admin/media-new.php">media uploader</a>.', 'woocommerce-jetpack' ),
59
+ 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
60
+ ),
61
 
62
  array(
63
  'title' => __( 'Header Image Width in mm', 'woocommerce-jetpack' ),
64
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_image_width_mm',
65
  'default' => 50,
66
  'type' => 'number',
67
+ ),
68
+
69
  array(
70
  'title' => __( 'Header Title', 'woocommerce-jetpack' ),
71
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_title_text',
72
  'default' => $invoice_type['title'],
73
  'type' => 'text',
74
+ ),
 
75
 
76
  array(
77
  'title' => __( 'Header Text', 'woocommerce-jetpack' ),
78
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_text',
79
  'default' => __( 'Company Name', 'woocommerce-jetpack' ),
80
  'type' => 'text',
81
+ ),
82
+
 
 
83
  array(
84
  'title' => __( 'Header Text Color', 'woocommerce-jetpack' ),
85
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_text_color',
87
  'type' => 'color',
88
  'css' => 'width:6em;',
89
  ),
90
+
91
  array(
92
  'title' => __( 'Header Line Color', 'woocommerce-jetpack' ),
93
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_line_color',
103
  'type' => 'number',
104
  ),
105
  ) );
106
+
107
+ $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_options' );
108
+ }
109
+
110
+ return $settings;
111
+ }
 
 
 
 
 
 
 
 
112
  }
113
+
114
  endif;
115
+
116
  return new WCJ_PDF_Invoicing_Header();
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.1.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -12,70 +12,73 @@ if ( ! defined( 'ABSPATH' ) ) exit;
12
 
13
  if ( ! class_exists( 'WCJ_PDF_Invoicing_Numbering' ) ) :
14
 
15
- class WCJ_PDF_Invoicing_Numbering {
16
 
17
- /**
18
- * Constructor.
19
- */
20
- public function __construct() {
21
- // Settings hooks
22
- add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
23
- add_filter( 'wcj_settings_pdf_invoicing_numbering', array( $this, 'get_settings' ), 100 );
24
- }
25
 
26
- /**
27
- * get_settings.
28
- */
29
- function get_settings() {
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  $settings = array();
 
32
  $invoice_types = wcj_get_invoice_types();
33
  foreach ( $invoice_types as $invoice_type ) {
34
-
35
  $settings[] = array( 'title' => strtoupper( $invoice_type['desc'] ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_options' );
36
  $settings[] = array(
37
- 'title' => __( 'Sequential', 'woocommerce-jetpack' ),
38
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_sequential_enabled',
39
- 'default' => 'no',
40
- 'type' => 'checkbox',
41
- );
42
  $settings[] = array(
43
- 'title' => __( 'Counter', 'woocommerce-jetpack' ),
44
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_counter',
45
- 'default' => 1,
46
- 'type' => 'number',
47
- );
48
  $settings[] = array(
49
- 'title' => __( 'Prefix', 'woocommerce-jetpack' ),
50
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_prefix',
51
- 'default' => '',
52
- 'type' => 'text',
53
- );
54
  $settings[] = array(
55
- 'title' => __( 'Counter Width', 'woocommerce-jetpack' ),
56
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_counter_width',
57
- 'default' => 0,
58
- 'type' => 'number',
59
- );
60
  $settings[] = array(
61
- 'title' => __( 'Suffix', 'woocommerce-jetpack' ),
62
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_suffix',
63
- 'default' => '',
64
- 'type' => 'text',
65
- );
66
  $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_options' );
67
  }
68
 
69
- return $settings;
70
- }
71
 
72
- /**
73
- * settings_section.
74
- */
75
- function settings_section( $sections ) {
76
- $sections['pdf_invoicing_numbering'] = __( 'Numbering', 'woocommerce-jetpack' );
77
- return $sections;
78
- }
79
  }
80
 
81
  endif;
4
  *
5
  * The WooCommerce Jetpack PDF Invoices Numbering class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
12
 
13
  if ( ! class_exists( 'WCJ_PDF_Invoicing_Numbering' ) ) :
14
 
15
+ class WCJ_PDF_Invoicing_Numbering extends WCJ_Module {
16
 
17
+ /**
18
+ * Constructor.
19
+ *
20
+ * @version 2.3.0
21
+ */
22
+ public function __construct() {
 
 
23
 
24
+ $this->id = 'pdf_invoicing_numbering';
25
+ $this->parent_id = 'pdf_invoicing';
26
+ $this->short_desc = __( 'Numbering', 'woocommerce-jetpack' );
27
+ $this->desc = '';
28
+ parent::__construct( 'submodule' );
29
+
30
+ $this->add_tools( array( 'renumerate_invoices' => __( 'Renumerate Invoices', 'woocommerce-jetpack' ), ) );
31
+ }
32
+
33
+ /**
34
+ * get_settings.
35
+ *
36
+ * @version 2.3.0
37
+ */
38
+ function get_settings() {
39
 
40
  $settings = array();
41
+
42
  $invoice_types = wcj_get_invoice_types();
43
  foreach ( $invoice_types as $invoice_type ) {
 
44
  $settings[] = array( 'title' => strtoupper( $invoice_type['desc'] ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_options' );
45
  $settings[] = array(
46
+ 'title' => __( 'Sequential', 'woocommerce-jetpack' ),
47
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_sequential_enabled',
48
+ 'default' => 'no',
49
+ 'type' => 'checkbox',
50
+ );
51
  $settings[] = array(
52
+ 'title' => __( 'Counter', 'woocommerce-jetpack' ),
53
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_counter',
54
+ 'default' => 1,
55
+ 'type' => 'number',
56
+ );
57
  $settings[] = array(
58
+ 'title' => __( 'Prefix', 'woocommerce-jetpack' ),
59
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_prefix',
60
+ 'default' => '',
61
+ 'type' => 'text',
62
+ );
63
  $settings[] = array(
64
+ 'title' => __( 'Counter Width', 'woocommerce-jetpack' ),
65
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_counter_width',
66
+ 'default' => 0,
67
+ 'type' => 'number',
68
+ );
69
  $settings[] = array(
70
+ 'title' => __( 'Suffix', 'woocommerce-jetpack' ),
71
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_suffix',
72
+ 'default' => '',
73
+ 'type' => 'text',
74
+ );
75
  $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_options' );
76
  }
77
 
78
+ $settings = $this->add_tools_list( $settings );
 
79
 
80
+ return $settings;
81
+ }
 
 
 
 
 
82
  }
83
 
84
  endif;
includes/price-by-country/class-wcj-exchange-rates-crons.php DELETED
@@ -1,130 +0,0 @@
1
- <?php
2
- /**
3
- * WooCommerce Jetpack Exchange Rates Crons
4
- *
5
- * The WooCommerce Jetpack Exchange Rates Crons class.
6
- *
7
- * @version 2.2.0
8
- * @author Algoritmika Ltd.
9
- */
10
-
11
- if ( ! defined( 'ABSPATH' ) ) exit;
12
-
13
- if ( ! class_exists( 'WCJ_Exchange_Rates_Crons' ) ) :
14
-
15
- class WCJ_Exchange_Rates_Crons {
16
-
17
- /**
18
- * Constructor.
19
- */
20
- public function __construct() {
21
- add_action( 'wp', array( $this, 'schedule_the_events' ) );
22
- $this->update_intervals = array(
23
- 'manual' => __( 'Enter Rates Manually', 'woocommerce-jetpack' ),
24
- 'hourly' => __( 'Automatically: Update Hourly', 'woocommerce-jetpack' ),
25
- 'twicedaily' => __( 'Automatically: Update Twice Daily', 'woocommerce-jetpack' ),
26
- 'daily' => __( 'Automatically: Update Daily', 'woocommerce-jetpack' ),
27
- 'weekly' => __( 'Automatically: Update Weekly', 'woocommerce-jetpack' ),
28
- 'minutely' => __( 'Automatically: Update Every Minute', 'woocommerce-jetpack' ),
29
- );
30
- /*foreach ( $this->update_intervals as $interval => $desc ) {
31
- if ( 'manual' === $interval )
32
- continue;
33
- add_action( 'auto_update_exchange_rates_hook_' . $interval,
34
- array( $this, 'update_the_exchange_rates' ) );
35
- }*/
36
- $selected_interval = get_option( 'wcj_price_by_country_auto_exchange_rates', 'manual' );
37
- if ( 'manual' != $selected_interval ) {
38
- //add_action( 'auto_update_exchange_rates_hook_' . $selected_interval,
39
- add_action( 'auto_update_exchange_rates_hook',
40
- array( $this, 'update_the_exchange_rates' ) );
41
- }
42
- add_filter( 'cron_schedules', array( $this, 'cron_add_custom_intervals' ) );
43
- }
44
-
45
- /**
46
- * On an early action hook, check if the hook is scheduled - if not, schedule it.
47
- */
48
- function schedule_the_events() {
49
-
50
- $selected_interval = apply_filters( 'wcj_get_option_filter', 'manual', get_option( 'wcj_price_by_country_auto_exchange_rates', 'manual' ) );
51
- foreach ( $this->update_intervals as $interval => $desc ) {
52
- if ( 'manual' === $interval )
53
- continue;
54
- $event_hook = 'auto_update_exchange_rates_hook';//_' . $interval;
55
- $event_timestamp = wp_next_scheduled( $event_hook, array( $interval ) );
56
- if ( ! $event_timestamp && $selected_interval === $interval ) {
57
- wp_schedule_event( time(), $selected_interval, $event_hook, array( $selected_interval ) );
58
- } elseif ( $event_timestamp && $selected_interval !== $interval ) {
59
- wp_unschedule_event( $event_timestamp, $event_hook, array( $interval ) );
60
- }
61
- }
62
- }
63
-
64
- /*
65
- * Functions gets currency exchange rate from rate-exchange.appspot.com server.
66
- * returns rate on success, else 0
67
- */
68
- function get_exchange_rate( $currency_from, $currency_to ) {
69
-
70
- $url = "http://query.yahooapis.com/v1/public/yql?q=select%20rate%2Cname%20from%20csv%20where%20url%3D'http%3A%2F%2Fdownload.finance.yahoo.com%2Fd%2Fquotes%3Fs%3D" . $currency_from . $currency_to . "%253DX%26f%3Dl1n'%20and%20columns%3D'rate%2Cname'&format=json";
71
- //$url = 'http://rate-exchange.appspot.com/currency?from=' . $currency_from . '&to=' . $currency_to;
72
-
73
- ob_start();
74
- $max_execution_time = ini_get( 'max_execution_time' );
75
- set_time_limit( 2 );
76
-
77
- $exchange_rate = json_decode( file_get_contents( $url ) );
78
-
79
- set_time_limit( $max_execution_time );
80
- ob_end_clean();
81
-
82
- return ( isset( $exchange_rate->query->results->row->rate ) ) ? floatval( $exchange_rate->query->results->row->rate ) : 0;
83
- //return ( isset( $exchange_rate->rate ) ) ? $exchange_rate->rate : 0;
84
- }
85
-
86
- /**
87
- * On the scheduled action hook, run a function.
88
- */
89
- function update_the_exchange_rates( $interval ) {
90
-
91
- for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_price_by_country_total_groups_number', 1 ) ); $i++ ) {
92
- $currency_from = get_option( 'woocommerce_currency' );
93
- $currency_to = get_option( 'wcj_price_by_country_exchange_rate_currency_group_' . $i );
94
- $the_rate = $this->get_exchange_rate( $currency_from, $currency_to );
95
- if ( 0 != $the_rate ) {
96
- if ( $currency_from != $currency_to ) {
97
- update_option( 'wcj_price_by_country_exchange_rate_group_' . $i, $the_rate );
98
- $result_message = __( 'Cron job: exchange rates successfully updated', 'woocommerce-jetpack' );
99
- } else {
100
- $result_message = __( 'Cron job: exchange rates not updated, as currency_from == currency_to', 'woocommerce-jetpack' );
101
- }
102
- } else {
103
- $result_message = __( 'Cron job: exchange rates update failed', 'woocommerce-jetpack' );
104
- }
105
- //wcj_log( $result_message . ': ' . $currency_from . $currency_to . ': ' . $the_rate . ': ' . 'update_the_exchange_rates: ' . $interval );
106
- }
107
- }
108
-
109
- /**
110
- * cron_add_custom_intervals.
111
- */
112
- function cron_add_custom_intervals( $schedules ) {
113
-
114
- $schedules['weekly'] = array(
115
- 'interval' => 604800,
116
- 'display' => __( 'Once Weekly', 'woocommerce-jetpack' )
117
- );
118
-
119
- $schedules['minutely'] = array(
120
- 'interval' => 60,
121
- 'display' => __( 'Once a Minute', 'woocommerce-jetpack' )
122
- );
123
-
124
- return $schedules;
125
- }
126
- }
127
-
128
- endif;
129
-
130
- return new WCJ_Exchange_Rates_Crons();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.2.6
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -24,6 +24,8 @@ class WCJ_Price_by_Country_Core {
24
 
25
  /**
26
  * add_hooks.
 
 
27
  */
28
  function add_hooks() {
29
 
@@ -38,22 +40,26 @@ class WCJ_Price_by_Country_Core {
38
  }
39
  }
40
 
41
- // Price hooks
42
- add_filter( 'woocommerce_get_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX, 2 );
43
- add_filter( 'woocommerce_get_sale_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX, 2 );
44
- add_filter( 'woocommerce_get_regular_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX, 2 );
45
- // add_filter( 'woocommerce_get_variation_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX, 2 );
46
- add_filter( 'woocommerce_get_variation_sale_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX, 2 );
47
- add_filter( 'woocommerce_get_variation_regular_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX, 2 );
48
- // add_filter( 'booking_form_calculated_booking_cost', array( $this, 'change_price_by_country' ), PHP_INT_MAX );
49
- // add_filter( 'woocommerce_get_price_html', array( $this, 'fix_variable_product_price_on_sale' ), 10 , 2 );
 
 
 
50
 
51
- // Currency hooks
52
- add_filter( 'woocommerce_currency_symbol', array( $this, 'change_currency_symbol' ), PHP_INT_MAX, 2 );
53
- add_filter( 'woocommerce_currency', array( $this, 'change_currency_code' ), PHP_INT_MAX, 1 );
54
 
55
- // Shipping
56
- add_filter( 'woocommerce_package_rates', array( $this, 'change_shipping_price_by_country' ), PHP_INT_MAX, 2 );
 
57
 
58
  // Country selection box
59
  /* if ( 'by_user_selection' === get_option( 'wcj_price_by_country_customer_country_detection_method', 'by_ip' ) ) {
@@ -226,7 +232,6 @@ class WCJ_Price_by_Country_Core {
226
  }
227
  }
228
 
229
-
230
  if ( null === $country ) {
231
  $this->customer_country_group_id = -1;
232
  return null;
@@ -273,12 +278,31 @@ class WCJ_Price_by_Country_Core {
273
  return $currency;
274
  }
275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  /**
277
  * change_price_by_country.
 
 
278
  */
279
  public function change_price_by_country( $price, $product ) {
280
 
281
- $the_product_id = ( isset( $product->variation_id ) ) ? $product->variation_id : $product->id;
 
282
 
283
  if ( null != ( $group_id = $this->get_customer_country_group_id() ) ) {
284
 
@@ -294,6 +318,7 @@ class WCJ_Price_by_Country_Core {
294
  return '';
295
  }
296
 
 
297
  if ( 'woocommerce_get_price' == current_filter() ) {
298
 
299
  $regular_or_sale = '_regular_price_';
4
  *
5
  * The WooCommerce Jetpack Price by Country Core class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
24
 
25
  /**
26
  * add_hooks.
27
+ *
28
+ * @version 2.3.0
29
  */
30
  function add_hooks() {
31
 
40
  }
41
  }
42
 
43
+ //if ( ) { //todo
44
+
45
+ // Price hooks
46
+ add_filter( 'woocommerce_variation_prices', array( $this, 'change_price_by_country_variations' ), PHP_INT_MAX, 2 );
47
+ add_filter( 'woocommerce_get_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX, 2 );
48
+ add_filter( 'woocommerce_get_sale_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX, 2 );
49
+ add_filter( 'woocommerce_get_regular_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX, 2 );
50
+ // add_filter( 'woocommerce_get_variation_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX, 2 );
51
+ // add_filter( 'woocommerce_get_variation_sale_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX, 2 );
52
+ // add_filter( 'woocommerce_get_variation_regular_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX, 2 );
53
+ // add_filter( 'booking_form_calculated_booking_cost', array( $this, 'change_price_by_country' ), PHP_INT_MAX );
54
+ // add_filter( 'woocommerce_get_price_html', array( $this, 'fix_variable_product_price_on_sale' ), 10 , 2 );
55
 
56
+ // Currency hooks
57
+ add_filter( 'woocommerce_currency_symbol', array( $this, 'change_currency_symbol' ), PHP_INT_MAX, 2 );
58
+ add_filter( 'woocommerce_currency', array( $this, 'change_currency_code' ), PHP_INT_MAX, 1 );
59
 
60
+ // Shipping
61
+ add_filter( 'woocommerce_package_rates', array( $this, 'change_shipping_price_by_country' ), PHP_INT_MAX, 2 );
62
+ //}
63
 
64
  // Country selection box
65
  /* if ( 'by_user_selection' === get_option( 'wcj_price_by_country_customer_country_detection_method', 'by_ip' ) ) {
232
  }
233
  }
234
 
 
235
  if ( null === $country ) {
236
  $this->customer_country_group_id = -1;
237
  return null;
278
  return $currency;
279
  }
280
 
281
+ /**
282
+ * change_price_by_country_variations.
283
+ *
284
+ * @version 2.3.0
285
+ * @since 2.3.0
286
+ */
287
+ public function change_price_by_country_variations( $prices_array, $product ) {
288
+ $modified_prices_array = $prices_array;
289
+ foreach ( $prices_array as $price_type => $prices ) {
290
+ foreach ( $prices as $variation_id => $price ) {
291
+ $modified_prices_array[ $price_type ][ $variation_id ] = $this->change_price_by_country( $price, $variation_id );
292
+ }
293
+ }
294
+ return $modified_prices_array;
295
+ }
296
+
297
  /**
298
  * change_price_by_country.
299
+ *
300
+ * @version 2.3.0
301
  */
302
  public function change_price_by_country( $price, $product ) {
303
 
304
+ if ( is_numeric( $product ) ) $the_product_id = $product;
305
+ else $the_product_id = ( isset( $product->variation_id ) ) ? $product->variation_id : $product->id;
306
 
307
  if ( null != ( $group_id = $this->get_customer_country_group_id() ) ) {
308
 
318
  return '';
319
  }
320
 
321
+ $price_by_country = '';
322
  if ( 'woocommerce_get_price' == current_filter() ) {
323
 
324
  $regular_or_sale = '_regular_price_';
includes/price-by-country/class-wcj-price-by-country-local.php CHANGED
@@ -72,8 +72,6 @@ class WCJ_Price_by_Country_Local {
72
 
73
  if ( $the_product->is_type( 'variation' ) ) {
74
  $html .= $this->get_all_options_html( $simple_or_variable, $current_post_id, $total_country_groups_number, '_' . $current_post_id );
75
- //wcj_log( $simple_or_variable . '|' . $current_post_id . '|' . $total_country_groups_number . '|' . '_' . $current_post_id );
76
- //wcj_log( $current_post_id );
77
  //$html = '</p>' . $html . '<p>';
78
  }
79
  /*
72
 
73
  if ( $the_product->is_type( 'variation' ) ) {
74
  $html .= $this->get_all_options_html( $simple_or_variable, $current_post_id, $total_country_groups_number, '_' . $current_post_id );
 
 
75
  //$html = '</p>' . $html . '<p>';
76
  }
77
  /*
includes/reports/wcj-class-reports-sales.php ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Jetpack Sales Reports
4
+ *
5
+ * The WooCommerce Jetpack Sales Reports class.
6
+ *
7
+ * @version 2.3.0
8
+ * @author Algoritmika Ltd.
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) exit;
12
+
13
+ if ( ! class_exists( 'WCJ_Reports_Sales' ) ) :
14
+
15
+ class WCJ_Reports_Sales {
16
+
17
+ /**
18
+ * Constructor.
19
+ *
20
+ * @version 2.3.0
21
+ * @since 2.3.0
22
+ */
23
+ public function __construct( $args = null ) {
24
+
25
+ }
26
+
27
+ /**
28
+ * get_report.
29
+ *
30
+ * @version 2.3.0
31
+ * @since 2.3.0
32
+ */
33
+ public function get_report() {
34
+
35
+ $html = '';
36
+
37
+ $this->year = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' );
38
+
39
+ $html .= $this->get_products_sales();
40
+
41
+ return $html;
42
+ }
43
+
44
+ /*
45
+ * sort_by_total_sales.
46
+ *
47
+ * @version 2.3.0
48
+ * @since 2.3.0
49
+ */
50
+ function sort_by_total_sales( $a, $b ) {
51
+ if ( $a['sales'] == $b['sales'] ) {
52
+ return 0;
53
+ }
54
+ return ( $a['sales'] < $b['sales'] ) ? 1 : -1;
55
+ }
56
+
57
+ /*
58
+ * get_products_sales.
59
+ *
60
+ * @version 2.3.0
61
+ * @since 2.3.0
62
+ */
63
+ function get_products_sales() {
64
+
65
+ $products_data = array();
66
+
67
+ $years = array();
68
+
69
+ $total_orders = 0;
70
+
71
+ $offset = 0;
72
+ $block_size = 96;
73
+ while( true ) {
74
+
75
+ $args_orders = array(
76
+ 'post_type' => 'shop_order',
77
+ 'post_status' => 'wc-completed',
78
+ 'posts_per_page' => $block_size,
79
+ 'orderby' => 'date',
80
+ 'order' => 'DESC',
81
+ 'offset' => $offset,
82
+ 'date_query' => array(
83
+ array(
84
+ 'year' => $this->year,
85
+ ),
86
+ ),
87
+ );
88
+ $loop_orders = new WP_Query( $args_orders );
89
+ if ( ! $loop_orders->have_posts() ) break;
90
+ while ( $loop_orders->have_posts() ) : $loop_orders->the_post();
91
+
92
+ $order_id = $loop_orders->post->ID;
93
+ $order = new WC_Order( $order_id );
94
+ $items = $order->get_items();
95
+ foreach ( $items as $item ) {
96
+
97
+ if ( ! isset( $products_data[ $item['product_id'] ][ 'sales' ] ) ) {
98
+ $products_data[ $item['product_id'] ][ 'sales' ] = 0;
99
+ }
100
+ $products_data[ $item['product_id'] ][ 'sales' ] += $item['qty'];
101
+
102
+ $month = date( 'n', get_the_time( 'U' ) );
103
+ $year = date( 'Y', get_the_time( 'U' ) );
104
+ $years[ $year ] = true;
105
+ if ( ! isset( $products_data[ $item['product_id'] ][ 'sales_by_month' ][ $year ][ $month ] ) ) {
106
+ $products_data[ $item['product_id'] ][ 'sales_by_month' ][ $year ][ $month ] = 0;
107
+ }
108
+ $products_data[ $item['product_id'] ][ 'sales_by_month' ][ $year ][ $month ] += $item['qty'];
109
+
110
+ if ( ! isset( $products_data[ $item['product_id'] ][ 'title' ] ) ) {
111
+ $products_data[ $item['product_id'] ][ 'title' ] = get_the_title( $item['product_id'] );
112
+ }
113
+
114
+ if ( ! isset( $products_data[ $item['product_id'] ][ 'last_sale' ] ) ) {
115
+ $products_data[ $item['product_id'] ][ 'last_sale' ] = date( 'Y-m-d H:i:s', get_the_time( 'U' ) );
116
+ }
117
+
118
+ }
119
+
120
+ $total_orders++;
121
+
122
+ endwhile;
123
+
124
+ $offset += $block_size;
125
+
126
+ }
127
+
128
+ usort( $products_data, array( $this, 'sort_by_total_sales' ) );
129
+
130
+ $table_data = array();
131
+ $the_header = array( __( 'Product', 'woocommerce-jetpack' ), );
132
+ foreach ( $years as $year => $value ) {
133
+ if ( $year != $this->year ) continue;
134
+ for ( $i = 12; $i >= 1; $i-- ) {
135
+ $the_header[] = sprintf( '%04d.%02d', $year, $i );
136
+ }
137
+ }
138
+ $table_data[] = $the_header;
139
+ foreach ( $products_data as $product_id => $the_data ) {
140
+ $the_row = array( $the_data['title'] . ' (' . $the_data['sales'] . ')', );
141
+ foreach ( $years as $year => $value ) {
142
+ if ( $year != $this->year ) continue;
143
+ for ( $i = 12; $i >= 1; $i-- ) {
144
+ if ( $i > 1 ) {
145
+ $prev_month_data = $the_data['sales_by_month'][ $year ][ $i - 1 ];
146
+ $color = ( $prev_month_data >= $the_data['sales_by_month'][ $year ][ $i ] ) ? 'red' : 'green';
147
+ } else {
148
+ $color = 'black';
149
+ }
150
+ $the_row[] = '<span style="color:' . $color . ';">' . $the_data['sales_by_month'][ $year ][ $i ] . '</span>';
151
+
152
+ }
153
+ }
154
+ $table_data[] = $the_row;
155
+ }
156
+
157
+ $menu = '';
158
+ $menu .= '<ul class="subsubsub">';
159
+ $menu .= '<li><a href="' . add_query_arg( 'year', date( 'Y' ) ) . '" class="' . ( ( $this->year == date( 'Y' ) ) ? 'current' : '' ) . '">' . date( 'Y' ) . '</a> | </li>';
160
+ $menu .= '<li><a href="' . add_query_arg( 'year', ( date( 'Y' ) - 1 ) ) . '" class="' . ( ( $this->year == ( date( 'Y' ) - 1 ) ) ? 'current' : '' ) . '">' . ( date( 'Y' ) - 1 ) . '</a> | </li>';
161
+ $menu .= '</ul>';
162
+ $menu .= '<br class="clear">';
163
+
164
+ return '<p>' . $menu . '</p>' . wcj_get_table_html( $table_data, array( 'table_class' => 'widefat' ) );
165
+ }
166
+ }
167
+
168
+ endif;
includes/reports/wcj-class-reports-stock.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Stock Reports class.
6
  *
7
- * @version 2.2.6
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -93,13 +93,15 @@ class WCJ_Reports_Stock {
93
 
94
  /*
95
  * gather_products_data.
 
 
96
  */
97
  public function gather_products_data( &$products_info ) {
98
 
99
  //return array();
100
 
101
  $args = array(
102
- 'post_type' => 'product',
103
  'posts_per_page' => -1,
104
  );
105
 
@@ -116,6 +118,7 @@ class WCJ_Reports_Stock {
116
  //if ( 0 == $the_stock )
117
  //$the_stock = get_post_meta( $the_ID, '_stock', true );
118
  $the_title = get_the_title();
 
119
  $the_date = get_the_date();
120
  $the_permalink = get_the_permalink();
121
 
@@ -133,6 +136,7 @@ class WCJ_Reports_Stock {
133
  $products_info[$the_ID] = array(
134
  'ID' => $the_ID,
135
  'title' => $the_title,
 
136
  'permalink' => $the_permalink,
137
  'price' => $the_price,
138
  'stock' => $the_stock,
@@ -153,61 +157,70 @@ class WCJ_Reports_Stock {
153
  /*
154
  * gather_orders_data.
155
  *
156
- * @version 2.2.6
157
  */
158
  function gather_orders_data( &$products_info ) {
159
 
160
- $args_orders = array(
161
- 'post_type' => 'shop_order',
162
- 'post_status' => 'wc-completed',
163
- 'posts_per_page' => -1,
164
- 'orderby' => 'date',
165
- 'order' => 'DESC',
166
- 'date_query' => array(
167
- array(
168
- 'column' => 'post_date_gmt',
169
- 'after' => $this->range_days . ' days ago',
 
 
 
 
 
 
170
  ),
171
- ),
172
- );
173
 
174
- //$one_day_seconds = ( 24 * 60 * 60 );
175
- //$now_time = time();
176
 
177
- $the_period = $this->range_days;
178
 
179
- $loop_orders = new WP_Query( $args_orders );
180
- while ( $loop_orders->have_posts() ) : $loop_orders->the_post();
 
181
 
182
- $order_id = $loop_orders->post->ID;
183
- $order = new WC_Order( $order_id );
184
- $items = $order->get_items();
185
 
186
- //$the_timestamp = get_the_time( 'U' );
187
- //$order_age = ( $now_time - $the_timestamp );
188
 
189
 
190
- foreach ( $items as $item ) {
191
 
192
- //$products_info_sales_in_period = $products_info[$item['product_id']]['sales_in_period'];
193
- //echo '<pre>' . print_r( $products_info_sales_in_period, true ) . '</pre>';
194
 
195
- //if ( ! empty( $products_info_sales_in_period ) ) {
196
 
197
- //foreach ( $products_info_sales_in_period as $the_period => $the_value ) {
198
- //if ( $order_age < ( $the_period * $one_day_seconds ) ) {
199
- $products_info[ $item['product_id'] ]['sales_in_period'][ $the_period ] += $item['qty'];
 
200
  //}
201
  //}
202
- //}
203
 
204
- if ( 0 == $products_info[ $item['product_id'] ]['last_sale'] ) {
205
- $products_info[ $item['product_id'] ]['last_sale'] = get_the_time( 'U' );//$the_timestamp;
 
 
206
  }
207
 
208
- }
209
 
210
- endwhile;
 
211
 
212
  //wp_reset_query();
213
  }
@@ -265,6 +278,8 @@ class WCJ_Reports_Stock {
265
 
266
  /*
267
  * get_report_html.
 
 
268
  */
269
  public function get_report_html() {
270
 
@@ -285,6 +300,7 @@ class WCJ_Reports_Stock {
285
  $html .= '<tr>';
286
  $html .= '<th>#</th>';
287
  $html .= '<th>' . __( 'Product', 'woocommerce-jetpack' ) . '</th>';
 
288
  $html .= '<th>' . __( 'Price', 'woocommerce-jetpack' ) . '</th>';
289
  $html .= '<th>' . __( 'Stock', 'woocommerce-jetpack' ) . '</th>';
290
  $html .= '<th>' . __( 'Stock price', 'woocommerce-jetpack' ) . '</th>';
@@ -310,8 +326,8 @@ class WCJ_Reports_Stock {
310
 
311
  ( ( 'overstocked' === $report_info['id'] ) &&
312
  ( $product_info['stock'] > 0 ) &&
313
- //( $product_info['total_sales'] > 0 ) &&
314
- ( ( time() - strtotime( $product_info['date_added'] ) ) > $this->range_days * 24 * 60 * 60 ) &&
315
  //( $product_info['sales_in_period'][ $this->range_days ] * 12 < $product_info['stock'] ) ) ||
316
  ( 0 === $product_info['sales_in_period'][ $this->range_days ] ) ) ||
317
 
@@ -326,6 +342,7 @@ class WCJ_Reports_Stock {
326
  $html .= '<tr>';
327
  $html .= '<td>' . $product_counter . '</td>';
328
  $html .= '<th>' . '<a href='. $product_info['permalink'] . '>' . $product_info['title'] . '</a>' . '</th>';
 
329
  $purchase_price_html = ( $product_info['purchase_price'] > 0 ) ?
330
  '<br><em>' . __( 'purchase price:', 'woocommerce-jetpack' ) . '</em>' . ' ' . wc_price( $product_info['purchase_price'] ) :
331
  '';
4
  *
5
  * The WooCommerce Jetpack Stock Reports class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
93
 
94
  /*
95
  * gather_products_data.
96
+ *
97
+ * @version 2.3.0
98
  */
99
  public function gather_products_data( &$products_info ) {
100
 
101
  //return array();
102
 
103
  $args = array(
104
+ 'post_type' => 'product',
105
  'posts_per_page' => -1,
106
  );
107
 
118
  //if ( 0 == $the_stock )
119
  //$the_stock = get_post_meta( $the_ID, '_stock', true );
120
  $the_title = get_the_title();
121
+ $the_categories = $the_product->get_categories();
122
  $the_date = get_the_date();
123
  $the_permalink = get_the_permalink();
124
 
136
  $products_info[$the_ID] = array(
137
  'ID' => $the_ID,
138
  'title' => $the_title,
139
+ 'category' => $the_categories,
140
  'permalink' => $the_permalink,
141
  'price' => $the_price,
142
  'stock' => $the_stock,
157
  /*
158
  * gather_orders_data.
159
  *
160
+ * @version 2.3.0
161
  */
162
  function gather_orders_data( &$products_info ) {
163
 
164
+ $offset = 0;
165
+ $block_size = 96;
166
+ while( true ) {
167
+
168
+ $args_orders = array(
169
+ 'post_type' => 'shop_order',
170
+ 'post_status' => 'wc-completed',
171
+ 'posts_per_page' => $block_size,
172
+ 'offset' => $offset,
173
+ 'orderby' => 'date',
174
+ 'order' => 'DESC',
175
+ 'date_query' => array(
176
+ array(
177
+ 'column' => 'post_date_gmt',
178
+ 'after' => $this->range_days . ' days ago',
179
+ ),
180
  ),
181
+ );
 
182
 
183
+ //$one_day_seconds = ( 24 * 60 * 60 );
184
+ //$now_time = time();
185
 
186
+ $the_period = $this->range_days;
187
 
188
+ $loop_orders = new WP_Query( $args_orders );
189
+ if ( ! $loop_orders->have_posts() ) break;
190
+ while ( $loop_orders->have_posts() ) : $loop_orders->the_post();
191
 
192
+ $order_id = $loop_orders->post->ID;
193
+ $order = new WC_Order( $order_id );
194
+ $items = $order->get_items();
195
 
196
+ //$the_timestamp = get_the_time( 'U' );
197
+ //$order_age = ( $now_time - $the_timestamp );
198
 
199
 
200
+ foreach ( $items as $item ) {
201
 
202
+ //$products_info_sales_in_period = $products_info[$item['product_id']]['sales_in_period'];
203
+ //echo '<pre>' . print_r( $products_info_sales_in_period, true ) . '</pre>';
204
 
205
+ //if ( ! empty( $products_info_sales_in_period ) ) {
206
 
207
+ //foreach ( $products_info_sales_in_period as $the_period => $the_value ) {
208
+ //if ( $order_age < ( $the_period * $one_day_seconds ) ) {
209
+ $products_info[ $item['product_id'] ]['sales_in_period'][ $the_period ] += $item['qty'];
210
+ //}
211
  //}
212
  //}
 
213
 
214
+ if ( 0 == $products_info[ $item['product_id'] ]['last_sale'] ) {
215
+ $products_info[ $item['product_id'] ]['last_sale'] = get_the_time( 'U' );//$the_timestamp;
216
+ }
217
+
218
  }
219
 
220
+ endwhile;
221
 
222
+ $offset += $block_size;
223
+ }
224
 
225
  //wp_reset_query();
226
  }
278
 
279
  /*
280
  * get_report_html.
281
+ *
282
+ * @version 2.3.0
283
  */
284
  public function get_report_html() {
285
 
300
  $html .= '<tr>';
301
  $html .= '<th>#</th>';
302
  $html .= '<th>' . __( 'Product', 'woocommerce-jetpack' ) . '</th>';
303
+ $html .= '<th>' . __( 'Category', 'woocommerce-jetpack' ) . '</th>';
304
  $html .= '<th>' . __( 'Price', 'woocommerce-jetpack' ) . '</th>';
305
  $html .= '<th>' . __( 'Stock', 'woocommerce-jetpack' ) . '</th>';
306
  $html .= '<th>' . __( 'Stock price', 'woocommerce-jetpack' ) . '</th>';
326
 
327
  ( ( 'overstocked' === $report_info['id'] ) &&
328
  ( $product_info['stock'] > 0 ) &&
329
+ //( 0 == $product_info['total_sales'] ) &&
330
+ ( ( current_time( 'timestamp' ) - strtotime( $product_info['date_added'] ) ) > $this->range_days * 24 * 60 * 60 ) &&
331
  //( $product_info['sales_in_period'][ $this->range_days ] * 12 < $product_info['stock'] ) ) ||
332
  ( 0 === $product_info['sales_in_period'][ $this->range_days ] ) ) ||
333
 
342
  $html .= '<tr>';
343
  $html .= '<td>' . $product_counter . '</td>';
344
  $html .= '<th>' . '<a href='. $product_info['permalink'] . '>' . $product_info['title'] . '</a>' . '</th>';
345
+ $html .= '<th>' . '<a href='. $product_info['permalink'] . '>' . $product_info['category'] . '</a>' . '</th>';
346
  $purchase_price_html = ( $product_info['purchase_price'] > 0 ) ?
347
  '<br><em>' . __( 'purchase price:', 'woocommerce-jetpack' ) . '</em>' . ' ' . wc_price( $product_info['purchase_price'] ) :
348
  '';
includes/shortcodes/class-wcj-general-shortcodes.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack General Shortcodes class.
6
  *
7
- * @version 2.2.9
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -17,7 +17,7 @@ class WCJ_General_Shortcodes extends WCJ_Shortcodes {
17
  /**
18
  * Constructor.
19
  *
20
- * @version 2.2.9
21
  */
22
  public function __construct() {
23
 
@@ -41,6 +41,7 @@ class WCJ_General_Shortcodes extends WCJ_Shortcodes {
41
  'form_method' => 'get',
42
  'class' => '',
43
  'style' => '',
 
44
  );
45
 
46
  parent::__construct();
@@ -49,6 +50,8 @@ class WCJ_General_Shortcodes extends WCJ_Shortcodes {
49
 
50
  /**
51
  * wcj_country_select_drop_down_list.
 
 
52
  */
53
  function wcj_country_select_drop_down_list( $atts, $content ) {
54
 
@@ -63,6 +66,17 @@ class WCJ_General_Shortcodes extends WCJ_Shortcodes {
63
  $html .= '<select name="wcj-country" id="wcj-country" style="' . $select_style . '" class="' . $select_class . '" onchange="this.form.submit()">';
64
  $countries = wcj_get_countries();
65
 
 
 
 
 
 
 
 
 
 
 
 
66
  /* if ( 'get' == $form_method ) {
67
  $selected_country = ( isset( $_GET[ 'wcj-country' ] ) ) ? $_GET[ 'wcj-country' ] : '';
68
  } else {
@@ -71,8 +85,9 @@ class WCJ_General_Shortcodes extends WCJ_Shortcodes {
71
  $selected_country = ( isset( $_SESSION[ 'wcj-country' ] ) ) ? $_SESSION[ 'wcj-country' ] : '';
72
 
73
  foreach ( $countries as $country_code => $country_name ) {
74
-
75
- $html .= '<option value="' . $country_code . '" ' . selected( $country_code, $selected_country, false ) . '>' . $country_name . '</option>';
 
76
  }
77
  $html .= '</select>';
78
 
4
  *
5
  * The WooCommerce Jetpack General Shortcodes class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
17
  /**
18
  * Constructor.
19
  *
20
+ * @version 2.3.0
21
  */
22
  public function __construct() {
23
 
41
  'form_method' => 'get',
42
  'class' => '',
43
  'style' => '',
44
+ 'countries' => '',
45
  );
46
 
47
  parent::__construct();
50
 
51
  /**
52
  * wcj_country_select_drop_down_list.
53
+ *
54
+ * @version 2.3.0
55
  */
56
  function wcj_country_select_drop_down_list( $atts, $content ) {
57
 
66
  $html .= '<select name="wcj-country" id="wcj-country" style="' . $select_style . '" class="' . $select_class . '" onchange="this.form.submit()">';
67
  $countries = wcj_get_countries();
68
 
69
+ /* $shortcode_countries = get_option( 'wcj_price_by_country_shortcode_countries', array() );
70
+ if ( '' == $shortcode_countries ) $shortcode_countries = array(); */
71
+ $shortcode_countries = $atts['countries'];
72
+ if ( '' == $shortcode_countries ) {
73
+ $shortcode_countries = array();
74
+ } else {
75
+ $shortcode_countries = str_replace( ' ', '', $shortcode_countries );
76
+ $shortcode_countries = trim( $shortcode_countries, ',' );
77
+ $shortcode_countries = explode( ',', $shortcode_countries );
78
+ }
79
+
80
  /* if ( 'get' == $form_method ) {
81
  $selected_country = ( isset( $_GET[ 'wcj-country' ] ) ) ? $_GET[ 'wcj-country' ] : '';
82
  } else {
85
  $selected_country = ( isset( $_SESSION[ 'wcj-country' ] ) ) ? $_SESSION[ 'wcj-country' ] : '';
86
 
87
  foreach ( $countries as $country_code => $country_name ) {
88
+ if ( empty( $shortcode_countries ) || ( in_array( $country_code, $shortcode_countries ) ) ) {
89
+ $html .= '<option value="' . $country_code . '" ' . selected( $country_code, $selected_country, false ) . '>' . $country_name . '</option>';
90
+ }
91
  }
92
  $html .= '</select>';
93
 
includes/shortcodes/class-wcj-orders-shortcodes.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Orders Shortcodes class.
6
  *
7
- * @version 2.2.9
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -17,7 +17,7 @@ class WCJ_Orders_Shortcodes extends WCJ_Shortcodes {
17
  /**
18
  * Constructor.
19
  *
20
- * @version 2.2.9
21
  */
22
  public function __construct() {
23
 
@@ -33,6 +33,7 @@ class WCJ_Orders_Shortcodes extends WCJ_Shortcodes {
33
  'wcj_order_checkout_field',
34
  'wcj_order_shipping_address',
35
  'wcj_order_customer_note',
 
36
  'wcj_order_custom_meta_field',
37
  'wcj_order_meta',
38
 
@@ -229,24 +230,23 @@ class WCJ_Orders_Shortcodes extends WCJ_Shortcodes {
229
  /**
230
  * wcj_order_custom_meta_field.
231
  *
232
- * @version 2.2.9
233
  * @since 2.2.9
 
234
  */
235
  function wcj_order_custom_meta_field( $atts ) {
236
- if ( '' == $atts['field_id'] ) return '';
237
- $field_value = $this->the_order->$atts['field_id'];
238
- return ( isset( $field_value ) ) ? $field_value : '';
239
  }
240
 
241
  /**
242
  * wcj_order_checkout_field.
243
  *
244
- * @version 2.2.6
245
  */
246
  function wcj_order_checkout_field( $atts ) {
247
  if ( '' == $atts['field_id'] ) return '';
248
- $field_array = $this->the_order->$atts['field_id'];
249
- return ( isset( $field_array['value'] ) ) ? $field_array['value'] : '';
250
  }
251
 
252
  /**
4
  *
5
  * The WooCommerce Jetpack Orders Shortcodes class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
17
  /**
18
  * Constructor.
19
  *
20
+ * @version 2.3.0
21
  */
22
  public function __construct() {
23
 
33
  'wcj_order_checkout_field',
34
  'wcj_order_shipping_address',
35
  'wcj_order_customer_note',
36
+ 'wcj_order_custom_field',
37
  'wcj_order_custom_meta_field',
38
  'wcj_order_meta',
39
 
230
  /**
231
  * wcj_order_custom_meta_field.
232
  *
233
+ * @version 2.3.0
234
  * @since 2.2.9
235
+ * @depreciated
236
  */
237
  function wcj_order_custom_meta_field( $atts ) {
238
+ return $this->wcj_order_checkout_field( $atts );
 
 
239
  }
240
 
241
  /**
242
  * wcj_order_checkout_field.
243
  *
244
+ * @version 2.3.0
245
  */
246
  function wcj_order_checkout_field( $atts ) {
247
  if ( '' == $atts['field_id'] ) return '';
248
+ $field_value = $this->the_order->$atts['field_id'];
249
+ return ( isset( $field_value['value'] ) ) ? $field_value['value'] : $field_value;
250
  }
251
 
252
  /**
includes/shortcodes/class-wcj-products-shortcodes.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Products Shortcodes class.
6
  *
7
- * @version 2.2.6
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -162,11 +162,11 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
162
  /**
163
  * wcj_product_crowdfunding_time_remaining.
164
  *
165
- * @version 2.2.6
166
  * @since 2.2.6
167
  */
168
  function wcj_product_crowdfunding_time_remaining( $atts ) {
169
- $seconds_remaining = strtotime( $this->wcj_product_crowdfunding_deadline( $atts ) ) - time();
170
  $days_remaining = floor( $seconds_remaining / ( 24 * 60 * 60 ) );
171
  $hours_remaining = floor( $seconds_remaining / ( 60 * 60 ) );
172
  $minutes_remaining = floor( $seconds_remaining / 60 );
4
  *
5
  * The WooCommerce Jetpack Products Shortcodes class.
6
  *
7
+ * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
162
  /**
163
  * wcj_product_crowdfunding_time_remaining.
164
  *
165
+ * @version 2.3.0
166
  * @since 2.2.6
167
  */
168
  function wcj_product_crowdfunding_time_remaining( $atts ) {
169
+ $seconds_remaining = strtotime( $this->wcj_product_crowdfunding_deadline( $atts ) ) - current_time( 'timestamp' );
170
  $days_remaining = floor( $seconds_remaining / ( 24 * 60 * 60 ) );
171
  $hours_remaining = floor( $seconds_remaining / ( 60 * 60 ) );
172
  $minutes_remaining = floor( $seconds_remaining / 60 );
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://algoritmika.com/donate/
4
  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,
5
  Requires at least: 3.8
6
  Tested up to: 4.3
7
- Stable tag: 2.2.9
8
  License: GNU General Public License v3.0
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -20,6 +20,7 @@ Booster for WooCommerce is a WordPress plugin that supercharges your site with a
20
 
21
  * *Bulk Price Converter* - Multiply all WooCommerce products prices by set value.
22
  * *Currencies* - Add all world currencies to your WooCommerce store; change currency symbol.
 
23
  * *Currency for External Products* - Set different currency for external WooCommerce products.
24
  * *Prices and Currencies by Country* - Change WooCommerce product price and currency automatically by customer's country.
25
  * *Wholesale Price* - Set WooCommerce wholesale pricing depending on product quantity in cart (buy more pay less).
@@ -51,9 +52,13 @@ Booster for WooCommerce is a WordPress plugin that supercharges your site with a
51
  * *Checkout Core Fields* - Customize WooCommerce core checkout fields. Disable/enable fields, set required, change labels and/or placeholders.
52
  * *Checkout Custom Fields* - Add custom fields to WooCommerce checkout page.
53
  * *Checkout Custom Info* - Add custom info to WooCommerce checkout page.
54
- * *Custom Payment Gateways* - Add multiple custom payment gateways to WooCommerce.
55
  * *Empty Cart Button* - Add and customize "Empty Cart" button to cart page.
56
  * *Mini Cart* - Customize WooCommerce mini cart widget.
 
 
 
 
 
57
  * *Payment Gateways Fees* - Enable extra fees for WooCommerce payment gateways.
58
  * *Payment Gateways Icons* - Change icons (images) for all default WooCommerce payment gateways.
59
  * *Payment Gateways per Category* - Show gateway only if there is product of selected category in WooCommerce cart.
@@ -111,6 +116,41 @@ To unlock all Booster for WooCommerce features, please install additional <a hre
111
 
112
  == Changelog ==
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  = 2.2.9 - 01/09/2015 =
115
  * Dev - Shortcodes - Orders - `[wcj_order_meta]` shortcode added (attribute: `meta_key`).
116
  * Dev - Shortcodes - Orders - `[wcj_order_custom_meta_field]` shortcode added. Suggested by https://wordpress.org/support/topic/pdf-invoice-get-order-item-meta-data.
4
  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,
5
  Requires at least: 3.8
6
  Tested up to: 4.3
7
+ Stable tag: 2.3.0
8
  License: GNU General Public License v3.0
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
20
 
21
  * *Bulk Price Converter* - Multiply all WooCommerce products prices by set value.
22
  * *Currencies* - Add all world currencies to your WooCommerce store; change currency symbol.
23
+ * *Currency Exchange Rates* - Automatic currency exchange rates for WooCommerce.
24
  * *Currency for External Products* - Set different currency for external WooCommerce products.
25
  * *Prices and Currencies by Country* - Change WooCommerce product price and currency automatically by customer's country.
26
  * *Wholesale Price* - Set WooCommerce wholesale pricing depending on product quantity in cart (buy more pay less).
52
  * *Checkout Core Fields* - Customize WooCommerce core checkout fields. Disable/enable fields, set required, change labels and/or placeholders.
53
  * *Checkout Custom Fields* - Add custom fields to WooCommerce checkout page.
54
  * *Checkout Custom Info* - Add custom info to WooCommerce checkout page.
 
55
  * *Empty Cart Button* - Add and customize "Empty Cart" button to cart page.
56
  * *Mini Cart* - Customize WooCommerce mini cart widget.
57
+
58
+ **Payment Gateways**
59
+
60
+ * *Custom Payment Gateways* - Add multiple custom payment gateways to WooCommerce.
61
+ * *Payment Gateways Currency* - Currency per WooCommerce payment gateway.
62
  * *Payment Gateways Fees* - Enable extra fees for WooCommerce payment gateways.
63
  * *Payment Gateways Icons* - Change icons (images) for all default WooCommerce payment gateways.
64
  * *Payment Gateways per Category* - Show gateway only if there is product of selected category in WooCommerce cart.
116
 
117
  == Changelog ==
118
 
119
+ = 2.3.0 - 01/10/2015 =
120
+ * Fix - `time` function calls replaced with `current_time` in: crowdfunding module and shortcode, invoicing, stock report.
121
+ * Dev - `WCJ_Module` code refactoring.
122
+ * Dev - Shortcodes - Orders - `[wcj_order_checkout_field]` shortcode modified. `[wcj_order_custom_meta_field]` depreciated (now duplicates `[wcj_order_checkout_field]`).
123
+ * Dev - PAYMENT GATEWAYS category added and modules renamed.
124
+ * Dev - PAYMENT GATEWAYS - Gateways Currency - Initial module release.
125
+ * Dev - PAYMENT GATEWAYS - Gateways Fees and Discounts - "Fee (or discount) type" option unlocked.
126
+ * Dev - PAYMENT GATEWAYS - Custom Gateways - Renaming Jetpack to Booster continued.
127
+ * Fix - PRICES & CURRENCIES - Currency for External Products - Additional product object validation added.
128
+ * Fix - PRICES & CURRENCIES - Prices and Currencies by Country - Variable product price bug fixed.
129
+ * Fix - PRICES & CURRENCIES - Prices and Currencies by Country - Price by Country on per Product Basis - Variable product bug fixed.
130
+ * Dev - PRICES & CURRENCIES - Prices and Currencies by Country - Exchange rates moved to new module.
131
+ * Dev - PRICES & CURRENCIES - Prices and Currencies by Country - `[wcj_country_select_drop_down_list]` shortcode - option to limit country list added.
132
+ * Dev - PRICES & CURRENCIES - Prices and Currencies by Country - Code refactoring.
133
+ * Dev - PRICES & CURRENCIES - Currency Exchange Rates - Initial module release (works with Gateways Currency and Prices and Currencies by Country modules).
134
+ * Dev - PRICES & CURRENCIES - Bulk Price Converter - Code refactoring; tool link added to module settings; tool visualisation html slightly modified.
135
+ * Dev - PRICES & CURRENCIES - Currency for External Products - Code refactoring.
136
+ * Fix - BUTTON & PRICE LABELS - Custom Price Labels - Labels not showing in ajax, fixed.
137
+ * Dev - PRODUCTS - Product Input Fields - List of available field types extended (select, radio, datepicker, timepicker etc.).
138
+ * Fix - CART & CHECKOUT - Checkout Custom Fields - Add new order from back end bug fixed.
139
+ * Dev - CART & CHECKOUT - Checkout Custom Fields - List of available field types extended (select, radio etc.).
140
+ * Dev - CART & CHECKOUT - Checkout Custom Fields - Major code refactoring.
141
+ * Fix - PDF Invoicing - "Cannot redeclare class TCPDF_FONT_DATA" warning fixed.
142
+ * Fix - PDF Invoicing - "TCPDF ERROR: [Image] Unable to get the size of the image" fixed.
143
+ * Dev - PDF Invoicing - Manual invoice creation option added (in invoicing display).
144
+ * Dev - PDF Invoicing - Code refactoring.
145
+ * Dev - PDF Invoicing - "powered by" removed in invoicing header.
146
+ * Dev - PDF Invoicing - Manual invoice create/delete option added.
147
+ * Dev - PDF Invoicing - Numbering - Code refactoring; "Renumerate Invoices" tool link added to submodule settings.
148
+ * Dev - PDF Invoicing - Renaming from Jetpack continued in "Booster - Renumerate Invoices".
149
+ * Dev - PDF Invoicing - TCPDF library loading only on PDF creation.
150
+ * Fix - EMAILS & MISC. - Reports - Stock reports - Code refactoring in `gather_orders_data` function - now no errors on gathering data in shops with large number of orders.
151
+ * Dev - EMAILS & MISC. - Reports - Stock reports - Category column added.
152
+ * Dev - EMAILS & MISC. - Reports - "Booster: Product Sales" report added.
153
+
154
  = 2.2.9 - 01/09/2015 =
155
  * Dev - Shortcodes - Orders - `[wcj_order_meta]` shortcode added (attribute: `meta_key`).
156
  * Dev - Shortcodes - Orders - `[wcj_order_custom_meta_field]` shortcode added. Suggested by https://wordpress.org/support/topic/pdf-invoice-get-order-item-meta-data.
woocommerce-jetpack.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Booster for WooCommerce
4
  Plugin URI: http://BoostWoo.com
5
  Description: Supercharge your WooCommerce site with these awesome powerful features.
6
- Version: 2.2.9
7
  Author: Algoritmika Ltd
8
  Author URI: http://www.algoritmika.com
9
  Copyright: © 2015 Algoritmika Ltd.
@@ -99,6 +99,14 @@ final class WC_Jetpack {
99
  }
100
  }
101
 
 
 
 
 
 
 
 
 
102
  // Loaded action
103
  do_action( 'wcj_loaded' );
104
 
@@ -106,6 +114,40 @@ final class WC_Jetpack {
106
  echo 'Constructor End: memory_get_usage( true )' . number_format( memory_get_usage( true ), 0, '.', ',' ); */
107
  }
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  /**
110
  * name_changed_notice.
111
  *
@@ -201,22 +243,22 @@ final class WC_Jetpack {
201
 
202
  case 'global':
203
  return '<div class="updated">
204
- <p class="main"><strong>' . __( 'Install Booster for WooCommerce Plus to unlock all features', 'woocommerce-jetpack' ) . '</strong></p>
205
  <span>' . sprintf( __('Some settings fields are locked and you will need %s to modify all locked fields.', 'woocommerce-jetpack'), '<a href="http://BoostWoo.com/plus/">Booster for WooCommerce Plus</a>' ) . '</span>
206
  <p><a href="http://BoostWoo.com/plus/" target="_blank" class="button button-primary">' . __( 'Buy now', 'woocommerce-jetpack' ) . '</a> <a href="http://BoostWoo.com" target="_blank" class="button">'. sprintf( __( 'Visit %s', 'woocommerce-jetpack' ), 'BoostWoo.com' ) . '</a></p>
207
  </div>';
208
 
209
  case 'desc':
210
- return __( 'Get <a href="http://BoostWoo.com/plus/" target="_blank">Booster for WooCommerce Plus</a> to change value.', 'woocommerce-jetpack' );
211
 
212
  case 'desc_below':
213
- return __( 'Get <a href="http://BoostWoo.com/plus/" target="_blank">Booster for WooCommerce Plus</a> to change values below.', 'woocommerce-jetpack' );
214
 
215
  case 'desc_above':
216
- return __( 'Get <a href="http://BoostWoo.com/plus/" target="_blank">Booster for WooCommerce Plus</a> to change values above.', 'woocommerce-jetpack' );
217
 
218
  case 'desc_no_link':
219
- return __( 'Get Booster for WooCommerce Plus to change value.', 'woocommerce-jetpack' );
220
 
221
  case 'readonly':
222
  return array( 'readonly' => 'readonly' );
@@ -322,6 +364,7 @@ final class WC_Jetpack {
322
  $settings[] = include_once( 'includes/class-wcj-payment-gateways-icons.php' );
323
  $settings[] = include_once( 'includes/class-wcj-payment-gateways-fees.php' );
324
  $settings[] = include_once( 'includes/class-wcj-payment-gateways-per-category.php' );
 
325
 
326
  $settings[] = include_once( 'includes/class-wcj-shipping.php' );
327
  $settings[] = include_once( 'includes/class-wcj-shipping-calculator.php' );
@@ -350,6 +393,7 @@ final class WC_Jetpack {
350
  $settings[] = include_once( 'includes/class-wcj-currencies.php' );
351
  $settings[] = include_once( 'includes/class-wcj-currency-external-products.php' );
352
  $settings[] = include_once( 'includes/class-wcj-price-by-country.php' );
 
353
 
354
  $settings[] = include_once( 'includes/class-wcj-general.php' );
355
  $settings[] = include_once( 'includes/class-wcj-old-slugs.php' );
@@ -364,7 +408,7 @@ final class WC_Jetpack {
364
  foreach ( $settings as $section ) {
365
 
366
  $values = $section->get_settings();
367
-
368
  // Modules statuses
369
  $submodules_classes = array(
370
  'WCJ_PDF_Invoicing_Display',
3
  Plugin Name: Booster for WooCommerce
4
  Plugin URI: http://BoostWoo.com
5
  Description: Supercharge your WooCommerce site with these awesome powerful features.
6
+ Version: 2.3.0
7
  Author: Algoritmika Ltd
8
  Author URI: http://www.algoritmika.com
9
  Copyright: © 2015 Algoritmika Ltd.
99
  }
100
  }
101
 
102
+ if (
103
+ 'yes' === get_option( 'wcj_product_input_fields_enabled' ) ||
104
+ 'yes' === get_option( 'wcj_checkout_custom_fields_enabled' )
105
+ ){
106
+ add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_scripts' ) );
107
+ add_action( 'init', array( $this, 'register_frontend_scripts' ) );
108
+ }
109
+
110
  // Loaded action
111
  do_action( 'wcj_loaded' );
112
 
114
  echo 'Constructor End: memory_get_usage( true )' . number_format( memory_get_usage( true ), 0, '.', ',' ); */
115
  }
116
 
117
+ /**
118
+ * enqueue_frontend_scripts.
119
+ *
120
+ * @version 2.3.0
121
+ * @since 2.3.0
122
+ */
123
+ function enqueue_frontend_scripts() {
124
+ wp_enqueue_script( 'jquery-ui-datepicker' );
125
+ wp_enqueue_script( 'jquery-ui-timepicker' );
126
+ wp_enqueue_script( 'wcj-datepicker', wcj_plugin_url() . '/includes/js/wcj-datepicker.js',
127
+ array( 'jquery' ),
128
+ false,
129
+ true );
130
+
131
+ wp_enqueue_style( 'jquery-ui-css', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
132
+ wp_enqueue_style( 'wcj-timepicker', wcj_plugin_url() . '/includes/css/jquery.timepicker.min.css' );
133
+ }
134
+
135
+ /**
136
+ * register_frontend_scripts.
137
+ *
138
+ * @version 2.3.0
139
+ * @since 2.3.0
140
+ */
141
+ public function register_frontend_scripts() {
142
+ wp_register_script(
143
+ 'jquery-ui-timepicker',
144
+ wcj_plugin_url() . '/includes/js/jquery.timepicker.min.js',
145
+ array( 'jquery' ),
146
+ false,
147
+ true
148
+ );
149
+ }
150
+
151
  /**
152
  * name_changed_notice.
153
  *
243
 
244
  case 'global':
245
  return '<div class="updated">
246
+ <p class="main"><strong>' . __( 'Install Booster Plus to unlock all features', 'woocommerce-jetpack' ) . '</strong></p>
247
  <span>' . sprintf( __('Some settings fields are locked and you will need %s to modify all locked fields.', 'woocommerce-jetpack'), '<a href="http://BoostWoo.com/plus/">Booster for WooCommerce Plus</a>' ) . '</span>
248
  <p><a href="http://BoostWoo.com/plus/" target="_blank" class="button button-primary">' . __( 'Buy now', 'woocommerce-jetpack' ) . '</a> <a href="http://BoostWoo.com" target="_blank" class="button">'. sprintf( __( 'Visit %s', 'woocommerce-jetpack' ), 'BoostWoo.com' ) . '</a></p>
249
  </div>';
250
 
251
  case 'desc':
252
+ return __( 'Get <a href="http://BoostWoo.com/plus/" target="_blank">Booster Plus</a> to change value.', 'woocommerce-jetpack' );
253
 
254
  case 'desc_below':
255
+ return __( 'Get <a href="http://BoostWoo.com/plus/" target="_blank">Booster Plus</a> to change values below.', 'woocommerce-jetpack' );
256
 
257
  case 'desc_above':
258
+ return __( 'Get <a href="http://BoostWoo.com/plus/" target="_blank">Booster Plus</a> to change values above.', 'woocommerce-jetpack' );
259
 
260
  case 'desc_no_link':
261
+ return __( 'Get Booster Plus to change value.', 'woocommerce-jetpack' );
262
 
263
  case 'readonly':
264
  return array( 'readonly' => 'readonly' );
364
  $settings[] = include_once( 'includes/class-wcj-payment-gateways-icons.php' );
365
  $settings[] = include_once( 'includes/class-wcj-payment-gateways-fees.php' );
366
  $settings[] = include_once( 'includes/class-wcj-payment-gateways-per-category.php' );
367
+ $settings[] = include_once( 'includes/class-wcj-payment-gateways-currency.php' );
368
 
369
  $settings[] = include_once( 'includes/class-wcj-shipping.php' );
370
  $settings[] = include_once( 'includes/class-wcj-shipping-calculator.php' );
393
  $settings[] = include_once( 'includes/class-wcj-currencies.php' );
394
  $settings[] = include_once( 'includes/class-wcj-currency-external-products.php' );
395
  $settings[] = include_once( 'includes/class-wcj-price-by-country.php' );
396
+ $settings[] = include_once( 'includes/class-wcj-currency-exchange-rates.php' );
397
 
398
  $settings[] = include_once( 'includes/class-wcj-general.php' );
399
  $settings[] = include_once( 'includes/class-wcj-old-slugs.php' );
408
  foreach ( $settings as $section ) {
409
 
410
  $values = $section->get_settings();
411
+
412
  // Modules statuses
413
  $submodules_classes = array(
414
  'WCJ_PDF_Invoicing_Display',