Booster for WooCommerce - Version 2.3.7

Version Description

  • 17/10/2015 =
  • Dev - General Shortcodes - [wcj_tcpdf_pagebreak] shortcode added.
  • Dev - BUTTON & PRICE LABELS - Custom Price Labels - Global labels - Products/Categories Include/Exclude options added.
  • Dev - BUTTON & PRICE LABELS - Custom Price Labels - Code refactoring. Enable/disable per product labels option added.
  • Fix - CART & CHECKOUT - Checkout Custom Fields - Bug, when displaying custom order checkout fields in emails and order details, fixed.
  • Dev - PAYMENT GATEWAYS - "Gateways per Category" module renamed to "Gateways per Product or Category".
  • Dev - PAYMENT GATEWAYS - Gateways per Category - "Products - Include" and "Products - Exclude" options added.
  • Dev - PAYMENT GATEWAYS - Gateways per Category - "Product Categories - Exclude" option added.
  • Fix - SHIPPING & ORDERS - Orders - Order Minimum Amount - Additional is_object check added (bug caused PHP Notice).
  • Dev - SHIPPING & ORDERS - Orders - Module description updated.
  • Dev - PDF INVOICING & PACKING SLIPS - Templates - Code refactoring.
  • Dev - PDF INVOICING & PACKING SLIPS - Misc. - Option to customize invoice link text on customer's account page added.
Download this release

Release Info

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

Code changes from version 2.3.6 to 2.3.7

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.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -72,7 +72,7 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
72
  }
73
 
74
  /**
75
- * add_custom_fields_to_admin_emails.
76
  *
77
  * @version 2.3.0
78
  */
@@ -209,7 +209,7 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
209
  /**
210
  * update_custom_checkout_fields_order_meta.
211
  *
212
- * @version 2.3.0
213
  */
214
  public function update_custom_checkout_fields_order_meta( $order_id ) {
215
  for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_checkout_custom_fields_total_number', 1 ) ); $i++ ) {
@@ -220,6 +220,9 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
220
  if ( ! empty( $_POST[ $option_name ] ) ) {
221
  update_post_meta( $order_id, '_' . $option_name_label, get_option( 'wcj_checkout_custom_field_label_' . $i ) );
222
  update_post_meta( $order_id, '_' . $option_name, wc_clean( $_POST[ $option_name ] ) );
 
 
 
223
  }
224
  }
225
  }
@@ -228,20 +231,35 @@ class WCJ_Checkout_Custom_Fields extends WCJ_Module {
228
  /**
229
  * add_custom_fields_to_order_display.
230
  *
231
- * @version 2.3.0
232
  * @since 2.3.0
233
  */
234
  function add_custom_fields_to_order_display( $order ) {
235
  $post_meta = get_post_meta( $order->id );
236
  foreach( $post_meta as $key => $values ) {
 
237
  if ( false !== strpos( $key, 'wcj_checkout_field_' ) && isset( $values[0] ) ) {
 
238
  if ( false !== strpos( $key, '_label_' ) ) {
239
  continue;
240
  }
 
 
 
241
  $the_label_key = str_replace( 'wcj_checkout_field_', 'wcj_checkout_field_label_', $key );
242
- if ( isset( $post_meta[ $the_label_key ][0] ) ) echo $post_meta[ $the_label_key ][0] . ': ';
243
- else if ( isset( $post_meta[ $the_label_key ][0]['label'] ) ) echo $post_meta[ $the_label_key ][0]['label'] . ': ';
244
- echo isset( $values[0]['value'] ) ? $values[0]['value'] : $values[0];
 
 
 
 
 
 
 
 
 
 
245
  }
246
  }
247
  }
4
  *
5
  * The WooCommerce Jetpack Checkout Custom Fields class.
6
  *
7
+ * @version 2.3.7
8
  * @author Algoritmika Ltd.
9
  */
10
 
72
  }
73
 
74
  /**
75
+ * add_custom_fields_to_emails.
76
  *
77
  * @version 2.3.0
78
  */
209
  /**
210
  * update_custom_checkout_fields_order_meta.
211
  *
212
+ * @version 2.3.7
213
  */
214
  public function update_custom_checkout_fields_order_meta( $order_id ) {
215
  for ( $i = 1; $i <= apply_filters( 'wcj_get_option_filter', 1, get_option( 'wcj_checkout_custom_fields_total_number', 1 ) ); $i++ ) {
220
  if ( ! empty( $_POST[ $option_name ] ) ) {
221
  update_post_meta( $order_id, '_' . $option_name_label, get_option( 'wcj_checkout_custom_field_label_' . $i ) );
222
  update_post_meta( $order_id, '_' . $option_name, wc_clean( $_POST[ $option_name ] ) );
223
+ } elseif ( 'checkbox' === get_option( 'wcj_checkout_custom_field_type_' . $i ) ) {
224
+ update_post_meta( $order_id, '_' . $option_name_label, get_option( 'wcj_checkout_custom_field_label_' . $i ) );
225
+ update_post_meta( $order_id, '_' . $option_name, 0 );
226
  }
227
  }
228
  }
231
  /**
232
  * add_custom_fields_to_order_display.
233
  *
234
+ * @version 2.3.7
235
  * @since 2.3.0
236
  */
237
  function add_custom_fields_to_order_display( $order ) {
238
  $post_meta = get_post_meta( $order->id );
239
  foreach( $post_meta as $key => $values ) {
240
+
241
  if ( false !== strpos( $key, 'wcj_checkout_field_' ) && isset( $values[0] ) ) {
242
+
243
  if ( false !== strpos( $key, '_label_' ) ) {
244
  continue;
245
  }
246
+
247
+ $output = '';
248
+
249
  $the_label_key = str_replace( 'wcj_checkout_field_', 'wcj_checkout_field_label_', $key );
250
+ if ( isset( $post_meta[ $the_label_key ][0] ) ) {
251
+ if ( is_array( $post_meta[ $the_label_key ][0] ) ) {
252
+ if ( isset( $post_meta[ $the_label_key ][0]['label'] ) ) {
253
+ $output .= $post_meta[ $the_label_key ][0]['label'] . ': ';
254
+ }
255
+ } else {
256
+ $output .= $post_meta[ $the_label_key ][0] . ': ';
257
+ }
258
+ }
259
+
260
+ $output .= ( is_array( $values[0] ) && isset( $values[0]['value'] ) ) ? $values[0]['value'] : $values[0];
261
+
262
+ if ( '' != $output ) echo $output . '<br>';
263
  }
264
  }
265
  }
includes/class-wcj-orders.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Orders class.
6
  *
7
- * @version 2.2.2
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -16,27 +16,30 @@ class WCJ_Orders extends WCJ_Module {
16
 
17
  /**
18
  * Constructor.
 
 
19
  */
20
  public function __construct() {
21
 
22
  $this->id = 'orders';
23
  $this->short_desc = __( 'Orders', 'woocommerce-jetpack' );
24
- $this->desc = __( 'Minimum WooCommerce order amount; orders auto-complete.', 'woocommerce-jetpack' );
25
  parent::__construct();
26
 
27
- // Main hooks
28
  if ( $this->is_enabled() ) {
29
 
30
  if ( get_option( 'wcj_order_minimum_amount' ) > 0 ) {
31
  add_action( 'woocommerce_checkout_process', array( $this, 'order_minimum_amount' ) );
32
- add_action( 'woocommerce_before_cart', array( $this, 'order_minimum_amount' ) );
33
- if ( 'yes' === get_option( 'wcj_order_minimum_amount_stop_from_seeing_checkout' ) )
34
- add_action( 'wp', array( $this, 'stop_from_seeing_checkout' ), 100 );
35
- //add_action( 'template_redirect', array( $this, 'stop_from_seeing_checkout' ), 100 );
 
36
  }
37
 
38
- if ( 'yes' === get_option( 'wcj_order_auto_complete_enabled' ) )
39
- add_action( 'woocommerce_thankyou', array( $this, 'auto_complete_order' ) );
 
40
 
41
  if ( 'yes' === get_option( 'wcj_orders_list_custom_columns_country', 'no' ) ) {
42
  // Country column
@@ -59,8 +62,8 @@ class WCJ_Orders extends WCJ_Module {
59
  function orders_by_country_admin_filter_query( $query ) {
60
  global $typenow, $wp_query;
61
  if ( $typenow == 'shop_order' && isset( $_GET['country'] ) && 'all' != $_GET['country'] ) {
62
- $query->query_vars['meta_value'] = $_GET['country'];//'FR';
63
- $query->query_vars['meta_key'] = '_billing_country';
64
  }
65
  }
66
 
@@ -151,7 +154,8 @@ class WCJ_Orders extends WCJ_Module {
151
  sprintf( apply_filters( 'wcj_get_option_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' ) ),
152
  woocommerce_price( $minimum ),
153
  woocommerce_price( WC()->cart->total )
154
- ), 'notice'
 
155
  );
156
  }
157
  } else {
@@ -159,7 +163,8 @@ class WCJ_Orders extends WCJ_Module {
159
  sprintf( apply_filters( 'wcj_get_option_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' ) ),
160
  woocommerce_price( $minimum ),
161
  woocommerce_price( WC()->cart->total )
162
- ), 'error'
 
163
  );
164
  }
165
  }
