Booster for WooCommerce - Version 1.1.0

Version Description

  • 24/07/2014 =
  • Dev - Orders Numbers feature moved to Orders feature.
  • Dev - PDF Invoices - Icons instead of text at orders list.
  • Fix - Currencies - Wrong readonly attribute for text field on WooCommerce > Settings > General, affecting Plus version, fixed.
  • Feature - Orders - Set minimum order amount.
  • Feature - Checkout - Customize checkout fields: disable/enable fields, set required, change labels and/or placeholders.
  • Feature - Shipping - Hide shipping when free is available.
  • Feature - Emails - Add another email recipient(s) to all WooCommerce emails.
  • Feature - Product Info - Customize single product tabs. Change related products number.
  • Feature - Cart - Add "Empty Cart" button to cart page, redirect add to cart button to any url (e.g. checkout page), automatically add product to cart on visit.
  • Feature Upgraded - Add to Cart - Display "Product already in cart" instead of "Add to cart" button.
Download this release

Release Info

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

Code changes from version 1.0.6 to 1.1.0

includes/admin/settings/class-wc-settings-jetpack.php CHANGED
@@ -75,7 +75,7 @@ class WC_Settings_Jetpack extends WC_Settings_Page {
75
  }
76
  else {
77
 
78
- $settings[] = array( 'title' => __( 'Features', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => $desc, 'id' => 'wcj_options' );
79
 
80
  $settings = apply_filters( 'wcj_features_status', $settings );
81
 
@@ -90,8 +90,41 @@ class WC_Settings_Jetpack extends WC_Settings_Page {
90
  $settings[] = $section->get_statuses()[1];*/
91
 
92
  $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_options' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
 
94
- return $settings;//apply_filters('wcj_general_settings', $settings );
95
  }
96
  }
97
  }
75
  }
76
  else {
77
 
78
+ $settings[] = array( 'title' => __( 'WooCommerce Jetpack Dashboard', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => 'This dashboard lets you enable/disable any Jetpack feature. Each checkbox comes with short feature\'s description. Please visit <a href="http://woojetpack.com" target="_blank">WooJetpack.com</a> for detailed info on each feature.', 'id' => 'wcj_options' );
79
 
80
  $settings = apply_filters( 'wcj_features_status', $settings );
81
 
90
  $settings[] = $section->get_statuses()[1];*/
91
 
92
  $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_options' );
93
+
94
+ $updated_settings = array();
95
+ $i = 0;
96
+ $s = count( $settings );
97
+ foreach ( $settings as $single_item ) {
98
+
99
+ if ( ( 'checkbox' == $single_item['type'] ) && ( $i > 0 ) ) {
100
+
101
+ if ( 1 == $i ) {
102
+ $single_item['checkboxgroup'] = 'start';
103
+ $single_item['title'] = 'The Features';
104
+ }
105
+ else {
106
+ if ( ( $s - 2 ) == $i )
107
+ $single_item['checkboxgroup'] = 'end';
108
+ else
109
+ $single_item['checkboxgroup'] = '';
110
+
111
+ $single_item['title'] = '';
112
+ }
113
+
114
+ // Temporary solution - 2014.07.21
115
+ $single_item['desc'] = str_replace( 'Enable the ', 'Enable the <strong>', $single_item['desc'] );
116
+ $single_item['desc'] = str_replace( ' feature', '</strong> feature', $single_item['desc'] );
117
+
118
+ $single_item['desc'] .= ': <em>' . $single_item['desc_tip'] . '</em>';
119
+ $single_item['desc_tip'] = '';
120
+ }
121
+
122
+ $updated_settings[] = $single_item;
123
+
124
+ $i++;
125
+ }
126
 
127
+ return $updated_settings;//apply_filters('wcj_general_settings', $settings );
128
  }
129
  }
130
  }
includes/class-wcj-add-to-cart.php CHANGED
@@ -25,6 +25,8 @@ class WCJ_Add_to_cart {
25
  add_filter( 'woocommerce_product_single_add_to_cart_text', array( $this, 'custom_add_to_cart_button_text' ), 100 );
26
  add_filter( 'woocommerce_product_add_to_cart_text', array( $this, 'custom_add_to_cart_button_text' ), 100 );
27
 
 
 
28
  }
29
 
30
  // Settings hooks
@@ -43,34 +45,58 @@ class WCJ_Add_to_cart {
43
 
44
  return $settings;
45
  }
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
  /**
48
  * custom_add_to_cart_button_text.
49
  */
50
  public function custom_add_to_cart_button_text( $add_to_cart_text) {
51
 
52
- global $product;
53
 
54
  $product_type = $product->product_type;
55
 
56
  if ( ! in_array( $product_type, array( 'external', 'grouped', 'simple', 'variable' ) ) )
57
  $product_type = 'other';
58
-
59
- if ( current_filter() == 'woocommerce_product_single_add_to_cart_text' ) {
60
 
61
- if ( get_option( 'wcj_add_to_cart_text_enabled_on_single_' . $product_type ) == 'yes' ) return get_option( 'wcj_add_to_cart_text_on_single_' . $product_type );
62
- else return $add_to_cart_text;
63
- }
64
- else if ( current_filter() == 'woocommerce_product_add_to_cart_text' ) {
65
 
66
- if ( get_option( 'wcj_add_to_cart_text_enabled_on_archives_' . $product_type ) == 'yes' ) return get_option( 'wcj_add_to_cart_text_on_archives_' . $product_type );
67
- else return $add_to_cart_text;
68
- }
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  // Default
71
  return $add_to_cart_text;
72
  }
73
-
74
  /**
75
  * get_settings.
76
  */
@@ -83,16 +109,40 @@ class WCJ_Add_to_cart {
83
  array(
84
  'title' => __( 'Add to Cart', 'woocommerce-jetpack' ),
85
  'desc' => __( 'Enable the Add to Cart feature', 'woocommerce-jetpack' ),
86
- 'desc_tip' => __( 'Change text for Add to cart button by product type.', 'woocommerce-jetpack' ),
87
  'id' => 'wcj_add_to_cart_enabled',
88
  'default' => 'yes',
89
  'type' => 'checkbox',
90
  ),
91
 
92
- //array( 'type' => 'sectionend', 'id' => 'wcj_add_to_cart_options' ),
93
  );
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  //ADD TO CART TEXT
 
 
96
  $groups_by_product_type = array(
97
 
98
  array(
@@ -164,13 +214,51 @@ class WCJ_Add_to_cart {
164
  'type' => 'checkbox',
165
  //'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
166
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  }
168
 
169
- //$settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_add_to_cart_options' );
170
- $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_add_to_cart_options' );
171
-
172
-
173
-
174
 
175
  return $settings;
176
  }
@@ -180,7 +268,7 @@ class WCJ_Add_to_cart {
180
  */
181
  function settings_section( $sections ) {
182
 
183
- $sections['add_to_cart'] = 'Add to Cart';
184
 
185
  return $sections;
186
  }
25
  add_filter( 'woocommerce_product_single_add_to_cart_text', array( $this, 'custom_add_to_cart_button_text' ), 100 );
26
  add_filter( 'woocommerce_product_add_to_cart_text', array( $this, 'custom_add_to_cart_button_text' ), 100 );
27
 
28
+ if ( get_option( 'wcj_add_to_cart_redirect_enabled' ) == 'yes' )
29
+ add_action( 'add_to_cart_redirect', array( $this, 'redirect_to_url' ), 100 );
30
  }
31
 
32
  // Settings hooks
45
 
46
  return $settings;
47
  }
48
+
49
+ /*
50
+ * redirect_to_url.
51
+ */
52
+ function redirect_to_url() {
53
+
54
+ global $woocommerce;
55
+ $checkout_url = get_option( 'wcj_add_to_cart_redirect_url' );
56
+ if ( $checkout_url === '' )
57
+ $checkout_url = $woocommerce->cart->get_checkout_url();
58
+ return $checkout_url;
59
+ }
60
 
61
  /**
62
  * custom_add_to_cart_button_text.
63
  */
64
  public function custom_add_to_cart_button_text( $add_to_cart_text) {
65
 
66
+ global $woocommerce,$product;
67
 
68
  $product_type = $product->product_type;
69
 
70
  if ( ! in_array( $product_type, array( 'external', 'grouped', 'simple', 'variable' ) ) )
71
  $product_type = 'other';
 
 
72
 
73
+ $single_or_archive = '';
74
+ if ( current_filter() == 'woocommerce_product_single_add_to_cart_text' ) $single_or_archive = 'single';
75
+ else if ( current_filter() == 'woocommerce_product_add_to_cart_text' ) $single_or_archive = 'archives';
 
76
 
77
+ if ( $single_or_archive !== '' ) {
 
 
78
 
79
+ if ( get_option( 'wcj_add_to_cart_text_enabled_on_' . $single_or_archive . '_in_cart_' . $product_type ) == 'yes' ) {
80
+
81
+ foreach( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
82
+
83
+ $_product = $values['data'];
84
+
85
+ if( get_the_ID() == $_product->id ) {
86
+
87
+ return get_option( 'wcj_add_to_cart_text_on_' . $single_or_archive . '_in_cart_' . $product_type );
88
+ }
89
+ }
90
+ }
91
+
92
+ if ( get_option( 'wcj_add_to_cart_text_enabled_on_' . $single_or_archive . '_' . $product_type ) == 'yes' ) return get_option( 'wcj_add_to_cart_text_on_' . $single_or_archive . '_' . $product_type );
93
+ else return $add_to_cart_text;
94
+ }
95
+
96
  // Default
97
  return $add_to_cart_text;
98
  }
99
+
100
  /**
101
  * get_settings.
102
  */
109
  array(
110
  'title' => __( 'Add to Cart', 'woocommerce-jetpack' ),
111
  'desc' => __( 'Enable the Add to Cart feature', 'woocommerce-jetpack' ),
112
+ 'desc_tip' => __( 'Set any url to redirect to on add to cart. Change text for Add to cart button by product type. Display "Already in cart" instead of "Add to cart" button if current product is already in cart.', 'woocommerce-jetpack' ),
113
  'id' => 'wcj_add_to_cart_enabled',
114
  'default' => 'yes',
115
  'type' => 'checkbox',
116
  ),
117
 
118
+ array( 'type' => 'sectionend', 'id' => 'wcj_add_to_cart_options' ),
119
  );
120
 
121
+ //ADD TO CART REDIRECT
122
+ $settings[] = array( 'title' => __( 'Add to Cart Redirect Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you set any url to redirect to after successfully adding product to cart. Leave empty to redirect to checkout page.', 'woocommerce-jetpack' ), 'id' => 'wcj_add_to_cart_redirect_options' );
123
+
124
+ $settings[] = array(
125
+ 'title' => __( 'Redirect', 'woocommerce-jetpack' ),
126
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
127
+ 'id' => 'wcj_add_to_cart_redirect_enabled',
128
+ 'default' => 'no',
129
+ 'type' => 'checkbox',
130
+ );
131
+
132
+ $settings[] = array(
133
+ 'title' => __( 'Redirect URL', 'woocommerce-jetpack' ),
134
+ 'desc_tip' => __( 'Redirect URL. Leave empty to redirect to checkout.', 'woocommerce-jetpack' ),
135
+ 'id' => 'wcj_add_to_cart_redirect_url',
136
+ 'default' => '',
137
+ 'type' => 'text',
138
+ 'css' => 'width:50%;min-width:300px;',
139
+ );
140
+
141
+ $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_add_to_cart_redirect_options' );
142
+
143
  //ADD TO CART TEXT
