Booster for WooCommerce - Version 1.5.0

Version Description

  • 13/09/2014 =
  • Dev - Orders - Renumerate orders tool compatibility with WooCommerce 2.2.x.
  • Dev - Orders - Custom Order Statuses compatibility with WooCommerce 2.2.x.
  • Dev - Orders - Renumerate orders tool moved to WooCommerce > Jetpack Tools.
  • Fix - PDF Invoices - Order Shipping Price position in Totals on admin settings page, fixed.
  • Dev - PDF Invoices - Save as pdf option added.
Download this release

Release Info

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

Code changes from version 1.4.0 to 1.5.0

includes/class-wcj-orders.php CHANGED
@@ -5,59 +5,97 @@
5
  * The WooCommerce Jetpack Orders class.
6
  *
7
  * @class WCJ_Orders
8
- * @version 1.1.0
9
  * @category Class
10
- * @author Algoritmika Ltd.
11
  */
12
-
13
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
-
15
  if ( ! class_exists( 'WCJ_Orders' ) ) :
16
-
17
  class WCJ_Orders {
18
-
19
  /**
20
  * Constructor.
21
  */
22
  public function __construct() {
23
-
 
 
 
 
 
 
 
 
 
 
 
24
  // Main hooks
25
  if ( get_option( 'wcj_orders_enabled' ) == 'yes' ) {
26
-
27
- if ( get_option( 'wcj_order_numbers_enabled' ) == 'yes' ) {
28
-
29
- add_action( 'woocommerce_new_order', array( $this, 'add_order_number_meta' ), 100 );
30
- add_filter( 'woocommerce_order_number', array( $this, 'display_order_number' ), 100, 2 );
31
-
32
- add_action( 'admin_menu', array( $this, 'add_renumerate_orders_tool' ), 100 );
33
- }
34
-
35
- if ( get_option( 'wcj_order_minimum_amount' ) > 0 ) {
36
  add_action( 'woocommerce_checkout_process', array( $this, 'order_minimum_amount' ) );
37
- add_action( 'woocommerce_before_cart', array( $this, 'order_minimum_amount' ) );
38
  }
39
-
40
  if ( 'yes' === get_option( 'wcj_orders_custom_statuses_enabled' ) ) {
41
- //add_action( 'admin_menu', array( $this, 'add_custom_statuses_tool' ), 100 );
42
- add_action( 'admin_head', array( $this, 'hook_statuses_icons_css' ) );
43
- add_filter( 'wcj_tools_tabs', array( $this, 'add_custom_statuses_tool_tab' ), 100 );
44
- add_action( 'wcj_tools_custom_statuses', array( $this, 'create_custom_statuses_tool' ), 100 );
 
45
  }
46
- add_action( 'wcj_tools_dashboard', array( $this, 'add_custom_statuses_tool_info_to_tools_dashboard' ), 100 );
47
-
48
  if ( 'yes' === get_option( 'wcj_order_auto_complete_enabled' ) )
49
- add_action( 'woocommerce_thankyou', array( $this, 'auto_complete_order' ) );
50
  }
51
-
52
- // woocommerce_admin_field_text_and_button / add_text_and_button_settings_fields
53
- //add_action( 'woocommerce_admin_field_text_and_button', array( $this, 'add_text_and_button_settings_fields' ) );
54
-
55
  // Settings hooks
56
- add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
57
- add_filter( 'wcj_settings_orders', array( $this, 'get_settings' ), 100 );
58
- add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
59
  }
60
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  /**
62
  * add_custom_statuses_tool_info_to_tools_dashboard.
63
  */
@@ -67,151 +105,80 @@ class WCJ_Orders {
67
  else
68
  echo '<h3>Custom Statuses tool is disabled.</h3>';
69
  echo '<p>The tool lets you add or delete any custom status for WooCommerce orders.</p>';
70
- }
71
-
72
  /**
73
  * add_custom_statuses_tool_tab.
74
  */
75
  public function add_custom_statuses_tool_tab( $tabs ) {
76
  $tabs[] = array(
77
  'id' => 'custom_statuses',
78
- 'title' => __( 'Custom Statuses', 'woocommerce-jetpack' ),
79
  );
80
  return $tabs;
81
- }
82
-
83
- /**
84
- * Auto Complete all WooCommerce orders.
85
- */
86
- public function auto_complete_order( $order_id ) {
87
-
88
- global $woocommerce;
89
-
90
- if ( !$order_id )
91
- return;
92
- $order = new WC_Order( $order_id );
93
- $order->update_status( 'completed' );
94
- }
95
 
96
  /**
97
- * order_minimum_amount.
 
98
  */
99
- public function order_minimum_amount() {
100
-
101
- $minimum = get_option( 'wcj_order_minimum_amount' );
102
- if ( WC()->cart->total < $minimum ) {
103
-
104
- if( is_cart() ) {
105
- if ( 'yes' === get_option( 'wcj_order_minimum_amount_cart_notice_enabled' ) ) {
106
- wc_print_notice(
107
- 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' ) ),
108
- woocommerce_price( $minimum ),
109
- woocommerce_price( WC()->cart->total )
110
- ), 'notice'
111
- );
112
- }
113
- } else {
114
- wc_add_notice(
115
- 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' ) ),
116
- woocommerce_price( $minimum ),
117
- woocommerce_price( WC()->cart->total )
118
- ), 'error'
119
- );
120
- }
121
- }
122
- }
123
-
124
- /**
125
- * add_custom_statuses_tool to WooCommerce menu (menu link).
126
- *
127
- public function add_custom_statuses_tool() {
128
-
129
- add_submenu_page( 'woocommerce', 'Jetpack - Custom Statuses', 'Custom Statuses', 'manage_options', 'woocommerce-jetpack-custom-statuses', array( $this, 'create_custom_statuses_tool' ) );
130
- }
131
-
132
- /**
133
- * add_custom_statuses_tool to WooCommerce menu (the content).
134
- */
135
-
136
-
137
- // TODO: content, color
138
  public function hook_statuses_icons_css() {
139
  $output = '<style>';
140
-
141
-
142
- $default_statuses = array(
143
- 'pending',
144
- 'failed',
145
- 'on-hold',
146
- 'processing',
147
- 'completed',
148
- 'refunded',
149
- 'cancelled',
150
- );
151
- $statuses = (array) get_terms( 'shop_order_status', array( 'hide_empty' => 0, 'orderby' => 'id' ) );
152
- foreach( $statuses as $status )
153
- if ( ! in_array( $status->slug, $default_statuses ) ) {
154
- $output .= 'mark.' . $status->slug . '::after { content: "\e011"; color: #999; }';
155
- $output .= 'mark.' . $status->slug . ':after {font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;margin:0;text-indent:0;position:absolute;top:0;left:0;width:100%;height:100%;text-align:center}';
156
  }
157
-
158
-
159
- //$output .= '.close { .ir;&:before { .icon("\e013"); }}';
160
- //$output .= '.close:before { .iconbefore("\e02d"); }';
161
  $output .= '.close:after { content: "\e011"; }';
162
-
163
  $output .= '</style>';
164
  echo $output;
165
  }