@@ -167,10 +172,15 @@ class WCJ_Orders extends WCJ_Module {
167
 
168
  /**
169
  * stop_from_seeing_checkout.
 
 
170
  */
171
  public function stop_from_seeing_checkout( $wp ) {
 
172
  global $woocommerce;
173
- $the_cart_total = $woocommerce->cart->cart_contents_total;
 
 
174
  if ( 0 != $the_cart_total && $the_cart_total < get_option( 'wcj_order_minimum_amount' ) && is_checkout() )
175
  wp_safe_redirect( $woocommerce->cart->get_cart_url() );
176
  }
@@ -180,100 +190,116 @@ class WCJ_Orders extends WCJ_Module {
180
  */
181
  function get_settings() {
182
 
183
- $settings = array(
184
 
185
- 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' ),
 
 
 
 
 
186
 
187
- array(
188
- 'title' => __( 'Amount', 'woocommerce-jetpack' ),
189
- 'desc' => __( 'Minimum order amount. Set to 0 to disable.', 'woocommerce-jetpack' ),
190
- 'id' => 'wcj_order_minimum_amount',
191
- 'default' => 0,
192
- 'type' => 'number',
193
  'custom_attributes' => array(
194
  'step' => '0.0001',
195
  'min' => '0',
196
  ),
197
- ),
198
-
199
- array(
200
- 'title' => __( 'Error message', 'woocommerce-jetpack' ),
201
- 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
202
- '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' ),
203
- 'id' => 'wcj_order_minimum_amount_error_message',
204
- 'default' => 'You must have an order with a minimum of %s to place your order, your current order total is %s.',
205
- 'type' => 'textarea',
206
  'custom_attributes'
207
- => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
208
- 'css' => 'width:50%;min-width:300px;',
209
- ),
210
-
211
- array(
212
- 'title' => __( 'Add notice to cart page also', 'woocommerce-jetpack' ),
213
- 'desc' => __( 'Add', 'woocommerce-jetpack' ),
214
- 'id' => 'wcj_order_minimum_amount_cart_notice_enabled',
215
- 'default' => 'no',
216
- 'type' => 'checkbox',
217
- ),
218
-
219
- array(
220
- 'title' => __( 'Message on cart page', 'woocommerce-jetpack' ),
221
- 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
222
- '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' ),
223
- 'id' => 'wcj_order_minimum_amount_cart_notice_message',
224
- 'default' => 'You must have an order with a minimum of %s to place your order, your current order total is %s.',
225
- 'type' => 'textarea',
226
  'custom_attributes'
227
- => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
228
- 'css' => 'width:50%;min-width:300px;',
229
- ),
230
 
231
- array(
232
- 'title' => __( 'Stop customer from seeing the Checkout page if minimum amount not reached.', 'woocommerce-jetpack' ),
233
- 'desc' => __( 'Redirect back to Cart page', 'woocommerce-jetpack' ),
234
- 'id' => 'wcj_order_minimum_amount_stop_from_seeing_checkout',
235
- 'default' => 'no',
236
- 'type' => 'checkbox',
237
- ),
238
 
239
- array( 'type' => 'sectionend', 'id' => 'wcj_order_minimum_amount_options' ),
 
 
 
240
 
241
- array( 'title' => __( 'Orders Auto-Complete', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you enable orders auto-complete function.', 'woocommerce-jetpack' ), 'id' => 'wcj_order_auto_complete_options' ),
 
 
 
 
 
242
 
243
- array(
244
- 'title' => __( 'Auto-complete all WooCommerce orders', 'woocommerce-jetpack' ),
245
- 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
246
- 'desc_tip' => __( 'E.g. if you sell digital products then you are not shipping anything and you may want auto-complete all your orders.', 'woocommerce-jetpack' ),
247
- 'id' => 'wcj_order_auto_complete_enabled',
248
- 'default' => 'no',
249
- 'type' => 'checkbox',
250
- ),
251
 
252
- array( 'type' => 'sectionend', 'id' => 'wcj_order_auto_complete_options' ),
 
 
 
253
 
254
  array(
255
- 'title' => __( 'Orders List Custom Columns', 'woocommerce-jetpack' ),
256
- 'type' => 'title',
257
- 'desc' => __( 'This section lets you add custom columns to WooCommerce orders list.', 'woocommerce-jetpack' ),
258
- 'id' => 'wcj_orders_list_custom_columns_options',
259
  ),
260
 
261
- array(
262
- 'title' => __( 'Country', 'woocommerce-jetpack' ),
263
- 'desc' => __( 'Add', 'woocommerce-jetpack' ),
264
- 'id' => 'wcj_orders_list_custom_columns_country',
265
- 'default' => 'no',
266
- 'type' => 'checkbox',
267
- ),
268
 
269
  array(
270
- 'type' => 'sectionend',
271
- 'id' => 'wcj_orders_list_custom_columns_options',
272
  ),
273
 
274
- );
275
 
276
- return $this->add_enable_module_setting( $settings );
277
  }
278
  }
279
 
4
  *
5
  * The WooCommerce Jetpack Orders class.
6
  *
7
+ * @version 2.3.7
8
  * @author Algoritmika Ltd.
9
  */
10
 
16
 
17
  /**
18
  * Constructor.
19
+ *
20
+ * @version 2.3.7
21
  */
22
  public function __construct() {
23
 
24
  $this->id = 'orders';
25
  $this->short_desc = __( 'Orders', 'woocommerce-jetpack' );
26
+ $this->desc = __( 'Minimum WooCommerce order amount; orders auto-complete; custom admin order list columns.', 'woocommerce-jetpack' );
27
  parent::__construct();
28
 
 
29
  if ( $this->is_enabled() ) {
30
 
31
  if ( get_option( 'wcj_order_minimum_amount' ) > 0 ) {
32
  add_action( 'woocommerce_checkout_process', array( $this, 'order_minimum_amount' ) );
33
+ add_action( 'woocommerce_before_cart', array( $this, 'order_minimum_amount' ) );
34
+ if ( 'yes' === get_option( 'wcj_order_minimum_amount_stop_from_seeing_checkout' ) ) {
35
+ add_action( 'wp', array( $this, 'stop_from_seeing_checkout' ), 100 );
36
+ // add_action( 'template_redirect', array( $this, 'stop_from_seeing_checkout' ), 100 );
37
+ }
38
  }
39
 
40
+ if ( 'yes' === get_option( 'wcj_order_auto_complete_enabled' ) ) {
41
+ add_action( 'woocommerce_thankyou', array( $this, 'auto_complete_order' ) );
42
+ }
43
 
44
  if ( 'yes' === get_option( 'wcj_orders_list_custom_columns_country', 'no' ) ) {
45
  // Country column
62
  function orders_by_country_admin_filter_query( $query ) {
63
  global $typenow, $wp_query;
64
  if ( $typenow == 'shop_order' && isset( $_GET['country'] ) && 'all' != $_GET['country'] ) {
65
+ $query->query_vars['meta_value'] = $_GET['country'];//'FR';
66
+ $query->query_vars['meta_key'] = '_billing_country';
67
  }
68
  }
69
 
154
  sprintf( apply_filters( 'wcj_get_option_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' ) ),
155
  woocommerce_price( $minimum ),
156
  woocommerce_price( WC()->cart->total )
157
+ ),
158
+ 'notice'
159
  );
160
  }
161
  } else {
163
  sprintf( apply_filters( 'wcj_get_option_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' ) ),
164
  woocommerce_price( $minimum ),
165
  woocommerce_price( WC()->cart->total )
166
+ ),
167
+ 'error'
168
  );
169
  }
170
  }
172
 
173
  /**
174
  * stop_from_seeing_checkout.
175
+ *
176
+ * @version 2.3.7
177
  */
178
  public function stop_from_seeing_checkout( $wp ) {
179
+ // if ( is_admin() ) return;
180
  global $woocommerce;
181
+ if ( ! isset( $woocommerce ) || ! is_object( $woocommerce ) ) return;
182
+ if ( ! isset( $woocommerce->cart ) || ! is_object( $woocommerce->cart ) ) return;
183
+ $the_cart_total = isset( $woocommerce->cart->cart_contents_total ) ? $woocommerce->cart->cart_contents_total : 0;
184
  if ( 0 != $the_cart_total && $the_cart_total < get_option( 'wcj_order_minimum_amount' ) && is_checkout() )
185
  wp_safe_redirect( $woocommerce->cart->get_cart_url() );
186
  }
190
  */
191
  function get_settings() {
192
 
193
+ $settings = array(
194
 
195
+ array(
196
+ 'title' => __( 'Order Minimum Amount', 'woocommerce-jetpack' ),
197
+ 'type' => 'title',
198
+ 'desc' => __( 'This section lets you set minimum order amount.', 'woocommerce-jetpack' ),
199
+ 'id' => 'wcj_order_minimum_amount_options',
200
+ ),
201
 
202
+ array(
203
+ 'title' => __( 'Amount', 'woocommerce-jetpack' ),
204
+ 'desc' => __( 'Minimum order amount. Set to 0 to disable.', 'woocommerce-jetpack' ),
205
+ 'id' => 'wcj_order_minimum_amount',
206
+ 'default' => 0,
207
+ 'type' => 'number',
208
  'custom_attributes' => array(
209
  'step' => '0.0001',
210
  'min' => '0',
211
  ),
212
+ ),
213
+
214
+ array(
215
+ 'title' => __( 'Error message', 'woocommerce-jetpack' ),
216
+ 'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
217
+ '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' ),
218
+ 'id' => 'wcj_order_minimum_amount_error_message',
219
+ 'default' => 'You must have an order with a minimum of %s to place your order, your current order total is %s.',
220
+ 'type' => 'textarea',
221
  'custom_attributes'
222
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
223
+ 'css' => 'width:50%;min-width:300px;',
224
+ ),
225
+
226
+ array(
227
+ 'title' => __( 'Add notice to cart page also', 'woocommerce-jetpack' ),
228
+ 'desc' => __( 'Add', 'woocommerce-jetpack' ),
229
+ 'id' => 'wcj_order_minimum_amount_cart_notice_enabled',
230
+ 'default' => 'no',
231
+ 'type' => 'checkbox',
232
+ ),
233
+
234
+ array(
235
+ 'title' => __( 'Message on cart page', '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_cart_notice_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' => 'textarea',
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' => __( 'Stop customer from seeing the Checkout page if minimum amount not reached.', 'woocommerce-jetpack' ),
248
+ 'desc' => __( 'Redirect back to Cart page', 'woocommerce-jetpack' ),
249
+ 'id' => 'wcj_order_minimum_amount_stop_from_seeing_checkout',
250
+ 'default' => 'no',
251
+ 'type' => 'checkbox',
252
+ ),
253
 
254
+ array(
255
+ 'type' => 'sectionend',
256
+ 'id' => 'wcj_order_minimum_amount_options',
257
+ ),
258
 
259
+ array(
260
+ 'title' => __( 'Orders Auto-Complete', 'woocommerce-jetpack' ),
261
+ 'type' => 'title',
262
+ 'desc' => __( 'This section lets you enable orders auto-complete function.', 'woocommerce-jetpack' ),
263
+ 'id' => 'wcj_order_auto_complete_options',
264
+ ),
265
 
266
+ array(
267
+ 'title' => __( 'Auto-complete all WooCommerce orders', 'woocommerce-jetpack' ),
268
+ 'desc' => __( 'Enable', 'woocommerce-jetpack' ),
269
+ 'desc_tip' => __( 'E.g. if you sell digital products then you are not shipping anything and you may want auto-complete all your orders.', 'woocommerce-jetpack' ),
270
+ 'id' => 'wcj_order_auto_complete_enabled',
271
+ 'default' => 'no',
272
+ 'type' => 'checkbox',
273
+ ),
274
 
275
+ array(
276
+ 'type' => 'sectionend',
277
+ 'id' => 'wcj_order_auto_complete_options',
278
+ ),
279
 
280
  array(
281
+ 'title' => __( 'Orders List Custom Columns', 'woocommerce-jetpack' ),
282
+ 'type' => 'title',
283
+ 'desc' => __( 'This section lets you add custom columns to WooCommerce orders list.', 'woocommerce-jetpack' ),
284
+ 'id' => 'wcj_orders_list_custom_columns_options',
285
  ),
286
 
287
+ array(
288
+ 'title' => __( 'Country', 'woocommerce-jetpack' ),
289
+ 'desc' => __( 'Add', 'woocommerce-jetpack' ),
290
+ 'id' => 'wcj_orders_list_custom_columns_country',
291
+ 'default' => 'no',
292
+ 'type' => 'checkbox',
293
+ ),
294
 
295
  array(
296
+ 'type' => 'sectionend',
297
+ 'id' => 'wcj_orders_list_custom_columns_options',
298
  ),
299
 
300
+ );
301
 
302
+ return $this->add_enable_module_setting( $settings );
303
  }