144
+ $settings[] = array( 'title' => __( 'Add to Cart Button Text Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => 'This sections lets you set text for add to cart button for various products types and various conditions.', 'id' => 'wcj_add_to_cart_text_options' );
145
+
146
  $groups_by_product_type = array(
147
 
148
  array(
214
  'type' => 'checkbox',
215
  //'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
216
  );
217
+
218
+ if ( $group_by_product_type['id'] === 'external' ) continue;
219
+
220
+ $settings[] =
221
+ array(
222
+ 'title' => '',//$group_by_product_type['title'],
223
+ 'id' => 'wcj_add_to_cart_text_on_single_in_cart_' . $group_by_product_type['id'],
224
+ 'default' => 'Already in cart - Add Again?',
225
+ 'type' => 'text',
226
+ 'css' => 'width:30%;min-width:300px;',
227
+ //'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
228
+ //'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
229
+ //'desc' => __( 'Set text for "Already in cart" on single product pages', 'woocommerce-jetpack' ),
230
+ );
231
+
232
+ $settings[] =
233
+ array(
234
+ 'title' => '',//$group_by_product_type['title'],
235
+ 'desc' => __( 'Enable "Already in cart" on single product pages', 'woocommerce-jetpack' ),
236
+ 'id' => 'wcj_add_to_cart_text_enabled_on_single_in_cart_' . $group_by_product_type['id'],
237
+ 'default' => 'yes',
238
+ 'type' => 'checkbox',
239
+ );
240
+
241
+ $settings[] =
242
+ array(
243
+ 'title' => '',//$group_by_product_type['title'],
244
+ 'id' => 'wcj_add_to_cart_text_on_archives_in_cart_' . $group_by_product_type['id'],
245
+ 'default' => 'Already in cart - Add Again?',
246
+ 'type' => 'text',
247
+ 'css' => 'width:30%;min-width:300px;',
248
+ //'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
249
+ );
250
+
251
+ $settings[] =
252
+ array(
253
+ 'title' => '',//$group_by_product_type['title'],
254
+ 'desc' => __( 'Enable "Already in cart" on product archives', 'woocommerce-jetpack' ),
255
+ 'id' => 'wcj_add_to_cart_text_enabled_on_archives_in_cart_' . $group_by_product_type['id'],
256
+ 'default' => 'yes',
257
+ 'type' => 'checkbox',
258
+ );
259
  }
260
 
261
+ $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_add_to_cart_text_options' );
 
 
 
 
262
 
263
  return $settings;
264
  }
268
  */
269
  function settings_section( $sections ) {
270
 
271
+ $sections['add_to_cart'] = __( 'Add to Cart', 'woocommerce-jetpack' );
272
 
273
  return $sections;
274
  }
includes/class-wcj-call-for-price.php CHANGED
@@ -104,27 +104,31 @@ class WCJ_Call_For_Price {
104
  ),
105
 
106
  array(
107
- 'title' => __( 'Show on Single Product', 'woocommerce-jetpack' ),
 
108
  'desc' => __( 'Check to show on single products page', 'woocommerce-jetpack' ),
109
  'id' => 'wcj_call_for_price_show_on_single',
110
  'default' => 'yes',
111
  'type' => 'checkbox',
 
112
  ),
113
 
114
  array(
115
- 'title' => __( 'Show on Products Archive', 'woocommerce-jetpack' ),
116
  'desc' => __( 'Check to show on products archive page', 'woocommerce-jetpack' ),
117
  'id' => 'wcj_call_for_price_show_on_archive',
118
  'default' => 'yes',
119
  'type' => 'checkbox',
 
120
  ),
121
 
122
  array(
123
- 'title' => __( 'Show on Home Page', 'woocommerce-jetpack' ),
124
  'desc' => __( 'Check to show on home page', 'woocommerce-jetpack' ),
125
  'id' => 'wcj_call_for_price_show_on_home',
126
  'default' => 'yes',
127
  'type' => 'checkbox',
 
128
  ),
129
 
130
  array(
104
  ),
105
 
106
  array(
107
+ 'title' => __( 'Visibility', 'woocommerce-jetpack' ),
108
+ //'title' => __( 'Show on Single Product', 'woocommerce-jetpack' ),
109
  'desc' => __( 'Check to show on single products page', 'woocommerce-jetpack' ),
110
  'id' => 'wcj_call_for_price_show_on_single',
111
  'default' => 'yes',
112
  'type' => 'checkbox',
113
+ 'checkboxgroup' => 'start',
114
  ),
115
 
116
  array(
117
+ //'title' => __( 'Show on Products Archive', 'woocommerce-jetpack' ),
118
  'desc' => __( 'Check to show on products archive page', 'woocommerce-jetpack' ),
119
  'id' => 'wcj_call_for_price_show_on_archive',
120
  'default' => 'yes',
121
  'type' => 'checkbox',
122
+ 'checkboxgroup' => '',
123
  ),
124
 
125
  array(
126
+ //'title' => __( 'Show on Home Page', 'woocommerce-jetpack' ),
127
  'desc' => __( 'Check to show on home page', 'woocommerce-jetpack' ),
128
  'id' => 'wcj_call_for_price_show_on_home',
129
  'default' => 'yes',
130
  'type' => 'checkbox',
131
+ 'checkboxgroup' => 'end',
132
  ),
133
 
134
  array(
includes/class-wcj-cart.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Jetpack Cart
4
+ *
5
+ * The WooCommerce Jetpack Cart class.
6
+ *
7
+ * @class WCJ_Cart
8
+ */
9
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
10
+
11
+ if ( ! class_exists( 'WCJ_Cart' ) ) :
12
+
13
+ class WCJ_Cart {
14
+
15
+ /**
16
+ * Constructor.
17
+ */
18
+ public function __construct() {
19
+
20
+ // Main hooks
21
+ if ( get_option( 'wcj_cart_enabled' ) == 'yes' ) {
22
+
23
+ if ( get_option( 'wcj_empty_cart_enabled' ) == 'yes' ) {
24
+
25
+ add_action( 'init', array( $this, 'empty_cart' ) );
26
+ add_action( 'woocommerce_after_cart', array( $this, 'add_empty_cart_link' ) );
27
+ //add_filter( 'wcj_empty_cart_button_filter', array( $this, 'empty_cart_button_filter_function' ), 100, 2 );
28
+ }
29
+
30
+ if ( get_option( 'wcj_add_to_cart_on_visit_enabled' ) == 'yes' )
31
+ add_action( 'woocommerce_before_single_product', array( $this, 'add_to_cart_on_visit' ), 100 );
32
+ }
33
+
34
+ // Settings hooks
35
+ add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
36
+ add_filter( 'wcj_settings_cart', array( $this, 'get_settings' ), 100 );
37
+ add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
38
+ }
39
+
40
+ /*
41
+ * empty_cart_button_filter_function.
42
+ *
43
+ public function empty_cart_button_filter_function ( $value, $type ) {
44
+
45
+ if ( 'text' == $type ) return 'Empty Cart';
46
+ if ( 'div-style' == $type ) return 'float: right';
47
+ }
48
+
49
+ /*
50
+ * Add item to cart on visit.
51
+ */
52
+ public function add_to_cart_on_visit() {
53
+
54
+ if ( is_product() ) {
55
+
56
+ global $woocommerce;
57
+ $product_id = get_the_ID();
58
+ $found = false;
59
+ //check if product already in cart
60
+ if ( sizeof( $woocommerce->cart->get_cart() ) > 0 ) {
61
+ foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
62
+ $_product = $values['data'];
63
+ if ( $_product->id == $product_id )
64
+ $found = true;
65
+ }
66
+ // if product not found, add it
67
+ if ( ! $found )
68
+ $woocommerce->cart->add_to_cart( $product_id );
69
+ } else {
70
+ // if no products in cart, add it
71
+ $woocommerce->cart->add_to_cart( $product_id );
72
+ }
73
+ }
74
+ }
75
+
76
+ /**
77
+ * add_empty_cart_link.
78
+ */
79
+ public function add_empty_cart_link() {
80
+
81
+ echo '<div style="' . apply_filters( 'wcjpc_filter', 'float: right;', get_option( 'wcj_empty_cart_div_style' ) ) . '"><form action="" method="post"><input type="submit" class="button" name="empty_cart" value="' . apply_filters( 'wcjpc_filter', 'Empty Cart', get_option( 'wcj_empty_cart_text' ) ) . '"></form></div>';
82
+ }
83
+
84
+ /**
85
+ * empty_cart.
86
+ */
87
+ public function empty_cart() {
88
+
89
+ if ( isset( $_POST['empty_cart'] ) ) {
90
+
91
+ global $woocommerce;
92
+ $woocommerce->cart->empty_cart();
93
+ }
94
+ }
95
+
96
+ /**
97
+ * add_enabled_option.
98
+ */
99
+ public function add_enabled_option( $settings ) {
100
+
101
+ $all_settings = $this->get_settings();
102
+ $settings[] = $all_settings[1];
103
+
104
+ return $settings;
105
+ }
106
+
107
+ /**
108
+ * get_settings.
109
+ */
110
+ function get_settings() {
111
+
112
+ $settings = array(
113
+
114
+ array( 'title' => __( 'Cart Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_cart_options' ),
115
+
116
+ array(
117
+ 'title' => __( 'Cart', 'woocommerce-jetpack' ),
118
+ 'desc' => __( 'Enable the Cart feature', 'woocommerce-jetpack' ),
119
+ 'desc_tip' => __( 'Add empty cart button, change add to cart redirect, automatically add to cart on product visit.', 'woocommerce-jetpack' ),
120
+ 'id' => 'wcj_cart_enabled',
121
+ 'default' => 'yes',
122
+ 'type' => 'checkbox',
123
+ ),
124
+
125
+ array( 'type' => 'sectionend', 'id' => 'wcj_cart_options' ),
126
+
127
+ array( 'title' => __( 'Empty Cart Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you add and customize "Empty Cart" button to cart page.', 'woocommerce-jetpack' ), 'id' => 'wcj_empty_cart_options' ),
128
+
129
+ array(
130
+ 'title' => __( 'Empty Cart', 'woocommerce-jetpack' ),
131
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
132
+ 'id' => 'wcj_empty_cart_enabled',
133
+ 'default' => 'yes',
134
+ 'type' => 'checkbox',
135
+ ),
136
+
137
+ array(
138
+ 'title' => __( 'Empty Cart Button Text', 'woocommerce-jetpack' ),
139
+ 'id' => 'wcj_empty_cart_text',
140
+ 'default' => 'Empty Cart',
141
+ 'type' => 'text',
142
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
143
+ 'custom_attributes'
144
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
145
+ ),
146
+
147
+ array(
148
+ 'title' => __( 'Wrapping DIV style', 'woocommerce-jetpack' ),
149
+ 'desc_tip' => __( 'Style for the button\'s div. Default is "float: right;"', 'woocommerce-jetpack' ),
150
+ 'id' => 'wcj_empty_cart_div_style',
151
+ 'default' => 'float: right;',
152
+ 'type' => 'text',
153
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
154
+ 'custom_attributes'
155
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
156
+ ),
157
+
158
+ array( 'type' => 'sectionend', 'id' => 'wcj_empty_cart_options' ),
159
+
160
+ array( 'title' => __( 'Add to Cart on Visit', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you enable automatically adding product to cart on visiting the product page. Product is only added once, so if it is already in cart - duplicate product is not added. ', 'woocommerce-jetpack' ), 'id' => 'wcj_add_to_cart_on_visit_options' ),
161
+
162
+ array(
163
+ 'title' => __( 'Add to Cart on Visit', 'woocommerce-jetpack' ),
164
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
165
+ 'id' => 'wcj_add_to_cart_on_visit_enabled',
166
+ 'default' => 'no',
167
+ 'type' => 'checkbox',
168
+ ),
169
+
170
+ array( 'type' => 'sectionend', 'id' => 'wcj_add_to_cart_on_visit_options' ),
171
+
172
+ );
173
+
174
+ return $settings;
175
+ }
176
+
177
+ /**
178
+ * settings_section.
179
+ */
180
+ function settings_section( $sections ) {
181
+
182
+ $sections['cart'] = __( 'Cart', 'woocommerce-jetpack' );
183
+
184
+ return $sections;
185
+ }
186
+ }
187
+
188
+ endif;
189
+
190
+ return new WCJ_Cart();
includes/class-wcj-checkout.php ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Jetpack Checkout
4
+ *
5
+ * The WooCommerce Jetpack Checkout class.
6
+ *
7
+ * @class WCJ_Checkout
8
+ */
9
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
10
+
11
+ if ( ! class_exists( 'WCJ_Checkout' ) ) :
12
+
13
+ class WCJ_Checkout {
14
+
15
+ /**
16
+ * @var array $sub_items
17
+ */
18
+ public $sub_items = array(
19
+ 'enabled' => 'checkbox',
20
+ ////'type',
21
+ 'required' => 'checkbox',
22
+ 'label' => 'text',
23
+ 'placeholder' => 'text',
24
+ //'clear',
25
+ );
26
+
27
+ /**
28
+ * @var array $items
29
+ */
30
+ public $items = array(
31
+ 'billing_country' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'yes' ),
32
+ 'billing_first_name' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'yes' ),
33
+ 'billing_last_name' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'yes' ),
34
+ 'billing_company' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'no' ),
35
+ 'billing_address_1' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'yes' ),
36
+ 'billing_address_2' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'no' ),
37
+ 'billing_city' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'yes' ),
38
+ 'billing_state' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'yes' ),
39
+ 'billing_postcode' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'yes' ),
40
+ 'billing_email' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'yes' ),
41
+ 'billing_phone' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'yes' ),
42
+ 'shipping_country' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'yes' ),
43
+ 'shipping_first_name' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'yes' ),
44
+ 'shipping_last_name' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'yes' ),
45
+ 'shipping_company' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'no' ),
46
+ 'shipping_address_1' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'yes' ),
47
+ 'shipping_address_2' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'no' ),
48
+ 'shipping_city' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'yes' ),
49
+ 'shipping_state' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'yes' ),
50
+ 'shipping_postcode' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'yes' ),
51
+ 'account_password' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'yes' ),
52
+ 'order_comments' => array( 'enabled' => 'yes', 'label' => '', 'placeholder' => '', 'required' => 'no' ),
53
+ );
54
+
55
+ /**
56
+ * Constructor.
57
+ */
58
+ public function __construct() {
59
+
60
+ // Main hooks
61
+ if ( get_option( 'wcj_checkout_enabled' ) == 'yes' ) {
62
+
63
+ add_filter( 'woocommerce_checkout_fields' , array( $this, 'custom_override_checkout_fields' ) );
64
+
65
+ //if ( is_super_admin() )
66
+ //global $woocommerce;
67
+ // print_r( $woocommerce );
68
+ }
69
+
70
+ // Settings hooks
71
+ add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
72
+ add_filter( 'wcj_settings_checkout', array( $this, 'get_settings' ), 100 );
73
+ add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
74
+ }
75
+
76
+ /**
77
+ * add_enabled_option.
78
+ */
79
+ public function add_enabled_option( $settings ) {
80
+
81
+ $all_settings = $this->get_settings();
82
+ $settings[] = $all_settings[1];
83
+
84
+ return $settings;
85
+ }
86
+
87
+ function custom_override_checkout_fields( $checkout_fields ) {
88
+
89
+ //if ( is_super_admin() ) { echo '<pre>'; print_r( $checkout_fields ); echo '</pre>'; }
90
+
91
+ foreach ( $this->items as $item_key => $default_values ) {
92
+
93
+ foreach ( $this->sub_items as $sub_item_key => $sub_item_type ) {
94
+
95
+ $item_id = 'wcj_checkout_fields_' . $item_key . '_' . $sub_item_key;
96
+ $the_option = get_option( $item_id );
97
+
98
+ $field_parts = explode( "_", $item_key, 2 );
99
+
100
+ if ( $sub_item_key == 'enabled' ) {
101
+
102
+ if ( $the_option == 'no' )
103
+ unset( $checkout_fields[$field_parts[0]][$item_key] ); // e.g. unset( $checkout_fields['billing']['billing_country'] );
104
+ }
105
+ else if ( isset( $checkout_fields[$field_parts[0]][$item_key] ) ) {
106
+
107
+ if ( $the_option != '' ) {
108
+
109
+ if ( $sub_item_key == 'required' ) {
110
+
111
+ if ( $the_option == 'yes' ) $the_option = true;
112
+ else $the_option = false;
113
+ }
114
+
115
+ $checkout_fields[$field_parts[0]][$item_key][$sub_item_key] = $the_option;
116
+ }
117
+ }
118
+ }
119
+ }
120
+
121
+ return $checkout_fields;
122
+ }
123
+
124
+ /**
125
+ * get_settings.
126
+ */
127
+ function get_settings() {
128
+
129
+ //global $woocommerce;
130
+
131
+ $settings = array(
132
+
133
+ array( 'title' => __( 'Checkout Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_checkout_options' ),
134
+
135
+ array(
136
+ 'title' => __( 'Checkout', 'woocommerce-jetpack' ),
137
+ 'desc' => __( 'Enable the Checkout feature', 'woocommerce-jetpack' ),
138
+ 'desc_tip' => __( 'Customize checkout fields. Disable/enable fields, set required, change labels and/or placeholders.', 'woocommerce-jetpack' ),
139
+ 'id' => 'wcj_checkout_enabled',
140
+ 'default' => 'yes',
141
+ 'type' => 'checkbox',
142
+ ),
143
+
144
+ array( 'type' => 'sectionend', 'id' => 'wcj_checkout_options' ),
145
+ );
146
+
147
+ $settings[] = array( 'title' => __( 'Checkout Fields Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you customize the checkout fields: change label, placeholder, set required, or remove any field.', 'woocommerce-jetpack' ), 'id' => 'wcj_checkout_fields_options' );
148
+
149
+ /*$items = array(
150
+ 'enabled' => 'checkbox',
151
+ ////'type',
152
+ 'label' => 'text',
153
+ 'placeholder' => 'text',
154
+ 'required' => 'checkbox',
155
+ //'clear',
156
+ );
157
+
158
+ $fields = array(
159
+ 'billing_country',// => array( 'yes', '', '', 'yes' ),
160
+ 'billing_first_name',
161
+ 'billing_last_name',
162
+ 'billing_company',
163
+ 'billing_address_1',
164
+ 'billing_address_2',
165
+ 'billing_city',
166
+ 'billing_state',
167
+ 'billing_postcode',
168
+ 'billing_email',
169
+ 'billing_phone',
170
+ 'shipping_country',
171
+ 'shipping_first_name',
172
+ 'shipping_last_name',
173
+ 'shipping_company',
174
+ 'shipping_address_1',
175
+ 'shipping_address_2',
176
+ 'shipping_city',
177
+ 'shipping_state',
178
+ 'shipping_postcode',
179
+ 'account_password',
180
+ 'order_comments',
181
+ );*/
182
+
183
+ //global $woocommerce;
184
+ //$checkout_fields = WC()->WC_Checkout->$checkout_fields;//apply_filters( 'woocommerce_checkout_fields' , array() );
185
+ /*if ( is_super_admin() ) {
186
+
187
+ global $woocommerce;
188
+ echo '<pre>[';
189
+ print_r( WC_Checkout::instance() );//->checkout()->checkout_fields;
190
+ echo ']</pre>';
191
+ }*/
192
+
193
+ //global $woocommerce;
194
+ //echo '<pre>'; print_r( $woocommerce->checkout()->checkout_fields ); echo '</pre>';
195
+
196
+ foreach ( $this->items as $field => $default_values) {
197
+
198
+ foreach ( $this->sub_items as $item_key => $item_type ) {
199
+
200
+ $item_id = 'wcj_checkout_fields_' . $field . '_' . $item_key;
201
+
202
+ //$field_parts = explode( "_", $field, 2 );
203
+
204
+ $default_value = $default_values[$item_type];//'';
205
+ //if ( $item_type == 'checkbox' ) $default_value = 'yes';
206
+
207
+ $item_title = $field;// . ' ' . $item_key;
208
+ $item_title = str_replace( "_", " ", $item_title );
209
+ $item_title = ucwords( $item_title );
210
+
211
+ $item_desc_tip = '';
212
+ if ( 'text' == $item_type ) $item_desc_tip = __( 'Leave blank for WooCommerce defaults.', 'woocommerce-jetpack' );
213
+
214
+ $settings_to_add = array(
215
+ //'title' => $item_title,
216
+ //'desc' => $item_id,//__( 'Enable the Checkout feature', 'woocommerce-jetpack' ),
217
+ 'desc' => $item_key,
218
+ 'desc_tip' => $item_desc_tip,
219
+ 'id' => $item_id,
220
+ 'default' => $default_value,
221
+ 'type' => $item_type,
222
+ 'css' => 'min-width:300px;width:50%;',
223
+ );
224
+
225
+ if ( 'enabled' == $item_key ) {
226
+
227
+ $settings_to_add['title'] = $item_title;
228
+ $settings_to_add['checkboxgroup'] = 'start';
229
+ }
230
+ else if ( 'required' == $item_key ) $settings_to_add['checkboxgroup'] = 'end';
231
+
232
+ $settings[] = $settings_to_add;
233
+ }
234
+ }
235
+
236
+ $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_checkout_fields_options' );
237
+
238
+ return $settings;
239
+ }
240
+
241
+ /**
242
+ * settings_section.
243
+ */
244
+ function settings_section( $sections ) {
245
+
246
+ $sections['checkout'] = 'Checkout';
247
+
248
+ return $sections;
249
+ }
250
+ }
251
+
252
+ endif;
253
+
254
+ return new WCJ_Checkout();
includes/class-wcj-currencies.php CHANGED
@@ -393,7 +393,8 @@ class WCJ_Currencies {
393
  'default' => get_woocommerce_currency_symbol(),
394
  'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
395
  'css' => 'width: 50px;',
396
- 'custom_attributes' => array( 'readonly' => 'readonly' ),
 
397
  );
