Booster for WooCommerce - Version 2.4.0

Version Description

  • 10/02/2016 =
  • Fix - Custom attribute handling in output_custom_number() fixed.
  • Dev - "Reset Module to Default Settings" option added.
  • Dev - Functions - General - wcj_is_module_enabled() function added.
  • Dev - Shortcodes - General - [wcj_country_select_drop_down_list] - manual sorting when countries attribute is used.
  • Fix - Shortcodes - Orders - [wcj_order_total_tax_percent] fixed. precision attribute added.
  • Fix - Shortcodes - Orders - get_cart_discount() (depreciated since WooCommerce 2.3) removed from [wcj_order_items_table] shortcode (affected if discount_as_item option was used); removed from [wcj_order_total_discount] shortcode; [wcj_order_cart_discount] shortcode removed.
  • Fix - Shortcodes - Orders - [wcj_order_total_in_words] - decimal part rounding bug fixed.
  • Dev - Shortcodes - Orders - [wcj_order_total_in_words] - whole and decimal attributes added.
  • Dev - Shortcodes - Orders - [wcj_order_items_table] - item_short_description option added.
  • Dev - Shortcodes - Products - hide_if_zero attribute added to Products Shortcodes.
  • Fix - Shortcodes - Products - [wcj_product_you_save] - checking if product is on sale.
  • Dev - Shortcodes - Products - [wcj_product_you_save] - hide_currency attribute added.
  • Fix - Shortcodes - Products - [wcj_product_you_save_percent] - checking if product is on sale.
  • Dev - Shortcodes - Products - [wcj_product_you_save_percent] - reverse attribute added.
  • Dev - Shortcodes - Products - New shortcodes added: [wcj_product_shipping_class] (returns shipping class name, not slug), [wcj_product_dimensions], [wcj_product_formatted_name], [wcj_product_stock_availability], [wcj_product_tax_class], [wcj_product_average_rating], [wcj_product_categories], [wcj_product_list_attributes], [wcj_product_list_attribute], [wcj_product_stock_quantity], [wcj_product_sale_price], [wcj_product_regular_price], [wcj_product_time_since_last_sale], [wcj_product_price_including_tax], [wcj_product_price_excluding_tax], [wcj_product_available_variations];
  • Fix - PRICES & CURRENCIES - Price by Country - Payment Gateway Currency module now changes prices after Price by Country module.
  • Fix - PRICES & CURRENCIES - Price by Country - Variable products fix (error appeared with WooCommerce v2.5.0 update).
  • Dev - PRICES & CURRENCIES - Currencies - Custom Currencies options added.
  • Dev - PRICES & CURRENCIES - Currencies - Code refactoring.
  • Dev - PRICES & CURRENCIES - Bulk Price Converter - Code refactoring.
  • Dev - PRICES & CURRENCIES - Bulk Price Converter - Option to convert prices by product category added.
  • Dev - PRODUCTS - Product Info - Code refactoring.
  • Dev - PRODUCTS - Product Info V2 - Initial module release. Product Info marked as depreciated.
  • Dev - PRODUCTS - Product Input Fields - Code refactoring.
  • Dev - PRODUCTS - Product Input Fields - Required field sign option added.
  • Dev - PRODUCTS - Product Input Fields - "time format", "interval" options for Timepicker added.
  • Dev - PRODUCTS - Product Input Fields - "First week day" option for Datepicker/Weekpicker added.
  • Dev - PRODUCTS - Product Input Fields - "Weekpicker" added.
  • Fix - PRODUCTS - Product Input Fields - add_product_input_fields_to_order_item_name() fixed. "Item Name Order Table Format" option added.
  • Dev - PRODUCTS - Product Input Fields - Datepicker - "date format", "min date" and "max date" options added.
  • Dev - PRODUCTS - SKU - "Category Suffix" and "Category Prefix" options added.
  • Dev - PRODUCTS - SKU - Code refactoring (minor). Suffix option unlocked.
  • Dev - CART & CHECKOUT - Checkout Core Fields - "time format", "interval" options for Timepicker added.
  • Dev - CART & CHECKOUT - Checkout Core Fields - "First week day" option for Datepicker/Weekpicker added.
  • Fix - CART & CHECKOUT - Checkout Core Fields - "Class" bug fixed.
  • Dev - CART & CHECKOUT - Checkout Custom Fields - "Weekpicker" added.
  • Dev - CART & CHECKOUT - Checkout Custom Fields - Code refactoring (minor).
  • Dev - CART & CHECKOUT - Checkout Custom Fields - Datepicker - "date format", "min date" and "max date" options added.
  • Dev - PAYMENT GATEWAYS - Gateways Currency - "No changes" option added.
  • Dev - PAYMENT GATEWAYS - Custom Gateways - "Custom Return URL (Thank You Page)" option added.
  • Dev - PDF Invoicing - Code refactoring. Classes: WCJ_PDF_Invoicing_Page, WCJ_PDF_Invoicing_Styling etc.
  • Dev - PDF Invoicing - "Hide Settings for Disabled Document Types" option added.
  • Dev - EMAILS & MISC. - General - "Products Revisions" options section added.
  • Dev - EMAILS & MISC. - General - Advanced Options (for handling datepicker and timepicker CSS and JS) added.
  • Dev - EMAILS & MISC. - General - "Disable Booster's Shortcodes" option added.
  • Dev - EMAILS & MISC. - EU VAT Number - wcj_get_european_union_countries_with_vat() Romania VAT rate changed from 24% to 20%.
  • Dev - EMAILS & MISC. - EU VAT Number - "Description" option added.
  • Dev - EMAILS & MISC. - Emails - "Custom Emails" - Triggers added (includes custom order statuses).
  • Dev - EMAILS & MISC. - Emails - "Custom Emails" - %customer% as recipient added.
  • Dev - EMAILS & MISC. - PDF Invoices v1 - removed.
Download this release

Release Info

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

Code changes from version 2.3.11 to 2.4.0

Files changed (42) hide show
  1. includes/admin/class-wc-settings-jetpack.php +26 -3
  2. includes/admin/class-wcj-tools.php +1 -1
  3. includes/admin/wcj-modules-cats.php +4 -2
  4. includes/class-wcj-checkout-core-fields.php +3 -3
  5. includes/class-wcj-checkout-custom-fields.php +81 -36
  6. includes/class-wcj-currencies.php +115 -80
  7. includes/class-wcj-eu-vat-number.php +34 -8
  8. includes/class-wcj-general.php +135 -42
  9. includes/class-wcj-mini-cart.php +6 -7
  10. includes/class-wcj-payment-gateways-currency.php +27 -7
  11. includes/class-wcj-pdf-invoices.php +0 -1448
  12. includes/class-wcj-pdf-invoicing.php +27 -73
  13. includes/class-wcj-product-bulk-price-converter.php +115 -57
  14. includes/class-wcj-product-custom-info.php +203 -0
  15. includes/class-wcj-product-info.php +200 -607
  16. includes/class-wcj-product-input-fields.php +92 -76
  17. includes/class-wcj-shortcodes.php +0 -89
  18. includes/class-wcj-sku.php +120 -34
  19. includes/classes/class-wcj-module.php +68 -7
  20. includes/emails/class-wc-email-wcj-custom.php +58 -25
  21. includes/functions/wcj-country-functions.php +4 -3
  22. includes/functions/wcj-functions.php +81 -2
  23. includes/gateways/class-wc-gateway-wcj-custom.php +99 -79
  24. includes/input-fields/class-wcj-product-input-fields-abstract.php +120 -19
  25. includes/js/wcj-datepicker.js +7 -2
  26. includes/js/wcj-timepicker.js +6 -1
  27. includes/js/wcj-weekpicker.js +38 -0
  28. includes/pdf-invoices/settings/class-wcj-pdf-invoicing-display.php +4 -3
  29. includes/pdf-invoices/settings/class-wcj-pdf-invoicing-emails.php +22 -28
  30. includes/pdf-invoices/settings/class-wcj-pdf-invoicing-footer.php +18 -21
  31. includes/pdf-invoices/settings/class-wcj-pdf-invoicing-header.php +14 -20
  32. includes/pdf-invoices/settings/class-wcj-pdf-invoicing-numbering.php +12 -6
  33. includes/pdf-invoices/settings/class-wcj-pdf-invoicing-page.php +54 -62
  34. includes/pdf-invoices/settings/class-wcj-pdf-invoicing-styling.php +12 -16
  35. includes/pdf-invoices/settings/class-wcj-pdf-invoicing-templates.php +15 -5
  36. includes/price-by-country/class-wcj-price-by-country-core.php +26 -9
  37. includes/shortcodes/class-wcj-general-shortcodes.php +11 -4
  38. includes/shortcodes/class-wcj-order-items-shortcodes.php +60 -44
  39. includes/shortcodes/class-wcj-orders-shortcodes.php +36 -23
  40. includes/shortcodes/class-wcj-products-shortcodes.php +295 -37
  41. readme.txt +53 -1
  42. woocommerce-jetpack.php +98 -52
includes/admin/class-wc-settings-jetpack.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Settings class.
6
  *
7
- * @version 2.3.9
8
  * @since 1.0.0
9
  * @author Algoritmika Ltd.
10
  */
@@ -126,16 +126,26 @@ class WC_Settings_Jetpack extends WC_Settings_Page {
126
 
127
  /**
128
  * output_custom_number.
 
 
129
  */
130
  function output_custom_number( $value ) {
131
  $type = 'number';//$value['type'];
132
  $option_value = get_option( $value['id'], $value['default'] );
133
 
134
  $tooltip_html = '';
135
- $custom_attributes = ( is_array( $value['custom_attributes'] ) ) ? $value['custom_attributes'] : array();
136
  $description = ' <span class="description">' . $value['desc'] . '</span>';
137
  $save_button = apply_filters( 'wcj_get_option_filter', '', ' <input name="save" class="button-primary" type="submit" value="' . __( 'Save changes', 'woocommerce' ) . '">' );
138
 
 
 
 
 
 
 
 
 
139
  ?><tr valign="top">
140
  <th scope="row" class="titledesc">
141
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
@@ -243,7 +253,7 @@ class WC_Settings_Jetpack extends WC_Settings_Page {
243
  /**
244
  * Output the settings.
245
  *
246
- * @version 2.3.9
247
  */
248
  function output() {
249
 
@@ -256,6 +266,19 @@ class WC_Settings_Jetpack extends WC_Settings_Page {
256
  $is_dashboard = ( '' != $current_section && 'alphabetically' != $current_section && 'by_category' != $current_section && 'active' != $current_section )
257
  ? false : true;
258
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  if ( 'yes' === get_option( 'wcj_admin_tools_enabled' ) && 'yes' === get_option( 'wcj_debuging_enabled', 'no' ) ) {
260
  // Breadcrumbs
261
  $breadcrumbs_html = '';
4
  *
5
  * The WooCommerce Jetpack Settings class.
6
  *
7
+ * @version 2.4.0
8
  * @since 1.0.0
9
  * @author Algoritmika Ltd.
10
  */
126
 
127
  /**
128
  * output_custom_number.
129
+ *
130
+ * @version 2.4.0
131
  */
132
  function output_custom_number( $value ) {
133
  $type = 'number';//$value['type'];
134
  $option_value = get_option( $value['id'], $value['default'] );
135
 
136
  $tooltip_html = '';
137
+ // $custom_attributes = ( is_array( $value['custom_attributes'] ) ) ? $value['custom_attributes'] : array();
138
  $description = ' <span class="description">' . $value['desc'] . '</span>';
139
  $save_button = apply_filters( 'wcj_get_option_filter', '', ' <input name="save" class="button-primary" type="submit" value="' . __( 'Save changes', 'woocommerce' ) . '">' );
140
 
141
+ // Custom attribute handling
142
+ $custom_attributes = array();
143
+ if ( ! empty( $value['custom_attributes'] ) && is_array( $value['custom_attributes'] ) ) {
144
+ foreach ( $value['custom_attributes'] as $attribute => $attribute_value ) {
145
+ $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
146
+ }
147
+ }
148
+
149
  ?><tr valign="top">
150
  <th scope="row" class="titledesc">
151
  <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
253
  /**
254
  * Output the settings.
255
  *
256
+ * @version 2.4.0
257
  */
258
  function output() {
259
 
266
  $is_dashboard = ( '' != $current_section && 'alphabetically' != $current_section && 'by_category' != $current_section && 'active' != $current_section )
267
  ? false : true;
268
 
269
+ $depreciated_modules = array(
270
+ 'product_info' => 'Product Info V2',
271
+ );
272
+ if ( array_key_exists( $current_section, $depreciated_modules ) ) {
273
+ echo '<div id="wcj_message" class="error">';
274
+ echo '<p>';
275
+ echo '<strong>';
276
+ echo sprintf( __( 'Please note that current module is depreciated and will be removed in future updates. Please use <em>%s</em> module instead.', 'woocommerce-jetpack' ), $depreciated_modules[ $current_section ] );
277
+ echo '</strong>';
278
+ echo '</p>';
279
+ echo '</div>';
280
+ }
281
+
282
  if ( 'yes' === get_option( 'wcj_admin_tools_enabled' ) && 'yes' === get_option( 'wcj_debuging_enabled', 'no' ) ) {
283
  // Breadcrumbs
284
  $breadcrumbs_html = '';
includes/admin/class-wcj-tools.php CHANGED
@@ -19,7 +19,7 @@ class WCJ_Tools {
19
  */
20
  function __construct() {
21
  if ( is_admin() ) {
22
- add_action( 'admin_menu', array($this, 'add_wcj_tools'), 100 );
23
  }
24
  }
25
 
19
  */
20
  function __construct() {
21
  if ( is_admin() ) {
22
+ add_action( 'admin_menu', array( $this, 'add_wcj_tools' ), 100 );
23
  }
24
  }
25
 
includes/admin/wcj-modules-cats.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Modules Array.
6
  *
7
- * @version 2.3.10
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
@@ -51,6 +51,7 @@ return array(
51
  'all_cat_ids' => array(
52
  'product_listings',
53
  'product_tabs',
 
54
  'product_info',
55
  'related_products',
56
  'sorting',
@@ -122,13 +123,14 @@ return array(
122
  'default_cat_id' => 'general',
123
  'all_cat_ids' => array(
124
  'general',
 
125
  'eu_vat_number',
126
  'old_slugs',
127
  'reports',
128
  'admin_tools',
129
  'emails',
130
  'wpml',
131
- 'pdf_invoices',
132
  ),
133
  ),
134
 
4
  *
5
  * The WooCommerce Modules Array.
6
  *
7
+ * @version 2.4.0
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
51
  'all_cat_ids' => array(
52
  'product_listings',
53
  'product_tabs',
54
+ 'product_custom_info',
55
  'product_info',
56
  'related_products',
57
  'sorting',
123
  'default_cat_id' => 'general',
124
  'all_cat_ids' => array(
125
  'general',
126
+ // 'shortcodes',
127
  'eu_vat_number',
128
  'old_slugs',
129
  'reports',
130
  'admin_tools',
131
  'emails',
132
  'wpml',
133
+ // 'pdf_invoices',
134
  ),
135
  ),
136
 
includes/class-wcj-checkout-core-fields.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Checkout Core Fields class.
6
  *
7
- * @version 2.3.8
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -155,7 +155,7 @@ class WCJ_Checkout_Core_Fields extends WCJ_Module {
155
  /**
156
  * custom_override_checkout_fields.
157
  *
158
- * @version 2.3.8
159
  */
160
  function custom_override_checkout_fields( $checkout_fields ) {
161
 
@@ -192,7 +192,7 @@ class WCJ_Checkout_Core_Fields extends WCJ_Module {
192
 
193
  $class = get_option( 'wcj_checkout_fields_' . $field . '_' . 'class', 'default' );
194
  if ( 'default' != $class ) {
195
- $checkout_fields[ $section ][ $field ]['class'] = $class;
196
  }
197
  }
198
  }
4
  *
5
  * The WooCommerce Jetpack Checkout Core Fields class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
155
  /**
156
  * custom_override_checkout_fields.
157
  *
158
+ * @version 2.4.0
159
  */
160
  function custom_override_checkout_fields( $checkout_fields ) {
161
 
192
 
193
  $class = get_option( 'wcj_checkout_fields_' . $field . '_' . 'class', 'default' );
194
  if ( 'default' != $class ) {
195
+ $checkout_fields[ $section ][ $field ]['class'] = array( $class );
196
  }
197
  }
198
  }
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.3.8
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -286,13 +286,13 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
286
  /**
287
  * add_woocommerce_admin_fields.
288
  *
289
- * @version 2.3.8
290
  */
291
  public function add_woocommerce_admin_fields( $fields, $section ) {
292
  for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_checkout_custom_fields_total_number', 1 ) ); $i++ ) {
293
  if ( 'yes' === get_option( 'wcj_checkout_custom_field_enabled_' . $i ) ) {
294
  $the_type = get_option( 'wcj_checkout_custom_field_type_' . $i );
295
- if ( 'datepicker' === $the_type || 'timepicker' === $the_type || 'number' === $the_type ) {
296
  $the_type = 'text';
297
  }
298
  if ( 'checkbox' === $the_type || 'select' === $the_type || 'radio' === $the_type ) {
@@ -347,7 +347,7 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
347
  /**
348
  * add_custom_checkout_fields.
349
  *
350
- * @version 2.3.8
351
  */
352
  public function add_custom_checkout_fields( $fields ) {
353
 
@@ -375,9 +375,20 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
375
 
376
  $the_type = get_option( 'wcj_checkout_custom_field_type_' . $i );
377
  $custom_attributes = array();
378
- if ( 'datepicker' === $the_type || 'timepicker' === $the_type || 'number' === $the_type ) {
379
- if ( 'datepicker' === $the_type || 'timepicker' === $the_type ) {
380
- $custom_attributes['display'] = ( 'datepicker' === $the_type ) ? 'date' : 'time';
 
 
 
 
 
 
 
 
 
 
 
381
  } else/* if ( 'number' === $the_type ) */ {
382
  $custom_attributes['display'] = $the_type;
383
  }
@@ -425,7 +436,7 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
425
  /**
426
  * get_settings.
427
  *
428
- * @version 2.3.8
429
  */
430
  public function get_settings() {
431
 
@@ -469,14 +480,13 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
469
  'default' => 1,
470
  'type' => 'custom_number',
471
  'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
472
- 'custom_attributes'
473
- => array_merge(
474
- is_array( apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) ) ? apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) : array(),
475
- array(
476
- 'step' => '1',
477
- 'min' => '1',
478
- )
479
- ),
480
  'css' => 'width:100px;',
481
  ),
482
  );
@@ -513,6 +523,7 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
513
  'checkbox' => __( 'Checkbox', 'woocommerce-jetpack' ),
514
  // 'file' => __( 'File', 'woocommerce-jetpack' ),
515
  'datepicker' => __( 'Datepicker', 'woocommerce-jetpack' ),
 
516
  'timepicker' => __( 'Timepicker', 'woocommerce-jetpack' ),
517
  'select' => __( 'Select', 'woocommerce-jetpack' ),
518
  'radio' => __( 'Radio', 'woocommerce-jetpack' ),
@@ -560,6 +571,59 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
560
  ),
561
  'css' => 'min-width:300px;width:50%;',
562
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
563
  array(
564
  'title' => '',
565
  'desc' => __( 'required', 'woocommerce-jetpack' ),
@@ -576,20 +640,6 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
576
  'type' => 'textarea',
577
  'css' => 'min-width:300px;width:50%;',
578
  ),
579
- /*array(
580
- 'title' => '',
581
- 'desc' => __( 'for datepicker: min days', 'woocommerce-jetpack' ),
582
- 'id' => 'wcj_checkout_custom_field_datepicker_mindays_' . $i,
583
- 'default' => 0,
584
- 'type' => 'number',
585
- ),
586
- array(
587
- 'title' => '',
588
- 'desc' => __( 'for datepicker: max days', 'woocommerce-jetpack' ),
589
- 'id' => 'wcj_checkout_custom_field_datepicker_maxdays_' . $i,
590
- 'default' => 0,
591
- 'type' => 'number',
592
- ),*/
593
  array(
594
  'title' => '',
595
  'desc' => __( 'placeholder', 'woocommerce-jetpack' ),
@@ -598,7 +648,6 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
598
  'type' => 'textarea',
599
  'css' => 'min-width:300px;width:50%;',
600
  ),
601
-
602
  array(
603
  'title' => '',
604
  'desc' => __( 'section', 'woocommerce-jetpack' ),
@@ -613,7 +662,6 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
613
  ),
614
  'css' => 'min-width:300px;width:50%;',
615
  ),
616
-
617
  array(
618
  'title' => '',
619
  'desc' => __( 'class', 'woocommerce-jetpack' ),
@@ -627,7 +675,6 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
627
  ),
628
  'css' => 'min-width:300px;width:50%;',
629
  ),
630
-
631
  array(
632
  'title' => '',
633
  'desc' => __( 'clear', 'woocommerce-jetpack' ),
@@ -636,7 +683,6 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
636
  'type' => 'checkbox',
637
  'css' => 'min-width:300px;width:50%;',
638
  ),
639
-
640
  array(
641
  'title' => '',
642
  'desc' => __( 'categories', 'woocommerce-jetpack' ),
@@ -648,14 +694,13 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
648
  'css' => 'min-width:300px;width:50%;',
649
  'options' => $product_cats,
650
  ),
651
-
652
  )
653
  );
654
  }
655
 
656
  $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_checkout_custom_fields_individual_options' );
657
 
658
- return $this->add_enable_module_setting( $settings );
659
  }
660
 
661
  }
4
  *
5
  * The WooCommerce Jetpack Checkout Custom Fields class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
286
  /**
287
  * add_woocommerce_admin_fields.
288
  *
289
+ * @version 2.4.0
290
  */
291
  public function add_woocommerce_admin_fields( $fields, $section ) {
292
  for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_checkout_custom_fields_total_number', 1 ) ); $i++ ) {
293
  if ( 'yes' === get_option( 'wcj_checkout_custom_field_enabled_' . $i ) ) {
294
  $the_type = get_option( 'wcj_checkout_custom_field_type_' . $i );
295
+ if ( 'datepicker' === $the_type || 'weekpicker' === $the_type || 'timepicker' === $the_type || 'number' === $the_type ) {
296
  $the_type = 'text';
297
  }
298
  if ( 'checkbox' === $the_type || 'select' === $the_type || 'radio' === $the_type ) {
347
  /**
348
  * add_custom_checkout_fields.
349
  *
350
+ * @version 2.4.0
351
  */
352
  public function add_custom_checkout_fields( $fields ) {
353
 
375
 
376
  $the_type = get_option( 'wcj_checkout_custom_field_type_' . $i );
377
  $custom_attributes = array();
378
+ if ( 'datepicker' === $the_type || 'weekpicker' === $the_type || 'timepicker' === $the_type || 'number' === $the_type ) {
379
+ if ( 'datepicker' === $the_type || 'weekpicker' === $the_type ) {
380
+ $datepicker_format_option = get_option( 'wcj_checkout_custom_field_datepicker_format_' . $i, '' );
381
+ $datepicker_format = ( '' == $datepicker_format_option ) ? get_option( 'date_format' ) : $datepicker_format_option;
382
+ $datepicker_format = wcj_date_format_php_to_js_v2( $datepicker_format );
383
+ $custom_attributes['dateformat'] = $datepicker_format;
384
+ $custom_attributes['mindate'] = get_option( 'wcj_checkout_custom_field_datepicker_mindate_' . $i, -365 );
385
+ $custom_attributes['maxdate'] = get_option( 'wcj_checkout_custom_field_datepicker_maxdate_' . $i, 365 );
386
+ $custom_attributes['firstday'] = get_option( 'wcj_checkout_custom_field_datepicker_firstday_' . $i, 0 );
387
+ $custom_attributes['display'] = ( 'datepicker' === $the_type ) ? 'date' : 'week';
388
+ } elseif ( 'timepicker' === $the_type ) {
389
+ $custom_attributes['timeformat'] = get_option( 'wcj_checkout_custom_field_timepicker_format_' . $i, 'hh:mm p' );
390
+ $custom_attributes['interval'] = get_option( 'wcj_checkout_custom_field_timepicker_interval_' . $i, 15 );
391
+ $custom_attributes['display'] = 'time';
392
  } else/* if ( 'number' === $the_type ) */ {
393
  $custom_attributes['display'] = $the_type;
394
  }
436
  /**
437
  * get_settings.
438
  *
439
+ * @version 2.4.0
440
  */
441
  public function get_settings() {
442
 
480
  'default' => 1,
481
  'type' => 'custom_number',
482
  'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
483
+ 'custom_attributes' => array_merge(
484
+ is_array( apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) ) ? apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) : array(),
485
+ array(
486
+ 'step' => '1',
487
+ 'min' => '1',
488
+ )
489
+ ),
 
490
  'css' => 'width:100px;',
491
  ),
492
  );
523
  'checkbox' => __( 'Checkbox', 'woocommerce-jetpack' ),
524
  // 'file' => __( 'File', 'woocommerce-jetpack' ),
525
  'datepicker' => __( 'Datepicker', 'woocommerce-jetpack' ),
526
+ 'weekpicker' => __( 'Weekpicker', 'woocommerce-jetpack' ),
527
  'timepicker' => __( 'Timepicker', 'woocommerce-jetpack' ),
528
  'select' => __( 'Select', 'woocommerce-jetpack' ),
529
  'radio' => __( 'Radio', 'woocommerce-jetpack' ),
571
  ),
572
  'css' => 'min-width:300px;width:50%;',
573
  ),
574
+ array(
575
+ 'title' => '',
576
+ 'desc' => __( 'If datepicker/weekpicker is selected, set date format here. Visit <a href="https://codex.wordpress.org/Formatting_Date_and_Time" target="_blank">documentation on date and time formatting</a> for valid date formats.', 'woocommerce-jetpack' ),
577
+ 'desc_tip' => __( 'Leave blank to use your current WordPress format', 'woocommerce-jetpack' ) . ': ' . get_option( 'date_format' ),
578
+ 'id' => 'wcj_checkout_custom_field_datepicker_format_' . $i,
579
+ 'type' => 'text',
580
+ 'default' => '',
581
+ ),
582
+ array(
583
+ 'title' => '',
584
+ 'desc' => __( 'If datepicker/weekpicker is selected, set min date (in days) here', 'woocommerce-jetpack' ),
585
+ 'id' => 'wcj_checkout_custom_field_datepicker_mindate_' . $i,
586
+ 'type' => 'number',
587
+ 'default' => -365,
588
+ ),
589
+ array(
590
+ 'title' => '',
591
+ 'desc' => __( 'If datepicker/weekpicker is selected, set max date (in days) here', 'woocommerce-jetpack' ),
592
+ 'id' => 'wcj_checkout_custom_field_datepicker_maxdate_' . $i,
593
+ 'type' => 'number',
594
+ 'default' => 365,
595
+ ),
596
+ array(
597
+ 'title' => '',
598
+ 'desc' => __( 'If datepicker/weekpicker is selected, set first week day here', 'woocommerce-jetpack' ),
599
+ 'id' => 'wcj_checkout_custom_field_datepicker_firstday_' . $i,
600
+ 'type' => 'select',
601
+ 'default' => 0,
602
+ 'options' => array(
603
+ __( 'Sunday', 'woocommerce-jetpack' ),
604
+ __( 'Monday', 'woocommerce-jetpack' ),
605
+ __( 'Tuesday', 'woocommerce-jetpack' ),
606
+ __( 'Wednesday', 'woocommerce-jetpack' ),
607
+ __( 'Thursday', 'woocommerce-jetpack' ),
608
+ __( 'Friday', 'woocommerce-jetpack' ),
609
+ __( 'Saturday', 'woocommerce-jetpack' ),
610
+ ),
611
+ ),
612
+ array(
613
+ 'title' => '',
614
+ 'desc' => __( 'If timepicker is selected, set time format here. Visit <a href="http://timepicker.co/options/" target="_blank">timepicker options page</a> for valid time formats.', 'woocommerce-jetpack' ),
615
+ 'id' => 'wcj_checkout_custom_field_timepicker_format_' . $i,
616
+ 'type' => 'text',
617
+ 'default' => 'hh:mm p',
618
+ ),
619
+
620
+ array(
621
+ 'title' => '',
622
+ 'desc' => __( 'If timepicker is selected, set interval (in minutes) here', 'woocommerce-jetpack' ),
623
+ 'id' => 'wcj_checkout_custom_field_timepicker_interval_' . $i,
624
+ 'type' => 'number',
625
+ 'default' => 15,
626
+ ),
627
  array(
628
  'title' => '',
629
  'desc' => __( 'required', 'woocommerce-jetpack' ),
640
  'type' => 'textarea',
641
  'css' => 'min-width:300px;width:50%;',
642
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
643
  array(
644
  'title' => '',
645
  'desc' => __( 'placeholder', 'woocommerce-jetpack' ),
648
  'type' => 'textarea',
649
  'css' => 'min-width:300px;width:50%;',
650
  ),
 
651
  array(
652
  'title' => '',
653
  'desc' => __( 'section', 'woocommerce-jetpack' ),
662
  ),
663
  'css' => 'min-width:300px;width:50%;',
664
  ),
 
665
  array(
666
  'title' => '',
667
  'desc' => __( 'class', 'woocommerce-jetpack' ),
675
  ),
676
  'css' => 'min-width:300px;width:50%;',
677
  ),
 
678
  array(
679
  'title' => '',
680
  'desc' => __( 'clear', 'woocommerce-jetpack' ),
683
  'type' => 'checkbox',
684
  'css' => 'min-width:300px;width:50%;',
685
  ),
 
686
  array(
687
  'title' => '',
688
  'desc' => __( 'categories', 'woocommerce-jetpack' ),
694
  'css' => 'min-width:300px;width:50%;',
695
  'options' => $product_cats,
696
  ),
 
697
  )
698
  );
699
  }
700
 
701
  $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_checkout_custom_fields_individual_options' );
702
 
703
+ return $this->add_standard_settings( $settings );
704
  }
705
 
706
  }
includes/class-wcj-currencies.php CHANGED
@@ -4,48 +4,60 @@
4
  *
5
  * The WooCommerce Jetpack currencies class stores currencies data.
6
  *
7
- * @class WCJ_Currencies
8
- * @package WC_Jetpack/Classes
9
- * @category Class
10
- * @author Algoritmika Ltd.
11
  */
12
 
13
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
 
15
  if ( ! class_exists( 'WCJ_Currencies' ) ) :
16
 
17
- class WCJ_Currencies {
18
 
19
- public function __construct() {
 
 
 
 
 
 
 
 
 
 
20
 
21
  $currencies = include( 'currencies/wcj-currencies.php' );
22
  foreach( $currencies as $data ) {
23
- $this->currency_symbols[ $data['code'] ] = $data['symbol'];
24
- $this->currency_names[ $data['code'] ] = $data['name'];
25
- //$this->currency_names_and_symbols[ $data['code'] ] = $data['name'] . ' (' . $data['symbol'] . ')';
26
  }
27
 
28
- // Hooks
29
- if ( get_option( 'wcj_currency_enabled' ) == 'yes') {
30
- // Main hooks
31
- add_filter( 'woocommerce_currencies', array( $this, 'add_all_currencies'), 100 );
32
- add_filter( 'woocommerce_currency_symbol', array( $this, 'add_currency_symbol'), 100, 2 );
33
- // Settings
34
- add_filter( 'woocommerce_general_settings', array( $this, 'add_edit_currency_symbol_field' ), 100 );
 
 
35
  }
36
 
37
- // Settings
38
- add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
39
- add_filter( 'wcj_settings_currency', array( $this, 'get_settings' ), 100 );
40
- add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
 
 
41
  }
42
 
43
  /**
44
  * add_all_currencies.
45
  */
46
  function add_all_currencies( $currencies ) {
47
- foreach ( $this->currency_names as $currency_code => $currency_name )
48
  $currencies[ $currency_code ] = $currency_name;
 
49
  asort( $currencies );
50
  return $currencies;
51
  }
@@ -54,105 +66,128 @@ class WCJ_Currencies {
54
  * add_currency_symbol.
55
  */
56
  function add_currency_symbol( $currency_symbol, $currency ) {
57
- if ( 'yes' === get_option( 'wcj_currency_hide_symbol' ) )
58
  return '';
 
59
  $default = ( isset( $this->currency_symbols[ $currency ] ) ) ? $this->currency_symbols[ $currency ] : $currency_symbol;
60
  return apply_filters( 'wcj_get_option_filter', $default, get_option( 'wcj_currency_' . $currency, $currency_symbol ) );
61
  }
62
 
63
  /**
64
  * add_edit_currency_symbol_field.
 
 
65
  */
66
  function add_edit_currency_symbol_field( $settings ) {
67
-
68
  $updated_settings = array();
69
-
70
  foreach ( $settings as $section ) {
71
-
72
  if ( isset( $section['id'] ) && 'woocommerce_currency_pos' == $section['id'] ) {
73
-
74
  $updated_settings[] = array(
75
- 'name' => __( 'Currency Symbol', 'woocommerce-jetpack' ), //TODO name or title?????
76
- 'desc_tip' => __( 'This sets the currency symbol.', 'woocommerce-jetpack' ),
77
- 'id' => 'wcj_currency_' . get_woocommerce_currency(),
78
- 'type' => 'text',
79
- 'default' => get_woocommerce_currency_symbol(),
80
- 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
81
- 'css' => 'width: 50px;',
82
- 'custom_attributes'
83
- => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
84
  );
85
  }
86
-
87
  $updated_settings[] = $section;
88
  }
89
-
90
  return $updated_settings;
91
  }
92
 
93
- /**
94
- * add_enabled_option.
95
- */
96
- public function add_enabled_option( $settings ) {
97
- $all_settings = $this->get_settings();
98
- $settings[] = $all_settings[1];
99
- return $settings;
100
- }
101
-
102
  /**
103
  * get_settings.
 
 
104
  */
105
  function get_settings() {
106
 
107
  $settings = array(
108
 
109
- array( 'title' => __( 'Currencies Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_currency_options' ),
 
 
 
 
110
 
111
  array(
112
- 'title' => __( 'Currencies', 'woocommerce-jetpack' ),
113
- 'desc' => '<strong>' . __( 'Enable Module', 'woocommerce-jetpack' ) . '</strong>',
114
- 'desc_tip' => __( 'Add all world currencies to your WooCommerce store; change currency symbol.', 'woocommerce-jetpack' ),
115
- 'id' => 'wcj_currency_enabled',
116
- 'default' => 'no',
117
- 'type' => 'checkbox'
118
  ),
 
119
 
120
- array( 'type' => 'sectionend', 'id' => 'wcj_currency_options' ),
 
 
 
 
 
 
 
 
 
121
 
122
- array( 'title' => __( 'Currency Symbol Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_all_currencies_list_options' ),
 
 
 
123
 
124
- array(
125
- 'title' => __( 'Hide Currency Symbol', 'woocommerce-jetpack' ),
126
- 'desc' => __( 'Hide', 'woocommerce-jetpack' ),
127
- 'desc_tip' => __( 'Default: no.', 'woocommerce-jetpack' ),
128
- 'id' => 'wcj_currency_hide_symbol',
129
- 'default' => 'no',
130
- 'type' => 'checkbox'
131
- ),
132
  );
133
 
134
- foreach ( $this->currency_names as $currency_code => $currency_name )
 
 
 
 
 
 
 
 
 
 
 
135
  $settings[] = array(
136
- 'title' => $currency_name,
137
- 'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc_no_link' ),
138
- 'id' => 'wcj_currency_' . $currency_code,
139
- 'default' => $this->currency_symbols[ $currency_code ],
140
- 'type' => 'text',
141
- 'custom_attributes'
142
- => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
143
  );
144
 
145
- $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_all_currencies_list_options' );
 
 
 
 
 
 
146
 
147
- return $settings;
148
- }
 
 
 
 
 
 
149
 
150
- /**
151
- * settings_section.
152
- */
153
- function settings_section( $sections ) {
154
- $sections['currency'] = __( 'Currencies', 'woocommerce-jetpack' );
155
- return $sections;
156
  }
157
  }
158
 
4
  *
5
  * The WooCommerce Jetpack currencies class stores currencies data.
6
  *
7
+ * @version 2.4.0
8
+ * @author Algoritmika Ltd.
 
 
9
  */
10
 
11
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
12
 
13
  if ( ! class_exists( 'WCJ_Currencies' ) ) :
14
 
15
+ class WCJ_Currencies extends WCJ_Module {
16
 
17
+ /**
18
+ * Constructor.
19
+ *
20
+ * @version 2.4.0
21
+ */
22
+ function __construct() {
23
+
24
+ $this->id = 'currency';
25
+ $this->short_desc = __( 'Currencies', 'woocommerce-jetpack' );
26
+ $this->desc = __( 'Add all world currencies to your WooCommerce store; change currency symbol.', '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[ $data['code'] ] = $data['name'];
 
33
  }
34
 
35
+ $custom_currency_total_number = apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_currency_custom_currency_total_number', 1 ) );
36
+ for ( $i = 1; $i <= $custom_currency_total_number; $i++) {
37
+ $custom_currency_code = get_option( 'wcj_currency_custom_currency_code_' . $i );
38
+ $custom_currency_name = get_option( 'wcj_currency_custom_currency_name_' . $i );
39
+ $custom_currency_symbol = get_option( 'wcj_currency_custom_currency_symbol_' . $i );
40
+ if ( '' != $custom_currency_code && '' != $custom_currency_name && '' != $custom_currency_symbol ) {
41
+ $this->currency_names[ $custom_currency_code ] = $custom_currency_name;
42
+ $this->currency_symbols[ $custom_currency_code ] = $custom_currency_symbol;
43
+ }
44
  }
45
 
46
+ if ( $this->is_enabled() ) {
47
+ add_filter( 'woocommerce_currencies', array( $this, 'add_all_currencies'), 100 );
48
+ add_filter( 'woocommerce_currency_symbol', array( $this, 'add_currency_symbol'), 100, 2 );
49
+
50
+ add_filter( 'woocommerce_general_settings', array( $this, 'add_edit_currency_symbol_field' ), 100 );
51
+ }
52
  }
53
 
54
  /**
55
  * add_all_currencies.
56
  */
57
  function add_all_currencies( $currencies ) {
58
+ foreach ( $this->currency_names as $currency_code => $currency_name ) {
59
  $currencies[ $currency_code ] = $currency_name;
60
+ }
61
  asort( $currencies );
62
  return $currencies;
63
  }
66
  * add_currency_symbol.
67
  */
68
  function add_currency_symbol( $currency_symbol, $currency ) {
69
+ if ( 'yes' === get_option( 'wcj_currency_hide_symbol' ) ) {
70
  return '';
71
+ }
72
  $default = ( isset( $this->currency_symbols[ $currency ] ) ) ? $this->currency_symbols[ $currency ] : $currency_symbol;
73
  return apply_filters( 'wcj_get_option_filter', $default, get_option( 'wcj_currency_' . $currency, $currency_symbol ) );
74
  }
75
 
76
  /**
77
  * add_edit_currency_symbol_field.
78
+ *
79
+ * @version 2.4.0
80
  */
81
  function add_edit_currency_symbol_field( $settings ) {
 
82
  $updated_settings = array();
 
83
  foreach ( $settings as $section ) {
 
84
  if ( isset( $section['id'] ) && 'woocommerce_currency_pos' == $section['id'] ) {
 
85
  $updated_settings[] = array(
86
+ 'name' => __( 'Booster: Currency Symbol', 'woocommerce-jetpack' ),
87
+ 'desc_tip' => __( 'This sets the currency symbol.', 'woocommerce-jetpack' ),
88
+ 'id' => 'wcj_currency_' . get_woocommerce_currency(),
89
+ 'type' => 'text',
90
+ 'default' => get_woocommerce_currency_symbol(),
91
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
92
+ 'css' => 'width: 50px;',
93
+ 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
 
94
  );
95
  }
 
96
  $updated_settings[] = $section;
97
  }
 
98
  return $updated_settings;
99
  }
100
 
 
 
 
 
 
 
 
 
 
101
  /**
102
  * get_settings.
103
+ *
104
+ * @version 2.4.0
105
  */
106
  function get_settings() {
107
 
108
  $settings = array(
109
 
110
+ array(
111
+ 'title' => __( 'Currency Symbol Options', 'woocommerce-jetpack' ),
112
+ 'type' => 'title',
113
+ 'id' => 'wcj_all_currencies_list_options',
114
+ ),
115
 
116
  array(
117
+ 'title' => __( 'Hide Currency Symbol', 'woocommerce-jetpack' ),
118
+ 'desc' => __( 'Hide', 'woocommerce-jetpack' ),
119
+ 'desc_tip' => __( 'Default: no.', 'woocommerce-jetpack' ),
120
+ 'id' => 'wcj_currency_hide_symbol',
121
+ 'default' => 'no',
122
+ 'type' => 'checkbox',
123
  ),
124
+ );
125
 
126
+ foreach ( $this->currency_names as $currency_code => $currency_name ) {
127
+ $settings[] = array(
128
+ 'title' => $currency_name,
129
+ 'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc_no_link' ),
130
+ 'id' => 'wcj_currency_' . $currency_code,
131
+ 'default' => $this->currency_symbols[ $currency_code ],
132
+ 'type' => 'text',
133
+ 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
134
+ );
135
+ }
136
 
137
+ $settings[] = array(
138
+ 'type' => 'sectionend',
139
+ 'id' => 'wcj_all_currencies_list_options',
140
+ );
141
 
142
+ $settings[] = array(
143
+ 'title' => __( 'Custom Currencies', 'woocommerce-jetpack' ),
144
+ 'type' => 'title',
145
+ 'id' => 'wcj_currency_custom_currency_options',
 
 
 
 
146
  );
147
 
148
+ $settings[] = array(
149
+ 'title' => __( 'Total Custom Currencies', 'woocommerce-jetpack' ),
150
+ 'id' => 'wcj_currency_custom_currency_total_number',
151
+ 'default' => 1,
152
+ 'type' => 'custom_number',
153
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
154
+ 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
155
+ );
156
+
157
+ $custom_currency_total_number = apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_currency_custom_currency_total_number', 1 ) );
158
+ for ( $i = 1; $i <= $custom_currency_total_number; $i++) {
159
+
160
  $settings[] = array(
161
+ 'title' => __( 'Custom Currency', 'woocommerce-jetpack' ) . ' #' . $i,
162
+ 'desc' => __( 'Currency Name', 'woocommerce-jetpack' ),
163
+ 'id' => 'wcj_currency_custom_currency_name_' . $i,
164
+ 'default' => '',
165
+ 'type' => 'text',
 
 
166
  );
167
 
168
+ $settings[] = array(
169
+ 'title' => '',
170
+ 'desc' => __( 'Currency Code', 'woocommerce-jetpack' ),
171
+ 'id' => 'wcj_currency_custom_currency_code_' . $i,
172
+ 'default' => '',
173
+ 'type' => 'text',
174
+ );
175
 
176
+ $settings[] = array(
177
+ 'title' => '',
178
+ 'desc' => __( 'Currency Symbol', 'woocommerce-jetpack' ),
179
+ 'id' => 'wcj_currency_custom_currency_symbol_' . $i,
180
+ 'default' => '',
181
+ 'type' => 'text',
182
+ );
183
+ }
184
 
185
+ $settings[] = array(
186
+ 'type' => 'sectionend',
187
+ 'id' => 'wcj_currency_custom_currency_options',
188
+ );
189
+
190
+ return $this->add_standard_settings( $settings );
191
  }
192
  }
193
 
includes/class-wcj-eu-vat-number.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack EU VAT Number class.
6
  *
7
- * @version 2.3.10
8
  * @since 2.3.9
9
  * @author Algoritmika Ltd.
10
  */
@@ -233,13 +233,15 @@ class WCJ_EU_VAT_Number extends WCJ_Module {
233
 
234
  /**
235
  * add_eu_vat_number_checkout_field_to_frontend.
 
 
236
  */
237
  function add_eu_vat_number_checkout_field_to_frontend( $fields ) {
238
  $fields['billing'][ 'billing_' . $this->id ] = array(
239
  'type' => 'text',
240
  // 'default' => isset( $_SESSION['wcj_eu_vat_number_to_check'] ) ? $_SESSION['wcj_eu_vat_number_to_check'] : '',
241
  'label' => get_option( 'wcj_eu_vat_number_field_label' ),
242
- // 'description' => '',
243
  'placeholder' => get_option( 'wcj_eu_vat_number_field_placeholder' ),
244
  'required' => ( 'yes' === get_option( 'wcj_eu_vat_number_field_required', 'no' ) ) ? true : false,
245
  'custom_attributes' => array(),
@@ -253,10 +255,9 @@ class WCJ_EU_VAT_Number extends WCJ_Module {
253
  /**
254
  * get_settings.
255
  *
256
- * @version 2.3.10
257
  */
258
  function get_settings() {
259
-
260
  $settings = array(
261
  array(
262
  'title' => __( 'Options', 'woocommerce-jetpack' ),
@@ -268,12 +269,21 @@ class WCJ_EU_VAT_Number extends WCJ_Module {
268
  'id' => 'wcj_eu_vat_number_field_label',
269
  'default' => __( 'EU VAT Number', 'woocommerce-jetpack' ),
270
  'type' => 'text',
 
271
  ),
272
  array(
273
  'title' => __( 'Placeholder', 'woocommerce-jetpack' ),
274
  'id' => 'wcj_eu_vat_number_field_placeholder',
275
  'default' => __( 'EU VAT Number', 'woocommerce-jetpack' ),
276
  'type' => 'text',
 
 
 
 
 
 
 
 
277
  ),
278
  /* array(
279
  'title' => __( 'Require Country Code in VAT Number', 'woocommerce-jetpack' ),
@@ -314,14 +324,15 @@ class WCJ_EU_VAT_Number extends WCJ_Module {
314
  'type' => 'checkbox',
315
  ),
316
  array(
317
- 'title' => __( 'Message on Not Valid', 'woocommerce-jetpack' ),
 
318
  'id' => 'wcj_eu_vat_number_not_valid_message',
319
- 'default' => '<strong>EU VAT Number</strong> is not valid.',
320
  'type' => 'textarea',
321
  'css' => 'width:300px;',
322
  ),
323
  array(
324
- 'title' => __( 'Disable VAT for Valid Numbers', 'woocommerce-jetpack' ),
325
  'desc' => __( 'Yes', 'woocommerce-jetpack' ),
326
  'id' => 'wcj_eu_vat_number_disable_for_valid',
327
  'default' => 'yes',
@@ -337,6 +348,14 @@ class WCJ_EU_VAT_Number extends WCJ_Module {
337
  'custom_attributes'
338
  => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
339
  ),
 
 
 
 
 
 
 
 
340
  array(
341
  'title' => __( 'Check for IP Location Country', 'woocommerce-jetpack' ),
342
  'desc' => __( 'Yes', 'woocommerce-jetpack' ),
@@ -347,12 +366,19 @@ class WCJ_EU_VAT_Number extends WCJ_Module {
347
  'custom_attributes'
348
  => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
349
  ),
 
 
 
 
 
 
 
 
350
  array(
351
  'type' => 'sectionend',
352
  'id' => 'wcj_eu_vat_number_options'
353
  ),
354
  );
355
-
356
  return $this->add_standard_settings( $settings );
357
  }
358
  }
4
  *
5
  * The WooCommerce Jetpack EU VAT Number class.
6
  *
7
+ * @version 2.4.0
8
  * @since 2.3.9
9
  * @author Algoritmika Ltd.
10
  */
233
 
234
  /**
235
  * add_eu_vat_number_checkout_field_to_frontend.
236
+ *
237
+ * @version 2.4.0
238
  */
239
  function add_eu_vat_number_checkout_field_to_frontend( $fields ) {
240
  $fields['billing'][ 'billing_' . $this->id ] = array(
241
  'type' => 'text',
242
  // 'default' => isset( $_SESSION['wcj_eu_vat_number_to_check'] ) ? $_SESSION['wcj_eu_vat_number_to_check'] : '',
243
  'label' => get_option( 'wcj_eu_vat_number_field_label' ),
244
+ 'description' => get_option( 'wcj_eu_vat_number_field_description' ),
245
  'placeholder' => get_option( 'wcj_eu_vat_number_field_placeholder' ),
246
  'required' => ( 'yes' === get_option( 'wcj_eu_vat_number_field_required', 'no' ) ) ? true : false,
247
  'custom_attributes' => array(),
255
  /**
256
  * get_settings.
257
  *
258
+ * @version 2.4.0
259
  */
260
  function get_settings() {
 
261
  $settings = array(
262
  array(
263
  'title' => __( 'Options', 'woocommerce-jetpack' ),
269
  'id' => 'wcj_eu_vat_number_field_label',
270
  'default' => __( 'EU VAT Number', 'woocommerce-jetpack' ),
271
  'type' => 'text',
272
+ 'css' => 'width:300px;',
273
  ),
274
  array(
275
  'title' => __( 'Placeholder', 'woocommerce-jetpack' ),
276
  'id' => 'wcj_eu_vat_number_field_placeholder',
277
  'default' => __( 'EU VAT Number', 'woocommerce-jetpack' ),
278
  'type' => 'text',
279
+ 'css' => 'width:300px;',
280
+ ),
281
+ array(
282
+ 'title' => __( 'Description', 'woocommerce-jetpack' ),
283
+ 'id' => 'wcj_eu_vat_number_field_description',
284
+ 'default' => '',
285
+ 'type' => 'text',
286
+ 'css' => 'width:300px;',
287
  ),
288
  /* array(
289
  'title' => __( 'Require Country Code in VAT Number', 'woocommerce-jetpack' ),
324
  'type' => 'checkbox',
325
  ),
326
  array(
327
+ 'title' => '',
328
+ 'desc' => __( 'Message on not valid', 'woocommerce-jetpack' ),
329
  'id' => 'wcj_eu_vat_number_not_valid_message',
330
+ 'default' => __( '<strong>EU VAT Number</strong> is not valid.', 'woocommerce-jetpack' ),
331
  'type' => 'textarea',
332
  'css' => 'width:300px;',
333
  ),
334
  array(
335
+ 'title' => __( 'Exempt VAT for Valid Numbers', 'woocommerce-jetpack' ),
336
  'desc' => __( 'Yes', 'woocommerce-jetpack' ),
337
  'id' => 'wcj_eu_vat_number_disable_for_valid',
338
  'default' => 'yes',
348
  'custom_attributes'
349
  => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
350
  ),
351
+ /* array(
352
+ 'title' => '',
353
+ 'desc' => __( 'Message if customer is in base country and VAT is NOT exempted.', 'woocommerce-jetpack' ),
354
+ 'id' => 'wcj_eu_vat_number_preserve_in_base_country_message',
355
+ 'default' => __( 'EU VAT Number is valid, however VAT is not exempted.', 'woocommerce-jetpack' ),
356
+ 'type' => 'textarea',
357
+ 'css' => 'width:300px;',
358
+ ), */
359
  array(
360
  'title' => __( 'Check for IP Location Country', 'woocommerce-jetpack' ),
361
  'desc' => __( 'Yes', 'woocommerce-jetpack' ),
366
  'custom_attributes'
367
  => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
368
  ),
369
+ /* array(
370
+ 'title' => '',
371
+ 'desc' => __( 'Message if customer\'s check for IP location country has failed.', 'woocommerce-jetpack' ),
372
+ 'id' => 'wcj_eu_vat_number_check_ip_location_country_message',
373
+ 'default' => __( 'IP must be from same country as VAT ID.', 'woocommerce-jetpack' ),
374
+ 'type' => 'textarea',
375
+ 'css' => 'width:300px;',
376
+ ), */
377
  array(
378
  'type' => 'sectionend',
379
  'id' => 'wcj_eu_vat_number_options'
380
  ),
381
  );
 
382
  return $this->add_standard_settings( $settings );
383
  }
384
  }
includes/class-wcj-general.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack General class.
6
  *
7
- * @version 2.3.10
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -17,7 +17,7 @@ class WCJ_General extends WCJ_Module {
17
  /**
18
  * Constructor.
19
  *
20
- * @version 2.3.10
21
  */
22
  public function __construct() {
23
 
@@ -39,6 +39,10 @@ class WCJ_General extends WCJ_Module {
39
 
40
  if ( $this->is_enabled() ) {
41
 
 
 
 
 
42
  if ( 'yes' === get_option( 'wcj_general_shortcodes_in_text_widgets_enabled' ) ) {
43
  add_filter( 'widget_text', 'do_shortcode' );
44
  }
@@ -52,6 +56,17 @@ class WCJ_General extends WCJ_Module {
52
  }
53
  }
54
 
 
 
 
 
 
 
 
 
 
 
 
55
  /**
56
  * create_export_customers_tool.
57
  *
@@ -209,7 +224,8 @@ class WCJ_General extends WCJ_Module {
209
  /**
210
  * get_settings.
211
  *
212
- * @version 2.3.9
 
213
  */
214
  function get_settings() {
215
 
@@ -234,75 +250,152 @@ class WCJ_General extends WCJ_Module {
234
  $settings = array(
235
 
236
  array(
237
- 'title' => __( 'Shortcodes Options', 'woocommerce-jetpack' ),
238
- 'type' => 'title',
239
- 'desc' => '',
240
- 'id' => 'wcj_general_shortcodes_options',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  ),
242
 
243
  array(
244
- 'title' => __( 'Enable Shortcodes in WordPress Text Widgets', 'woocommerce-jetpack' ),
245
- 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
246
- 'id' => 'wcj_general_shortcodes_in_text_widgets_enabled',
247
- 'default' => 'no',
248
- 'type' => 'checkbox',
249
  ),
250
 
251
  array(
252
- 'type' => 'sectionend',
253
- 'id' => 'wcj_general_shortcodes_options',
254
  ),
255
 
256
  array(
257
- 'title' => __( 'Custom CSS Options', 'woocommerce-jetpack' ),
258
- 'type' => 'title',
259
- 'desc' => __( 'Another custom CSS, if you need one.', 'woocommerce-jetpack' ),
260
- 'id' => 'wcj_general_custom_css_options',
261
  ),
262
 
263
  array(
264
- 'title' => __( 'Custom CSS - Front end (Customers)', 'woocommerce-jetpack' ),
265
- 'id' => 'wcj_general_custom_css',
266
- 'default' => '',
267
- 'type' => 'custom_textarea',
268
- 'css' => 'width:66%;min-width:300px;min-height:300px;',
269
  ),
270
 
271
  array(
272
- 'title' => __( 'Custom CSS - Back end (Admin)', 'woocommerce-jetpack' ),
273
- 'id' => 'wcj_general_custom_admin_css',
274
- 'default' => '',
275
- 'type' => 'custom_textarea',
276
- 'css' => 'width:66%;min-width:300px;min-height:300px;',
277
  ),
278
 
279
  array(
280
- 'type' => 'sectionend',
281
- 'id' => 'wcj_general_custom_css_options',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
  ),
283
 
284
  /* array(
285
- 'title' => __( 'WooCommerce Templates Editor Links', 'woocommerce-jetpack' ),
286
- 'type' => 'title',
287
- 'id' => 'wcj_general_wc_templates_editor_links_options',
288
  ),
289
 
290
  array(
291
- 'title' => __( 'Templates', 'woocommerce-jetpack' ),
292
- 'id' => 'wcj_general_wc_templates_editor_links',
293
- 'type' => 'custom_link',
294
- 'link' => '<pre>' . $links_html . '</pre>',
295
  ),
296
 
297
  array(
298
- 'type' => 'sectionend',
299
- 'id' => 'wcj_general_wc_templates_editor_links_options',
300
  ), */
301
  );
302
 
303
- $settings = $this->add_tools_list( $settings );
304
-
305
- return $this->add_enable_module_setting( $settings );
306
  }
307
  }
308
 
4
  *
5
  * The WooCommerce Jetpack General class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
17
  /**
18
  * Constructor.
19
  *
20
+ * @version 2.4.0
21
  */
22
  public function __construct() {
23
 
39
 
40
  if ( $this->is_enabled() ) {
41
 
42
+ if ( 'yes' === get_option( 'wcj_product_revisions_enabled', 'no' ) ) {
43
+ add_filter( 'woocommerce_register_post_type_product', array( $this, 'enable_product_revisions' ) );
44
+ }
45
+
46
  if ( 'yes' === get_option( 'wcj_general_shortcodes_in_text_widgets_enabled' ) ) {
47
  add_filter( 'widget_text', 'do_shortcode' );
48
  }
56
  }
57
  }
58
 
59
+ /**
60
+ * enable_product_revisions.
61
+ *
62
+ * @version 2.4.0
63
+ * @since 2.4.0
64
+ */
65
+ function enable_product_revisions( $args ) {
66
+ $args['supports'][] = 'revisions';
67
+ return $args;
68
+ }
69
+
70
  /**
71
  * create_export_customers_tool.
72
  *
224
  /**
225
  * get_settings.
226
  *
227
+ * @version 2.4.0
228
+ * @todo add link to Booster's shortcodes list
229
  */
230
  function get_settings() {
231
 
250
  $settings = array(
251
 
252
  array(
253
+ 'title' => __( 'Shortcodes Options', 'woocommerce-jetpack' ),
254
+ 'type' => 'title',
255
+ 'id' => 'wcj_general_shortcodes_options',
256
+ ),
257
+
258
+ array(
259
+ 'title' => __( 'Enable All Shortcodes in WordPress Text Widgets', 'woocommerce-jetpack' ),
260
+ 'desc_tip' => __( 'This will enable all (including non Booster\'s) shortcodes in WordPress text widgets.', 'woocommerce-jetpack' ),
261
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
262
+ 'id' => 'wcj_general_shortcodes_in_text_widgets_enabled',
263
+ 'default' => 'no',
264
+ 'type' => 'checkbox',
265
+ ),
266
+
267
+ array(
268
+ 'title' => __( 'Disable Booster\'s Shortcodes', 'woocommerce-jetpack' ),
269
+ 'desc_tip' => __( 'Disable all Booster\'s shortcodes (for memory saving).', 'woocommerce-jetpack' ),
270
+ 'desc' => __( 'Disable', 'woocommerce-jetpack' ),
271
+ 'id' => 'wcj_general_shortcodes_disable_booster_shortcodes',
272
+ 'default' => 'no',
273
+ 'type' => 'checkbox',
274
+ ),
275
+
276
+ array(
277
+ 'type' => 'sectionend',
278
+ 'id' => 'wcj_general_shortcodes_options',
279
+ ),
280
+
281
+ array(
282
+ 'title' => __( 'Custom CSS Options', 'woocommerce-jetpack' ),
283
+ 'type' => 'title',
284
+ 'desc' => __( 'Another custom CSS, if you need one.', 'woocommerce-jetpack' ),
285
+ 'id' => 'wcj_general_custom_css_options',
286
+ ),
287
+
288
+ array(
289
+ 'title' => __( 'Custom CSS - Front end (Customers)', 'woocommerce-jetpack' ),
290
+ 'id' => 'wcj_general_custom_css',
291
+ 'default' => '',
292
+ 'type' => 'custom_textarea',
293
+ 'css' => 'width:66%;min-width:300px;min-height:300px;',
294
+ ),
295
+
296
+ array(
297
+ 'title' => __( 'Custom CSS - Back end (Admin)', 'woocommerce-jetpack' ),
298
+ 'id' => 'wcj_general_custom_admin_css',
299
+ 'default' => '',
300
+ 'type' => 'custom_textarea',
301
+ 'css' => 'width:66%;min-width:300px;min-height:300px;',
302
+ ),
303
+
304
+ array(
305
+ 'type' => 'sectionend',
306
+ 'id' => 'wcj_general_custom_css_options',
307
+ ),
308
+
309
+ array(
310
+ 'title' => __( 'Product Revisions', 'woocommerce-jetpack' ),
311
+ 'type' => 'title',
312
+ 'id' => 'wcj_product_revisions_options',
313
  ),
314
 
315
  array(
316
+ 'title' => __( 'Product Revisions', 'woocommerce-jetpack' ),
317
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
318
+ 'id' => 'wcj_product_revisions_enabled',
319
+ 'default' => 'no',
320
+ 'type' => 'checkbox',
321
  ),
322
 
323
  array(
324
+ 'type' => 'sectionend',
325
+ 'id' => 'wcj_product_revisions_options',
326
  ),
327
 
328
  array(
329
+ 'title' => __( 'Advanced Options', 'woocommerce-jetpack' ),
330
+ 'type' => 'title',
331
+ 'id' => 'wcj_general_advanced_options',
 
332
  ),
333
 
334
  array(
335
+ 'title' => __( 'Disable Loading Datepicker/Weekpicker CSS', 'woocommerce-jetpack' ),
336
+ 'desc' => __( 'Disable', 'woocommerce-jetpack' ),
337
+ 'id' => 'wcj_general_advanced_disable_datepicker_css',
338
+ 'default' => 'no',
339
+ 'type' => 'checkbox',
340
  ),
341
 
342
  array(
343
+ 'title' => __( 'Datepicker/Weekpicker CSS', 'woocommerce-jetpack' ),
344
+ 'id' => 'wcj_general_advanced_datepicker_css',
345
+ 'default' => '//ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/themes/base/jquery-ui.css',
346
+ 'type' => 'text',
347
+ 'css' => 'width:66%;min-width:300px;',
348
  ),
349
 
350
  array(
351
+ 'title' => __( 'Disable Loading Datepicker/Weekpicker JavaScript', 'woocommerce-jetpack' ),
352
+ 'desc' => __( 'Disable', 'woocommerce-jetpack' ),
353
+ 'id' => 'wcj_general_advanced_disable_datepicker_js',
354
+ 'default' => 'no',
355
+ 'type' => 'checkbox',
356
+ ),
357
+
358
+ array(
359
+ 'title' => __( 'Disable Loading Timepicker CSS', 'woocommerce-jetpack' ),
360
+ 'desc' => __( 'Disable', 'woocommerce-jetpack' ),
361
+ 'id' => 'wcj_general_advanced_disable_timepicker_css',
362
+ 'default' => 'no',
363
+ 'type' => 'checkbox',
364
+ ),
365
+
366
+ array(
367
+ 'title' => __( 'Disable Loading Timepicker JavaScript', 'woocommerce-jetpack' ),
368
+ 'desc' => __( 'Disable', 'woocommerce-jetpack' ),
369
+ 'id' => 'wcj_general_advanced_disable_timepicker_js',
370
+ 'default' => 'no',
371
+ 'type' => 'checkbox',
372
+ ),
373
+
374
+ array(
375
+ 'type' => 'sectionend',
376
+ 'id' => 'wcj_general_advanced_options',
377
  ),
378
 
379
  /* array(
380
+ 'title' => __( 'WooCommerce Templates Editor Links', 'woocommerce-jetpack' ),
381
+ 'type' => 'title',
382
+ 'id' => 'wcj_general_wc_templates_editor_links_options',
383
  ),
384
 
385
  array(
386
+ 'title' => __( 'Templates', 'woocommerce-jetpack' ),
387
+ 'id' => 'wcj_general_wc_templates_editor_links',
388
+ 'type' => 'custom_link',
389
+ 'link' => '<pre>' . $links_html . '</pre>',
390
  ),
391
 
392
  array(
393
+ 'type' => 'sectionend',
394
+ 'id' => 'wcj_general_wc_templates_editor_links_options',
395
  ), */
396
  );
397
 
398
+ return $this->add_standard_settings( $settings );
 
 
399
  }
400
  }
401
 
includes/class-wcj-mini-cart.php CHANGED
@@ -25,9 +25,9 @@ class WCJ_Mini_Cart extends WCJ_Module {
25
  $this->desc = __( 'Customize WooCommerce mini cart widget.', 'woocommerce-jetpack' );
26
  parent::__construct();
27
 
28
- if ( $this->is_enabled() ) {
29
  $total_number = apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_mini_cart_custom_info_total_number', 1 ) );
30
- for ( $i = 1; $i <= $total_number; $i++) {
31
  add_action( get_option( 'wcj_mini_cart_custom_info_hook_' . $i, 'woocommerce_after_mini_cart' ), array( $this, 'add_mini_cart_custom_info' ) );
32
  }
33
  }
@@ -39,7 +39,7 @@ class WCJ_Mini_Cart extends WCJ_Module {
39
  function get_settings() {
40
 
41
  // The Module settings
42
- $settings = array();
43
 
44
  // Mini Cart Custom Info Options
45
  $settings[] = array( 'title' => __( 'Mini Cart Custom Info Blocks', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_mini_cart_custom_info_options' );
@@ -51,15 +51,14 @@ class WCJ_Mini_Cart extends WCJ_Module {
51
  'type' => 'custom_number',
52
  //'type' => 'number',
53
  'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
54
- 'custom_attributes'
55
- => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
56
  );
57
 
58
  $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_mini_cart_custom_info_options' );
59
 
60
  $total_number = apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_mini_cart_custom_info_total_number', 1 ) );
61
 
62
- for ( $i = 1; $i <= $total_number; $i++) {
63
 
64
  $settings = array_merge( $settings, array(
65
 
@@ -103,7 +102,7 @@ class WCJ_Mini_Cart extends WCJ_Module {
103
 
104
  //$settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_mini_cart_custom_info_options' );
105
 
106
- return $this->add_enable_module_setting( $settings );
107
  }
108
 
109
  /**
25
  $this->desc = __( 'Customize WooCommerce mini cart widget.', 'woocommerce-jetpack' );
26
  parent::__construct();
27
 
28
+ if ( $this->is_enabled() ) {
29
  $total_number = apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_mini_cart_custom_info_total_number', 1 ) );
30
+ for ( $i = 1; $i <= $total_number; $i++ ) {
31
  add_action( get_option( 'wcj_mini_cart_custom_info_hook_' . $i, 'woocommerce_after_mini_cart' ), array( $this, 'add_mini_cart_custom_info' ) );
32
  }
33
  }
39
  function get_settings() {
40
 
41
  // The Module settings
42
+ $settings = array();
43
 
44
  // Mini Cart Custom Info Options
45
  $settings[] = array( 'title' => __( 'Mini Cart Custom Info Blocks', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_mini_cart_custom_info_options' );
51
  'type' => 'custom_number',
52
  //'type' => 'number',
53
  'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
54
+ 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
 
55
  );
56
 
57
  $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_mini_cart_custom_info_options' );
58
 
59
  $total_number = apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_mini_cart_custom_info_total_number', 1 ) );
60
 
61
+ for ( $i = 1; $i <= $total_number; $i++ ) {
62
 
63
  $settings = array_merge( $settings, array(
64
 
102
 
103
  //$settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_mini_cart_custom_info_options' );
104
 
105
+ return $this->add_enable_module_setting( $settings );
106
  }
107
 
108
  /**
includes/class-wcj-payment-gateways-currency.php CHANGED
@@ -83,6 +83,8 @@ class WCJ_Payment_Gateways_Currency extends WCJ_Module {
83
 
84
  /**
85
  * extend_paypal_supported_currencies.
 
 
86
  */
87
  function extend_paypal_supported_currencies( $supported_currencies ) {
88
  if ( $this->is_cart_or_checkout() ) {
@@ -90,7 +92,9 @@ class WCJ_Payment_Gateways_Currency extends WCJ_Module {
90
  $current_gateway = $woocommerce->session->chosen_payment_method;
91
  if ( '' != $current_gateway ) {
92
  $gateway_currency = get_option( 'wcj_gateways_currency_' . $current_gateway );
93
- $supported_currencies[] = $gateway_currency;
 
 
94
  }
95
  }
96
  return $supported_currencies;
@@ -98,6 +102,8 @@ class WCJ_Payment_Gateways_Currency extends WCJ_Module {
98
 
99
  /**
100
  * change_currency_symbol.
 
 
101
  */
102
  public function change_currency_symbol( $currency_symbol, $currency ) {
103
  if ( $this->is_cart_or_checkout() ) {
@@ -105,7 +111,9 @@ class WCJ_Payment_Gateways_Currency extends WCJ_Module {
105
  $current_gateway = $woocommerce->session->chosen_payment_method;
106
  if ( '' != $current_gateway ) {
107
  $gateway_currency = get_option( 'wcj_gateways_currency_' . $current_gateway );
108
- return wcj_get_currency_symbol( $gateway_currency );
 
 
109
  }
110
  }
111
  return $currency_symbol;
@@ -113,6 +121,8 @@ class WCJ_Payment_Gateways_Currency extends WCJ_Module {
113
 
114
  /**
115
  * change_currency_code.
 
 
116
  */
117
  public function change_currency_code( $currency ) {
118
  if ( $this->is_cart_or_checkout() ) {
@@ -127,8 +137,10 @@ class WCJ_Payment_Gateways_Currency extends WCJ_Module {
127
  }
128
  } */
129
  if ( '' != $current_gateway ) {
130
- $gateway_currency = get_option( 'wcj_gateways_currency_' . $current_gateway );
131
- return $gateway_currency;
 
 
132
  }
133
  }
134
  return $currency;
@@ -170,6 +182,8 @@ class WCJ_Payment_Gateways_Currency extends WCJ_Module {
170
 
171
  /**
172
  * add_currency_settings.
 
 
173
  */
174
  function add_currency_settings( $settings ) {
175
 
@@ -192,7 +206,13 @@ class WCJ_Payment_Gateways_Currency extends WCJ_Module {
192
  'currency_to' => $currency_to,
193
  'multiply_by_field_id' => 'wcj_gateways_currency_exchange_rate_' . $key,
194
  );
195
- if ( $currency_from == $currency_to ) $custom_attributes['disabled'] = 'disabled';
 
 
 
 
 
 
196
 
197
  $settings = array_merge( $settings, array(
198
 
@@ -200,9 +220,9 @@ class WCJ_Payment_Gateways_Currency extends WCJ_Module {
200
  'title' => $gateway->title,
201
  // 'desc' => __( 'currency', 'woocommerce-jetpack' ),
202
  'id' => 'wcj_gateways_currency_' . $key,
203
- 'default' => get_woocommerce_currency(),
204
  'type' => 'select',
205
- 'options' => wcj_get_currencies_names_and_symbols(),
206
  ),
207
 
208
  array(
83
 
84
  /**
85
  * extend_paypal_supported_currencies.
86
+ *
87
+ * @version 2.4.0
88
  */
89
  function extend_paypal_supported_currencies( $supported_currencies ) {
90
  if ( $this->is_cart_or_checkout() ) {
92
  $current_gateway = $woocommerce->session->chosen_payment_method;
93
  if ( '' != $current_gateway ) {
94
  $gateway_currency = get_option( 'wcj_gateways_currency_' . $current_gateway );
95
+ if ( 'no_changes' != $gateway_currency ) {
96
+ $supported_currencies[] = $gateway_currency;
97
+ }
98
  }
99
  }
100
  return $supported_currencies;
102
 
103
  /**
104
  * change_currency_symbol.
105
+ *
106
+ * @version 2.4.0
107
  */
108
  public function change_currency_symbol( $currency_symbol, $currency ) {
109
  if ( $this->is_cart_or_checkout() ) {
111
  $current_gateway = $woocommerce->session->chosen_payment_method;
112
  if ( '' != $current_gateway ) {
113
  $gateway_currency = get_option( 'wcj_gateways_currency_' . $current_gateway );
114
+ if ( 'no_changes' != $gateway_currency ) {
115
+ return wcj_get_currency_symbol( $gateway_currency );
116
+ }
117
  }
118
  }
119
  return $currency_symbol;
121
 
122
  /**
123
  * change_currency_code.
124
+ *
125
+ * @version 2.4.0
126
  */
127
  public function change_currency_code( $currency ) {
128
  if ( $this->is_cart_or_checkout() ) {
137
  }
138
  } */
139
  if ( '' != $current_gateway ) {
140
+ $gateway_currency = get_option( 'wcj_gateways_currency_' . $current_gateway );
141
+ if ( 'no_changes' != $gateway_currency ) {
142
+ return $gateway_currency;
143
+ }
144
  }
145
  }
146
  return $currency;
182
 
183
  /**
184
  * add_currency_settings.
185
+ *
186
+ * @version 2.4.0
187
  */
188
  function add_currency_settings( $settings ) {
189
 
206
  'currency_to' => $currency_to,
207
  'multiply_by_field_id' => 'wcj_gateways_currency_exchange_rate_' . $key,
208
  );
209
+ if ( $currency_from == $currency_to ) {
210
+ $custom_attributes['disabled'] = 'disabled';
211
+ }
212
+ if ( 'no_changes' == $currency_to ) {
213
+ $custom_attributes['disabled'] = 'disabled';
214
+ $currency_to = $currency_from;
215
+ }
216
 
217
  $settings = array_merge( $settings, array(
218
 
220
  'title' => $gateway->title,
221
  // 'desc' => __( 'currency', 'woocommerce-jetpack' ),
222
  'id' => 'wcj_gateways_currency_' . $key,
223
+ 'default' => 'no_changes',//get_woocommerce_currency(),
224
  'type' => 'select',
225
+ 'options' => array_merge( array( 'no_changes' => __( 'No changes', 'woocommerce-jetpack' ) ), wcj_get_currencies_names_and_symbols() ),
226
  ),
227
 
228
  array(
includes/class-wcj-pdf-invoices.php DELETED
@@ -1,1448 +0,0 @@
1
- <?php
2
- /**
3
- * WooCommerce Jetpack PDF Invoices
4
- *
5
- * The WooCommerce Jetpack PDF Invoices class.
6
- *
7
- * @version 2.3.10
8
- * @author Algoritmika Ltd.
9
- */
10
-
11
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
12
-
13
- if ( ! class_exists( 'WCJ_PDF_Invoices' ) ) :
14
-
15
- class WCJ_PDF_Invoices {
16
-
17
- public $default_css;
18
-
19
- /**
20
- * Constructor.
21
- */
22
- public function __construct() {
23
-
24
- $this->default_css =
25
- '.pdf_invoice_header_text_wcj { text-align: right; color: gray; font-weight: bold; } ' .
26
- '.pdf_invoice_number_and_date_table_wcj { width: 50%; } ' .
27
- '.pdf_invoice_items_table_wcj { padding: 5px; width: 100%; } ' .
28
- '.pdf_invoice_items_table_wcj th { border: 1px solid #F0F0F0; font-weight: bold; text-align: center; } ' .
29
- '.pdf_invoice_items_table_wcj td { border: 1px solid #F0F0F0; } ' .
30
- '.pdf_invoice_totals_table_wcj { padding: 5px; width: 100%; } ' .
31
- '.pdf_invoice_totals_table_wcj th { width: 80%; text-align: right; } ' .
32
- '.pdf_invoice_totals_table_wcj td { width: 20%; text-align: right; border: 1px solid #F0F0F0; }';
33
-
34
- // add_shortcode( 'wcj_order_date', array( $this, 'shortcode_pdf_invoices_order_date' ) );
35
- // add_shortcode( 'wcj_order_billing_address', array( $this, 'shortcode_pdf_invoices_billing_address' ) );
36
- // add_shortcode( 'wcj_items_total_weight', array( $this, 'shortcode_pdf_invoices_items_total_weight' ) );
37
- // add_shortcode( 'wcj_items_total_quantity', array( $this, 'shortcode_pdf_invoices_items_total_quantity' ) );
38
- // add_shortcode( 'wcj_items_total_number', array( $this, 'shortcode_pdf_invoices_items_total_number' ) );
39
-
40
- // Main hooks
41
- if ( get_option( 'wcj_pdf_invoices_enabled' ) == 'yes' ) {
42
-
43
- add_filter( 'woocommerce_admin_order_actions', array( $this, 'add_pdf_invoices_link_to_order_list' ), 100, 2 );
44
-
45
- add_action( 'init', array( $this, 'generate_pdf' ), 10 );
46
-
47
- add_action( 'admin_head', array( $this, 'add_pdf_invoice_icon_css' ) );
48
-
49
- if ( 'yes' === apply_filters( 'wcj_get_option_filter', 'no', get_option( 'wcj_pdf_invoices_enabled_for_customers' ) ) )
50
- add_filter( 'woocommerce_my_account_my_orders_actions', array( $this, 'add_pdf_invoices_link_to_my_account' ), 100, 2 );
51
-
52
- if ( 'yes' === apply_filters( 'wcj_get_option_filter', 'no', get_option( 'wcj_pdf_invoices_attach_to_email_enabled' ) ) )
53
- add_filter( 'woocommerce_email_attachments', array( $this, 'add_pdf_invoice_email_attachment' ), 100, 3 );
54
-
55
- add_filter( 'woocommerce_payment_gateways_settings', array( $this, 'add_attach_invoice_settings' ), 100 );
56
- }
57
-
58
- // Settings hooks
59
- add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
60
- add_filter( 'wcj_settings_pdf_invoices', array( $this, 'get_settings' ), 100 );
61
- add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
62
- }
63
-
64
- /**
65
- * add_attach_invoice_settings.
66
- */
67
- function add_attach_invoice_settings( $settings ) {
68
- $settings[] = array( 'title' => __( 'Payment Gateways Attach PDF Invoice V1 Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you choose when to attach PDF invoice to customers emails.', 'woocommerce-jetpack' ), 'id' => 'wcj_gateways_attach_invoice_options' );
69
- global $woocommerce;
70
- $available_gateways = $woocommerce->payment_gateways->payment_gateways();
71
- foreach ( $available_gateways as $key => $gateway ) {
72
-
73
- $settings = array_merge( $settings, array(
74
-
75
- array(
76
- 'title' => $gateway->title,
77
- //'desc' => __( 'Attach PDF invoice to customers emails.', 'woocommerce-jetpack' ),
78
- 'desc' => __( 'Attach PDF invoice.', 'woocommerce-jetpack' ),
79
- 'id' => 'wcj_gateways_attach_invoice_' . $key,
80
- 'default' => 'yes',
81
- 'type' => 'checkbox',
82
- ),
83
-
84
-
85
- ) );
86
- }
87
-
88
- $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_gateways_attach_invoice_options' );
89
-
90
- return $settings;
91
- }
92
-
93
- /**
94
- * Shortcodes.
95
- */
96
- public function get_shortcode( $shortcode, $atts ) {
97
- $atts = shortcode_atts( array(
98
- 'before' => '',
99
- 'after' => '',
100
- 'visibility' => '',
101
- 'options' => '',
102
- 'id' => '',
103
- ), $atts, $shortcode );
104
- if ( 'admin' === $atts['visibility'] && ! is_super_admin() )
105
- return '';
106
- if ( '' != ( $result = $this->get_pdf_invoices_short_code( $shortcode, $atts['id'], $atts['options'] ) ) )
107
- return $atts['before'] . $result . $atts['after'];
108
- return '';
109
- }
110
-
111
- public function get_pdf_invoices_short_code( $shortcode, $id, $options ) {
112
- // Get the order id
113
- if ( isset( $_GET['pdf_invoice'] ) )
114
- $order_id = $_GET['pdf_invoice'];
115
- else if ( '' != $id )
116
- $order_id = $id;
117
- // Get the order
118
- $the_order = wc_get_order( $order_id );
119
- if ( false == $the_order )
120
- return '';
121
- // The shortcodes
122
- switch ( $shortcode ) {
123
- case '%order_date%':
124
- return date_i18n( get_option( 'date_format' ), strtotime( $the_order->order_date ) );
125
- case '%billing_address%':
126
- return $the_order->get_formatted_billing_address();
127
- case '%items_total_weight%':
128
- return $this->get_order_items_total_weight( $the_order );
129
- case '%items_total_number%':
130
- return $this->get_order_items_total_number( $the_order );
131
- case '%items_total_quantity%':
132
- return $this->get_order_items_total_quantity( $the_order );
133
- default:
134
- return '';
135
- }
136
- return '';
137
- }
138
-
139
- public function get_order_items_total_weight( $the_order ) {
140
- $total_weight = 0;
141
- $the_items = $the_order->get_items();
142
- foreach( $the_items as $the_item ) {
143
- //$the_product = new WC_Product( $the_item['product_id'] );
144
- $the_product = wc_get_product( $the_item['product_id'] );
145
- $total_weight += $the_item['qty'] * $the_product->get_weight();
146
- }
147
- return ( 0 == $total_weight ) ? '' : $total_weight;
148
- }
149
-
150
- public function get_order_items_total_number( $the_order ) {
151
- $total_number = count( $the_order->get_items() );
152
- return ( 0 == $total_number ) ? '' : $total_number;
153
- }
154
-
155
- public function get_order_items_total_quantity( $the_order ) {
156
- $total_quantity = 0;
157
- $the_items = $the_order->get_items();
158
- foreach( $the_items as $the_item )
159
- $total_quantity += $the_item['qty'];
160
- return ( 0 == $total_quantity ) ? '' : $total_quantity;
161
- }
162
-
163
- public function shortcode_pdf_invoices_order_date( $atts ) {
164
- return $this->get_shortcode( '%order_date%', $atts );
165
- }
166
-
167
- public function shortcode_pdf_invoices_billing_address( $atts ) {
168
- return $this->get_shortcode( '%billing_address%', $atts );
169
- }
170
-
171
- public function shortcode_pdf_invoices_items_total_weight( $atts ) {
172
- return $this->get_shortcode( '%items_total_weight%', $atts );
173
- }
174
-
175
- public function shortcode_pdf_invoices_items_total_number( $atts ) {
176
- return $this->get_shortcode( '%items_total_number%', $atts );
177
- }
178
-
179
- public function shortcode_pdf_invoices_items_total_quantity( $atts ) {
180
- return $this->get_shortcode( '%items_total_quantity%', $atts );
181
- }
182
-
183
- /**
184
- * do_attach_for_payment_method.
185
- */
186
- public function do_attach_for_payment_method( $payment_method ) {
187
- return ( 'no' === get_option( 'wcj_gateways_attach_invoice_' . $payment_method, 'yes' ) ) ? false : true;
188
- }
189
-
190
- /**
191
- * add_pdf_invoice_email_attachment.
192
- */
193
- public function add_pdf_invoice_email_attachment( $attachments, $status, $order ) {
194
- if ( isset( $status ) && 'customer_completed_order' === $status && isset( $order ) && true === $this->do_attach_for_payment_method( $order->payment_method ) ) {
195
- $file_name = sys_get_temp_dir() . '/invoice-' . $order->id . '.pdf';
196
- $result = file_put_contents( $file_name, $this->generate_pdf( $order->id ) );
197
- $attachments[] = $file_name;
198
- }
199
- return $attachments;
200
- }
201
-
202
- /**
203
- * Unlocks - PDF Invoices - add_pdf_invoices_link_to_my_account.
204
- */
205
- public function add_pdf_invoices_link_to_my_account( $actions, $the_order ) {
206
-
207
- if ( 'no' === get_option( 'wcj_pdf_invoices_save_as_enabled' ) )
208
- $actions['pdf_invoice'] = array(
209
- 'url' => $_SERVER['REQUEST_URI'] . '?pdf_invoice=' . $the_order->id,
210
- 'name' => __( 'Invoice', 'woocommerce-jetpack' ),
211
- );
212
- else
213
- $actions['save_pdf_invoice'] = array(
214
- 'url' => $_SERVER['REQUEST_URI'] . '?pdf_invoice=' . $the_order->id . '&save_pdf_invoice=1',
215
- 'name' => __( 'Invoice', 'woocommerce-jetpack' ),
216
- );
217
-
218
- return $actions;
219
- }
220
-
221
- /**
222
- * add_pdf_invoice_icon_css.
223
- */
224
- function add_pdf_invoice_icon_css() {
225
-
226
- echo '<style> a.button.tips.view.pdf_invoice:after { content: "\e028" !important; } </style>';
227
- echo '<style> a.button.tips.view.save_pdf_invoice:after { content: "\e028" !important; } </style>';
228
- }
229
-
230
- /**
231
- * generate_pdf.
232
- */
233
- public function generate_pdf( $get_by_order_id = 0 ) {
234
-
235
- if ( ! isset( $_GET['pdf_invoice'] ) && 0 == $get_by_order_id ) return;
236
-
237
- $order_id = ( 0 == $get_by_order_id ) ? $_GET['pdf_invoice'] : $get_by_order_id;
238
-
239
- if ( ! is_user_logged_in() && 0 == $get_by_order_id ) return;
240
-
241
- if ( ( ! current_user_can( 'administrator' ) ) && ( ! is_shop_manager() ) && ( get_current_user_id() != intval( get_post_meta( $order_id, '_customer_user', true ) ) ) && ( 0 == $get_by_order_id ) ) return;
242
-
243
- // Include the main TCPDF library (search for installation path).
244
- //require_once('tcpdf_include.php');
245
- require_once( 'lib/tcpdf_min/tcpdf.php' );
246
-
247
- // create new PDF document
248
- $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
249
-
250
- // set document information
251
- $pdf->SetCreator( PDF_CREATOR );
252
- //$pdf->SetAuthor( 'Algoritmika Ltd.' );
253
- $pdf->SetTitle( 'Invoice' );
254
- $pdf->SetSubject( 'Invoice PDF' );
255
- $pdf->SetKeywords( 'invoice, PDF' );
256
-
257
- // set default header data
258
- // TODO 2014.09.21
259
- // $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
260
- //$pdf->SetHeaderData( get_option( 'wcj_pdf_invoices_seller_logo_url' ), 30, get_option( 'wcj_pdf_invoices_header_title' ), get_option( 'wcj_pdf_invoices_header_string' ), array(0,64,255), array(0,64,128));
261
- $pdf->SetPrintHeader(false);
262
- $pdf->setFooterData(array(0,64,0), array(0,64,128));
263
- //$pdf->SetPrintFooter(false);
264
-
265
- // set header and footer fonts
266
- $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
267
- $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
268
-
269
- // set default monospaced font
270
- $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
271
-
272
- // set margins
273
- $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
274
- $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
275
- $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
276
-
277
- // set auto page breaks
278
- $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
279
-
280
- // set image scale factor
281
- $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
282
-
283
- /*
284
- // set some language-dependent strings (optional)
285
- if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
286
- require_once(dirname(__FILE__).'/lang/eng.php');
287
- $pdf->setLanguageArray($l);
288
- }
289
- */
290
-
291
- // ---------------------------------------------------------
292
-
293
- // set default font subsetting mode
294
- $pdf->setFontSubsetting(true);
295
-
296
- // Set font
297
- // dejavusans is a UTF-8 Unicode font, if you only need to
298
- // print standard ASCII chars, you can use core fonts like
299
- // helvetica or times to reduce file size.
300
- $pdf->SetFont(
301
- apply_filters( 'wcj_get_option_filter', 'dejavusans', get_option( 'wcj_pdf_invoices_general_font_family', 'dejavusans' ) ),
302
- '',
303
- apply_filters( 'wcj_get_option_filter', 8, get_option( 'wcj_pdf_invoices_general_font_size' ) ),
304
- '',
305
- true);
306
-
307
- // Add a page
308
- // This method has several options, check the source code documentation for more information.
309
- $pdf->AddPage();
310
-
311
- if ( 'yes' === get_option( 'wcj_pdf_invoices_general_font_shadowed', 'yes' ) ) {
312
- // set text shadow effect
313
- $pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
314
- }
315
-
316
- $html = $this->get_invoice_html( $order_id );
317
-
318
- // Print text using writeHTMLCell()
319
- $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
320
-
321
- // ---------------------------------------------------------
322
-
323
- // Close and output PDF document
324
- // This method has several options, check the source code documentation for more information.
325
- // $the_order = new WC_Order( $order_id );
326
- // $order_number = $the_order->get_order_number();
327
-
328
-
329
-
330
-
331
-
332
-
333
- /**/
334
-
335
- if ( $get_by_order_id > 0 )
336
- return $pdf->Output('invoice-' . $order_id . '.pdf', 'S');
337
- else
338
- {
339
- $file_name = 'invoice-' . $order_id . '.pdf';
340
- $file_path = sys_get_temp_dir() . '/' . $file_name;
341
- $result = file_put_contents( $file_path, $pdf->Output( '', 'S' ) );
342
- //echo $pdf->Output( '', 'S' );
343
-
344
- if ( isset( $_GET['save_pdf_invoice'] ) && '1' == $_GET['save_pdf_invoice'] ) {
345
- //$pdf->Output('invoice-' . $order_id . '.pdf', 'D');
346
-
347
- header("Content-Type: application/octet-stream");
348
-
349
- //$file = $file_name;//$_GET["file"] .".pdf";
350
- header("Content-Disposition: attachment; filename=" . urlencode($file_name));
351
- header("Content-Type: application/octet-stream");
352
- header("Content-Type: application/download");
353
- header("Content-Description: File Transfer");
354
-
355
- }
356
- else {
357
- //$pdf->Output('invoice-' . $order_id . '.pdf', 'I');
358
-
359
- header("Content-type: application/pdf");
360
- header("Content-Disposition: inline; filename=" . urlencode($file_name));
361
- }
362
-
363
- header("Content-Length: " . filesize($file_path));
364
- flush(); // this doesn't really matter.
365
- if ( false !== ( $fp = fopen($file_path, "r") ) ) {
366
- while (!feof($fp))
367
- {
368
- echo fread($fp, 65536);
369
- flush(); // this is essential for large downloads
370
- }
371
- fclose($fp);
372
- } else {
373
- die( __( 'Unexpected error', 'woocommerce-jetpack' ) );
374
- }
375
- }
376
-
377
-
378
-
379
-
380
- /**/
381
-
382
-
383
-
384
-
385
-
386
- /**
387
-
388
-
389
- if ( $get_by_order_id > 0 )
390
- return $pdf->Output('invoice-' . $order_id . '.pdf', 'S');
391
- if ( isset( $_GET['save_pdf_invoice'] ) && '1' == $_GET['save_pdf_invoice'] )
392
- $pdf->Output('invoice-' . $order_id . '.pdf', 'D');
393
- else
394
- $pdf->Output('invoice-' . $order_id . '.pdf', 'I');
395
-
396
- /**/
397
-
398
-
399
-
400
-
401
-
402
-
403
-
404
- }
405
-
406
-
407
- /**
408
- * add_custom_checkout_fields_to_pdf.
409
- */
410
- public function add_custom_checkout_fields_to_pdf( $order_id, $section ) {
411
-
412
- $result = '';
413
-
414
- $post_meta = get_post_meta( $order_id );
415
- foreach( $post_meta as $key => $values ) {
416
- $value = maybe_unserialize( $values[0] );
417
- if ( isset( $value['section'] ) && $section === $value['section'] ) {
418
- if ( '' != $value['value'] ) {
419
- $the_label = $value['label'];
420
- if ( '' != $the_label )
421
- $the_label = $the_label . ': ';
422
- $result .= '<p>' . $the_label . $value['value'] . '</p>';
423
- }
424
- }
425
- }
426
-
427
- return $result;
428
- }
429
-
430
- /**
431
- * get_columns.
432
- */
433
- public function get_columns() {
434
-
435
- // Count optional columns number for column width calculation
436
- $total_optional_columns = 0;
437
- if ( '' != get_option( 'wcj_pdf_invoices_column_single_price_tax_excl_text' ) ) $total_optional_columns++;
438
- if ( '' != get_option( 'wcj_pdf_invoices_column_single_price_tax_text' ) ) $total_optional_columns++;
439
- if ( '' != get_option( 'wcj_pdf_invoices_column_single_price_tax_incl_text' ) ) $total_optional_columns++;
440
- if ( '' != get_option( 'wcj_pdf_invoices_column_price_tax_excl_text' ) ) $total_optional_columns++;
441
- if ( '' != get_option( 'wcj_pdf_invoices_column_price_tax_percent' ) ) $total_optional_columns++;
442
- if ( '' != get_option( 'wcj_pdf_invoices_column_price_tax_text' ) ) $total_optional_columns++;
443
- $price_column_width = 50 / ( 1 + $total_optional_columns );
444
-
445
- // Columns array //
446
- // - if required == false (i.e. optional), then title != '' will be checked
447
- return array(
448
- array(
449
- //'name' => 'item-counter',
450
- 'title' => get_option( 'wcj_pdf_invoices_column_nr_text' ),
451
- 'css' => 'width:7%;',
452
- 'required' => true,
453
- 'value_var' => 'item_counter',
454
- 'td_css' => 'text-align:center;',
455
- ),
456
- array(
457
- 'title' => get_option( 'wcj_pdf_invoices_column_item_name_text' ),
458
- 'css' => 'width:36%;',
459
- 'required' => true,
460
- 'value_var' => 'item_name',
461
- 'td_css' => '',
462
- ),
463
- array(
464
- 'title' => get_option( 'wcj_pdf_invoices_column_qty_text' ),
465
- 'css' => 'width:7%;',
466
- 'required' => true,
467
- 'value_var' => 'item_quantity',
468
- 'td_css' => 'text-align:center;',
469
- ),
470
- array(
471
- 'title' => get_option( 'wcj_pdf_invoices_column_single_price_tax_excl_text' ),
472
- 'css' => 'width:' . $price_column_width . '%;',
473
- 'required' => false,
474
- 'value_var' => 'item_total_excl_tax_formatted',
475
- 'td_css' => 'text-align:right;',
476
- ),
477
- array(
478
- 'title' => get_option( 'wcj_pdf_invoices_column_single_price_tax_text' ),
479
- 'css' => 'width:' . $price_column_width . '%;',
480
- 'required' => false,
481
- 'value_var' => 'item_total_tax_formatted',
482
- 'td_css' => 'text-align:right;',
483
- ),
484
- array(
485
- 'title' => get_option( 'wcj_pdf_invoices_column_single_price_tax_incl_text' ),
486
- 'css' => 'width:' . $price_column_width . '%;',
487
- 'required' => false,
488
- 'value_var' => 'item_total_incl_tax_formatted',
489
- 'td_css' => 'text-align:right;',
490
- ),
491
- array(
492
- 'title' => get_option( 'wcj_pdf_invoices_column_price_tax_excl_text' ),
493
- 'css' => 'width:' . $price_column_width . '%;',
494
- 'required' => false,
495
- 'value_var' => 'line_total_excl_tax_formatted',
496
- 'td_css' => 'text-align:right;',
497
- ),
498
- array(
499
- 'title' => get_option( 'wcj_pdf_invoices_column_price_tax_percent' ),
500
- 'css' => 'width:' . $price_column_width . '%;',
501
- 'required' => false,
502
- 'value_var' => 'line_total_tax_percent',
503
- 'td_css' => 'text-align:right;',
504
- ),
505
- array(
506
- 'title' => get_option( 'wcj_pdf_invoices_column_price_tax_text' ),
507
- 'css' => 'width:' . $price_column_width . '%;',
508
- 'required' => false,
509
- 'value_var' => 'line_total_tax_formatted',
510
- 'td_css' => 'text-align:right;',
511
- ),
512
- array(
513
- 'title' => get_option( 'wcj_pdf_invoices_column_price_text' ),
514
- 'css' => 'width:' . $price_column_width . '%;',
515
- 'required' => true,
516
- 'value_var' => 'line_total_incl_tax_formatted',
517
- 'td_css' => 'text-align:right;',
518
- ),
519
- );
520
- }
521
-
522
- /**
523
- * get_header.
524
- */
525
- public function get_header( $the_order ) {
526
- // Starting output
527
- // Css
528
- $html = '<style>' . apply_filters( 'wcj_get_option_filter', $this->default_css, get_option( 'wcj_pdf_invoices_general_css' ) ) . '</style>';
529
-
530
- // HEADER //
531
- // TEXT AND LOGO //
532
- $html .= '<p>';
533
- if ( '' != get_option( 'wcj_pdf_invoices_seller_logo_url' ) )
534
- $html .= '<img src="' . get_option( 'wcj_pdf_invoices_seller_logo_url' ) . '">';
535
- $html .= '<div class="pdf_invoice_header_text_wcj">' . get_option( 'wcj_pdf_invoices_header_text' ) . '</div>';
536
- // NUMBER AND DATE //
537
- $html .= '<table class="pdf_invoice_number_and_date_table_wcj"><tbody>';
538
- $html .= '<tr><td>' . get_option( 'wcj_pdf_invoices_invoice_number_text' ) . '</td><td>' . $the_order->get_order_number() . '</td></tr>';
539
- if ( '' != get_option( 'wcj_pdf_invoices_order_date_text' ) )
540
- $html .= '<tr><td>' . get_option( 'wcj_pdf_invoices_order_date_text' ) . '</td><td>' . date_i18n( get_option( 'date_format' ), strtotime( $the_order->order_date ) ) . '</td></tr>';
541
- if ( '' != get_option( 'wcj_pdf_invoices_order_time_text' ) )
542
- $html .= '<tr><td>' . get_option( 'wcj_pdf_invoices_order_time_text' ) . '</td><td>' . date_i18n( get_option( 'time_format' ), strtotime( $the_order->order_date ) ) . '</td></tr>';
543
- $html .= '<tr><td>' . get_option( 'wcj_pdf_invoices_invoice_date_text' ) . '</td><td>' . date_i18n( get_option( 'date_format' ), strtotime( $the_order->order_date ) ) . '</td></tr>';
544
- if ( '' != get_option( 'wcj_pdf_invoices_invoice_due_date_text' ) )
545
- $html .= '<tr><td>' . get_option( 'wcj_pdf_invoices_invoice_due_date_text' ) . '</td><td>' . date_i18n( get_option( 'date_format' ), ( strtotime( $the_order->order_date ) + get_option( 'wcj_pdf_invoices_invoice_due_date_days' ) * 24 * 60 *60 ) ) . '</td></tr>';
546
- if ( '' != get_option( 'wcj_pdf_invoices_invoice_fulfillment_date_text' ) )
547
- $html .= '<tr><td>' . get_option( 'wcj_pdf_invoices_invoice_fulfillment_date_text' ) . '</td><td>' . date_i18n( get_option( 'date_format' ), ( strtotime( $the_order->order_date ) + get_option( 'wcj_pdf_invoices_invoice_fulfillment_date_days' ) * 24 * 60 *60 ) ) . '</td></tr>';
548
- $html .= '</tbody></table>';
549
- $html .= '</p>';
550
-
551
- // SELLER AND BUYER INFO //
552
- $html .= '<p>';
553
- $html .= '<table class="pdf_invoice_seller_and_buyer_table_wcj"><tbody>';
554
- $html .= '<tr><td>';
555
- $html .= '<h2>' . get_option( 'wcj_pdf_invoices_seller_text' ) . '</h2>';
556
- $html .= str_replace( PHP_EOL, '<br>', get_option( 'wcj_pdf_invoices_seller_info' ) );
557
- $html .= '</td><td>';
558
- $html .= '<h2>' . get_option( 'wcj_pdf_invoices_buyer_text' ) . '</h2>';
559
- $html .= $the_order->get_formatted_billing_address() . $this->add_custom_checkout_fields_to_pdf( $the_order->id, 'billing' );
560
- $html .= '</td></tr></tbody></table>';
561
- $html .= '</p>';
562
-
563
- return $html;
564
- }
565
-
566
- /**
567
- * get_items_table.
568
- */
569
- public function get_items_table( $the_order ) {
570
-
571
- $html = '';
572
-
573
- // ITEMS //
574
- $the_items = $the_order->get_items();
575
- $html .= '<h2>' . get_option( 'wcj_pdf_invoices_items_text' ) . '</h2>';
576
- $html .= '<table class="pdf_invoice_items_table_wcj"><tbody>';
577
- $columns = $this->get_columns();
578
- // Adding to output //
579
- $html .= '<tr>';
580
- foreach ( $columns as $column )
581
- if ( ( true === $column['required'] ) || ( '' != $column['title'] ) )
582
- $html .= '<th style="' . $column['css'] . '">' . $column['title'] . '</th>';
583
- $html .= '</tr>';
584
-
585
-
586
-
587
- // Shipping as item
588
- $order_total_shipping = $the_order->get_total_shipping();
589
- if ( ( '' != get_option( 'wcj_pdf_invoices_display_shipping_as_item_text' ) ) && ( $order_total_shipping > 0 ) ) {
590
-
591
- $shipping_item_name = get_option( 'wcj_pdf_invoices_display_shipping_as_item_text' );
592
-
593
- // Add shipping method text
594
- if ( 'yes' === get_option( 'wcj_pdf_invoices_display_shipping_as_item_shipping_method' ) )
595
- $shipping_item_name .= '<div style="font-size:x-small;">' . $the_order->get_shipping_method() . '</div>';
596
- else if ( 'replace' === get_option( 'wcj_pdf_invoices_display_shipping_as_item_shipping_method' ) )
597
- $shipping_item_name = $the_order->get_shipping_method();
598
-
599
- // Create item
600
- $the_items[] = array(
601
- 'name' => $shipping_item_name,
602
- 'type' => 'line_item',
603
- 'qty' => 1,
604
- 'line_subtotal' => $order_total_shipping,
605
- 'line_total' => $order_total_shipping,
606
- 'line_tax' => $the_order->get_shipping_tax(),
607
- 'line_subtotal_tax' => $the_order->get_shipping_tax(),
608
- 'item_meta' => array(
609
- '_qty' => array( 1 ),
610
- '_line_subtotal' => array( $order_total_shipping ),
611
- '_line_total' => array( $order_total_shipping ),
612
- '_line_tax' => array( $the_order->get_shipping_tax() ),
613
- '_line_subtotal_tax' => array( $the_order->get_shipping_tax() ),
614
- ),
615
- );
616
- }
617
-
618
- // Discount as item
619
- $total_tax_excl = $the_order->get_total_discount( true );
620
- if ( ( '' != get_option( 'wcj_pdf_invoices_display_discount_as_item_text' ) ) && ( 0 != $total_tax_excl ) ) {
621
-
622
- //$total_tax_excl = $the_order->get_total_discount( true );
623
- $tax = $the_order->get_total_discount( false ) - $total_tax_excl;
624
-
625
- if ( false != ( $the_tax = $this->wcj_order_get_cart_discount_tax( $the_order ) ) ) {
626
- $total_tax_excl -= $the_tax;
627
- $tax += $the_tax;
628
- }
629
-
630
- $total_tax_excl *= -1;
631
- $tax *= -1;
632
-
633
- $the_items[] = array(
634
- 'name' => get_option( 'wcj_pdf_invoices_display_discount_as_item_text' ),
635
- 'type' => 'line_item',
636
- 'qty' => 1,
637
- 'line_subtotal' => $total_tax_excl,
638
- 'line_total' => $total_tax_excl,
639
- 'line_tax' => $tax,
640
- 'line_subtotal_tax' => $tax,
641
- 'item_meta' => array(
642
- '_qty' => array( 1 ),
643
- '_line_subtotal' => array( $total_tax_excl ),
644
- '_line_total' => array( $total_tax_excl ),
645
- '_line_tax' => array( $tax ),
646
- '_line_subtotal_tax' => array( $tax ),
647
- ),
648
- );
649
- }
650
-
651
-
652
- $order_currency_array = array( 'currency' => $the_order->get_order_currency() );
653
-
654
-
655
- // ITEMS LOOP //
656
- $item_counter = 0;
657
- foreach ( $the_items as $item ) {
658
-
659
- // Preparing data //
660
- // Item Prices
661
- $item_total_excl_tax = $the_order->get_item_subtotal( $item, false, false );
662
- // $item_tax = $the_order->get_item_tax( $item, true );
663
- $item_tax = $the_order->get_item_subtotal( $item, true, false ) - $the_order->get_item_subtotal( $item, false, false );
664
- $item_total_incl_tax = $the_order->get_item_subtotal( $item, true, false );
665
- // Line Prices
666
- $line_total_excl_tax = $the_order->get_line_subtotal( $item, false, false );
667
- $line_tax = $the_order->get_line_subtotal( $item, true, false ) - $the_order->get_line_subtotal( $item, false, false );
668
- // $line_tax = $the_order->get_line_tax( $item );
669
- $line_total_incl_tax = $the_order->get_line_subtotal( $item, true, false );
670
- $line_total_tax_percent = 0;
671
- if ( 0 != $the_order->get_item_total( $item, false, false ) /* $line_total_excl_tax */ ) {
672
- $line_total_tax_percent = $the_order->get_item_tax( $item, false ) / $the_order->get_item_total( $item, false, false ) * 100;//round( ( $line_tax / $line_total_excl_tax * 100 ), 2 );
673
- $line_total_tax_percent = sprintf( '%.2f %%', $line_total_tax_percent );
674
- }
675
-
676
- $item_total_excl_tax_formatted = wc_price( $item_total_excl_tax, $order_currency_array );
677
- $item_total_tax_formatted = wc_price( $item_tax, $order_currency_array );
678
- $item_total_incl_tax_formatted = wc_price( $item_total_incl_tax, $order_currency_array );
679
-
680
- $line_total_excl_tax_formatted = wc_price( $line_total_excl_tax, $order_currency_array );
681
- $line_total_tax_formatted = wc_price( $line_tax, $order_currency_array );
682
- $line_total_incl_tax_formatted = wc_price( $line_total_incl_tax, $order_currency_array );
683
-
684
- // Item Quantity
685
- $item_quantity = $item['qty'];
686
-
687
- // Item Name
688
- $item_name = $item['name']; //$product->get_title();
689
-
690
-
691
- $product = $the_order->get_product_from_item( $item );
692
- if ( $product ) {
693
- // Additional info (e.g. SKU)
694
- if ( '' != get_option( 'wcj_pdf_invoices_column_item_name_additional_text' ) && $product->get_sku() )
695
- $item_name .= ' ' . str_replace( '%sku%', $product->get_sku(), get_option( 'wcj_pdf_invoices_column_item_name_additional_text' ) );
696
-
697
- // Variation (if needed)
698
- if ( $product->is_type( 'variation' ) )
699
- $item_name .= '<div style="font-size:smaller;">' . wc_get_formatted_variation( $product->variation_data, true ) . '</div>';
700
- }
701
-
702
- // Item Counter
703
- $item_counter++;
704
-
705
- // Adding to output //
706
- $html .= '<tr>';
707
- foreach ( $columns as $column )
708
- if ( ( true === $column['required'] ) || ( '' != $column['title'] ) ) {
709
- $html .= '<td style="' . $column['td_css'] . '">' . $$column['value_var'] . '</td>';
710
- }
711
- $html .= '</tr>';
712
- }
713
- $html .= '</tbody></table>';
714
-
715
- return $html;
716
- }
717
-
718
-
719
- /**
720
- * wcj_order_get_cart_discount_tax.
721
- */
722
- function wcj_order_get_cart_discount_tax( $the_order ) {
723
-
724
- $the_cart_discount = $the_order->get_cart_discount();
725
- $is_discount_taxable = ( $the_cart_discount > 0 ) ? true : false;
726
-
727
- if ( $is_discount_taxable ) {
728
-
729
- /* $order_total_incl_tax = $this->the_order->get_total();
730
- $order_total_tax = $this->the_order->get_total_tax(); */
731
-
732
-
733
-
734
- $order_total_incl_tax = 0;
735
- $order_total_tax = 0;
736
- $items = $the_order->get_items();
737
- foreach ( $items as $item ) {
738
- $order_total_incl_tax += $item['line_total'] + $item['line_tax'];
739
- $order_total_tax += $item['line_tax'];
740
- }
741
-
742
-
743
-
744
-
745
-
746
- if ( 0 != $order_total_incl_tax ) {
747
-
748
- // $order_tax_rate = $order_total_tax / ( $order_total_incl_tax - $order_total_tax );
749
- $order_tax_rate = $order_total_tax / $order_total_incl_tax;
750
- //$order_tax_rate = round( $order_tax_rate, 4 );
751
-
752
- $the_tax = $the_cart_discount * $order_tax_rate;//$the_cart_discount * $order_tax_rate;
753
-
754
- /* wcj_log( $order_total_incl_tax );
755
- wcj_log( $order_total_tax );
756
- wcj_log( $order_tax_rate );
757
- wcj_log( $the_tax );
758
- wcj_log( $the_tax / ( $the_cart_discount - $the_tax) );
759
- wcj_log( $order_total_tax / ( $order_total_incl_tax - $order_total_tax ) ); */
760
-
761
- return $the_tax;
762
- }
763
- }
764
-
765
- return false;
766
- }
767
-
768
- /**
769
- * get_footer.
770
- */
771
- public function get_footer( $the_order ) {
772
-
773
- // ORDER TOTALS //
774
-
775
-
776
-
777
-
778
-
779
- // Getting Totals
780
- $order_total_incl_tax = $the_order->get_total();
781
- $order_total_tax = $the_order->get_total_tax();
782
- $order_total_excl_tax = $order_total_incl_tax - $order_total_tax;
783
- //$order_total_discount_incl_tax = $the_order->get_total_discount( false );
784
- $order_total_discount_excl_tax = $the_order->get_total_discount( true ); //excl_tax
785
-
786
- $is_discount_taxable = ( $the_order->get_cart_discount() === $the_order->get_total_discount() ) ? true : false;
787
- if ( $is_discount_taxable && 0 != $order_total_incl_tax ) {
788
- $order_tax_rate = $order_total_tax / $order_total_incl_tax;
789
- $order_total_discount_excl_tax = $order_total_discount_excl_tax - $order_total_discount_excl_tax * $order_tax_rate;
790
- }
791
-
792
- //$order_subtotal = $order_total_excl_tax + $order_total_discount_excl_tax;
793
- $order_subtotal = $the_order->get_subtotal();
794
- $order_total_shipping_excl_tax = $the_order->get_total_shipping();
795
- /* if ( '' === get_option( 'wcj_pdf_invoices_display_shipping_as_item_text' ) )
796
- $order_subtotal = $order_subtotal - $order_total_shipping_excl_tax; */
797
- if ( '' != get_option( 'wcj_pdf_invoices_display_shipping_as_item_text' ) )
798
- $order_subtotal = $order_subtotal + $order_total_shipping_excl_tax;
799
-
800
- if ( '' != get_option( 'wcj_pdf_invoices_display_discount_as_item_text' ) )
801
- $order_subtotal = $order_subtotal - $order_total_discount_excl_tax;
802
-
803
-
804
- $order_currency_array = array( 'currency' => $the_order->get_order_currency() );
805
- $html = '';
806
- $html .= '<p><table class="pdf_invoice_totals_table_wcj"><tbody>';
807
- // FEES
808
- $fees_array = $the_order->get_fees();
809
- if ( ! empty( $fees_array ) )
810
- foreach ( $fees_array as $key => $fee_array )
811
- $html .= '<tr><th>' . $fee_array['name'] . '</th><td>' . wc_price( $fee_array['line_total'], $order_currency_array ) . '</td></tr>';
812
- // SUBTOTAL
813
- //$html .= '<tr><th>' . get_option( 'wcj_pdf_invoices_order_subtotal_text' ) . '</th><td>' . wc_price( ( $order_subtotal + $order_total_discount_excl_tax ), $order_currency_array ) . '</td></tr>';
814
- $html .= '<tr><th>' . get_option( 'wcj_pdf_invoices_order_subtotal_text' ) . '</th><td>' . wc_price( $order_subtotal, $order_currency_array ) . '</td></tr>';
815
- // SHIPPING
816
- if ( ( '' === get_option( 'wcj_pdf_invoices_display_shipping_as_item_text' ) ) && ( $order_total_shipping_excl_tax > 0 ) )
817
- $html .= '<tr><th>' . get_option( 'wcj_pdf_invoices_order_shipping_text' ) . '</th><td>' . wc_price( $order_total_shipping_excl_tax, $order_currency_array ) . '</td></tr>';
818
- // DISCOUNT
819
- if ( ( '' === get_option( 'wcj_pdf_invoices_display_discount_as_item_text' ) ) && ( 0 != $order_total_discount_excl_tax ) )
820
- $html .= '<tr><th>' . get_option( 'wcj_pdf_invoices_order_discount_text' ) . '</th><td>-' . wc_price( ( $order_total_discount_excl_tax /* + $order_total_discount_tax */ ), $order_currency_array ) . '</td></tr>';
821
- // SUBTOTAL2 - with discount and shipping
822
- //if ( $order_total_excl_tax != $order_subtotal )
823
- if ( wc_price( $order_total_excl_tax, $order_currency_array ) != wc_price( $order_subtotal, $order_currency_array ) )
824
- $html .= '<tr><th>' . get_option( 'wcj_pdf_invoices_order_total_excl_tax_text' ) . '</th><td>' . wc_price( $order_total_excl_tax, $order_currency_array ) . '</td></tr>';
825
- // TAXES
826
- if ( 0 != $order_total_tax )
827
- $html .= '<tr><th>' . get_option( 'wcj_pdf_invoices_order_total_tax_text' ) . '</th><td>' . wc_price( $order_total_tax, $order_currency_array ) . '</td></tr>';
828
- // TOTAL
829
- $html .= '<tr><th>' . get_option( 'wcj_pdf_invoices_order_total_text' ) . '</th><td>' . $the_order->get_formatted_order_total() . '</td></tr>';
830
- $html .= '</tbody></table></p>';
831
-
832
-
833
-
834
-
835
-
836
-
837
- // PAYMENT METHOD
838
- if ( '' != get_option( 'wcj_pdf_invoices_order_payment_method_text' ) )
839
- $html .= '<p>' . get_option( 'wcj_pdf_invoices_order_payment_method_text' ). ': ' . $the_order->payment_method_title . '</p>';
840
- // SHIPPING METHOD
841
- if ( '' != get_option( 'wcj_pdf_invoices_order_shipping_method_text' ) )
842
- $html .= '<p>' . get_option( 'wcj_pdf_invoices_order_shipping_method_text' ). ': ' . $the_order->get_shipping_method() . '</p>';
843
- // SHIPPING ADDRESS
844
- if ( '' != get_option( 'wcj_pdf_invoices_order_shipping_address_text' ) &&
845
- $the_order->get_formatted_billing_address() != $the_order->get_formatted_shipping_address() )
846
- $html .= '<p>' . get_option( 'wcj_pdf_invoices_order_shipping_address_text' ). ':<br>' . $the_order->get_formatted_shipping_address() . $this->add_custom_checkout_fields_to_pdf( $the_order->id, 'shipping' ) . '</p>';
847
-
848
- return $html;
849
- }
850
-
851
- /**
852
- * get_invoice_html.
853
- */
854
- public function get_invoice_html( $order_id ) {
855
-
856
- // PREPARING DATA //
857
- // General
858
- //$the_order = new WC_Order( $order_id );
859
- $the_order = wc_get_order( $order_id );
860
-
861
-
862
- $html = '';
863
- $html .= $this->get_header( $the_order );
864
- $html .= $this->get_items_table( $the_order );
865
- $html .= $this->get_footer( $the_order );
866
-
867
-
868
-
869
- // ADDITIONAL FOOTER
870
- if ( '' != get_option( 'wcj_pdf_invoices_footer_text' ) ) {
871
- $additional_footer = str_replace( PHP_EOL, '<br>', get_option( 'wcj_pdf_invoices_footer_text' ) );
872
- $additional_footer = apply_filters( 'the_content', $additional_footer );
873
- $html .= '<p>' . $additional_footer . '</p>';
874
- }
875
-
876
- // ADDITIONAL HEADER
877
- if ( '' != get_option( 'wcj_pdf_invoices_additional_header_text' ) ) {
878
- $additional_header = str_replace( PHP_EOL, '<br>', get_option( 'wcj_pdf_invoices_additional_header_text' ) );
879
- $additional_header = apply_filters( 'the_content', $additional_header );
880
- $html = '<p>' . $additional_header . '</p>' . $html;
881
- }
882
-
883
- return $html;
884
- }
885
-
886
- /**
887
- * add_pdf_invoices_link_to_order_list.
888
- */
889
- public function add_pdf_invoices_link_to_order_list( $actions, $the_order ) {
890
- if ( 'no' === get_option( 'wcj_pdf_invoices_save_as_enabled' ) )
891
- $actions['pdf_invoice'] = array(
892
- 'url' => basename( $_SERVER['REQUEST_URI'] ) . '&pdf_invoice=' . $the_order->id,
893
- 'name' => __( 'PDF Invoice', 'woocommerce-jetpack' ),
894
- 'action' => "view pdf_invoice"
895
- );
896
- else
897
- $actions['save_pdf_invoice'] = array(
898
- 'url' => basename( $_SERVER['REQUEST_URI'] ) . '&pdf_invoice=' . $the_order->id . '&save_pdf_invoice=1',
899
- 'name' => __( 'PDF Invoice', 'woocommerce-jetpack' ),
900
- 'action' => "view save_pdf_invoice"
901
- );
902
-
903
- return $actions;
904
- }
905
-
906
- /**
907
- * add_enabled_option.
908
- */
909
- public function add_enabled_option( $settings ) {
910
-
911
- $all_settings = $this->get_settings();
912
- $settings[] = $all_settings[1];
913
-
914
- return $settings;
915
- }
916
-
917
- /**
918
- * get_settings.
919
- */
920
- function get_settings() {
921
-
922
- $settings = array(
923
-
924
- array( 'title' => __( 'PDF Invoices Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_options' ),
925
-
926
- array(
927
- 'title' => __( 'PDF Invoices', 'woocommerce-jetpack' ) . ' V1 - ' . __( 'depreciated', 'woocommerce-jetpack' ),
928
- 'desc' => '<strong>' . __( 'Enable Module', 'woocommerce-jetpack' ) . '</strong>',
929
- 'desc_tip' => __( 'Add PDF invoices for the WooCommerce store owners and for the customers.', 'woocommerce-jetpack' ),
930
- 'id' => 'wcj_pdf_invoices_enabled',
931
- 'default' => 'no',
932
- 'type' => 'checkbox',
933
- ),
934
-
935
- array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_options' ),
936
-
937
- array( 'title' => __( 'Invoice Header', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you set texts for required invoice number and date, and optional logo, header text, invoice due and fulfillment dates.', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_header_options' ),
938
-
939
- array(
940
- 'title' => __( 'Your Logo URL', 'woocommerce-jetpack' ),
941
- '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' ),
942
- 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
943
- 'id' => 'wcj_pdf_invoices_seller_logo_url',
944
- 'default' => '',
945
- 'type' => 'text',
946
- 'css' => 'width:33%;min-width:300px;',
947
- ),
948
-
949
- array(
950
- 'title' => __( 'Header Text', 'woocommerce-jetpack' ),
951
- 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
952
- 'desc' => __( 'Default: INVOICE', 'woocommerce-jetpack' ),
953
- 'id' => 'wcj_pdf_invoices_header_text',
954
- 'default' => __( 'INVOICE', 'woocommerce-jetpack' ),
955
- 'type' => 'text',
956
- 'css' => 'width:33%;min-width:300px;',
957
- ),
958
-
959
- array(
960
- 'title' => __( 'Invoice Number', 'woocommerce-jetpack' ),
961
- 'desc' => __( 'Default: Invoice number', 'woocommerce-jetpack' ),
962
- 'id' => 'wcj_pdf_invoices_invoice_number_text',
963
- 'default' => __( 'Invoice number', 'woocommerce-jetpack' ),
964
- 'type' => 'text',
965
- 'css' => 'width:33%;min-width:300px;',
966
- ),
967
-
968
- array(
969
- 'title' => __( 'Order Date', 'woocommerce-jetpack' ),
970
- 'desc' => __( 'Default: Order date', 'woocommerce-jetpack' ),
971
- 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
972
- 'id' => 'wcj_pdf_invoices_order_date_text',
973
- 'default' => __( 'Order date', 'woocommerce-jetpack' ),
974
- 'type' => 'text',
975
- 'css' => 'width:33%;min-width:300px;',
976
- ),
977
-
978
- array(
979
- 'title' => __( 'Order Time', 'woocommerce-jetpack' ),
980
- 'desc' => __( 'Default: Order time', 'woocommerce-jetpack' ),
981
- 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
982
- 'id' => 'wcj_pdf_invoices_order_time_text',
983
- 'default' => __( 'Order time', 'woocommerce-jetpack' ),
984
- 'type' => 'text',
985
- 'css' => 'width:33%;min-width:300px;',
986
- ),
987
-
988
- array(
989
- 'title' => __( 'Invoice Date', 'woocommerce-jetpack' ),
990
- 'desc' => __( 'Default: Invoice date', 'woocommerce-jetpack' ),
991
- 'id' => 'wcj_pdf_invoices_invoice_date_text',
992
- 'default' => __( 'Invoice date', 'woocommerce-jetpack' ),
993
- 'type' => 'text',
994
- 'css' => 'width:33%;min-width:300px;',
995
- ),
996
-
997
- array(
998
- 'title' => 'Invoice Due Date',
999
- 'desc' => __( 'Default: Invoice due date', 'woocommerce-jetpack' ),
1000
- 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
1001
- 'id' => 'wcj_pdf_invoices_invoice_due_date_text',
1002
- 'default' => __( 'Invoice due date', 'woocommerce-jetpack' ),
1003
- 'type' => 'text',
1004
- 'css' => 'width:33%;min-width:300px;',
1005
- ),
1006
-
1007
- array(
1008
- 'title' => '',
1009
- 'desc' => __( 'days', 'woocommerce-jetpack' ),
1010
- //'desc_tip' => __( 'Set to 0 to disable', 'woocommerce-jetpack' ),
1011
- 'id' => 'wcj_pdf_invoices_invoice_due_date_days',
1012
- 'default' => 0,
1013
- 'type' => 'number',
1014
- 'css' => 'width:33%;min-width:300px;',
1015
- ),
1016
-
1017
- array(
1018
- 'title' => 'Invoice Fulfillment Date',
1019
- 'desc' => __( 'Default: Invoice fulfillment date', 'woocommerce-jetpack' ),
1020
- 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
1021
- 'id' => 'wcj_pdf_invoices_invoice_fulfillment_date_text',
1022
- 'default' => __( 'Invoice fulfillment date', 'woocommerce-jetpack' ),
1023
- 'type' => 'text',
1024
- 'css' => 'width:33%;min-width:300px;',
1025
- ),
1026
-
1027
- array(
1028
- 'title' => '',
1029
- 'desc' => __( 'days', 'woocommerce-jetpack' ),
1030
- //'desc_tip' => __( 'Set to 0 to disable', 'woocommerce-jetpack' ),
1031
- 'id' => 'wcj_pdf_invoices_invoice_fulfillment_date_days',
1032
- 'default' => 0,
1033
- 'type' => 'number',
1034
- 'css' => 'width:33%;min-width:300px;',
1035
- ),
1036
-
1037
- array(
1038
- 'title' => __( 'Additional Header', 'woocommerce-jetpack' ),
1039
- 'desc_tip' => __( 'Additional header - will be displayed above all data on invoice. You can use html and/or shortcodes here.', 'woocommerce-jetpack' ),
1040
- 'id' => 'wcj_pdf_invoices_additional_header_text',
1041
- 'default' => '',
1042
- 'type' => 'textarea',
1043
- 'css' => 'width:33%;min-width:300px;min-height:300px;',
1044
- ),
1045
-
1046
- array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_header_options' ),
1047
-
1048
- array( 'title' => __( 'Seller and Buyer Info', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_seller_and_buyer_options' ),
1049
-
1050
- array(
1051
- 'title' => __( 'Seller', 'woocommerce-jetpack' ),
1052
- //'desc_tip' => __( 'Seller text', 'woocommerce-jetpack' ),
1053
- 'id' => 'wcj_pdf_invoices_seller_text',
1054
- 'default' => __( 'Seller', 'woocommerce-jetpack' ),
1055
- 'type' => 'text',
1056
- 'css' => 'width:33%;min-width:300px;',
1057
- ),
1058
-
1059
- array(
1060
- 'title' => __( 'Your business information', 'woocommerce-jetpack' ),
1061
- //'desc_tip' => __( 'Seller information', 'woocommerce-jetpack' ),
1062
- 'desc' => __( 'New lines are added automatically.', 'woocommerce-jetpack' ),
1063
- 'id' => 'wcj_pdf_invoices_seller_info',
1064
- 'default' => __( '<strong>Company Name</strong>', 'woocommerce-jetpack' ),
1065
- 'type' => 'textarea',
1066
- 'css' => 'width:33%;min-width:300px;min-height:300px;',
1067
- ),
1068
-
1069
- array(
1070
- 'title' => __( 'Buyer', 'woocommerce-jetpack' ),
1071
- //'desc_tip' => __( 'Buyer text', 'woocommerce-jetpack' ),
1072
- 'id' => 'wcj_pdf_invoices_buyer_text',
1073
- 'default' => __( 'Buyer', 'woocommerce-jetpack' ),
1074
- 'type' => 'text',
1075
- 'css' => 'width:33%;min-width:300px;',
1076
- ),
1077
-
1078
- array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_seller_and_buyer_options' ),
1079
-
1080
- array( 'title' => __( 'Items', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_items_options' ),
1081
-
1082
- array(
1083
- 'title' => __( 'Items Table Heading Text', 'woocommerce-jetpack' ),
1084
- //'desc_tip' => __( 'Items text', 'woocommerce-jetpack' ),
1085
- 'id' => 'wcj_pdf_invoices_items_text',
1086
- 'default' => __( 'Items', 'woocommerce-jetpack' ),
1087
- 'type' => 'text',
1088
- 'css' => 'width:33%;min-width:300px;',
1089
- ),
1090
-
1091
- array(
1092
- 'title' => __( 'Shipping as Item', 'woocommerce-jetpack' ),
1093
- 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
1094
- 'desc' => __( 'Display shipping as item', 'woocommerce-jetpack' ),
1095
- //'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
1096
- 'id' => 'wcj_pdf_invoices_display_shipping_as_item_text',
1097
- 'default' => '',
1098
- 'type' => 'text',
1099
- //'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
1100
- ),
1101
-
1102
- /*array(
1103
- 'title' => '',
1104
- 'desc' => __( 'Add shipping method info', 'woocommerce-jetpack' ),
1105
- 'id' => 'wcj_pdf_invoices_display_shipping_as_item_method_enabled',
1106
- 'default' => 'yes',
1107
- 'type' => 'checkbox',
1108
- ),*/
1109
-
1110
- array(
1111
- 'title' => '',
1112
- 'desc' => __( 'Add shipping method info', 'woocommerce-jetpack' ),
1113
- 'id' => 'wcj_pdf_invoices_display_shipping_as_item_shipping_method',
1114
- 'css' => 'min-width:350px;',
1115
- 'class' => 'chosen_select',
1116
- 'default' => 'no',
1117
- 'type' => 'select',
1118
- 'options' => array(
1119
- 'no' => __( 'Do not add shipping method info', 'woocommerce-jetpack' ),
1120
- 'yes' => __( 'Add shipping method info', 'woocommerce-jetpack' ),
1121
- 'replace' => __( 'Replace with shipping method info', 'woocommerce-jetpack' ),
1122
- ),
1123
- 'desc_tip' => true,
1124
- ),
1125
-
1126
- array(
1127
- 'title' => __( 'Discount as Item', 'woocommerce-jetpack' ),
1128
- 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
1129
- 'desc' => __( 'Display discount as item', 'woocommerce-jetpack' ),
1130
- //'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
1131
- 'id' => 'wcj_pdf_invoices_display_discount_as_item_text',
1132
- 'default' => '',
1133
- 'type' => 'text',
1134
- //'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
1135
- ),
1136
-
1137
- array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_items_options' ),
1138
-
1139
- array( 'title' => __( 'Items Columns', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you set column names in invoice items table. You can disable some columns by leaving blank column name.', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_items_columns_options' ),
1140
-
1141
- array(
1142
- 'title' => __( 'Nr.', 'woocommerce-jetpack' ),
1143
- //'desc_tip' => __( 'Nr. text', 'woocommerce-jetpack' ),
1144
- 'id' => 'wcj_pdf_invoices_column_nr_text',
1145
- 'default' => __( 'Nr.', 'woocommerce-jetpack' ),
1146
- 'type' => 'text',
1147
- 'css' => 'width:33%;min-width:300px;',
1148
- ),
1149
-
1150
- array(
1151
- 'title' => __( 'Item Name', 'woocommerce-jetpack' ),
1152
- //'desc_tip' => __( 'Item name text', 'woocommerce-jetpack' ),
1153
- 'id' => 'wcj_pdf_invoices_column_item_name_text',
1154
- 'default' => __( 'Item Name', 'woocommerce-jetpack' ),
1155
- 'type' => 'text',
1156
- 'css' => 'width:33%;min-width:300px;',
1157
- ),
1158
-
1159
- array(
1160
- 'title' => __( 'Item Name Additional Info', 'woocommerce-jetpack' ),
1161
- 'desc_tip' => __( 'Here you can add more info to item\'s name column (e.g. sku). Default is (SKU: %sku%)', 'woocommerce-jetpack' ),
1162
- 'id' => 'wcj_pdf_invoices_column_item_name_additional_text',
1163
- 'default' => __( '(SKU: %sku%)', 'woocommerce-jetpack' ),
1164
- 'type' => 'textarea',
1165
- 'css' => 'width:33%;min-width:300px;',
1166
- ),
1167
-
1168
- array(
1169
- 'title' => __( 'Qty', 'woocommerce-jetpack' ),
1170
- //'desc_tip' => __( 'Qty text', 'woocommerce-jetpack' ),
1171
- 'id' => 'wcj_pdf_invoices_column_qty_text',
1172
- 'default' => __( 'Qty', 'woocommerce-jetpack' ),
1173
- 'type' => 'text',
1174
- 'css' => 'width:33%;min-width:300px;',
1175
- ),
1176
-
1177
- array(
1178
- 'title' => __( 'Single Item Price (TAX excl.)', 'woocommerce-jetpack' ),
1179
- 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
1180
- 'id' => 'wcj_pdf_invoices_column_single_price_tax_excl_text',
1181
- 'default' => __( 'Price (TAX excl.)', 'woocommerce-jetpack' ),
1182
- 'type' => 'text',
1183
- 'css' => 'width:33%;min-width:300px;',
1184
- ),
1185
-
1186
- array(
1187
- 'title' => __( 'Single Item TAX', 'woocommerce-jetpack' ),
1188
- 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
1189
- 'id' => 'wcj_pdf_invoices_column_single_price_tax_text',
1190
- 'default' => __( 'TAX', 'woocommerce-jetpack' ),
1191
- 'type' => 'text',
1192
- 'css' => 'width:33%;min-width:300px;',
1193
- ),
1194
-
1195
- array(
1196
- 'title' => __( 'Single Item Price (TAX incl.)', 'woocommerce-jetpack' ),
1197
- 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
1198
- 'id' => 'wcj_pdf_invoices_column_single_price_tax_incl_text',
1199
- 'default' => __( 'Price (TAX incl.)', 'woocommerce-jetpack' ),
1200
- 'type' => 'text',
1201
- 'css' => 'width:33%;min-width:300px;',
1202
- ),
1203
-
1204
- array(
1205
- 'title' => __( 'Sum (TAX excl.)', 'woocommerce-jetpack' ),
1206
- 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
1207
- 'id' => 'wcj_pdf_invoices_column_price_tax_excl_text',
1208
- 'default' => __( 'Sum (TAX excl.)', 'woocommerce-jetpack' ),
1209
- 'type' => 'text',
1210
- 'css' => 'width:33%;min-width:300px;',
1211
- ),
1212
-
1213
- array(
1214
- 'title' => __( 'Tax Percent', 'woocommerce-jetpack' ),
1215
- 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
1216
- 'id' => 'wcj_pdf_invoices_column_price_tax_percent',
1217
- 'default' => __( 'Taxes %', 'woocommerce-jetpack' ),
1218
- 'type' => 'text',
1219
- 'css' => 'width:33%;min-width:300px;',
1220
- ),
1221
-
1222
- array(
1223
- 'title' => __( 'Taxes', 'woocommerce-jetpack' ),
1224
- 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
1225
- 'id' => 'wcj_pdf_invoices_column_price_tax_text',
1226
- 'default' => __( 'Taxes', 'woocommerce-jetpack' ),
1227
- 'type' => 'text',
1228
- 'css' => 'width:33%;min-width:300px;',
1229
- ),
1230
-
1231
- array(
1232
- 'title' => __( 'Sum (TAX incl.)', 'woocommerce-jetpack' ),
1233
- //'desc_tip' => __( 'Price text', 'woocommerce-jetpack' ),
1234
- 'id' => 'wcj_pdf_invoices_column_price_text',
1235
- 'default' => __( 'Sum (TAX incl.)', 'woocommerce-jetpack' ),
1236
- 'type' => 'text',
1237
- 'css' => 'width:33%;min-width:300px;',
1238
- ),
1239
-
1240
- array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_items_columns_options' ),
1241
-
1242
- array( 'title' => __( 'Totals', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you set texts for totals table.', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_totals_options' ),
1243
-
1244
- array(
1245
- 'title' => __( 'Order Subtotal', 'woocommerce-jetpack' ),
1246
- 'desc_tip' => __( 'Order Subtotal = Total - Taxes - Shipping - Discounts', 'woocommerce-jetpack' ),
1247
- 'id' => 'wcj_pdf_invoices_order_subtotal_text',
1248
- 'default' => __( 'Order Subtotal', 'woocommerce-jetpack' ),
1249
- 'type' => 'text',
1250
- 'css' => 'width:33%;min-width:300px;',
1251
- ),
1252
-
1253
- array(
1254
- 'title' => __( 'Order Shipping Price', 'woocommerce-jetpack' ),
1255
- //'desc_tip' => __( 'Order Shipping text', 'woocommerce-jetpack' ),
1256
- 'id' => 'wcj_pdf_invoices_order_shipping_text',
1257
- 'default' => __( 'Shipping', 'woocommerce-jetpack' ),
1258
- 'type' => 'text',
1259
- 'css' => 'width:33%;min-width:300px;',
1260
- ),
1261
-
1262
- array(
1263
- 'title' => __( 'Total Discount', 'woocommerce-jetpack' ),
1264
- //'desc_tip' => __( 'Total Discount text', 'woocommerce-jetpack' ),
1265
- 'id' => 'wcj_pdf_invoices_order_discount_text',
1266
- 'default' => __( 'Discount', 'woocommerce-jetpack' ),
1267
- 'type' => 'text',
1268
- 'css' => 'width:33%;min-width:300px;',
1269
- ),
1270
-
1271
- array(
1272
- 'title' => __( 'Order Total (TAX excl.)', 'woocommerce-jetpack' ),
1273
- 'desc_tip' => __( 'Order Total (TAX excl.) = Total - Taxes. Shown only if discount or shipping is not equal to zero. In other words: if "Order Total (TAX excl.)" not equal to "Order Subtotal"', 'woocommerce-jetpack' ),
1274
- 'id' => 'wcj_pdf_invoices_order_total_excl_tax_text',
1275
- 'default' => __( 'Order Total (TAX excl.)', 'woocommerce-jetpack' ),
1276
- 'type' => 'text',
1277
- 'css' => 'width:33%;min-width:300px;',
1278
- ),
1279
-
1280
- array(
1281
- 'title' => __( 'Order Total Taxes', 'woocommerce-jetpack' ),
1282
- //'desc_tip' => __( 'Order Subtotal = Total - Taxes - Shipping - Discounts', 'woocommerce-jetpack' ),
1283
- 'id' => 'wcj_pdf_invoices_order_total_tax_text',
1284
- 'default' => __( 'Taxes', 'woocommerce-jetpack' ),
1285
- 'type' => 'text',
1286
- 'css' => 'width:33%;min-width:300px;',
1287
- ),
1288
-
1289
- array(
1290
- 'title' => __( 'Order Total', 'woocommerce-jetpack' ),
1291
- //'desc_tip' => __( 'Order Total text', 'woocommerce-jetpack' ),
1292
- 'id' => 'wcj_pdf_invoices_order_total_text',
1293
- 'default' => __( 'Order Total', 'woocommerce-jetpack' ),
1294
- 'type' => 'text',
1295
- 'css' => 'width:33%;min-width:300px;',
1296
- ),
1297
-
1298
- array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_totals_options' ),
1299
-
1300
- array( 'title' => __( 'Footer', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_footer_options' ),
1301
-
1302
- array(
1303
- 'title' => __( 'Payment Method', 'woocommerce-jetpack' ),
1304
- 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
1305
- 'id' => 'wcj_pdf_invoices_order_payment_method_text',
1306
- 'default' => __( 'Payment Method', 'woocommerce-jetpack' ),
1307
- 'type' => 'text',
1308
- 'css' => 'width:33%;min-width:300px;',
1309
- ),
1310
-
1311
- array(
1312
- 'title' => __( 'Shipping Method', 'woocommerce-jetpack' ),
1313
- 'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
1314
- 'id' => 'wcj_pdf_invoices_order_shipping_method_text',
1315
- 'default' => __( 'Shipping Method', 'woocommerce-jetpack' ),
1316
- 'type' => 'text',
1317
- 'css' => 'width:33%;min-width:300px;',
1318
- ),
1319
-
1320
- array(
1321
- 'title' => __( 'Shipping Address', 'woocommerce-jetpack' ),
1322
- 'desc_tip' => __( 'Will be displayed only if customer\'s shipping address differs from billing address. Leave blank to disable', 'woocommerce-jetpack' ),
1323
- 'id' => 'wcj_pdf_invoices_order_shipping_address_text',
1324
- 'default' => __( 'Shipping Address', 'woocommerce-jetpack' ),
1325
- 'type' => 'text',
1326
- 'css' => 'width:33%;min-width:300px;',
1327
- ),
1328
-
1329
- array(
1330
- 'title' => __( 'Additional Footer', 'woocommerce-jetpack' ),
1331
- 'desc_tip' => __( 'Additional footer - will be displayed below all other data on invoice. You can use html and/or shortcodes here.', 'woocommerce-jetpack' ),
1332
- 'id' => 'wcj_pdf_invoices_footer_text',
1333
- 'default' => '',
1334
- 'type' => 'textarea',
1335
- 'css' => 'width:33%;min-width:300px;min-height:300px;',
1336
- ),
1337
-
1338
- array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_footer_options' ),
1339
-
1340
- array( 'title' => __( 'General Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_general_options' ),
1341
-
1342
- array(
1343
- 'title' => __( 'Font Family', 'woocommerce-jetpack' ),
1344
- //'desc' => __( 'Default: dejavusans', 'woocommerce-jetpack' ),
1345
- 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
1346
- 'id' => 'wcj_pdf_invoices_general_font_family',
1347
- 'default' => 'dejavusans',
1348
- 'type' => 'select',
1349
- 'options' => array(
1350
- 'dejavusans' => 'DejaVu Sans',
1351
- 'courier' => 'Courier',
1352
- 'helvetica' => 'Helvetica',
1353
- 'times' => 'Times',
1354
- ),
1355
- 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
1356
- ),
1357
-
1358
- array(
1359
- 'title' => __( 'Font Size', 'woocommerce-jetpack' ),
1360
- 'desc' => __( 'Default: 8', 'woocommerce-jetpack' ),
1361
- 'id' => 'wcj_pdf_invoices_general_font_size',
1362
- 'default' => 8,
1363
- 'type' => 'number',
1364
- ),
1365
-
1366
- array(
1367
- 'title' => __( 'Make Font Shadowed', 'woocommerce-jetpack' ),
1368
- 'desc' => __( 'Default: Yes', 'woocommerce-jetpack' ),
1369
- 'id' => 'wcj_pdf_invoices_general_font_shadowed',
1370
- 'default' => 'yes',
1371
- 'type' => 'checkbox',
1372
- ),
1373
-
1374
- array(
1375
- 'title' => __( 'CSS', 'woocommerce-jetpack' ),
1376
- 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
1377
- 'id' => 'wcj_pdf_invoices_general_css',
1378
- 'default' => $this->default_css,
1379
- 'type' => 'textarea',
1380
- 'css' => 'width:66%;min-width:300px;min-height:300px;',
1381
- 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
1382
- ),
1383
-
1384
- //array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_general_options' ),
1385
-
1386
- //array( 'title' => __( 'More Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_pdf_invoices_more_options' ),
1387
-
1388
- array(
1389
- 'title' => __( 'PDF Invoices for Customers (in My Account)', 'woocommerce-jetpack' ),
1390
- 'desc' => __( 'Enable the PDF Invoices in customers account', 'woocommerce-jetpack' ),
1391
- 'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
1392
- 'id' => 'wcj_pdf_invoices_enabled_for_customers',
1393
- 'default' => 'no',
1394
- 'type' => 'checkbox',
1395
- 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
1396
- ),
1397
-
1398
- array(
1399
- 'title' => __( 'PDF Invoices for Customers (Email attachment)', 'woocommerce-jetpack' ),
1400
- 'desc' => __( 'Enable the PDF Invoices attachment files in customers email on order completed', 'woocommerce-jetpack' ),
1401
- 'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
1402
- 'id' => 'wcj_pdf_invoices_attach_to_email_enabled',
1403
- 'default' => 'no',
1404
- 'type' => 'checkbox',
1405
- 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
1406
- ),
1407
-
1408
- /* array(
1409
- 'title' => __( '', 'woocommerce-jetpack' ),
1410
- 'desc' => __( 'Attach PDF invoice only on customer\'s request', 'woocommerce-jetpack' ),
1411
- 'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
1412
- 'id' => 'wcj_pdf_invoices_attach_to_email_on_request_only',
1413
- 'default' => 'no',
1414
- 'type' => 'checkbox',
1415
- 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
1416
- ), */
1417
-
1418
- array(
1419
- 'title' => __( 'Enable Save as', 'woocommerce-jetpack' ),
1420
- 'desc' => __( 'Enable save as pdf instead of view pdf', 'woocommerce-jetpack' ),
1421
- //'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
1422
- 'id' => 'wcj_pdf_invoices_save_as_enabled',
1423
- 'default' => 'yes',
1424
- 'type' => 'checkbox',
1425
- //'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
1426
- ),
1427
-
1428
- //array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_more_options' ),
1429
- array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_general_options' ),
1430
- );
1431
-
1432
- return $settings;
1433
- }
1434
-
1435
- /**
1436
- * settings_section.
1437
- *
1438
- * @version 2.3.10
1439
- */
1440
- function settings_section( $sections ) {
1441
- $sections['pdf_invoices'] = __( 'PDF Invoices', 'woocommerce-jetpack' ) . ' v1 - <em>' . __( 'Depreciated', 'woocommerce-jetpack' ) . '</em>';
1442
- return $sections;
1443
- }
1444
- }
1445
-
1446
- endif;
1447
-
1448
- return new WCJ_PDF_Invoices();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-wcj-pdf-invoicing.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing class.
6
  *
7
- * @version 2.3.10
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -45,8 +45,6 @@ class WCJ_PDF_Invoicing extends WCJ_Module {
45
 
46
  $this->the_pdf_invoicing_report_tool = include_once( 'pdf-invoices/class-wcj-pdf-invoicing-report-tool.php' );
47
 
48
- // define ( 'K_PATH_IMAGES', $_SERVER['DOCUMENT_ROOT'] );
49
-
50
  $invoice_types = wcj_get_enabled_invoice_types();
51
  foreach ( $invoice_types as $invoice_type ) {
52
  $the_hook = get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_create_on', 'woocommerce_new_order' );
@@ -54,11 +52,6 @@ class WCJ_PDF_Invoicing extends WCJ_Module {
54
  add_action( $the_hook, array( $this, 'create_' . $invoice_type['id'] ) );
55
  }
56
  }
57
-
58
- /* $this->meta_box_screen = 'shop_order';
59
- $this->meta_box_context = 'side';
60
- $this->meta_box_priority = 'default';
61
- add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ) ); */
62
  }
63
  }
64
 
@@ -69,7 +62,6 @@ class WCJ_PDF_Invoicing extends WCJ_Module {
69
  * @since 2.3.10
70
  */
71
  function create_invoices_report_tool() {
72
- //$the_tool = include_once( 'pdf-invoices/class-wcj-pdf-invoicing-report-tool.php' );
73
  return $this->the_pdf_invoicing_report_tool->create_invoices_report_tool();
74
  }
75
 
@@ -85,45 +77,6 @@ class WCJ_PDF_Invoicing extends WCJ_Module {
85
  }
86
 
87
  /**
88
- * create_meta_box.
89
- *
90
- * @version 2.3.0
91
- * @since 2.3.0
92
- */
93
- /* public function create_meta_box() {
94
-
95
- $current_post_id = get_the_ID();
96
-
97
- $html = '';
98
- $html .= '<table>';
99
- $invoice_types = wcj_get_invoice_types();
100
- foreach ( $invoice_types as $invoice_type ) {
101
- $the_hook = get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_create_on', 'woocommerce_new_order' );
102
- if ( 'disabled' != $the_hook && '' != $the_hook ) {
103
- $html .= '<tr>';
104
-
105
- $html .= '<th style="text-align:left;">';
106
- $html .= $invoice_type['title'];
107
- $html .= '</th>';
108
-
109
- $html .= '<td style="text-align:right;">';
110
- $html .= '<a href="';
111
- if ( false == wcj_is_invoice_created( $current_post_id, $invoice_type['id'] ) ) {
112
- $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' ) );
113
- $html .= '">' . __( 'Create', 'woocommerce-jetpack' ) . '</a>';
114
- } else {
115
- $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' ) );
116
- $html .= '">' . __( 'Delete', 'woocommerce-jetpack' ) . '</a>';
117
- }
118
- $html .= '</td>';
119
-
120
- $html .= '</tr>';
121
- }
122
- }
123
- $html .= '</table>';
124
- echo $html;
125
- } */
126
-
127
  * create_invoice.
128
  */
129
  function create_invoice( $order_id ) {
@@ -164,22 +117,9 @@ class WCJ_PDF_Invoicing extends WCJ_Module {
164
  * create_document.
165
  */
166
  function create_document( $order_id, $invoice_type ) {
167
-
168
  if ( false == wcj_is_invoice_created( $order_id, $invoice_type ) ) {
169
  wcj_create_invoice( $order_id, $invoice_type );
170
  }
171
- /*
172
- if ( '' == get_post_meta( $order_id, '_wcj_invoicing_' . $invoice_type . '_number', true ) ) {
173
- if ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type . '_sequential_enabled' ) ) {
174
- $the_invoice_number = get_option( 'wcj_invoicing_' . $invoice_type . '_numbering_counter', 1 );
175
- update_option( 'wcj_invoicing_' . $invoice_type . '_numbering_counter', ( $the_invoice_number + 1 ) );
176
- } else {
177
- $the_invoice_number = $order_id;
178
- }
179
- update_post_meta( $order_id, '_wcj_invoicing_' . $invoice_type . '_number', $the_invoice_number );
180
- update_post_meta( $order_id, '_wcj_invoicing_' . $invoice_type . '_date', time() );
181
- }
182
- */
183
  }
184
 
185
  /**
@@ -217,28 +157,32 @@ class WCJ_PDF_Invoicing extends WCJ_Module {
217
  function generate_pdf_on_init() {
218
 
219
  // Check if all is OK
220
- if ( ( true !== $this->get_invoice ) ||
221
- ( 0 == $this->order_id ) ||
222
- ( ! is_user_logged_in() ) ||
223
- ( ! current_user_can( 'administrator' ) && ! is_shop_manager() && get_current_user_id() != intval( get_post_meta( $this->order_id, '_customer_user', true ) ) ) )
 
 
224
  return;
 
225
 
226
  $the_invoice = wcj_get_pdf_invoice( $this->order_id, $this->invoice_type_id );
227
- // $invoice = new WCJ_PDF_Invoice();
228
  $dest = ( true === $this->save_as_pdf ) ? 'D' : 'I';
229
- // $invoice->get_pdf( $this->order_id, $this->invoice_type_id, '', $dest );//, $this->invoice_type_id );
230
  $the_invoice->get_pdf( $dest );
231
- // echo $invoice_html;
232
  }
233
 
234
  * get_settings.
235
  *
236
- * @version 2.3.10
237
  */
238
  function get_settings() {
239
 
240
  $settings = array(
241
- array( 'title' => __( 'PDF Invoicing General Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_pdf_invoicing_options' ),
 
 
 
 
242
  );
243
 
244
  // Hooks Array
@@ -262,12 +206,22 @@ class WCJ_PDF_Invoicing extends WCJ_Module {
262
  'class' => 'chosen_select',
263
  'options' => $create_on_array,
264
  'desc' => ( 0 === $k ) ? '' : apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
265
- 'custom_attributes'
266
- => ( 0 === $k ) ? '' : apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
267
  );
268
  }
269
 
270
- $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoicing_options' );
 
 
 
 
 
 
 
 
 
 
 
271
 
272
  return $this->add_standard_settings( $settings );
273
  }
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
45
 
46
  $this->the_pdf_invoicing_report_tool = include_once( 'pdf-invoices/class-wcj-pdf-invoicing-report-tool.php' );
47
 
 
 
48
  $invoice_types = wcj_get_enabled_invoice_types();
49
  foreach ( $invoice_types as $invoice_type ) {
50
  $the_hook = get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_create_on', 'woocommerce_new_order' );
52
  add_action( $the_hook, array( $this, 'create_' . $invoice_type['id'] ) );
53
  }
54
  }
 
 
 
 
 
55
  }
56
  }
57
 
62
  * @since 2.3.10
63
  */
64
  function create_invoices_report_tool() {
 
65
  return $this->the_pdf_invoicing_report_tool->create_invoices_report_tool();
66
  }
67
 
77
  }
78
 
79
  /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  * create_invoice.
81
  */
82
  function create_invoice( $order_id ) {
117
  * create_document.
118
  */
119
  function create_document( $order_id, $invoice_type ) {
 
120
  if ( false == wcj_is_invoice_created( $order_id, $invoice_type ) ) {
121
  wcj_create_invoice( $order_id, $invoice_type );
122
  }
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
124
 
125
  /**
157
  function generate_pdf_on_init() {
158
 
159
  // Check if all is OK
160
+ if (
161
+ ( true !== $this->get_invoice ) ||
162
+ ( 0 == $this->order_id ) ||
163
+ ( ! is_user_logged_in() ) ||
164
+ ( ! current_user_can( 'administrator' ) && ! is_shop_manager() && get_current_user_id() != intval( get_post_meta( $this->order_id, '_customer_user', true ) ) )
165
+ ) {
166
  return;
167
+ }
168
 
169
  $the_invoice = wcj_get_pdf_invoice( $this->order_id, $this->invoice_type_id );
 
170
  $dest = ( true === $this->save_as_pdf ) ? 'D' : 'I';
 
171
  $the_invoice->get_pdf( $dest );
 
172
  }
173
 
174
  * get_settings.
175
  *
176
+ * @version 2.4.0
177
  */
178
  function get_settings() {
179
 
180
  $settings = array(
181
+ array(
182
+ 'title' => __( 'PDF Invoicing General Options', 'woocommerce-jetpack' ),
183
+ 'type' => 'title',
184
+ 'id' => 'wcj_pdf_invoicing_options',
185
+ ),
186
  );
187
 
188
  // Hooks Array
206
  'class' => 'chosen_select',
207
  'options' => $create_on_array,
208
  'desc' => ( 0 === $k ) ? '' : apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
209
+ 'custom_attributes' => ( 0 === $k ) ? '' : apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
 
210
  );
211
  }
212
 
213
+ $settings[] = array(
214
+ 'title' => __( 'Hide Disabled Docs Settings', 'woocommerce-jetpack' ),
215
+ 'desc' => __( 'Hide', 'woocommerce-jetpack' ),
216
+ 'id' => 'wcj_invoicing_hide_disabled_docs_settings',
217
+ 'default' => 'no',
218
+ 'type' => 'checkbox',
219
+ );
220
+
221
+ $settings[] = array(
222
+ 'type' => 'sectionend',
223
+ 'id' => 'wcj_pdf_invoicing_options',
224
+ );
225
 
226
  return $this->add_standard_settings( $settings );
227
  }
includes/class-wcj-product-bulk-price-converter.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Bulk Price Converter class.
6
  *
7
- * @version 2.3.10
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -37,78 +37,116 @@ class WCJ_Bulk_Price_Converter extends WCJ_Module {
37
  /**
38
  * change_price_by_type.
39
  *
40
- * @version 2.3.0
41
  */
42
- public function change_price_by_type( $product_id, $multiply_price_by, $price_type, $is_preview ) {
43
  $the_price = get_post_meta( $product_id, '_' . $price_type, true );
44
  $the_modified_price = $the_price;
45
  if ( '' != $the_price ) {
46
  $precision = get_option( 'woocommerce_price_num_decimals', 2 );
47
  $the_modified_price = round( $the_price * $multiply_price_by, $precision );
48
- /*if ( isset( $_POST['make_pretty_prices'] ) )
49
- $the_modified_price = $this->make_pretty_price( $the_modified_price );*/
50
- if ( ! $is_preview )
51
  update_post_meta( $product_id, '_' . $price_type, $the_modified_price );
 
52
  }
53
 
 
 
 
 
 
 
 
54
  echo '<tr>' .
55
- '<td>' . get_the_title( $product_id ) . '</td>' .
56
- '<td><em>' . $price_type . '</em></td>' .
57
- '<td>' . $the_price . '</td>' .
58
- '<td>' . $the_modified_price . '</td>' .
59
- '</tr>';
 
60
  }
61
 
62
  /**
63
  * change_price_all_types.
 
 
64
  */
65
- public function change_price_all_types( $product_id, $multiply_price_by, $is_preview ) {
66
- $this->change_price_by_type( $product_id, $multiply_price_by, 'price', $is_preview );
67
- $this->change_price_by_type( $product_id, $multiply_price_by, 'sale_price', $is_preview );
68
- $this->change_price_by_type( $product_id, $multiply_price_by, 'regular_price', $is_preview );
69
  }
70
 
71
  /**
72
  * change_product_price.
 
 
73
  */
74
  public function change_product_price( $product_id, $multiply_price_by, $is_preview ) {
75
- $this->change_price_all_types( $product_id, $multiply_price_by, $is_preview );
76
  // Handling variable products
77
  $product = wc_get_product( $product_id );
78
  if ( $product->is_type( 'variable' ) ) {
79
  $variations = $product->get_available_variations();
80
  foreach( $variations as $variation ) {
81
- $this->change_price_all_types( $variation['variation_id'], $multiply_price_by, $is_preview );
82
  }
83
  }
84
  }
85
 
86
  /**
87
  * change_all_products_prices
 
 
88
  */
89
  public function change_all_products_prices( $multiply_prices_by, $is_preview ) {
90
  $multiply_prices_by = floatval( $multiply_prices_by );
91
- if ( $multiply_prices_by <= 0 )
92
  return;
 
93
 
94
  ob_start();
95
 
96
- $args = array(
97
- 'post_type' => 'product',
98
- 'post_status' => 'any',
99
- 'posts_per_page' => -1,
100
- );
101
- $loop = new WP_Query( $args );
102
- echo '<table class="widefat" style="width:50%; min-width: 300px;">';
103
  echo '<tr>' .
104
- '<th>' . __( 'Product', 'woocommerce-jetpack' ) . '</th>' .
105
- '<th>' . __( 'Price Type', 'woocommerce-jetpack' ) . '</th>' .
106
- '<th>' . __( 'Price', 'woocommerce-jetpack' ) . '</th>' .
 
107
  '<th>' . __( 'Modified Price', 'woocommerce-jetpack' ) . '</th>' .
108
- '</tr>';
109
- while ( $loop->have_posts() ) : $loop->the_post();
110
- $this->change_product_price( $loop->post->ID, $multiply_prices_by, $is_preview );
111
- endwhile;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  echo '</table>';
113
 
114
  return ob_get_clean();
@@ -117,12 +155,10 @@ class WCJ_Bulk_Price_Converter extends WCJ_Module {
117
  /**
118
  * create_bulk_price_converter_tool.
119
  *
120
- * @version 2.3.0
121
  */
122
  public function create_bulk_price_converter_tool() {
123
 
124
- echo $this->get_back_to_settings_link_html();
125
-
126
  $result_message = '';
127
 
128
  $multiply_prices_by = isset( $_POST['multiply_prices_by'] ) ? $_POST['multiply_prices_by'] : 1;
@@ -143,18 +179,50 @@ class WCJ_Bulk_Price_Converter extends WCJ_Module {
143
  }
144
  }
145
  }
146
- ?>
147
- <div>
148
- <?php echo $result_message; ?>
149
- <p><form method="post" action="">
150
- <?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; ?>">
151
- <input class="button-primary" type="submit" name="bulk_change_prices_preview" id="bulk_change_prices_preview" value="Preview Prices">
152
- <?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 } ?>
153
- <?php /*<input type="checkbox" name="make_pretty_prices" id="make_pretty_prices" value="">Make Pretty Prices*/ ?>
154
- </form></p>
155
- <?php if ( $is_preview ) echo $result_changing_prices; ?>
156
- </div>
157
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  }
159
 
160
 
@@ -215,16 +283,6 @@ class WCJ_Bulk_Price_Converter extends WCJ_Module {
215
  return $the_multiplied_price;
216
  } */
217
 
218
- /**
219
- * get_settings.
220
- *
221
- * @version 2.3.0
222
- */
223
- function get_settings() {
224
- $settings = array();
225
- $settings = $this->add_tools_list( $settings );
226
- return $this->add_enable_module_setting( $settings );
227
- }
228
  }
229
 
230
  endif;
4
  *
5
  * The WooCommerce Jetpack Bulk Price Converter class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
37
  /**
38
  * change_price_by_type.
39
  *
40
+ * @version 2.4.0
41
  */
42
+ public function change_price_by_type( $product_id, $multiply_price_by, $price_type, $is_preview, $parent_product_id ) {
43
  $the_price = get_post_meta( $product_id, '_' . $price_type, true );
44
  $the_modified_price = $the_price;
45
  if ( '' != $the_price ) {
46
  $precision = get_option( 'woocommerce_price_num_decimals', 2 );
47
  $the_modified_price = round( $the_price * $multiply_price_by, $precision );
48
+ /* if ( isset( $_POST['make_pretty_prices'] ) )
49
+ $the_modified_price = $this->make_pretty_price( $the_modified_price ); */
50
+ if ( ! $is_preview ) {
51
  update_post_meta( $product_id, '_' . $price_type, $the_modified_price );
52
+ }
53
  }
54
 
55
+ $product_cats = array();
56
+ $product_terms = get_the_terms( $parent_product_id, 'product_cat' );
57
+ if ( is_array( $product_terms ) ) {
58
+ foreach ( $product_terms as $term ) {
59
+ $product_cats[] = esc_html( $term->name );
60
+ }
61
+ }
62
  echo '<tr>' .
63
+ '<td>' . get_the_title( $product_id ) . '</td>' .
64
+ '<td>' . implode( ', ', $product_cats ) . '</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
+ *
74
+ * @version 2.4.0
75
  */
76
+ public function change_price_all_types( $product_id, $multiply_price_by, $is_preview, $parent_product_id ) {
77
+ $this->change_price_by_type( $product_id, $multiply_price_by, 'price', $is_preview, $parent_product_id );
78
+ $this->change_price_by_type( $product_id, $multiply_price_by, 'sale_price', $is_preview, $parent_product_id );
79
+ $this->change_price_by_type( $product_id, $multiply_price_by, 'regular_price', $is_preview, $parent_product_id );
80
  }
81
 
82
  /**
83
  * change_product_price.
84
+ *
85
+ * @version 2.4.0
86
  */
87
  public function change_product_price( $product_id, $multiply_price_by, $is_preview ) {
88
+ $this->change_price_all_types( $product_id, $multiply_price_by, $is_preview, $product_id );
89
  // Handling variable products
90
  $product = wc_get_product( $product_id );
91
  if ( $product->is_type( 'variable' ) ) {
92
  $variations = $product->get_available_variations();
93
  foreach( $variations as $variation ) {
94
+ $this->change_price_all_types( $variation['variation_id'], $multiply_price_by, $is_preview, $product_id );
95
  }
96
  }
97
  }
98
 
99
  /**
100
  * change_all_products_prices
101
+ *
102
+ * @version 2.4.0
103
  */
104
  public function change_all_products_prices( $multiply_prices_by, $is_preview ) {
105
  $multiply_prices_by = floatval( $multiply_prices_by );
106
+ if ( $multiply_prices_by <= 0 ) {
107
  return;
108
+ }
109
 
110
  ob_start();
111
 
112
+ echo '<table class="widefat" style="width:50%; min-width: 300px; margin-top: 10px;">';
 
 
 
 
 
 
113
  echo '<tr>' .
114
+ '<th>' . __( 'Product', 'woocommerce-jetpack' ) . '</th>' .
115
+ '<th>' . __( 'Categories', 'woocommerce-jetpack' ) . '</th>' .
116
+ '<th>' . __( 'Price Type', 'woocommerce-jetpack' ) . '</th>' .
117
+ '<th>' . __( 'Original Price', 'woocommerce-jetpack' ) . '</th>' .
118
  '<th>' . __( 'Modified Price', 'woocommerce-jetpack' ) . '</th>' .
119
+ '</tr>';
120
+
121
+ $offset = 0;
122
+ $block_size = 96;
123
+ while( true ) {
124
+ $args = array(
125
+ 'post_type' => 'product',
126
+ 'post_status' => 'any',
127
+ 'posts_per_page' => $block_size,
128
+ 'offset' => $offset,
129
+ // 'orderby' => 'date',
130
+ // 'order' => 'ASC',
131
+ );
132
+ if ( isset( $_POST['wcj_product_cat'] ) && 'wcj_any' != $_POST['wcj_product_cat'] && 'any' != apply_filters( 'wcj_get_option_filter', 'any', '' ) ) {
133
+ $args['tax_query'] = array(
134
+ array(
135
+ 'taxonomy' => 'product_cat',
136
+ 'field' => 'slug',
137
+ 'terms' => array( $_POST['wcj_product_cat'] ),
138
+ ),
139
+ );
140
+ }
141
+ $loop = new WP_Query( $args );
142
+ if ( ! $loop->have_posts() ) break;
143
+ while ( $loop->have_posts() ) : $loop->the_post();
144
+ $this->change_product_price( $loop->post->ID, $multiply_prices_by, $is_preview );
145
+ endwhile;
146
+ $offset += $block_size;
147
+ }
148
+ wp_reset_postdata();
149
+
150
  echo '</table>';
151
 
152
  return ob_get_clean();
155
  /**
156
  * create_bulk_price_converter_tool.
157
  *
158
+ * @version 2.4.0
159
  */
160
  public function create_bulk_price_converter_tool() {
161
 
 
 
162
  $result_message = '';
163
 
164
  $multiply_prices_by = isset( $_POST['multiply_prices_by'] ) ? $_POST['multiply_prices_by'] : 1;
179
  }
180
  }
181
  }
182
+
183
+ $select_options_html = '';
184
+ $selected_option = ( isset( $_POST['wcj_product_cat'] ) ) ? $_POST['wcj_product_cat'] : '';
185
+ $product_categories = get_terms( 'product_cat', 'orderby=name&hide_empty=0' );
186
+ if ( ! empty( $product_categories ) && ! is_wp_error( $product_categories ) ){
187
+ foreach ( $product_categories as $product_category ) {
188
+ $select_options_html .= '<option value="' . $product_category->slug . '"' . selected( $product_category->slug, $selected_option, false ) . '>' . $product_category->name . '</option>';
189
+ }
190
+ }
191
+
192
+ // Output HTML
193
+ echo '<div>';
194
+ echo $this->get_tool_header_html( 'bulk_price_converter' );
195
+ echo $result_message;
196
+ echo '<form method="post" action="">';
197
+ $data_table = array();
198
+ $data_table[] = array(
199
+ __( 'Multiply all product prices by', 'woocommerce-jetpack' ),
200
+ '<input class="" type="number" step="0.000001" min="0.000001" name="multiply_prices_by" id="multiply_prices_by" value="' . $multiply_prices_by . '">',
201
+ );
202
+ if ( '' != $select_options_html ) {
203
+ $data_table[] = array(
204
+ __( 'Category', 'woocommerce-jetpack' ),
205
+ '<select name="wcj_product_cat" ' . apply_filters( 'wcj_get_option_filter', 'disabled', '' ) . '>' .
206
+ '<option value="wcj_any">' . __( 'Any', 'woocommerce-jetpack' ) . '</option>' .
207
+ $select_options_html .
208
+ '</select>' . ' ' . apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
209
+ );
210
+ }
211
+ $data_table[] = array(
212
+ '<input class="button-primary" type="submit" name="bulk_change_prices_preview" id="bulk_change_prices_preview" value="' . __( 'Preview Prices', 'woocommerce-jetpack' ) . '">',
213
+ '',
214
+ );
215
+ if ( isset( $_POST['bulk_change_prices_preview'] ) ) {
216
+ $data_table[] = array(
217
+ '<input class="button-primary" type="submit" name="bulk_change_prices" id="bulk_change_prices" value="' . __( 'Change Prices', 'woocommerce-jetpack' ) . '">',
218
+ '',
219
+ );
220
+ }
221
+ /* <input type="checkbox" name="make_pretty_prices" id="make_pretty_prices" value="">Make Pretty Prices */
222
+ echo wcj_get_table_html( $data_table, array( 'table_heading_type' => 'none', ) );
223
+ echo '</form>';
224
+ if ( $is_preview ) echo $result_changing_prices;
225
+ echo '</div>';
226
  }
227
 
228
 
283
  return $the_multiplied_price;
284
  } */
285
 
 
 
 
 
 
 
 
 
 
 
286
  }
287
 
288
  endif;
includes/class-wcj-product-custom-info.php ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Jetpack Product Custom Info
4
+ *
5
+ * The WooCommerce Jetpack Product Custom Info class.
6
+ *
7
+ * @version 2.4.0
8
+ * @since 2.4.0
9
+ * @author Algoritmika Ltd.
10
+ */
11
+
12
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
13
+
14
+ if ( ! class_exists( 'WCJ_Product_Custom_info' ) ) :
15
+
16
+ class WCJ_Product_Custom_info extends WCJ_Module {
17
+
18
+ /**
19
+ * Constructor.
20
+ */
21
+ public function __construct() {
22
+
23
+ $this->id = 'product_custom_info';
24
+ $this->short_desc = __( 'Product Info V2', 'woocommerce-jetpack' );
25
+ $this->desc = __( 'Add additional info to WooCommerce category and single product pages.', 'woocommerce-jetpack' );
26
+ parent::__construct();
27
+
28
+ add_action( 'init', array( $this, 'add_settings_hook' ) );
29
+
30
+ if ( $this->is_enabled() ) {
31
+ $single_or_archive_array = array( 'single', 'archive' );
32
+ foreach ( $single_or_archive_array as $single_or_archive ) {
33
+ for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_product_custom_info_total_number_' . $single_or_archive, 1 ) ); $i++ ) {
34
+ $default_hook = ( 'single' === $single_or_archive ) ? 'woocommerce_after_single_product_summary' : 'woocommerce_after_shop_loop_item_title';
35
+ add_action(
36
+ get_option( 'wcj_product_custom_info_hook_' . $single_or_archive . '_' . $i, $default_hook ),
37
+ array( $this, 'add_product_custom_info' )
38
+ );
39
+ }
40
+ }
41
+ }
42
+ }
43
+
44
+ /**
45
+ * add_product_custom_info.
46
+ */
47
+ function add_product_custom_info() {
48
+ $current_filter = current_filter();
49
+ $single_or_archive_array = array( 'single', 'archive' );
50
+ foreach ( $single_or_archive_array as $single_or_archive ) {
51
+ for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_product_custom_info_total_number_' . $single_or_archive, 1 ) ); $i++ ) {
52
+ if ( '' != get_option( 'wcj_product_custom_info_content_' . $single_or_archive . '_' . $i ) && $current_filter === get_option( 'wcj_product_custom_info_hook_' . $single_or_archive . '_' . $i ) ) {
53
+ $products_to_exclude = get_option( 'wcj_product_custom_info_products_to_exclude_' . $single_or_archive . '_' . $i );
54
+ $products_to_include = get_option( 'wcj_product_custom_info_products_to_include_' . $single_or_archive . '_' . $i );
55
+ $product_id = get_the_ID();
56
+ if (
57
+ ( empty( $products_to_exclude ) || ! in_array( $product_id, $products_to_exclude ) ) &&
58
+ ( empty( $products_to_include ) || in_array( $product_id, $products_to_include ) )
59
+ ) {
60
+ echo do_shortcode( get_option( 'wcj_product_custom_info_content_' . $single_or_archive . '_' . $i ) );
61
+ }
62
+ }
63
+ }
64
+ }
65
+ }
66
+
67
+ /**
68
+ * get_settings.
69
+ */
70
+ function get_settings() {
71
+ $settings = array();
72
+ $settings = apply_filters( 'wcj_product_custom_info_settings', $settings );
73
+ return $this->add_standard_settings( $settings );
74
+ }
75
+
76
+ /*
77
+ * add_settings_hook.
78
+ */
79
+ function add_settings_hook() {
80
+ add_filter( 'wcj_product_custom_info_settings', array( $this, 'add_settings' ) );
81
+ }
82
+
83
+ /**
84
+ * add_settings.
85
+ */
86
+ function add_settings() {
87
+
88
+ $products = array();
89
+ $args = array(
90
+ 'post_type' => 'product',
91
+ 'post_status' => 'any',
92
+ 'posts_per_page' => -1,
93
+ );
94
+ $loop = new WP_Query( $args );
95
+ if ( $loop->have_posts() ) {
96
+ while ( $loop->have_posts() ) : $loop->the_post();
97
+ $products[ strval( $loop->post->ID ) ] = get_the_title( $loop->post->ID );
98
+ endwhile;
99
+ wp_reset_postdata();
100
+ }
101
+
102
+ $settings = array();
103
+ $single_or_archive_array = array( 'single', 'archive' );
104
+ foreach ( $single_or_archive_array as $single_or_archive ) {
105
+ $single_or_archive_desc = ( 'single' === $single_or_archive ) ? __( 'Single', 'woocommerce-jetpack' ) : __( 'Archive', 'woocommerce-jetpack' );
106
+ $settings = array_merge( $settings, array(
107
+ array(
108
+ 'title' => __( 'Product Custom Info Blocks', 'woocommerce-jetpack' ) . ' - ' . $single_or_archive_desc,
109
+ 'type' => 'title',
110
+ 'id' => 'wcj_product_custom_info_options_' . $single_or_archive,
111
+ ),
112
+ array(
113
+ 'title' => __( 'Total Blocks', 'woocommerce-jetpack' ),
114
+ 'id' => 'wcj_product_custom_info_total_number_' . $single_or_archive,
115
+ 'default' => 1,
116
+ 'type' => 'custom_number',
117
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
118
+ 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
119
+ ),
120
+ array(
121
+ 'type' => 'sectionend',
122
+ 'id' => 'wcj_product_custom_info_options_' . $single_or_archive,
123
+ ),
124
+ ) );
125
+ for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_product_custom_info_total_number_' . $single_or_archive, 1 ) ); $i++ ) {
126
+ $settings = array_merge( $settings, array(
127
+ array(
128
+ 'title' => __( 'Info Block', 'woocommerce-jetpack' ) . ' #' . $i . ' - ' . $single_or_archive_desc,
129
+ 'type' => 'title',
130
+ 'id' => 'wcj_product_custom_info_options_' . $single_or_archive . '_' . $i,
131
+ ),
132
+ array(
133
+ 'title' => __( 'Content', 'woocommerce-jetpack' ),
134
+ 'id' => 'wcj_product_custom_info_content_' . $single_or_archive . '_' . $i,
135
+ 'default' => '[wcj_product_total_sales before="Total sales: " after=" pcs."]',
136
+ 'type' => 'textarea',
137
+ 'css' => 'width:30%;min-width:300px;height:100px;',
138
+ ),
139
+ array(
140
+ 'title' => __( 'Position', 'woocommerce-jetpack' ),
141
+ 'id' => 'wcj_product_custom_info_hook_' . $single_or_archive . '_' . $i,
142
+ 'default' => ( 'single' === $single_or_archive ) ? 'woocommerce_after_single_product_summary' : 'woocommerce_after_shop_loop_item_title',
143
+ 'type' => 'select',
144
+ 'options' => ( 'single' === $single_or_archive ) ?
145
+ array(
146
+ 'woocommerce_before_single_product' => __( 'Before single product', 'woocommerce-jetpack' ),
147
+ 'woocommerce_before_single_product_summary' => __( 'Before single product summary', 'woocommerce-jetpack' ),
148
+ 'woocommerce_single_product_summary' => __( 'Inside single product summary', 'woocommerce-jetpack' ),
149
+ 'woocommerce_after_single_product_summary' => __( 'After single product summary', 'woocommerce-jetpack' ),
150
+ 'woocommerce_after_single_product' => __( 'After single product', 'woocommerce-jetpack' ),
151
+ ) :
152
+ array(
153
+ 'woocommerce_before_shop_loop_item' => __( 'Before product', 'woocommerce-jetpack' ),
154
+ 'woocommerce_before_shop_loop_item_title' => __( 'Before product title', 'woocommerce-jetpack' ),
155
+ 'woocommerce_shop_loop_item_title' => __( 'Inside product title', 'woocommerce-jetpack' ),
156
+ 'woocommerce_after_shop_loop_item_title' => __( 'After product title', 'woocommerce-jetpack' ),
157
+ 'woocommerce_after_shop_loop_item' => __( 'After product', 'woocommerce-jetpack' ),
158
+ ),
159
+ 'css' => 'width:250px;',
160
+ ),
161
+ array(
162
+ 'title' => __( 'Priority', 'woocommerce-jetpack' ),
163
+ 'id' => 'wcj_product_custom_info_priority_' . $single_or_archive . '_' . $i,
164
+ 'default' => 10,
165
+ 'type' => 'number',
166
+ 'css' => 'width:250px;',
167
+ ),
168
+ array(
169
+ 'title' => __( 'Products to Include', 'woocommerce-jetpack' ),
170
+ 'desc_tip' => __( 'Leave blank to disable the option.', 'woocommerce-jetpack' ),
171
+ 'id' => 'wcj_product_custom_info_products_to_include_' . $single_or_archive . '_' . $i,
172
+ 'default' => '',
173
+ 'type' => 'multiselect',
174
+ 'class' => 'chosen_select',
175
+ 'css' => 'width: 450px;',
176
+ 'options' => $products,
177
+ ),
178
+ array(
179
+ 'title' => __( 'Products to Exclude', 'woocommerce-jetpack' ),
180
+ 'desc_tip' => __( 'Leave blank to disable the option.', 'woocommerce-jetpack' ),
181
+ 'id' => 'wcj_product_custom_info_products_to_exclude_' . $single_or_archive . '_' . $i,
182
+ 'default' => '',
183
+ 'type' => 'multiselect',
184
+ 'class' => 'chosen_select',
185
+ 'css' => 'width: 450px;',
186
+ 'options' => $products,
187
+ ),
188
+ array(
189
+ 'type' => 'sectionend',
190
+ 'id' => 'wcj_product_custom_info_options_' . $single_or_archive . '_' . $i,
191
+ ),
192
+ ) );
193
+ }
194
+ }
195
+
196
+ return $settings;
197
+ }
198
+
199
+ }
200
+
201
+ endif;
202
+
203
+ return new WCJ_Product_Custom_info();
includes/class-wcj-product-info.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Product Info class.
6
  *
7
- * @version 2.2.6
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -12,285 +12,134 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
12
 
13
  if ( ! class_exists( 'WCJ_Product_Info' ) ) :
14
 
15
- class WCJ_Product_Info {
16
 
17
  /**
18
- * Constructor.
 
 
 
19
  */
20
- public function __construct() {
21
-
22
- // Product archives filters array
23
- $this->product_info_on_archive_filters_array = array(
24
- 'woocommerce_before_shop_loop_item' => __( 'Before product', 'woocommerce-jetpack' ),
25
- 'woocommerce_before_shop_loop_item_title' => __( 'Before product title', 'woocommerce-jetpack' ),
26
- 'woocommerce_after_shop_loop_item' => __( 'After product', 'woocommerce-jetpack' ),
27
- 'woocommerce_after_shop_loop_item_title' => __( 'After product title', 'woocommerce-jetpack' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  );
29
-
30
- // Single product filters array
31
- $this->product_info_on_single_filters_array = array(
32
- 'woocommerce_single_product_summary' => __( 'Inside single product summary', 'woocommerce-jetpack' ),
33
- 'woocommerce_before_single_product_summary' => __( 'Before single product summary', 'woocommerce-jetpack' ),
34
- 'woocommerce_after_single_product_summary' => __( 'After single product summary', 'woocommerce-jetpack' ),
35
  );
 
36
 
37
- // List of product info short codes
38
- $this->product_info_shortcodes_array = array(
39
- '%sku%',
40
- '%title%',
41
- '%weight%',
42
- '%sale_price%',
43
- '%regular_price_if_on_sale%',
44
- '%regular_price%',
45
- '%price%',
46
- '%price_including_tax%',
47
- '%price_excluding_tax%',
48
- '%tax_class%',
49
- '%average_rating%',
50
- '%categories%',
51
- '%shipping_class%',
52
- '%dimensions%',
53
- '%formatted_name%',
54
- '%stock_availability%',
55
- '%total_sales%',
56
- '%you_save%',
57
- '%you_save_percent%',
58
- '%sale_price_formatted%',
59
- '%regular_price_if_on_sale_formatted%',
60
- '%regular_price_formatted%',
61
- '%price_formatted%',
62
- '%price_including_tax_formatted%',
63
- '%price_excluding_tax_formatted%',
64
- '%you_save_formatted%',
65
- '%time_since_last_sale%',
66
- //'%available_variations%',
67
- '%list_attributes%',
68
- '%stock_quantity%',
69
- '%list_attribute%',
70
- );
71
 
72
- // Main hooks
73
- if ( 'yes' === get_option( 'wcj_product_info_enabled' ) ) {
 
 
74
 
75
- // Product Info
 
 
 
76
  $this->add_product_info_filters( 'archive' );
77
  $this->add_product_info_filters( 'single' );
78
-
79
-
80
-
81
- // Shortcodes
82
- add_shortcode( 'wcj_sku', array( $this, 'shortcode_product_info_sku' ) );
83
- add_shortcode( 'wcj_title', array( $this, 'shortcode_product_info_title' ) );
84
- add_shortcode( 'wcj_weight', array( $this, 'shortcode_product_info_weight' ) );
85
- add_shortcode( 'wcj_sale_price', array( $this, 'shortcode_product_info_sale_price' ) );
86
- add_shortcode( 'wcj_regular_price_if_on_sale', array( $this, 'shortcode_product_info_regular_price_if_on_sale' ) );
87
- add_shortcode( 'wcj_regular_price', array( $this, 'shortcode_product_info_regular_price' ) );
88
- add_shortcode( 'wcj_price', array( $this, 'shortcode_product_info_price' ) );
89
- add_shortcode( 'wcj_price_including_tax', array( $this, 'shortcode_product_info_price_including_tax' ) );
90
- add_shortcode( 'wcj_price_excluding_tax', array( $this, 'shortcode_product_info_price_excluding_tax' ) );
91
- add_shortcode( 'wcj_tax_class', array( $this, 'shortcode_product_info_tax_class' ) );
92
- add_shortcode( 'wcj_average_rating', array( $this, 'shortcode_product_info_average_rating' ) );
93
- add_shortcode( 'wcj_categories', array( $this, 'shortcode_product_info_categories' ) );
94
- add_shortcode( 'wcj_shipping_class', array( $this, 'shortcode_product_info_shipping_class' ) );
95
- add_shortcode( 'wcj_dimensions', array( $this, 'shortcode_product_info_dimensions' ) );
96
- add_shortcode( 'wcj_formatted_name', array( $this, 'shortcode_product_info_formatted_name' ) );
97
- add_shortcode( 'wcj_stock_availability', array( $this, 'shortcode_product_info_stock_availability' ) );
98
- add_shortcode( 'wcj_total_sales', array( $this, 'shortcode_product_info_total_sales' ) );
99
- add_shortcode( 'wcj_you_save', array( $this, 'shortcode_product_info_you_save' ) );
100
- add_shortcode( 'wcj_you_save_percent', array( $this, 'shortcode_product_info_you_save_percent' ) );
101
- add_shortcode( 'wcj_sale_price_formatted', array( $this, 'shortcode_product_info_sale_price_formatted' ) );
102
- add_shortcode( 'wcj_regular_price_if_on_sale_formatted', array( $this, 'shortcode_product_info_regular_price_if_on_sale_formatted' ) );
103
- add_shortcode( 'wcj_regular_price_formatted', array( $this, 'shortcode_product_info_regular_price_formatted' ) );
104
- add_shortcode( 'wcj_price_formatted', array( $this, 'shortcode_product_info_price_formatted' ) );
105
- add_shortcode( 'wcj_price_including_tax_formatted', array( $this, 'shortcode_product_info_price_including_tax_formatted' ) );
106
- add_shortcode( 'wcj_price_excluding_tax_formatted', array( $this, 'shortcode_product_info_price_excluding_tax_formatted' ) );
107
- add_shortcode( 'wcj_you_save_formatted', array( $this, 'shortcode_product_info_you_save_formatted' ) );
108
- add_shortcode( 'wcj_time_since_last_sale', array( $this, 'shortcode_product_info_time_since_last_sale' ) );
109
- add_shortcode( 'wcj_available_variations', array( $this, 'shortcode_product_info_available_variations' ) );
110
- add_shortcode( 'wcj_list_attributes', array( $this, 'shortcode_product_info_list_attributes' ) );
111
- add_shortcode( 'wcj_stock_quantity', array( $this, 'shortcode_product_info_stock_quantity' ) );
112
- add_shortcode( 'wcj_list_attribute', array( $this, 'shortcode_product_info_list_attribute' ) );
113
-
114
- // Depreciated
115
- add_shortcode( 'wcjp_list_attribute', array( $this, 'shortcode_wcjp_list_attribute' ) );
116
-
117
-
118
- }
119
-
120
- // Settings hooks
121
- add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
122
- add_filter( 'wcj_settings_product_info', array( $this, 'get_settings' ), 100 );
123
- add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
124
- }
125
-
126
-
127
- /**
128
- * shortcode_wcjp_list_attribute.
129
- */
130
- public function shortcode_wcjp_list_attribute( $atts ) {
131
- $atts_array = shortcode_atts( array(
132
- 'attribute_name' => '',
133
- 'before' => '',
134
- 'after' => '',
135
- 'visibility' => '',
136
- ), $atts );
137
- global $product;
138
- if ( '' != $atts_array['attribute_name'] && $product && '' != $product->get_attribute( $atts_array['attribute_name'] ) ) {
139
- if ( 'admin' === $atts_array['visibility'] && ! is_super_admin() )
140
- return '';
141
- return $atts_array['before'] . $product->get_attribute( $atts_array['attribute_name'] ) . $atts_array['after'];
142
  }
143
- return '';
144
  }
145
 
146
  /**
147
- * Shortcodes.
 
 
 
148
  */
149
- public function get_shortcode( $shortcode, $atts ) {
150
- $atts = shortcode_atts( array(
151
- 'before' => '',
152
- 'after' => '',
153
- 'visibility' => '',
154
- 'id' => 0,
155
- 'options' => '',
156
- ), $atts, $shortcode );
157
- if ( 'admin' === $atts['visibility'] && ! is_super_admin() )
158
- return '';
159
- if ( '' != ( $result = $this->get_product_info_short_code( $shortcode, $atts['id'], $atts['options'] ) ) )
160
- return $atts['before'] . $result . $atts['after'];
161
- return '';
162
- }
163
-
164
- public function shortcode_product_info_sku( $atts ) {
165
- return $this->get_shortcode( '%sku%', $atts );
166
- }
167
-
168
- public function shortcode_product_info_title( $atts ) {
169
- return $this->get_shortcode( '%title%', $atts );
170
- }
171
-
172
- public function shortcode_product_info_weight( $atts ) {
173
- return $this->get_shortcode( '%weight%', $atts );
174
- }
175
-
176
- public function shortcode_product_info_sale_price( $atts ) {
177
- return $this->get_shortcode( '%sale_price%', $atts );
178
- }
179
-
180
- public function shortcode_product_info_regular_price_if_on_sale( $atts ) {
181
- return $this->get_shortcode( '%regular_price_if_on_sale%', $atts );
182
- }
183
-
184
- public function shortcode_product_info_regular_price( $atts ) {
185
- return $this->get_shortcode( '%regular_price%', $atts );
186
- }
187
-
188
- public function shortcode_product_info_price( $atts ) {
189
- return $this->get_shortcode( '%price%', $atts );
190
- }
191
-
192
- public function shortcode_product_info_price_including_tax( $atts ) {
193
- return $this->get_shortcode( '%price_including_tax%', $atts );
194
- }
195
-
196
- public function shortcode_product_info_price_excluding_tax( $atts ) {
197
- return $this->get_shortcode( '%price_excluding_tax%', $atts );
198
- }
199
-
200
- public function shortcode_product_info_tax_class( $atts ) {
201
- return $this->get_shortcode( '%tax_class%', $atts );
202
- }
203
-
204
- public function shortcode_product_info_average_rating( $atts ) {
205
- return $this->get_shortcode( '%average_rating%', $atts );
206
- }
207
-
208
- public function shortcode_product_info_categories( $atts ) {
209
- return $this->get_shortcode( '%categories%', $atts );
210
- }
211
-
212
- public function shortcode_product_info_shipping_class( $atts ) {
213
- return $this->get_shortcode( '%shipping_class%', $atts );
214
- }
215
-
216
- public function shortcode_product_info_dimensions( $atts ) {
217
- return $this->get_shortcode( '%dimensions%', $atts );
218
- }
219
-
220
- public function shortcode_product_info_formatted_name( $atts ) {
221
- return $this->get_shortcode( '%formatted_name%', $atts );
222
- }
223
-
224
- public function shortcode_product_info_stock_availability( $atts ) {
225
- return $this->get_shortcode( '%stock_availability%', $atts );
226
- }
227
-
228
- public function shortcode_product_info_total_sales( $atts ) {
229
- return $this->get_shortcode( '%total_sales%', $atts );
230
- }
231
-
232
- public function shortcode_product_info_you_save( $atts ) {
233
- return $this->get_shortcode( '%you_save%', $atts );
234
- }
235
-
236
- public function shortcode_product_info_you_save_percent( $atts ) {
237
- return $this->get_shortcode( '%you_save_percent%', $atts );
238
- }
239
-
240
- public function shortcode_product_info_sale_price_formatted( $atts ) {
241
- return $this->get_shortcode( '%sale_price_formatted%', $atts );
242
- }
243
-
244
- public function shortcode_product_info_regular_price_if_on_sale_formatted( $atts ) {
245
- return $this->get_shortcode( '%regular_price_if_on_sale_formatted%', $atts );
246
- }
247
-
248
- public function shortcode_product_info_regular_price_formatted( $atts ) {
249
- return $this->get_shortcode( '%regular_price_formatted%', $atts );
250
- }
251
-
252
- public function shortcode_product_info_price_formatted( $atts ) {
253
- return $this->get_shortcode( '%price_formatted%', $atts );
254
- }
255
-
256
- public function shortcode_product_info_price_including_tax_formatted( $atts ) {
257
- return $this->get_shortcode( '%price_including_tax_formatted%', $atts );
258
- }
259
-
260
- public function shortcode_product_info_price_excluding_tax_formatted( $atts ) {
261
- return $this->get_shortcode( '%price_excluding_tax_formatted%', $atts );
262
- }
263
-
264
- public function shortcode_product_info_you_save_formatted( $atts ) {
265
- return $this->get_shortcode( '%you_save_formatted%', $atts );
266
- }
267
-
268
- public function shortcode_product_info_time_since_last_sale( $atts ) {
269
- return $this->get_shortcode( '%time_since_last_sale%', $atts );
270
- }
271
-
272
- /*public function shortcode_product_info_available_variations( $atts ) {
273
- return $this->get_shortcode( '%available_variations%', $atts );
274
- }*/
275
-
276
- public function shortcode_product_info_list_attributes( $atts ) {
277
- return $this->get_shortcode( '%list_attributes%', $atts );
278
- }
279
-
280
- public function shortcode_product_info_stock_quantity( $atts ) {
281
- return $this->get_shortcode( '%stock_quantity%', $atts );
282
- }
283
-
284
- public function shortcode_product_info_list_attribute( $atts ) {
285
- return $this->get_shortcode( '%list_attribute%', $atts );
286
  }
287
 
288
  /**
289
- * list_short_codes.
 
 
 
290
  */
291
- public function list_short_codes() {
292
- //return __( 'Available shortcodes are:', 'woocommerce-jetpack' ) . ' ' . implode( ", ", $this->product_info_shortcodes_array );
293
- return __( 'Available shortcodes are:', 'woocommerce-jetpack' ) . '<ul><li>' . implode( '</li><li>', $this->product_info_shortcodes_array ) . '</li></ul>';
 
 
 
294
  }
295
 
296
  /**
@@ -311,15 +160,19 @@ class WCJ_Product_Info {
311
 
312
  /**
313
  * product_info.
 
 
314
  */
315
  public function product_info() {
316
  $the_action_name = current_filter();
317
  if ( array_key_exists( $the_action_name, $this->product_info_on_archive_filters_array ) ) {
318
  $the_product_info = get_option( 'wcj_product_info_on_archive' );
 
319
  $this->apply_product_info_short_codes( $the_product_info, false );
320
  }
321
  else if ( array_key_exists( $the_action_name, $this->product_info_on_single_filters_array ) ) {
322
  $the_product_info = get_option( 'wcj_product_info_on_single' );
 
323
  $this->apply_product_info_short_codes( $the_product_info, false );
324
  }
325
  }
@@ -337,18 +190,23 @@ class WCJ_Product_Info {
337
 
338
  /**
339
  * add_more_product_info.
 
 
340
  */
341
  public function add_more_product_info( $single_or_archive ) {
342
  //$single_or_archive = 'archive';
343
  for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 4, get_option( 'wcj_more_product_info_on_' . $single_or_archive . '_fields_total', 4 ) ); $i++ ) {
344
  $field_id = 'wcj_more_product_info_on_' . $single_or_archive . '_' . $i ;
345
  $the_product_info = get_option( $field_id );
 
346
  $this->apply_product_info_short_codes( $the_product_info, true );
347
  }
348
  }
349
 
350
  /**
351
  * apply_product_info_short_codes.
 
 
352
  */
353
  public function apply_product_info_short_codes( $the_product_info, $remove_on_empty ) {
354
 
@@ -357,14 +215,16 @@ class WCJ_Product_Info {
357
  $product_ids_to_exclude = str_replace( ' ', '', $product_ids_to_exclude );
358
  $product_ids_to_exclude = explode( ',', $product_ids_to_exclude );
359
  $product_id = get_the_ID();
360
- if ( ! empty( $product_ids_to_exclude ) && is_array( $product_ids_to_exclude ) && in_array( $product_id, $product_ids_to_exclude ) )
361
  return;
 
362
  }
363
 
364
- if ( '' == $the_product_info )
365
  return;
 
366
 
367
- foreach ( $this->product_info_shortcodes_array as $product_info_short_code ) {
368
  if ( false !== strpos( $the_product_info, $product_info_short_code ) ) {
369
  // We found short code in the text
370
  $replace_with_phrase = $this->get_product_info_short_code( $product_info_short_code );
@@ -379,250 +239,24 @@ class WCJ_Product_Info {
379
  $the_product_info = str_replace( $product_info_short_code, $replace_with_phrase, $the_product_info );
380
  }
381
  }
382
- }
383
 
384
- echo apply_filters( 'the_content', $the_product_info );
 
385
  }
386
 
387
- /**
388
- * get_product_info.
389
- */
390
- public function get_product_info_short_code( $short_code, $id = 0, $options = null ) {
391
-
392
-
393
- if ( 0 != $id ) {
394
- $product = wc_get_product( $id );
395
- }
396
- else {
397
- //$product = wc_get_product();
398
- if ( ! array_key_exists( 'product', $GLOBALS ) )
399
- return '';
400
- global $product;
401
- }
402
-
403
- if ( ! $product )
404
- return '';
405
-
406
- if ( '%list_attribute%' == $short_code && empty( $options ) )
407
- return '';
408
-
409
- switch( $short_code ) {
410
-
411
- case '%list_attribute%':
412
- return $product->get_attribute( $options );
413
-
414
- case '%sku%':
415
- return $product->get_sku();
416
-
417
- case '%sku%':
418
- return $product->get_sku();
419
-
420
- case '%title%':
421
- return $product->get_title();
422
-
423
- case '%weight%':
424
- if ( $product->has_weight() )
425
- return $product->get_weight();
426
- else
427
- return false;
428
-
429
- case '%sale_price%':
430
- if ( $product->is_on_sale() )
431
- return $product->get_sale_price();
432
- else
433
- return false;
434
-
435
- case '%regular_price_if_on_sale%':
436
- if ( $product->is_on_sale() )
437
- return $product->get_regular_price();
438
- else
439
- return false;
440
-
441
- case '%regular_price%':
442
- return $product->get_regular_price();
443
-
444
- case '%price%':
445
- return $product->get_price();
446
-
447
- case '%price_including_tax%':
448
- return $product->get_price_including_tax();
449
-
450
- case '%price_excluding_tax%':
451
- return $product->get_price_excluding_tax();
452
-
453
- case '%tax_class%':
454
- return $product->get_tax_class();
455
-
456
- case '%average_rating%':
457
- return $product->get_average_rating();
458
-
459
- case '%categories%':
460
- return $product->get_categories();
461
-
462
- case '%shipping_class%':
463
- return $product->get_shipping_class();
464
-
465
- case '%dimensions%':
466
- if ( $product->has_dimensions() )
467
- return $product->get_dimensions();
468
- else
469
- return false;
470
-
471
- case '%formatted_name%':
472
- return $product->get_formatted_name();
473
-
474
- case '%stock_availability%':
475
- $stock_availability_array = $product->get_availability();
476
- if ( isset( $stock_availability_array['availability'] ) )
477
- return $stock_availability_array['availability'];
478
- else
479
- return false;
480
-
481
- case '%total_sales%':
482
- $product_custom_fields = get_post_custom( $product->id );
483
- if ( isset( $product_custom_fields['total_sales'][0] ) )
484
- return $product_custom_fields['total_sales'][0];
485
- else
486
- return false;
487
-
488
- case '%you_save%':
489
- if ( $product->is_on_sale() )
490
- return ( $product->get_regular_price() - $product->get_sale_price() );
491
- else
492
- return false;
493
-
494
- case '%you_save_percent%':
495
- if ( $product->is_on_sale() ) {
496
- if ( 0 != $product->get_regular_price() ) {
497
- $you_save = ( $product->get_regular_price() - $product->get_sale_price() );
498
- return intval( $you_save / $product->get_regular_price() * 100 );
499
- }
500
- else
501
- return false;
502
- }
503
- else
504
- return false;
505
-
506
- case '%sale_price_formatted%':
507
- if ( $product->is_on_sale() )
508
- return wc_price( $product->get_sale_price() );
509
- else
510
- return false;
511
-
512
- case '%regular_price_if_on_sale_formatted%':
513
- if ( $product->is_on_sale() )
514
- return wc_price( $product->get_regular_price() );
515
- else
516
- return false;
517
-
518
- case '%regular_price_formatted%':
519
- return wc_price( $product->get_regular_price() );
520
-
521
- case '%price_formatted%':
522
- return wc_price( $product->get_price() );
523
-
524
- case '%price_including_tax_formatted%':
525
- return wc_price( $product->get_price_including_tax() );
526
-
527
- case '%price_excluding_tax_formatted%':
528
- return wc_price( $product->get_price_excluding_tax() );
529
-
530
- case '%you_save_formatted%':
531
- if ( $product->is_on_sale() )
532
- return wc_price( $product->get_regular_price() - $product->get_sale_price() );
533
- else
534
- return false;
535
-
536
- case '%time_since_last_sale%':
537
- return $this->get_time_since_last_sale();
538
-
539
- case '%list_attributes%':
540
- if ( $product->has_attributes() )
541
- return $product->list_attributes();
542
- else
543
- return false;
544
-
545
- case '%stock_quantity%':
546
- $stock_quantity = $product->get_stock_quantity();
547
- if ( '' != $stock_quantity )
548
- return $stock_quantity;
549
- else
550
- return false;
551
-
552
- // Not finished!
553
- case '%available_variations%':
554
- if ( $product->is_type( 'variable' ) )
555
- return print_r( $product->get_available_variations(), true );
556
- else
557
- return false;
558
-
559
- default:
560
- return false;
561
- }
562
-
563
- return false;
564
- }
565
-
566
- /**
567
- * get_time_since_last_sale.
568
- *
569
- * @version 2.2.6
570
- */
571
- public function get_time_since_last_sale() {
572
- // Constants
573
- $days_to_cover = 90;
574
- $do_use_only_completed_orders = true;
575
- // Get the ID before new query
576
- $the_ID = get_the_ID();
577
- // Create args for new query
578
- $args = array(
579
- 'post_type' => 'shop_order',
580
- 'post_status' => ( true === $do_use_only_completed_orders ? 'wc-completed' : 'any' ),
581
- 'posts_per_page' => -1,
582
- 'orderby' => 'date',
583
- 'order' => 'DESC',
584
- 'date_query' => array( array( 'after' => strtotime( '-' . $days_to_cover . ' days' ) ) ),
585
- );
586
- // Run new query
587
- $loop = new WP_Query( $args );
588
- // Analyze the results, i.e. orders
589
- while ( $loop->have_posts() ) : $loop->the_post();
590
- $order = new WC_Order( $loop->post->ID );
591
- $items = $order->get_items();
592
- foreach ( $items as $item ) {
593
- // Run through all order's items
594
- if ( $item['product_id'] == $the_ID ) {
595
- // Found sale!
596
- $result = sprintf( __( '%s ago', 'woocommerce-jetpack' ), human_time_diff( get_the_time('U'), current_time('timestamp') ) );
597
- //wp_reset_query();
598
- wp_reset_postdata();
599
- return $result;
600
- }
601
- }
602
- endwhile;
603
- //wp_reset_query();
604
- wp_reset_postdata();
605
- // No sales found
606
- return false;
607
- }
608
-
609
-
610
-
611
- // ADMIN //
612
-
613
  /**
614
  * admin_add_product_info_fields_with_header.
615
  */
616
  function admin_add_product_info_fields_with_header( &$settings, $single_or_archive, $title, $filters_array ) {
617
  $settings = array_merge( $settings, array(
618
  array(
619
- 'title' => $title,//__( 'Product Info on Archive Pages', 'woocommerce-jetpack' ),
620
- 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
621
- 'id' => 'wcj_more_product_info_on_' . $single_or_archive . '_enabled',
622
- 'default' => 'no',
623
- 'type' => 'checkbox',
624
  ),
625
-
626
  array(
627
  'title' => '',
628
  'desc' => __( 'Position', 'woocommerce-jetpack' ),
@@ -631,126 +265,101 @@ class WCJ_Product_Info {
631
  'class' => 'chosen_select',
632
  'default' => 'woocommerce_after_shop_loop_item_title',
633
  'type' => 'select',
634
- 'options' => $filters_array,// $this->product_info_on_archive_filters_array,
635
  'desc_tip' => true,
636
  ),
637
-
638
  array(
639
  'title' => '',
640
- 'desc_tip' => __( 'Priority (i.e. Order)', 'woocommerce-jetpack' ),
641
  'id' => 'wcj_more_product_info_on_' . $single_or_archive . '_filter_priority',
642
  'default' => 10,
643
  'type' => 'number',
644
  ),
645
-
646
  array(
647
- 'title' => '',
648
- 'desc_tip' => __( 'Number of product info fields. Click "Save changes" after you change this number.', 'woocommerce-jetpack' ),
649
- 'id' => 'wcj_more_product_info_on_' . $single_or_archive . '_fields_total',
650
- 'default' => 4,
651
- 'type' => 'number',
652
- 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
653
- 'custom_attributes'
654
- => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
655
  ),
656
  ) );
657
-
658
  $this->admin_add_product_info_fields( $settings, $single_or_archive );
659
  }
660
 
661
  /**
662
  * admin_add_product_info_fields.
 
 
663
  */
664
  function admin_add_product_info_fields( &$settings, $single_or_archive ) {
665
- //$single_or_archive = 'archive';
666
  for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 4, get_option( 'wcj_more_product_info_on_' . $single_or_archive . '_fields_total', 4 ) ); $i++ ) {
667
  $field_id = 'wcj_more_product_info_on_' . $single_or_archive . '_' . $i ;
668
  $default_value = '';
669
  switch ( $i ) {
670
  case 1: $default_value = '<ul>'; break;
671
- case 2: $default_value = '<li>' . __( 'You save: <strong>%you_save_formatted%</strong> (%you_save_percent%%)', 'woocommerce-jetpack' ) . '</li>'; break;
672
- case 3: $default_value = '<li>' . __( 'Total sales: %total_sales%', 'woocommerce-jetpack' ) . '</li>'; break;
673
  case 4: $default_value = '</ul>'; break;
674
  }
675
- $desc = ( '' != $default_value ) ? __( 'Default', 'woocommerce-jetpack' ) . ': ' . esc_html( $default_value ) : '';
676
- $short_codes_list = '%you_save%, %total_sales%';
677
- $desc_tip = __( 'Field Nr. ', 'woocommerce-jetpack' ) . $i . '<br>' . __( 'Available short codes: ', 'woocommerce-jetpack' ) . $short_codes_list;
678
  $settings[] = array(
679
- 'title' => '',
680
- //'desc_tip' => $desc_tip,
681
- //'desc' => $desc,
682
- 'id' => $field_id,
683
- 'default' => $default_value,
684
- 'type' => 'textarea',
685
- 'css' => 'width:50%;min-width:300px;',
686
  );
687
  }
688
  }
689
 
690
- /**
691
- * Return feature's enable/disable option.
692
- */
693
- public function add_enabled_option( $settings ) {
694
- $all_settings = $this->get_settings();
695
- $settings[] = $all_settings[1];
696
- return $settings;
697
- }
698
-
699
  /**
700
  * Get settings.
 
 
701
  */
702
  function get_settings() {
703
 
704
  $settings = array(
705
-
706
- // Product Info Options - Global
707
- array( 'title' => __( 'Product Info Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_product_info_options' ),
708
-
709
  array(
710
- 'title' => __( 'Product Info', 'woocommerce-jetpack' ),
711
- 'desc' => '<strong>' . __( 'Enable Module', 'woocommerce-jetpack' ) . '</strong>',
712
- 'desc_tip' => __( 'Add additional info to WooCommerce category and single product pages.', 'woocommerce-jetpack' ),
713
- 'id' => 'wcj_product_info_enabled',
714
- 'default' => 'no',
715
- 'type' => 'checkbox',
716
  ),
717
-
718
- array( 'type' => 'sectionend', 'id' => 'wcj_product_info_options' ),
719
-
720
- // More Product Info
721
- array( 'title' => __( 'More Products Info', 'woocommerce-jetpack' ), 'type' => 'title',
722
- 'desc' => __( 'For full list of short codes, please visit <a target="_blank" href="http://woojetpack.com/features/product-info/">http://woojetpack.com/features/product-info/</a>', 'woocommerce-jetpack' ),
723
- //'desc' => $this->list_short_codes(),
724
- 'id' => 'wcj_more_product_info_options' ),
725
  );
726
-
727
  $this->admin_add_product_info_fields_with_header( $settings, 'archive', __( 'Product Info on Archive Pages', 'woocommerce-jetpack' ), $this->product_info_on_archive_filters_array );
728
- $this->admin_add_product_info_fields_with_header( $settings, 'single', __( 'Product Info on Single Pages', 'woocommerce-jetpack' ), $this->product_info_on_single_filters_array );
729
-
730
- $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_more_product_info_options' );
 
 
731
 
732
  $settings = array_merge( $settings, array(
733
-
734
- // More Product Info - "Constant" modification
735
- array( 'title' => __( 'Even More Products Info', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_product_info_additional_options' ),
736
-
737
  array(
738
- 'title' => __( 'Product Info on Archive Pages', 'woocommerce-jetpack' ),
739
- 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
740
- 'id' => 'wcj_product_info_on_archive_enabled',
741
- 'default' => 'no',
742
- 'type' => 'checkbox',
743
  ),
744
-
745
  array(
746
- 'title' => '',
747
- 'desc_tip' => __( 'HTML info.', 'woocommerce-jetpack' ),
748
- 'id' => 'wcj_product_info_on_archive',
749
- 'default' => __( 'SKU: %sku%', 'woocommerce-jetpack' ),
750
- 'type' => 'textarea',
751
- 'css' => 'width:50%;min-width:300px;height:100px;',
 
 
 
 
 
 
 
752
  ),
753
-
754
  array(
755
  'title' => '',
756
  'desc' => __( 'Position', 'woocommerce-jetpack' ),
@@ -762,35 +371,28 @@ class WCJ_Product_Info {
762
  'options' => $this->product_info_on_archive_filters_array,
763
  'desc_tip' => true,
764
  ),
765
-
766
  array(
767
  'title' => '',
768
- 'desc_tip' => __( 'Priority (i.e. Order)', 'woocommerce-jetpack' ),
769
  'id' => 'wcj_product_info_on_archive_filter_priority',
770
  'default' => 10,
771
  'type' => 'number',
772
  ),
773
-
774
  array(
775
- 'title' => __( 'Product Info on Single Product Pages', 'woocommerce-jetpack' ),
776
- 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
777
- 'id' => 'wcj_product_info_on_single_enabled',
778
- 'default' => 'no',
779
- 'type' => 'checkbox',
780
  ),
781
-
782
  array(
783
- 'title' => '',
784
- 'desc_tip' => __( 'HTML info.', 'woocommerce-jetpack' ),// . ' ' . $this->list_short_codes(),
785
- 'id' => 'wcj_product_info_on_single',
786
- 'default' => __( 'Total sales: %total_sales%', 'woocommerce-jetpack' ),
787
- 'type' => 'textarea',
788
- /*'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
789
- 'custom_attributes'
790
- => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),*/
791
- 'css' => 'width:50%;min-width:300px;height:100px;',
792
  ),
793
-
794
  array(
795
  'title' => '',
796
  'desc' => __( 'Position', 'woocommerce-jetpack' ),
@@ -800,17 +402,15 @@ class WCJ_Product_Info {
800
  'default' => 'woocommerce_after_single_product_summary',
801
  'type' => 'select',
802
  'options' => $this->product_info_on_single_filters_array,
803
- 'desc_tip' => true,
804
  ),
805
-
806
  array(
807
  'title' => '',
808
- 'desc_tip' => __( 'Priority (i.e. Order)', 'woocommerce-jetpack' ),
809
  'id' => 'wcj_product_info_on_single_filter_priority',
810
  'default' => 10,
811
  'type' => 'number',
812
  ),
813
-
814
  array(
815
  'title' => __( 'Product IDs to exclude', 'woocommerce-jetpack' ),
816
  'desc_tip' => __( 'Comma separated list of product IDs to exclude from product info.', 'woocommerce-jetpack' ),
@@ -819,20 +419,13 @@ class WCJ_Product_Info {
819
  'type' => 'text',
820
  'css' => 'min-width:300px;',
821
  ),
822
-
823
- array( 'type' => 'sectionend', 'id' => 'wcj_product_info_additional_options' ),
824
-
 
825
  ) );
826
 
827
- return $settings;
828
- }
829
-
830
- /**
831
- * Add settings section.
832
- */
833
- function settings_section( $sections ) {
834
- $sections['product_info'] = __( 'Product Info', 'woocommerce-jetpack' );
835
- return $sections;
836
  }
837
  }
838
 
4
  *
5
  * The WooCommerce Jetpack Product Info class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
12
 
13
  if ( ! class_exists( 'WCJ_Product_Info' ) ) :
14
 
15
+ class WCJ_Product_Info extends WCJ_Module {
16
 
17
  /**
18
+ * search_and_replace_depreciated_shortcodes.
19
+ *
20
+ * @version 2.4.0
21
+ * @since 2.4.0
22
  */
23
+ private function search_and_replace_depreciated_shortcodes( $data ) {
24
+ $search_and_replace_depreciated_shortcodes_array = array(
25
+ '%sku%' => '[wcj_product_sku]',
26
+ 'wcj_sku' => 'wcj_product_sku',
27
+ '%title%' => '[wcj_product_title]',
28
+ 'wcj_title' => 'wcj_product_title',
29
+ '%weight%' => '[wcj_product_weight]',
30
+ 'wcj_weight' => 'wcj_product_weight',
31
+ '%total_sales%' => '[wcj_product_total_sales]',
32
+ 'wcj_total_sales' => 'wcj_product_total_sales',
33
+ '%shipping_class%' => '[wcj_product_shipping_class]',
34
+ 'wcj_shipping_class' => 'wcj_product_shipping_class',
35
+ '%dimensions%' => '[wcj_product_dimensions]',
36
+ 'wcj_dimensions' => 'wcj_product_dimensions',
37
+ '%formatted_name%' => '[wcj_product_formatted_name]',
38
+ 'wcj_formatted_name' => 'wcj_product_formatted_name',
39
+ '%stock_availability%' => '[wcj_product_stock_availability]',
40
+ 'wcj_stock_availability' => 'wcj_product_stock_availability',
41
+ '%tax_class%' => '[wcj_product_tax_class]',
42
+ 'wcj_tax_class' => 'wcj_product_tax_class',
43
+ '%average_rating%' => '[wcj_product_average_rating]',
44
+ 'wcj_average_rating' => 'wcj_product_average_rating',
45
+ '%categories%' => '[wcj_product_categories]',
46
+ 'wcj_categories' => 'wcj_product_categories',
47
+ '%list_attributes%' => '[wcj_product_list_attributes]',
48
+ 'wcj_list_attributes' => 'wcj_product_list_attributes',
49
+ // '%list_attribute%' => '[wcj_product_list_attribute]',
50
+ 'wcj_list_attribute options=' => 'wcj_product_list_attribute name=',
51
+ 'wcjp_list_attribute attribute_name=' => 'wcj_product_list_attribute name=',
52
+ '%stock_quantity%' => '[wcj_product_stock_quantity]',
53
+ 'wcj_stock_quantity' => 'wcj_product_stock_quantity',
54
+ '%sale_price%' => '[wcj_product_sale_price hide_currency="yes"]',
55
+ 'wcj_sale_price' => 'wcj_product_sale_price hide_currency="yes"',
56
+ '%sale_price_formatted%' => '[wcj_product_sale_price]',
57
+ 'wcj_sale_price_formatted' => 'wcj_product_sale_price',
58
+ '%regular_price%' => '[wcj_product_regular_price hide_currency="yes"]',
59
+ 'wcj_regular_price' => 'wcj_product_regular_price hide_currency="yes"',
60
+ '%regular_price_formatted%' => '[wcj_product_regular_price]',
61
+ 'wcj_regular_price_formatted' => 'wcj_product_regular_price',
62
+ '%regular_price_if_on_sale%' => '[wcj_product_regular_price hide_currency="yes" show_always="no"]',
63
+ 'wcj_regular_price_if_on_sale' => 'wcj_product_regular_price hide_currency="yes" show_always="no"',
64
+ '%regular_price_if_on_sale_formatted%' => '[wcj_product_regular_price show_always="no"]',
65
+ 'wcj_regular_price_if_on_sale_formatted' => 'wcj_product_regular_price show_always="no"',
66
+ '%time_since_last_sale%' => '[wcj_product_time_since_last_sale]',
67
+ 'wcj_time_since_last_sale' => 'wcj_product_time_since_last_sale',
68
+ '%price_including_tax%' => '[wcj_product_price_including_tax hide_currency="yes"]',
69
+ 'wcj_price_including_tax' => 'wcj_product_price_including_tax hide_currency="yes"',
70
+ '%price_including_tax_formatted%' => '[wcj_product_price_including_tax]',
71
+ 'wcj_price_including_tax_formatted' => 'wcj_product_price_including_tax',
72
+ '%price_excluding_tax%' => '[wcj_product_price_excluding_tax hide_currency="yes"]',
73
+ 'wcj_price_excluding_tax' => 'wcj_product_price_excluding_tax hide_currency="yes"',
74
+ '%price_excluding_tax_formatted%' => '[wcj_product_price_excluding_tax]',
75
+ 'wcj_price_excluding_tax_formatted' => 'wcj_product_price_excluding_tax',
76
+ '%price%' => '[wcj_product_price hide_currency="yes"]',
77
+ 'wcj_price' => 'wcj_product_price hide_currency="yes"',
78
+ '%price_formatted%' => '[wcj_product_price]',
79
+ 'wcj_price_formatted' => 'wcj_product_price',
80
+ '%you_save%' => '[wcj_product_you_save hide_currency="yes"]',
81
+ 'wcj_you_save' => 'wcj_product_you_save hide_currency="yes"',
82
+ '%you_save_formatted%' => '[wcj_product_you_save]',
83
+ 'wcj_you_save_formatted' => 'wcj_product_you_save',
84
+ '%you_save_percent%' => '[wcj_product_you_save_percent]',
85
+ 'wcj_you_save_percent' => 'wcj_product_you_save_percent',
86
+ 'wcj_available_variations' => 'wcj_product_available_variations',
87
  );
88
+ return str_replace(
89
+ array_keys( $search_and_replace_depreciated_shortcodes_array ),
90
+ array_values( $search_and_replace_depreciated_shortcodes_array ),
91
+ $data
 
 
92
  );
93
+ }
94
 
95
+ /**
96
+ * Constructor.
97
+ *
98
+ * @version 2.4.0
99
+ */
100
+ function __construct() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
+ $this->id = 'product_info';
103
+ $this->short_desc = __( 'Product Info', 'woocommerce-jetpack' );
104
+ $this->desc = __( 'Add additional info to WooCommerce category and single product pages.', 'woocommerce-jetpack' );
105
+ parent::__construct();
106
 
107
+ $this->product_info_on_archive_filters_array = $this->get_product_info_on_archive_filters_array();
108
+ $this->product_info_on_single_filters_array = $this->get_product_info_on_single_filters_array();
109
+
110
+ if ( $this->is_enabled() ) {
111
  $this->add_product_info_filters( 'archive' );
112
  $this->add_product_info_filters( 'single' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  }
 
114
  }
115
 
116
  /**
117
+ * get_product_info_on_archive_filters_array.
118
+ *
119
+ * @version 2.4.0
120
+ * @since 2.4.0
121
  */
122
+ private function get_product_info_on_archive_filters_array() {
123
+ return array(
124
+ 'woocommerce_before_shop_loop_item' => __( 'Before product', 'woocommerce-jetpack' ),
125
+ 'woocommerce_before_shop_loop_item_title' => __( 'Before product title', 'woocommerce-jetpack' ),
126
+ 'woocommerce_after_shop_loop_item' => __( 'After product', 'woocommerce-jetpack' ),
127
+ 'woocommerce_after_shop_loop_item_title' => __( 'After product title', 'woocommerce-jetpack' ),
128
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  }
130
 
131
  /**
132
+ * get_product_info_on_single_filters_array.
133
+ *
134
+ * @version 2.4.0
135
+ * @since 2.4.0
136
  */
137
+ private function get_product_info_on_single_filters_array() {
138
+ return array(
139
+ 'woocommerce_single_product_summary' => __( 'Inside single product summary', 'woocommerce-jetpack' ),
140
+ 'woocommerce_before_single_product_summary' => __( 'Before single product summary', 'woocommerce-jetpack' ),
141
+ 'woocommerce_after_single_product_summary' => __( 'After single product summary', 'woocommerce-jetpack' ),
142
+ );
143
  }
144
 
145
  /**
160
 
161
  /**
162
  * product_info.
163
+ *
164
+ * @version 2.4.0
165
  */
166
  public function product_info() {
167
  $the_action_name = current_filter();
168
  if ( array_key_exists( $the_action_name, $this->product_info_on_archive_filters_array ) ) {
169
  $the_product_info = get_option( 'wcj_product_info_on_archive' );
170
+ $the_product_info = $this->search_and_replace_depreciated_shortcodes( $the_product_info );
171
  $this->apply_product_info_short_codes( $the_product_info, false );
172
  }
173
  else if ( array_key_exists( $the_action_name, $this->product_info_on_single_filters_array ) ) {
174
  $the_product_info = get_option( 'wcj_product_info_on_single' );
175
+ $the_product_info = $this->search_and_replace_depreciated_shortcodes( $the_product_info );
176
  $this->apply_product_info_short_codes( $the_product_info, false );
177
  }
178
  }
190
 
191
  /**
192
  * add_more_product_info.
193
+ *
194
+ * @version 2.4.0
195
  */
196
  public function add_more_product_info( $single_or_archive ) {
197
  //$single_or_archive = 'archive';
198
  for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 4, get_option( 'wcj_more_product_info_on_' . $single_or_archive . '_fields_total', 4 ) ); $i++ ) {
199
  $field_id = 'wcj_more_product_info_on_' . $single_or_archive . '_' . $i ;
200
  $the_product_info = get_option( $field_id );
201
+ $the_product_info = $this->search_and_replace_depreciated_shortcodes( $the_product_info );
202
  $this->apply_product_info_short_codes( $the_product_info, true );
203
  }
204
  }
205
 
206
  /**
207
  * apply_product_info_short_codes.
208
+ *
209
+ * @version 2.4.0
210
  */
211
  public function apply_product_info_short_codes( $the_product_info, $remove_on_empty ) {
212
 
215
  $product_ids_to_exclude = str_replace( ' ', '', $product_ids_to_exclude );
216
  $product_ids_to_exclude = explode( ',', $product_ids_to_exclude );
217
  $product_id = get_the_ID();
218
+ if ( ! empty( $product_ids_to_exclude ) && is_array( $product_ids_to_exclude ) && in_array( $product_id, $product_ids_to_exclude ) ) {
219
  return;
220
+ }
221
  }
222
 
223
+ if ( '' == $the_product_info ) {
224
  return;
225
+ }
226
 
227
+ /* foreach ( $this->product_info_shortcodes_array as $product_info_short_code ) {
228
  if ( false !== strpos( $the_product_info, $product_info_short_code ) ) {
229
  // We found short code in the text
230
  $replace_with_phrase = $this->get_product_info_short_code( $product_info_short_code );
239
  $the_product_info = str_replace( $product_info_short_code, $replace_with_phrase, $the_product_info );
240
  }
241
  }
242
+ } */
243
 
244
+ //echo apply_filters( 'the_content', $the_product_info );
245
+ echo do_shortcode( $the_product_info );
246
  }
247
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
  /**
249
  * admin_add_product_info_fields_with_header.
250
  */
251
  function admin_add_product_info_fields_with_header( &$settings, $single_or_archive, $title, $filters_array ) {
252
  $settings = array_merge( $settings, array(
253
  array(
254
+ 'title' => $title,
255
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
256
+ 'id' => 'wcj_more_product_info_on_' . $single_or_archive . '_enabled',
257
+ 'default' => 'no',
258
+ 'type' => 'checkbox',
259
  ),
 
260
  array(
261
  'title' => '',
262
  'desc' => __( 'Position', 'woocommerce-jetpack' ),
265
  'class' => 'chosen_select',
266
  'default' => 'woocommerce_after_shop_loop_item_title',
267
  'type' => 'select',
268
+ 'options' => $filters_array, //$this->product_info_on_archive_filters_array,
269
  'desc_tip' => true,
270
  ),
 
271
  array(
272
  'title' => '',
273
+ 'desc_tip' => __( 'Priority (i.e. Order)', 'woocommerce-jetpack' ),
274
  'id' => 'wcj_more_product_info_on_' . $single_or_archive . '_filter_priority',
275
  'default' => 10,
276
  'type' => 'number',
277
  ),
 
278
  array(
279
+ 'title' => '',
280
+ 'desc_tip' => __( 'Number of product info fields. Click "Save changes" after you change this number.', 'woocommerce-jetpack' ),
281
+ 'id' => 'wcj_more_product_info_on_' . $single_or_archive . '_fields_total',
282
+ 'default' => 4,
283
+ 'type' => 'number',
284
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
285
+ 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
 
286
  ),
287
  ) );
 
288
  $this->admin_add_product_info_fields( $settings, $single_or_archive );
289
  }
290
 
291
  /**
292
  * admin_add_product_info_fields.
293
+ *
294
+ * @version 2.4.0
295
  */
296
  function admin_add_product_info_fields( &$settings, $single_or_archive ) {
 
297
  for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 4, get_option( 'wcj_more_product_info_on_' . $single_or_archive . '_fields_total', 4 ) ); $i++ ) {
298
  $field_id = 'wcj_more_product_info_on_' . $single_or_archive . '_' . $i ;
299
  $default_value = '';
300
  switch ( $i ) {
301
  case 1: $default_value = '<ul>'; break;
302
+ case 2: $default_value = '<li>' . __( '[wcj_product_you_save before="You save: <strong>" hide_if_zero="yes" after="</strong>"][wcj_product_you_save_percent hide_if_zero="yes" before=" (" after="%)"]', 'woocommerce-jetpack' ) . '</li>'; break;
303
+ case 3: $default_value = '<li>' . __( '[wcj_product_total_sales before="Total sales: "]', 'woocommerce-jetpack' ) . '</li>'; break;
304
  case 4: $default_value = '</ul>'; break;
305
  }
306
+ // $desc = ( '' != $default_value ) ? __( 'Default', 'woocommerce-jetpack' ) . ': ' . esc_html( $default_value ) : '';
307
+ // $short_codes_list = '%you_save%, %total_sales%';
308
+ // $desc_tip = __( 'Field Nr. ', 'woocommerce-jetpack' ) . $i . '<br>' . __( 'Available short codes: ', 'woocommerce-jetpack' ) . $short_codes_list;
309
  $settings[] = array(
310
+ 'title' => '',
311
+ // 'desc_tip' => $desc_tip,
312
+ // 'desc' => $desc,
313
+ 'id' => $field_id,
314
+ 'default' => $default_value,
315
+ 'type' => 'textarea',
316
+ 'css' => 'width:50%;min-width:300px;',
317
  );
318
  }
319
  }
320
 
 
 
 
 
 
 
 
 
 
321
  /**
322
  * Get settings.
323
+ *
324
+ * @version 2.4.0
325
  */
326
  function get_settings() {
327
 
328
  $settings = array(
 
 
 
 
329
  array(
330
+ 'title' => __( 'Products Info', 'woocommerce-jetpack' ), 'type' => 'title',
331
+ 'desc' => __( 'For full list of short codes, please visit <a target="_blank" href="http://booster.io/shortcodes/">http://booster.io/shortcodes/</a>.', 'woocommerce-jetpack' ),
332
+ 'id' => 'wcj_more_product_info_options',
 
 
 
333
  ),
 
 
 
 
 
 
 
 
334
  );
 
335
  $this->admin_add_product_info_fields_with_header( $settings, 'archive', __( 'Product Info on Archive Pages', 'woocommerce-jetpack' ), $this->product_info_on_archive_filters_array );
336
+ $this->admin_add_product_info_fields_with_header( $settings, 'single', __( 'Product Info on Single Pages', 'woocommerce-jetpack' ), $this->product_info_on_single_filters_array );
337
+ $settings[] = array(
338
+ 'type' => 'sectionend',
339
+ 'id' => 'wcj_more_product_info_options',
340
+ );
341
 
342
  $settings = array_merge( $settings, array(
 
 
 
 
343
  array(
344
+ 'title' => __( 'Even More Products Info', 'woocommerce-jetpack' ),
345
+ 'type' => 'title',
346
+ 'id' => 'wcj_product_info_additional_options',
 
 
347
  ),
 
348
  array(
349
+ 'title' => __( 'Product Info on Archive Pages', 'woocommerce-jetpack' ),
350
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
351
+ 'id' => 'wcj_product_info_on_archive_enabled',
352
+ 'default' => 'no',
353
+ 'type' => 'checkbox',
354
+ ),
355
+ array(
356
+ 'title' => '',
357
+ 'desc_tip' => __( 'HTML info.', 'woocommerce-jetpack' ),
358
+ 'id' => 'wcj_product_info_on_archive',
359
+ 'default' => __( '[wcj_product_sku before="SKU: "]', 'woocommerce-jetpack' ),
360
+ 'type' => 'textarea',
361
+ 'css' => 'width:50%;min-width:300px;height:100px;',
362
  ),
 
363
  array(
364
  'title' => '',
365
  'desc' => __( 'Position', 'woocommerce-jetpack' ),
371
  'options' => $this->product_info_on_archive_filters_array,
372
  'desc_tip' => true,
373
  ),
 
374
  array(
375
  'title' => '',
376
+ 'desc_tip' => __( 'Priority (i.e. Order)', 'woocommerce-jetpack' ),
377
  'id' => 'wcj_product_info_on_archive_filter_priority',
378
  'default' => 10,
379
  'type' => 'number',
380
  ),
 
381
  array(
382
+ 'title' => __( 'Product Info on Single Product Pages', 'woocommerce-jetpack' ),
383
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
384
+ 'id' => 'wcj_product_info_on_single_enabled',
385
+ 'default' => 'no',
386
+ 'type' => 'checkbox',
387
  ),
 
388
  array(
389
+ 'title' => '',
390
+ 'desc_tip' => __( 'HTML info.', 'woocommerce-jetpack' ),// . ' ' . $this->list_short_codes(),
391
+ 'id' => 'wcj_product_info_on_single',
392
+ 'default' => __( 'Total sales: [wcj_product_total_sales]', 'woocommerce-jetpack' ),
393
+ 'type' => 'textarea',
394
+ 'css' => 'width:50%;min-width:300px;height:100px;',
 
 
 
395
  ),
 
396
  array(
397
  'title' => '',
398
  'desc' => __( 'Position', 'woocommerce-jetpack' ),
402
  'default' => 'woocommerce_after_single_product_summary',
403
  'type' => 'select',
404
  'options' => $this->product_info_on_single_filters_array,
405
+ 'desc_tip' => true,
406
  ),
 
407
  array(
408
  'title' => '',
409
+ 'desc_tip' => __( 'Priority (i.e. Order)', 'woocommerce-jetpack' ),
410
  'id' => 'wcj_product_info_on_single_filter_priority',
411
  'default' => 10,
412
  'type' => 'number',
413
  ),
 
414
  array(
415
  'title' => __( 'Product IDs to exclude', 'woocommerce-jetpack' ),
416
  'desc_tip' => __( 'Comma separated list of product IDs to exclude from product info.', 'woocommerce-jetpack' ),
419
  'type' => 'text',
420
  'css' => 'min-width:300px;',
421
  ),
422
+ array(
423
+ 'type' => 'sectionend',
424
+ 'id' => 'wcj_product_info_additional_options',
425
+ ),
426
  ) );
427
 
428
+ return $this->add_standard_settings( $settings );
 
 
 
 
 
 
 
 
429
  }
430
  }
431
 
includes/class-wcj-product-input-fields.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Product Input Fields class.
6
  *
7
- * @version 2.2.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -12,18 +12,22 @@ if ( ! defined( 'ABSPATH' ) ) exit;
12
 
13
  if ( ! class_exists( 'WCJ_Product_Input_Fields' ) ) :
14
 
15
- class WCJ_Product_Input_Fields {
16
 
17
  /**
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
 
@@ -37,18 +41,13 @@ class WCJ_Product_Input_Fields {
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 );
@@ -67,7 +66,7 @@ class WCJ_Product_Input_Fields {
67
  * handle_downloads.
68
  *
69
  * @version 2.2.2
70
- * @since 2.2.2
71
  */
72
  public function handle_downloads() {
73
  if ( isset ( $_GET['wcj_download_file'] ) ) {
@@ -111,41 +110,20 @@ class WCJ_Product_Input_Fields {
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
 
@@ -164,9 +142,14 @@ class WCJ_Product_Input_Fields {
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(
@@ -191,62 +174,95 @@ class WCJ_Product_Input_Fields {
191
  ),
192
 
193
  array(
194
- 'title' => __( 'Product Input Fields Number', 'woocommerce-jetpack' ),
195
- 'desc_tip' => __( 'Click "Save changes" after you change this number.', 'woocommerce-jetpack' ),
196
- 'id' => 'wcj_product_input_fields_global_total_number',
197
- 'default' => 1,
198
- 'type' => 'number',
199
- 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
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++ ) {
207
  foreach( $options as $option ) {
208
- $settings[] =
209
- array(
210
- 'title' => ( 'wcj_product_input_fields_enabled_global_' === $option['id'] ) ? __( 'Product Input Field', 'woocommerce-jetpack' ) . ' #' . $i : '',
211
- 'desc' => $option['title'],
212
- 'id' => $option['id'] . $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
  }
220
 
221
- $settings[] =
222
- array(
223
  'type' => 'sectionend',
224
  'id' => 'wcj_product_input_fields_global_options',
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
 
4
  *
5
  * The WooCommerce Jetpack Product Input Fields class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
12
 
13
  if ( ! class_exists( 'WCJ_Product_Input_Fields' ) ) :
14
 
15
+ class WCJ_Product_Input_Fields extends WCJ_Module {
16
 
17
  /**
18
  * Constructor.
19
+ * @version 2.4.0
20
  */
21
  public function __construct() {
22
 
23
+ $this->id = 'product_input_fields';
24
+ $this->short_desc = __( 'Product Input Fields', 'woocommerce-jetpack' );
25
+ $this->desc = __( 'WooCommerce product input fields.', 'woocommerce-jetpack' );
26
+ parent::__construct();
27
+
28
  include_once( 'input-fields/class-wcj-product-input-fields-abstract.php' );
29
 
30
+ if ( $this->is_enabled() ) {
 
31
 
32
  add_action( 'woocommerce_delete_order_items', array( $this, 'delete_file_uploads' ) );
33
 
41
  add_action( 'init', array( $this, 'register_scripts' ) );
42
  }
43
  }
 
 
 
 
 
44
  }
45
 
46
  /**
47
  * delete_file_uploads.
48
  *
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 );
66
  * handle_downloads.
67
  *
68
  * @version 2.2.2
69
+ * @since 2.2.2
70
  */
71
  public function handle_downloads() {
72
  if ( isset ( $_GET['wcj_download_file'] ) ) {
110
  return $product_input_fields_abstract->get_options();
111
  }
112
 
 
 
 
 
 
 
 
 
 
113
  /**
114
  * get_settings.
115
+ *
116
+ * @version 2.4.0
117
  */
118
  function get_settings() {
119
 
120
  $settings = array(
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  array(
123
  'title' => __( 'Product Input Fields per Product Options', 'woocommerce-jetpack' ),
124
  'type' => 'title',
125
+ 'desc' => __( 'Add custom input fields to product\'s single page for customer to fill before adding product to cart.', 'woocommerce-jetpack' ) . ' '
126
+ . __( 'When enabled this module will add "Product Input Fields" tab to each product\'s "Edit" page.', 'woocommerce-jetpack' ),
 
127
  'id' => 'wcj_product_input_fields_local_options',
128
  ),
129
 
142
  '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' ),
143
  'default' => 1,
144
  'type' => 'number',
145
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
146
+ 'custom_attributes' => array_merge(
147
+ is_array( apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) ) ? apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) : array(),
148
+ array(
149
+ 'step' => '1',
150
+ 'min' => '1',
151
+ )
152
+ ),
153
  ),
154
 
155
  array(
174
  ),
175
 
176
  array(
177
+ 'title' => __( 'Product Input Fields Number', 'woocommerce-jetpack' ),
178
+ 'desc_tip' => __( 'Click "Save changes" after you change this number.', 'woocommerce-jetpack' ),
179
+ 'id' => 'wcj_product_input_fields_global_total_number',
180
+ 'default' => 1,
181
+ 'type' => 'custom_number',
182
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
183
+ 'custom_attributes' => array_merge(
184
+ is_array( apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) ) ? apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ) : array(),
185
+ array(
186
+ 'step' => '1',
187
+ 'min' => '1',
188
+ )
189
+ ),
190
  ),
191
  );
192
 
193
  $options = $this->get_options();
194
  for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_product_input_fields_global_total_number', 1 ) ); $i++ ) {
195
  foreach( $options as $option ) {
196
+ $settings[] = array(
197
+ 'title' => ( 'wcj_product_input_fields_enabled_global_' === $option['id'] ) ? __( 'Product Input Field', 'woocommerce-jetpack' ) . ' #' . $i : '',
198
+ 'desc' => $option['title'],
199
+ 'desc_tip' => ( isset( $option['desc_tip'] ) ) ? $option['desc_tip'] : '',
200
+ 'id' => $option['id'] . $i,
201
+ 'default' => $option['default'],
202
+ 'type' => $option['type'],
203
+ 'options' => isset( $option['options'] ) ? $option['options'] : '',
204
+ 'css' => 'width:30%;min-width:300px;',
205
+ );
206
  }
207
  }
208
 
209
+ $settings[] = array(
 
210
  'type' => 'sectionend',
211
  'id' => 'wcj_product_input_fields_global_options',
212
+ );
213
 
214
  $settings = array_merge( $settings, array(
215
+ array(
216
+ 'title' => __( 'Frontend View Options', 'woocommerce-jetpack' ),
217
+ 'type' => 'title',
218
+ 'id' => 'wcj_product_input_fields_frontend_view_options',
219
+ ),
220
+
221
+ array(
222
+ 'title' => __( 'HTML to add after required field title', 'woocommerce-jetpack' ),
223
+ 'id' => 'wcj_product_input_fields_frontend_view_required_html',
224
+ 'default' => '&nbsp;<abbr class="required" title="required">*</abbr>',
225
+ 'type' => 'textarea',
226
+ 'css' => 'width:30%;min-width:300px;',
227
+ ),
228
 
229
  array(
230
+ 'title' => __( 'Item Name Order Table Format', 'woocommerce-jetpack' ),
231
+ 'desc_tip' => __( 'Affects Checkout, Emails and Admin Orders View', 'woocommerce-jetpack' ),
232
+ 'id' => 'wcj_product_input_fields_frontend_view_order_table_format',
233
+ 'default' => '&nbsp;| %title% %value%',
234
+ 'type' => 'textarea',
235
+ 'css' => 'width:30%;min-width:300px;',
236
  ),
237
 
238
+ array(
239
+ 'type' => 'sectionend',
240
+ 'id' => 'wcj_product_input_fields_frontend_view_options',
241
+ ),
242
  ) );
243
 
244
+ $settings = array_merge( $settings, array(
245
+ array(
246
+ 'title' => __( 'Admin Order View Options', 'woocommerce-jetpack' ),
247
+ 'type' => 'title',
248
+ 'id' => 'wcj_product_input_fields_admin_view_options',
249
+ ),
250
 
251
+ array(
252
+ 'title' => __( 'Replace Field ID with Field Label', 'woocommerce-jetpack' ),
253
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
254
+ 'id' => 'wcj_product_input_fields_make_nicer_name_enabled',
255
+ 'default' => 'yes',
256
+ 'type' => 'checkbox',
257
+ ),
258
+
259
+ array(
260
+ 'type' => 'sectionend',
261
+ 'id' => 'wcj_product_input_fields_admin_view_options',
262
+ ),
263
+ ) );
264
+
265
+ return $this->add_standard_settings( $settings );
266
  }
267
  }
268
 
includes/class-wcj-shortcodes.php DELETED
@@ -1,89 +0,0 @@
1
- <?php
2
- /**
3
- * WooCommerce Jetpack Shortcodes
4
- *
5
- * The WooCommerce Jetpack Shortcodes class.
6
- *
7
- * @class WCJ_Shortcodes
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_Shortcodes' ) ) :
16
-
17
- class WCJ_Shortcodes {
18
-
19
- /**
20
- * Constructor.
21
- */
22
- public function __construct() {
23
-
24
- // Main hooks
25
- //if ( 'yes' === get_option( 'wcj_shortcodes_enabled' ) ) {
26
- //add_shortcode( 'wcj_sku', array( 'WCJ_Product_Info', 'shortcode_product_info_sku' ) );
27
- //add_shortcode( 'wcj_sku', array( &WCJ_Product_Info, 'shortcode_product_info_sku' ) );
28
- //}
29
-
30
- // Settings hooks
31
- //add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
32
- //add_filter( 'wcj_settings_shortcodes', array( $this, 'get_settings' ), 100 );
33
- //add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
34
- }
35
-
36
-
37
-
38
- /**
39
- * add_enabled_option.
40
- *
41
- public function shortcode_product_info_sku( $atts ) {
42
- return 'ttt';
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
- function get_settings() {
58
-
59
- $settings = array(
60
-
61
- array( 'title' => __( 'Shortcodes Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'Shortcodes.', 'woocommerce-jetpack' ), 'id' => 'wcj_shortcodes_options' ),
62
-
63
- array(
64
- 'title' => __( 'Shortcodes', 'woocommerce-jetpack' ),
65
- 'desc' => __( 'Enable the Shortcodes feature', 'woocommerce-jetpack' ),
66
- 'desc_tip' => __( 'Shortcodes.', 'woocommerce-jetpack' ),
67
- 'id' => 'wcj_shortcodes_enabled',
68
- 'default' => 'yes',
69
- 'type' => 'checkbox',
70
- ),
71
-
72
- array( 'type' => 'sectionend', 'id' => 'wcj_shortcodes_options' ),
73
- );
74
-
75
- return $settings;
76
- }
77
-
78
- /**
79
- * settings_section.
80
- */
81
- function settings_section( $sections ) {
82
- $sections['shortcodes'] = __( 'Shortcodes', 'woocommerce-jetpack' );
83
- return $sections;
84
- }
85
- }
86
-
87
- endif;
88
-
89
- return new WCJ_Shortcodes();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-wcj-sku.php CHANGED
@@ -4,8 +4,9 @@
4
  *
5
  * The WooCommerce Jetpack SKU class.
6
  *
7
- * @version 2.3.10
8
  * @author Algoritmika Ltd.
 
9
  */
10
 
11
  if ( ! defined( 'ABSPATH' ) ) exit;
@@ -17,7 +18,7 @@ class WCJ_SKU extends WCJ_Module {
17
  /**
18
  * Constructor.
19
  *
20
- * @version 2.3.10
21
  */
22
  function __construct() {
23
 
@@ -29,7 +30,7 @@ class WCJ_SKU extends WCJ_Module {
29
  $this->add_tools( array(
30
  'sku' => array(
31
  'title' => __( 'Autogenerate SKUs', 'woocommerce-jetpack' ),
32
- 'desc' => __( 'The tool generates and sets product SKUs.', 'woocommerce-jetpack' ),//__( 'Autogenerate SKUs for Existing Products', 'woocommerce-jetpack' ),
33
  ),
34
  ) );
35
 
@@ -40,33 +41,37 @@ class WCJ_SKU extends WCJ_Module {
40
 
41
  /**
42
  * set_sku_with_variable.
 
 
 
43
  */
44
  function set_sku_with_variable( $product_id, $is_preview ) {
45
 
46
- $this->set_sku( $product_id, $product_id, '', $is_preview );
47
 
48
  // Handling variable products
49
  $variation_handling = apply_filters( 'wcj_get_option_filter', 'as_variable', get_option( 'wcj_sku_variations_handling', 'as_variable' ) );
50
  $product = wc_get_product( $product_id );
51
  if ( $product->is_type( 'variable' ) ) {
52
-
53
  $variations = $product->get_available_variations();
54
-
55
  if ( 'as_variable' === $variation_handling ) {
56
- foreach( $variations as $variation )
57
- $this->set_sku( $variation['variation_id'], $product_id, '', $is_preview );
 
58
  }
59
  else if ( 'as_variation' === $variation_handling ) {
60
- foreach( $variations as $variation )
61
- $this->set_sku( $variation['variation_id'], $variation['variation_id'], '', $is_preview );
 
62
  }
63
  else if ( 'as_variable_with_suffix' === $variation_handling ) {
64
  $variation_suffixes = 'abcdefghijklmnopqrstuvwxyz';
65
  $abc = 0;
66
- foreach( $variations as $variation ) {
67
- $this->set_sku( $variation['variation_id'], $product_id, $variation_suffixes[ $abc++ ], $is_preview );
68
- if ( 26 == $abc )
69
  $abc = 0;
 
70
  }
71
  }
72
  }
@@ -74,19 +79,44 @@ class WCJ_SKU extends WCJ_Module {
74
 
75
  /**
76
  * set_sku.
 
 
77
  */
78
- function set_sku( $product_id, $sku_number, $variation_suffix, $is_preview ) {
79
- $the_sku = sprintf( '%s%0' . get_option( 'wcj_sku_minimum_number_length', 0 ) . 'd%s%s',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  get_option( 'wcj_sku_prefix', '' ),
81
  $sku_number,
82
- apply_filters( 'wcj_get_option_filter', '', get_option( 'wcj_sku_suffix', '' ) ),
83
- $variation_suffix );
 
 
 
84
  if ( $is_preview ) {
85
  echo '<tr>' .
86
- '<td>' . $this->product_counter++ . '</td>' .
87
- '<td>' . get_the_title( $product_id ) . '</td>' .
88
- '<td>' . $the_sku . '</td>' .
89
- '</tr>';
 
90
  }
91
  else {
92
  update_post_meta( $product_id, '_' . 'sku', $the_sku );
@@ -96,10 +126,10 @@ class WCJ_SKU extends WCJ_Module {
96
  /**
97
  * set_all_products_skus.
98
  *
99
- * @version 2.3.10
100
  */
101
  function set_all_products_skus( $is_preview ) {
102
- $limit = 1000;
103
  $offset = 0;
104
  while ( TRUE ) {
105
  $posts = new WP_Query( array(
@@ -110,11 +140,12 @@ class WCJ_SKU extends WCJ_Module {
110
  ));
111
  if ( ! $posts->have_posts() ) break;
112
  while ( $posts->have_posts() ) {
113
- $posts->the_post();
114
- $this->set_sku_with_variable( $posts->post->ID, $is_preview );
115
  }
116
  $offset += $limit;
117
  }
 
118
  }
119
 
120
  /**
@@ -134,19 +165,20 @@ class WCJ_SKU extends WCJ_Module {
134
  /**
135
  * create_sku_tool
136
  *
137
- * @version 2.3.10
138
  */
139
  function create_sku_tool() {
140
  $result_message = '';
141
  $is_preview = ( isset( $_POST['preview_sku'] ) ) ? true : false;
142
  if ( isset( $_POST['set_sku'] ) || isset( $_POST['preview_sku'] ) ) {
143
  $this->product_counter = 1;
144
- $preview_html = '<table class="widefat" style="width:50%; min-width: 300px;">';
145
  $preview_html .=
146
  '<tr>' .
147
  '<th></th>' .
148
- '<th>' . __( 'Product', 'woocommerce-jetpack' ) . '</th>' .
149
- '<th>' . __( 'SKU', 'woocommerce-jetpack' ) . '</th>' .
 
150
  '</tr>';
151
  ob_start();
152
  $this->set_all_products_skus( $is_preview );
@@ -157,16 +189,18 @@ class WCJ_SKU extends WCJ_Module {
157
  ?><div>
158
  <?php echo $this->get_tool_header_html( 'sku' ); ?>
159
  <?php if ( ! $is_preview ) echo $result_message; ?>
160
- <p><form method="post" action="">
161
  <input class="button-primary" type="submit" name="preview_sku" id="preview_sku" value="<?php _e( 'Preview SKUs', 'woocommerce-jetpack' ); ?>">
162
  <input class="button-primary" type="submit" name="set_sku" value="<?php _e( 'Set SKUs', 'woocommerce-jetpack' ); ?>">
163
- </form></p>
164
  <?php if ( $is_preview ) echo $preview_html; ?>
165
  </div><?php
166
  }
167
 
168
  /**
169
  * get_settings.
 
 
170
  */
171
  function get_settings() {
172
 
@@ -179,6 +213,19 @@ class WCJ_SKU extends WCJ_Module {
179
  'id' => 'wcj_sku_format_options',
180
  ),
181
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  array(
183
  'title' => __( 'Prefix', 'woocommerce-jetpack' ),
184
  'id' => 'wcj_sku_prefix',
@@ -198,8 +245,8 @@ class WCJ_SKU extends WCJ_Module {
198
  'id' => 'wcj_sku_suffix',
199
  'default' => '',
200
  'type' => 'text',
201
- 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
202
- 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
203
  ),
204
 
205
  array(
@@ -220,10 +267,49 @@ class WCJ_SKU extends WCJ_Module {
220
  'type' => 'sectionend',
221
  'id' => 'wcj_sku_format_options',
222
  ),
 
223
 
 
 
 
 
 
224
  );
225
 
226
- return $this->add_standard_settings( $settings, __( 'When enabled - all new products will be given (autogenerated) SKU.<br>If you wish to set SKUs for existing products, use Autogenerate SKUs Tool.', 'woocommerce-jetpack' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  }
228
  }
229
 
4
  *
5
  * The WooCommerce Jetpack SKU class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
+ * @todo add "random number" option
10
  */
11
 
12
  if ( ! defined( 'ABSPATH' ) ) exit;
18
  /**
19
  * Constructor.
20
  *
21
+ * @version 2.4.0
22
  */
23
  function __construct() {
24
 
30
  $this->add_tools( array(
31
  'sku' => array(
32
  'title' => __( 'Autogenerate SKUs', 'woocommerce-jetpack' ),
33
+ 'desc' => __( 'The tool generates and sets product SKUs for existing products.', 'woocommerce-jetpack' ),
34
  ),
35
  ) );
36
 
41
 
42
  /**
43
  * set_sku_with_variable.
44
+ *
45
+ * @version 2.4.0
46
+ * @todo Handle cases with more than 26 variations
47
  */
48
  function set_sku_with_variable( $product_id, $is_preview ) {
49
 
50
+ $this->set_sku( $product_id, $product_id, '', $is_preview, $product_id );
51
 
52
  // Handling variable products
53
  $variation_handling = apply_filters( 'wcj_get_option_filter', 'as_variable', get_option( 'wcj_sku_variations_handling', 'as_variable' ) );
54
  $product = wc_get_product( $product_id );
55
  if ( $product->is_type( 'variable' ) ) {
 
56
  $variations = $product->get_available_variations();
 
57
  if ( 'as_variable' === $variation_handling ) {
58
+ foreach ( $variations as $variation ) {
59
+ $this->set_sku( $variation['variation_id'], $product_id, '', $is_preview, $product_id );
60
+ }
61
  }
62
  else if ( 'as_variation' === $variation_handling ) {
63
+ foreach ( $variations as $variation ) {
64
+ $this->set_sku( $variation['variation_id'], $variation['variation_id'], '', $is_preview, $product_id );
65
+ }
66
  }
67
  else if ( 'as_variable_with_suffix' === $variation_handling ) {
68
  $variation_suffixes = 'abcdefghijklmnopqrstuvwxyz';
69
  $abc = 0;
70
+ foreach ( $variations as $variation ) {
71
+ $this->set_sku( $variation['variation_id'], $product_id, $variation_suffixes[ $abc++ ], $is_preview, $product_id );
72
+ if ( 26 == $abc ) {
73
  $abc = 0;
74
+ }
75
  }
76
  }
77
  }
79
 
80
  /**
81
  * set_sku.
82
+ *
83
+ * @version 2.4.0
84
  */
85
+ function set_sku( $product_id, $sku_number, $variation_suffix, $is_preview, $parent_product_id ) {
86
+
87
+ $category_prefix = '';
88
+ $category_suffix = '';
89
+ $product_cat = '';
90
+ $product_terms = get_the_terms( $parent_product_id, 'product_cat' );
91
+ if ( is_array( $product_terms ) ) {
92
+ foreach ( $product_terms as $term ) {
93
+ $product_cat = esc_html( $term->name );
94
+ $category_prefix = get_option( 'wcj_sku_prefix_cat_' . $term->term_id, '' );
95
+ $category_suffix = get_option( 'wcj_sku_suffix_cat_' . $term->term_id, '' );
96
+ break;
97
+ }
98
+ }
99
+
100
+ /* if ( 'random' === get_option( 'wcj_sku_number_generation', 'product_id' ) ) {
101
+ $sku_number = rand();
102
+ } */
103
+
104
+ $the_sku = sprintf( '%s%s%0' . get_option( 'wcj_sku_minimum_number_length', 0 ) . 'd%s%s%s',
105
+ apply_filters( 'wcj_get_option_filter', '', $category_prefix ),
106
  get_option( 'wcj_sku_prefix', '' ),
107
  $sku_number,
108
+ get_option( 'wcj_sku_suffix', '' ),
109
+ $variation_suffix,
110
+ $category_suffix
111
+ );
112
+
113
  if ( $is_preview ) {
114
  echo '<tr>' .
115
+ '<td>' . $this->product_counter++ . '</td>' .
116
+ '<td>' . get_the_title( $product_id ) . ' (' . __( 'ID', 'woocommerce-jetpack' ) . ':' . $product_id . ')' . '</td>' .
117
+ '<td>' . $product_cat . '</td>' .
118
+ '<td>' . $the_sku . '</td>' .
119
+ '</tr>';
120
  }
121
  else {
122
  update_post_meta( $product_id, '_' . 'sku', $the_sku );
126
  /**
127
  * set_all_products_skus.
128
  *
129
+ * @version 2.4.0
130
  */
131
  function set_all_products_skus( $is_preview ) {
132
+ $limit = 96;
133
  $offset = 0;
134
  while ( TRUE ) {
135
  $posts = new WP_Query( array(
140
  ));
141
  if ( ! $posts->have_posts() ) break;
142
  while ( $posts->have_posts() ) {
143
+ $posts->the_post();
144
+ $this->set_sku_with_variable( $posts->post->ID, $is_preview );
145
  }
146
  $offset += $limit;
147
  }
148
+ wp_reset_postdata();
149
  }
150
 
151
  /**
165
  /**
166
  * create_sku_tool
167
  *
168
+ * @version 2.4.0
169
  */
170
  function create_sku_tool() {
171
  $result_message = '';
172
  $is_preview = ( isset( $_POST['preview_sku'] ) ) ? true : false;
173
  if ( isset( $_POST['set_sku'] ) || isset( $_POST['preview_sku'] ) ) {
174
  $this->product_counter = 1;
175
+ $preview_html = '<table class="widefat" style="width:50%; min-width: 300px; margin-top: 10px;">';
176
  $preview_html .=
177
  '<tr>' .
178
  '<th></th>' .
179
+ '<th>' . __( 'Product', 'woocommerce-jetpack' ) . '</th>' .
180
+ '<th>' . __( 'Categories', 'woocommerce-jetpack' ) . '</th>' .
181
+ '<th>' . __( 'SKU', 'woocommerce-jetpack' ) . '</th>' .
182
  '</tr>';
183
  ob_start();
184
  $this->set_all_products_skus( $is_preview );
189
  ?><div>
190
  <?php echo $this->get_tool_header_html( 'sku' ); ?>
191
  <?php if ( ! $is_preview ) echo $result_message; ?>
192
+ <form method="post" action="">
193
  <input class="button-primary" type="submit" name="preview_sku" id="preview_sku" value="<?php _e( 'Preview SKUs', 'woocommerce-jetpack' ); ?>">
194
  <input class="button-primary" type="submit" name="set_sku" value="<?php _e( 'Set SKUs', 'woocommerce-jetpack' ); ?>">
195
+ </form>
196
  <?php if ( $is_preview ) echo $preview_html; ?>
197
  </div><?php
198
  }
199
 
200
  /**
201
  * get_settings.
202
+ *
203
+ * @version 2.4.0
204
  */
205
  function get_settings() {
206
 
213
  'id' => 'wcj_sku_format_options',
214
  ),
215
 
216
+ /* array(
217
+ 'title' => __( 'Number Generation', 'woocommerce-jetpack' ),
218
+ 'id' => 'wcj_sku_number_generation',
219
+ 'default' => 'product_id',
220
+ 'type' => 'select',
221
+ 'options' => array(
222
+ 'product_id' => __( 'From product ID (recommended)', 'woocommerce-jetpack' ),
223
+ 'random' => __( 'Random (including variations)', 'woocommerce-jetpack' ),
224
+ ),
225
+ // 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
226
+ // 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
227
+ ), */
228
+
229
  array(
230
  'title' => __( 'Prefix', 'woocommerce-jetpack' ),
231
  'id' => 'wcj_sku_prefix',
245
  'id' => 'wcj_sku_suffix',
246
  'default' => '',
247
  'type' => 'text',
248
+ // 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
249
+ // 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
250
  ),
251
 
252
  array(
267
  'type' => 'sectionend',
268
  'id' => 'wcj_sku_format_options',
269
  ),
270
+ );
271
 
272
+ $settings[] = array(
273
+ 'title' => __( 'Categories Options', 'woocommerce-jetpack' ),
274
+ 'type' => 'title',
275
+ 'desc' => '',
276
+ 'id' => 'wcj_sku_categories_options',
277
  );
278
 
279
+ $product_categories = get_terms( 'product_cat', 'orderby=name&hide_empty=0' );
280
+ if ( ! empty( $product_categories ) && ! is_wp_error( $product_categories ) ){
281
+ foreach ( $product_categories as $product_category ) {
282
+ $settings[] = array(
283
+ 'title' => $product_category->name,
284
+ 'desc' => __( 'Prefix', 'woocommerce-jetpack' ),
285
+ 'id' => 'wcj_sku_prefix_cat_' . $product_category->term_id,
286
+ 'default' => '',
287
+ 'type' => 'text',
288
+ 'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc_no_link' ),
289
+ 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
290
+ );
291
+ $settings[] = array(
292
+ 'title' => '',
293
+ 'desc' => __( 'Suffix', 'woocommerce-jetpack' ),
294
+ 'id' => 'wcj_sku_suffix_cat_' . $product_category->term_id,
295
+ 'default' => '',
296
+ 'type' => 'text',
297
+ // 'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc_no_link' ),
298
+ // 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
299
+ );
300
+ }
301
+ }
302
+
303
+ $settings[] = array(
304
+ 'type' => 'sectionend',
305
+ 'id' => 'wcj_sku_format_options',
306
+ );
307
+
308
+ return $this->add_standard_settings(
309
+ $settings,
310
+ __( 'When enabled - all new products will be given (autogenerated) SKU.', 'woocommerce-jetpack' ) . '<br>' .
311
+ __( 'If you wish to set SKUs for existing products, use "Autogenerate SKUs" Tool.', 'woocommerce-jetpack' )
312
+ );
313
  }
314
  }
315
 
includes/classes/class-wcj-module.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Module class.
6
  *
7
- * @version 2.3.10
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
@@ -23,39 +23,66 @@ if ( ! class_exists( 'WCJ_Module' ) ) :
23
 
24
  /**
25
  * Constructor.
 
 
26
  */
27
  public function __construct( $type = 'module' ) {
28
- // Settings hooks
29
  add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
30
  add_filter( 'wcj_settings_' . $this->id, array( $this, 'get_settings' ), 100 );
31
  $this->type = $type;
32
  if ( 'module' === $this->type ) {
33
  $this->parent_id = '';
34
- //add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
36
  }
37
 
38
  /**
39
  * add_standard_settings.
40
  *
41
- * @version 2.3.10
42
  * @since 2.3.10
43
  */
44
  function add_standard_settings( $settings = array(), $module_desc = '' ) {
45
  if ( isset( $this->tools_array ) && ! empty( $this->tools_array ) ) {
46
  $settings = $this->add_tools_list( $settings );
47
  }
 
48
  return $this->add_enable_module_setting( $settings, $module_desc );
49
  }
50
 
51
  /**
52
  * get_settings.
53
  *
54
- * @since 2.2.6
 
55
  */
56
  function get_settings() {
57
- $settings = array();
58
- return $this->add_enable_module_setting( $settings );
59
  }
60
 
61
  /**
@@ -315,6 +342,40 @@ if ( ! class_exists( 'WCJ_Module' ) ) :
315
  }
316
  }
317
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
318
  /**
319
  * settings_section.
320
  * only for `module`
4
  *
5
  * The WooCommerce Jetpack Module class.
6
  *
7
+ * @version 2.4.0
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
23
 
24
  /**
25
  * Constructor.
26
+ *
27
+ * @version 2.4.0
28
  */
29
  public function __construct( $type = 'module' ) {
 
30
  add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
31
  add_filter( 'wcj_settings_' . $this->id, array( $this, 'get_settings' ), 100 );
32
  $this->type = $type;
33
  if ( 'module' === $this->type ) {
34
  $this->parent_id = '';
35
+ }
36
+ add_action( 'init', array( $this, 'reset_settings' ) );
37
+ }
38
+
39
+ /**
40
+ * reset_settings.
41
+ *
42
+ * @version 2.4.0
43
+ * @since 2.4.0
44
+ */
45
+ function reset_settings() {
46
+ if ( isset( $_GET['wcj_reset_settings'] ) && $this->id === $_GET['wcj_reset_settings'] && is_super_admin() && ! isset( $_POST['save'] ) ) {
47
+ global $wcj_notice;
48
+ if ( ! isset( $_GET['wcj_confirm_reset_settings'] ) ) {
49
+ $wcj_notice .= __( 'Are you sure you want to reset current module\'s settings to default values?', 'woocommerce-jetpack' );
50
+ $yes_button_style = "background: green; border-color: green; box-shadow: 0 1px 0 green; text-shadow: 0 -1px 1px #0a0,1px 0 1px #0a0,0 1px 1px #0a0,-1px 0 1px #0a0;";
51
+ $no_button_style = "background: red; border-color: red; box-shadow: 0 1px 0 red; text-shadow: 0 -1px 1px #a00,1px 0 1px #a00,0 1px 1px #a00,-1px 0 1px #a00;";
52
+ $wcj_notice .= ' ' . '<a class="button-primary" style="' . $yes_button_style . '" href="' . add_query_arg( 'wcj_confirm_reset_settings', 'yes' ) . '">' . __( 'Yes', 'woocommerce-jetpack' ) . '</a>';
53
+ $wcj_notice .= ' ' . '<a class="button-primary" style="' . $no_button_style . '" href="' . remove_query_arg( 'wcj_reset_settings' ) . '">' . __( 'No', 'woocommerce-jetpack' ) . '</a>';
54
+ } else {
55
+ foreach ( $this->get_settings() as $settings ) {
56
+ $default_value = isset( $settings['default'] ) ? $settings['default'] : '';
57
+ update_option( $settings['id'], $default_value );
58
+ }
59
+ $wcj_notice .= __( 'Settings have been reset to defaults.', 'woocommerce-jetpack' );
60
+ }
61
  }
62
  }
63
 
64
  /**
65
  * add_standard_settings.
66
  *
67
+ * @version 2.4.0
68
  * @since 2.3.10
69
  */
70
  function add_standard_settings( $settings = array(), $module_desc = '' ) {
71
  if ( isset( $this->tools_array ) && ! empty( $this->tools_array ) ) {
72
  $settings = $this->add_tools_list( $settings );
73
  }
74
+ $settings = $this->add_reset_settings_button( $settings );
75
  return $this->add_enable_module_setting( $settings, $module_desc );
76
  }
77
 
78
  /**
79
  * get_settings.
80
  *
81
+ * @version 2.4.0
82
+ * @since 2.2.6
83
  */
84
  function get_settings() {
85
+ return $this->add_standard_settings();
 
86
  }
87
 
88
  /**
342
  }
343
  }
344
 
345
+ /**
346
+ * add_reset_settings_button.
347
+ *
348
+ * @version 2.4.0
349
+ * @since 2.4.0
350
+ */
351
+ function add_reset_settings_button( $settings ) {
352
+ $reset_button_style = "background: red; border-color: red; box-shadow: 0 1px 0 red; text-shadow: 0 -1px 1px #a00,1px 0 1px #a00,0 1px 1px #a00,-1px 0 1px #a00;";
353
+ $reset_settings_setting = array(
354
+ array(
355
+ 'title' => __( 'Reset Settings', 'woocommerce-jetpack' ),
356
+ 'type' => 'title',
357
+ 'id' => 'wcj_' . $this->id . '_reset_settings_options',
358
+ ),
359
+ array(
360
+ 'title' => __( 'Reset Module to Default Settings', 'woocommerce-jetpack' ),
361
+ 'id' => 'wcj_' . $this->id . '_reset_settings',
362
+ 'type' => 'custom_link',
363
+ 'link' => '<a class="button-primary" style="' . $reset_button_style . '" href="' . add_query_arg( 'wcj_reset_settings', $this->id, remove_query_arg( 'wcj_confirm_reset_settings' ) ) . '">' . __( 'Reset settings', 'woocommerce-jetpack' ) . '</a>',
364
+ ),
365
+ /* array(
366
+ 'title' => __( 'Reset to Default Settings', 'woocommerce-jetpack' ),
367
+ 'id' => 'wcj_' . $this->id . '_reset_settings',
368
+ 'type' => 'custom_link',
369
+ 'link' => '<input name="wcj_reset_settings" class="button-primary" type="submit" value="Reset settings">',
370
+ ), */
371
+ array(
372
+ 'type' => 'sectionend',
373
+ 'id' => 'wcj_' . $this->id . '_reset_settings_options',
374
+ ),
375
+ );
376
+ return array_merge( $settings, $reset_settings_setting );
377
+ }
378
+
379
  /**
380
  * settings_section.
381
  * only for `module`
includes/emails/class-wc-email-wcj-custom.php CHANGED
@@ -11,7 +11,7 @@ if ( ! class_exists( 'WC_Email_WCJ_Custom' ) ) :
11
  *
12
  * An email sent to recipient list when selected triggers are called.
13
  *
14
- * @version 2.3.9
15
  * @since 2.3.9
16
  * @author Algoritmika Ltd.
17
  * @extends WC_Email
@@ -20,10 +20,13 @@ class WC_Email_WCJ_Custom extends WC_Email {
20
 
21
  /**
22
  * Constructor
 
 
23
  */
24
  function __construct( $id = 1 ) {
25
 
26
  $this->id = 'wcj_custom' . '_' . $id;
 
27
  $this->title = __( 'Custom', 'woocommerce-jetpack' ) . ' #' . $id;
28
  $this->description = __( 'Custom emails are sent to the recipient list when selected triggers are called.', 'woocommerce-jetpack' );
29
 
@@ -45,20 +48,28 @@ class WC_Email_WCJ_Custom extends WC_Email {
45
  parent::__construct();
46
 
47
  // Other settings
48
- $this->recipient = $this->get_option( 'recipient' );
 
49
 
50
- if ( ! $this->recipient )
51
- $this->recipient = get_option( 'admin_email' );
 
52
  }
53
 
54
  /**
55
  * Trigger.
 
 
56
  */
57
  function trigger( $order_id ) {
58
 
59
  if ( $order_id ) {
60
  $this->object = wc_get_order( $order_id );
61
 
 
 
 
 
62
  $this->find['order-date'] = '{order_date}';
63
  $this->find['order-number'] = '{order_number}';
64
 
@@ -118,16 +129,47 @@ class WC_Email_WCJ_Custom extends WC_Email {
118
  return $this->get_option( 'content_plain_template' );
119
  }
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  /**
122
  * Initialise settings form fields
 
 
123
  */
124
  function init_form_fields() {
 
125
  ob_start();
126
  include( 'email-html.php' );
127
  $default_html_template = ob_get_clean();
128
  ob_start();
129
  include( 'email-plain.php' );
130
  $default_plain_template = ob_get_clean();
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  $this->form_fields = array(
132
  'enabled' => array(
133
  'title' => __( 'Enable/Disable', 'woocommerce' ),
@@ -140,32 +182,23 @@ class WC_Email_WCJ_Custom extends WC_Email {
140
  'type' => 'multiselect',
141
  'placeholder' => '',
142
  'default' => array(),
143
- 'options' => array(
144
- 'woocommerce_order_status_pending_to_processing_notification' => __( 'Order status pending to processing', 'woocommerce-jetpack' ),
145
- 'woocommerce_order_status_pending_to_completed_notification' => __( 'Order status pending to completed', 'woocommerce-jetpack' ),
146
- 'woocommerce_order_status_pending_to_on-hold_notification' => __( 'Order status pending to on-hold', 'woocommerce-jetpack' ),
147
- 'woocommerce_order_status_pending_to_cancelled_notification' => __( 'Order status pending to cancelled', 'woocommerce-jetpack' ),
148
-
149
- 'woocommerce_order_status_failed_to_processing_notification' => __( 'Order status failed to processing', 'woocommerce-jetpack' ),
150
- 'woocommerce_order_status_failed_to_completed_notification' => __( 'Order status failed to completed', 'woocommerce-jetpack' ),
151
- 'woocommerce_order_status_failed_to_on-hold_notification' => __( 'Order status failed to on-hold', 'woocommerce-jetpack' ),
152
-
153
- 'woocommerce_order_status_completed_notification' => __( 'Order status completed', 'woocommerce-jetpack' ),
154
-
155
- 'woocommerce_order_status_on-hold_to_cancelled_notification' => __( 'Order status on-hold to cancelled', 'woocommerce-jetpack' ),
156
-
157
- 'woocommerce_reset_password_notification' => __( 'Reset password notification', 'woocommerce-jetpack' ),
158
-
159
- 'woocommerce_order_fully_refunded_notification' => __( 'Order fully refunded notification', 'woocommerce-jetpack' ),
160
- 'woocommerce_order_partially_refunded_notification' => __( 'Order partially refunded notification', 'woocommerce-jetpack' ),
161
-
162
- 'woocommerce_new_customer_note_notification' => __( 'New customer note notification', 'woocommerce-jetpack' ),
163
  ),
 
 
164
  ),
165
  'recipient' => array(
166
  'title' => __( 'Recipient(s)', 'woocommerce' ),
167
  'type' => 'text',
168
- 'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to <code>%s</code>.', 'woocommerce' ), esc_attr( get_option('admin_email') ) ),
169
  'placeholder' => '',
170
  'default' => '',
171
  ),
11
  *
12
  * An email sent to recipient list when selected triggers are called.
13
  *
14
+ * @version 2.4.0
15
  * @since 2.3.9
16
  * @author Algoritmika Ltd.
17
  * @extends WC_Email
20
 
21
  /**
22
  * Constructor
23
+ *
24
+ * @version 2.4.0
25
  */
26
  function __construct( $id = 1 ) {
27
 
28
  $this->id = 'wcj_custom' . '_' . $id;
29
+ $this->customer_email = ( '%customer%' === $this->get_option( 'recipient' ) ) ? true : false;
30
  $this->title = __( 'Custom', 'woocommerce-jetpack' ) . ' #' . $id;
31
  $this->description = __( 'Custom emails are sent to the recipient list when selected triggers are called.', 'woocommerce-jetpack' );
32
 
48
  parent::__construct();
49
 
50
  // Other settings
51
+ if ( ! $this->customer_email ) {
52
+ $this->recipient = $this->get_option( 'recipient' );
53
 
54
+ if ( ! $this->recipient )
55
+ $this->recipient = get_option( 'admin_email' );
56
+ }
57
  }
58
 
59
  /**
60
  * Trigger.
61
+ *
62
+ * @version 2.4.0
63
  */
64
  function trigger( $order_id ) {
65
 
66
  if ( $order_id ) {
67
  $this->object = wc_get_order( $order_id );
68
 
69
+ if ( $this->customer_email ) {
70
+ $this->recipient = $this->object->billing_email;
71
+ }
72
+
73
  $this->find['order-date'] = '{order_date}';
74
  $this->find['order-number'] = '{order_number}';
75
 
129
  return $this->get_option( 'content_plain_template' );
130
  }
131
 
132
+ /**
133
+ * get_order_statuses.
134
+ *
135
+ * @version 2.4.0
136
+ * @since 2.4.0
137
+ */
138
+ function get_order_statuses() {
139
+ $result = array();
140
+ $statuses = function_exists( 'wc_get_order_statuses' ) ? wc_get_order_statuses() : array();
141
+ foreach( $statuses as $status => $status_name ) {
142
+ $result[ substr( $status, 3 ) ] = $statuses[ $status ];
143
+ }
144
+ return $result;
145
+ }
146
+
147
  /**
148
  * Initialise settings form fields
149
+ *
150
+ * @version 2.4.0
151
  */
152
  function init_form_fields() {
153
+
154
  ob_start();
155
  include( 'email-html.php' );
156
  $default_html_template = ob_get_clean();
157
  ob_start();
158
  include( 'email-plain.php' );
159
  $default_plain_template = ob_get_clean();
160
+
161
+ $status_change_triggers = array();
162
+ $status_triggers = array();
163
+ $order_statuses = $this->get_order_statuses();
164
+ foreach ( $order_statuses as $slug => $name ) {
165
+ $status_triggers[ 'woocommerce_order_status_' . $slug . '_notification' ] = sprintf( __( 'Order status %s', 'woocommerce-jetpack' ), $name );
166
+ foreach ( $order_statuses as $slug2 => $name2 ) {
167
+ if ( $slug != $slug2 ) {
168
+ $status_change_triggers[ 'woocommerce_order_status_' . $slug . '_to_' . $slug2 . '_notification' ] = sprintf( __( 'Order status %s to %s', 'woocommerce-jetpack' ), $name, $name2 );
169
+ }
170
+ }
171
+ }
172
+
173
  $this->form_fields = array(
174
  'enabled' => array(
175
  'title' => __( 'Enable/Disable', 'woocommerce' ),
182
  'type' => 'multiselect',
183
  'placeholder' => '',
184
  'default' => array(),
185
+ 'options' => array_merge(
186
+ $status_triggers,
187
+ array(
188
+ 'woocommerce_reset_password_notification' => __( 'Reset password notification', 'woocommerce-jetpack' ),
189
+ 'woocommerce_order_fully_refunded_notification' => __( 'Order fully refunded notification', 'woocommerce-jetpack' ),
190
+ 'woocommerce_order_partially_refunded_notification' => __( 'Order partially refunded notification', 'woocommerce-jetpack' ),
191
+ 'woocommerce_new_customer_note_notification' => __( 'New customer note notification', 'woocommerce-jetpack' ),
192
+ ),
193
+ $status_change_triggers
 
 
 
 
 
 
 
 
 
 
 
194
  ),
195
+ 'css' => 'height:300px;',
196
+ // 'class' => 'chosen_select',
197
  ),
198
  'recipient' => array(
199
  'title' => __( 'Recipient(s)', 'woocommerce' ),
200
  'type' => 'text',
201
+ 'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to <code>%s</code>.', 'woocommerce' ), esc_attr( get_option('admin_email') ) ) . ' ' . __( 'Or enter <code>%customer%</code> to send to customer billing email.', 'woocommerce-jetpack' ),
202
  'placeholder' => '',
203
  'default' => '',
204
  ),
includes/functions/wcj-country-functions.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Country Jetpack Functions.
6
  *
7
- * @version 2.2.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -30,6 +30,7 @@ if ( ! function_exists( 'wcj_get_customer_country' ) ) {
30
  /**
31
  * wcj_get_european_union_countries_with_vat.
32
  *
 
33
  * @return array
34
  */
35
  if ( ! function_exists( 'wcj_get_european_union_countries_with_vat' ) ) {
@@ -59,7 +60,7 @@ if ( ! function_exists( 'wcj_get_european_union_countries_with_vat' ) ) {
59
  'NL' => 21,
60
  'PL' => 23,
61
  'PT' => 23,
62
- 'RO' => 24,
63
  'SE' => 25,
64
  'SI' => 22,
65
  'SK' => 20,
@@ -337,7 +338,7 @@ if ( ! function_exists( 'wcj_get_countries' ) ) {
337
  'WS' => __( 'Western Samoa', 'woocommerce' ),
338
  'YE' => __( 'Yemen', 'woocommerce' ),
339
  'ZM' => __( 'Zambia', 'woocommerce' ),
340
- 'ZW' => __( 'Zimbabwe', 'woocommerce' )
341
  );
342
  }
343
  }
4
  *
5
  * The WooCommerce Country Jetpack Functions.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
30
  /**
31
  * wcj_get_european_union_countries_with_vat.
32
  *
33
+ * @version 2.4.0
34
  * @return array
35
  */
36
  if ( ! function_exists( 'wcj_get_european_union_countries_with_vat' ) ) {
60
  'NL' => 21,
61
  'PL' => 23,
62
  'PT' => 23,
63
+ 'RO' => 20,//24,
64
  'SE' => 25,
65
  'SI' => 22,
66
  'SK' => 20,
338
  'WS' => __( 'Western Samoa', 'woocommerce' ),
339
  'YE' => __( 'Yemen', 'woocommerce' ),
340
  'ZM' => __( 'Zambia', 'woocommerce' ),
341
+ 'ZW' => __( 'Zimbabwe', 'woocommerce' )
342
  );
343
  }
344
  }
includes/functions/wcj-functions.php CHANGED
@@ -4,10 +4,23 @@
4
  *
5
  * The WooCommerce Jetpack Functions.
6
  *
7
- * @version 2.3.10
8
  * @author Algoritmika Ltd.
9
  */
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  if ( ! function_exists( 'wcj_get_rates_for_tax_class' ) ) {
12
  /* Used by admin settings page.
13
  *
@@ -340,7 +353,7 @@ if ( ! function_exists( 'wcj_plugin_path' ) ) {
340
  * Convert the php date format string to a js date format.
341
  * https://gist.github.com/clubduece/4053820
342
  */
343
- if ( ! function_exists( 'wcj_date_format_php_to_js' ) ) {
344
  function wcj_date_format_php_to_js( $php_date_format ) {
345
  $date_formats_php_to_js = array(
346
  'F j, Y' => 'MM dd, yy',
@@ -350,6 +363,72 @@ if ( ! function_exists( 'wcj_date_format_php_to_js' ) ) {
350
  );
351
  return isset( $date_formats_php_to_js[ $php_date_format ] ) ? $date_formats_php_to_js[ $php_date_format ] : 'MM dd, yy';
352
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
  }
354
 
355
  /**
4
  *
5
  * The WooCommerce Jetpack Functions.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
11
+ /*
12
+ * wcj_get_select_options()
13
+ *
14
+ * @version 2.4.0
15
+ * @since 2.4.0
16
+ * @return boolean
17
+ */
18
+ if ( ! function_exists( 'wcj_is_module_enabled' ) ) {
19
+ function wcj_is_module_enabled( $module_id ) {
20
+ return ( 'yes' === get_option( 'wcj_' . $module_id . '_enabled', 'no' ) ) ? true : false;
21
+ }
22
+ }
23
+
24
  if ( ! function_exists( 'wcj_get_rates_for_tax_class' ) ) {
25
  /* Used by admin settings page.
26
  *
353
  * Convert the php date format string to a js date format.
354
  * https://gist.github.com/clubduece/4053820
355
  */
356
+ /* if ( ! function_exists( 'wcj_date_format_php_to_js' ) ) {
357
  function wcj_date_format_php_to_js( $php_date_format ) {
358
  $date_formats_php_to_js = array(
359
  'F j, Y' => 'MM dd, yy',
363
  );
364
  return isset( $date_formats_php_to_js[ $php_date_format ] ) ? $date_formats_php_to_js[ $php_date_format ] : 'MM dd, yy';
365
  }
366
+ } */
367
+
368
+ /*
369
+ * Matches each symbol of PHP date format standard
370
+ * with jQuery equivalent codeword
371
+ * http://stackoverflow.com/questions/16702398/convert-a-php-date-format-to-a-jqueryui-datepicker-date-format
372
+ *
373
+ * @author Tristan Jahier
374
+ * @version 2.4.0
375
+ * @since 2.4.0
376
+ */
377
+ if ( ! function_exists( 'wcj_date_format_php_to_js_v2' ) ) {
378
+ function wcj_date_format_php_to_js_v2( $php_format ) {
379
+ $SYMBOLS_MATCHING = array(
380
+ // Day
381
+ 'd' => 'dd',
382
+ 'D' => 'D',
383
+ 'j' => 'd',
384
+ 'l' => 'DD',
385
+ 'N' => '',
386
+ 'S' => '',
387
+ 'w' => '',
388
+ 'z' => 'o',
389
+ // Week
390
+ 'W' => '',
391
+ // Month
392
+ 'F' => 'MM',
393
+ 'm' => 'mm',
394
+ 'M' => 'M',
395
+ 'n' => 'm',
396
+ 't' => '',
397
+ // Year
398
+ 'L' => '',
399
+ 'o' => '',
400
+ 'Y' => 'yy',
401
+ 'y' => 'y',
402
+ // Time
403
+ 'a' => '',
404
+ 'A' => '',
405
+ 'B' => '',
406
+ 'g' => '',
407
+ 'G' => '',
408
+ 'h' => '',
409
+ 'H' => '',
410
+ 'i' => '',
411
+ 's' => '',
412
+ 'u' => ''
413
+ );
414
+ $jqueryui_format = "";
415
+ $escaping = false;
416
+ for ( $i = 0; $i < strlen( $php_format ); $i++ ) {
417
+ $char = $php_format[ $i ];
418
+ if ( $char === '\\' ) { // PHP date format escaping character
419
+ $i++;
420
+ $jqueryui_format .= ( $escaping ) ? $php_format[ $i ] : '\'' . $php_format[ $i ];
421
+ $escaping = true;
422
+ } else {
423
+ if ( $escaping ) {
424
+ $jqueryui_format .= "'";
425
+ $escaping = false;
426
+ }
427
+ $jqueryui_format .= ( isset( $SYMBOLS_MATCHING[ $char ] ) ) ? $SYMBOLS_MATCHING[ $char ] : $char;
428
+ }
429
+ }
430
+ return $jqueryui_format;
431
+ }
432
  }
433
 
434
  /**
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.3.9
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -16,85 +16,95 @@ function init_wc_gateway_wcj_custom_class() {
16
 
17
  /**
18
  * set_icon
19
- *
20
- public function set_icon() {
21
  $icon_url = get_option( 'wcj_payment_gateways_icons_woocommerce_wcj_custom_icon', '' );
22
  if ( $icon_url === '' )
23
  return $this->get_option( 'icon', '' );
24
  return $icon_url;
25
- }
26
 
27
  /**
28
  * Initialise Gateway Settings Form Fields
 
 
29
  */
30
  public function init_form_fields() {
31
  global $woocommerce;
32
 
33
  $shipping_methods = array();
34
 
35
- if ( is_admin() )
36
  foreach ( WC()->shipping->load_shipping_methods() as $method ) {
37
  $shipping_methods[ $method->id ] = $method->get_title();
38
  }
 
39
 
40
  $desc = '';
41
  $icon_url = $this->get_option( 'icon', '' );//apply_filters( 'woocommerce_wcj_custom_icon', $this->get_option( 'icon', '' ) );
42
- if ( $icon_url !== '' )
43
  //$desc = '<img src="' . $icon_url . '" alt="WooJetpack Custom" title="WooJetpack Custom" />';
44
  $desc = '<img src="' . $icon_url . '" alt="' . $this->title . '" title="' . $this->title . '" />';
 
45
 
46
  $this->form_fields = array(
47
  'enabled' => array(
48
- 'title' => __( 'Enable/Disable', 'woocommerce' ),
49
- 'type' => 'checkbox',
50
- 'label' => __( 'Enable Custom Payment', 'woocommerce' ),
51
- 'default' => 'no',
52
  ),
 
53
  'title' => array(
54
- 'title' => __( 'Title', 'woocommerce' ),
55
- 'type' => 'text',
56
- 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
57
- 'default' => __( 'Custom Payment', 'woocommerce' ),
58
- 'desc_tip' => true,
59
  ),
 
60
  'description' => array(
61
- 'title' => __( 'Description', 'woocommerce' ),
62
- 'type' => 'textarea',
63
- 'description' => __( 'Payment method description that the customer will see on your checkout.', 'woocommerce' ),
64
- 'default' => __( 'Custom Payment Description.', 'woocommerce' ),
65
- 'desc_tip' => true,
66
  ),
 
67
  'instructions' => array(
68
- 'title' => __( 'Instructions', 'woocommerce' ),
69
- 'type' => 'textarea',
70
- 'description' => __( 'Instructions that will be added to the thank you page.', 'woocommerce-jetpack' ),
71
- 'default' => '',
72
- 'desc_tip' => true,
73
  ),
 
74
  'instructions_in_email' => array(
75
- 'title' => __( 'Email Instructions', 'woocommerce' ),
76
- 'type' => 'textarea',
77
- 'description' => __( 'Instructions that will be added to the emails.', 'woocommerce-jetpack' ),
78
- 'default' => '',
79
- 'desc_tip' => true,
80
  ),
 
81
  'icon' => array(
82
- 'title' => __( 'Icon', 'woocommerce-jetpack' ),
83
- 'type' => 'text',
84
- 'desc_tip' => __( 'If you want to show an image next to the gateway\'s name on the frontend, enter a URL to an image.', 'woocommerce-jetpack' ),
85
- 'default' => '',
86
- 'description' => $desc,
87
- 'css' => 'min-width:300px;width:50%;',
88
  ),
 
89
  'min_amount' => array(
90
- 'title' => __( 'Minimum order amount', 'woocommerce-jetpack' ),
91
- 'type' => 'number',
92
- 'desc_tip' => __( 'If you want to set minimum order amount to show this gateway on frontend, enter a number here. Set to 0 to disable.', 'woocommerce-jetpack' ),
93
- 'default' => 0,
94
- 'description' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
95
- 'custom_attributes'
96
- => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
97
  ),
 
98
  'enable_for_methods' => array(
99
  'title' => __( 'Enable for shipping methods', 'woocommerce' ),
100
  'type' => 'multiselect',
@@ -104,10 +114,9 @@ function init_wc_gateway_wcj_custom_class() {
104
  'description' => __( 'If gateway is only available for certain shipping methods, set it up here. Leave blank to enable for all methods.', 'woocommerce-jetpack' ),
105
  'options' => $shipping_methods,
106
  'desc_tip' => true,
107
- 'custom_attributes' => array(
108
- 'data-placeholder' => __( 'Select shipping methods', 'woocommerce' )
109
- )
110
  ),
 
111
  'enable_for_virtual' => array(
112
  'title' => __( 'Enable for virtual orders', 'woocommerce' ),
113
  'label' => __( 'Enable gateway if the order is virtual', 'woocommerce-jetpack' ),
@@ -116,27 +125,36 @@ function init_wc_gateway_wcj_custom_class() {
116
  ),
117
 
118
  'default_order_status' => array(
119
- 'title' => __( 'Default Order Status', 'woocommerce-jetpack' ),
120
- 'description' => __( 'Enable Custom Statuses feature to add custom statuses to the list.', 'woocommerce-jetpack' ),
121
- 'default' => apply_filters( 'woocommerce_default_order_status', 'pending' ),
122
- 'type' => 'select',
123
- 'options' => $this->get_order_statuses(),
124
  ),
125
 
126
  'send_email_to_admin' => array(
127
- 'title' => __( 'Send Additional Emails', 'woocommerce-jetpack' ),
128
  'label' => __( 'Send to Admin', 'woocommerce-jetpack' ),
129
- //'description' => __( 'This may help if you are using pending or custom default status and not getting new order emails.', 'woocommerce-jetpack' ),
130
- 'default' => 'no',
131
- 'type' => 'checkbox',
132
  ),
133
 
134
  'send_email_to_customer' => array(
135
- 'title' => '',//__( 'Send Additional Email to Customer', 'woocommerce-jetpack' ),
136
  'label' => __( 'Send to Customer', 'woocommerce-jetpack' ),
137
- 'description' => __( 'This may help if you are using pending or custom default status and not getting new order emails.', 'woocommerce-jetpack' ),
138
- 'default' => 'no',
139
- 'type' => 'checkbox',
 
 
 
 
 
 
 
 
 
140
  ),
141
  );
142
 
@@ -279,8 +297,9 @@ function init_wc_gateway_wcj_custom_class() {
279
  /**
280
  * Process the payment and return the result
281
  *
282
- * @param int $order_id
283
- * @return array
 
284
  */
285
  public function process_payment( $order_id ) {
286
 
@@ -306,37 +325,38 @@ function init_wc_gateway_wcj_custom_class() {
306
 
307
  // Return thankyou redirect
308
  return array(
309
- 'result' => 'success',
310
- 'redirect' => $this->get_return_url( $order ),
311
  );
312
  }
313
 
314
  /**
315
  * init.
316
  *
317
- * @version 2.3.0
318
  */
319
  public function init( $id_count ) {
320
- $this->id = ( 1 === $id_count ) ? 'jetpack_custom_gateway' : 'jetpack_custom_gateway_' . $id_count;
321
- $this->has_fields = false;
322
- $this->method_title = __( 'Custom Gateway', 'woocommerce-jetpack' ) . ' #' . $id_count;
323
- $this->method_description = __( 'Booster for WooCommerce: Custom Payment Gateway', 'woocommerce-jetpack' ) . ' #' . $id_count;
324
  $this->id_count = $id_count;
325
  // Load the settings.
326
  $this->init_form_fields();
327
  $this->init_settings();
328
  // Define user set variables
329
- $this->title = $this->get_option( 'title' );
330
- $this->description = $this->get_option( 'description' );
331
- $this->instructions = $this->get_option( 'instructions', '' );//$this->description );
332
- $this->instructions_in_email = $this->get_option( 'instructions_in_email', '' );
333
- $this->icon = $this->get_option( 'icon', '' );//apply_filters( 'woocommerce_wcj_custom_icon', $this->get_option( 'icon', '' ) );
334
- $this->min_amount = $this->get_option( 'min_amount', 0 );
335
- $this->enable_for_methods = $this->get_option( 'enable_for_methods', array() );
336
- $this->enable_for_virtual = $this->get_option( 'enable_for_virtual', 'yes' ) === 'yes' ? true : false;
337
- $this->default_order_status = $this->get_option( 'default_order_status', 'pending' );
338
- $this->send_email_to_admin = $this->get_option( 'send_email_to_admin', 'no' );
339
- $this->send_email_to_customer = $this->get_option( 'send_email_to_customer', 'no' );
 
340
  // Actions
341
  add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
342
  add_action( 'woocommerce_thankyou_' . $this->id, array( $this, 'thankyou_page' ) );
4
  *
5
  * The WooCommerce Jetpack Custom Payment Gateway class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
16
 
17
  /**
18
  * set_icon
19
+ */
20
+ /* public function set_icon() {
21
  $icon_url = get_option( 'wcj_payment_gateways_icons_woocommerce_wcj_custom_icon', '' );
22
  if ( $icon_url === '' )
23
  return $this->get_option( 'icon', '' );
24
  return $icon_url;
25
+ } */
26
 
27
  /**
28
  * Initialise Gateway Settings Form Fields
29
+ *
30
+ * @version 2.4.0
31
  */
32
  public function init_form_fields() {
33
  global $woocommerce;
34
 
35
  $shipping_methods = array();
36
 
37
+ if ( is_admin() ) {
38
  foreach ( WC()->shipping->load_shipping_methods() as $method ) {
39
  $shipping_methods[ $method->id ] = $method->get_title();
40
  }
41
+ }
42
 
43
  $desc = '';
44
  $icon_url = $this->get_option( 'icon', '' );//apply_filters( 'woocommerce_wcj_custom_icon', $this->get_option( 'icon', '' ) );
45
+ if ( $icon_url !== '' ) {
46
  //$desc = '<img src="' . $icon_url . '" alt="WooJetpack Custom" title="WooJetpack Custom" />';
47
  $desc = '<img src="' . $icon_url . '" alt="' . $this->title . '" title="' . $this->title . '" />';
48
+ }
49
 
50
  $this->form_fields = array(
51
  'enabled' => array(
52
+ 'title' => __( 'Enable/Disable', 'woocommerce' ),
53
+ 'type' => 'checkbox',
54
+ 'label' => __( 'Enable Custom Payment', 'woocommerce' ),
55
+ 'default' => 'no',
56
  ),
57
+
58
  'title' => array(
59
+ 'title' => __( 'Title', 'woocommerce' ),
60
+ 'type' => 'text',
61
+ 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce' ),
62
+ 'default' => __( 'Custom Payment', 'woocommerce' ),
63
+ 'desc_tip' => true,
64
  ),
65
+
66
  'description' => array(
67
+ 'title' => __( 'Description', 'woocommerce' ),
68
+ 'type' => 'textarea',
69
+ 'description' => __( 'Payment method description that the customer will see on your checkout.', 'woocommerce' ),
70
+ 'default' => __( 'Custom Payment Description.', 'woocommerce' ),
71
+ 'desc_tip' => true,
72
  ),
73
+
74
  'instructions' => array(
75
+ 'title' => __( 'Instructions', 'woocommerce' ),
76
+ 'type' => 'textarea',
77
+ 'description' => __( 'Instructions that will be added to the thank you page.', 'woocommerce-jetpack' ),
78
+ 'default' => '',
79
+ 'desc_tip' => true,
80
  ),
81
+
82
  'instructions_in_email' => array(
83
+ 'title' => __( 'Email Instructions', 'woocommerce' ),
84
+ 'type' => 'textarea',
85
+ 'description' => __( 'Instructions that will be added to the emails.', 'woocommerce-jetpack' ),
86
+ 'default' => '',
87
+ 'desc_tip' => true,
88
  ),
89
+
90
  'icon' => array(
91
+ 'title' => __( 'Icon', 'woocommerce-jetpack' ),
92
+ 'type' => 'text',
93
+ 'desc_tip' => __( 'If you want to show an image next to the gateway\'s name on the frontend, enter a URL to an image.', 'woocommerce-jetpack' ),
94
+ 'default' => '',
95
+ 'description' => $desc,
96
+ 'css' => 'min-width:300px;width:50%;',
97
  ),
98
+
99
  'min_amount' => array(
100
+ 'title' => __( 'Minimum order amount', 'woocommerce-jetpack' ),
101
+ 'type' => 'number',
102
+ 'desc_tip' => __( 'If you want to set minimum order amount to show this gateway on frontend, enter a number here. Set to 0 to disable.', 'woocommerce-jetpack' ),
103
+ 'default' => 0,
104
+ 'description' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
105
+ 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
 
106
  ),
107
+
108
  'enable_for_methods' => array(
109
  'title' => __( 'Enable for shipping methods', 'woocommerce' ),
110
  'type' => 'multiselect',
114
  'description' => __( 'If gateway is only available for certain shipping methods, set it up here. Leave blank to enable for all methods.', 'woocommerce-jetpack' ),
115
  'options' => $shipping_methods,
116
  'desc_tip' => true,
117
+ 'custom_attributes' => array( 'data-placeholder' => __( 'Select shipping methods', 'woocommerce' ) ),
 
 
118
  ),
119
+
120
  'enable_for_virtual' => array(
121
  'title' => __( 'Enable for virtual orders', 'woocommerce' ),
122
  'label' => __( 'Enable gateway if the order is virtual', 'woocommerce-jetpack' ),
125
  ),
126
 
127
  'default_order_status' => array(
128
+ 'title' => __( 'Default Order Status', 'woocommerce-jetpack' ),
129
+ 'description' => __( 'Enable Custom Statuses feature to add custom statuses to the list.', 'woocommerce-jetpack' ),
130
+ 'default' => apply_filters( 'woocommerce_default_order_status', 'pending' ),
131
+ 'type' => 'select',
132
+ 'options' => $this->get_order_statuses(),
133
  ),
134
 
135
  'send_email_to_admin' => array(
136
+ 'title' => __( 'Send Additional Emails', 'woocommerce-jetpack' ),
137
  'label' => __( 'Send to Admin', 'woocommerce-jetpack' ),
138
+ // 'description' => __( 'This may help if you are using pending or custom default status and not getting new order emails.', 'woocommerce-jetpack' ),
139
+ 'default' => 'no',
140
+ 'type' => 'checkbox',
141
  ),
142
 
143
  'send_email_to_customer' => array(
144
+ 'title' => '',//__( 'Send Additional Email to Customer', 'woocommerce-jetpack' ),
145
  'label' => __( 'Send to Customer', 'woocommerce-jetpack' ),
146
+ 'description' => __( 'This may help if you are using pending or custom default status and not getting new order emails.', 'woocommerce-jetpack' ),
147
+ 'default' => 'no',
148
+ 'type' => 'checkbox',
149
+ ),
150
+
151
+ 'custom_return_url' => array(
152
+ 'title' => __( 'Custom Return URL (Thank You Page)', 'woocommerce-jetpack' ),
153
+ 'label' => __( 'URL', 'woocommerce-jetpack' ),
154
+ 'desc_tip' => __( 'Enter full URL with http(s).', 'woocommerce-jetpack' ),
155
+ 'description' => __( 'Optional. Leave blank to use default URL.', 'woocommerce-jetpack' ),
156
+ 'default' => '',
157
+ 'type' => 'text',
158
  ),
159
  );
160
 
297
  /**
298
  * Process the payment and return the result
299
  *
300
+ * @version 2.4.0
301
+ * @param int $order_id
302
+ * @return array
303
  */
304
  public function process_payment( $order_id ) {
305
 
325
 
326
  // Return thankyou redirect
327
  return array(
328
+ 'result' => 'success',
329
+ 'redirect' => ( '' == $this->custom_return_url ) ? $this->get_return_url( $order ) : $this->custom_return_url,
330
  );
331
  }
332
 
333
  /**
334
  * init.
335
  *
336
+ * @version 2.4.0
337
  */
338
  public function init( $id_count ) {
339
+ $this->id = ( 1 === $id_count ) ? 'jetpack_custom_gateway' : 'jetpack_custom_gateway_' . $id_count;
340
+ $this->has_fields = false;
341
+ $this->method_title = __( 'Custom Gateway', 'woocommerce-jetpack' ) . ' #' . $id_count;
342
+ $this->method_description = __( 'Booster for WooCommerce: Custom Payment Gateway', 'woocommerce-jetpack' ) . ' #' . $id_count;
343
  $this->id_count = $id_count;
344
  // Load the settings.
345
  $this->init_form_fields();
346
  $this->init_settings();
347
  // Define user set variables
348
+ $this->title = $this->get_option( 'title' );
349
+ $this->description = $this->get_option( 'description' );
350
+ $this->instructions = $this->get_option( 'instructions', '' );//$this->description );
351
+ $this->instructions_in_email = $this->get_option( 'instructions_in_email', '' );
352
+ $this->icon = $this->get_option( 'icon', '' );//apply_filters( 'woocommerce_wcj_custom_icon', $this->get_option( 'icon', '' ) );
353
+ $this->min_amount = $this->get_option( 'min_amount', 0 );
354
+ $this->enable_for_methods = $this->get_option( 'enable_for_methods', array() );
355
+ $this->enable_for_virtual = $this->get_option( 'enable_for_virtual', 'yes' ) === 'yes' ? true : false;
356
+ $this->default_order_status = $this->get_option( 'default_order_status', 'pending' );
357
+ $this->send_email_to_admin = $this->get_option( 'send_email_to_admin', 'no' );
358
+ $this->send_email_to_customer = $this->get_option( 'send_email_to_customer', 'no' );
359
+ $this->custom_return_url = $this->get_option( 'custom_return_url', '' );
360
  // Actions
361
  add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
362
  add_action( 'woocommerce_thankyou_' . $this->id, array( $this, 'thankyou_page' ) );
includes/input-fields/class-wcj-product-input-fields-abstract.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Product Input Fields abstract class.
6
  *
7
- * @version 2.3.8
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -27,7 +27,7 @@ class WCJ_Product_Input_Fields_Abstract {
27
  /**
28
  * get_options.
29
  *
30
- * @version 2.3.8
31
  */
32
  public function get_options() {
33
  $options = array(
@@ -51,6 +51,7 @@ class WCJ_Product_Input_Fields_Abstract {
51
  'checkbox' => __( 'Checkbox', 'woocommerce-jetpack' ),
52
  'file' => __( 'File', 'woocommerce-jetpack' ),
53
  'datepicker' => __( 'Datepicker', 'woocommerce-jetpack' ),
 
54
  'timepicker' => __( 'Timepicker', 'woocommerce-jetpack' ),
55
  'select' => __( 'Select', 'woocommerce-jetpack' ),
56
  'radio' => __( 'Radio', 'woocommerce-jetpack' ),
@@ -110,6 +111,64 @@ class WCJ_Product_Input_Fields_Abstract {
110
  'default' => __( '.jpg,.jpeg,.png', 'woocommerce-jetpack' ),
111
  ),
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  array(
114
  'id' => 'wcj_product_input_fields_type_select_options_' . $this->scope . '_',
115
  'title' => __( 'If select/radio is selected, set options here. One option per line', 'woocommerce-jetpack' ),
@@ -356,7 +415,7 @@ class WCJ_Product_Input_Fields_Abstract {
356
  /**
357
  * add_product_input_fields_to_frontend.
358
  *
359
- * @version 2.3.8
360
  */
361
  public function add_product_input_fields_to_frontend() {
362
  global $product;
@@ -371,10 +430,26 @@ class WCJ_Product_Input_Fields_Abstract {
371
  $title = $this->get_value( 'wcj_product_input_fields_title_' . $this->scope . '_' . $i, $product->id, '' );
372
  $placeholder = $this->get_value( 'wcj_product_input_fields_placeholder_' . $this->scope . '_' . $i, $product->id, '' );
373
 
 
 
 
 
 
 
 
 
 
 
 
 
374
  $file_accept = $this->get_value( 'wcj_product_input_fields_type_file_accept_' . $this->scope . '_' . $i, $product->id, '' );
375
  $custom_attributes = ( 'file' === $type ) ? ' accept="' . $file_accept . '"' : '';
376
  $field_name = 'wcj_product_input_fields_' . $this->scope . '_' . $i;
377
 
 
 
 
 
378
  if ( 'on' === $is_enabled || 'yes' === $is_enabled ) {
379
  switch ( $type ) {
380
 
@@ -389,6 +464,7 @@ class WCJ_Product_Input_Fields_Abstract {
389
  break;
390
 
391
  case 'checkbox':
 
392
  $checked = checked(
393
  $this->get_value( 'wcj_product_input_fields_type_checkbox_default_' . $this->scope . '_' . $i, $product->id, 'no' ),
394
  'yes',
@@ -399,12 +475,17 @@ class WCJ_Product_Input_Fields_Abstract {
399
 
400
  case 'datepicker':
401
 
402
- echo '<p>' . $title . '<input type="' . $type . '" display="date" name="' . $field_name . '" placeholder="' . $placeholder . '"' . $custom_attributes . '>' . '</p>';
 
 
 
 
 
403
  break;
404
 
405
  case 'timepicker':
406
 
407
- echo '<p>' . $title . '<input type="' . $type . '" display="time" name="' . $field_name . '" placeholder="' . $placeholder . '"' . $custom_attributes . '>' . '</p>';
408
  break;
409
 
410
  case 'textarea':
@@ -432,7 +513,7 @@ class WCJ_Product_Input_Fields_Abstract {
432
  echo '<p>' . $title . '<select name="' . $field_name . '">' . $select_options_html . '</select>' . '</p>';
433
  break;
434
 
435
- case 'radio' :
436
 
437
  $select_options_raw = $this->get_value( 'wcj_product_input_fields_type_select_options_' . $this->scope . '_' . $i, $product->id, '' );
438
  $select_options = wcj_get_select_options( $select_options_raw );
@@ -451,7 +532,8 @@ class WCJ_Product_Input_Fields_Abstract {
451
  }
452
  break;
453
 
454
- case 'country' :
 
455
  $countries = WC()->countries->get_allowed_countries();
456
  if ( sizeof( $countries ) > 1 ) {
457
  $value = key( $countries );
@@ -539,14 +621,19 @@ class WCJ_Product_Input_Fields_Abstract {
539
 
540
  /**
541
  * Adds product input values to order details (and emails).
 
 
542
  */
543
- public function add_product_input_fields_to_order_item_name( $name, $item ) {
544
 
545
  $total_number = apply_filters( 'wcj_get_option_filter', 1, $this->get_value( 'wcj_' . 'product_input_fields' . '_' . $this->scope . '_total_number', $item['product_id'], 1 ) );
546
- if ( $total_number < 1 )
547
  return $name;
 
548
 
549
- $name .= '<dl style="font-size:smaller;">';
 
 
550
  for ( $i = 1; $i <= $total_number; $i++ ) {
551
 
552
  $is_enabled = $this->get_value( 'wcj_product_input_fields_enabled_' . $this->scope . '_' . $i, $item['product_id'], 'no' );
@@ -567,7 +654,7 @@ class WCJ_Product_Input_Fields_Abstract {
567
 
568
  $yes_value = $this->get_value( 'wcj_product_input_fields_type_checkbox_yes_' . $this->scope . '_' . $i, $item['product_id'], '' );
569
  $no_value = $this->get_value( 'wcj_product_input_fields_type_checkbox_no_' . $this->scope . '_' . $i, $item['product_id'], '' );
570
- //$type = $this->get_value( 'wcj_product_input_fields_type_' . $this->scope . '_' . $i, $item['product_id'], '' );
571
  if ( 'checkbox' === $type ) {
572
  $value = ( 'on' === $value ) ? $yes_value : $no_value;
573
  }
@@ -577,24 +664,38 @@ class WCJ_Product_Input_Fields_Abstract {
577
  $value = $value['name'];
578
  }
579
 
580
- $name .= '<dt>'
581
- . $title
582
- . '</dt>'
583
- . '<dd>'
584
- . $value
585
- . '</dd>';
 
 
 
 
 
 
 
 
 
 
586
  }
587
  }
588
- $name .= '</dl>';
 
 
589
 
590
  return $name;
591
  }
592
 
593
  /**
594
  * Adds product input values to cart item details.
 
 
595
  */
596
  public function add_product_input_fields_to_cart_item_name( $name, $cart_item, $cart_item_key ) {
597
- return $this->add_product_input_fields_to_order_item_name( $name, $cart_item );
598
  }
599
 
600
  /**
4
  *
5
  * The WooCommerce Jetpack Product Input Fields abstract class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
27
  /**
28
  * get_options.
29
  *
30
+ * @version 2.4.0
31
  */
32
  public function get_options() {
33
  $options = array(
51
  'checkbox' => __( 'Checkbox', 'woocommerce-jetpack' ),
52
  'file' => __( 'File', 'woocommerce-jetpack' ),
53
  'datepicker' => __( 'Datepicker', 'woocommerce-jetpack' ),
54
+ 'weekpicker' => __( 'Weekpicker', 'woocommerce-jetpack' ),
55
  'timepicker' => __( 'Timepicker', 'woocommerce-jetpack' ),
56
  'select' => __( 'Select', 'woocommerce-jetpack' ),
57
  'radio' => __( 'Radio', 'woocommerce-jetpack' ),
111
  'default' => __( '.jpg,.jpeg,.png', 'woocommerce-jetpack' ),
112
  ),
113
 
114
+ array(
115
+ 'id' => 'wcj_product_input_fields_type_datepicker_format_' . $this->scope . '_',
116
+ 'title' => __( 'If datepicker/weekpicker is selected, set date format here. Visit <a href="https://codex.wordpress.org/Formatting_Date_and_Time" target="_blank">documentation on date and time formatting</a> for valid date formats.', 'woocommerce-jetpack' ),
117
+ 'desc_tip' => __( 'Leave blank to use your current WordPress format', 'woocommerce-jetpack' ) . ': ' . get_option( 'date_format' ),
118
+ 'short_title' => __( 'Datepicker/Weekpicker: Date format', 'woocommerce-jetpack' ),
119
+ 'type' => 'text',
120
+ 'default' => '',
121
+ ),
122
+
123
+ array(
124
+ 'id' => 'wcj_product_input_fields_type_datepicker_mindate_' . $this->scope . '_',
125
+ 'title' => __( 'If datepicker/weekpicker is selected, set min date (in days) here', 'woocommerce-jetpack' ),
126
+ 'short_title' => __( 'Datepicker/Weekpicker: Min date', 'woocommerce-jetpack' ),
127
+ 'type' => 'number',
128
+ 'default' => -365,
129
+ ),
130
+
131
+ array(
132
+ 'id' => 'wcj_product_input_fields_type_datepicker_maxdate_' . $this->scope . '_',
133
+ 'title' => __( 'If datepicker/weekpicker is selected, set max date (in days) here', 'woocommerce-jetpack' ),
134
+ 'short_title' => __( 'Datepicker/Weekpicker: Max date', 'woocommerce-jetpack' ),
135
+ 'type' => 'number',
136
+ 'default' => 365,
137
+ ),
138
+
139
+ array(
140
+ 'id' => 'wcj_product_input_fields_type_datepicker_firstday_' . $this->scope . '_',
141
+ 'title' => __( 'If datepicker/weekpicker is selected, set first week day here', 'woocommerce-jetpack' ),
142
+ 'short_title' => __( 'Datepicker/Weekpicker: First week day', 'woocommerce-jetpack' ),
143
+ 'type' => 'select',
144
+ 'default' => 0,
145
+ 'options' => array(
146
+ __( 'Sunday', 'woocommerce-jetpack' ),
147
+ __( 'Monday', 'woocommerce-jetpack' ),
148
+ __( 'Tuesday', 'woocommerce-jetpack' ),
149
+ __( 'Wednesday', 'woocommerce-jetpack' ),
150
+ __( 'Thursday', 'woocommerce-jetpack' ),
151
+ __( 'Friday', 'woocommerce-jetpack' ),
152
+ __( 'Saturday', 'woocommerce-jetpack' ),
153
+ ),
154
+ ),
155
+
156
+ array(
157
+ 'id' => 'wcj_product_input_fields_type_timepicker_format_' . $this->scope . '_',
158
+ 'title' => __( 'If timepicker is selected, set time format here. Visit <a href="http://timepicker.co/options/" target="_blank">timepicker options page</a> for valid time formats.', 'woocommerce-jetpack' ),
159
+ 'short_title' => __( 'Timepicker: Time format', 'woocommerce-jetpack' ),
160
+ 'type' => 'text',
161
+ 'default' => 'hh:mm p',
162
+ ),
163
+
164
+ array(
165
+ 'id' => 'wcj_product_input_fields_type_timepicker_interval_' . $this->scope . '_',
166
+ 'title' => __( 'If timepicker is selected, set interval (in minutes) here', 'woocommerce-jetpack' ),
167
+ 'short_title' => __( 'Timepicker: Interval', 'woocommerce-jetpack' ),
168
+ 'type' => 'number',
169
+ 'default' => 15,
170
+ ),
171
+
172
  array(
173
  'id' => 'wcj_product_input_fields_type_select_options_' . $this->scope . '_',
174
  'title' => __( 'If select/radio is selected, set options here. One option per line', 'woocommerce-jetpack' ),
415
  /**
416
  * add_product_input_fields_to_frontend.
417
  *
418
+ * @version 2.4.0
419
  */
420
  public function add_product_input_fields_to_frontend() {
421
  global $product;
430
  $title = $this->get_value( 'wcj_product_input_fields_title_' . $this->scope . '_' . $i, $product->id, '' );
431
  $placeholder = $this->get_value( 'wcj_product_input_fields_placeholder_' . $this->scope . '_' . $i, $product->id, '' );
432
 
433
+ $datepicker_format = $this->get_value( 'wcj_product_input_fields_type_datepicker_format_' . $this->scope . '_' . $i, $product->id, '' );
434
+ if ( '' == $datepicker_format ) {
435
+ $datepicker_format = get_option( 'date_format' );
436
+ }
437
+ $datepicker_format = wcj_date_format_php_to_js_v2( $datepicker_format );
438
+ $datepicker_mindate = $this->get_value( 'wcj_product_input_fields_type_datepicker_mindate_' . $this->scope . '_' . $i, $product->id, -365 );
439
+ $datepicker_maxdate = $this->get_value( 'wcj_product_input_fields_type_datepicker_maxdate_' . $this->scope . '_' . $i, $product->id, 365 );
440
+ $datepicker_firstday = $this->get_value( 'wcj_product_input_fields_type_datepicker_firstday_' . $this->scope . '_' . $i, $product->id, 0 );
441
+
442
+ $timepicker_format = $this->get_value( 'wcj_product_input_fields_type_timepicker_format_' . $this->scope . '_' . $i, $product->id, 'hh:mm p' );
443
+ $timepicker_interval = $this->get_value( 'wcj_product_input_fields_type_timepicker_interval_' . $this->scope . '_' . $i, $product->id, 15 );
444
+
445
  $file_accept = $this->get_value( 'wcj_product_input_fields_type_file_accept_' . $this->scope . '_' . $i, $product->id, '' );
446
  $custom_attributes = ( 'file' === $type ) ? ' accept="' . $file_accept . '"' : '';
447
  $field_name = 'wcj_product_input_fields_' . $this->scope . '_' . $i;
448
 
449
+ if ( 'on' === $is_required || 'yes' === $is_required ) {
450
+ $title .= get_option( 'wcj_product_input_fields_frontend_view_required_html', '&nbsp;<abbr class="required" title="required">*</abbr>' );
451
+ }
452
+
453
  if ( 'on' === $is_enabled || 'yes' === $is_enabled ) {
454
  switch ( $type ) {
455
 
464
  break;
465
 
466
  case 'checkbox':
467
+
468
  $checked = checked(
469
  $this->get_value( 'wcj_product_input_fields_type_checkbox_default_' . $this->scope . '_' . $i, $product->id, 'no' ),
470
  'yes',
475
 
476
  case 'datepicker':
477
 
478
+ echo '<p>' . $title . '<input firstday="' . $datepicker_firstday . '" dateformat="' . $datepicker_format . '" mindate="' . $datepicker_mindate . '" maxdate="' . $datepicker_maxdate . '" type="' . $type . '" display="date" name="' . $field_name . '" placeholder="' . $placeholder . '"' . $custom_attributes . '>' . '</p>';
479
+ break;
480
+
481
+ case 'weekpicker':
482
+
483
+ echo '<p>' . $title . '<input firstday="' . $datepicker_firstday . '" dateformat="' . $datepicker_format . '" mindate="' . $datepicker_mindate . '" maxdate="' . $datepicker_maxdate . '" type="' . $type . '" display="week" name="' . $field_name . '" placeholder="' . $placeholder . '"' . $custom_attributes . '>' . '</p>';
484
  break;
485
 
486
  case 'timepicker':
487
 
488
+ echo '<p>' . $title . '<input interval="' . $timepicker_interval . '" timeformat="' . $timepicker_format . '" type="' . $type . '" display="time" name="' . $field_name . '" placeholder="' . $placeholder . '"' . $custom_attributes . '>' . '</p>';
489
  break;
490
 
491
  case 'textarea':
513
  echo '<p>' . $title . '<select name="' . $field_name . '">' . $select_options_html . '</select>' . '</p>';
514
  break;
515
 
516
+ case 'radio':
517
 
518
  $select_options_raw = $this->get_value( 'wcj_product_input_fields_type_select_options_' . $this->scope . '_' . $i, $product->id, '' );
519
  $select_options = wcj_get_select_options( $select_options_raw );
532
  }
533
  break;
534
 
535
+ case 'country':
536
+
537
  $countries = WC()->countries->get_allowed_countries();
538
  if ( sizeof( $countries ) > 1 ) {
539
  $value = key( $countries );
621
 
622
  /**
623
  * Adds product input values to order details (and emails).
624
+ *
625
+ * @version 2.4.0
626
  */
627
+ public function add_product_input_fields_to_order_item_name( $name, $item, $is_cart = false ) {
628
 
629
  $total_number = apply_filters( 'wcj_get_option_filter', 1, $this->get_value( 'wcj_' . 'product_input_fields' . '_' . $this->scope . '_total_number', $item['product_id'], 1 ) );
630
+ if ( $total_number < 1 ) {
631
  return $name;
632
+ }
633
 
634
+ if ( $is_cart ) {
635
+ $name .= '<dl style="font-size:smaller;">';
636
+ }
637
  for ( $i = 1; $i <= $total_number; $i++ ) {
638
 
639
  $is_enabled = $this->get_value( 'wcj_product_input_fields_enabled_' . $this->scope . '_' . $i, $item['product_id'], 'no' );
654
 
655
  $yes_value = $this->get_value( 'wcj_product_input_fields_type_checkbox_yes_' . $this->scope . '_' . $i, $item['product_id'], '' );
656
  $no_value = $this->get_value( 'wcj_product_input_fields_type_checkbox_no_' . $this->scope . '_' . $i, $item['product_id'], '' );
657
+ // $type = $this->get_value( 'wcj_product_input_fields_type_' . $this->scope . '_' . $i, $item['product_id'], '' );
658
  if ( 'checkbox' === $type ) {
659
  $value = ( 'on' === $value ) ? $yes_value : $no_value;
660
  }
664
  $value = $value['name'];
665
  }
666
 
667
+ if ( '' != $value ) {
668
+ if ( $is_cart ) {
669
+ $name .= '<dt>'
670
+ . $title
671
+ . '</dt>'
672
+ . '<dd>'
673
+ . $value
674
+ . '</dd>';
675
+ } else {
676
+ $name .= str_replace(
677
+ array( '%title%', '%value%' ),
678
+ array( $title, $value ),
679
+ get_option( 'wcj_product_input_fields_frontend_view_order_table_format', '&nbsp;| %title% %value%' )
680
+ );
681
+ }
682
+ }
683
  }
684
  }
685
+ if ( $is_cart ) {
686
+ $name .= '</dl>';
687
+ }
688
 
689
  return $name;
690
  }
691
 
692
  /**
693
  * Adds product input values to cart item details.
694
+ *
695
+ * @version 2.4.0
696
  */
697
  public function add_product_input_fields_to_cart_item_name( $name, $cart_item, $cart_item_key ) {
698
+ return $this->add_product_input_fields_to_order_item_name( $name, $cart_item, true );
699
  }
700
 
701
  /**
includes/js/wcj-datepicker.js CHANGED
@@ -1,5 +1,10 @@
1
  jQuery(document).ready(function() {
2
- jQuery("input[display='date']").datepicker({
3
- dateFormat : 'yy/mm/dd'
 
 
 
 
 
4
  });
5
  });
1
  jQuery(document).ready(function() {
2
+ jQuery("input[display='date']").each( function () {
3
+ jQuery(this).datepicker({
4
+ dateFormat : jQuery(this).attr("dateformat"),
5
+ minDate : jQuery(this).attr("mindate"),
6
+ maxDate : jQuery(this).attr("maxdate"),
7
+ firstDay : jQuery(this).attr("firstday")
8
+ });
9
  });
10
  });
includes/js/wcj-timepicker.js CHANGED
@@ -1,3 +1,8 @@
1
  jQuery(document).ready(function() {
2
- jQuery("input[display='time']").timepicker();
 
 
 
 
 
3
  });
1
  jQuery(document).ready(function() {
2
+ jQuery("input[display='time']").each( function () {
3
+ jQuery(this).timepicker({
4
+ timeFormat : jQuery(this).attr("timeformat"),
5
+ interval : jQuery(this).attr("interval")
6
+ });
7
+ });
8
  });
includes/js/wcj-weekpicker.js ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function() {
2
+ jQuery("input[display='week']").each( function () {
3
+ jQuery(this).datepicker({
4
+ dateFormat : jQuery(this).attr("dateformat"),
5
+ minDate : jQuery(this).attr("mindate"),
6
+ maxDate : jQuery(this).attr("maxdate"),
7
+ firstDay : jQuery(this).attr("firstday"),
8
+ showOtherMonths: true,
9
+ selectOtherMonths: true,
10
+ changeMonth: true,
11
+ changeYear: true,
12
+ showWeek: true,
13
+ beforeShow: function(dateText, inst) {
14
+ // for week highighting
15
+ jQuery(".ui-datepicker-calendar tbody tr").live("mousemove", function() {
16
+ jQuery(this).find("td a").addClass("ui-state-hover");
17
+ jQuery(this).find(".ui-datepicker-week-col").addClass("ui-state-hover");
18
+ });
19
+ jQuery(".ui-datepicker-calendar tbody tr").live("mouseleave", function() {
20
+ jQuery(this).find("td a").removeClass("ui-state-hover");
21
+ jQuery(this).find(".ui-datepicker-week-col").removeClass("ui-state-hover");
22
+ });
23
+ },
24
+ onClose: function(dateText, inst) {
25
+ var date = jQuery(this).datepicker( "getDate" );
26
+ if (date != null){
27
+ var dateFormat = inst.settings.dateFormat || jQuery(this).datepicker._defaults.dateFormat;
28
+ var endDate = new Date(date.getFullYear(), date.getMonth(), date.getDate() - date.getDay() + 6);
29
+ var endDateFormatted = jQuery.datepicker.formatDate( dateFormat, endDate, inst.settings );
30
+ jQuery(this).val(dateText + " - " + endDateFormatted);
31
+ }
32
+ // disable live listeners so they dont impact other instances
33
+ jQuery(".ui-datepicker-calendar tbody tr").die("mousemove");
34
+ jQuery(".ui-datepicker-calendar tbody tr").die("mouseleave");
35
+ }
36
+ });
37
+ });
38
+ });
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.3.10
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -90,6 +90,7 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
90
  $html .= '"><span style="color:gray;font-style:italic;font-size:x-small;text-decoration:underline;">' . $delete_button_label . '</span></a>';
91
  }
92
  } else {
 
93
  // Create Button
94
  $create_button_label = get_option( 'wcj_invoicing_' . $invoice_type_id . '_admin_column_create_btn', __( 'Create', 'woocommerce-jetpack' ) );
95
  if ( '' != $create_button_label ) {
@@ -139,12 +140,12 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
139
  /**
140
  * get_settings.
141
  *
142
- * @version 2.3.10
143
  */
144
  function get_settings() {
145
 
146
  $settings = array();
147
- $invoice_types = wcj_get_invoice_types();
148
  foreach ( $invoice_types as $invoice_type ) {
149
 
150
  $settings[] = array(
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing Display class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
90
  $html .= '"><span style="color:gray;font-style:italic;font-size:x-small;text-decoration:underline;">' . $delete_button_label . '</span></a>';
91
  }
92
  } else {
93
+
94
  // Create Button
95
  $create_button_label = get_option( 'wcj_invoicing_' . $invoice_type_id . '_admin_column_create_btn', __( 'Create', 'woocommerce-jetpack' ) );
96
  if ( '' != $create_button_label ) {
140
  /**
141
  * get_settings.
142
  *
143
+ * @version 2.4.0
144
  */
145
  function get_settings() {
146
 
147
  $settings = array();
148
+ $invoice_types = ( 'yes' === get_option( 'wcj_invoicing_hide_disabled_docs_settings', 'no' ) ) ? wcj_get_enabled_invoice_types() : wcj_get_invoice_types();
149
  foreach ( $invoice_types as $invoice_type ) {
150
 
151
  $settings[] = array(
includes/pdf-invoices/settings/class-wcj-pdf-invoicing-emails.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing Emails class.
6
  *
7
- * @version 2.3.9
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -74,45 +74,42 @@ class WCJ_PDF_Invoicing_Emails extends WCJ_Module {
74
  * add_payment_gateways_pdf_invoicing_emails_settings.
75
  */
76
  function add_payment_gateways_pdf_invoicing_emails_settings( $settings, $invoice_type_id ) {
77
- global $woocommerce;
78
- $available_gateways = $woocommerce->payment_gateways->payment_gateways();
79
- foreach ( $available_gateways as $key => $gateway ) {
80
- $available_gateways_options_array[ $key ] = $gateway->title;
81
- }
82
- $settings[] = array(
83
- 'title' => __( 'Payment gateways to include', 'woocommerce' ),
84
- 'id' => 'wcj_invoicing_' . $invoice_type_id . '_payment_gateways',
85
- 'type' => 'multiselect',
86
- 'class' => 'chosen_select',
87
- 'css' => 'width: 450px;',
88
- 'default' => '',
89
- 'options' => $available_gateways_options_array,
90
- 'custom_attributes' => array(
91
- 'data-placeholder' => __( 'Select some gateways. Leave blank to include all.', 'woocommerce-jetpack' )
92
- )
93
- );
94
- return $settings;
95
  }
96
 
97
  /**
98
  * get_settings.
99
  *
100
- * @version 2.3.9
101
  */
102
  function get_settings() {
103
 
104
  $settings = array();
105
- $invoice_types = wcj_get_invoice_types();
106
  foreach ( $invoice_types as $invoice_type ) {
107
 
108
  $settings[] = array(
109
  'title' => strtoupper( $invoice_type['desc'] ),
110
  'type' => 'title',
111
  'desc' => '',
112
- 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_emails_options'
113
  );
114
 
115
- //$available_emails = apply_filters( 'woocommerce_resend_order_emails_available', array( 'new_order', 'cancelled_order', 'customer_processing_order', 'customer_completed_order', 'customer_invoice', 'customer_refunded_order' ) );
116
  $available_emails = array(
117
  'new_order' => __( 'Admin - New Order', 'woocommerce' ),
118
  'cancelled_order' => __( 'Admin - Cancelled Order', 'woocommerce' ),
@@ -132,19 +129,16 @@ class WCJ_PDF_Invoicing_Emails extends WCJ_Module {
132
  'type' => 'multiselect',
133
  'class' => 'chosen_select',
134
  'css' => 'width: 450px;',
135
- // 'default' => 'new_order',
136
  'default' => '',
137
  'options' => $available_emails,
138
- 'custom_attributes' => array(
139
- 'data-placeholder' => __( 'Select some emails', 'woocommerce' )
140
- )
141
  );
142
 
143
  $settings = apply_filters( 'wcj_pdf_invoicing_emails_settings', $settings, $invoice_type['id'] );
144
 
145
  $settings[] = array(
146
  'type' => 'sectionend',
147
- 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_emails_options'
148
  );
149
  }
150
 
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing Emails class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
74
  * add_payment_gateways_pdf_invoicing_emails_settings.
75
  */
76
  function add_payment_gateways_pdf_invoicing_emails_settings( $settings, $invoice_type_id ) {
77
+ global $woocommerce;
78
+ $available_gateways = $woocommerce->payment_gateways->payment_gateways();
79
+ foreach ( $available_gateways as $key => $gateway ) {
80
+ $available_gateways_options_array[ $key ] = $gateway->title;
81
+ }
82
+ $settings[] = array(
83
+ 'title' => __( 'Payment gateways to include', 'woocommerce' ),
84
+ 'id' => 'wcj_invoicing_' . $invoice_type_id . '_payment_gateways',
85
+ 'type' => 'multiselect',
86
+ 'class' => 'chosen_select',
87
+ 'css' => 'width: 450px;',
88
+ 'default' => '',
89
+ 'options' => $available_gateways_options_array,
90
+ 'custom_attributes' => array( 'data-placeholder' => __( 'Select some gateways. Leave blank to include all.', 'woocommerce-jetpack' ) ),
91
+ );
92
+ return $settings;
 
 
93
  }
94
 
95
  /**
96
  * get_settings.
97
  *
98
+ * @version 2.4.0
99
  */
100
  function get_settings() {
101
 
102
  $settings = array();
103
+ $invoice_types = ( 'yes' === get_option( 'wcj_invoicing_hide_disabled_docs_settings', 'no' ) ) ? wcj_get_enabled_invoice_types() : wcj_get_invoice_types();
104
  foreach ( $invoice_types as $invoice_type ) {
105
 
106
  $settings[] = array(
107
  'title' => strtoupper( $invoice_type['desc'] ),
108
  'type' => 'title',
109
  'desc' => '',
110
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_emails_options',
111
  );
112
 
 
113
  $available_emails = array(
114
  'new_order' => __( 'Admin - New Order', 'woocommerce' ),
115
  'cancelled_order' => __( 'Admin - Cancelled Order', 'woocommerce' ),
129
  'type' => 'multiselect',
130
  'class' => 'chosen_select',
131
  'css' => 'width: 450px;',
 
132
  'default' => '',
133
  'options' => $available_emails,
134
+ 'custom_attributes' => array( 'data-placeholder' => __( 'Select some emails', 'woocommerce' ) ),
 
 
135
  );
136
 
137
  $settings = apply_filters( 'wcj_pdf_invoicing_emails_settings', $settings, $invoice_type['id'] );
138
 
139
  $settings[] = array(
140
  'type' => 'sectionend',
141
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_emails_options',
142
  );
143
  }
144
 
includes/pdf-invoices/settings/class-wcj-pdf-invoicing-footer.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing Footer class.
6
  *
7
- * @version 2.2.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -27,37 +27,36 @@ class WCJ_PDF_Invoicing_Footer extends WCJ_Module {
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'] . '_footer_options' );
38
-
 
 
39
  $settings = array_merge( $settings, array(
40
-
41
  array(
42
  'title' => __( 'Enable Footer', 'woocommerce-jetpack' ),
43
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_footer_enabled',
44
  'default' => 'yes',
45
  'type' => 'checkbox',
46
  ),
47
-
48
  array(
49
  'title' => __( 'Footer Text', 'woocommerce-jetpack' ),
50
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_footer_text',
51
- //'default' => __( 'Page %page_number% / %total_pages%', 'woocommerce-jetpack' ),
52
  'default' => 'Page %page_number% / %total_pages%',
53
  'type' => 'textarea',
54
  'css' => 'width:66%;min-width:300px;height:165px;',
55
  'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
56
  'desc_tip' => __( 'You can use HTML here, as well as any WordPress shortcodes. There is two more predefined values you can use: %page_number% and %total_pages%.', 'woocommerce-jetpack' ),
57
- 'custom_attributes'
58
- => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
59
  ),
60
-
61
  array(
62
  'title' => __( 'Footer Text Color', 'woocommerce-jetpack' ),
63
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_footer_text_color',
@@ -65,7 +64,6 @@ class WCJ_PDF_Invoicing_Footer extends WCJ_Module {
65
  'type' => 'color',
66
  'css' => 'width:6em;',
67
  ),
68
-
69
  array(
70
  'title' => __( 'Footer Line Color', 'woocommerce-jetpack' ),
71
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_footer_line_color',
@@ -73,21 +71,20 @@ class WCJ_PDF_Invoicing_Footer extends WCJ_Module {
73
  'type' => 'color',
74
  'css' => 'width:6em;',
75
  ),
76
-
77
  array(
78
  'title' => __( 'Footer Margin', 'woocommerce-jetpack' ),
79
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_margin_footer',
80
- 'default' => 10,//PDF_MARGIN_FOOTER
81
  'type' => 'number',
82
  ),
83
-
84
  ) );
85
-
86
- $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_footer_options' );
 
 
87
  }
88
-
89
- return $settings;
90
- }
91
  }
92
 
93
  endif;
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing Footer class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
27
 
28
  /**
29
  * get_settings.
30
+ *
31
+ * @version 2.4.0
32
  */
33
  function get_settings() {
 
34
  $settings = array();
35
+ $invoice_types = ( 'yes' === get_option( 'wcj_invoicing_hide_disabled_docs_settings', 'no' ) ) ? wcj_get_enabled_invoice_types() : wcj_get_invoice_types();
36
  foreach ( $invoice_types as $invoice_type ) {
37
+ $settings[] = array(
38
+ 'title' => strtoupper( $invoice_type['desc'] ),
39
+ 'type' => 'title',
40
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_footer_options',
41
+ );
42
  $settings = array_merge( $settings, array(
 
43
  array(
44
  'title' => __( 'Enable Footer', 'woocommerce-jetpack' ),
45
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_footer_enabled',
46
  'default' => 'yes',
47
  'type' => 'checkbox',
48
  ),
 
49
  array(
50
  'title' => __( 'Footer Text', 'woocommerce-jetpack' ),
51
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_footer_text',
52
+ // 'default' => __( 'Page %page_number% / %total_pages%', 'woocommerce-jetpack' ),
53
  'default' => 'Page %page_number% / %total_pages%',
54
  'type' => 'textarea',
55
  'css' => 'width:66%;min-width:300px;height:165px;',
56
  'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
57
  'desc_tip' => __( 'You can use HTML here, as well as any WordPress shortcodes. There is two more predefined values you can use: %page_number% and %total_pages%.', 'woocommerce-jetpack' ),
58
+ 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
 
59
  ),
 
60
  array(
61
  'title' => __( 'Footer Text Color', 'woocommerce-jetpack' ),
62
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_footer_text_color',
64
  'type' => 'color',
65
  'css' => 'width:6em;',
66
  ),
 
67
  array(
68
  'title' => __( 'Footer Line Color', 'woocommerce-jetpack' ),
69
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_footer_line_color',
71
  'type' => 'color',
72
  'css' => 'width:6em;',
73
  ),
 
74
  array(
75
  'title' => __( 'Footer Margin', 'woocommerce-jetpack' ),
76
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_margin_footer',
77
+ 'default' => 10, // PDF_MARGIN_FOOTER
78
  'type' => 'number',
79
  ),
 
80
  ) );
81
+ $settings[] = array(
82
+ 'type' => 'sectionend',
83
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_footer_options',
84
+ );
85
  }
86
+ return $settings;
87
+ }
 
88
  }
89
 
90
  endif;
includes/pdf-invoices/settings/class-wcj-pdf-invoicing-header.php CHANGED
@@ -4,8 +4,8 @@
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;
@@ -30,25 +30,24 @@ class WCJ_PDF_Invoicing_Header extends WCJ_Module {
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',
@@ -58,28 +57,24 @@ class WCJ_PDF_Invoicing_Header extends WCJ_Module {
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,7 +82,6 @@ class WCJ_PDF_Invoicing_Header extends WCJ_Module {
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',
@@ -95,18 +89,18 @@ class WCJ_PDF_Invoicing_Header extends WCJ_Module {
95
  'type' => 'color',
96
  'css' => 'width:6em;',
97
  ),
98
-
99
  array(
100
  'title' => __( 'Header Margin', 'woocommerce-jetpack' ),
101
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_margin_header',
102
- 'default' => 10,//PDF_MARGIN_HEADER
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
  }
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing Header class.
6
  *
7
+ * @version 2.4.0
8
+ * @author Algoritmika Ltd.
9
  */
10
 
11
  if ( ! defined( 'ABSPATH' ) ) exit;
30
  /**
31
  * get_settings.
32
  *
33
+ * @version 2.4.0
34
  */
35
  function get_settings() {
 
36
  $settings = array();
37
+ $invoice_types = ( 'yes' === get_option( 'wcj_invoicing_hide_disabled_docs_settings', 'no' ) ) ? wcj_get_enabled_invoice_types() : wcj_get_invoice_types();
38
  foreach ( $invoice_types as $invoice_type ) {
39
+ $settings[] = array(
40
+ 'title' => strtoupper( $invoice_type['desc'] ),
41
+ 'type' => 'title',
42
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_options',
43
+ );
44
  $settings = array_merge( $settings, array(
 
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
  array(
52
  'title' => __( 'Header Image', 'woocommerce-jetpack' ),
53
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_image',
57
  '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' ),
58
  'desc_tip' => __( 'Leave blank to disable', 'woocommerce-jetpack' ),
59
  ),
 
60
  array(
61
  'title' => __( 'Header Image Width in mm', 'woocommerce-jetpack' ),
62
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_image_width_mm',
63
  'default' => 50,
64
  'type' => 'number',
65
  ),
 
66
  array(
67
  'title' => __( 'Header Title', 'woocommerce-jetpack' ),
68
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_title_text',
69
  'default' => $invoice_type['title'],
70
  'type' => 'text',
71
  ),
 
72
  array(
73
  'title' => __( 'Header Text', 'woocommerce-jetpack' ),
74
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_text',
75
  'default' => __( 'Company Name', 'woocommerce-jetpack' ),
76
  'type' => 'text',
77
  ),
 
78
  array(
79
  'title' => __( 'Header Text Color', 'woocommerce-jetpack' ),
80
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_text_color',
82
  'type' => 'color',
83
  'css' => 'width:6em;',
84
  ),
 
85
  array(
86
  'title' => __( 'Header Line Color', 'woocommerce-jetpack' ),
87
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_line_color',
89
  'type' => 'color',
90
  'css' => 'width:6em;',
91
  ),
 
92
  array(
93
  'title' => __( 'Header Margin', 'woocommerce-jetpack' ),
94
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_margin_header',
95
+ 'default' => 10, // PDF_MARGIN_HEADER
96
  'type' => 'number',
97
  ),
98
  ) );
99
+ $settings[] = array(
100
+ 'type' => 'sectionend',
101
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_header_options',
102
+ );
103
  }
 
104
  return $settings;
105
  }
106
  }
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.3.10
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -20,7 +20,6 @@ class WCJ_PDF_Invoicing_Numbering extends WCJ_Module {
20
  * @version 2.3.10
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' );
@@ -31,13 +30,17 @@ class WCJ_PDF_Invoicing_Numbering extends WCJ_Module {
31
  /**
32
  * get_settings.
33
  *
34
- * @version 2.3.10
35
  */
36
  function get_settings() {
37
  $settings = array();
38
- $invoice_types = wcj_get_invoice_types();
39
  foreach ( $invoice_types as $invoice_type ) {
40
- $settings[] = array( 'title' => strtoupper( $invoice_type['desc'] ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_options' );
 
 
 
 
41
  $settings[] = array(
42
  'title' => __( 'Sequential', 'woocommerce-jetpack' ),
43
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_sequential_enabled',
@@ -68,7 +71,10 @@ class WCJ_PDF_Invoicing_Numbering extends WCJ_Module {
68
  'default' => '',
69
  'type' => 'text',
70
  );
71
- $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_options' );
 
 
 
72
  }
73
  return $settings;
74
  }
4
  *
5
  * The WooCommerce Jetpack PDF Invoices Numbering class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
20
  * @version 2.3.10
21
  */
22
  public function __construct() {
 
23
  $this->id = 'pdf_invoicing_numbering';
24
  $this->parent_id = 'pdf_invoicing';
25
  $this->short_desc = __( 'Numbering', 'woocommerce-jetpack' );
30
  /**
31
  * get_settings.
32
  *
33
+ * @version 2.4.0
34
  */
35
  function get_settings() {
36
  $settings = array();
37
+ $invoice_types = ( 'yes' === get_option( 'wcj_invoicing_hide_disabled_docs_settings', 'no' ) ) ? wcj_get_enabled_invoice_types() : wcj_get_invoice_types();
38
  foreach ( $invoice_types as $invoice_type ) {
39
+ $settings[] = array(
40
+ 'title' => strtoupper( $invoice_type['desc'] ),
41
+ 'type' => 'title',
42
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_options',
43
+ );
44
  $settings[] = array(
45
  'title' => __( 'Sequential', 'woocommerce-jetpack' ),
46
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_sequential_enabled',
71
  'default' => '',
72
  'type' => 'text',
73
  );
74
+ $settings[] = array(
75
+ 'type' => 'sectionend',
76
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_numbering_options',
77
+ );
78
  }
79
  return $settings;
80
  }
includes/pdf-invoices/settings/class-wcj-pdf-invoicing-page.php CHANGED
@@ -4,41 +4,47 @@
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing Page class.
6
  *
7
- * @class WCJ_PDF_Invoicing_Page
8
- * @version 2.1.2
9
- * @category Class
10
- * @author Algoritmika Ltd.
11
  */
12
-
13
  if ( ! defined( 'ABSPATH' ) ) exit;
14
-
15
  if ( ! class_exists( 'WCJ_PDF_Invoicing_Page' ) ) :
16
-
17
- class WCJ_PDF_Invoicing_Page {
18
-
19
- /**
20
- * Constructor.
21
- */
22
- function __construct() {
23
- /*if ( 'yes' === get_option( 'wcj_pdf_invoicing_enabled' ) ) {
24
 
25
- }*/
26
- // Settings hooks
27
- add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
28
- add_filter( 'wcj_settings_pdf_invoicing_page', array( $this, 'get_settings' ), 100 );
29
- }
30
-
31
- /**
32
- * get_settings.
33
- */
34
- function get_settings() {
35
-
36
- $settings = array();
37
- $invoice_types = wcj_get_invoice_types();
38
- foreach ( $invoice_types as $invoice_type ) {
39
 
40
- $settings[] = array( 'title' => strtoupper( $invoice_type['desc'] ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_page_options' );
41
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  $settings[] = array(
43
  'title' => __( 'Page Orientation', 'woocommerce-jetpack' ),
44
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_page_orientation',
@@ -48,61 +54,47 @@ class WCJ_PDF_Invoicing_Page {
48
  'P' => __( 'Portrait', 'woocommerce-jetpack' ),
49
  'L' => __( 'Landscape', 'woocommerce-jetpack' ),
50
  ),
51
- );
52
-
53
- $page_formats = array();
54
- for ( $i = 1; $i < 8; $i++ ) $page_formats[ 'A' . $i ] = 'A' . $i;
55
  $settings[] = array(
56
  'title' => __( 'Page Format', 'woocommerce-jetpack' ),
57
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_page_format',
58
  'default' => 'A4',
59
  'type' => 'select',
60
  'options' => $page_formats,
61
- );
62
-
63
  $settings[] = array(
64
  'title' => __( 'Margin Left', 'woocommerce-jetpack' ),
65
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_margin_left',
66
- 'default' => 15,//PDF_MARGIN_LEFT,
67
  'type' => 'number',
68
- );
69
-
70
  $settings[] = array(
71
  'title' => __( 'Margin Right', 'woocommerce-jetpack' ),
72
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_margin_right',
73
- 'default' => 15,//PDF_MARGIN_RIGHT,
74
  'type' => 'number',
75
  );
76
-
77
  $settings[] = array(
78
  'title' => __( 'Margin Top', 'woocommerce-jetpack' ),
79
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_margin_top',
80
- 'default' => 27,//PDF_MARGIN_TOP,
81
  'type' => 'number',
82
  );
83
-
84
  $settings[] = array(
85
  'title' => __( 'Margin Bottom', 'woocommerce-jetpack' ),
86
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_margin_bottom',
87
- 'default' => 0,//PDF_MARGIN_BOTTOM,
88
  'type' => 'number',
89
- );
90
-
91
- $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_page_options' );
92
- }
93
-
94
- return $settings;
95
- }
96
-
97
- /**
98
- * settings_section.
99
- */
100
- function settings_section( $sections ) {
101
- $sections['pdf_invoicing_page'] = __( 'Page Settings', 'woocommerce-jetpack' );
102
- return $sections;
103
- }
104
  }
105
-
106
  endif;
107
-
108
- return new WCJ_PDF_Invoicing_Page();
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing Page class.
6
  *
7
+ * @version 2.4.0
8
+ * @author Algoritmika Ltd.
 
 
9
  */
10
+
11
  if ( ! defined( 'ABSPATH' ) ) exit;
12
+
13
  if ( ! class_exists( 'WCJ_PDF_Invoicing_Page' ) ) :
 
 
 
 
 
 
 
 
14
 
15
+ class WCJ_PDF_Invoicing_Page extends WCJ_Module {
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
+ /**
18
+ * Constructor.
19
+ *
20
+ * @version 2.4.0
21
+ */
22
+ function __construct() {
23
+ $this->id = 'pdf_invoicing_page';
24
+ $this->parent_id = 'pdf_invoicing';
25
+ $this->short_desc = __( 'Page Settings', 'woocommerce-jetpack' );
26
+ $this->desc = '';
27
+ parent::__construct( 'submodule' );
28
+ }
29
+
30
+ /**
31
+ * get_settings.
32
+ *
33
+ * @version 2.4.0
34
+ */
35
+ function get_settings() {
36
+ $settings = array();
37
+ $page_formats = array();
38
+ for ( $i = 1; $i < 8; $i++ ) {
39
+ $page_formats[ 'A' . $i ] = 'A' . $i;
40
+ }
41
+ $invoice_types = ( 'yes' === get_option( 'wcj_invoicing_hide_disabled_docs_settings', 'no' ) ) ? wcj_get_enabled_invoice_types() : wcj_get_invoice_types();
42
+ foreach ( $invoice_types as $invoice_type ) {
43
+ $settings[] = array(
44
+ 'title' => strtoupper( $invoice_type['desc'] ),
45
+ 'type' => 'title',
46
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_page_options',
47
+ );
48
  $settings[] = array(
49
  'title' => __( 'Page Orientation', 'woocommerce-jetpack' ),
50
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_page_orientation',
54
  'P' => __( 'Portrait', 'woocommerce-jetpack' ),
55
  'L' => __( 'Landscape', 'woocommerce-jetpack' ),
56
  ),
57
+ );
 
 
 
58
  $settings[] = array(
59
  'title' => __( 'Page Format', 'woocommerce-jetpack' ),
60
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_page_format',
61
  'default' => 'A4',
62
  'type' => 'select',
63
  'options' => $page_formats,
64
+ );
 
65
  $settings[] = array(
66
  'title' => __( 'Margin Left', 'woocommerce-jetpack' ),
67
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_margin_left',
68
+ 'default' => 15, // PDF_MARGIN_LEFT,
69
  'type' => 'number',
70
+ );
 
71
  $settings[] = array(
72
  'title' => __( 'Margin Right', 'woocommerce-jetpack' ),
73
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_margin_right',
74
+ 'default' => 15, // PDF_MARGIN_RIGHT,
75
  'type' => 'number',
76
  );
 
77
  $settings[] = array(
78
  'title' => __( 'Margin Top', 'woocommerce-jetpack' ),
79
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_margin_top',
80
+ 'default' => 27, // PDF_MARGIN_TOP,
81
  'type' => 'number',
82
  );
 
83
  $settings[] = array(
84
  'title' => __( 'Margin Bottom', 'woocommerce-jetpack' ),
85
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_margin_bottom',
86
+ 'default' => 0, // PDF_MARGIN_BOTTOM,
87
  'type' => 'number',
88
+ );
89
+ $settings[] = array(
90
+ 'type' => 'sectionend',
91
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_page_options',
92
+ );
93
+ }
94
+ return $settings;
95
+ }
 
 
 
 
 
 
 
96
  }
97
+
98
  endif;
99
+
100
+ return new WCJ_PDF_Invoicing_Page();
includes/pdf-invoices/settings/class-wcj-pdf-invoicing-styling.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing Styling class.
6
  *
7
- * @version 2.3.9
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -12,27 +12,31 @@ if ( ! defined( 'ABSPATH' ) ) exit;
12
 
13
  if ( ! class_exists( 'WCJ_PDF_Invoicing_Styling' ) ) :
14
 
15
- class WCJ_PDF_Invoicing_Styling {
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_styling', array( $this, 'get_settings' ), 100 );
 
 
24
  }
25
 
26
  /**
27
  * get_settings.
28
  *
29
- * @version 2.3.9
30
  */
31
  function get_settings() {
32
 
33
  $settings = array();
34
 
35
- $invoice_types = wcj_get_invoice_types();
36
  foreach ( $invoice_types as $invoice_type ) {
37
 
38
  $settings[] = array(
@@ -91,14 +95,6 @@ class WCJ_PDF_Invoicing_Styling {
91
 
92
  return $settings;
93
  }
94
-
95
- /**
96
- * settings_section.
97
- */
98
- function settings_section( $sections ) {
99
- $sections['pdf_invoicing_styling'] = __( 'Styling', 'woocommerce-jetpack' );
100
- return $sections;
101
- }
102
  }
103
 
104
  endif;
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing Styling class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
12
 
13
  if ( ! class_exists( 'WCJ_PDF_Invoicing_Styling' ) ) :
14
 
15
+ class WCJ_PDF_Invoicing_Styling extends WCJ_Module {
16
 
17
  /**
18
  * Constructor.
19
+ *
20
+ * @version 2.4.0
21
  */
22
+ function __construct() {
23
+ $this->id = 'pdf_invoicing_styling';
24
+ $this->parent_id = 'pdf_invoicing';
25
+ $this->short_desc = __( 'Styling', 'woocommerce-jetpack' );
26
+ $this->desc = '';
27
+ parent::__construct( 'submodule' );
28
  }
29
 
30
  /**
31
  * get_settings.
32
  *
33
+ * @version 2.4.0
34
  */
35
  function get_settings() {
36
 
37
  $settings = array();
38
 
39
+ $invoice_types = ( 'yes' === get_option( 'wcj_invoicing_hide_disabled_docs_settings', 'no' ) ) ? wcj_get_enabled_invoice_types() : wcj_get_invoice_types();
40
  foreach ( $invoice_types as $invoice_type ) {
41
 
42
  $settings[] = array(
95
 
96
  return $settings;
97
  }
 
 
 
 
 
 
 
 
98
  }
99
 
100
  endif;
includes/pdf-invoices/settings/class-wcj-pdf-invoicing-templates.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack PDF Invoices Templates class.
6
  *
7
- * @version 2.3.7
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -29,12 +29,14 @@ class WCJ_PDF_Invoicing_Templates extends WCJ_Module {
29
 
30
  /**
31
  * get_settings.
 
 
32
  */
33
  function get_settings() {
34
 
35
  $settings = array();
36
 
37
- $invoice_types = wcj_get_invoice_types();
38
  foreach ( $invoice_types as $invoice_type ) {
39
 
40
  ob_start();
@@ -52,15 +54,23 @@ class WCJ_PDF_Invoicing_Templates extends WCJ_Module {
52
  'default' => $default_template,
53
  'type' => 'textarea',
54
  'css' => 'width:66%;min-width:300px;height:500px;',
55
- );
56
  $settings[] = array(
57
  'type' => 'sectionend',
58
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_templates_options',
59
  );
60
  }
61
 
62
- $settings[] = array( 'title' => __( 'Available Shortcodes', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => wcj_get_shortcodes_list(), 'id' => 'wcj_invoicing_templates_desc' );
63
- $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_invoicing_templates_desc' );
 
 
 
 
 
 
 
 
64
 
65
  return $settings;
66
  }
4
  *
5
  * The WooCommerce Jetpack PDF Invoices Templates class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
29
 
30
  /**
31
  * get_settings.
32
+ *
33
+ * @version 2.4.0
34
  */
35
  function get_settings() {
36
 
37
  $settings = array();
38
 
39
+ $invoice_types = ( 'yes' === get_option( 'wcj_invoicing_hide_disabled_docs_settings', 'no' ) ) ? wcj_get_enabled_invoice_types() : wcj_get_invoice_types();
40
  foreach ( $invoice_types as $invoice_type ) {
41
 
42
  ob_start();
54
  'default' => $default_template,
55
  'type' => 'textarea',
56
  'css' => 'width:66%;min-width:300px;height:500px;',
57
+ );
58
  $settings[] = array(
59
  'type' => 'sectionend',
60
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_templates_options',
61
  );
62
  }
63
 
64
+ $settings[] = array(
65
+ 'title' => __( 'Available Shortcodes', 'woocommerce-jetpack' ),
66
+ 'type' => 'title',
67
+ 'desc' => wcj_get_shortcodes_list(),
68
+ 'id' => 'wcj_invoicing_templates_desc',
69
+ );
70
+ $settings[] = array(
71
+ 'type' => 'sectionend',
72
+ 'id' => 'wcj_invoicing_templates_desc',
73
+ );
74
 
75
  return $settings;
76
  }
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.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -25,7 +25,7 @@ class WCJ_Price_by_Country_Core {
25
  /**
26
  * add_hooks.
27
  *
28
- * @version 2.3.0
29
  */
30
  function add_hooks() {
31
 
@@ -43,10 +43,10 @@ class WCJ_Price_by_Country_Core {
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 );
@@ -54,11 +54,16 @@ class WCJ_Price_by_Country_Core {
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
@@ -70,6 +75,18 @@ class WCJ_Price_by_Country_Core {
70
  // add_shortcode( 'wcj_debug_price_by_country', array( $this, 'get_debug_info' ) );
71
  }
72
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  /**
74
  * add_country_selection_box.
75
  *
4
  *
5
  * The WooCommerce Jetpack Price by Country Core class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
25
  /**
26
  * add_hooks.
27
  *
28
+ * @version 2.4.0
29
  */
30
  function add_hooks() {
31
 
43
  //if ( ) { //todo
44
 
45
  // Price hooks
46
+ // add_filter( 'woocommerce_variation_prices', array( $this, 'change_price_by_country_variations' ), PHP_INT_MAX - 1, 2 );
47
+ add_filter( 'woocommerce_get_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX - 1, 2 );
48
+ add_filter( 'woocommerce_get_sale_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX - 1, 2 );
49
+ add_filter( 'woocommerce_get_regular_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX - 1, 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 );
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 - 1, 2 );
58
+ add_filter( 'woocommerce_currency', array( $this, 'change_currency_code' ), PHP_INT_MAX - 1, 1 );
59
 
60
  // Shipping
61
+ add_filter( 'woocommerce_package_rates', array( $this, 'change_shipping_price_by_country' ), PHP_INT_MAX - 1, 2 );
62
+
63
+ //add_filter( 'woocommerce_get_variation_prices_hash', array( $this, 'get_variation_prices_hash' ), PHP_INT_MAX - 1, 3 );
64
+ add_filter( 'woocommerce_variation_prices_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX - 1, 2 );
65
+ add_filter( 'woocommerce_variation_prices_regular_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX - 1, 2 );
66
+ add_filter( 'woocommerce_variation_prices_sale_price', array( $this, 'change_price_by_country' ), PHP_INT_MAX - 1, 2 );
67
  //}
68
 
69
  // Country selection box
75
  // add_shortcode( 'wcj_debug_price_by_country', array( $this, 'get_debug_info' ) );
76
  }
77
 
78
+ /**
79
+ * get_variation_prices_hash.
80
+ *
81
+ * @version 2.4.0
82
+ * @since 2.4.0
83
+ */
84
+ /* function get_variation_prices_hash( $price_hash, $_product, $display ) {
85
+ if ( ! empty( $price_hash ) ) wcj_log( $price_hash );
86
+ //$price_hash = array( false );
87
+ return $price_hash;
88
+ } */
89
+
90
  /**
91
  * add_country_selection_box.
92
  *
includes/shortcodes/class-wcj-general-shortcodes.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack General Shortcodes class.
6
  *
7
- * @version 2.3.7
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -62,7 +62,7 @@ class WCJ_General_Shortcodes extends WCJ_Shortcodes {
62
  /**
63
  * wcj_country_select_drop_down_list.
64
  *
65
- * @version 2.3.0
66
  */
67
  function wcj_country_select_drop_down_list( $atts, $content ) {
68
 
@@ -95,11 +95,18 @@ class WCJ_General_Shortcodes extends WCJ_Shortcodes {
95
  } */
96
  $selected_country = ( isset( $_SESSION[ 'wcj-country' ] ) ) ? $_SESSION[ 'wcj-country' ] : '';
97
 
98
- foreach ( $countries as $country_code => $country_name ) {
99
- if ( empty( $shortcode_countries ) || ( in_array( $country_code, $shortcode_countries ) ) ) {
100
  $html .= '<option value="' . $country_code . '" ' . selected( $country_code, $selected_country, false ) . '>' . $country_name . '</option>';
101
  }
 
 
 
 
 
 
102
  }
 
103
  $html .= '</select>';
104
 
105
  $html .= '</form>';
4
  *
5
  * The WooCommerce Jetpack General Shortcodes class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
62
  /**
63
  * wcj_country_select_drop_down_list.
64
  *
65
+ * @version 2.4.0
66
  */
67
  function wcj_country_select_drop_down_list( $atts, $content ) {
68
 
95
  } */
96
  $selected_country = ( isset( $_SESSION[ 'wcj-country' ] ) ) ? $_SESSION[ 'wcj-country' ] : '';
97
 
98
+ if ( empty( $shortcode_countries ) ) {
99
+ foreach ( $countries as $country_code => $country_name ) {
100
  $html .= '<option value="' . $country_code . '" ' . selected( $country_code, $selected_country, false ) . '>' . $country_name . '</option>';
101
  }
102
+ } else {
103
+ foreach ( $shortcode_countries as $country_code ) {
104
+ if ( isset( $countries[ $country_code ] ) ) {
105
+ $html .= '<option value="' . $country_code . '" ' . selected( $country_code, $selected_country, false ) . '>' . $countries[ $country_code ] . '</option>';
106
+ }
107
+ }
108
  }
109
+
110
  $html .= '</select>';
111
 
112
  $html .= '</form>';
includes/shortcodes/class-wcj-order-items-shortcodes.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Order Items Shortcodes class.
6
  *
7
- * @version 2.2.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -14,21 +14,21 @@ if ( ! class_exists( 'WCJ_Order_Items_Shortcodes' ) ) :
14
 
15
  class WCJ_Order_Items_Shortcodes extends WCJ_Shortcodes {
16
 
17
- /**
18
- * Constructor.
19
- */
20
- public function __construct() {
21
 
22
  $this->the_shortcodes = array(
23
  'wcj_order_items_table',
24
  );
25
 
26
  parent::__construct();
27
- }
28
 
29
- /**
30
- * add_extra_atts.
31
- */
32
  function add_extra_atts( $atts ) {
33
  $modified_atts = array_merge( array(
34
  'order_id' => ( isset( $_GET['order_id'] ) ) ? $_GET['order_id'] : get_the_ID(),
@@ -47,53 +47,53 @@ class WCJ_Order_Items_Shortcodes extends WCJ_Shortcodes {
47
  return $modified_atts;
48
  }
49
 
50
- /**
51
- * init_atts.
52
- */
53
  function init_atts( $atts ) {
54
  $this->the_order = ( 'shop_order' === get_post_type( $atts['order_id'] ) ) ? wc_get_order( $atts['order_id'] ) : null;
55
  if ( ! $this->the_order ) return false;
56
  return $atts;
57
  }
58
 
59
- /**
60
- * wcj_price_shortcode.
61
- */
62
  private function wcj_price_shortcode( $raw_price, $atts ) {
63
  return wcj_price( $atts['price_prefix'] . $raw_price, $this->the_order->get_order_currency(), $atts['hide_currency'] );
64
  }
65
 
66
- /**
67
- * add_item.
68
- */
69
- private function add_item( $items, $new_item_args = array() ) {
70
  if ( empty ( $new_item_args ) ) return $items;
71
  extract( $new_item_args );
72
  // Create item
73
  $items[] = array(
74
- 'is_custom' => true,
75
- 'name' => $name,
76
- 'type' => 'line_item',
77
- 'qty' => $qty,
78
- 'line_subtotal' => $line_subtotal,
79
- 'line_total' => $line_total,
80
- 'line_tax' => $line_tax,
81
  'line_subtotal_tax' => $line_subtotal_tax,
82
- 'item_meta' => array(
83
- '_qty' => array( $qty ),
84
- '_line_subtotal' => array( $line_subtotal ),
85
- '_line_total' => array( $line_total ),
86
- '_line_tax' => array( $line_tax ),
87
- '_line_subtotal_tax' => array( $line_subtotal_tax ),
88
  ),
89
  );
90
  return $items;
91
  }
92
 
93
- /**
94
- * wcj_order_get_cart_discount_tax.
95
- */
96
- function wcj_order_get_cart_discount_tax() {
97
 
98
  $the_cart_discount = $this->the_order->get_cart_discount();
99
  $is_discount_taxable = ( $the_cart_discount > 0 ) ? true : false;
@@ -101,7 +101,7 @@ class WCJ_Order_Items_Shortcodes extends WCJ_Shortcodes {
101
  if ( $is_discount_taxable ) {
102
 
103
  /* $order_total_incl_tax = $this->the_order->get_total();
104
- $order_total_tax = $this->the_order->get_total_tax(); */
105
 
106
  $order_total_incl_tax = 0;
107
  $order_total_tax = 0;
@@ -121,12 +121,14 @@ class WCJ_Order_Items_Shortcodes extends WCJ_Shortcodes {
121
  }
122
 
123
  return false;
124
- }
125
 
126
- /**
127
- * wcj_order_items_table.
128
- */
129
- function wcj_order_items_table( $atts, $content = '' ) {
 
 
130
 
131
  $html = '';
132
  $the_order = $this->the_order;
@@ -158,10 +160,10 @@ class WCJ_Order_Items_Shortcodes extends WCJ_Shortcodes {
158
  $total_discount_tax_excl = $the_order->get_total_discount( true );
159
  $discount_tax = $the_order->get_total_discount( false ) - $total_discount_tax_excl;
160
 
161
- if ( false != ( $the_tax = $this->wcj_order_get_cart_discount_tax() ) ) {
162
  $total_discount_tax_excl -= $the_tax;
163
  $discount_tax += $the_tax;
164
- }
165
 
166
  $total_discount_tax_excl *= -1;
167
  $discount_tax *= -1;
@@ -199,6 +201,20 @@ class WCJ_Order_Items_Shortcodes extends WCJ_Shortcodes {
199
  $data[ $item_counter ][] = $the_item_title;
200
  }
201
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  case 'item_variation':
203
  $data[ $item_counter ][] = ( $the_product->is_type( 'variation' ) ) ? wc_get_formatted_variation( $the_product->variation_data, true ) : '';
204
  break;
4
  *
5
  * The WooCommerce Jetpack Order Items Shortcodes class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
14
 
15
  class WCJ_Order_Items_Shortcodes extends WCJ_Shortcodes {
16
 
17
+ /**
18
+ * Constructor.
19
+ */
20
+ public function __construct() {
21
 
22
  $this->the_shortcodes = array(
23
  'wcj_order_items_table',
24
  );
25
 
26
  parent::__construct();
27
+ }
28
 
29
+ /**
30
+ * add_extra_atts.
31
+ */
32
  function add_extra_atts( $atts ) {
33
  $modified_atts = array_merge( array(
34
  'order_id' => ( isset( $_GET['order_id'] ) ) ? $_GET['order_id'] : get_the_ID(),
47
  return $modified_atts;
48
  }
49
 
50
+ /**
51
+ * init_atts.
52
+ */
53
  function init_atts( $atts ) {
54
  $this->the_order = ( 'shop_order' === get_post_type( $atts['order_id'] ) ) ? wc_get_order( $atts['order_id'] ) : null;
55
  if ( ! $this->the_order ) return false;
56
  return $atts;
57
  }
58
 
59
+ /**
60
+ * wcj_price_shortcode.
61
+ */
62
  private function wcj_price_shortcode( $raw_price, $atts ) {
63
  return wcj_price( $atts['price_prefix'] . $raw_price, $this->the_order->get_order_currency(), $atts['hide_currency'] );
64
  }
65
 
66
+ /**
67
+ * add_item.
68
+ */
69
+ private function add_item( $items, $new_item_args = array() ) {
70
  if ( empty ( $new_item_args ) ) return $items;
71
  extract( $new_item_args );
72
  // Create item
73
  $items[] = array(
74
+ 'is_custom' => true,
75
+ 'name' => $name,
76
+ 'type' => 'line_item',
77
+ 'qty' => $qty,
78
+ 'line_subtotal' => $line_subtotal,
79
+ 'line_total' => $line_total,
80
+ 'line_tax' => $line_tax,
81
  'line_subtotal_tax' => $line_subtotal_tax,
82
+ 'item_meta' => array(
83
+ '_qty' => array( $qty ),
84
+ '_line_subtotal' => array( $line_subtotal ),
85
+ '_line_total' => array( $line_total ),
86
+ '_line_tax' => array( $line_tax ),
87
+ '_line_subtotal_tax' => array( $line_subtotal_tax ),
88
  ),
89
  );
90
  return $items;
91
  }
92
 
93
+ /**
94
+ * wcj_order_get_cart_discount_tax.
95
+ */
96
+ /* function wcj_order_get_cart_discount_tax() {
97
 
98
  $the_cart_discount = $this->the_order->get_cart_discount();
99
  $is_discount_taxable = ( $the_cart_discount > 0 ) ? true : false;
101
  if ( $is_discount_taxable ) {
102
 
103
  /* $order_total_incl_tax = $this->the_order->get_total();
104
+ $order_total_tax = $this->the_order->get_total_tax(); *//*
105
 
106
  $order_total_incl_tax = 0;
107
  $order_total_tax = 0;
121
  }
122
 
123
  return false;
124
+ } */
125
 
126
+ /**
127
+ * wcj_order_items_table.
128
+ *
129
+ * @version 2.4.0
130
+ */
131
+ function wcj_order_items_table( $atts, $content = '' ) {
132
 
133
  $html = '';
134
  $the_order = $this->the_order;
160
  $total_discount_tax_excl = $the_order->get_total_discount( true );
161
  $discount_tax = $the_order->get_total_discount( false ) - $total_discount_tax_excl;
162
 
163
+ /* if ( false != ( $the_tax = $this->wcj_order_get_cart_discount_tax() ) ) {
164
  $total_discount_tax_excl -= $the_tax;
165
  $discount_tax += $the_tax;
166
+ } */
167
 
168
  $total_discount_tax_excl *= -1;
169
  $discount_tax *= -1;
201
  $data[ $item_counter ][] = $the_item_title;
202
  }
203
  break;
204
+ case 'item_excerpt':
205
+ case 'item_description':
206
+ case 'item_short_description':
207
+ if ( true === $item['is_custom'] ) {
208
+ $data[ $item_counter ][] = '';
209
+ } else {
210
+ global $post;
211
+ $post = get_post( $item['product_id'] );
212
+ setup_postdata( $post );
213
+ $the_excerpt = get_the_excerpt();
214
+ wp_reset_postdata();
215
+ $data[ $item_counter ][] = $the_excerpt;
216
+ }
217
+ break;
218
  case 'item_variation':
219
  $data[ $item_counter ][] = ( $the_product->is_type( 'variation' ) ) ? wc_get_formatted_variation( $the_product->variation_data, true ) : '';
220
  break;
includes/shortcodes/class-wcj-orders-shortcodes.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Orders Shortcodes class.
6
  *
7
- * @version 2.3.11
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -17,7 +17,7 @@ class WCJ_Orders_Shortcodes extends WCJ_Shortcodes {
17
  /**
18
  * Constructor.
19
  *
20
- * @version 2.3.0
21
  */
22
  public function __construct() {
23
 
@@ -40,7 +40,7 @@ class WCJ_Orders_Shortcodes extends WCJ_Shortcodes {
40
  'wcj_order_subtotal',
41
  'wcj_order_subtotal_plus_shipping',
42
  'wcj_order_total_discount',
43
- 'wcj_order_cart_discount',
44
  'wcj_order_shipping_tax',
45
  'wcj_order_total_tax',
46
  'wcj_order_total_tax_percent',
@@ -67,6 +67,8 @@ class WCJ_Orders_Shortcodes extends WCJ_Shortcodes {
67
 
68
  /**
69
  * add_extra_atts.
 
 
70
  */
71
  function add_extra_atts( $atts ) {
72
  $modified_atts = array_merge( array(
@@ -79,6 +81,9 @@ class WCJ_Orders_Shortcodes extends WCJ_Shortcodes {
79
  'field_id' => '',
80
  'name' => '',
81
  'round_by_line' => 'no',
 
 
 
82
  ), $atts );
83
 
84
  return $modified_atts;
@@ -298,7 +303,7 @@ class WCJ_Orders_Shortcodes extends WCJ_Shortcodes {
298
  /**
299
  * wcj_order_get_cart_discount_tax.
300
  */
301
- function wcj_order_get_cart_discount_tax() {
302
 
303
  $the_cart_discount = $this->the_order->get_cart_discount();
304
  $is_discount_taxable = ( $the_cart_discount > 0 ) ? true : false;
@@ -306,7 +311,7 @@ class WCJ_Orders_Shortcodes extends WCJ_Shortcodes {
306
  if ( $is_discount_taxable ) {
307
 
308
  /* $order_total_incl_tax = $this->the_order->get_total();
309
- $order_total_tax = $this->the_order->get_total_tax(); */
310
 
311
  $order_total_incl_tax = 0;
312
  $order_total_tax = 0;
@@ -326,20 +331,22 @@ class WCJ_Orders_Shortcodes extends WCJ_Shortcodes {
326
  }
327
 
328
  return false;
329
- }
330
 
331
  /**
332
  * wcj_order_total_discount.
 
 
333
  */
334
  function wcj_order_total_discount( $atts ) {
335
 
336
  $the_discount = $this->the_order->get_total_discount( $atts['excl_tax'] );
337
 
338
- if ( true === $atts['excl_tax'] ) {
339
  if ( false != ( $the_tax = $this->wcj_order_get_cart_discount_tax() ) ) {
340
  $the_discount -= $the_tax;
341
  }
342
- }
343
 
344
  return $this->wcj_price_shortcode( $the_discount, $atts );
345
  }
@@ -347,9 +354,9 @@ class WCJ_Orders_Shortcodes extends WCJ_Shortcodes {
347
  /**
348
  * wcj_order_cart_discount.
349
  */
350
- function wcj_order_cart_discount( $atts ) {
351
  return $this->wcj_price_shortcode( $this->the_order->get_cart_discount() , $atts );
352
- }
353
 
354
  /**
355
  * wcj_order_shipping_tax.
@@ -361,13 +368,15 @@ class WCJ_Orders_Shortcodes extends WCJ_Shortcodes {
361
  /**
362
  * wcj_order_total_tax_percent.
363
  *
364
- * @version 2.3.11
365
  */
366
  function wcj_order_total_tax_percent( $atts ) {
367
- $order_total_excl_tax = $this->the_order->get_total() - $this->the_order->get_total_tax();
368
  $order_total_tax_not_rounded = $this->the_order->get_cart_tax() + $this->the_order->get_shipping_tax();
369
- $order_total_tax_percent = ( 0 == $order_total_excl_tax ) ? 0 : $order_total_tax_not_rounded / $order_total_excl_tax * 100;
370
- return apply_filters( 'wcj_order_total_tax_percent', $order_total_tax_percent, $this->the_order );
 
 
 
371
  }
372
 
373
  /**
@@ -399,7 +408,7 @@ class WCJ_Orders_Shortcodes extends WCJ_Shortcodes {
399
  $the_subtotal += $this->the_order->get_line_subtotal( $item, false, true );
400
  }
401
  } else {
402
- $the_subtotal = $this->the_order->get_subtotal();
403
  }
404
 
405
  return $this->wcj_price_shortcode( $the_subtotal, $atts );
@@ -433,21 +442,25 @@ class WCJ_Orders_Shortcodes extends WCJ_Shortcodes {
433
 
434
  /**
435
  * wcj_order_total_in_words.
 
 
436
  */
437
  function wcj_order_total_in_words( $atts ) {
 
438
  $order_total = ( true === $atts['excl_tax'] ) ? $this->the_order->get_total() - $this->the_order->get_total_tax() : $this->the_order->get_total();
439
- $order_total_dollars = intval( $order_total );
440
- $order_total_cents = ( $order_total - intval( $order_total ) ) * 100;
441
 
442
  $the_number_in_words = '%s %s';
443
- if ( 0 != $order_total_cents ) $the_number_in_words .= ', %s %s.';
444
- else $the_number_in_words .= '.';
445
- $dollars = 'Dollars';//$this->the_order->get_order_currency();
446
- $cents = 'Cents';
 
447
  return sprintf( $the_number_in_words,
448
- ucfirst( convert_number_to_words( $order_total_dollars ) ),
449
  $dollars,
450
- ucfirst( convert_number_to_words( $order_total_cents ) ),
451
  $cents );
452
  }
453
  }
4
  *
5
  * The WooCommerce Jetpack Orders Shortcodes class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
17
  /**
18
  * Constructor.
19
  *
20
+ * @version 2.4.0
21
  */
22
  public function __construct() {
23
 
40
  'wcj_order_subtotal',
41
  'wcj_order_subtotal_plus_shipping',
42
  'wcj_order_total_discount',
43
+ // 'wcj_order_cart_discount',
44
  'wcj_order_shipping_tax',
45
  'wcj_order_total_tax',
46
  'wcj_order_total_tax_percent',
67
 
68
  /**
69
  * add_extra_atts.
70
+ *
71
+ * @version 2.4.0
72
  */
73
  function add_extra_atts( $atts ) {
74
  $modified_atts = array_merge( array(
81
  'field_id' => '',
82
  'name' => '',
83
  'round_by_line' => 'no',
84
+ 'whole' => __( 'Dollars', 'woocommerce-jetpack' ),
85
+ 'decimal' => __( 'Cents', 'woocommerce-jetpack' ),
86
+ 'precision' => get_option( 'woocommerce_price_num_decimals', 2 ),
87
  ), $atts );
88
 
89
  return $modified_atts;
303
  /**
304
  * wcj_order_get_cart_discount_tax.
305
  */
306
+ /* function wcj_order_get_cart_discount_tax() {
307
 
308
  $the_cart_discount = $this->the_order->get_cart_discount();
309
  $is_discount_taxable = ( $the_cart_discount > 0 ) ? true : false;
311
  if ( $is_discount_taxable ) {
312
 
313
  /* $order_total_incl_tax = $this->the_order->get_total();
314
+ $order_total_tax = $this->the_order->get_total_tax(); *//*
315
 
316
  $order_total_incl_tax = 0;
317
  $order_total_tax = 0;
331
  }
332
 
333
  return false;
334
+ } */
335
 
336
  /**
337
  * wcj_order_total_discount.
338
+ *
339
+ * @version 2.4.0
340
  */
341
  function wcj_order_total_discount( $atts ) {
342
 
343
  $the_discount = $this->the_order->get_total_discount( $atts['excl_tax'] );
344
 
345
+ /* if ( true === $atts['excl_tax'] ) {
346
  if ( false != ( $the_tax = $this->wcj_order_get_cart_discount_tax() ) ) {
347
  $the_discount -= $the_tax;
348
  }
349
+ } */
350
 
351
  return $this->wcj_price_shortcode( $the_discount, $atts );
352
  }
354
  /**
355
  * wcj_order_cart_discount.
356
  */
357
+ /* function wcj_order_cart_discount( $atts ) {
358
  return $this->wcj_price_shortcode( $this->the_order->get_cart_discount() , $atts );
359
+ } */
360
 
361
  /**
362
  * wcj_order_shipping_tax.
368
  /**
369
  * wcj_order_total_tax_percent.
370
  *
371
+ * @version 2.4.0
372
  */
373
  function wcj_order_total_tax_percent( $atts ) {
 
374
  $order_total_tax_not_rounded = $this->the_order->get_cart_tax() + $this->the_order->get_shipping_tax();
375
+ $order_total_excl_tax = $this->the_order->get_total() - $order_total_tax_not_rounded;
376
+ $order_total_tax_percent = ( 0 == $order_total_excl_tax ) ? 0 : $order_total_tax_not_rounded / $order_total_excl_tax * 100;
377
+ $order_total_tax_percent = round( $order_total_tax_percent, $atts['precision'] );
378
+ apply_filters( 'wcj_order_total_tax_percent', $order_total_tax_percent, $this->the_order );
379
+ return number_format( $order_total_tax_percent, $atts['precision'] );
380
  }
381
 
382
  /**
408
  $the_subtotal += $this->the_order->get_line_subtotal( $item, false, true );
409
  }
410
  } else {
411
+ $the_subtotal = $this->the_order->get_subtotal();
412
  }
413
 
414
  return $this->wcj_price_shortcode( $the_subtotal, $atts );
442
 
443
  /**
444
  * wcj_order_total_in_words.
445
+ *
446
+ * @version 2.4.0
447
  */
448
  function wcj_order_total_in_words( $atts ) {
449
+
450
  $order_total = ( true === $atts['excl_tax'] ) ? $this->the_order->get_total() - $this->the_order->get_total_tax() : $this->the_order->get_total();
451
+ $order_total_whole = intval( $order_total );
452
+ $order_total_decimal = round( ( $order_total - $order_total_whole ) * 100 );
453
 
454
  $the_number_in_words = '%s %s';
455
+ $the_number_in_words .= ( 0 != $order_total_decimal ) ? ', %s %s.' : '.';
456
+
457
+ $dollars = $atts['whole'];
458
+ $cents = $atts['decimal'];
459
+
460
  return sprintf( $the_number_in_words,
461
+ ucfirst( convert_number_to_words( $order_total_whole ) ),
462
  $dollars,
463
+ ucfirst( convert_number_to_words( $order_total_decimal ) ),
464
  $cents );
465
  }
466
  }
includes/shortcodes/class-wcj-products-shortcodes.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Products Shortcodes class.
6
  *
7
- * @version 2.3.8
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -17,7 +17,7 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
17
  /**
18
  * Constructor.
19
  *
20
- * @version 2.2.6
21
  */
22
  public function __construct() {
23
 
@@ -42,6 +42,22 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
42
  'wcj_product_crowdfunding_startdate',
43
  'wcj_product_crowdfunding_deadline',
44
  'wcj_product_crowdfunding_time_remaining',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  );
46
 
47
  $this->the_atts = array(
@@ -55,18 +71,23 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
55
  'sep' => ', ',
56
  'add_links' => 'yes',
57
  'add_percent_row' => 'no',
 
 
 
 
 
58
  );
59
 
60
  parent::__construct();
61
- }
62
 
63
- /**
64
- * Inits shortcode atts and properties.
65
  *
66
  * @param array $atts Shortcode atts.
67
  *
68
  * @return array The (modified) shortcode atts.
69
- */
70
  function init_atts( $atts ) {
71
 
72
  // Atts
@@ -119,6 +140,233 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
119
  return ( 'orders_sum' === $return_value ) ? $total_sum : $total_orders;
120
  }
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  /**
123
  * wcj_product_total_orders.
124
  *
@@ -211,12 +459,12 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
211
  /**
212
  * wcj_product_total_sales.
213
  *
214
- * @version 2.2.6
215
  * @since 2.2.6
216
  */
217
  function wcj_product_total_sales( $atts ) {
218
  $product_custom_fields = get_post_custom( $this->the_product->id );
219
- return ( isset( $product_custom_fields['total_sales'][0] ) ) ? $product_custom_fields['total_sales'][0] : false;
220
  }
221
 
222
  /**
@@ -251,34 +499,46 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
251
  /**
252
  * wcj_product_you_save.
253
  *
254
- * @return string
 
255
  */
256
  function wcj_product_you_save( $atts ) {
257
-
258
- if ( $this->the_product->is_type( 'variable' ) ) {
259
- $you_save = ( $this->the_product->get_variation_regular_price( 'max' ) - $this->the_product->get_variation_sale_price( 'max' ) );
 
 
 
 
260
  } else {
261
- $you_save = ( $this->the_product->get_regular_price() - $this->the_product->get_sale_price() );
262
  }
263
- return wc_price( $you_save );
264
  }
265
 
266
  /**
267
  * wcj_product_you_save_percent.
268
  *
269
- * @return string
 
270
  */
271
  function wcj_product_you_save_percent( $atts ) {
272
-
273
- if ( $this->the_product->is_type( 'variable' ) ) {
274
- $you_save = ( $this->the_product->get_variation_regular_price( 'max' ) - $this->the_product->get_variation_sale_price( 'max' ) );
275
- $regular_price = $this->the_product->get_variation_regular_price( 'max' );
 
 
 
 
 
 
 
 
 
 
276
  } else {
277
- $you_save = ( $this->the_product->get_regular_price() - $this->the_product->get_sale_price() );
278
- $regular_price = $this->the_product->get_regular_price();
279
  }
280
-
281
- return ( 0 != $regular_price ) ? intval( $you_save / $regular_price * 100 ) : '';
282
  }
283
 
284
  /**
@@ -292,13 +552,12 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
292
  //return get_post_meta( $atts['product_id'], $atts['name'], true );
293
  }
294
 
295
- /**
296
- * Returns product (modified) price.
297
- *
298
- * @todo Variable products: a)not range, and b)price by country.
299
  *
300
- * @return string The product (modified) price
301
- */
 
302
  function wcj_product_price( $atts ) {
303
  // Variable
304
  if ( $this->the_product->is_type( 'variable' ) ) {
@@ -322,9 +581,9 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
322
  }
323
  }
324
 
325
- /**
326
  * wcj_product_wholesale_price_table.
327
- */
328
  function wcj_product_wholesale_price_table( $atts ) {
329
 
330
  if ( ! wcj_is_product_wholesale_enabled( $this->the_product->id ) ) return '';
@@ -410,9 +669,7 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
410
  if ( 0 != $atts['excerpt_length'] ) remove_filter( 'excerpt_length', array( $this, 'custom_excerpt_length' ), PHP_INT_MAX );
411
 
412
  wp_reset_postdata();
413
- //wcj_log( $the_excerpt );
414
  return $the_excerpt;
415
-
416
  }
417
 
418
  /**
@@ -436,15 +693,16 @@ class WCJ_Products_Shortcodes extends WCJ_Shortcodes {
436
  /**
437
  * Get the product's weight.
438
  *
439
- * @return string
 
440
  */
441
  function wcj_product_weight( $atts ) {
442
- return $this->the_product->get_weight();
443
  }
444
 
445
  /**
446
- * wcj_product_image.
447
- */
448
  function wcj_product_image( $atts ) {
449
  return $this->the_product->get_image( $atts['image_size'] );
450
  }
4
  *
5
  * The WooCommerce Jetpack Products Shortcodes class.
6
  *
7
+ * @version 2.4.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
17
  /**
18
  * Constructor.
19
  *
20
+ * @version 2.4.0
21
  */
22
  public function __construct() {
23
 
42
  'wcj_product_crowdfunding_startdate',
43
  'wcj_product_crowdfunding_deadline',
44
  'wcj_product_crowdfunding_time_remaining',
45
+ 'wcj_product_shipping_class',
46
+ 'wcj_product_dimensions',
47
+ 'wcj_product_formatted_name',
48
+ 'wcj_product_stock_availability',
49
+ 'wcj_product_tax_class',
50
+ 'wcj_product_average_rating',
51
+ 'wcj_product_categories',
52
+ 'wcj_product_list_attributes',
53
+ 'wcj_product_list_attribute',
54
+ 'wcj_product_stock_quantity',
55
+ 'wcj_product_sale_price',
56
+ 'wcj_product_regular_price',
57
+ 'wcj_product_time_since_last_sale',
58
+ 'wcj_product_price_including_tax',
59
+ 'wcj_product_price_excluding_tax',
60
+ 'wcj_product_available_variations',
61
  );
62
 
63
  $this->the_atts = array(
71
  'sep' => ', ',
72
  'add_links' => 'yes',
73
  'add_percent_row' => 'no',
74
+ 'show_always' => 'yes',
75
+ 'hide_if_zero' => 'no',
76
+ 'reverse' => 'no',
77
+ 'find' => '',
78
+ 'replace' => '',
79
  );
80
 
81
  parent::__construct();
82
+ }
83
 
84
+ /**
85
+ * Inits shortcode atts and properties.
86
  *
87
  * @param array $atts Shortcode atts.
88
  *
89
  * @return array The (modified) shortcode atts.
90
+ */
91
  function init_atts( $atts ) {
92
 
93
  // Atts
140
  return ( 'orders_sum' === $return_value ) ? $total_sum : $total_orders;
141
  }
142
 
143
+ /**
144
+ * wcj_product_time_since_last_sale.
145
+ *
146
+ * @version 2.4.0
147
+ * @since 2.4.0
148
+ * @todo not finished
149
+ */
150
+ function wcj_product_time_since_last_sale( $atts ) {
151
+ // Constants
152
+ $days_to_cover = 90;
153
+ $do_use_only_completed_orders = true;
154
+ // Get the ID before new query
155
+ $the_ID = get_the_ID();
156
+ // Create args for new query
157
+ $args = array(
158
+ 'post_type' => 'shop_order',
159
+ 'post_status' => ( true === $do_use_only_completed_orders ? 'wc-completed' : 'any' ),
160
+ 'posts_per_page' => -1,
161
+ 'orderby' => 'date',
162
+ 'order' => 'DESC',
163
+ 'date_query' => array( array( 'after' => strtotime( '-' . $days_to_cover . ' days' ) ) ),
164
+ );
165
+ // Run new query
166
+ $loop = new WP_Query( $args );
167
+ // Analyze the results, i.e. orders
168
+ while ( $loop->have_posts() ) : $loop->the_post();
169
+ $order = new WC_Order( $loop->post->ID );
170
+ $items = $order->get_items();
171
+ foreach ( $items as $item ) {
172
+ // Run through all order's items
173
+ if ( $item['product_id'] == $the_ID ) {
174
+ // Found sale!
175
+ $result = sprintf( __( '%s ago', 'woocommerce-jetpack' ), human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) );
176
+ wp_reset_postdata();
177
+ return $result;
178
+ }
179
+ }
180
+ endwhile;
181
+ wp_reset_postdata();
182
+ // No sales found
183
+ return '';
184
+ }
185
+
186
+ /**
187
+ * wcj_product_available_variations.
188
+ *
189
+ * @version 2.4.0
190
+ * @since 2.4.0
191
+ */
192
+ function wcj_product_available_variations( $atts ) {
193
+ $return_html = '';
194
+ if ( $this->the_product->is_type( 'variable' ) ) {
195
+ $return_html .= '<table>';
196
+ foreach ( $this->the_product->get_available_variations() as $variation ) {
197
+ $return_html .= '<tr>';
198
+ foreach ( $variation['attributes'] as $attribute_slug => $attribute_name ) {
199
+ if ( '' == $attribute_name ) $attribute_name = __( 'Any', 'woocommerce-jetpack' );
200
+ $return_html .= '<td>' . $attribute_name . '</td>';
201
+ }
202
+ $return_html .= '<td>' . $variation['price_html'] . '</td>';
203
+ $return_html .= '</tr>';
204
+ }
205
+ $return_html .= '</table>';
206
+ }
207
+ return $return_html;
208
+ }
209
+
210
+ /**
211
+ * wcj_product_price_excluding_tax.
212
+ *
213
+ * @version 2.4.0
214
+ * @since 2.4.0
215
+ */
216
+ function wcj_product_price_excluding_tax( $atts ) {
217
+ $the_price = $this->the_product->get_price_excluding_tax();
218
+ return ( 'yes' === $atts['hide_currency'] ) ? $the_price : wc_price( $the_price );
219
+ }
220
+
221
+ /**
222
+ * wcj_product_price_including_tax.
223
+ *
224
+ * @version 2.4.0
225
+ * @since 2.4.0
226
+ */
227
+ function wcj_product_price_including_tax( $atts ) {
228
+ $the_price = $this->the_product->get_price_including_tax();
229
+ return ( 'yes' === $atts['hide_currency'] ) ? $the_price : wc_price( $the_price );
230
+ }
231
+
232
+ /**
233
+ * wcj_product_regular_price.
234
+ *
235
+ * @version 2.4.0
236
+ * @since 2.4.0
237
+ */
238
+ function wcj_product_regular_price( $atts ) {
239
+ if ( $this->the_product->is_on_sale() || 'yes' === $atts['show_always'] ) {
240
+ $the_price = $this->the_product->get_regular_price();
241
+ return ( 'yes' === $atts['hide_currency'] ) ? $the_price : wc_price( $the_price );
242
+ }
243
+ return '';
244
+ }
245
+
246
+ /**
247
+ * wcj_product_sale_price.
248
+ *
249
+ * @version 2.4.0
250
+ * @since 2.4.0
251
+ */
252
+ function wcj_product_sale_price( $atts ) {
253
+ if ( $this->the_product->is_on_sale() ) {
254
+ $the_price = $this->the_product->get_sale_price();
255
+ return ( 'yes' === $atts['hide_currency'] ) ? $the_price : wc_price( $the_price );
256
+ }
257
+ return '';
258
+ }
259
+
260
+ /**
261
+ * wcj_product_tax_class.
262
+ *
263
+ * @version 2.4.0
264
+ * @since 2.4.0
265
+ */
266
+ function wcj_product_tax_class( $atts ) {
267
+ return $this->the_product->get_tax_class();
268
+ }
269
+
270
+ /**
271
+ * wcj_product_list_attributes.
272
+ *
273
+ * @version 2.4.0
274
+ * @since 2.4.0
275
+ */
276
+ function wcj_product_list_attributes( $atts ) {
277
+ return ( $this->the_product->has_attributes() ) ? $this->the_product->list_attributes() : '';
278
+ }
279
+
280
+ /**
281
+ * wcj_product_list_attribute.
282
+ *
283
+ * @version 2.4.0
284
+ * @since 2.4.0
285
+ */
286
+ function wcj_product_list_attribute( $atts ) {
287
+ return str_replace( $atts['find'], $atts['replace'], $this->the_product->get_attribute( $atts['name'] ) );
288
+ }
289
+
290
+ /**
291
+ * wcj_product_stock_quantity.
292
+ *
293
+ * @version 2.4.0
294
+ * @since 2.4.0
295
+ */
296
+ function wcj_product_stock_quantity( $atts ) {
297
+ $stock_quantity = $this->the_product->get_stock_quantity();
298
+ return ( '' != $stock_quantity ) ? $stock_quantity : false;
299
+ }
300
+
301
+ /**
302
+ * wcj_product_average_rating.
303
+ *
304
+ * @version 2.4.0
305
+ * @since 2.4.0
306
+ */
307
+ function wcj_product_average_rating( $atts ) {
308
+ return $this->the_product->get_average_rating();
309
+ }
310
+
311
+ /**
312
+ * wcj_product_categories.
313
+ *
314
+ * @version 2.4.0
315
+ * @since 2.4.0
316
+ */
317
+ function wcj_product_categories( $atts ) {
318
+ return $this->the_product->get_categories();
319
+ }
320
+
321
+ /**
322
+ * wcj_product_formatted_name.
323
+ *
324
+ * @version 2.4.0
325
+ * @since 2.4.0
326
+ */
327
+ function wcj_product_formatted_name( $atts ) {
328
+ return $this->the_product->get_formatted_name();
329
+ }
330
+
331
+ /**
332
+ * wcj_product_stock_availability.
333
+ *
334
+ * @version 2.4.0
335
+ * @since 2.4.0
336
+ */
337
+ function wcj_product_stock_availability( $atts ) {
338
+ $stock_availability_array = $this->the_product->get_availability();
339
+ return ( isset( $stock_availability_array['availability'] ) ) ? $stock_availability_array['availability'] : '';
340
+ }
341
+
342
+ /**
343
+ * wcj_product_dimensions.
344
+ *
345
+ * @version 2.4.0
346
+ * @since 2.4.0
347
+ */
348
+ function wcj_product_dimensions( $atts ) {
349
+ return ( $this->the_product->has_dimensions() ) ? $this->the_product->get_dimensions() : '';
350
+ }
351
+
352
+ /**
353
+ * wcj_product_shipping_class.
354
+ *
355
+ * @version 2.4.0
356
+ * @since 2.4.0
357
+ */
358
+ function wcj_product_shipping_class( $atts ) {
359
+ $the_product_shipping_class = $this->the_product->get_shipping_class();
360
+ if ( '' != $the_product_shipping_class ) {
361
+ foreach ( WC()->shipping->get_shipping_classes() as $shipping_class ) {
362
+ if ( $the_product_shipping_class === $shipping_class->slug ) {
363
+ return $shipping_class->name;
364
+ }
365
+ }
366
+ }
367
+ return '';
368
+ }
369
+
370
  /**
371
  * wcj_product_total_orders.
372
  *
459
  /**
460
  * wcj_product_total_sales.
461
  *
462
+ * @version 2.4.0
463
  * @since 2.2.6
464
  */
465
  function wcj_product_total_sales( $atts ) {
466
  $product_custom_fields = get_post_custom( $this->the_product->id );
467
+ return ( isset( $product_custom_fields['total_sales'][0] ) ) ? $product_custom_fields['total_sales'][0] : '';
468
  }
469
 
470
  /**
499
  /**
500
  * wcj_product_you_save.
501
  *
502
+ * @return string
503
+ * @version 2.4.0
504
  */
505
  function wcj_product_you_save( $atts ) {
506
+ if ( $this->the_product->is_on_sale() ) {
507
+ if ( $this->the_product->is_type( 'variable' ) ) {
508
+ $you_save = ( $this->the_product->get_variation_regular_price( 'max' ) - $this->the_product->get_variation_sale_price( 'max' ) );
509
+ } else {
510
+ $you_save = ( $this->the_product->get_regular_price() - $this->the_product->get_sale_price() );
511
+ }
512
+ return ( 'yes' === $atts['hide_currency'] ) ? $you_save : wc_price( $you_save );
513
  } else {
514
+ return ( 'yes' === $atts['hide_if_zero'] ) ? '' : 0;
515
  }
 
516
  }
517
 
518
  /**
519
  * wcj_product_you_save_percent.
520
  *
521
+ * @return string
522
+ * @version 2.4.0
523
  */
524
  function wcj_product_you_save_percent( $atts ) {
525
+ if ( $this->the_product->is_on_sale() ) {
526
+ if ( $this->the_product->is_type( 'variable' ) ) {
527
+ $you_save = ( $this->the_product->get_variation_regular_price( 'max' ) - $this->the_product->get_variation_sale_price( 'max' ) );
528
+ $regular_price = $this->the_product->get_variation_regular_price( 'max' );
529
+ } else {
530
+ $you_save = ( $this->the_product->get_regular_price() - $this->the_product->get_sale_price() );
531
+ $regular_price = $this->the_product->get_regular_price();
532
+ }
533
+ if ( 0 != $regular_price ) {
534
+ $you_save_percent = intval( $you_save / $regular_price * 100 );
535
+ return ( 'yes' === $atts['reverse'] ) ? ( 100 - $you_save_percent ) : $you_save_percent;
536
+ } else {
537
+ return '';
538
+ }
539
  } else {
540
+ return ( 'yes' === $atts['hide_if_zero'] ) ? '' : ( ( 'yes' === $atts['reverse'] ) ? 100 : 0 );
 
541
  }
 
 
542
  }
543
 
544
  /**
552
  //return get_post_meta( $atts['product_id'], $atts['name'], true );
553
  }
554
 
555
+ /**
556
+ * Returns product (modified) price.
 
 
557
  *
558
+ * @todo variable products: a) not range; and b) price by country.
559
+ * @return string The product (modified) price
560
+ */
561
  function wcj_product_price( $atts ) {
562
  // Variable
563
  if ( $this->the_product->is_type( 'variable' ) ) {
581
  }
582
  }
583
 
584
+ /**
585
  * wcj_product_wholesale_price_table.
586
+ */
587
  function wcj_product_wholesale_price_table( $atts ) {
588
 
589
  if ( ! wcj_is_product_wholesale_enabled( $this->the_product->id ) ) return '';
669
  if ( 0 != $atts['excerpt_length'] ) remove_filter( 'excerpt_length', array( $this, 'custom_excerpt_length' ), PHP_INT_MAX );
670
 
671
  wp_reset_postdata();
 
672
  return $the_excerpt;
 
673
  }
674
 
675
  /**
693
  /**
694
  * Get the product's weight.
695
  *
696
+ * @return string
697
+ * @version 2.4.0
698
  */
699
  function wcj_product_weight( $atts ) {
700
+ return ( $this->the_product->has_weight() ) ? $this->the_product->get_weight() : '';
701
  }
702
 
703
  /**
704
+ * wcj_product_image.
705
+ */
706
  function wcj_product_image( $atts ) {
707
  return $this->the_product->get_image( $atts['image_size'] );
708
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: algoritmika,anbinder,solovjov
3
  Tags: woocommerce,booster for woocommerce,woocommerce jetpack,custom price labels,call for price,currency symbol,remove sorting,remove old product slugs,add to cart text,order number,sequential order numbering,email pdf invoice,pdf invoice,pdf invoices,already in cart,empty cart,redirect to checkout,minimum order amount,customize checkout fields,checkout fields,email,customize product tabs,product tabs,related products number,empty cart,redirect add to cart,redirect to checkout,product already in cart,custom payment gateway,payment gateway icon,auto-complete all orders,custom order statuses,custom order status,remove text from price,custom css,hide categories count,hide subcategories count,hide category count,hide subcategory count,display total sales,custom product tabs,remove product tab,payment gateway fee,vat
4
  Requires at least: 3.8
5
  Tested up to: 4.4
6
- Stable tag: 2.3.11
7
  License: GNU General Public License v3.0
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -116,6 +116,58 @@ To unlock all Booster for WooCommerce features, please install additional <a hre
116
 
117
  == Changelog ==
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  = 2.3.11 - 29/12/2015 =
120
  * Fix - Orders Shortcodes - `[wcj_order_total_tax_percent]` shortcode "rounding bug" fixed.
121
  * Fix - PDF Invoicing - "Invoices Report" tool - Tax percent column "rounding bug" fixed.
3
  Tags: woocommerce,booster for woocommerce,woocommerce jetpack,custom price labels,call for price,currency symbol,remove sorting,remove old product slugs,add to cart text,order number,sequential order numbering,email pdf invoice,pdf invoice,pdf invoices,already in cart,empty cart,redirect to checkout,minimum order amount,customize checkout fields,checkout fields,email,customize product tabs,product tabs,related products number,empty cart,redirect add to cart,redirect to checkout,product already in cart,custom payment gateway,payment gateway icon,auto-complete all orders,custom order statuses,custom order status,remove text from price,custom css,hide categories count,hide subcategories count,hide category count,hide subcategory count,display total sales,custom product tabs,remove product tab,payment gateway fee,vat
4
  Requires at least: 3.8
5
  Tested up to: 4.4
6
+ Stable tag: 2.4.0
7
  License: GNU General Public License v3.0
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
116
 
117
  == Changelog ==
118
 
119
+ = 2.4.0 - 10/02/2016 =
120
+ * Fix - Custom attribute handling in `output_custom_number()` fixed.
121
+ * Dev - "Reset Module to Default Settings" option added.
122
+ * Dev - Functions - General - `wcj_is_module_enabled()` function added.
123
+ * Dev - Shortcodes - General - `[wcj_country_select_drop_down_list]` - manual sorting when `countries` attribute is used.
124
+ * Fix - Shortcodes - Orders - `[wcj_order_total_tax_percent]` fixed. `precision` attribute added.
125
+ * Fix - Shortcodes - Orders - `get_cart_discount()` (depreciated since WooCommerce 2.3) removed from `[wcj_order_items_table]` shortcode (affected if `discount_as_item` option was used); removed from `[wcj_order_total_discount]` shortcode; `[wcj_order_cart_discount]` shortcode removed.
126
+ * Fix - Shortcodes - Orders - `[wcj_order_total_in_words]` - decimal part rounding bug fixed.
127
+ * Dev - Shortcodes - Orders - `[wcj_order_total_in_words]` - `whole` and `decimal` attributes added.
128
+ * Dev - Shortcodes - Orders - `[wcj_order_items_table]` - `item_short_description` option added.
129
+ * Dev - Shortcodes - Products - `hide_if_zero` attribute added to Products Shortcodes.
130
+ * Fix - Shortcodes - Products - `[wcj_product_you_save]` - checking if product is on sale.
131
+ * Dev - Shortcodes - Products - `[wcj_product_you_save]` - `hide_currency` attribute added.
132
+ * Fix - Shortcodes - Products - `[wcj_product_you_save_percent]` - checking if product is on sale.
133
+ * Dev - Shortcodes - Products - `[wcj_product_you_save_percent]` - `reverse` attribute added.
134
+ * Dev - Shortcodes - Products - New shortcodes added: `[wcj_product_shipping_class]` (returns shipping class *name*, not slug), `[wcj_product_dimensions]`, `[wcj_product_formatted_name]`, `[wcj_product_stock_availability]`, `[wcj_product_tax_class]`, `[wcj_product_average_rating]`, `[wcj_product_categories]`, `[wcj_product_list_attributes]`, `[wcj_product_list_attribute]`, `[wcj_product_stock_quantity]`, `[wcj_product_sale_price]`, `[wcj_product_regular_price]`, `[wcj_product_time_since_last_sale]`, `[wcj_product_price_including_tax]`, `[wcj_product_price_excluding_tax]`, `[wcj_product_available_variations]`;
135
+ * Fix - PRICES & CURRENCIES - Price by Country - Payment Gateway Currency module now changes prices *after* Price by Country module.
136
+ * Fix - PRICES & CURRENCIES - Price by Country - Variable products fix (error appeared with WooCommerce v2.5.0 update).
137
+ * Dev - PRICES & CURRENCIES - Currencies - *Custom Currencies* options added.
138
+ * Dev - PRICES & CURRENCIES - Currencies - Code refactoring.
139
+ * Dev - PRICES & CURRENCIES - Bulk Price Converter - Code refactoring.
140
+ * Dev - PRICES & CURRENCIES - Bulk Price Converter - Option to convert prices by *product category* added.
141
+ * Dev - PRODUCTS - Product Info - Code refactoring.
142
+ * Dev - PRODUCTS - Product Info V2 - Initial module release. Product Info marked as depreciated.
143
+ * Dev - PRODUCTS - Product Input Fields - Code refactoring.
144
+ * Dev - PRODUCTS - Product Input Fields - Required field sign option added.
145
+ * Dev - PRODUCTS - Product Input Fields - "time format", "interval" options for Timepicker added.
146
+ * Dev - PRODUCTS - Product Input Fields - "First week day" option for Datepicker/Weekpicker added.
147
+ * Dev - PRODUCTS - Product Input Fields - "Weekpicker" added.
148
+ * Fix - PRODUCTS - Product Input Fields - `add_product_input_fields_to_order_item_name()` fixed. "Item Name Order Table Format" option added.
149
+ * Dev - PRODUCTS - Product Input Fields - Datepicker - "date format", "min date" and "max date" options added.
150
+ * Dev - PRODUCTS - SKU - "Category Suffix" and "Category Prefix" options added.
151
+ * Dev - PRODUCTS - SKU - Code refactoring (minor). Suffix option unlocked.
152
+ * Dev - CART & CHECKOUT - Checkout Core Fields - "time format", "interval" options for Timepicker added.
153
+ * Dev - CART & CHECKOUT - Checkout Core Fields - "First week day" option for Datepicker/Weekpicker added.
154
+ * Fix - CART & CHECKOUT - Checkout Core Fields - "Class" bug fixed.
155
+ * Dev - CART & CHECKOUT - Checkout Custom Fields - "Weekpicker" added.
156
+ * Dev - CART & CHECKOUT - Checkout Custom Fields - Code refactoring (minor).
157
+ * Dev - CART & CHECKOUT - Checkout Custom Fields - Datepicker - "date format", "min date" and "max date" options added.
158
+ * Dev - PAYMENT GATEWAYS - Gateways Currency - "No changes" option added.
159
+ * Dev - PAYMENT GATEWAYS - Custom Gateways - "Custom Return URL (Thank You Page)" option added.
160
+ * Dev - PDF Invoicing - Code refactoring. Classes: WCJ_PDF_Invoicing_Page, WCJ_PDF_Invoicing_Styling etc.
161
+ * Dev - PDF Invoicing - "Hide Settings for Disabled Document Types" option added.
162
+ * Dev - EMAILS & MISC. - General - "Products Revisions" options section added.
163
+ * Dev - EMAILS & MISC. - General - Advanced Options (for handling datepicker and timepicker CSS and JS) added.
164
+ * Dev - EMAILS & MISC. - General - "Disable Booster's Shortcodes" option added.
165
+ * Dev - EMAILS & MISC. - EU VAT Number - `wcj_get_european_union_countries_with_vat()` Romania VAT rate changed from 24% to 20%.
166
+ * Dev - EMAILS & MISC. - EU VAT Number - "Description" option added.
167
+ * Dev - EMAILS & MISC. - Emails - "Custom Emails" - Triggers added (includes custom order statuses).
168
+ * Dev - EMAILS & MISC. - Emails - "Custom Emails" - `%customer%` as recipient added.
169
+ * Dev - EMAILS & MISC. - PDF Invoices v1 - removed.
170
+
171
  = 2.3.11 - 29/12/2015 =
172
  * Fix - Orders Shortcodes - `[wcj_order_total_tax_percent]` shortcode "rounding bug" fixed.
173
  * Fix - PDF Invoicing - "Invoices Report" tool - Tax percent column "rounding bug" fixed.
woocommerce-jetpack.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Booster for WooCommerce
4
  Plugin URI: http://booster.io
5
  Description: Supercharge your WooCommerce site with these awesome powerful features.
6
- Version: 2.3.11
7
  Author: Algoritmika Ltd
8
  Author URI: http://www.algoritmika.com
9
  Copyright: © 2015 Algoritmika Ltd.
@@ -21,7 +21,7 @@ if ( ! class_exists( 'WC_Jetpack' ) ) :
21
  * Main WC_Jetpack Class
22
  *
23
  * @class WC_Jetpack
24
- * @version 2.3.9
25
  */
26
 
27
  final class WC_Jetpack {
@@ -63,7 +63,7 @@ final class WC_Jetpack {
63
  /**
64
  * WC_Jetpack Constructor.
65
  *
66
- * @version 2.2.5
67
  * @access public
68
  */
69
  public function __construct() {
@@ -97,7 +97,7 @@ final class WC_Jetpack {
97
  'yes' === get_option( 'wcj_pdf_invoicing_enabled' ) ||
98
  'yes' === get_option( 'wcj_crowdfunding_enabled' )
99
  ) {
100
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
101
  //add_action( 'admin_head', array( $this, 'add_datepicker_script' ) );
102
  }
103
  }
@@ -107,7 +107,6 @@ final class WC_Jetpack {
107
  'yes' === get_option( 'wcj_checkout_custom_fields_enabled' )
108
  ){
109
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_scripts' ) );
110
- add_action( 'init', array( $this, 'register_frontend_scripts' ) );
111
  }
112
 
113
  // Loaded action
@@ -120,39 +119,92 @@ final class WC_Jetpack {
120
  /**
121
  * enqueue_frontend_scripts.
122
  *
123
- * @version 2.3.3
124
  * @since 2.3.0
125
  */
126
  function enqueue_frontend_scripts() {
127
- wp_enqueue_script( 'jquery-ui-datepicker' );
128
- wp_enqueue_script( 'jquery-ui-timepicker' );
129
- wp_enqueue_script( 'wcj-datepicker', wcj_plugin_url() . '/includes/js/wcj-datepicker.js',
130
- array( 'jquery' ),
131
- false,
132
- true );
133
- wp_enqueue_script( 'wcj-timepicker', wcj_plugin_url() . '/includes/js/wcj-timepicker.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-css', wcj_plugin_url() . '/includes/css/jquery.timepicker.min.css' );
140
  }
141
 
142
  /**
143
- * register_frontend_scripts.
144
  *
145
- * @version 2.3.0
146
- * @since 2.3.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  */
148
- public function register_frontend_scripts() {
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
  /**
@@ -193,17 +245,6 @@ final class WC_Jetpack {
193
  }
194
  }
195
 
196
- /**
197
- * enqueue_scripts.
198
- *
199
- * @version 2.2.5
200
- */
201
- public function enqueue_scripts() {
202
- wp_enqueue_script( 'jquery-ui-datepicker' );
203
- wp_enqueue_script( 'wcj-datepicker', $this->plugin_url() . '/includes/js/wcj-datepicker.js' );
204
- wp_enqueue_style( 'jquery-ui-css', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
205
- }
206
-
207
  /**
208
  * admin_footer_text
209
  *
@@ -317,7 +358,6 @@ final class WC_Jetpack {
317
  * include_functions.
318
  */
319
  private function include_functions() {
320
- // Functions
321
  include_once( 'includes/functions/wcj-debug-functions.php' );
322
  include_once( 'includes/functions/wcj-functions.php' );
323
  include_once( 'includes/functions/wcj-html-functions.php' );
@@ -327,21 +367,25 @@ final class WC_Jetpack {
327
 
328
  /**
329
  * include_shortcodes.
 
 
330
  */
331
  private function include_shortcodes() {
332
- // Shortcodes
333
- include_once( 'includes/shortcodes/class-wcj-shortcodes.php' );
334
- include_once( 'includes/shortcodes/class-wcj-general-shortcodes.php' );
335
- include_once( 'includes/shortcodes/class-wcj-invoices-shortcodes.php' );
336
- include_once( 'includes/shortcodes/class-wcj-orders-shortcodes.php' );
337
- include_once( 'includes/shortcodes/class-wcj-order-items-shortcodes.php' );
338
- include_once( 'includes/shortcodes/class-wcj-products-shortcodes.php' );
 
 
339
  }
340
 
341
  /**
342
  * Include modules and submodules
343
  *
344
- * @version 2.3.9
345
  */
346
  private function include_modules() {
347
  $settings = array();
@@ -351,6 +395,7 @@ final class WC_Jetpack {
351
 
352
  $settings[] = include_once( 'includes/class-wcj-product-listings.php' );
353
  $settings[] = include_once( 'includes/class-wcj-sorting.php' );
 
354
  $settings[] = include_once( 'includes/class-wcj-product-info.php' );
355
  $settings[] = include_once( 'includes/class-wcj-product-add-to-cart.php' );
356
  $settings[] = include_once( 'includes/class-wcj-related-products.php' );
@@ -387,7 +432,7 @@ final class WC_Jetpack {
387
  $settings[] = include_once( 'includes/class-wcj-order-numbers.php' );
388
  $settings[] = include_once( 'includes/class-wcj-order-custom-statuses.php' );
389
 
390
- $settings[] = include_once( 'includes/class-wcj-pdf-invoices.php' );
391
 
392
  $settings[] = include_once( 'includes/class-wcj-pdf-invoicing.php' );
393
  $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-numbering.php' );
@@ -398,7 +443,7 @@ final class WC_Jetpack {
398
  $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-page.php' );
399
  $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-emails.php' );
400
  $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-display.php' );
401
- //$settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-general.php' );
402
 
403
  $settings[] = include_once( 'includes/class-wcj-emails.php' );
404
 
@@ -408,6 +453,7 @@ final class WC_Jetpack {
408
  $settings[] = include_once( 'includes/class-wcj-currency-exchange-rates.php' );
409
 
410
  $settings[] = include_once( 'includes/class-wcj-general.php' );
 
411
  $settings[] = include_once( 'includes/class-wcj-eu-vat-number.php' );
412
  $settings[] = include_once( 'includes/class-wcj-old-slugs.php' );
413
  $settings[] = include_once( 'includes/class-wcj-reports.php' );
3
  Plugin Name: Booster for WooCommerce
4
  Plugin URI: http://booster.io
5
  Description: Supercharge your WooCommerce site with these awesome powerful features.
6
+ Version: 2.4.0
7
  Author: Algoritmika Ltd
8
  Author URI: http://www.algoritmika.com
9
  Copyright: © 2015 Algoritmika Ltd.
21
  * Main WC_Jetpack Class
22
  *
23
  * @class WC_Jetpack
24
+ * @version 2.4.0
25
  */
26
 
27
  final class WC_Jetpack {
63
  /**
64
  * WC_Jetpack Constructor.
65
  *
66
+ * @version 2.4.0
67
  * @access public
68
  */
69
  public function __construct() {
97
  'yes' === get_option( 'wcj_pdf_invoicing_enabled' ) ||
98
  'yes' === get_option( 'wcj_crowdfunding_enabled' )
99
  ) {
100
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_backend_scripts' ) );
101
  //add_action( 'admin_head', array( $this, 'add_datepicker_script' ) );
102
  }
103
  }
107
  'yes' === get_option( 'wcj_checkout_custom_fields_enabled' )
108
  ){
109
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_scripts' ) );
 
110
  }
111
 
112
  // Loaded action
119
  /**
120
  * enqueue_frontend_scripts.
121
  *
122
+ * @version 2.4.0
123
  * @since 2.3.0
124
  */
125
  function enqueue_frontend_scripts() {
126
+ $this->maybe_enqueue_datepicker_scripts();
127
+ $this->maybe_enqueue_timepicker_scripts();
128
+ $this->maybe_enqueue_datepicker_style();
129
+ $this->maybe_enqueue_timepicker_style();
 
 
 
 
 
 
 
 
 
130
  }
131
 
132
  /**
133
+ * enqueue_backend_scripts.
134
  *
135
+ * @version 2.4.0
136
+ */
137
+ public function enqueue_backend_scripts() {
138
+ $this->maybe_enqueue_datepicker_scripts();
139
+ $this->maybe_enqueue_datepicker_style();
140
+ }
141
+
142
+ /**
143
+ * maybe_enqueue_datepicker_scripts.
144
+ *
145
+ * @version 2.4.0
146
+ * @since 2.4.0
147
+ */
148
+ function maybe_enqueue_datepicker_scripts() {
149
+ if ( ! wcj_is_module_enabled( 'general' ) || ( wcj_is_module_enabled( 'general' ) && 'no' === get_option( 'wcj_general_advanced_disable_datepicker_js', 'no' ) ) ) {
150
+ wp_enqueue_script( 'jquery-ui-datepicker' );
151
+ wp_enqueue_script( 'wcj-datepicker', wcj_plugin_url() . '/includes/js/wcj-datepicker.js',
152
+ array( 'jquery' ),
153
+ false,
154
+ true );
155
+ wp_enqueue_script( 'wcj-weekpicker', wcj_plugin_url() . '/includes/js/wcj-weekpicker.js',
156
+ array( 'jquery' ),
157
+ false,
158
+ true );
159
+ }
160
+ }
161
+
162
+ /**
163
+ * maybe_enqueue_timepicker_scripts.
164
+ *
165
+ * @version 2.4.0
166
+ * @since 2.4.0
167
  */
168
+ function maybe_enqueue_timepicker_scripts() {
169
+ if ( ! wcj_is_module_enabled( 'general' ) || ( wcj_is_module_enabled( 'general' ) && 'no' === get_option( 'wcj_general_advanced_disable_timepicker_js', 'no' ) ) ) {
170
+ wp_enqueue_script( 'jquery-ui-timepicker',
171
+ wcj_plugin_url() . '/includes/js/jquery.timepicker.min.js',
172
+ array( 'jquery' ),
173
+ false,
174
+ true );
175
+ wp_enqueue_script( 'wcj-timepicker', wcj_plugin_url() . '/includes/js/wcj-timepicker.js',
176
+ array( 'jquery' ),
177
+ false,
178
+ true );
179
+ }
180
+ }
181
+
182
+ /**
183
+ * maybe_enqueue_datepicker_style.
184
+ *
185
+ * @version 2.4.0
186
+ * @since 2.4.0
187
+ */
188
+ function maybe_enqueue_datepicker_style() {
189
+ if ( ! wcj_is_module_enabled( 'general' ) || ( wcj_is_module_enabled( 'general' ) && 'no' === get_option( 'wcj_general_advanced_disable_datepicker_css', 'no' ) ) ) {
190
+ $datepicker_css_path = '//ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/themes/base/jquery-ui.css';
191
+ if ( wcj_is_module_enabled( 'general' ) ) {
192
+ $datepicker_css_path = get_option( 'wcj_general_advanced_datepicker_css', $datepicker_css_path );
193
+ }
194
+ wp_enqueue_style( 'jquery-ui-css', $datepicker_css_path );
195
+ }
196
+ }
197
+
198
+ /**
199
+ * maybe_enqueue_timepicker_style.
200
+ *
201
+ * @version 2.4.0
202
+ * @since 2.4.0
203
+ */
204
+ function maybe_enqueue_timepicker_style() {
205
+ if ( ! wcj_is_module_enabled( 'general' ) || ( wcj_is_module_enabled( 'general' ) && 'no' === get_option( 'wcj_general_advanced_disable_timepicker_css', 'no' ) ) ) {
206
+ wp_enqueue_style( 'wcj-timepicker-css', wcj_plugin_url() . '/includes/css/jquery.timepicker.min.css' );
207
+ }
208
  }
209
 
210
  /**
245
  }
246
  }
247
 
 
 
 
 
 
 
 
 
 
 
 
248
  /**
249
  * admin_footer_text
250
  *
358
  * include_functions.
359
  */
360
  private function include_functions() {
 
361
  include_once( 'includes/functions/wcj-debug-functions.php' );
362
  include_once( 'includes/functions/wcj-functions.php' );
363
  include_once( 'includes/functions/wcj-html-functions.php' );
367
 
368
  /**
369
  * include_shortcodes.
370
+ *
371
+ * @version 2.4.0
372
  */
373
  private function include_shortcodes() {
374
+ //if ( 'yes' === get_option( 'wcj_shortcodes_enabled', 'no' ) ) {
375
+ if ( ! wcj_is_module_enabled( 'general' ) || ( wcj_is_module_enabled( 'general' ) && 'no' === get_option( 'wcj_general_shortcodes_disable_booster_shortcodes', 'no' ) ) ) {
376
+ include_once( 'includes/shortcodes/class-wcj-shortcodes.php' );
377
+ include_once( 'includes/shortcodes/class-wcj-general-shortcodes.php' );
378
+ include_once( 'includes/shortcodes/class-wcj-invoices-shortcodes.php' );
379
+ include_once( 'includes/shortcodes/class-wcj-orders-shortcodes.php' );
380
+ include_once( 'includes/shortcodes/class-wcj-order-items-shortcodes.php' );
381
+ include_once( 'includes/shortcodes/class-wcj-products-shortcodes.php' );
382
+ }
383
  }
384
 
385
  /**
386
  * Include modules and submodules
387
  *
388
+ * @version 2.4.0
389
  */
390
  private function include_modules() {
391
  $settings = array();
395
 
396
  $settings[] = include_once( 'includes/class-wcj-product-listings.php' );
397
  $settings[] = include_once( 'includes/class-wcj-sorting.php' );
398
+ $settings[] = include_once( 'includes/class-wcj-product-custom-info.php' );
399
  $settings[] = include_once( 'includes/class-wcj-product-info.php' );
400
  $settings[] = include_once( 'includes/class-wcj-product-add-to-cart.php' );
401
  $settings[] = include_once( 'includes/class-wcj-related-products.php' );
432
  $settings[] = include_once( 'includes/class-wcj-order-numbers.php' );
433
  $settings[] = include_once( 'includes/class-wcj-order-custom-statuses.php' );
434
 
435
+ // $settings[] = include_once( 'includes/class-wcj-pdf-invoices.php' );
436
 
437
  $settings[] = include_once( 'includes/class-wcj-pdf-invoicing.php' );
438
  $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-numbering.php' );
443
  $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-page.php' );
444
  $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-emails.php' );
445
  $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-display.php' );
446
+ // $settings[] = include_once( 'includes/pdf-invoices/settings/class-wcj-pdf-invoicing-general.php' );
447
 
448
  $settings[] = include_once( 'includes/class-wcj-emails.php' );
449
 
453
  $settings[] = include_once( 'includes/class-wcj-currency-exchange-rates.php' );
454
 
455
  $settings[] = include_once( 'includes/class-wcj-general.php' );
456
+ // $settings[] = include_once( 'includes/class-wcj-shortcodes-module.php' );
457
  $settings[] = include_once( 'includes/class-wcj-eu-vat-number.php' );
458
  $settings[] = include_once( 'includes/class-wcj-old-slugs.php' );
459
  $settings[] = include_once( 'includes/class-wcj-reports.php' );