304
  }
305
 
includes/class-wcj-payment-gateways-per-category.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Payment Gateways per Category class.
6
  *
7
- * @version 2.3.0
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
@@ -18,19 +18,19 @@ class WCJ_Payment_Gateways_Per_Category extends WCJ_Module {
18
  /**
19
  * Constructor.
20
  *
21
- * @version 2.3.0
22
  */
23
  function __construct() {
24
 
25
  $this->id = 'payment_gateways_per_category';
26
- $this->short_desc = __( 'Gateways per Category', 'woocommerce-jetpack' );
27
- $this->desc = __( 'Show gateway only if there is product of selected category in WooCommerce cart.', 'woocommerce-jetpack' );
28
  parent::__construct();
29
 
30
  add_filter( 'init', array( $this, 'add_hooks' ) );
31
 
32
  if ( $this->is_enabled() ) {
33
- //add_filter( 'woocommerce_payment_gateways_settings', array( $this, 'add_per_category_settings' ), 100 );
34
  add_filter( 'woocommerce_available_payment_gateways', array( $this, 'filter_available_payment_gateways_per_category' ), 100 );
35
  }
36
  }
@@ -40,9 +40,7 @@ class WCJ_Payment_Gateways_Per_Category extends WCJ_Module {
40
  */
41
  function get_settings() {
42
  $settings = array();
43
-
44
  $settings = apply_filters( 'wcj_payment_gateways_per_category_settings', $settings );
45
-
46
  return $this->add_enable_module_setting( $settings );
47
  }
48
 
@@ -50,15 +48,21 @@ class WCJ_Payment_Gateways_Per_Category extends WCJ_Module {
50
  * add_hooks.
51
  */
52
  function add_hooks() {
53
- add_filter( 'wcj_payment_gateways_per_category_settings', array( $this, 'add_per_category_settings' ) );
54
  }
55
 
56
  /**
57
  * filter_available_payment_gateways_per_category.
 
 
58
  */
59
  function filter_available_payment_gateways_per_category( $available_gateways ) {
60
- //if ( ! is_checkout() ) return $available_gateways;
 
 
61
  foreach ( $available_gateways as $gateway_id => $gateway ) {
 
 
62
  $categories_in = get_option( 'wcj_gateways_per_category_' . $gateway_id );
63
  if ( ! empty( $categories_in ) ) {
64
  $do_skip = true;
@@ -79,22 +83,83 @@ class WCJ_Payment_Gateways_Per_Category extends WCJ_Module {
79
  }
80
  if ( $do_skip ) {
81
  // Skip (i.e. hide/unset) current gateway - no products of needed categories found in the cart
82
- unset( $available_gateways[ $gateway_id ] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  }
84
  }
 
85
  }
 
86
  return $available_gateways;
87
  }
88
 
89
  /**
90
  * add_per_category_settings.
 
 
91
  */
92
  function add_per_category_settings( $settings ) {
93
 
94
  $settings[] = array(
95
- 'title' => __( 'WooCommerce Jetpack: Payment Gateways per Category Options', 'woocommerce-jetpack' ),
96
  'type' => 'title',
97
- //'desc' => __( '', 'woocommerce-jetpack' ),
98
  'id' => 'wcj_gateways_per_category_options',
99
  );
100
 
@@ -104,23 +169,75 @@ class WCJ_Payment_Gateways_Per_Category extends WCJ_Module {
104
  $product_cats[ $product_category->term_id ] = $product_category->name;
105
  }
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  global $woocommerce;
108
  $available_gateways = $woocommerce->payment_gateways->payment_gateways();
109
  foreach ( $available_gateways as $gateway_id => $gateway ) {
110
  $settings[] = array(
111
- 'title' => $gateway->title,
112
- 'desc' => 'Product Categories',
113
- 'desc_tip' => __( 'Show gateway only if there is product of selected category in cart.', 'woocommerce-jetpack' ),
114
- 'id' => 'wcj_gateways_per_category_' . $gateway_id,
115
- 'default' => '',
116
- 'type' => 'multiselect',
 
 
 
 
 
 
 
 
 
 
 
117
  'class' => 'chosen_select',
118
  'css' => 'width: 450px;',
119
  'options' => $product_cats,
120
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  }
122
 
123
- $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_gateways_per_category_options' );
 
 
 
124
 
125
  return $settings;
126
  }
4
  *
5
  * The WooCommerce Jetpack Payment Gateways per Category class.
6
  *
7
+ * @version 2.3.7
8
  * @since 2.2.0
9
  * @author Algoritmika Ltd.
10
  */
18
  /**
19
  * Constructor.
20
  *
21
+ * @version 2.3.7
22
  */
23
  function __construct() {
24
 
25
  $this->id = 'payment_gateways_per_category';
26
+ $this->short_desc = __( 'Gateways per Product or Category', 'woocommerce-jetpack' );
27
+ $this->desc = __( 'Show WooCommerce gateway only if there is selected product or product category in cart.', 'woocommerce-jetpack' );
28
  parent::__construct();
29
 
30
  add_filter( 'init', array( $this, 'add_hooks' ) );
31
 
32
  if ( $this->is_enabled() ) {
33
+ // add_filter( 'woocommerce_payment_gateways_settings', array( $this, 'add_per_category_settings' ), 100 );
34
  add_filter( 'woocommerce_available_payment_gateways', array( $this, 'filter_available_payment_gateways_per_category' ), 100 );
35
  }
36
  }
40
  */
41
  function get_settings() {
42
  $settings = array();
 
43
  $settings = apply_filters( 'wcj_payment_gateways_per_category_settings', $settings );
 
44
  return $this->add_enable_module_setting( $settings );
45
  }
46
 
48
  * add_hooks.
49
  */
50
  function add_hooks() {
51
+ add_filter( 'wcj_payment_gateways_per_category_settings', array( $this, 'add_per_category_settings' ) );
52
  }
53
 
54
  /**
55
  * filter_available_payment_gateways_per_category.
56
+ *
57
+ * @version 2.3.7
58
  */
59
  function filter_available_payment_gateways_per_category( $available_gateways ) {
60
+
61
+ // if ( ! is_checkout() ) return $available_gateways;
62
+
63
  foreach ( $available_gateways as $gateway_id => $gateway ) {
64
+
65
+ // Including by categories
66
  $categories_in = get_option( 'wcj_gateways_per_category_' . $gateway_id );
67
  if ( ! empty( $categories_in ) ) {
68
  $do_skip = true;
83
  }
84
  if ( $do_skip ) {
85
  // Skip (i.e. hide/unset) current gateway - no products of needed categories found in the cart
86
+ if ( isset( $available_gateways[ $gateway_id ] ) ) unset( $available_gateways[ $gateway_id ] );
87
+ continue; // ... to next gateway
88
+ }
89
+ }
90
+
91
+ // Excluding by categories
92
+ $categories_excl = get_option( 'wcj_gateways_per_category_excl_' . $gateway_id );
93
+ if ( ! empty( $categories_excl ) ) {
94
+ $do_skip = false;
95
+ foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
96
+ $product_categories = get_the_terms( $values['product_id'], 'product_cat' );
97
+ if ( empty( $product_categories ) ) continue; // ... to next product in the cart
98
+ foreach( $product_categories as $product_category ) {
99
+ if ( in_array( $product_category->term_id, $categories_excl ) ) {
100
+ // Skip (i.e. hide/unset) current gateway
101
+ if ( isset( $available_gateways[ $gateway_id ] ) ) unset( $available_gateways[ $gateway_id ] );
102
+ $do_skip = true;
103
+ break;
104
+ }
105
+ }
106
+ if ( $do_skip ) break;
107
+ }
108
+ if ( $do_skip ) {
109
+ continue; // ... to next gateway
110
+ }
111
+ }
112
+
113
+ // Including by products
114
+ $products_in = apply_filters( 'wcj_get_option_filter', array(), get_option( 'wcj_gateways_per_products_' . $gateway_id ) );
115
+ if ( ! empty( $products_in ) ) {
116
+ $do_skip = true;
117
+ foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
118
+ if ( in_array( $values['product_id'], $products_in ) ) {
119
+ // Current gateway is OK
120
+ $do_skip = false;
121
+ break;
122
+ }
123
+ }
124
+ if ( $do_skip ) {
125
+ // Skip (i.e. hide/unset) current gateway
126
+ if ( isset( $available_gateways[ $gateway_id ] ) ) unset( $available_gateways[ $gateway_id ] );
127
+ continue; // ... to next gateway
128
+ }
129
+ }
130
+
131
+ // Excluding by products
132
+ $products_excl = apply_filters( 'wcj_get_option_filter', array(), get_option( 'wcj_gateways_per_products_excl_' . $gateway_id ) );
133
+ if ( ! empty( $products_excl ) ) {
134
+ $do_skip = false;
135
+ foreach ( WC()->cart->get_cart() as $cart_item_key => $values ) {
136
+ if ( in_array( $values['product_id'], $products_excl ) ) {
137
+ // Skip (i.e. hide/unset) current gateway
138
+ if ( isset( $available_gateways[ $gateway_id ] ) ) unset( $available_gateways[ $gateway_id ] );
139
+ $do_skip = true;
140
+ break;
141
+ }
142
+ }
143
+ if ( $do_skip ) {
144
+ continue; // ... to next gateway
145
  }
146
  }
147
+
148
  }
149
+
150
  return $available_gateways;
151
  }
152
 
153
  /**
154
  * add_per_category_settings.
155
+ *
156
+ * @version 2.3.7
157
  */
158
  function add_per_category_settings( $settings ) {
159
 
160
  $settings[] = array(
161
+ 'title' => __( 'Options', 'woocommerce-jetpack' ),
162
  'type' => 'title',
 
163
  'id' => 'wcj_gateways_per_category_options',
164
  );
165
 
169
  $product_cats[ $product_category->term_id ] = $product_category->name;
170
  }
171
 
172
+ $products = array();
173
+ $args = array(
174
+ 'post_type' => 'product',
175
+ 'post_status' => 'any',
176
+ 'posts_per_page' => -1,
177
+ );
178
+ $loop = new WP_Query( $args );
179
+ if ( $loop->have_posts() ) {
180
+ while ( $loop->have_posts() ) : $loop->the_post();
181
+ $products[ strval( $loop->post->ID ) ] = get_the_title( $loop->post->ID );
182
+ endwhile;
183
+ wp_reset_postdata();
184
+ }
185
+
186
  global $woocommerce;
187
  $available_gateways = $woocommerce->payment_gateways->payment_gateways();
188
  foreach ( $available_gateways as $gateway_id => $gateway ) {
189
  $settings[] = array(
190
+ 'title' => $gateway->title,
191
+ 'desc' => __( 'Product Categories - Include', 'woocommerce-jetpack' ),
192
+ 'desc_tip' => __( 'Show gateway only if there is product of selected category in cart. Leave blank to disable the option.', 'woocommerce-jetpack' ),
193
+ 'id' => 'wcj_gateways_per_category_' . $gateway_id,
194
+ 'default' => '',
195
+ 'type' => 'multiselect',
196
+ 'class' => 'chosen_select',
197
+ 'css' => 'width: 450px;',
198
+ 'options' => $product_cats,
199
+ );
200
+ $settings[] = array(
201
+ 'title' => '',
202
+ 'desc' => __( 'Product Categories - Exclude', 'woocommerce-jetpack' ),
203
+ 'desc_tip' => __( 'Hide gateway if there is product of selected category in cart. Leave blank to disable the option.', 'woocommerce-jetpack' ),
204
+ 'id' => 'wcj_gateways_per_category_excl_' . $gateway_id,
205
+ 'default' => '',
206
+ 'type' => 'multiselect',
207
  'class' => 'chosen_select',
208
  'css' => 'width: 450px;',
209
  'options' => $product_cats,
210
  );
211
+ $settings[] = array(
212
+ 'title' => '',
213
+ 'desc' => __( 'Products - Include', 'woocommerce-jetpack' ) . '. ' . apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
214
+ 'desc_tip' => __( 'Show gateway only if there is selected products in cart. Leave blank to disable the option.', 'woocommerce-jetpack' ),
215
+ 'id' => 'wcj_gateways_per_products_' . $gateway_id,
216
+ 'default' => '',
217
+ 'type' => 'multiselect',
218
+ 'class' => 'chosen_select',
219
+ 'css' => 'width: 450px;',
220
+ 'options' => $products,
221
+ 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
222
+ );
223
+ $settings[] = array(
224
+ 'title' => '',
225
+ 'desc' => __( 'Products - Exclude', 'woocommerce-jetpack' ) . '. ' . apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
226
+ 'desc_tip' => __( 'Hide gateway if there is selected products in cart. Leave blank to disable the option.', 'woocommerce-jetpack' ),
227
+ 'id' => 'wcj_gateways_per_products_excl_' . $gateway_id,
228
+ 'default' => '',
229
+ 'type' => 'multiselect',
230
+ 'class' => 'chosen_select',
231
+ 'css' => 'width: 450px;',
232
+ 'options' => $products,
233
+ 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
234
+ );
235
  }
236
 
237
+ $settings[] = array(
238
+ 'type' => 'sectionend',
239
+ 'id' => 'wcj_gateways_per_category_options',
240
+ );
241
 
242
  return $settings;
243
  }
includes/class-wcj-price-labels.php CHANGED
@@ -4,7 +4,7 @@
4
  *
5
  * The WooCommerce Jetpack Price Labels class.
6
  *
7
- * @version 2.3.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -12,43 +12,49 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
12
 
13
  if ( ! class_exists( 'WCJ_Price_Labels' ) ) :
14
 
15
- class WCJ_Price_Labels {
16
-
17
- // Custom Price Labels - fields array
18
- public $custom_tab_group_name = 'wcj_price_labels';// for compatibility with Custom Price Label Pro plugin should use 'simple_is_custom_pricing_label'
19
- public $custom_tab_sections = array ( '_instead', '_before', '_between', '_after', );
20
- public $custom_tab_sections_titles = array (
21
- '_instead' => 'Instead of the price',// for compatibility with Custom Price Label Pro plugin should use ''
22
- '_before' => 'Before the price',
23
- '_between' => 'Between regular and sale prices',
24
- '_after' => 'After the price',
25
- );
26
- public $custom_tab_section_variations = array ( '_text', '_enabled', '_home', '_products', '_single', '_page', '_cart', /*'_simple',*/ '_variable', '_variation', /*'_grouped',*/ );
27
- public $custom_tab_section_variations_titles = array (
28
- '_text' => '',//'The label',
29
- '_enabled' => 'Enable',// for compatibility with Custom Price Label Pro plugin should use ''
30
- '_home' => 'Hide on home page',
31
- '_products' => 'Hide on products page',
32
- '_single' => 'Hide on single',
33
- '_page' => 'Hide on all pages',
34
- '_cart' => 'Hide on cart page only',
35
- //'_simple' => 'Hide for simple product',
36
- '_variable' => 'Hide for main price',
37
- '_variation' => 'Hide for all variations',
38
- //'_grouped' => 'Hide for grouped product',
39
- );
40
 
41
  /**
42
  * Constructor.
 
 
43
  */
44
  public function __construct() {
45
 
46
- // HOOKS
47
- // Main hooks
48
- if ( 'yes' === get_option( 'wcj_price_labels_enabled' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
- if ( is_admin() ) {
51
 
 
 
 
52
  if ( 'yes' === get_option( 'wcj_migrate_from_custom_price_labels_enabled' ) ) {
53
  // "Migrate from Custom Price Labels (Pro)" tool
54
  add_filter( 'wcj_tools_tabs', array( $this, 'add_migrate_from_custom_price_labels_tool_tab' ), 100 );
@@ -56,10 +62,11 @@ class WCJ_Price_Labels {
56
  }
57
  }
58
 
59
- // Add meta box
60
- add_action( 'add_meta_boxes', array( $this, 'add_price_label_meta_box' ) );
61
- // Save Post
62
- add_action( 'save_post_product', array( $this, 'save_custom_price_labels' ), 999, 2 );
 
63
 
64
  // Prices Hooks
65
  $this->prices_filters = array(
@@ -98,11 +105,6 @@ class WCJ_Price_Labels {
98
  }
99
 
100
  add_action( 'wcj_tools_dashboard', array( $this, 'add_migrate_tool_info_to_tools_dashboard' ), 1000 );
101
-
102
- // Settings hooks
103
- add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
104
- add_filter( 'wcj_settings_price_labels', array( $this, 'get_settings' ), 100 );
105
- add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
106
  }
107
 
108
  /**
@@ -125,17 +127,23 @@ class WCJ_Price_Labels {
125
  */
126
  public function add_migrate_from_custom_price_labels_tool_tab( $tabs ) {
127
  $tabs[] = array(
128
- 'id' => 'migrate_from_custom_price_labels',
129
- 'title' => __( 'Migrate from Custom Price Labels', 'woocommerce-jetpack' ),
130
  );
131
  return $tabs;
132
  }
133
 
134
- /*public function get_migration_new_meta_name( $old_meta_name ) {
 
 
 
135
  $new_meta_name = str_replace( 'simple_is_custom_pricing_label', 'wcj_price_labels', $old_meta_name );
136
  return $new_meta_name;
137
- }*/
138
 
 
 
 
139
  public function create_migrate_from_custom_price_labels_tool_tab() {
140
 
141
  echo '<h2>' . __( 'WooCommerce Jetpack - Migrate from Custom Price Labels (Pro)', 'woocommerce-jetpack' ) . '</h2>';
@@ -239,25 +247,12 @@ class WCJ_Price_Labels {
239
  echo $form_html . $html;
240
  }
241
 
242
- /*public function custom_price1( $price, $product ) {
243
- echo '[' . $price . ']';
244
- return $price;
245
- }*/
246
-
247
  /**
248
- * add_enabled_option.
249
  */
250
- public function add_enabled_option( $settings ) {
251
-
252
- $all_settings = $this->get_settings();
253
- $settings[] = $all_settings[1];
254
-
255
- return $settings;
256
- }
257
-
258
  public function save_custom_price_labels( $post_id, $post ) {
259
 
260
- //$product = get_product( $post );TODO - do I need it?
261
 
262
  if ( ! isset( $_POST['woojetpack_price_labels_save_post'] ) )
263
  return;
@@ -266,12 +261,11 @@ class WCJ_Price_Labels {
266
 
267
  foreach ( $this->custom_tab_section_variations as $custom_tab_section_variation ) {
268
 
269
- //$option_name = $this->custom_tab_group_name;
270
  $option_name = $this->custom_tab_group_name . $custom_tab_section . $custom_tab_section_variation;
271
 
272
  // if ( isset( $_POST[ $option_name ] ) ) update_post_meta( $post_id, '_' . $option_name, $_POST[ $option_name ] );
273
 
274
- /**/
275
  if ( $custom_tab_section_variation == '_text' ) {
276
  //$option_name .= $custom_tab_section_variation . $custom_tab_section;
277
  if ( isset( $_POST[ $option_name ] ) ) update_post_meta( $post_id, '_' . $option_name, $_POST[ $option_name ] );
@@ -281,18 +275,19 @@ class WCJ_Price_Labels {
281
  if ( isset( $_POST[ $option_name ] ) ) update_post_meta( $post_id, '_' . $option_name, $_POST[ $option_name ] );
282
  else update_post_meta( $post_id, '_' . $option_name, 'off' );
283
  }
284
- /**/
285
  }
286
  }
287
  }
288
 
 
 
 
289
  public function add_price_label_meta_box() {
290
-
291
  add_meta_box( 'wc-jetpack-price-labels', 'WooCommerce Jetpack: Custom Price Labels', array( $this, 'wcj_price_label' ), 'product', 'normal', 'high' );
292
  }
293
 
294
  /*
295
- * back end
296
  */
297
  public function wcj_price_label() {
298
 
@@ -414,17 +409,14 @@ class WCJ_Price_Labels {
414
  }
415
 
416
  /*
417
- * front end.
418
  *
419
- * @version 2.3.0
420
  */
421
  public function custom_price( $price, $product ) {
422
 
423
  if ( ! wcj_is_frontend() ) return $price;
424
 
425
- //if ( 'simple' === $product->product_type )
426
- // return $price;
427
-
428
  $current_filter_name = current_filter();
429
 
430
  if ( ( 'woocommerce_get_price_html' === $current_filter_name ) && ( 'booking' !== $product->product_type ) )
@@ -433,117 +425,187 @@ class WCJ_Price_Labels {
433
  if ( 'woocommerce_cart_item_price' === $current_filter_name )
434
  $product = $product['data'];
435
 
436
- // Global price labels - Add text before price
437
- $text_to_add_before = apply_filters( 'wcj_get_option_filter', '', get_option( 'wcj_global_price_labels_add_before_text' ) );
438
- if ( '' != $text_to_add_before )
439
- $price = $text_to_add_before . $price;
440
- // Global price labels - Add text after price
441
- $text_to_add_after = get_option( 'wcj_global_price_labels_add_after_text' );
442
- if ( '' != $text_to_add_after )
443
- $price = $price . $text_to_add_after;
444
-
445
- // Global price labels - Between regular and sale prices
446
- $text_to_add_between_regular_and_sale = get_option( 'wcj_global_price_labels_between_regular_and_sale_text' );
447
- if ( '' != $text_to_add_between_regular_and_sale )
448
- $price = apply_filters( 'wcj_get_option_filter', $price, str_replace( '</del> <ins>', '</del>' . $text_to_add_between_regular_and_sale . '<ins>', $price ) );
449
-
450
- // Global price labels - Remove text from price
451
- $text_to_remove = apply_filters( 'wcj_get_option_filter', '', get_option( 'wcj_global_price_labels_remove_text' ) );
452
- if ( '' != $text_to_remove )
453
- $price = str_replace( $text_to_remove, '', $price );
454
- // Global price labels - Remove text from price
455
- $text_to_replace = apply_filters( 'wcj_get_option_filter', '', get_option( 'wcj_global_price_labels_replace_text' ) );
456
- $text_to_replace_with = apply_filters( 'wcj_get_option_filter', '', get_option( 'wcj_global_price_labels_replace_with_text' ) );
457
- if ( '' != $text_to_replace && '' != $text_to_replace_with )
458
- $price = str_replace( $text_to_replace, $text_to_replace_with, $price );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
459
 
460
- foreach ( $this->custom_tab_sections as $custom_tab_section ) {
 
461
 
462
- $labels_array = array();
463
 
464
- foreach ( $this->custom_tab_section_variations as $custom_tab_section_variation ) {
465
 
466
- //$option_name = $this->custom_tab_group_name;
467
- $option_name = $this->custom_tab_group_name . $custom_tab_section . $custom_tab_section_variation;
468
- $labels_array[ 'variation' . $custom_tab_section_variation ] = get_post_meta( $product->post->ID, '_' . $option_name, true );
469
 
470
- /*if ( $custom_tab_section_variation == '_text' ) {
 
 
471
 
472
- //$option_name .= $custom_tab_section_variation . $custom_tab_section;
473
- $labels_array[ 'variation' . $custom_tab_section_variation ] = get_post_meta($product->post->ID, '_' . $option_name, true );
474
- }
475
- else {
476
 
477
- //$option_name .= $custom_tab_section . $custom_tab_section_variation;
478
- $labels_array[ 'variation' . $custom_tab_section_variation ] = get_post_meta($product->post->ID, '_' . $option_name, true);
479
- }*/
 
480
 
481
- //$price .= print_r( $labels_array );
482
- }
 
483
 
484
- if ( 'on' === $labels_array[ 'variation_enabled' ] ) {
485
-
486
- if (
487
- ( ( 'off' === $labels_array['variation_home'] ) && ( is_front_page() ) ) ||
488
- ( ( 'off' === $labels_array['variation_products'] ) && ( is_archive() ) ) ||
489
- ( ( 'off' === $labels_array['variation_single'] ) && ( is_single() ) ) ||
490
- ( ( 'off' === $labels_array['variation_page'] ) && ( is_page() ) )
491
- )
492
- {
493
- //$current_filter_name = current_filter();
494
- if ( 'woocommerce_cart_item_price' === $current_filter_name && 'on' === $labels_array['variation_cart'] )
495
- continue;
496
-
497
- $variable_filters_array = array(
498
- 'woocommerce_variable_empty_price_html',
499
- 'woocommerce_variable_free_price_html',
500
- 'woocommerce_variable_free_sale_price_html',
501
- 'woocommerce_variable_price_html',
502
- 'woocommerce_variable_sale_price_html',
503
- );
504
-
505
- $variation_filters_array = array(
506
- 'woocommerce_variation_empty_price_html',
507
- 'woocommerce_variation_free_price_html',
508
- //woocommerce_variation_option_name
509
- 'woocommerce_variation_price_html',
510
- 'woocommerce_variation_sale_price_html',
511
- );
512
-
513
- if (
514
- ( in_array( $current_filter_name, $variable_filters_array ) && ( $labels_array['variation_variable'] == 'off' ) ) ||
515
- ( in_array( $current_filter_name, $variation_filters_array ) && ( $labels_array['variation_variation'] == 'off' ) ) ||
516
- ( ! in_array( $current_filter_name, $variable_filters_array ) && ! in_array( $current_filter_name, $variation_filters_array ) )
517
- )
518
- $price = $this->customize_price( $price, $custom_tab_section, $labels_array['variation_text'] );
519
- }
520
- }
521
 
522
- //unset( $labels_array );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
523
  }
524
 
525
  return do_shortcode( $price );
526
  }
527
 
 
 
 
 
 
528
  function get_settings() {
 
 
 
 
529
 
530
- $settings = array(
 
 
 
 
 
 
 
 
531
 
532
- array( 'title' => __( 'Custom Price Labels Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_price_labels_options' ),
 
 
 
 
 
 
533
 
534
- array(
535
- 'title' => __( 'Custom Price Labels', 'woocommerce-jetpack' ),
536
- 'desc' => '<strong>' . __( 'Enable Module', 'woocommerce-jetpack' ) . '</strong>',
537
- 'desc_tip' => __( 'Create any custom price label for any WooCommerce product.', 'woocommerce-jetpack' ),
538
- 'id' => 'wcj_price_labels_enabled',
539
- 'default' => 'no',
540
- 'type' => 'checkbox',
541
- ),
 
 
 
 
 
 
 
 
 
 
 
542
 
543
- array( 'type' => 'sectionend', 'id' => 'wcj_price_labels_options' ),
544
 
545
  array(
546
- 'title' => __( 'Global Custom Price Labels', 'woocommerce-jetpack' ),
547
  'type' => 'title',
548
  'desc' => __( 'This section lets you set price labels for all products globally.', 'woocommerce-jetpack' ),
549
  'id' => 'wcj_global_price_labels_options',
@@ -622,12 +684,80 @@ class WCJ_Price_Labels {
622
  'css' => 'width:30%;min-width:300px;',
623
  ),
624
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
625
  array(
626
  'type' => 'sectionend',
627
  'id' => 'wcj_global_price_labels_options',
628
  ),
629
 
630
- array( 'title' => __( 'Migrate from Custom Price Labels (Pro) Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you enable "Migrate from Custom Price Labels (Pro)" tool.', 'woocommerce-jetpack' ), 'id' => 'wcj_migrate_from_custom_price_labels_options' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
631
 
632
  array(
633
  'title' => __( 'Enable', 'woocommerce-jetpack' ),
@@ -636,18 +766,16 @@ class WCJ_Price_Labels {
636
  'type' => 'checkbox',
637
  ),
638
 
639
- array( 'type' => 'sectionend', 'id' => 'wcj_migrate_from_custom_price_labels_options' ),
640
-
 
 
641
 
642
  );
643
 
 
644
  return $settings;
645
  }
646
-
647
- function settings_section( $sections ) {
648
- $sections['price_labels'] = __( 'Custom Price Labels', 'woocommerce-jetpack' );
649
- return $sections;
650
- }
651
  }
652
 
653
  endif;
4
  *
5
  * The WooCommerce Jetpack Price Labels class.
6
  *
7
+ * @version 2.3.7
8
  * @author Algoritmika Ltd.
9
  */
10
 
12
 
13
  if ( ! class_exists( 'WCJ_Price_Labels' ) ) :
14
 
15
+ class WCJ_Price_Labels extends WCJ_Module {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  /**
18
  * Constructor.
19
+ *
20
+ * @version 2.3.7
21
  */
22
  public function __construct() {
23
 
24
+ $this->id = 'price_labels';
25
+ $this->short_desc = __( 'Custom Price Labels', 'woocommerce-jetpack' );
26
+ $this->desc = __( 'Create any custom price label for any WooCommerce product.', 'woocommerce-jetpack' );
27
+ parent::__construct();
28
+
29
+ // Custom Price Labels - fields array
30
+ $this->custom_tab_group_name = 'wcj_price_labels';// for compatibility with Custom Price Label Pro plugin should use 'simple_is_custom_pricing_label'
31
+ $this->custom_tab_sections = array( '_instead', '_before', '_between', '_after', );
32
+ $this->custom_tab_sections_titles = array(
33
+ '_instead' => __( 'Instead of the price', 'woocommerce-jetpack' ),// for compatibility with Custom Price Label Pro plugin should use ''
34
+ '_before' => __( 'Before the price', 'woocommerce-jetpack' ),
35
+ '_between' => __( 'Between regular and sale prices', 'woocommerce-jetpack' ),
36
+ '_after' => __( 'After the price', 'woocommerce-jetpack' ),
37
+ );
38
+ $this->custom_tab_section_variations = array( '_text', '_enabled', '_home', '_products', '_single', '_page', '_cart', /*'_simple',*/ '_variable', '_variation', /*'_grouped',*/ );
39
+ $this->custom_tab_section_variations_titles = array(
40
+ '_text' => '',//'The label',
41
+ '_enabled' => __( 'Enable', 'woocommerce-jetpack' ),// for compatibility with Custom Price Label Pro plugin should use ''
42
+ '_home' => __( 'Hide on home page', 'woocommerce-jetpack' ),
43
+ '_products' => __( 'Hide on products page', 'woocommerce-jetpack' ),
44
+ '_single' => __( 'Hide on single', 'woocommerce-jetpack' ),
45
+ '_page' => __( 'Hide on all pages', 'woocommerce-jetpack' ),
46
+ '_cart' => __( 'Hide on cart page only', 'woocommerce-jetpack' ),
47
+ // '_simple' => __( 'Hide for simple product', 'woocommerce-jetpack' ),
48
+ '_variable' => __( 'Hide for main price', 'woocommerce-jetpack' ),
49
+ '_variation' => __( 'Hide for all variations', 'woocommerce-jetpack' ),
50
+ // '_grouped' => __( 'Hide for grouped product', 'woocommerce-jetpack' ),
51
+ );
52
 
53
+ add_action( 'init', array( $this, 'add_settings_hook' ) );
54
 
55
+ if ( $this->is_enabled() ) {
56
+
57
+ if ( is_admin() ) {
58
  if ( 'yes' === get_option( 'wcj_migrate_from_custom_price_labels_enabled' ) ) {
59
  // "Migrate from Custom Price Labels (Pro)" tool
60
  add_filter( 'wcj_tools_tabs', array( $this, 'add_migrate_from_custom_price_labels_tool_tab' ), 100 );
62
  }
63
  }
64
 
65
+ if ( 'yes' === get_option( 'wcj_local_price_labels_enabled' ) ) {
66
+ // Meta box (admin)
67
+ add_action( 'add_meta_boxes', array( $this, 'add_price_label_meta_box' ) );
68
+ add_action( 'save_post_product', array( $this, 'save_custom_price_labels' ), 999, 2 );
69
+ }
70
 
71
  // Prices Hooks
72
  $this->prices_filters = array(
105
  }
106
 
107
  add_action( 'wcj_tools_dashboard', array( $this, 'add_migrate_tool_info_to_tools_dashboard' ), 1000 );
 
 
 
 
 
108
  }
109
 
110
  /**
127
  */
128
  public function add_migrate_from_custom_price_labels_tool_tab( $tabs ) {
129
  $tabs[] = array(
130
+ 'id' => 'migrate_from_custom_price_labels',
131
+ 'title' => __( 'Migrate from Custom Price Labels', 'woocommerce-jetpack' ),
132
  );
133
  return $tabs;
134
  }
135
 
136
+ /**
137
+ * get_migration_new_meta_name.
138
+ */
139
+ /* public function get_migration_new_meta_name( $old_meta_name ) {
140
  $new_meta_name = str_replace( 'simple_is_custom_pricing_label', 'wcj_price_labels', $old_meta_name );
141
  return $new_meta_name;
142
+ } */
143
 
144
+ /**
145
+ * create_migrate_from_custom_price_labels_tool_tab.
146
+ */
147
  public function create_migrate_from_custom_price_labels_tool_tab() {
148
 
149
  echo '<h2>' . __( 'WooCommerce Jetpack - Migrate from Custom Price Labels (Pro)', 'woocommerce-jetpack' ) . '</h2>';
247
  echo $form_html . $html;
248
  }
249
 
 
 
 
 
 
250
  /**
251
+ * save_custom_price_labels.
252
  */
 
 
 
 
 
 
 
 
253
  public function save_custom_price_labels( $post_id, $post ) {
254
 
255
+ // $product = get_product( $post );TODO - do I need it?
256
 
257
  if ( ! isset( $_POST['woojetpack_price_labels_save_post'] ) )
258
  return;
261
 
262
  foreach ( $this->custom_tab_section_variations as $custom_tab_section_variation ) {
263
 
264
+ // $option_name = $this->custom_tab_group_name;
265
  $option_name = $this->custom_tab_group_name . $custom_tab_section . $custom_tab_section_variation;
266
 
267
  // if ( isset( $_POST[ $option_name ] ) ) update_post_meta( $post_id, '_' . $option_name, $_POST[ $option_name ] );
268
 
 
269
  if ( $custom_tab_section_variation == '_text' ) {
270
  //$option_name .= $custom_tab_section_variation . $custom_tab_section;
271
  if ( isset( $_POST[ $option_name ] ) ) update_post_meta( $post_id, '_' . $option_name, $_POST[ $option_name ] );
275
  if ( isset( $_POST[ $option_name ] ) ) update_post_meta( $post_id, '_' . $option_name, $_POST[ $option_name ] );
276
  else update_post_meta( $post_id, '_' . $option_name, 'off' );
277
  }
 
278
  }
279
  }
280
  }
281
 
282
+ /**
283
+ * add_price_label_meta_box.
284
+ */
285
  public function add_price_label_meta_box() {
 
286
  add_meta_box( 'wc-jetpack-price-labels', 'WooCommerce Jetpack: Custom Price Labels', array( $this, 'wcj_price_label' ), 'product', 'normal', 'high' );
287
  }
288
 
289
  /*
290
+ * wcj_price_label - back end.
291
  */
292
  public function wcj_price_label() {
293
 
409
  }
410
 
411
  /*
412
+ * custom_price - front end.
413
  *
414
+ * @version 2.3.7
415
  */
416
  public function custom_price( $price, $product ) {
417
 
418
  if ( ! wcj_is_frontend() ) return $price;
419
 
 
 
 
420
  $current_filter_name = current_filter();
421
 
422
  if ( ( 'woocommerce_get_price_html' === $current_filter_name ) && ( 'booking' !== $product->product_type ) )
425
  if ( 'woocommerce_cart_item_price' === $current_filter_name )
426
  $product = $product['data'];
427
 
428
+ $do_apply_global = true;
429
+ $products_incl = get_option( 'wcj_global_price_labels_products_incl', array() );
430
+ if ( ! empty( $products_incl ) ) $do_apply_global = ( in_array( $product->id, $products_incl ) ) ? true : false;
431
+ $products_excl = get_option( 'wcj_global_price_labels_products_excl', array() );
432
+ if ( ! empty( $products_excl ) ) $do_apply_global = ( in_array( $product->id, $products_excl ) ) ? false : true;
433
+ $product_categories = get_the_terms( $product->id, 'product_cat' );
434
+ $product_categories_incl = get_option( 'wcj_global_price_labels_product_cats_incl', array() );
435
+ if ( ! empty( $product_categories_incl ) ) {
436
+ $do_apply_global = false;
437
+ if ( ! empty( $product_categories ) ) {
438
+ foreach ( $product_categories as $product_category ) {
439
+ if ( in_array( $product_category->term_id, $product_categories_incl ) ) {
440
+ $do_apply_global = true;
441
+ break;
442
+ }
443
+ }
444
+ }
445
+ }
446
+ $product_categories_excl = get_option( 'wcj_global_price_labels_product_cats_excl', array() );
447
+ if ( ! empty( $product_categories_excl ) ) {
448
+ $do_apply_global = true;
449
+ if ( ! empty( $product_categories ) ) {
450
+ foreach ( $product_categories as $product_category ) {
451
+ if ( in_array( $product_category->term_id, $product_categories_excl ) ) {
452
+ $do_apply_global = false;
453
+ break;
454
+ }
455
+ }
456
+ }
457
+ }
458
+ if ( $do_apply_global ) {
459
+ // Global price labels - Add text before price
460
+ $text_to_add_before = apply_filters( 'wcj_get_option_filter', '', get_option( 'wcj_global_price_labels_add_before_text' ) );
461
+ if ( '' != $text_to_add_before )
462
+ $price = $text_to_add_before . $price;
463
+ // Global price labels - Add text after price
464
+ $text_to_add_after = get_option( 'wcj_global_price_labels_add_after_text' );
465
+ if ( '' != $text_to_add_after )
466
+ $price = $price . $text_to_add_after;
467
+
468
+ // Global price labels - Between regular and sale prices
469
+ $text_to_add_between_regular_and_sale = get_option( 'wcj_global_price_labels_between_regular_and_sale_text' );
470
+ if ( '' != $text_to_add_between_regular_and_sale )
471
+ $price = apply_filters( 'wcj_get_option_filter', $price, str_replace( '</del> <ins>', '</del>' . $text_to_add_between_regular_and_sale . '<ins>', $price ) );
472
+
473
+ // Global price labels - Remove text from price
474
+ $text_to_remove = apply_filters( 'wcj_get_option_filter', '', get_option( 'wcj_global_price_labels_remove_text' ) );
475
+ if ( '' != $text_to_remove )
476
+ $price = str_replace( $text_to_remove, '', $price );
477
+ // Global price labels - Replace in price
478
+ $text_to_replace = apply_filters( 'wcj_get_option_filter', '', get_option( 'wcj_global_price_labels_replace_text' ) );
479
+ $text_to_replace_with = apply_filters( 'wcj_get_option_filter', '', get_option( 'wcj_global_price_labels_replace_with_text' ) );
480
+ if ( '' != $text_to_replace && '' != $text_to_replace_with )
481
+ $price = str_replace( $text_to_replace, $text_to_replace_with, $price );
482
+ }
483
 
484
+ // Per product
485
+ if ( 'yes' === get_option( 'wcj_local_price_labels_enabled' ) ) {
486
 
487
+ foreach ( $this->custom_tab_sections as $custom_tab_section ) {
488
 
489
+ $labels_array = array();
490
 
491
+ foreach ( $this->custom_tab_section_variations as $custom_tab_section_variation ) {
 
 
492
 
493
+ //$option_name = $this->custom_tab_group_name;
494
+ $option_name = $this->custom_tab_group_name . $custom_tab_section . $custom_tab_section_variation;
495
+ $labels_array[ 'variation' . $custom_tab_section_variation ] = get_post_meta( $product->post->ID, '_' . $option_name, true );
496
 
497
+ /* if ( $custom_tab_section_variation == '_text' ) {
 
 
 
498
 
499
+ //$option_name .= $custom_tab_section_variation . $custom_tab_section;
500
+ $labels_array[ 'variation' . $custom_tab_section_variation ] = get_post_meta($product->post->ID, '_' . $option_name, true );
501
+ }
502
+ else {
503
 
504
+ //$option_name .= $custom_tab_section . $custom_tab_section_variation;
505
+ $labels_array[ 'variation' . $custom_tab_section_variation ] = get_post_meta($product->post->ID, '_' . $option_name, true);
506
+ } */
507
 
508
+ //$price .= print_r( $labels_array );
509
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
510
 
511
+ if ( 'on' === $labels_array[ 'variation_enabled' ] ) {
512
+
513
+ if (
514
+ ( ( 'off' === $labels_array['variation_home'] ) && ( is_front_page() ) ) ||
515
+ ( ( 'off' === $labels_array['variation_products'] ) && ( is_archive() ) ) ||
516
+ ( ( 'off' === $labels_array['variation_single'] ) && ( is_single() ) ) ||
517
+ ( ( 'off' === $labels_array['variation_page'] ) && ( is_page() ) )
518
+ )
519
+ {
520
+ //$current_filter_name = current_filter();
521
+ if ( 'woocommerce_cart_item_price' === $current_filter_name && 'on' === $labels_array['variation_cart'] )
522
+ continue;
523
+
524
+ $variable_filters_array = array(
525
+ 'woocommerce_variable_empty_price_html',
526
+ 'woocommerce_variable_free_price_html',
527
+ 'woocommerce_variable_free_sale_price_html',
528
+ 'woocommerce_variable_price_html',
529
+ 'woocommerce_variable_sale_price_html',
530
+ );
531
+
532
+ $variation_filters_array = array(
533
+ 'woocommerce_variation_empty_price_html',
534
+ 'woocommerce_variation_free_price_html',
535
+ //woocommerce_variation_option_name
536
+ 'woocommerce_variation_price_html',
537
+ 'woocommerce_variation_sale_price_html',
538
+ );
539
+
540
+ if (
541
+ ( in_array( $current_filter_name, $variable_filters_array ) && ( $labels_array['variation_variable'] == 'off' ) ) ||
542
+ ( in_array( $current_filter_name, $variation_filters_array ) && ( $labels_array['variation_variation'] == 'off' ) ) ||
543
+ ( ! in_array( $current_filter_name, $variable_filters_array ) && ! in_array( $current_filter_name, $variation_filters_array ) )
544
+ )
545
+ $price = $this->customize_price( $price, $custom_tab_section, $labels_array['variation_text'] );
546
+ }
547
+ }
548
+
549
+ //unset( $labels_array );
550
+ }
551
  }
552
 
553
  return do_shortcode( $price );
554
  }
555
 
556
+ /**
557
+ * get_settings.
558
+ *
559
+ * @version 2.3.7
560
+ */
561
  function get_settings() {
562
+ $settings = array();
563
+ $settings = apply_filters( 'wcj_price_labels_settings', $settings );
564
+ return $this->add_enable_module_setting( $settings );
565
+ }
566
 
567
+ /*
568
+ * add_settings_hook.
569
+ *
570
+ * @version 2.3.7
571
+ * @since 2.3.7
572
+ */
573
+ function add_settings_hook() {
574
+ add_filter( 'wcj_price_labels_settings', array( $this, 'add_settings' ) );
575
+ }
576
 
577
+ /*
578
+ * add_settings.
579
+ *
580
+ * @version 2.3.7
581
+ * @since 2.3.7
582
+ */
583
+ function add_settings() {
584
 
585
+ $product_cats = array();
586
+ $product_categories = get_terms( 'product_cat', 'orderby=name&hide_empty=0' );
587
+ foreach ( $product_categories as $product_category ) {
588
+ $product_cats[ $product_category->term_id ] = $product_category->name;
589
+ }
590
+
591
+ $products = array();
592
+ $args = array(
593
+ 'post_type' => 'product',
594
+ 'post_status' => 'any',
595
+ 'posts_per_page' => -1,
596
+ );
597
+ $loop = new WP_Query( $args );
598
+ if ( $loop->have_posts() ) {
599
+ while ( $loop->have_posts() ) : $loop->the_post();
600
+ $products[ strval( $loop->post->ID ) ] = get_the_title( $loop->post->ID );
601
+ endwhile;
602
+ wp_reset_postdata();
603
+ }
604
 
605
+ $settings = array(
606
 
607
  array(
608
+ 'title' => __( 'Custom Price Labels - Globally', 'woocommerce-jetpack' ),
609
  'type' => 'title',
610
  'desc' => __( 'This section lets you set price labels for all products globally.', 'woocommerce-jetpack' ),
611
  'id' => 'wcj_global_price_labels_options',
684
  'css' => 'width:30%;min-width:300px;',
685
  ),
686
 
687
+ array(
688
+ 'title' => __( 'Products - Include', 'woocommerce-jetpack' ),
689
+ 'desc_tip' => __( 'Apply global price labels only for selected products. Leave blank to disable the option.', 'woocommerce-jetpack' ),
690
+ 'id' => 'wcj_global_price_labels_products_incl',
691
+ 'default' => '',
692
+ 'type' => 'multiselect',
693
+ 'class' => 'chosen_select',
694
+ 'css' => 'width: 450px;',
695
+ 'options' => $products,
696
+ ),
697
+
698
+ array(
699
+ 'title' => __( 'Products - Exclude', 'woocommerce-jetpack' ),
700
+ 'desc_tip' => __( 'Do not apply global price labels only for selected products. Leave blank to disable the option.', 'woocommerce-jetpack' ),
701
+ 'id' => 'wcj_global_price_labels_products_excl',
702
+ 'default' => '',
703
+ 'type' => 'multiselect',
704
+ 'class' => 'chosen_select',
705
+ 'css' => 'width: 450px;',
706
+ 'options' => $products,
707
+ ),
708
+
709
+ array(
710
+ 'title' => __( 'Product Categories - Include', 'woocommerce-jetpack' ),
711
+ 'desc_tip' => __( 'Apply global price labels only for selected product categories. Leave blank to disable the option.', 'woocommerce-jetpack' ),
712
+ 'id' => 'wcj_global_price_labels_product_cats_incl',
713
+ 'default' => '',
714
+ 'type' => 'multiselect',
715
+ 'class' => 'chosen_select',
716
+ 'css' => 'width: 450px;',
717
+ 'options' => $product_cats,
718
+ ),
719
+
720
+ array(
721
+ 'title' => __( 'Product Categories - Exclude', 'woocommerce-jetpack' ),
722
+ 'desc_tip' => __( 'Do not apply global price labels only for selected product categories. Leave blank to disable the option.', 'woocommerce-jetpack' ),
723
+ 'id' => 'wcj_global_price_labels_product_cats_excl',
724
+ 'default' => '',
725
+ 'type' => 'multiselect',
726
+ 'class' => 'chosen_select',
727
+ 'css' => 'width: 450px;',
728
+ 'options' => $product_cats,
729
+ ),
730
+
731
  array(
732
  'type' => 'sectionend',
733
  'id' => 'wcj_global_price_labels_options',
734
  ),
735
 
736
+ array(
737
+ 'title' => __( 'Custom Price Labels - Per Product', 'woocommerce-jetpack' ),
738
+ 'type' => 'title',
739
+ 'id' => 'wcj_local_price_labels_options'
740
+ ),
741
+
742
+ array(
743
+ 'title' => __( 'Enable', 'woocommerce-jetpack' ),
744
+ 'desc' => __( 'This will add metaboxes to each product\'s admin edit page.', 'woocommerce-jetpack' ),
745
+ 'id' => 'wcj_local_price_labels_enabled',
746
+ 'default' => 'yes',
747
+ 'type' => 'checkbox',
748
+ ),
749
+
750
+ array(
751
+ 'type' => 'sectionend',
752
+ 'id' => 'wcj_local_price_labels_options'
753
+ ),
754
+
755
+ array(
756
+ 'title' => __( 'Migrate from Custom Price Labels (Pro) Options', 'woocommerce-jetpack' ),
757
+ 'type' => 'title',
758
+ 'desc' => __( 'This section lets you enable "Migrate from Custom Price Labels (Pro)" tool.', 'woocommerce-jetpack' ),
759
+ 'id' => 'wcj_migrate_from_custom_price_labels_options'
760
+ ),
761
 
762
  array(
763
  'title' => __( 'Enable', 'woocommerce-jetpack' ),
766
  'type' => 'checkbox',
767
  ),
768
 
769
+ array(
770
+ 'type' => 'sectionend',
771
+ 'id' => 'wcj_migrate_from_custom_price_labels_options'
772
+ ),
773
 
774
  );
775
 
776
+ //return $this->add_enable_module_setting( $settings );
777
  return $settings;
778
  }
 
 
 
 
 
779
  }
780
 
781
  endif;
includes/class-wcj-product-tabs.php CHANGED
@@ -90,7 +90,7 @@ class WCJ_Product_Tabs extends WCJ_Module {
90
  $do_exclude = false;
91
  $product_categories_objects = get_the_terms( $product->id, 'product_cat' );
92
  if ( $product_categories_objects && ! empty( $product_categories_objects ) ) {
93
- foreach ( $product_categories_objects as $product_categories_object ) {
94
  if ( $product && $array_to_exclude && in_array( $product_categories_object->term_id, $array_to_exclude ) ) {
95
  $do_exclude = true;
96
  break;
90
  $do_exclude = false;
91
  $product_categories_objects = get_the_terms( $product->id, 'product_cat' );
92
  if ( $product_categories_objects && ! empty( $product_categories_objects ) ) {
93
+ foreach ( $product_categories_objects as $product_categories_object ) {
94
  if ( $product && $array_to_exclude && in_array( $product_categories_object->term_id, $array_to_exclude ) ) {
95
  $do_exclude = true;
96
  break;
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.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -120,6 +120,8 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
120
 
121
  /**
122
  * add_pdf_invoices_action_links.
 
 
123
  */
124
  function add_pdf_invoices_action_links( $actions, $the_order ) {
125
 
@@ -147,7 +149,8 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
147
  }
148
  $the_url = add_query_arg( $query_args );
149
 
150
- $the_name = $invoice_type['desc'];
 
151
  $the_action = 'view ' . $invoice_type['id'];
152
 
153
  /* if ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_save_as_enabled', 'no' ) ) {
@@ -163,6 +166,8 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
163
 
164
  /**
165
  * get_settings.
 
 
166
  */
167
  function get_settings() {
168
 
@@ -170,7 +175,11 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
170
  $invoice_types = wcj_get_invoice_types();
171
  foreach ( $invoice_types as $invoice_type ) {
172
 
173
- $settings[] = array( 'title' => strtoupper( $invoice_type['desc'] ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_display_options' );
 
 
 
 
174
 
175
  $settings = array_merge( $settings, array(
176
 
@@ -189,7 +198,6 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
189
 
190
  array(
191
  'title' => __( 'Customer\'s "My Account" Page', 'woocommerce-jetpack' ),
192
- // 'desc' => __( 'Enable the PDF Invoices in customers account', 'woocommerce-jetpack' ),
193
  'desc' => __( 'Add link', 'woocommerce-jetpack' ),
194
  'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
195
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_enabled_for_customers',
@@ -198,15 +206,23 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
198
  'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
199
  ),
200
 
 
 
 
 
 
 
 
 
 
 
201
  array(
202
  'title' => __( 'Enable "Save as"', 'woocommerce-jetpack' ),
203
  'desc' => __( 'Enable', 'woocommerce-jetpack' ),
204
  'desc_tip' => __( 'Enable "save as" pdf instead of view pdf in browser', 'woocommerce-jetpack' ),
205
- // 'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
206
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_save_as_enabled',
207
  'default' => 'yes',
208
  'type' => 'checkbox',
209
- // 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
210
  ),
211
 
212
  array(
@@ -218,7 +234,10 @@ class WCJ_PDF_Invoicing_Display extends WCJ_Module {
218
  ),
219
  ) );
220
 
221
- $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_display_options' );
 
 
 
222
  }
223
 
224
  return $settings;
4
  *
5
  * The WooCommerce Jetpack PDF Invoicing Display class.
6
  *
7
+ * @version 2.3.7
8
  * @author Algoritmika Ltd.
9
  */
10
 
120
 
121
  /**
122
  * add_pdf_invoices_action_links.
123
+ *
124
+ * @version 2.3.7
125
  */
126
  function add_pdf_invoices_action_links( $actions, $the_order ) {
127
 
149
  }
150
  $the_url = add_query_arg( $query_args );
151
 
152
+ $the_name = get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_link_text' );
153
+ if ( '' == $the_name ) $the_name = $invoice_type['title'];
154
  $the_action = 'view ' . $invoice_type['id'];
155
 
156
  /* if ( 'yes' === get_option( 'wcj_invoicing_' . $invoice_type['id'] . '_save_as_enabled', 'no' ) ) {
166
 
167
  /**
168
  * get_settings.
169
+ *
170
+ * @version 2.3.7
171
  */
172
  function get_settings() {
173
 
175
  $invoice_types = wcj_get_invoice_types();
176
  foreach ( $invoice_types as $invoice_type ) {
177
 
178
+ $settings[] = array(
179
+ 'title' => strtoupper( $invoice_type['desc'] ),
180
+ 'type' => 'title',
181
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_display_options',
182
+ );
183
 
184
  $settings = array_merge( $settings, array(
185
 
198
 
199
  array(
200
  'title' => __( 'Customer\'s "My Account" Page', 'woocommerce-jetpack' ),
 
201
  'desc' => __( 'Add link', 'woocommerce-jetpack' ),
202
  'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
203
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_enabled_for_customers',
206
  'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
207
  ),
208
 
209
+ array(
210
+ 'title' => '',
211
+ 'desc' => __( 'Link Text', 'woocommerce-jetpack' ),
212
+ 'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc_no_link' ),
213
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_link_text',
214
+ 'default' => $invoice_type['title'],
215
+ 'type' => 'text',
216
+ 'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
217
+ ),
218
+
219
  array(
220
  'title' => __( 'Enable "Save as"', 'woocommerce-jetpack' ),
221
  'desc' => __( 'Enable', 'woocommerce-jetpack' ),
222
  'desc_tip' => __( 'Enable "save as" pdf instead of view pdf in browser', 'woocommerce-jetpack' ),
 
223
  'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_save_as_enabled',
224
  'default' => 'yes',
225
  'type' => 'checkbox',
 
226
  ),
227
 
228
  array(
234
  ),
235
  ) );
236
 
237
+ $settings[] = array(
238
+ 'type' => 'sectionend',
239
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_display_options',
240
+ );
241
  }
242
 
243
  return $settings;
includes/pdf-invoices/settings/class-wcj-pdf-invoicing-templates.php CHANGED
@@ -4,69 +4,69 @@
4
  *
5
  * The WooCommerce Jetpack PDF Invoices Templates class.
6
  *
7
- * @class WCJ_PDF_Invoicing_Templates
8
- * @version 1.0.0
9
- * @category Class
10
- * @author Algoritmika Ltd.
11
  */
12
-
13
  if ( ! defined( 'ABSPATH' ) ) exit;
14
-
15
  if ( ! class_exists( 'WCJ_PDF_Invoicing_Templates' ) ) :
16
-
17
- class WCJ_PDF_Invoicing_Templates {
18
-
19
- /**
20
- * Constructor.
21
- */
22
- public function __construct() {
23
- // Settings hooks
24
- add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
25
- add_filter( 'wcj_settings_pdf_invoicing_templates', array( $this, 'get_settings' ), 100 );
26
- }
27
-
28
- /**
29
- * get_settings.
30
- */
31
- function get_settings() {
32
-
33
- $settings = array();
 
 
 
 
 
34
  $invoice_types = wcj_get_invoice_types();
35
  foreach ( $invoice_types as $invoice_type ) {
36
-
37
  ob_start();
38
  include( 'defaults/wcj-content-template-' . $invoice_type['id'] . '.php' );
39
- $default_template = ob_get_clean();
40
-
41
- $settings[] = array( 'title' => strtoupper( $invoice_type['desc'] ), 'type' => 'title', 'desc' => '', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_templates_options' );
 
 
 
 
42
  $settings[] = array(
43
- 'title' => __( 'HTML Template', 'woocommerce-jetpack' ),
44
- //'title' => $invoice_type['title'],
45
- 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_template',
46
- 'default' => $default_template,
47
- 'type' => 'textarea',
48
- 'css' => 'width:66%;min-width:300px;height:500px;',
49
- );
50
- $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_templates_options' );
 
 
51
  }
52
-
53
- $settings[] = array( 'title' => __( 'Available Shortcodes', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => wcj_get_shortcodes_list(), 'id' => 'wcj_invoicing_templates_desc' );
54
- $settings[] = array( 'type' => 'sectionend', 'id' => 'wcj_invoicing_templates_desc' );
55
 
56
- ;
57
-
58
- return $settings;
59
- }
60
-
61
- /**
62
- * settings_section.
63
- */
64
- function settings_section( $sections ) {
65
- $sections['pdf_invoicing_templates'] = __( 'Templates', 'woocommerce-jetpack' );
66
- return $sections;
67
- }
68
  }
69
-
70
  endif;
71
-
72
- return new WCJ_PDF_Invoicing_Templates();
4
  *
5
  * The WooCommerce Jetpack PDF Invoices Templates class.
6
  *
7
+ * @version 2.3.7
8
+ * @author Algoritmika Ltd.
 
 
9
  */
10
+
11
  if ( ! defined( 'ABSPATH' ) ) exit;
12
+
13
  if ( ! class_exists( 'WCJ_PDF_Invoicing_Templates' ) ) :
14
+
15
+ class WCJ_PDF_Invoicing_Templates extends WCJ_Module {
16
+
17
+ /**
18
+ * Constructor.
19
+ *
20
+ * @version 2.3.7
21
+ */
22
+ function __construct() {
23
+ $this->id = 'pdf_invoicing_templates';
24
+ $this->parent_id = 'pdf_invoicing';
25
+ $this->short_desc = __( 'Templates', 'woocommerce-jetpack' );
26
+ $this->desc = '';
27
+ parent::__construct( 'submodule' );
28
+ }
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();
41
  include( 'defaults/wcj-content-template-' . $invoice_type['id'] . '.php' );
42
+ $default_template = ob_get_clean();
43
+
44
+ $settings[] = array(
45
+ 'title' => strtoupper( $invoice_type['desc'] ),
46
+ 'type' => 'title',
47
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_templates_options',
48
+ );
49
  $settings[] = array(
50
+ 'title' => __( 'HTML Template', 'woocommerce-jetpack' ),
51
+ 'id' => 'wcj_invoicing_' . $invoice_type['id'] . '_template',
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
+ }
67
+
 
 
 
 
 
 
68
  }
69
+
70
  endif;
71
+
72
+ return new WCJ_PDF_Invoicing_Templates();
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.0
8
  * @author Algoritmika Ltd.
9
  */
10
 
@@ -17,7 +17,7 @@ class WCJ_General_Shortcodes extends WCJ_Shortcodes {
17
  /**
18
  * Constructor.
19
  *
20
- * @version 2.3.0
21
  */
22
  public function __construct() {
23
 
@@ -29,6 +29,7 @@ class WCJ_General_Shortcodes extends WCJ_Shortcodes {
29
  'wcj_wpml_translate',
30
  'wcj_country_select_drop_down_list',
31
  'wcj_text',
 
32
  );
33
 
34
  $this->the_atts = array(
@@ -48,6 +49,16 @@ class WCJ_General_Shortcodes extends WCJ_Shortcodes {
48
 
49
  }
50
 
 
 
 
 
 
 
 
 
 
 
51
  /**
52
  * wcj_country_select_drop_down_list.
53
  *
4
  *
5
  * The WooCommerce Jetpack General Shortcodes class.
6
  *
7
+ * @version 2.3.7
8
  * @author Algoritmika Ltd.
9
  */
10
 
17
  /**
18
  * Constructor.
19
  *
20
+ * @version 2.3.7
21
  */
22
  public function __construct() {
23
 
29
  'wcj_wpml_translate',
30
  'wcj_country_select_drop_down_list',
31
  'wcj_text',
32
+ 'wcj_tcpdf_pagebreak',
33
  );
34
 
35
  $this->the_atts = array(
49
 
50
  }
51
 
52
+ /**
53
+ * wcj_tcpdf_pagebreak.
54
+ *
55
+ * @version 2.3.7
56
+ * @since 2.3.7
57
+ */
58
+ function wcj_tcpdf_pagebreak( $atts, $content ) {
59
+ return '<tcpdf method="AddPage" />';
60
+ }
61
+
62
  /**
63
  * wcj_country_select_drop_down_list.
64
  *
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://algoritmika.com/donate/
4
  Tags: woocommerce,booster for woocommerce,woocommerce jetpack,custom price labels,call for price,currency symbol,remove sorting,remove old product slugs,add to cart text,order number,sequential order numbering,email pdf invoice,pdf invoice,pdf invoices,already in cart,empty cart,redirect to checkout,minimum order amount,customize checkout fields,checkout fields,email,customize product tabs,product tabs,related products number,empty cart,redirect add to cart,redirect to checkout,product already in cart,custom payment gateway,payment gateway icon,auto-complete all orders,custom order statuses,custom order status,remove text from price,custom css,hide categories count,hide subcategories count,hide category count,hide subcategory count,display total sales,custom product tabs,remove product tab,payment gateway fee,
5
  Requires at least: 3.8
6
  Tested up to: 4.3
7
- Stable tag: 2.3.6
8
  License: GNU General Public License v3.0
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -116,6 +116,19 @@ To unlock all Booster for WooCommerce features, please install additional <a hre
116
 
117
  == Changelog ==
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  = 2.3.6 - 06/10/2015 =
120
  * Fix - Orders Shortcodes - `[wcj_order_checkout_field]` bug fixed.
121
 
4
  Tags: woocommerce,booster for woocommerce,woocommerce jetpack,custom price labels,call for price,currency symbol,remove sorting,remove old product slugs,add to cart text,order number,sequential order numbering,email pdf invoice,pdf invoice,pdf invoices,already in cart,empty cart,redirect to checkout,minimum order amount,customize checkout fields,checkout fields,email,customize product tabs,product tabs,related products number,empty cart,redirect add to cart,redirect to checkout,product already in cart,custom payment gateway,payment gateway icon,auto-complete all orders,custom order statuses,custom order status,remove text from price,custom css,hide categories count,hide subcategories count,hide category count,hide subcategory count,display total sales,custom product tabs,remove product tab,payment gateway fee,
5
  Requires at least: 3.8
6
  Tested up to: 4.3
7
+ Stable tag: 2.3.7
8
  License: GNU General Public License v3.0
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
116
 
117
  == Changelog ==
118
 
119
+ = 2.3.7 - 17/10/2015 =
120
+ * Dev - General Shortcodes - `[wcj_tcpdf_pagebreak]` shortcode added.
121
+ * Dev - BUTTON & PRICE LABELS - Custom Price Labels - Global labels - Products/Categories Include/Exclude options added.
122
+ * Dev - BUTTON & PRICE LABELS - Custom Price Labels - Code refactoring. Enable/disable *per product* labels option added.
123
+ * Fix - CART & CHECKOUT - Checkout Custom Fields - Bug, when displaying custom order checkout fields in emails and order details, fixed.
124
+ * Dev - PAYMENT GATEWAYS - "Gateways per Category" module renamed to "Gateways per Product or Category".
125
+ * Dev - PAYMENT GATEWAYS - Gateways per Category - "Products - Include" and "Products - Exclude" options added.
126
+ * Dev - PAYMENT GATEWAYS - Gateways per Category - "Product Categories - Exclude" option added.
127
+ * Fix - SHIPPING & ORDERS - Orders - Order Minimum Amount - Additional is_object check added (bug caused PHP Notice).
128
+ * Dev - SHIPPING & ORDERS - Orders - Module description updated.
129
+ * Dev - PDF INVOICING & PACKING SLIPS - Templates - Code refactoring.
130
+ * Dev - PDF INVOICING & PACKING SLIPS - Misc. - Option to customize invoice *link text on customer's account page* added.
131
+
132
  = 2.3.6 - 06/10/2015 =
133
  * Fix - Orders Shortcodes - `[wcj_order_checkout_field]` bug fixed.
134
 
woocommerce-jetpack.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Booster for WooCommerce
4
  Plugin URI: http://BoostWoo.com
5
  Description: Supercharge your WooCommerce site with these awesome powerful features.
6
- Version: 2.3.6
7
  Author: Algoritmika Ltd
8
  Author URI: http://www.algoritmika.com
9
  Copyright: © 2015 Algoritmika Ltd.
3
  Plugin Name: Booster for WooCommerce
4
  Plugin URI: http://BoostWoo.com
5
  Description: Supercharge your WooCommerce site with these awesome powerful features.
6
+ Version: 2.3.7
7
  Author: Algoritmika Ltd
8
  Author URI: http://www.algoritmika.com
9
  Copyright: © 2015 Algoritmika Ltd.