398
  }
399
 
393
  'default' => get_woocommerce_currency_symbol(),
394
  'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
395
  'css' => 'width: 50px;',
396
+ 'custom_attributes'
397
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
398
  );
399
  }
400
 
includes/class-wcj-emails.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Jetpack Emails
4
+ *
5
+ * The WooCommerce Jetpack Emails class.
6
+ *
7
+ * @class WCJ_Emails
8
+ */
9
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
10
+
11
+ if ( ! class_exists( 'WCJ_Emails' ) ) :
12
+
13
+ class WCJ_Emails {
14
+
15
+ /**
16
+ * Constructor.
17
+ */
18
+ public function __construct() {
19
+
20
+ // Main hooks
21
+ if ( get_option( 'wcj_emails_enabled' ) == 'yes' ) {
22
+
23
+ if ( get_option( 'wcj_emails_bcc_email' ) !== '' )
24
+ add_filter( 'woocommerce_email_headers', 'add_bcc_email' );
25
+
26
+ if ( get_option( 'wcj_emails_cc_email' ) !== '' )
27
+ add_filter( 'woocommerce_email_headers', 'add_cc_email' );
28
+
29
+ // Settings
30
+ add_filter( 'woocommerce_email_settings', array( $this, 'add_email_forwarding_fields' ), 100 );
31
+ }
32
+
33
+ // Settings hooks
34
+ add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
35
+ add_filter( 'wcj_settings_emails', array( $this, 'get_settings' ), 100 );
36
+ add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
37
+ }
38
+
39
+ /**
40
+ * add_enabled_option.
41
+ */
42
+ public function add_enabled_option( $settings ) {
43
+
44
+ $all_settings = $this->get_settings();
45
+ $settings[] = $all_settings[1];
46
+
47
+ return $settings;
48
+ }
49
+
50
+ function add_email_forwarding_fields( $settings ) {
51
+
52
+ $updated_settings = array();
53
+
54
+ foreach ( $settings as $section ) {
55
+
56
+ if ( ( isset( $section['id'] ) && 'email_template_options' == $section['id'] ) &&
57
+ ( isset( $section['type'] ) && 'title' == $section['type'] ) ) {
58
+
59
+ $updated_settings[] =
60
+ array( 'title' => __( 'WooCommerce Jetpack: Email Forwarding Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you add another email recipient(s) to all WooCommerce emails. Leave blank to disable.', 'woocommerce-jetpack' ), 'id' => 'wcj_emails_forwarding_options' );
61
+
62
+ $updated_settings[] =
63
+ array(
64
+ 'title' => __( 'Cc Email', 'woocommerce-jetpack' ),
65
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
66
+ 'desc_tip' => __( 'Cc to email, e.g. youremail@yourdomain.com. Leave blank to disable.', 'woocommerce-jetpack' ),
67
+ 'id' => 'wcj_emails_cc_email',
68
+ 'default' => '',
69
+ 'type' => 'text',
70
+ 'custom_attributes'
71
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
72
+ );
73
+
74
+ $updated_settings[] =
75
+ array(
76
+ 'title' => __( 'Bcc Email', 'woocommerce-jetpack' ),
77
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
78
+ 'desc_tip' => __( 'Bcc to email, e.g. youremail@yourdomain.com. Leave blank to disable.', 'woocommerce-jetpack' ),
79
+ 'id' => 'wcj_emails_bcc_email',
80
+ 'default' => '',
81
+ 'type' => 'text',
82
+ 'custom_attributes'
83
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
84
+ );
85
+
86
+ $updated_settings[] =
87
+ array( 'type' => 'sectionend', 'id' => 'wcj_emails_forwarding_options' );
88
+
89
+ }
90
+
91
+ $updated_settings[] = $section;
92
+ }
93
+
94
+ return $updated_settings;
95
+ }
96
+
97
+ /**
98
+ * Add another email recipient to all WooCommerce emails
99
+ */
100
+ function add_bcc_email() {
101
+
102
+ return 'Bcc: ' . get_option( 'wcj_emails_bcc_email' ) . '\r\n';
103
+ }
104
+
105
+ /**
106
+ * Add another email recipient to all WooCommerce emails
107
+ */
108
+ function add_cc_email() {
109
+
110
+ return 'Cc: ' . get_option( 'wcj_emails_cc_email' ) . '\r\n';
111
+ }
112
+
113
+ /**
114
+ * get_settings.
115
+ */
116
+ function get_settings() {
117
+
118
+ $settings = array(
119
+
120
+ array( 'title' => __( 'Emails Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_emails_options' ),
121
+
122
+ array(
123
+ 'title' => __( 'Emails', 'woocommerce-jetpack' ),
124
+ 'desc' => __( 'Enable the Emails feature', 'woocommerce-jetpack' ),
125
+ 'desc_tip' => __( 'Add another email recipient(s) to all WooCommerce emails.', 'woocommerce-jetpack' ),
126
+ 'id' => 'wcj_emails_enabled',
127
+ 'default' => 'yes',
128
+ 'type' => 'checkbox',
129
+ ),
130
+
131
+ array( 'type' => 'sectionend', 'id' => 'wcj_emails_options' ),
132
+
133
+ array( 'title' => __( 'Email Forwarding Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you add another email recipient(s) to all WooCommerce emails. Leave blank to disable.', 'woocommerce-jetpack' ), 'id' => 'wcj_emails_forwarding_options' ),
134
+
135
+ array(
136
+ 'title' => __( 'Cc Email', 'woocommerce-jetpack' ),
137
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
138
+ 'desc_tip' => __( 'Cc to email, e.g. youremail@yourdomain.com. Leave blank to disable.', 'woocommerce-jetpack' ),
139
+ 'id' => 'wcj_emails_cc_email',
140
+ 'default' => '',
141
+ 'type' => 'text',
142
+ 'custom_attributes'
143
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
144
+ ),
145
+
146
+ array(
147
+ 'title' => __( 'Bcc Email', 'woocommerce-jetpack' ),
148
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
149
+ 'desc_tip' => __( 'Bcc to email, e.g. youremail@yourdomain.com. Leave blank to disable.', 'woocommerce-jetpack' ),
150
+ 'id' => 'wcj_emails_bcc_email',
151
+ 'default' => '',
152
+ 'type' => 'text',
153
+ 'custom_attributes'
154
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
155
+ ),
156
+
157
+ array( 'type' => 'sectionend', 'id' => 'wcj_emails_forwarding_options' ),
158
+ );
159
+
160
+ return $settings;
161
+ }
162
+
163
+ /**
164
+ * settings_section.
165
+ */
166
+ function settings_section( $sections ) {
167
+
168
+ $sections['emails'] = 'Emails';
169
+
170
+ return $sections;
171
+ }
172
+ }
173
+
174
+ endif;
175
+
176
+ return new WCJ_Emails();
includes/class-wcj-order-numbers.php DELETED
@@ -1,191 +0,0 @@
1
- <?php
2
- /**
3
- * WooCommerce Jetpack Order Numbers
4
- *
5
- * The WooCommerce Jetpack Order Numbers class.
6
- *
7
- * @class WCJ_Order_Numbers
8
- */
9
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
10
-
11
- if ( ! class_exists( 'WCJ_Order_Numbers' ) ) :
12
-
13
- class WCJ_Order_Numbers {
14
-
15
- /**
16
- * Constructor.
17
- */
18
- public function __construct() {
19
-
20
- // Main hooks
21
- if ( get_option( 'wcj_order_numbers_enabled' ) == 'yes' ) {
22
-
23
- add_action( 'woocommerce_new_order', array( $this, 'add_order_number_meta' ), 100 );
24
- add_filter( 'woocommerce_order_number', array( $this, 'display_order_number' ), 100, 2 );
25
- }
26
- add_action( 'admin_menu', array($this, 'add_renumerate_orders_tool'), 100 );
27
-
28
- // Settings hooks
29
- add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
30
- add_filter( 'wcj_settings_order_numbers', array( $this, 'get_settings' ), 100 );
31
- add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
32
- }
33
-
34
- /**
35
- * Add Renumerate Orders tool to WooCommerce menu (menu link).
36
- */
37
- public function add_renumerate_orders_tool() {
38
-
39
- add_submenu_page( 'woocommerce', 'Jetpack - Renumerate Orders', 'Renumerate Orders', 'manage_options', 'woocommerce-jetpack--renumerate-orders', array( $this, 'create_renumerate_orders_tool' ) );
40
- }
41
-
42
- /**
43
- * Add Renumerate Orders tool to WooCommerce menu (the content).
44
- */
45
- public function create_renumerate_orders_tool() {
46
-
47
- $result_message = '';
48
- if ( isset( $_POST['renumerate_orders'] ) ) {
49
-
50
- $this->renumerate_orders();
51
- $result_message = '<div class="updated"><p><strong>Orders successfully renumerated!</p></div>';
52
- }
53
- ?>
54
-
55
- <?php echo $result_message; ?>
56
- <div>
57
- <h2>WooCommerce Jetpack - Renumerate Orders</h2>
58
- <p>The tool renumerates all orders. Press the button below to renumerate all existing orders starting from order counter settings in WooCommerce > Settings > Jetpack > Order Numbers.</p>
59
- <form method="post" action="">
60
- <input type="submit" name="renumerate_orders" value="Renumerate orders">
61
- </form>
62
- </div>
63
- <?php
64
- }
65
-
66
- /**
67
- * Add/update order_number meta to order.
68
- */
69
- public function add_order_number_meta( $order_id ) {
70
-
71
- $current_order_number = get_option( 'wcj_order_number_counter' );
72
- update_option( 'wcj_order_number_counter', ( $current_order_number + 1 ) );
73
- //add_post_meta( $order_id, '_wcj_order_number', $current_order_number );
74
- update_post_meta( $order_id, '_wcj_order_number', $current_order_number );
75
- }
76
-
77
- /**
78
- * Display order number.
79
- */
80
- public function display_order_number( $order_number, $order ) {
81
-
82
- $order_number_meta = get_post_meta( $order->id, '_wcj_order_number', true );
83
- if ( $order_number_meta !== '' )
84
- $order_number = '#' . $order_number_meta;
85
-
86
- return $order_number;
87
- }
88
-
89
- /**
90
- * Renumerate orders function.
91
- */
92
- public function renumerate_orders() {
93
-
94
- $args = array(
95
- 'post_type' => 'shop_order',
96
- 'post_status' => 'publish',
97
- 'posts_per_page' => -1,
98
- 'orderby' => 'date',
99
- 'order' => 'ASC',
100
- );
101
-
102
- $loop = new WP_Query( $args );
103
-
104
- while ( $loop->have_posts() ) : $loop->the_post();
105
-
106
- $order_id = $loop->post->ID;
107
- $this->add_order_number_meta( $order_id );
108
-
109
- endwhile;
110
- }
111
-
112
- /**
113
- * Add Enabled option to Jetpack Dashboard.
114
- */
115
- public function add_enabled_option( $settings ) {
116
-
117
- $all_settings = $this->get_settings();
118
- $settings[] = $all_settings[1];
119
-
120
- return $settings;
121
- }
122
-
123
- /**
124
- * Add settings arrays to Jetpack Settings.
125
- */
126
- function get_settings() {
127
-
128
- $settings = array(
129
-
130
- array( 'title' => __( 'Order Numbers Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'Order Numbers.', 'woocommerce-jetpack' ), 'id' => 'wcj_order_numbers_options' ),
131
-
132
- array(
133
- 'title' => __( 'Order Numbers', 'woocommerce-jetpack' ),
134
- 'desc' => __( 'Enable the Order Numbers feature', 'woocommerce-jetpack' ),
135
- 'desc_tip' => __( 'Sequential order numbering. Custom order number prefix and number width.', 'woocommerce-jetpack' ),
136
- 'id' => 'wcj_order_numbers_enabled',
137
- 'default' => 'no',
138
- 'type' => 'checkbox',
139
- ),
140
-
141
- array(
142
- 'title' => __( 'Next Order Number', 'woocommerce-jetpack' ),
143
- 'desc' => __( 'Next new order will be given this number.', 'woocommerce-jetpack' ),
144
- //'desc_tip' => __( 'Order Numbers.', 'woocommerce-jetpack' ),
145
- 'id' => 'wcj_order_number_counter',
146
- 'default' => 1,
147
- 'type' => 'number',
148
- ),
149
-
150
- array(
151
- 'title' => __( 'Order Number Prefix', 'woocommerce-jetpack' ),
152
- 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
153
- 'desc_tip' => __( 'Prefix before order number (optional). This will change the prefixes for all existing orders.', 'woocommerce-jetpack' ),
154
- 'id' => 'wcj_order_number_prefix',
155
- 'default' => '#',
156
- 'type' => 'text',
157
- 'custom_attributes'
158
- => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
159
- ),
160
-
161
- array(
162
- 'title' => __( 'Order Number Width', 'woocommerce-jetpack' ),
163
- 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
164
- 'desc_tip' => __( 'Minimum width of number without prefix (zeros will be added to the left side). This will change the minimum width of order number for all existing orders. E.g. set to 5 to have order number displayed as 00001 instead of 1. Leave zero to disable.', 'woocommerce-jetpack' ),
165
- 'id' => 'wcj_order_number_min_width',
166
- 'default' => 0,
167
- 'type' => 'number',
168
- 'custom_attributes'
169
- => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
170
- ),
171
-
172
- array( 'type' => 'sectionend', 'id' => 'wcj_order_numbers_options' ),
173
- );
174
-
175
- return $settings;
176
- }
177
-
178
- /**
179
- * Add settings section to WooCommerce > Settings > Jetpack.
180
- */
181
- function settings_section( $sections ) {
182
-
183
- $sections['order_numbers'] = 'Order Numbers';
184
-
185
- return $sections;
186
- }
187
- }
188
-
189
- endif;
190
-
191
- return new WCJ_Order_Numbers();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-wcj-orders.php ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Jetpack Orders
4
+ *
5
+ * The WooCommerce Jetpack Orders class.
6
+ *
7
+ * @class WCJ_Orders
8
+ */
9
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
10
+
11
+ if ( ! class_exists( 'WCJ_Orders' ) ) :
12
+
13
+ class WCJ_Orders {
14
+
15
+ /**
16
+ * Constructor.
17
+ */
18
+ public function __construct() {
19
+
20
+ // Main hooks
21
+ if ( get_option( 'wcj_orders_enabled' ) == 'yes' ) {
22
+
23
+ if ( get_option( 'wcj_order_numbers_enabled' ) == 'yes' ) {
24
+
25
+ add_action( 'woocommerce_new_order', array( $this, 'add_order_number_meta' ), 100 );
26
+ add_filter( 'woocommerce_order_number', array( $this, 'display_order_number' ), 100, 2 );
27
+ }
28
+ add_action( 'admin_menu', array( $this, 'add_renumerate_orders_tool' ), 100 );
29
+
30
+ if ( get_option( 'wcj_order_minimum_amount' ) > 0 ) {
31
+
32
+ add_action( 'woocommerce_checkout_process', array( $this, 'order_minimum_amount' ) );
33
+ add_action( 'woocommerce_before_cart', array( $this, 'order_minimum_amount' ) );
34
+ }
35
+ }
36
+
37
+ // Settings hooks
38
+ add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
39
+ add_filter( 'wcj_settings_orders', array( $this, 'get_settings' ), 100 );
40
+ add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
41
+ }
42
+
43
+ /**
44
+ * order_minimum_amount.
45
+ */
46
+ public function order_minimum_amount() {
47
+
48
+ $minimum = get_option( 'wcj_order_minimum_amount' );
49
+ if ( WC()->cart->total < $minimum ) {
50
+
51
+ if( is_cart() ) {
52
+
53
+ if ( 'yes' === get_option( 'wcj_order_minimum_amount_cart_notice_enabled' ) ) {
54
+
55
+ wc_print_notice(
56
+ sprintf( apply_filters( 'wcjpc_filter', 'You must have an order with a minimum of %s to place your order, your current order total is %s.', get_option( 'wcj_order_minimum_amount_cart_notice_message' ) ),
57
+ woocommerce_price( $minimum ),
58
+ woocommerce_price( WC()->cart->total )
59
+ ), 'notice'
60
+ );
61
+ }
62
+
63
+ } else {
64
+
65
+ wc_add_notice(
66
+ sprintf( apply_filters( 'wcjpc_filter', 'You must have an order with a minimum of %s to place your order, your current order total is %s.', get_option( 'wcj_order_minimum_amount_error_message' ) ),
67
+ woocommerce_price( $minimum ),
68
+ woocommerce_price( WC()->cart->total )
69
+ ), 'error'
70
+ );
71
+ }
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Add Renumerate Orders tool to WooCommerce menu (menu link).
77
+ */
78
+ public function add_renumerate_orders_tool() {
79
+
80
+ add_submenu_page( 'woocommerce', 'Jetpack - Renumerate Orders', 'Renumerate Orders', 'manage_options', 'woocommerce-jetpack-renumerate-orders', array( $this, 'create_renumerate_orders_tool' ) );
81
+ }
82
+
83
+ /**
84
+ * Add Renumerate Orders tool to WooCommerce menu (the content).
85
+ */
86
+ public function create_renumerate_orders_tool() {
87
+
88
+ $result_message = '';
89
+ if ( isset( $_POST['renumerate_orders'] ) ) {
90
+
91
+ $this->renumerate_orders();
92
+ $result_message = '<div class="updated"><p><strong>Orders successfully renumerated!</p></div>';
93
+ }
94
+ ?><?php echo $result_message; ?>
95
+ <div>
96
+ <h2>WooCommerce Jetpack - Renumerate Orders</h2>
97
+ <p>The tool renumerates all orders. Press the button below to renumerate all existing orders starting from order counter settings in WooCommerce > Settings > Jetpack > Order Numbers.</p>
98
+ <form method="post" action="">
99
+ <input type="submit" name="renumerate_orders" value="Renumerate orders">
100
+ </form>
101
+ </div>
102
+ <?php
103
+ }
104
+
105
+ /**
106
+ * Add/update order_number meta to order.
107
+ */
108
+ public function add_order_number_meta( $order_id ) {
109
+
110
+ $current_order_number = get_option( 'wcj_order_number_counter' );
111
+ update_option( 'wcj_order_number_counter', ( $current_order_number + 1 ) );
112
+ update_post_meta( $order_id, '_wcj_order_number', $current_order_number );
113
+ }
114
+
115
+ /**
116
+ * Display order number.
117
+ */
118
+ public function display_order_number( $order_number, $order ) {
119
+
120
+ $order_number_meta = get_post_meta( $order->id, '_wcj_order_number', true );
121
+ if ( $order_number_meta !== '' )
122
+ $order_number = '#' . $order_number_meta;
123
+
124
+ return $order_number;
125
+ }
126
+
127
+ /**
128
+ * Renumerate orders function.
129
+ */
130
+ public function renumerate_orders() {
131
+
132
+ $args = array(
133
+ 'post_type' => 'shop_order',
134
+ 'post_status' => 'publish',
135
+ 'posts_per_page' => -1,
136
+ 'orderby' => 'date',
137
+ 'order' => 'ASC',
138
+ );
139
+
140
+ $loop = new WP_Query( $args );
141
+
142
+ while ( $loop->have_posts() ) : $loop->the_post();
143
+
144
+ $order_id = $loop->post->ID;
145
+ $this->add_order_number_meta( $order_id );
146
+
147
+ endwhile;
148
+ }
149
+
150
+ /**
151
+ * Add Enabled option to Jetpack Dashboard.
152
+ */
153
+ public function add_enabled_option( $settings ) {
154
+
155
+ $all_settings = $this->get_settings();
156
+ $settings[] = $all_settings[1];
157
+
158
+ return $settings;
159
+ }
160
+
161
+ /**
162
+ * Add settings arrays to Jetpack Settings.
163
+ */
164
+ function get_settings() {
165
+
166
+ $settings = array(
167
+
168
+ //This first section\'s checkbox enables/disables all options below.
169
+ array( 'title' => __( 'Orders Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_orders_options' ),
170
+
171
+ array(
172
+ 'title' => __( 'Orders', 'woocommerce-jetpack' ),
173
+ 'desc' => __( 'Enable the Orders feature', 'woocommerce-jetpack' ),
174
+ 'desc_tip' => __( 'Sequential order numbering, custom order number prefix and number width. Minimum order amount.', 'woocommerce-jetpack' ),
175
+ 'id' => 'wcj_orders_enabled',
176
+ 'default' => 'yes',
177
+ 'type' => 'checkbox',
178
+ ),
179
+
180
+ array( 'type' => 'sectionend', 'id' => 'wcj_orders_options' ),
181
+
182
+ array( 'title' => __( 'Order Numbers Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you enable sequential order numbering, set custom number prefix and width.', 'woocommerce-jetpack' ), 'id' => 'wcj_order_numbers_options' ),
183
+
184
+ array(
185
+ 'title' => __( 'Order Numbers', 'woocommerce-jetpack' ),
186
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
187
+ 'id' => 'wcj_order_numbers_enabled',
188
+ 'default' => 'no',
189
+ 'type' => 'checkbox',
190
+ ),
191
+
192
+ array(
193
+ 'title' => __( 'Next Order Number', 'woocommerce-jetpack' ),
194
+ 'desc' => __( 'Next new order will be given this number.', 'woocommerce-jetpack' ),
195
+ 'id' => 'wcj_order_number_counter',
196
+ 'default' => 1,
197
+ 'type' => 'number',
198
+ ),
199
+
200
+ array(
201
+ 'title' => __( 'Order Number Prefix', 'woocommerce-jetpack' ),
202
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
203
+ 'desc_tip' => __( 'Prefix before order number (optional). This will change the prefixes for all existing orders.', 'woocommerce-jetpack' ),
204
+ 'id' => 'wcj_order_number_prefix',
205
+ 'default' => '#',
206
+ 'type' => 'text',
207
+ 'custom_attributes'
208
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
209
+ ),
210
+
211
+ array(
212
+ 'title' => __( 'Order Number Width', 'woocommerce-jetpack' ),
213
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
214
+ 'desc_tip' => __( 'Minimum width of number without prefix (zeros will be added to the left side). This will change the minimum width of order number for all existing orders. E.g. set to 5 to have order number displayed as 00001 instead of 1. Leave zero to disable.', 'woocommerce-jetpack' ),
215
+ 'id' => 'wcj_order_number_min_width',
216
+ 'default' => 0,
217
+ 'type' => 'number',
218
+ 'custom_attributes'
219
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
220
+ ),
221
+
222
+ array( 'type' => 'sectionend', 'id' => 'wcj_order_numbers_options' ),
223
+
224
+ array( 'title' => __( 'Order Minimum Amount', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you set minimum order amount.', 'woocommerce-jetpack' ), 'id' => 'wcj_order_minimum_amount_options' ),
225
+
226
+ array(
227
+ 'title' => __( 'Amount', 'woocommerce-jetpack' ),
228
+ 'desc' => __( 'Minimum order amount. Set to 0 to disable.', 'woocommerce-jetpack' ),
229
+ 'id' => 'wcj_order_minimum_amount',
230
+ 'default' => 0,
231
+ 'type' => 'number',
232
+ ),
233
+
234
+ array(
235
+ 'title' => __( 'Error message', 'woocommerce-jetpack' ),
236
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
237
+ 'desc_tip' => __( 'Message to customer if order is below minimum amount. Default: You must have an order with a minimum of %s to place your order, your current order total is %s.', 'woocommerce-jetpack' ),
238
+ 'id' => 'wcj_order_minimum_amount_error_message',
239
+ 'default' => 'You must have an order with a minimum of %s to place your order, your current order total is %s.',
240
+ 'type' => 'text',
241
+ 'custom_attributes'
242
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
243
+ 'css' => 'width:50%;min-width:300px;',
244
+ ),
245
+
246
+ array(
247
+ 'title' => __( 'Add notice to cart page also', 'woocommerce-jetpack' ),
248
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
249
+ 'id' => 'wcj_order_minimum_amount_cart_notice_enabled',
250
+ 'default' => 'no',
251
+ 'type' => 'checkbox',
252
+ ),
253
+
254
+ array(
255
+ 'title' => __( 'Message on cart page', 'woocommerce-jetpack' ),
256
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
257
+ 'desc_tip' => __( 'Message to customer if order is below minimum amount. Default: You must have an order with a minimum of %s to place your order, your current order total is %s.', 'woocommerce-jetpack' ),
258
+ 'id' => 'wcj_order_minimum_amount_cart_notice_message',
259
+ 'default' => 'You must have an order with a minimum of %s to place your order, your current order total is %s.',
260
+ 'type' => 'text',
261
+ 'custom_attributes'
262
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
263
+ 'css' => 'width:50%;min-width:300px;',
264
+ ),
265
+
266
+ array( 'type' => 'sectionend', 'id' => 'wcj_order_minimum_amount_options' ),
267
+
268
+ );
269
+
270
+ return $settings;
271
+ }
272
+
273
+ /**
274
+ * Add settings section to WooCommerce > Settings > Jetpack.
275
+ */
276
+ function settings_section( $sections ) {
277
+
278
+ $sections['orders'] = 'Orders';
279
+
280
+ return $sections;
281
+ }
282
+ }
283
+
284
+ endif;
285
+
286
+ return new WCJ_Orders();
includes/class-wcj-pdf-invoices.php CHANGED
@@ -24,6 +24,8 @@ class WCJ_PDF_Invoices {
24
 
25
  add_action( 'init', array( $this, 'generate_pdf' ), 10 );
26
  //wp_ajax_
 
 
27
  }
28
 
29
  //$this->generate_pdf();
@@ -34,6 +36,15 @@ class WCJ_PDF_Invoices {
34
  add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
35
  }
36
 
 
 
 
 
 
 
 
 
 
37
  /**
38
  * generate_pdf.
39
  */
@@ -217,13 +228,13 @@ class WCJ_PDF_Invoices {
217
  $actions['pdf_invoice'] = array(
218
  'url' => basename( $_SERVER['REQUEST_URI'] ) . '&pdf_invoice=' . $the_order->id,
219
  'name' => __( 'PDF', 'woocommerce-jetpack' ),
220
- 'action' => "pdf_invoice"
221
  );
222
 
223
  $actions['save_pdf_invoice'] = array(
224
  'url' => basename( $_SERVER['REQUEST_URI'] ) . '&pdf_invoice=' . $the_order->id . '&save_pdf_invoice=1',
225
  'name' => __( 'Save PDF', 'woocommerce-jetpack' ),
226
- 'action' => "save_pdf_invoice"
227
  );
228
 
229
  return $actions;
@@ -252,7 +263,7 @@ class WCJ_PDF_Invoices {
252
  array(
253
  'title' => __( 'PDF Invoices', 'woocommerce-jetpack' ),
254
  'desc' => __( 'Enable the PDF Invoices feature', 'woocommerce-jetpack' ),
255
- 'desc_tip' => __( 'PDF Invoices.', 'woocommerce-jetpack' ),
256
  'id' => 'wcj_pdf_invoices_enabled',
257
  'default' => 'yes',
258
  'type' => 'checkbox',
24
 
25
  add_action( 'init', array( $this, 'generate_pdf' ), 10 );
26
  //wp_ajax_
27
+
28
+ add_action( 'admin_head', array( $this, 'add_custom_css' ) );
29
  }
30
 
31
  //$this->generate_pdf();
36
  add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
37
  }
38
 
39
+ /**
40
+ * add_custom_css.
41
+ */
42
+ function add_custom_css() {
43
+
44
+ echo '<style> a.button.tips.view.pdf_invoice:after { content: "\e011" !important; } </style>';
45
+ echo '<style> a.button.tips.view.save_pdf_invoice:after { content: "\e011" !important; } </style>';
46
+ }
47
+
48
  /**
49
  * generate_pdf.
50
  */
228
  $actions['pdf_invoice'] = array(
229
  'url' => basename( $_SERVER['REQUEST_URI'] ) . '&pdf_invoice=' . $the_order->id,
230
  'name' => __( 'PDF', 'woocommerce-jetpack' ),
231
+ 'action' => "view pdf_invoice"
232
  );
233
 
234
  $actions['save_pdf_invoice'] = array(
235
  'url' => basename( $_SERVER['REQUEST_URI'] ) . '&pdf_invoice=' . $the_order->id . '&save_pdf_invoice=1',
236
  'name' => __( 'Save PDF', 'woocommerce-jetpack' ),
237
+ 'action' => "view save_pdf_invoice"
238
  );
239
 
240
  return $actions;
263
  array(
264
  'title' => __( 'PDF Invoices', 'woocommerce-jetpack' ),
265
  'desc' => __( 'Enable the PDF Invoices feature', 'woocommerce-jetpack' ),
266
+ 'desc_tip' => __( 'Add PDF invoices for the store owners and for the customers.', 'woocommerce-jetpack' ),
267
  'id' => 'wcj_pdf_invoices_enabled',
268
  'default' => 'yes',
269
  'type' => 'checkbox',
includes/class-wcj-price-labels.php CHANGED
@@ -120,7 +120,7 @@ class WCJ_Price_Labels {
120
 
121
  public function add_price_label_meta_box() {
122
 
123
- add_meta_box( 'wc-jetpack-price-labels', 'Custom Price Labels', array($this, 'wcj_price_label'), 'product', 'normal', 'high' );
124
  }
125
 
126
  /*
120
 
121
  public function add_price_label_meta_box() {
122
 
123
+ add_meta_box( 'wc-jetpack-price-labels', 'WooCommerce Jetpack: Custom Price Labels', array($this, 'wcj_price_label'), 'product', 'normal', 'high' );
124
  }
125
 
126
  /*
includes/class-wcj-product-info.php CHANGED
@@ -16,15 +16,16 @@ if ( ! class_exists( 'WCJ_Product_Info' ) ) :
16
 
17
  class WCJ_Product_Info {
18
 
 
 
 
19
  public function __construct() {
20
 
21
- //HOOKS
22
-
23
  // Main hooks
24
- if ( get_option( 'wcj_product_info_enabled' ) == 'yes' ) {
25
 
26
- add_action( 'woocommerce_single_product_summary', array( $this, 'print_total_sales' ), 999);
27
- //add_action( 'woocommerce_after_single_product', array( $this, 'print_total_sales' ) );
28
  }
29
 
30
  // Settings hooks
@@ -34,7 +35,7 @@ class WCJ_Product_Info {
34
  }
35
 
36
  /**
37
- * add_enabled_option.
38
  */
39
  public function add_enabled_option( $settings ) {
40
 
@@ -42,85 +43,214 @@ class WCJ_Product_Info {
42
  $settings[] = $all_settings[1];
43
 
44
  return $settings;
45
- }
46
 
47
- function print_total_sales() {
 
 
 
48
 
49
- echo str_replace( '[TOTALSALES]', get_post_custom( get_the_ID() )['total_sales'][0], get_option( 'wcj_product_info_total_sales_text' ) );
 
 
 
 
 
 
 
50
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
 
 
 
52
  function get_settings() {
53
 
54
  $settings = array(
55
 
 
56
  array( 'title' => __( 'Product Info Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_product_info_options' ),
57
 
58
  array(
59
  'title' => __( 'Product Info', 'woocommerce-jetpack' ),
60
  'desc' => __( 'Enable the Product Info feature', 'woocommerce-jetpack' ),
61
- 'desc_tip' => __( 'Display total product sales etc.', 'woocommerce-jetpack' ),
62
  'id' => 'wcj_product_info_enabled',
63
  'default' => 'yes',
64
  'type' => 'checkbox'
65
  ),
66
 
67
- array( 'type' => 'sectionend', 'id' => 'wcj_product_info_options' ),
68
 
69
-
70
- array( 'title' => __( 'Total Sales Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_product_info_total_sales_options' ),
71
 
72
  array(
73
- 'title' => __( 'Enable', 'woocommerce-jetpack' ),
74
- 'desc' => __( 'Enable Total Sales', 'woocommerce-jetpack' ),
75
- //'desc_tip'=> __( 'Display total product sales etc.', 'woocommerce-jetpack' ),
76
- 'id' => 'wcj_product_info_total_sales_enabled',
77
  'default' => 'no',
78
  'type' => 'checkbox'
79
- ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
  array(
82
- 'title' => __( 'Text to Show', 'woocommerce-jetpack' ),
83
- 'desc_tip' => __( 'This sets the text to output for total sales. Default is "Total Sales: [TOTALSALES]"', 'woocommerce-jetpack' ),
84
- 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
85
- 'id' => 'wcj_product_info_total_sales_text',
86
- 'default' => __( 'Total Sales: [TOTALSALES]', 'woocommerce-jetpack' ),
87
- 'type' => 'textarea',
88
- 'css' => 'width:50%;min-width:300px;',
 
 
 
 
 
 
89
  'custom_attributes'
90
- => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
91
  ),
 
 
 
 
 
 
 
 
92
 
93
- array( 'type' => 'sectionend', 'id' => 'wcj_product_info_total_sales_options' ),
 
 
 
 
 
 
94
 
95
- /*array(
96
- 'title' => __( 'Show on Single Product', 'woocommerce-jetpack' ),
97
- //'desc_tip'=> __( 'Check to show single products page', 'woocommerce-jetpack' ),
98
- 'id' => 'wcj_product_info_show_on_single',
99
- 'default' => 'yes',
100
- 'type' => 'checkbox',
 
 
101
  ),
102
 
103
  array(
104
- 'title' => __( 'Show on Products Archive', 'woocommerce-jetpack' ),
105
- 'id' => 'wcj_product_info_show_on_archive',
106
- 'default' => 'yes',
107
- 'type' => 'checkbox',
 
108
  ),
109
-
 
 
 
 
 
110
  array(
111
- 'title' => __( 'Show on Home Page', 'woocommerce-jetpack' ),
112
- 'id' => 'wcj_product_info_show_on_home',
113
- 'default' => 'yes',
114
- 'type' => 'checkbox',
115
- ),*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  );
117
 
118
  return $settings;
119
  }
120
 
 
 
 
121
  function settings_section( $sections ) {
122
 
123
- $sections['product_info'] = 'Product Info';
124
 
125
  return $sections;
126
  }
16
 
17
  class WCJ_Product_Info {
18
 
19
+ /**
20
+ * Constructor.
21
+ */
22
  public function __construct() {
23
 
 
 
24
  // Main hooks
25
+ if ( 'yes' == get_option( 'wcj_product_info_enabled' ) ) {
26
 
27
+ add_filter( 'woocommerce_product_tabs', array( $this, 'customize_product_tabs' ), 98 );
28
+ add_filter( 'woocommerce_related_products_args', array( $this, 'related_products_limit' ), 100 );
29
  }
30
 
31
  // Settings hooks
35
  }
36
 
37
  /**
38
+ * Return feature's enable/disable option.
39
  */
40
  public function add_enabled_option( $settings ) {
41
 
43
  $settings[] = $all_settings[1];
44
 
45
  return $settings;
46
+ }
47
 
48
+ /**
49
+ * Change number of related products on product page.
50
+ */
51
+ function related_products_limit( $args ) {
52
 
53
+ if ( get_option( 'wcj_product_info_related_products_enable' ) == 'yes' ) {
54
+
55
+ $args['posts_per_page'] = get_option( 'wcj_product_info_related_products_num' );
56
+ $args['orderby'] = get_option( 'wcj_product_info_related_products_orderby' );
57
+ if ( get_option( 'wcj_product_info_related_products_orderby' ) != 'rand' ) $args['order'] = get_option( 'wcj_product_info_related_products_order' );
58
+ }
59
+
60
+ return $args;
61
  }
62
+
63
+ /**
64
+ * Customize the product tabs.
65
+ */
66
+ function customize_product_tabs( $tabs ) {
67
+
68
+ // Unset
69
+ if ( get_option( 'wcj_product_info_product_tabs_description_disable' ) === 'yes' )
70
+ unset( $tabs['description'] );
71
+ if ( get_option( 'wcj_product_info_product_tabs_reviews_disable' ) === 'yes' )
72
+ unset( $tabs['reviews'] );
73
+ if ( get_option( 'wcj_product_info_product_tabs_additional_information_disable' ) === 'yes' )
74
+ unset( $tabs['additional_information'] );
75
+
76
+ // Priority and Title
77
+ if ( isset( $tabs['description'] ) ) {
78
+ $tabs['description']['priority'] = apply_filters( 'wcjpc_filter', 10, get_option( 'wcj_product_info_product_tabs_description_priority' ) );
79
+ if ( get_option( 'wcj_product_info_product_tabs_description_title' ) !== '' )
80
+ $tabs['description']['title'] = get_option( 'wcj_product_info_product_tabs_description_title' );
81
+ }
82
+ if ( isset( $tabs['reviews'] ) ) {
83
+ $tabs['reviews']['priority'] = apply_filters( 'wcjpc_filter', 20, get_option( 'wcj_product_info_product_tabs_reviews_priority' ) );
84
+ if ( get_option( 'wcj_product_info_product_tabs_reviews_title' ) !== '' )
85
+ $tabs['reviews']['title'] = get_option( 'wcj_product_info_product_tabs_reviews_title' );
86
+ }
87
+ if ( isset( $tabs['additional_information'] ) ) {
88
+ $tabs['additional_information']['priority'] = apply_filters( 'wcjpc_filter', 30, get_option( 'wcj_product_info_product_tabs_additional_information_priority' ) );
89
+ if ( get_option( 'wcj_product_info_product_tabs_additional_information_title' ) !== '' )
90
+ $tabs['additional_information']['title'] = get_option( 'wcj_product_info_product_tabs_additional_information_title' );
91
+ }
92
+
93
+ return $tabs;
94
+ }
95
 
96
+ /**
97
+ * Get settings.
98
+ */
99
  function get_settings() {
100
 
101
  $settings = array(
102
 
103
+ // Product Info Options
104
  array( 'title' => __( 'Product Info Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_product_info_options' ),
105
 
106
  array(
107
  'title' => __( 'Product Info', 'woocommerce-jetpack' ),
108
  'desc' => __( 'Enable the Product Info feature', 'woocommerce-jetpack' ),
109
+ 'desc_tip' => __( 'Customize single product tabs, change related products number.', 'woocommerce-jetpack' ),
110
  'id' => 'wcj_product_info_enabled',
111
  'default' => 'yes',
112
  'type' => 'checkbox'
113
  ),
114
 
115
+ array( 'type' => 'sectionend', 'id' => 'wcj_product_info_options' ),
116
 
117
+ // Product Tabs Options
118
+ array( 'title' => __( 'Product Tabs Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => 'This section lets you customize single product tabs.', 'id' => 'wcj_product_info_product_tabs_options' ),
119
 
120
  array(
121
+ 'title' => __( 'Description Tab', 'woocommerce-jetpack' ),
122
+ 'desc' => __( 'Remove tab from product page', 'woocommerce-jetpack' ),
123
+ 'id' => 'wcj_product_info_product_tabs_description_disable',
 
124
  'default' => 'no',
125
  'type' => 'checkbox'
126
+ ),
127
+
128
+ array(
129
+ 'title' => __( 'Priority (i.e. Order)', 'woocommerce-jetpack' ),
130
+ 'id' => 'wcj_product_info_product_tabs_description_priority',
131
+ 'default' => 10,
132
+ 'type' => 'number',
133
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
134
+ 'custom_attributes'
135
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
136
+ ),
137
+
138
+ array(
139
+ 'title' => __( 'Title', 'woocommerce-jetpack' ),
140
+ 'desc_tip' => __( 'Leave blank for WooCommerce defaults', 'woocommerce-jetpack' ),
141
+ 'id' => 'wcj_product_info_product_tabs_description_title',
142
+ 'default' => '',
143
+ 'type' => 'text',
144
+ ),
145
 
146
  array(
147
+ 'title' => __( 'Reviews Tab', 'woocommerce-jetpack' ),
148
+ 'desc' => __( 'Remove tab from product page', 'woocommerce-jetpack' ),
149
+ 'id' => 'wcj_product_info_product_tabs_reviews_disable',
150
+ 'default' => 'no',
151
+ 'type' => 'checkbox'
152
+ ),
153
+
154
+ array(
155
+ 'title' => __( 'Priority (i.e. Order)', 'woocommerce-jetpack' ),
156
+ 'id' => 'wcj_product_info_product_tabs_reviews_priority',
157
+ 'default' => 20,
158
+ 'type' => 'number',
159
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
160
  'custom_attributes'
161
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
162
  ),
163
+
164
+ array(
165
+ 'title' => __( 'Title', 'woocommerce-jetpack' ),
166
+ 'desc_tip' => __( 'Leave blank for WooCommerce defaults', 'woocommerce-jetpack' ),
167
+ 'id' => 'wcj_product_info_product_tabs_reviews_title',
168
+ 'default' => '',
169
+ 'type' => 'text',
170
+ ),
171
 
172
+ array(
173
+ 'title' => __( 'Additional Information Tab', 'woocommerce-jetpack' ),
174
+ 'desc' => __( 'Remove tab from product page', 'woocommerce-jetpack' ),
175
+ 'id' => 'wcj_product_info_product_tabs_additional_information_disable',
176
+ 'default' => 'no',
177
+ 'type' => 'checkbox'
178
+ ),
179
 
180
+ array(
181
+ 'title' => __( 'Priority (i.e. Order)', 'woocommerce-jetpack' ),
182
+ 'id' => 'wcj_product_info_product_tabs_additional_information_priority',
183
+ 'default' => 30,
184
+ 'type' => 'number',
185
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
186
+ 'custom_attributes'
187
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
188
  ),
189
 
190
  array(
191
+ 'title' => __( 'Title', 'woocommerce-jetpack' ),
192
+ 'desc_tip' => __( 'Leave blank for WooCommerce defaults', 'woocommerce-jetpack' ),
193
+ 'id' => 'wcj_product_info_product_tabs_additional_information_title',
194
+ 'default' => '',
195
+ 'type' => 'text',
196
  ),
197
+
198
+ array( 'type' => 'sectionend', 'id' => 'wcj_product_info_product_tabs_options' ),
199
+
200
+ // Related Products Options
201
+ array( 'title' => __( 'Related Products Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => 'This section lets you change related products number.', 'id' => 'wcj_product_info_related_products_options' ),
202
+
203
  array(
204
+ 'title' => __( 'Enable', 'woocommerce-jetpack' ),
205
+ 'id' => 'wcj_product_info_related_products_enable',
206
+ 'default' => 'no',
207
+ 'type' => 'checkbox'
208
+ ),
209
+
210
+ array(
211
+ 'title' => __( 'Related Products Number', 'woocommerce-jetpack' ),
212
+ 'id' => 'wcj_product_info_related_products_num',
213
+ 'default' => 3,
214
+ 'type' => 'number',
215
+ ),
216
+
217
+ array(
218
+ 'title' => __( 'Order by', 'woocommerce-jetpack' ),
219
+ 'id' => 'wcj_product_info_related_products_orderby',
220
+ 'default' => 'rand',
221
+ 'type' => 'select',
222
+ 'options' => array(
223
+ 'rand' => __( 'Random', 'woocommerce-jetpack' ),
224
+ 'date' => __( 'Date', 'woocommerce-jetpack' ),
225
+ 'title' => __( 'Title', 'woocommerce-jetpack' ),
226
+ ),
227
+ ),
228
+
229
+ array(
230
+ 'title' => __( 'Order', 'woocommerce-jetpack' ),
231
+ 'desc_tip' => __( 'Ignored if order by "Random" is selected above.', 'woocommerce-jetpack' ),
232
+ 'id' => 'wcj_product_info_related_products_order',
233
+ 'default' => 'desc',
234
+ 'type' => 'select',
235
+ 'options' => array(
236
+ 'asc' => __( 'Ascending', 'woocommerce-jetpack' ),
237
+ 'desc' => __( 'Descending', 'woocommerce-jetpack' ),
238
+ ),
239
+ ),
240
+
241
+ array( 'type' => 'sectionend', 'id' => 'wcj_product_info_related_products_options' ),
242
+
243
  );
244
 
245
  return $settings;
246
  }
247
 
248
+ /**
249
+ * Add settings section.
250
+ */
251
  function settings_section( $sections ) {
252
 
253
+ $sections['product_info'] = __( 'Product Info', 'woocommerce-jetpack' );
254
 
255
  return $sections;
256
  }
includes/class-wcj-shipping.php ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Jetpack Shipping
4
+ *
5
+ * The WooCommerce Jetpack Shipping class.
6
+ *
7
+ * @class WCJ_Shipping
8
+ */
9
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
10
+
11
+ if ( ! class_exists( 'WCJ_Shipping' ) ) :
12
+
13
+ class WCJ_Shipping {
14
+
15
+ /**
16
+ * Constructor.
17
+ */
18
+ public function __construct() {
19
+
20
+ // Main hooks
21
+ if ( get_option( 'wcj_shipping_enabled' ) == 'yes' ) {
22
+
23
+ //add_filter( 'woocommerce_available_shipping_methods', array( $this, 'hide_all_shipping_when_free_is_available' ), 10, 1 );
24
+ add_filter( 'woocommerce_package_rates', array( $this, 'hide_shipping_when_free_is_available' ), 10, 2 );
25
+
26
+ // Settings
27
+ add_filter( 'woocommerce_shipping_settings', array( $this, 'add_hide_shipping_if_free_available_fields' ), 100 );
28
+ }
29
+
30
+ // Settings hooks
31
+ add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
32
+ add_filter( 'wcj_settings_shipping', array( $this, 'get_settings' ), 100 );
33
+ add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
34
+ }
35
+
36
+ /**
37
+ * add_enabled_option.
38
+ */
39
+ public function add_enabled_option( $settings ) {
40
+
41
+ $all_settings = $this->get_settings();
42
+ $settings[] = $all_settings[1];
43
+
44
+ return $settings;
45
+ }
46
+
47
+ function add_hide_shipping_if_free_available_fields( $settings ) {
48
+
49
+ $updated_settings = array();
50
+
51
+ foreach ( $settings as $section ) {
52
+
53
+ if ( isset( $section['id'] ) && 'woocommerce_shipping_method_format' == $section['id'] ) {
54
+ //( isset( $section['type'] ) && 'title' == $section['type'] ) ) {
55
+
56
+ // $updated_settings[] =
57
+ // array( 'title' => __( 'Hide if free is available', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_shipping_hide_if_free_available_options' );
58
+
59
+ $updated_settings[] =
60
+ array(
61
+ 'title' => __( 'WooCommerce Jetpack: Hide shipping', 'woocommerce-jetpack' ),
62
+ 'desc' => __( 'Hide local delivery when free is available', 'woocommerce-jetpack' ),
63
+ 'desc_tip' => __( '', 'woocommerce-jetpack' ),
64
+ 'id' => 'wcj_shipping_hide_if_free_available_local_delivery',
65
+ 'default' => 'no',
66
+ 'type' => 'checkbox',
67
+ 'checkboxgroup' => 'start',
68
+ );
69
+
70
+ $updated_settings[] =
71
+ array(
72
+ //'title' => __( 'Hide all', 'woocommerce-jetpack' ),
73
+ 'desc' => __( 'Hide all when free is available', 'woocommerce-jetpack' ),
74
+ 'desc_tip' => __( '', 'woocommerce-jetpack' ),
75
+ 'id' => 'wcj_shipping_hide_if_free_available_all',
76
+ 'default' => 'no',
77
+ 'type' => 'checkbox',
78
+ 'checkboxgroup' => 'end',
79
+ );
80
+
81
+ //$updated_settings[] =
82
+ // array( 'type' => 'sectionend', 'id' => 'wcj_shipping_hide_if_free_available_options' );
83
+
84
+ }
85
+
86
+ $updated_settings[] = $section;
87
+ }
88
+
89
+ return $updated_settings;
90
+ }
91
+
92
+ function hide_shipping_when_free_is_available( $rates, $package ) {
93
+
94
+ //print_r( $rates );
95
+
96
+ // Only modify rates if free_shipping is present
97
+ if ( isset( $rates['free_shipping'] ) ) {
98
+
99
+ // To unset a single rate/method, do the following. This example unsets flat_rate shipping
100
+ if ( get_option( 'wcj_shipping_hide_if_free_available_local_delivery' ) == 'yes' )
101
+ unset( $rates['local_delivery'] );
102
+
103
+ if ( get_option( 'wcj_shipping_hide_if_free_available_all' ) == 'yes' ) {
104
+
105
+ // To unset all methods except for free_shipping, do the following
106
+ $free_shipping = $rates['free_shipping'];
107
+ //unset( $rates );
108
+ $rates = array();
109
+ $rates['free_shipping'] = $free_shipping;
110
+ }
111
+
112
+ //echo 'free-shipping';
113
+ }
114
+
115
+ return $rates;
116
+ }
117
+
118
+ /**
119
+ * Hide ALL Shipping option when free shipping is available
120
+ *
121
+ * @param array $available_methods
122
+ *
123
+ function hide_all_shipping_when_free_is_available( $available_methods ) {
124
+
125
+ if( isset( $available_methods['free_shipping'] ) ) {
126
+
127
+ // Get Free Shipping array into a new array
128
+ $freeshipping = array();
129
+ $freeshipping = $available_methods['free_shipping'];
130
+
131
+ // Empty the $available_methods array
132
+ unset( $available_methods );
133
+
134
+ // Add Free Shipping back into $avaialble_methods
135
+ $available_methods = array();
136
+ $available_methods[] = $freeshipping;
137
+
138
+ }
139
+
140
+ return $available_methods;
141
+ }
142
+
143
+ /**
144
+ * get_settings.
145
+ */
146
+ function get_settings() {
147
+
148
+ $settings = array(
149
+
150
+ array( 'title' => __( 'Shipping Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_shipping_options' ),
151
+
152
+ array(
153
+ 'title' => __( 'Shipping', 'woocommerce-jetpack' ),
154
+ 'desc' => __( 'Enable the Shipping feature', 'woocommerce-jetpack' ),
155
+ 'desc_tip' => __( 'Hide shipping when free is available.', 'woocommerce-jetpack' ),
156
+ 'id' => 'wcj_shipping_enabled',
157
+ 'default' => 'yes',
158
+ 'type' => 'checkbox',
159
+ ),
160
+
161
+ array( 'type' => 'sectionend', 'id' => 'wcj_shipping_options' ),
162
+
163
+ array( 'title' => __( 'Hide if free is available', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you hide other shipping options when free shipping is available on shop frontend.', 'woocommerce-jetpack' ), 'id' => 'wcj_shipping_hide_if_free_available_options' ),
164
+
165
+ array(
166
+ //'title' => __( 'Hide local delivery', 'woocommerce-jetpack' ),
167
+ 'title' => __( 'Hide shipping', 'woocommerce-jetpack' ),
168
+ 'desc' => __( 'Hide local delivery when free is available', 'woocommerce-jetpack' ),
169
+ 'desc_tip' => __( '', 'woocommerce-jetpack' ),
170
+ 'id' => 'wcj_shipping_hide_if_free_available_local_delivery',
171
+ 'default' => 'no',
172
+ 'type' => 'checkbox',
173
+ 'checkboxgroup' => 'start',
174
+ ),
175
+
176
+ array(
177
+ //'title' => __( 'Hide all', 'woocommerce-jetpack' ),
178
+ 'desc' => __( 'Hide all when free is available', 'woocommerce-jetpack' ),
179
+ 'desc_tip' => __( '', 'woocommerce-jetpack' ),
180
+ 'id' => 'wcj_shipping_hide_if_free_available_all',
181
+ 'default' => 'no',
182
+ 'type' => 'checkbox',
183
+ 'checkboxgroup' => 'end',
184
+ ),
185
+
186
+ array( 'type' => 'sectionend', 'id' => 'wcj_shipping_hide_if_free_available_options' ),
187
+
188
+ );
189
+
190
+ return $settings;
191
+ }
192
+
193
+ /**
194
+ * settings_section.
195
+ */
196
+ function settings_section( $sections ) {
197
+
198
+ $sections['shipping'] = 'Shipping';
199
+
200
+ return $sections;
201
+ }
202
+ }
203
+
204
+ endif;
205
+
206
+ return new WCJ_Shipping();
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === WooCommerce Jetpack ===
2
  Contributors: algoritmika
3
  Donate link: http://algoritmika.com/donate/
4
- Tags: woocommerce,woocommerce jetpack,custom price labels,call for price,currency symbol,remove sorting,remove old product slugs,add to cart text,order number,sequential order numbering,pdf invoice,pdf invoices
5
  Requires at least: 3.9.1
6
  Tested up to: 3.9.1
7
- Stable tag: 1.0.6
8
  License: GNU General Public License v3.0
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -16,13 +16,19 @@ WooCommerce Jetpack is a WordPress plugin that supercharges your site with aweso
16
 
17
  = Features =
18
 
 
 
 
 
 
 
19
  * Custom Price Labels - Create any custom price label for any product.
20
  * Call for Price - Create any custom price label, like "Call for price", for all products with empty price.
21
  * Currencies - Add all world currencies, change currency symbol.
22
  * Order Numbers - Sequential order numbering, custom order number prefix and number width.
23
  * PDF Invoices - Add PDF invoices for store owners and for customers.
24
  * More Sorting Options - Add more sorting options or remove sorting at all (including WooCommerce default).
25
- * Add to Cart - Change text for add to cart buttons for each product type.
26
  * Old Slugs - Remove old product slugs.
27
 
28
  = Feedback =
@@ -51,6 +57,18 @@ To unlock all WooCommerce Jetpack features, please install additional <a href="h
51
 
52
  == Changelog ==
53
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  = 1.0.6 - 15/07/2014 =
55
  * Feature - PDF Invoices.
56
 
1
  === WooCommerce Jetpack ===
2
  Contributors: algoritmika
3
  Donate link: http://algoritmika.com/donate/
4
+ Tags: woocommerce,woocommerce jetpack,custom price labels,call for price,currency symbol,remove sorting,remove old product slugs,add to cart text,order number,sequential order numbering,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
5
  Requires at least: 3.9.1
6
  Tested up to: 3.9.1
7
+ Stable tag: 1.1.0
8
  License: GNU General Public License v3.0
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
16
 
17
  = Features =
18
 
19
+ * Orders - Set minimum order amount.
20
+ * Checkout - Customize checkout fields: disable/enable fields, set required, change labels and/or placeholders.
21
+ * Shipping - Hide shipping when free is available.
22
+ * Emails - Add another email recipient(s) to all WooCommerce emails.
23
+ * Product Info - Customize single product tabs. Change related products number.
24
+ * Cart - Add "Empty Cart" button to cart page, redirect add to cart button to any url (e.g. checkout page), automatically add product to cart on visit.
25
  * Custom Price Labels - Create any custom price label for any product.
26
  * Call for Price - Create any custom price label, like "Call for price", for all products with empty price.
27
  * Currencies - Add all world currencies, change currency symbol.
28
  * Order Numbers - Sequential order numbering, custom order number prefix and number width.
29
  * PDF Invoices - Add PDF invoices for store owners and for customers.
30
  * More Sorting Options - Add more sorting options or remove sorting at all (including WooCommerce default).
31
+ * Add to Cart - Change text for add to cart buttons for each product type. Display "Product already in cart" instead of "Add to cart" button.
32
  * Old Slugs - Remove old product slugs.
33
 
34
  = Feedback =
57
 
58
  == Changelog ==
59
 
60
+ = 1.1.0 - 24/07/2014 =
61
+ * Dev - Orders Numbers feature moved to Orders feature.
62
+ * Dev - PDF Invoices - Icons instead of text at orders list.
63
+ * Fix - Currencies - Wrong readonly attribute for text field on WooCommerce > Settings > General, affecting Plus version, fixed.
64
+ * Feature - Orders - Set minimum order amount.
65
+ * Feature - Checkout - Customize checkout fields: disable/enable fields, set required, change labels and/or placeholders.
66
+ * Feature - Shipping - Hide shipping when free is available.
67
+ * Feature - Emails - Add another email recipient(s) to all WooCommerce emails.
68
+ * Feature - Product Info - Customize single product tabs. Change related products number.
69
+ * Feature - Cart - Add "Empty Cart" button to cart page, redirect add to cart button to any url (e.g. checkout page), automatically add product to cart on visit.
70
+ * Feature Upgraded - Add to Cart - Display "Product already in cart" instead of "Add to cart" button.
71
+
72
  = 1.0.6 - 15/07/2014 =
73
  * Feature - PDF Invoices.
74
 
woocommerce-jetpack.php CHANGED
@@ -3,14 +3,13 @@
3
  Plugin Name: WooCommerce Jetpack
4
  Plugin URI: http://woojetpack.com
5
  Description: Supercharge your WooCommerce site with these awesome powerful features.
6
- Version: 1.0.6
7
- Author: Algoritmika Ltd.
8
  Author URI: http://www.algoritmika.com
9
  Copyright: © 2014 Algoritmika Ltd.
10
  License: GNU General Public License v3.0
11
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
12
  */
13
-
14
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
15
 
16
  if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) return; // Check if WooCommerce is active
@@ -105,7 +104,7 @@ final class WC_Jetpack {
105
  return '<div class="updated">
106
  <p class="main"><strong>' . __( 'Install WooCommerce Jetpack Plus to unlock all features', 'woocommerce-jetpack' ) . '</strong></p>
107
  <span>' . sprintf( __('Some settings fields are locked and you will need %s to modify all locked fields.', 'woocommerce-jetpack'), '<a href="http://woojetpack.com/plus/">WooCommerce Jetpack Plus</a>' ) . '</span>
108
- <p><a href="http://woojetpack.com/plus/" target="_blank" class="button button-primary">' . sprintf( __( 'Buy now just for %s', 'woocommerce-jetpack' ), '$9' ). '</a> <a href="http://woojetpack.com" target="_blank" class="button">'. sprintf( __( 'Visit %s', 'woocommerce-jetpack' ), 'woojetpack.com' ) . '</a></p>
109
  </div>';
110
 
111
  case 'desc':
@@ -162,14 +161,20 @@ final class WC_Jetpack {
162
  $settings = array();
163
 
164
  $settings[] = include_once( 'includes/class-wcj-price-labels.php' );
165
- $settings[] = include_once( 'includes/class-wcj-call-for-price.php' );
166
  $settings[] = include_once( 'includes/class-wcj-currencies.php' );
167
  $settings[] = include_once( 'includes/class-wcj-sorting.php' );
168
- $settings[] = include_once( 'includes/class-wcj-old-slugs.php' );
 
169
  $settings[] = include_once( 'includes/class-wcj-add-to-cart.php' );
170
- $settings[] = include_once( 'includes/class-wcj-order-numbers.php' );
171
- $settings[] = include_once( 'includes/class-wcj-pdf-invoices.php' );
172
- //$settings[] = include_once( 'includes/class-wcj-product-info.php' );
 
 
 
 
 
173
 
174
  // Add options
175
  if ( is_admin() ) {
3
  Plugin Name: WooCommerce Jetpack
4
  Plugin URI: http://woojetpack.com
5
  Description: Supercharge your WooCommerce site with these awesome powerful features.
6
+ Version: 1.1.0
7
+ Author: Algoritmika Ltd
8
  Author URI: http://www.algoritmika.com
9
  Copyright: © 2014 Algoritmika Ltd.
10
  License: GNU General Public License v3.0
11
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
12
  */
 
13
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
 
15
  if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) return; // Check if WooCommerce is active
104
  return '<div class="updated">
105
  <p class="main"><strong>' . __( 'Install WooCommerce Jetpack Plus to unlock all features', 'woocommerce-jetpack' ) . '</strong></p>
106
  <span>' . sprintf( __('Some settings fields are locked and you will need %s to modify all locked fields.', 'woocommerce-jetpack'), '<a href="http://woojetpack.com/plus/">WooCommerce Jetpack Plus</a>' ) . '</span>
107
+ <p><a href="http://woojetpack.com/plus/" target="_blank" class="button button-primary">' . __( 'Buy now', 'woocommerce-jetpack' ) . '</a> <a href="http://woojetpack.com" target="_blank" class="button">'. sprintf( __( 'Visit %s', 'woocommerce-jetpack' ), 'WooJetpack.com' ) . '</a></p>
108
  </div>';
109
 
110
  case 'desc':
161
  $settings = array();
162
 
163
  $settings[] = include_once( 'includes/class-wcj-price-labels.php' );
164
+ $settings[] = include_once( 'includes/class-wcj-call-for-price.php' );
165
  $settings[] = include_once( 'includes/class-wcj-currencies.php' );
166
  $settings[] = include_once( 'includes/class-wcj-sorting.php' );
167
+ $settings[] = include_once( 'includes/class-wcj-product-info.php' );
168
+
169
  $settings[] = include_once( 'includes/class-wcj-add-to-cart.php' );
170
+ $settings[] = include_once( 'includes/class-wcj-cart.php' );
171
+ $settings[] = include_once( 'includes/class-wcj-shipping.php' );
172
+ $settings[] = include_once( 'includes/class-wcj-checkout.php' );
173
+
174
+ $settings[] = include_once( 'includes/class-wcj-orders.php' );
175
+ $settings[] = include_once( 'includes/class-wcj-emails.php' );
176
+ $settings[] = include_once( 'includes/class-wcj-pdf-invoices.php' );
177
+ $settings[] = include_once( 'includes/class-wcj-old-slugs.php' );
178
 
179
  // Add options
180
  if ( is_admin() ) {