166
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
  public function create_custom_statuses_tool() {
168
-
169
  $result_message = '';
170
- if ( isset( $_POST['add_custom_status'] ) && isset( $_POST['new_status'] ) ) {
171
- //$this->renumerate_orders();
172
- if ( $_POST['new_status'] != '' ) {
173
-
174
- $result = wp_insert_term( $_POST['new_status'], 'shop_order_status' );//, array( 'color' => '#999', ) );
175
- if ( $result > 0 ) $result_message = '<div class="updated"><p>' . __( 'New status have been successfully added!', 'woocommerce-jetpack' ) . '</p></div>';
176
- else $result_message = '<div class="error"><p>' . __( 'Status was not added.', 'woocommerce-jetpack' ) . '</p></div>';
177
- //$result_message = '<div class="updated"><p><strong>' . $_POST['new_status'] . ':' . $_POST['add_custom_status'] . '</strong></p></div>';
178
-
179
- }
180
- else $result_message = '<div class="error"><p>' . __( 'Status name is empty. Status not added.', 'woocommerce-jetpack' ) . '</p></div>';
181
- }
182
-
183
- if ( isset( $_GET['delete'] ) && ( $_GET['delete'] > 0 ) ) {
184
- if ( true === wp_delete_term( $_GET['delete'], 'shop_order_status' ) )
185
  $result_message = '<div class="updated"><p>' . __( 'Status have been successfully deleted.', 'woocommerce-jetpack' ) . '</p></div>';
186
  else
187
  $result_message = '<div class="error"><p>' . __( 'Delete failed.', 'woocommerce-jetpack' ) . '</p></div>';
188
  }
189
-
190
- /*
191
- stdClass Object
192
- (
193
- [term_id] => 6
194
- [name] => pending
195
- [slug] => pending
196
- [term_group] => 0
197
- [term_taxonomy_id] => 6
198
- [taxonomy] => shop_order_status
199
- [description] =>
200
- [parent] => 0
201
- [count] => 0
202
- )
203
- */
204
-
205
- $default_statuses = array(
206
- 'pending',
207
- 'failed',
208
- 'on-hold',
209
- 'processing',
210
- 'completed',
211
- 'refunded',
212
- 'cancelled',
213
- );
214
-
215
  ?><div>
216
  <h2><?php echo __( 'WooCommerce Jetpack - Custom Statuses', 'woocommerce-jetpack' ); ?></h2>
217
  <p><?php echo __( 'The tool lets you add or delete any custom status for WooCommerce orders.', 'woocommerce-jetpack' ); ?></p>
@@ -219,60 +186,84 @@ class WCJ_Orders {
219
  <h3><?php echo __( 'Statuses', 'woocommerce-jetpack' ); ?></h3>
220
  <table class="wc_status_table widefat"><?php
221
  echo '<tr>';
222
- echo '<th>' . __( 'Term ID', 'woocommerce-jetpack' ) . '</th>';
223
- echo '<th>' . __( 'Name', 'woocommerce-jetpack' ) . '</th>';
224
  echo '<th>' . __( 'Slug', 'woocommerce-jetpack' ) . '</th>';
225
- echo '<th>' . __( 'Count', 'woocommerce-jetpack' ) . '</th>';
 
226
  echo '<th>' . __( 'Delete', 'woocommerce-jetpack' ) . '</th>';
227
  echo '</tr>';
228
- $statuses = (array) get_terms( 'shop_order_status', array( 'hide_empty' => 0, 'orderby' => 'id' ) );
229
- foreach( $statuses as $status ) {
230
- echo '<tr>';
231
- echo '<td>' . $status->term_id . '</td>';
232
- echo '<td>' . $status->name . '</td>';
233
- echo '<td>' . $status->slug . '</td>';
234
- echo '<td>' . $status->count . '</td>';
235
- if ( in_array( $status->slug, $default_statuses ) )
236
- echo '<td></td>';
237
- else
238
- echo '<td>' . '<a href="' . add_query_arg( 'delete', $status->term_id ) . '">' . __( 'Delete', 'woocommerce-jetpack' ) . '</a>' . '</td>';
239
- echo '</tr>';
240
- }
241
  ?></table>
242
  <p><form method="post" action="<?php echo remove_query_arg( 'delete' ); ?>">
243
- <input type="text" name="new_status">
244
- <input type="submit" name="add_custom_status" value="Add new custom status">
 
245
  </form></p>
246
- </div><?php
247
- }
248
-
 
 
 
249
  /**
250
- * Add Renumerate Orders tool to WooCommerce menu (menu link).
251
- */
252
- public function add_renumerate_orders_tool() {
 
 
 
 
 
253
 
254
- add_submenu_page( 'woocommerce', 'Jetpack - Renumerate Orders', 'Renumerate Orders', 'manage_options', 'woocommerce-jetpack-renumerate-orders', array( $this, 'create_renumerate_orders_tool' ) );
 
 
 
 
 
 
 
 
255
  }
256
-
 
 
 
 
 
 
 
 
 
 
 
257
  /**
258
  * Add Renumerate Orders tool to WooCommerce menu (the content).
259
- */
260
  public function create_renumerate_orders_tool() {
261
-
262
  $result_message = '';
263
- if ( isset( $_POST['renumerate_orders'] ) ) {
264
  $this->renumerate_orders();
265
  $result_message = '<div class="updated"><p><strong>Orders successfully renumerated!</strong></p></div>';
266
  }
267
- ?><?php echo $result_message; ?>
268
- <div>
269
- <h2>WooCommerce Jetpack - Renumerate Orders</h2>
270
- <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>
271
  <form method="post" action="">
272
- <input type="submit" name="renumerate_orders" value="Renumerate orders">
273
  </form>
274
- </div><?php
275
- }
276
 
277
  /**
278
  * Add/update order_number meta to order.
@@ -280,78 +271,103 @@ class WCJ_Orders {
280
  public function add_order_number_meta( $order_id ) {
281
 
282
  $current_order_number = get_option( 'wcj_order_number_counter' );
 
283
  update_option( 'wcj_order_number_counter', ( $current_order_number + 1 ) );
284
  update_post_meta( $order_id, '_wcj_order_number', $current_order_number );
285
  }
286
-
287
- /**
288
- * Display order number.
289
- *
290
- public function display_order_number( $order_number, $order ) {
291
-
292
- $order_number_meta = get_post_meta( $order->id, '_wcj_order_number', true );
293
- if ( $order_number_meta !== '' )
294
- $order_number = '#' . $order_number_meta;
295
-
296
- return $order_number;
297
- }
298
-
299
- /**
300
- * Display order number.
301
- */
302
- public function display_order_number( $order_number, $order ) {
303
-
304
- $order_number_meta = get_post_meta( $order->id, '_wcj_order_number', true );
305
- if ( $order_number_meta !== '' )
306
- $order_number = apply_filters( 'wcj_get_option_filter', '#' . $order_number_meta, sprintf( '%s%0' . get_option( 'wcj_order_number_min_width', 0 ) . 'd', get_option( 'wcj_order_number_prefix', '' ), $order_number_meta ) );
307
-
308
- return $order_number;
309
- }
310
-
311
  /**
312
  * Renumerate orders function.
313
- */
314
  public function renumerate_orders() {
315
-
316
  $args = array(
317
  'post_type' => 'shop_order',
318
- 'post_status' => 'publish',
319
  'posts_per_page' => -1,
320
  'orderby' => 'date',
321
  'order' => 'ASC',
322
  );
323
-
324
  $loop = new WP_Query( $args );
325
-
326
  while ( $loop->have_posts() ) : $loop->the_post();
327
-
328
  $order_id = $loop->post->ID;
329
  $this->add_order_number_meta( $order_id );
330
-
331
  endwhile;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
332
  }
333
-
 
334
  /**
335
  * Add Enabled option to Jetpack Dashboard.
336
  */
337
  public function add_enabled_option( $settings ) {
338
-
339
  $all_settings = $this->get_settings();
340
  $settings[] = $all_settings[1];
341
-
342
  return $settings;
343
  }
344
-
345
  /**
346
  * Add settings arrays to Jetpack Settings.
347
- */
348
  function get_settings() {
349
-
350
  $settings = array(
351
-
352
  //This first section\'s checkbox enables/disables all options below.
353
  array( 'title' => __( 'Orders Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_orders_options' ),
354
-
355
  array(
356
  'title' => __( 'Orders', 'woocommerce-jetpack' ),
357
  'desc' => __( 'Enable the Orders feature', 'woocommerce-jetpack' ),
@@ -359,12 +375,12 @@ class WCJ_Orders {
359
  'id' => 'wcj_orders_enabled',
360
  'default' => 'yes',
361
  'type' => 'checkbox',
362
- ),
363
-
364
  array( 'type' => 'sectionend', 'id' => 'wcj_orders_options' ),
365
 
366
  array( 'title' => __( 'Order Numbers', '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' ),
367
-
368
  array(
369
  'title' => __( 'Order Numbers', 'woocommerce-jetpack' ),
370
  'desc' => __( 'Enable', 'woocommerce-jetpack' ),
@@ -372,14 +388,14 @@ class WCJ_Orders {
372
  'default' => 'no',
373
  'type' => 'checkbox',
374
  ),
375
-
376
  array(
377
  'title' => __( 'Next Order Number', 'woocommerce-jetpack' ),
378
  'desc' => __( 'Next new order will be given this number.', 'woocommerce-jetpack' ),
379
  'id' => 'wcj_order_number_counter',
380
  'default' => 1,
381
  'type' => 'number',
382
- ),
383
 
384
  array(
385
  'title' => __( 'Order Number Prefix', 'woocommerce-jetpack' ),
@@ -388,32 +404,32 @@ class WCJ_Orders {
388
  'id' => 'wcj_order_number_prefix',
389
  'default' => '#',
390
  'type' => 'text',
391
- 'custom_attributes'
392
- => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
393
  ),
394
 
395
  array(
396
  'title' => __( 'Order Number Width', 'woocommerce-jetpack' ),
397
  'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
398
- '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' ),
399
  'id' => 'wcj_order_number_min_width',
400
  'default' => 0,
401
  'type' => 'number',
402
- 'custom_attributes'
403
- => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
404
- ),
405
-
406
  array( 'type' => 'sectionend', 'id' => 'wcj_order_numbers_options' ),
407
-
408
  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' ),
409
-
410
  array(
411
  'title' => __( 'Amount', 'woocommerce-jetpack' ),
412
  'desc' => __( 'Minimum order amount. Set to 0 to disable.', 'woocommerce-jetpack' ),
413
  'id' => 'wcj_order_minimum_amount',
414
  'default' => 0,
415
  'type' => 'number',
416
- ),
417
 
418
  array(
419
  'title' => __( 'Error message', 'woocommerce-jetpack' ),
@@ -422,18 +438,18 @@ class WCJ_Orders {
422
  'id' => 'wcj_order_minimum_amount_error_message',
423
  'default' => 'You must have an order with a minimum of %s to place your order, your current order total is %s.',
424
  'type' => 'text',
425
- 'custom_attributes'
426
  => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
427
  'css' => 'width:50%;min-width:300px;',
428
  ),
429
-
430
  array(
431
  'title' => __( 'Add notice to cart page also', 'woocommerce-jetpack' ),
432
  'desc' => __( 'Add', 'woocommerce-jetpack' ),
433
  'id' => 'wcj_order_minimum_amount_cart_notice_enabled',
434
  'default' => 'no',
435
  'type' => 'checkbox',
436
- ),
437
 
438
  array(
439
  'title' => __( 'Message on cart page', 'woocommerce-jetpack' ),
@@ -442,15 +458,15 @@ class WCJ_Orders {
442
  'id' => 'wcj_order_minimum_amount_cart_notice_message',
443
  'default' => 'You must have an order with a minimum of %s to place your order, your current order total is %s.',
444
  'type' => 'text',
445
- 'custom_attributes'
446
  => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
447
  'css' => 'width:50%;min-width:300px;',
448
- ),
449
-
450
  array( 'type' => 'sectionend', 'id' => 'wcj_order_minimum_amount_options' ),
451
 
452
  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' ),
453
-
454
  array(
455
  'title' => __( 'Auto-complete all WooCommerce orders', 'woocommerce-jetpack' ),
456
  'desc' => __( 'Enable', 'woocommerce-jetpack' ),
@@ -458,12 +474,12 @@ class WCJ_Orders {
458
  'id' => 'wcj_order_auto_complete_enabled',
459
  'default' => 'no',
460
  'type' => 'checkbox',
461
- ),
462
-
463
  array( 'type' => 'sectionend', 'id' => 'wcj_order_auto_complete_options' ),
464
 
465
  array( 'title' => __( 'Custom Statuses', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you enable custom statuses tool.', 'woocommerce-jetpack' ), 'id' => 'wcj_orders_custom_statuses_options' ),
466
-
467
  array(
468
  'title' => __( 'Custom Statuses', 'woocommerce-jetpack' ),
469
  'desc' => __( 'Enable', 'woocommerce-jetpack' ),
@@ -471,69 +487,24 @@ class WCJ_Orders {
471
  'id' => 'wcj_orders_custom_statuses_enabled',
472
  'default' => 'yes',
473
  'type' => 'checkbox',
474
- ),
475
-
476
- array( 'type' => 'sectionend', 'id' => 'wcj_orders_custom_statuses_options' ),
477
-
478
  );
479
-
480
- /*
481
- $settings[] = array(
482
- 'title' => __( 'Add new custom status', 'woocommerce-jetpack' ),
483
- //'desc' => __( 'Enable Custom Statuses', 'woocommerce-jetpack' ),
484
- //'desc_tip' => __( 'Sequential order numbering, custom order number prefix and number width. Minimum order amount.', 'woocommerce-jetpack' ),
485
- 'id' => 'wcj_orders_custom_statuses_add',
486
- 'default' => '',
487
- 'type' => 'text_and_button',
488
-
489
- 'button_value' => 'Add',
490
- /*'form_name' => '',
491
- 'form_action' => '',
492
- 'form_method' => 'post',*//*
493
- );
494
- */
495
-
496
  return $settings;
497
  }
498
-
499
- /**
500
- * add_text_and_button_settings_fields.
501
- *
502
- function add_text_and_button_settings_fields( $value ) {
503
- ?><tr valign="top">
504
- <th scope="row" class="titledesc">
505
- <label for="<?php echo esc_attr( $value['id'] ) . '_text'; ?>"><?php echo esc_html( $value['title'] ); ?></label>
506
- <?php /*echo $tip;*//* ?>
507
- </th>
508
- <td class="forminp forminp-text">
509
- <form
510
- name="<?php echo esc_attr( $value['id'] ) . '_form'; ?>"
511
- action=""
512
- method="get">
513
- <input
514
- name="<?php echo esc_attr( $value['id'] ) . '_text'; ?>"
515
- id="<?php echo esc_attr( $value['id'] ) . '_text'; ?>"
516
- type="text"
517
- style="<?php echo esc_attr( $value['css'] ); ?>"
518
- <?php /*value="<?php echo esc_attr( $option_value ); ?>"*//* ?>
519
- class="<?php echo esc_attr( $value['class'] ); ?>"
520
- <?php /*echo implode( ' ', $custom_attributes );*//* ?>
521
- /> <?php /*echo $description;*//* ?>
522
- <input type="submit" value="<?php echo esc_attr( $value['button_value'] ); ?>">
523
- </form>
524
- </td>
525
- </tr><?php
526
- }
527
-
528
  /**
529
  * Add settings section to WooCommerce > Settings > Jetpack.
530
  */
531
- function settings_section( $sections ) {
532
- $sections['orders'] = 'Orders';
533
  return $sections;
534
- }
535
  }
536
-
537
  endif;
538
-
539
  return new WCJ_Orders();
5
  * The WooCommerce Jetpack Orders class.
6
  *
7
  * @class WCJ_Orders
8
+ * @version 1.3.1
9
  * @category Class
10
+ * @author Algoritmika Ltd.
11
  */
12
+
13
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
+
15
  if ( ! class_exists( 'WCJ_Orders' ) ) :
16
+
17
  class WCJ_Orders {
18
+
19
  /**
20
  * Constructor.
21
  */
22
  public function __construct() {
23
+
24
+ // Variables
25
+ $this->default_statuses = array(
26
+ 'wc-pending' => _x( 'Pending payment', 'Order status', 'woocommerce' ),
27
+ 'wc-processing' => _x( 'Processing', 'Order status', 'woocommerce' ),
28
+ 'wc-on-hold' => _x( 'On hold', 'Order status', 'woocommerce' ),
29
+ 'wc-completed' => _x( 'Completed', 'Order status', 'woocommerce' ),
30
+ 'wc-cancelled' => _x( 'Cancelled', 'Order status', 'woocommerce' ),
31
+ 'wc-refunded' => _x( 'Refunded', 'Order status', 'woocommerce' ),
32
+ 'wc-failed' => _x( 'Failed', 'Order status', 'woocommerce' ),
33
+ );
34
+
35
  // Main hooks
36
  if ( get_option( 'wcj_orders_enabled' ) == 'yes' ) {
37
+
38
+ if ( 'yes' === get_option( 'wcj_order_numbers_enabled' ) ) {
39
+ add_action( 'woocommerce_new_order', array( $this, 'add_order_number_meta' ), 100 );
40
+ add_filter( 'woocommerce_order_number', array( $this, 'display_order_number' ), 100, 2 );
41
+ add_filter( 'wcj_tools_tabs', array( $this, 'add_renumerate_orders_tool_tab' ), 100 );
42
+ add_action( 'wcj_tools_renumerate_orders', array( $this, 'create_renumerate_orders_tool' ), 100 );
43
+ }
44
+ add_action( 'wcj_tools_dashboard', array( $this, 'add_renumerate_orders_tool_info_to_tools_dashboard' ), 100 );
45
+
46
+ if ( get_option( 'wcj_order_minimum_amount' ) > 0 ) {
47
  add_action( 'woocommerce_checkout_process', array( $this, 'order_minimum_amount' ) );
48
+ add_action( 'woocommerce_before_cart', array( $this, 'order_minimum_amount' ) );
49
  }
50
+
51
  if ( 'yes' === get_option( 'wcj_orders_custom_statuses_enabled' ) ) {
52
+ add_filter( 'wc_order_statuses', array( $this, 'add_custom_statuses_to_filter' ), 100 );
53
+ add_action( 'init', array( $this, 'register_custom_post_statuses' ) );
54
+ add_action( 'admin_head', array( $this, 'hook_statuses_icons_css' ) );
55
+ add_filter( 'wcj_tools_tabs', array( $this, 'add_custom_statuses_tool_tab' ), 100 );
56
+ add_action( 'wcj_tools_custom_statuses', array( $this, 'create_custom_statuses_tool' ), 100 );
57
  }
58
+ add_action( 'wcj_tools_dashboard', array( $this, 'add_custom_statuses_tool_info_to_tools_dashboard' ), 100 );
59
+
60
  if ( 'yes' === get_option( 'wcj_order_auto_complete_enabled' ) )
61
+ add_action( 'woocommerce_thankyou', array( $this, 'auto_complete_order' ) );
62
  }
63
+
 
 
 
64
  // Settings hooks
65
+ add_filter( 'wcj_settings_sections', array( $this, 'settings_section' ) );
66
+ add_filter( 'wcj_settings_orders', array( $this, 'get_settings' ), 100 );
67
+ add_filter( 'wcj_features_status', array( $this, 'add_enabled_option' ), 100 );
68
  }
69
+
70
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
71
+ // CUSTOM STATUSES //
72
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
73
+ /**
74
+ * register_custom_post_statuses.
75
+ */
76
+ public function register_custom_post_statuses() {
77
+ $wcj_orders_custom_statuses_array = ( '' == get_option( 'wcj_orders_custom_statuses_array' ) ) ? array() : get_option( 'wcj_orders_custom_statuses_array' );
78
+ foreach ( $wcj_orders_custom_statuses_array as $slug => $label )
79
+ register_post_status( $slug, array(
80
+ 'label' => $label,
81
+ 'public' => true,
82
+ 'exclude_from_search' => false,
83
+ 'show_in_admin_all_list' => true,
84
+ 'show_in_admin_status_list' => true,
85
+ 'label_count' => _n_noop( $label . ' <span class="count">(%s)</span>', $label . ' <span class="count">(%s)</span>' ),
86
+ )
87
+ );
88
+ }
89
+
90
+ /**
91
+ * add_custom_statuses_to_filter.
92
+ */
93
+ public function add_custom_statuses_to_filter( $order_statuses ) {
94
+ $wcj_orders_custom_statuses_array = ( '' == get_option( 'wcj_orders_custom_statuses_array' ) ) ? array() : get_option( 'wcj_orders_custom_statuses_array' );
95
+ $order_statuses = ( '' == $order_statuses ) ? array() : $order_statuses;
96
+ return array_merge( $order_statuses, $wcj_orders_custom_statuses_array );
97
+ }
98
+
99
  /**
100
  * add_custom_statuses_tool_info_to_tools_dashboard.
101
  */
105
  else
106
  echo '<h3>Custom Statuses tool is disabled.</h3>';
107
  echo '<p>The tool lets you add or delete any custom status for WooCommerce orders.</p>';
108
+ }
109
+
110
  /**
111
  * add_custom_statuses_tool_tab.
112
  */
113
  public function add_custom_statuses_tool_tab( $tabs ) {
114
  $tabs[] = array(
115
  'id' => 'custom_statuses',
116
+ 'title' => __( 'Custom Statuses', 'woocommerce-jetpack' ),
117
  );
118
  return $tabs;
119
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
120
 
121
  /**
122
+ * hook_statuses_icons_css.
123
+ * TODO: content, color
124
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  public function hook_statuses_icons_css() {
126
  $output = '<style>';
127
+ $statuses = function_exists( 'wc_get_order_statuses' ) ? wc_get_order_statuses() : array();
128
+ foreach( $statuses as $status => $status_name ) {
129
+ if ( ! array_key_exists( $status, $this->default_statuses ) ) {
130
+ $output .= 'mark.' . substr( $status, 3 ) . '::after { content: "\e011"; color: #999; }';
131
+ $output .= 'mark.' . substr( $status, 3 ) . ':after {font-family:WooCommerce;speak:none;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;margin:0;text-indent:0;position:absolute;top:0;left:0;width:100%;height:100%;text-align:center}';
 
 
 
 
 
 
 
 
 
 
 
132
  }
133
+ }
 
 
 
134
  $output .= '.close:after { content: "\e011"; }';
 
135
  $output .= '</style>';
136
  echo $output;
137
  }
138
+
139
+ /**
140
+ * Add new custom status to wcj_orders_custom_statuses_array.
141
+ */
142
+ public function add_custom_status( $new_status, $new_status_label ) {
143
+
144
+ // Checking function arguments
145
+ if ( ! isset( $new_status ) || '' == $new_status )
146
+ return '<div class="error"><p>' . __( 'Status slug is empty. Status not added.', 'woocommerce-jetpack' ) . '</p></div>';
147
+ if ( ! isset( $new_status_label ) || '' == $new_status_label )
148
+ return '<div class="error"><p>' . __( 'Status label is empty. Status not added.', 'woocommerce-jetpack' ) . '</p></div>';
149
+
150
+ // Checking status
151
+ $statuses_updated = ( '' == get_option( 'wcj_orders_custom_statuses_array' ) ) ? array() : get_option( 'wcj_orders_custom_statuses_array' );
152
+ $new_key = 'wc-' . $_POST['new_status'];
153
+ if ( isset( $statuses_updated[$new_key] ) )
154
+ return '<div class="error"><p>' . __( 'Duplicate slug. Status not added.', 'woocommerce-jetpack' ) . '</p></div>';
155
+ $statuses_updated[$new_key] = $_POST['new_status_label'];
156
+
157
+ // Adding custom status
158
+ $result = update_option( 'wcj_orders_custom_statuses_array', $statuses_updated );
159
+ if ( true === $result )
160
+ return '<div class="updated"><p>' . __( 'New status have been successfully added!', 'woocommerce-jetpack' ) . '</p></div>';
161
+ else
162
+ return '<div class="error"><p>' . __( 'Status was not added.', 'woocommerce-jetpack' ) . '</p></div>';
163
+ }
164
+
165
+ /**
166
+ * create_custom_statuses_tool.
167
+ */
168
  public function create_custom_statuses_tool() {
169
+
170
  $result_message = '';
171
+ if ( isset( $_POST['add_custom_status'] ) )
172
+ $result_message = $this->add_custom_status( $_POST['new_status'], $_POST['new_status_label'] );
173
+ else if ( isset( $_GET['delete'] ) && ( '' != $_GET['delete'] ) ) {
174
+ $statuses_updated = apply_filters( 'wc_order_statuses', $statuses_updated );
175
+ unset( $statuses_updated[ $_GET['delete'] ] );
176
+ $result = update_option( 'wcj_orders_custom_statuses_array', $statuses_updated );
177
+ if ( true === $result )
 
 
 
 
 
 
 
 
178
  $result_message = '<div class="updated"><p>' . __( 'Status have been successfully deleted.', 'woocommerce-jetpack' ) . '</p></div>';
179
  else
180
  $result_message = '<div class="error"><p>' . __( 'Delete failed.', 'woocommerce-jetpack' ) . '</p></div>';
181
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  ?><div>
183
  <h2><?php echo __( 'WooCommerce Jetpack - Custom Statuses', 'woocommerce-jetpack' ); ?></h2>
184
  <p><?php echo __( 'The tool lets you add or delete any custom status for WooCommerce orders.', 'woocommerce-jetpack' ); ?></p>
186
  <h3><?php echo __( 'Statuses', 'woocommerce-jetpack' ); ?></h3>
187
  <table class="wc_status_table widefat"><?php
188
  echo '<tr>';
 
 
189
  echo '<th>' . __( 'Slug', 'woocommerce-jetpack' ) . '</th>';
190
+ echo '<th>' . __( 'Label', 'woocommerce-jetpack' ) . '</th>';
191
+ //echo '<th>' . __( 'Count', 'woocommerce-jetpack' ) . '</th>';
192
  echo '<th>' . __( 'Delete', 'woocommerce-jetpack' ) . '</th>';
193
  echo '</tr>';
194
+ $statuses = function_exists( 'wc_get_order_statuses' ) ? wc_get_order_statuses() : array();
195
+ foreach( $statuses as $status => $status_name ) {
196
+ echo '<tr>';
197
+ echo '<td>' . esc_attr( $status ) . '</td>';
198
+ echo '<td>' . esc_html( $status_name ) . '</td>';
199
+ if ( array_key_exists( $status, $this->default_statuses ) )
200
+ echo '<td></td>';
201
+ else
202
+ echo '<td>' . '<a href="' . add_query_arg( 'delete', $status ) . '">' . __( 'Delete', 'woocommerce-jetpack' ) . '</a>' . '</td>';
203
+ echo '</tr>';
204
+ }
 
 
205
  ?></table>
206
  <p><form method="post" action="<?php echo remove_query_arg( 'delete' ); ?>">
207
+ Slug: wc-<input type="text" name="new_status">
208
+ Label: <input type="text" name="new_status_label">
209
+ <input class="button-primary" type="submit" name="add_custom_status" value="Add new custom status">
210
  </form></p>
211
+ </div><?php
212
+ }
213
+
214
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
215
+ // ORDERS NUMBERS //
216
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
217
  /**
218
+ * Display order number.
219
+ */
220
+ public function display_order_number( $order_number, $order ) {
221
+ $order_number_meta = get_post_meta( $order->id, '_wcj_order_number', true );
222
+ if ( $order_number_meta !== '' )
223
+ $order_number = apply_filters( 'wcj_get_option_filter', '#' . $order_number_meta, sprintf( '%s%0' . get_option( 'wcj_order_number_min_width', 0 ) . 'd', get_option( 'wcj_order_number_prefix', '' ), $order_number_meta ) );
224
+ return $order_number;
225
+ }
226
 
227
+ /**
228
+ * add_renumerate_orders_tool_info_to_tools_dashboard.
229
+ */
230
+ public function add_renumerate_orders_tool_info_to_tools_dashboard() {
231
+ if ( 'yes' === get_option( 'wcj_order_numbers_enabled' ) )
232
+ echo '<h3>Orders Renumerate tool is enabled.</h3>';
233
+ else
234
+ echo '<h3>Orders Renumerate tool is disabled.</h3>';
235
+ echo '<p>' . __( 'The tool renumerates all orders.', 'woocommerce-jetpack' ) . '</p>';
236
  }
237
+
238
+ /**
239
+ * add_renumerate_orders_tool_tab.
240
+ */
241
+ public function add_renumerate_orders_tool_tab( $tabs ) {
242
+ $tabs[] = array(
243
+ 'id' => 'renumerate_orders',
244
+ 'title' => __( 'Renumerate orders', 'woocommerce-jetpack' ),
245
+ );
246
+ return $tabs;
247
+ }
248
+
249
  /**
250
  * Add Renumerate Orders tool to WooCommerce menu (the content).
251
+ */
252
  public function create_renumerate_orders_tool() {
 
253
  $result_message = '';
254
+ if ( isset( $_POST['renumerate_orders'] ) ) {
255
  $this->renumerate_orders();
256
  $result_message = '<div class="updated"><p><strong>Orders successfully renumerated!</strong></p></div>';
257
  }
258
+ ?><div>
259
+ <h2><?php echo __( 'WooCommerce Jetpack - Renumerate Orders', 'woocommerce-jetpack' ); ?></h2>
260
+ <p><?php echo __( '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.', 'woocommerce-jetpack' ); ?></p>
261
+ <?php echo $result_message; ?>
262
  <form method="post" action="">
263
+ <input class="button-primary" type="submit" name="renumerate_orders" value="Renumerate orders">
264
  </form>
265
+ </div><?php
266
+ }
267
 
268
  /**
269
  * Add/update order_number meta to order.
271
  public function add_order_number_meta( $order_id ) {
272
 
273
  $current_order_number = get_option( 'wcj_order_number_counter' );
274
+ //echo $current_order_number;
275
  update_option( 'wcj_order_number_counter', ( $current_order_number + 1 ) );
276
  update_post_meta( $order_id, '_wcj_order_number', $current_order_number );
277
  }
278
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  /**
280
  * Renumerate orders function.
281
+ */
282
  public function renumerate_orders() {
283
+
284
  $args = array(
285
  'post_type' => 'shop_order',
286
+ 'post_status' => 'any',
287
  'posts_per_page' => -1,
288
  'orderby' => 'date',
289
  'order' => 'ASC',
290
  );
291
+
292
  $loop = new WP_Query( $args );
293
+
294
  while ( $loop->have_posts() ) : $loop->the_post();
295
+
296
  $order_id = $loop->post->ID;
297
  $this->add_order_number_meta( $order_id );
298
+
299
  endwhile;
300
+ }
301
+
302
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
303
+ // AUTO COMPLETE //
304
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
305
+ /**
306
+ * Auto Complete all WooCommerce orders.
307
+ */
308
+ public function auto_complete_order( $order_id ) {
309
+
310
+ global $woocommerce;
311
+
312
+ if ( !$order_id )
313
+ return;
314
+ $order = new WC_Order( $order_id );
315
+ $order->update_status( 'completed' );
316
+ }
317
+
318
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
319
+ // MINIMUM AMOUNT //
320
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
321
+ /**
322
+ * order_minimum_amount.
323
+ */
324
+ public function order_minimum_amount() {
325
+
326
+ $minimum = get_option( 'wcj_order_minimum_amount' );
327
+ if ( WC()->cart->total < $minimum ) {
328
+
329
+ if( is_cart() ) {
330
+ if ( 'yes' === get_option( 'wcj_order_minimum_amount_cart_notice_enabled' ) ) {
331
+ wc_print_notice(
332
+ 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' ) ),
333
+ woocommerce_price( $minimum ),
334
+ woocommerce_price( WC()->cart->total )
335
+ ), 'notice'
336
+ );
337
+ }
338
+ } else {
339
+ wc_add_notice(
340
+ 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' ) ),
341
+ woocommerce_price( $minimum ),
342
+ woocommerce_price( WC()->cart->total )
343
+ ), 'error'
344
+ );
345
+ }
346
+ }
347
  }
348
+
349
+
350
  /**
351
  * Add Enabled option to Jetpack Dashboard.
352
  */
353
  public function add_enabled_option( $settings ) {
354
+
355
  $all_settings = $this->get_settings();
356
  $settings[] = $all_settings[1];
357
+
358
  return $settings;
359
  }
360
+
361
  /**
362
  * Add settings arrays to Jetpack Settings.
363
+ */
364
  function get_settings() {
365
+
366
  $settings = array(
367
+
368
  //This first section\'s checkbox enables/disables all options below.
369
  array( 'title' => __( 'Orders Options', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( '', 'woocommerce-jetpack' ), 'id' => 'wcj_orders_options' ),
370
+
371
  array(
372
  'title' => __( 'Orders', 'woocommerce-jetpack' ),
373
  'desc' => __( 'Enable the Orders feature', 'woocommerce-jetpack' ),
375
  'id' => 'wcj_orders_enabled',
376
  'default' => 'yes',
377
  'type' => 'checkbox',
378
+ ),
379
+
380
  array( 'type' => 'sectionend', 'id' => 'wcj_orders_options' ),
381
 
382
  array( 'title' => __( 'Order Numbers', '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' ),
383
+
384
  array(
385
  'title' => __( 'Order Numbers', 'woocommerce-jetpack' ),
386
  'desc' => __( 'Enable', 'woocommerce-jetpack' ),
388
  'default' => 'no',
389
  'type' => 'checkbox',
390
  ),
391
+
392
  array(
393
  'title' => __( 'Next Order Number', 'woocommerce-jetpack' ),
394
  'desc' => __( 'Next new order will be given this number.', 'woocommerce-jetpack' ),
395
  'id' => 'wcj_order_number_counter',
396
  'default' => 1,
397
  'type' => 'number',
398
+ ),
399
 
400
  array(
401
  'title' => __( 'Order Number Prefix', 'woocommerce-jetpack' ),
404
  'id' => 'wcj_order_number_prefix',
405
  'default' => '#',
406
  'type' => 'text',
407
+ 'custom_attributes'
408
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
409
  ),
410
 
411
  array(
412
  'title' => __( 'Order Number Width', 'woocommerce-jetpack' ),
413
  'desc' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
414
+ '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' ),
415
  'id' => 'wcj_order_number_min_width',
416
  'default' => 0,
417
  'type' => 'number',
418
+ 'custom_attributes'
419
+ => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
420
+ ),
421
+
422
  array( 'type' => 'sectionend', 'id' => 'wcj_order_numbers_options' ),
423
+
424
  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' ),
425
+
426
  array(
427
  'title' => __( 'Amount', 'woocommerce-jetpack' ),
428
  'desc' => __( 'Minimum order amount. Set to 0 to disable.', 'woocommerce-jetpack' ),
429
  'id' => 'wcj_order_minimum_amount',
430
  'default' => 0,
431
  'type' => 'number',
432
+ ),
433
 
434
  array(
435
  'title' => __( 'Error message', 'woocommerce-jetpack' ),
438
  'id' => 'wcj_order_minimum_amount_error_message',
439
  'default' => 'You must have an order with a minimum of %s to place your order, your current order total is %s.',
440
  'type' => 'text',
441
+ 'custom_attributes'
442
  => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
443
  'css' => 'width:50%;min-width:300px;',
444
  ),
445
+
446
  array(
447
  'title' => __( 'Add notice to cart page also', 'woocommerce-jetpack' ),
448
  'desc' => __( 'Add', 'woocommerce-jetpack' ),
449
  'id' => 'wcj_order_minimum_amount_cart_notice_enabled',
450
  'default' => 'no',
451
  'type' => 'checkbox',
452
+ ),
453
 
454
  array(
455
  'title' => __( 'Message on cart page', 'woocommerce-jetpack' ),
458
  'id' => 'wcj_order_minimum_amount_cart_notice_message',
459
  'default' => 'You must have an order with a minimum of %s to place your order, your current order total is %s.',
460
  'type' => 'text',
461
+ 'custom_attributes'
462
  => apply_filters( 'get_wc_jetpack_plus_message', '', 'readonly' ),
463
  'css' => 'width:50%;min-width:300px;',
464
+ ),
465
+
466
  array( 'type' => 'sectionend', 'id' => 'wcj_order_minimum_amount_options' ),
467
 
468
  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' ),
469
+
470
  array(
471
  'title' => __( 'Auto-complete all WooCommerce orders', 'woocommerce-jetpack' ),
472
  'desc' => __( 'Enable', 'woocommerce-jetpack' ),
474
  'id' => 'wcj_order_auto_complete_enabled',
475
  'default' => 'no',
476
  'type' => 'checkbox',
477
+ ),
478
+
479
  array( 'type' => 'sectionend', 'id' => 'wcj_order_auto_complete_options' ),
480
 
481
  array( 'title' => __( 'Custom Statuses', 'woocommerce-jetpack' ), 'type' => 'title', 'desc' => __( 'This section lets you enable custom statuses tool.', 'woocommerce-jetpack' ), 'id' => 'wcj_orders_custom_statuses_options' ),
482
+
483
  array(
484
  'title' => __( 'Custom Statuses', 'woocommerce-jetpack' ),
485
  'desc' => __( 'Enable', 'woocommerce-jetpack' ),
487
  'id' => 'wcj_orders_custom_statuses_enabled',
488
  'default' => 'yes',
489
  'type' => 'checkbox',
490
+ ),
491
+
492
+ array( 'type' => 'sectionend', 'id' => 'wcj_orders_custom_statuses_options' ),
493
+
494
  );
495
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
496
  return $settings;
497
  }
498
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
499
  /**
500
  * Add settings section to WooCommerce > Settings > Jetpack.
501
  */
502
+ function settings_section( $sections ) {
503
+ $sections['orders'] = __( 'Orders', 'woocommerce-jetpack' );
504
  return $sections;
505
+ }
506
  }
507
+
508
  endif;
509
+
510
  return new WCJ_Orders();
includes/class-wcj-pdf-invoices.php CHANGED
@@ -5,7 +5,7 @@
5
  * The WooCommerce Jetpack PDF Invoices class.
6
  *
7
  * @class WCJ_PDF_Invoices
8
- * @version 1.2.0
9
  * @category Class
10
  * @author Algoritmika Ltd.
11
  */
@@ -55,22 +55,28 @@ class WCJ_PDF_Invoices {
55
  * Unlocks - PDF Invoices - add_pdf_invoices_link_to_my_account.
56
  */
57
  public function add_pdf_invoices_link_to_my_account( $actions, $the_order ) {
58
-
59
- $actions['pdf_invoice'] = array(
60
- 'url' => $_SERVER['REQUEST_URI'] . '?pdf_invoice=' . $the_order->id,
61
- 'name' => __( 'Invoice', 'woocommerce-jetpack' ),
62
- );
63
-
64
- return $actions;
 
 
 
 
 
 
65
  }
66
 
67
  /**
68
  * add_pdf_invoice_icon_css.
69
  */
70
  function add_pdf_invoice_icon_css() {
71
-
72
  echo '<style> a.button.tips.view.pdf_invoice:after { content: "\e028" !important; } </style>';
73
- //echo '<style> a.button.tips.view.save_pdf_invoice:after { content: "\e028" !important; } </style>';
74
  }
75
 
76
  /**
@@ -160,6 +166,8 @@ class WCJ_PDF_Invoices {
160
 
161
  // Close and output PDF document
162
  // This method has several options, check the source code documentation for more information.
 
 
163
  if ( isset( $_GET['save_pdf_invoice'] ) && ( $_GET['save_pdf_invoice'] == '1' ) )
164
  $pdf->Output('invoice-' . $order_number . '.pdf', 'D');
165
  else
@@ -487,18 +495,18 @@ class WCJ_PDF_Invoices {
487
  * add_pdf_invoices_link_to_order_list.
488
  */
489
  public function add_pdf_invoices_link_to_order_list( $actions, $the_order ) {
490
-
491
- $actions['pdf_invoice'] = array(
492
- 'url' => basename( $_SERVER['REQUEST_URI'] ) . '&pdf_invoice=' . $the_order->id,
493
- 'name' => __( 'PDF Invoice', 'woocommerce-jetpack' ),
494
- 'action' => "view pdf_invoice"
495
- );
496
-
497
- /*$actions['save_pdf_invoice'] = array(
498
- 'url' => basename( $_SERVER['REQUEST_URI'] ) . '&pdf_invoice=' . $the_order->id . '&save_pdf_invoice=1',
499
- 'name' => __( 'Save PDF', 'woocommerce-jetpack' ),
500
- 'action' => "view save_pdf_invoice"
501
- );*/
502
 
503
  return $actions;
504
  }
@@ -806,6 +814,15 @@ class WCJ_PDF_Invoices {
806
  'css' => 'width:33%;min-width:300px;',
807
  ),
808
 
 
 
 
 
 
 
 
 
 
809
  array(
810
  'title' => __( 'Total Discount', 'woocommerce-jetpack' ),
811
  //'desc_tip' => __( 'Total Discount text', 'woocommerce-jetpack' ),
@@ -815,15 +832,6 @@ class WCJ_PDF_Invoices {
815
  'css' => 'width:33%;min-width:300px;',
816
  ),
817
 
818
- array(
819
- 'title' => __( 'Order Shipping Price', 'woocommerce-jetpack' ),
820
- //'desc_tip' => __( 'Order Shipping text', 'woocommerce-jetpack' ),
821
- 'id' => 'wcj_pdf_invoices_order_shipping_text',
822
- 'default' => __( 'Shipping', 'woocommerce-jetpack' ),
823
- 'type' => 'text',
824
- 'css' => 'width:33%;min-width:300px;',
825
- ),
826
-
827
  array(
828
  'title' => __( 'Order Total (TAX excl.)', 'woocommerce-jetpack' ),
829
  'desc_tip' => __( 'Order Total (TAX excl.) = Total - Taxes. Shown only if discount or shipping is not equal to zero. In other words: if "Order Total (TAX excl.)" not equal to "Order Subtotal"', 'woocommerce-jetpack' ),
@@ -919,6 +927,16 @@ class WCJ_PDF_Invoices {
919
  'type' => 'checkbox',
920
  'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
921
  ),
 
 
 
 
 
 
 
 
 
 
922
 
923
  //array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_more_options' ),
924
  array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_general_options' ),
5
  * The WooCommerce Jetpack PDF Invoices class.
6
  *
7
  * @class WCJ_PDF_Invoices
8
+ * @version 1.3.2
9
  * @category Class
10
  * @author Algoritmika Ltd.
11
  */
55
  * Unlocks - PDF Invoices - add_pdf_invoices_link_to_my_account.
56
  */
57
  public function add_pdf_invoices_link_to_my_account( $actions, $the_order ) {
58
+
59
+ if ( 'no' === get_option( 'wcj_pdf_invoices_save_as_enabled' ) )
60
+ $actions['pdf_invoice'] = array(
61
+ 'url' => $_SERVER['REQUEST_URI'] . '?pdf_invoice=' . $the_order->id,
62
+ 'name' => __( 'Invoice', 'woocommerce-jetpack' ),
63
+ );
64
+ else
65
+ $actions['save_pdf_invoice'] = array(
66
+ 'url' => $_SERVER['REQUEST_URI'] . '?pdf_invoice=' . $the_order->id . '&save_pdf_invoice=1',
67
+ 'name' => __( 'Invoice', 'woocommerce-jetpack' ),
68
+ );
69
+
70
+ return $actions;
71
  }
72
 
73
  /**
74
  * add_pdf_invoice_icon_css.
75
  */
76
  function add_pdf_invoice_icon_css() {
77
+
78
  echo '<style> a.button.tips.view.pdf_invoice:after { content: "\e028" !important; } </style>';
79
+ echo '<style> a.button.tips.view.save_pdf_invoice:after { content: "\e028" !important; } </style>';
80
  }
81
 
82
  /**
166
 
167
  // Close and output PDF document
168
  // This method has several options, check the source code documentation for more information.
169
+ $the_order = new WC_Order( $order_id );
170
+ $order_number = $the_order->get_order_number();
171
  if ( isset( $_GET['save_pdf_invoice'] ) && ( $_GET['save_pdf_invoice'] == '1' ) )
172
  $pdf->Output('invoice-' . $order_number . '.pdf', 'D');
173
  else
495
  * add_pdf_invoices_link_to_order_list.
496
  */
497
  public function add_pdf_invoices_link_to_order_list( $actions, $the_order ) {
498
+ if ( 'no' === get_option( 'wcj_pdf_invoices_save_as_enabled' ) )
499
+ $actions['pdf_invoice'] = array(
500
+ 'url' => basename( $_SERVER['REQUEST_URI'] ) . '&pdf_invoice=' . $the_order->id,
501
+ 'name' => __( 'PDF Invoice', 'woocommerce-jetpack' ),
502
+ 'action' => "view pdf_invoice"
503
+ );
504
+ else
505
+ $actions['save_pdf_invoice'] = array(
506
+ 'url' => basename( $_SERVER['REQUEST_URI'] ) . '&pdf_invoice=' . $the_order->id . '&save_pdf_invoice=1',
507
+ 'name' => __( 'PDF Invoice', 'woocommerce-jetpack' ),
508
+ 'action' => "view save_pdf_invoice"
509
+ );
510
 
511
  return $actions;
512
  }
814
  'css' => 'width:33%;min-width:300px;',
815
  ),
816
 
817
+ array(
818
+ 'title' => __( 'Order Shipping Price', 'woocommerce-jetpack' ),
819
+ //'desc_tip' => __( 'Order Shipping text', 'woocommerce-jetpack' ),
820
+ 'id' => 'wcj_pdf_invoices_order_shipping_text',
821
+ 'default' => __( 'Shipping', 'woocommerce-jetpack' ),
822
+ 'type' => 'text',
823
+ 'css' => 'width:33%;min-width:300px;',
824
+ ),
825
+
826
  array(
827
  'title' => __( 'Total Discount', 'woocommerce-jetpack' ),
828
  //'desc_tip' => __( 'Total Discount text', 'woocommerce-jetpack' ),
832
  'css' => 'width:33%;min-width:300px;',
833
  ),
834
 
 
 
 
 
 
 
 
 
 
835
  array(
836
  'title' => __( 'Order Total (TAX excl.)', 'woocommerce-jetpack' ),
837
  'desc_tip' => __( 'Order Total (TAX excl.) = Total - Taxes. Shown only if discount or shipping is not equal to zero. In other words: if "Order Total (TAX excl.)" not equal to "Order Subtotal"', 'woocommerce-jetpack' ),
927
  'type' => 'checkbox',
928
  'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
929
  ),
930
+
931
+ array(
932
+ 'title' => __( 'Enable Save as', 'woocommerce-jetpack' ),
933
+ 'desc' => __( 'Enable save as pdf instead of view pdf', 'woocommerce-jetpack' ),
934
+ //'desc_tip' => apply_filters( 'get_wc_jetpack_plus_message', '', 'desc' ),
935
+ 'id' => 'wcj_pdf_invoices_save_as_enabled',
936
+ 'default' => 'no',
937
+ 'type' => 'checkbox',
938
+ //'custom_attributes' => apply_filters( 'get_wc_jetpack_plus_message', '', 'disabled' ),
939
+ ),
940
 
941
  //array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_more_options' ),
942
  array( 'type' => 'sectionend', 'id' => 'wcj_pdf_invoices_general_options' ),
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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,custom payment gateway,payment gateway icon,auto-complete all orders,custom order statuses,custom order status,remove text from price
5
  Requires at least: 3.9.1
6
  Tested up to: 4.0
7
- Stable tag: 1.4.0
8
  License: GNU General Public License v3.0
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -63,40 +63,47 @@ Please let us know if you want anything added to list by <a href="http://woojetp
63
 
64
  If you wish that some task would go up the queue to make it faster, please contact us by <a href="http://woojetpack.com/contact-us/">filling this form</a>. We are listening carefully to our users!
65
 
66
- = 1.5.0 - 11/09/2014 =
67
- 1. Fix - Payment Gateways - Instructions are not showing. Suggested by Jen.
68
- 1. Upgrade Feature - PDF Invoices - Send PDF invoice or link to invoice to the customer. Make this option available for certain payment methods only (user selection). Idea by Jen.
69
- 1. Upgrade Feature - Shipping - Advance free shipping - Free shipping for multiple country/places. Each country/places different prices. Idea by LQTOYS.
70
-
71
- = 1.6.0 - 18/09/2014 =
72
- 1. New Feature - Smart Reports - Various reports based on products prices, sales, stock.
73
 
74
  = 1.7.0 - 01/10/2014 =
75
- 1. Upgrade Feature - Custom Price Labels - Add "global labels".
76
- 1. Upgrade Feature - Shipping - Add "Custom Shipping Method".
77
- 1. Upgrade Feature - Product Info - Add "total sales" and "time since last sale" info.
78
- 1. Upgrade Feature - Orders - Custom Order Statuses - Add options for selecting icons and color.
79
 
80
  = 1.8.0 - 07/10/2014 =
81
- 1. New Feature - Products per Page - Add "products per page" option for customers (i.e. front end).
82
 
83
  = 1.9.0 - 21/10/2014 =
84
- 1. Upgrade Feature - Custom Price Labels - Add "local remove".
85
- 1. Upgrade Feature - Orders - Bulk orders (start from global discount for all products; later - discounts for individual products).
86
- 1. Upgrade Feature - Custom Price Labels - Add different labels for archives, single, homepage, related. Add option to select which price hooks to use. Different labels for variable and variation.
87
- 1. Upgrade Feature - Cart - Cart discount.
88
 
89
  = 2.0.0 - 01/11/2014 =
90
- 1. Dev - Major source code, documentation, locking mechanism etc. recheck.
91
 
92
  == Changelog ==
93
 
 
 
 
 
 
 
 
94
  = 1.4.0 - 07/09/2014 =
95
  * Dev - Custom Price Labels - Support for price labels showing on Pages, added. Suggested by Axel.
96
  * Fix - PDF Invoices - Bug with some item table columns not showing, fixed. Suggested by Tomas.
97
  * Dev - PDF Invoices - Discount as separate item option added.
98
  * Dev - PDF Invoices - Shipping as separate item option added. Suggested by Tomas.
99
- * Dev - All tools (i.e. Old Slugs and Custom Order Statuses) moved to WooCommerce > Jetpack Tools.
100
 
101
  = 1.3.0 - 25/08/2014 =
102
  * Feature Upgraded - PDF Invoices - Major upgrade: single item price, item and line taxes, payment and shipping methods, additional footer, font size, custom css added.
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,custom payment gateway,payment gateway icon,auto-complete all orders,custom order statuses,custom order status,remove text from price
5
  Requires at least: 3.9.1
6
  Tested up to: 4.0
7
+ Stable tag: 1.5.0
8
  License: GNU General Public License v3.0
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
63
 
64
  If you wish that some task would go up the queue to make it faster, please contact us by <a href="http://woojetpack.com/contact-us/">filling this form</a>. We are listening carefully to our users!
65
 
66
+ = 1.6.0 - 21/09/2014 =
67
+ * Fix - Payment Gateways - Instructions are not showing. Suggested by Jen.
68
+ * Upgrade Feature - PDF Invoices - Send PDF invoice or link to invoice to the customer. Make this option available for certain payment methods only (user selection). Idea by Jen.
69
+ * Upgrade Feature - Shipping - Advance free shipping - Free shipping for multiple country/places. Each country/places different prices. Idea by LQTOYS.
70
+ * New Feature - Add second currency to the price.
71
+ * New Feature - Smart Reports - Various reports based on products prices, sales, stock.
72
+ * Dev - PDF Invoices - If displaying shipping as item, add shipping method text. Suggested by Tomas.
73
 
74
  = 1.7.0 - 01/10/2014 =
75
+ * Upgrade Feature - Custom Price Labels - Add "global labels".
76
+ * Upgrade Feature - Shipping - Add "Custom Shipping Method".
77
+ * Upgrade Feature - Product Info - Add "total sales" and "time since last sale" info.
78
+ * Upgrade Feature - Orders - Custom Order Statuses - Add options for selecting icons and color.
79
 
80
  = 1.8.0 - 07/10/2014 =
81
+ * New Feature - Products per Page - Add "products per page" option for customers (i.e. front end).
82
 
83
  = 1.9.0 - 21/10/2014 =
84
+ * Upgrade Feature - Custom Price Labels - Add "local remove".
85
+ * Upgrade Feature - Orders - Bulk orders (start from global discount for all products; later - discounts for individual products).
86
+ * Upgrade Feature - Custom Price Labels - Add different labels for archives, single, homepage, related. Add option to select which price hooks to use. Different labels for variable and variation.
87
+ * Upgrade Feature - Cart - Cart discount.
88
 
89
  = 2.0.0 - 01/11/2014 =
90
+ * Dev - Major source code, documentation, locking mechanism etc. recheck.
91
 
92
  == Changelog ==
93
 
94
+ = 1.5.0 - 13/09/2014 =
95
+ * Dev - Orders - Renumerate orders tool compatibility with WooCommerce 2.2.x.
96
+ * Dev - Orders - Custom Order Statuses compatibility with WooCommerce 2.2.x.
97
+ * Dev - Orders - Renumerate orders tool moved to WooCommerce > Jetpack Tools.
98
+ * Fix - PDF Invoices - `Order Shipping Price` position in `Totals` on admin settings page, fixed.
99
+ * Dev - PDF Invoices - Save as pdf option added.
100
+
101
  = 1.4.0 - 07/09/2014 =
102
  * Dev - Custom Price Labels - Support for price labels showing on Pages, added. Suggested by Axel.
103
  * Fix - PDF Invoices - Bug with some item table columns not showing, fixed. Suggested by Tomas.
104
  * Dev - PDF Invoices - Discount as separate item option added.
105
  * Dev - PDF Invoices - Shipping as separate item option added. Suggested by Tomas.
106
+ * Dev - Old Slugs and Custom Order Statuses tools moved to WooCommerce > Jetpack Tools.
107
 
108
  = 1.3.0 - 25/08/2014 =
109
  * Feature Upgraded - PDF Invoices - Major upgrade: single item price, item and line taxes, payment and shipping methods, additional footer, font size, custom css added.
woocommerce-jetpack.php CHANGED
@@ -3,7 +3,7 @@
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.4.0
7
  Author: Algoritmika Ltd
8
  Author URI: http://www.algoritmika.com
9
  Copyright: © 2014 Algoritmika Ltd.
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.5.0
7
  Author: Algoritmika Ltd
8
  Author URI: http://www.algoritmika.com
9
  Copyright: © 2014 Algoritmika Ltd.