Abandoned Cart Lite for WooCommerce - Version 3.5

Version Description

  • This version has 1 new feature and 3 enhancements.

  • New Feature - New setting named as "Enable tracking carts when customer doesn't enter details" on the settings page. When this setting is enabled it will enable tracking of abandoned products & carts even if the customer does not visit the checkout page or does not enter any details on the checkout page like Name or Email. Tracking will begin as soon as a visitor adds a product to their cart and visits the cart page.

  • Enhancement - The default settings value for "Cart abandoned cut-off time" for logged-in users has been modified to 10 minutes.

  • Enhancement - The Settings tab of the plugin has been redesigned. Now, the plugin will display 2 sub-tabs for different settings. The sub-tabs are named as "General Settings" & "Email Sending Settings". The settings of add/edit email template "Send From This Name", "Send From This Email Address" & "Send Reply Emails to" has been moved to the Settings -> Email Sending Setting tab.

  • Enhancement - In this version we have introduced three new views of abandoned orders in the Abandoned Orders tab. The views named are "All", "Registered Users", "Guest Users" & "Carts without Customer Details". The "Registered Users" view will display only the logged-in user's abandoned carts. The "Guest Users" view will display the guest user's carts & "Carts without Customer Details" view will display all the abandoned carts of the guest users who have not entered an email address or any information on the checkout page.

Download this release

Release Info

Developer ashokrane
Plugin Icon 128x128 Abandoned Cart Lite for WooCommerce
Version 3.5
Comparing to
See all releases

Code changes from version 2.6 to 3.5

Files changed (55) hide show
  1. css/view.abadoned.orders.style.css → assets/css/view.abandoned.orders.style.css +0 -0
  2. {images → assets/images}/abandoned_cart_small.png +0 -0
  3. {images → assets/images}/ac_editor_icon.png +0 -0
  4. {images → assets/images}/ac_tab_icon.png +0 -0
  5. {images → assets/images}/check.jpg +0 -0
  6. {images → assets/images}/copy.png +0 -0
  7. {images → assets/images}/delete.png +0 -0
  8. {images → assets/images}/edit.png +0 -0
  9. {images → assets/images}/handbag.jpg +0 -0
  10. {images → assets/images}/shoes.jpg +0 -0
  11. {images → assets/images}/spectre.jpg +0 -0
  12. {js → assets/js}/abandoncart_plugin_button.js +7 -0
  13. {js → assets/js}/jquery.tipTip.minified.js +0 -0
  14. class-abandoned-orders-table.php +0 -438
  15. class-product-report-table.php +0 -301
  16. class-recover-orders-table.php +0 -404
  17. class-templates-table.php +0 -295
  18. cron/send_email.php +0 -447
  19. cron/wcal_send_email.php +496 -0
  20. {languages → i18n/languages}/messages.pot +0 -0
  21. {languages → i18n/languages}/woocommerce-ac-de_DE.mo +0 -0
  22. {languages → i18n/languages}/woocommerce-ac-de_DE.po +0 -0
  23. {languages → i18n/languages}/woocommerce-ac-he_IL.mo +0 -0
  24. {languages → i18n/languages}/woocommerce-ac-he_IL.po +0 -0
  25. {languages → i18n/languages}/woocommerce-ac-sk_SK.mo +0 -0
  26. {languages → i18n/languages}/woocommerce-ac-sk_SK.po +0 -0
  27. {languages → i18n/languages}/woocommerce-ac.mo +0 -0
  28. i18n/languages/woocommerce-ac.po +500 -0
  29. i18n/languages/woocommerce-ac.pot +505 -0
  30. includes/classes/class-wcal-abandoned-orders-table.php +479 -0
  31. includes/classes/class-wcal-aes-counter.php +171 -0
  32. includes/classes/class-wcal-aes.php +190 -0
  33. includes/classes/class-wcal-product-report-table.php +258 -0
  34. includes/classes/class-wcal-recover-orders-table.php +371 -0
  35. includes/classes/class-wcal-templates-table.php +259 -0
  36. includes/wcal-common.php +46 -0
  37. actions.php → includes/wcal_actions.php +19 -19
  38. includes/wcal_class-guest.php +256 -0
  39. default-settings.php → includes/wcal_default-settings.php +13 -21
  40. languages/woocommerce-ac.po +0 -269
  41. pagination.class.php +0 -204
  42. readme.txt +137 -9
  43. screenshot-1.png +0 -0
  44. screenshot-2.png +0 -0
  45. screenshot-3.png +0 -0
  46. screenshot-4.png +0 -0
  47. screenshot-5.png +0 -0
  48. views/wacp-email-template-preview.php +0 -52
  49. views/wacp-wc-email-template-preview.php +0 -47
  50. views/wcal-email-template-preview.php +50 -0
  51. views/wcal-wc-email-template-preview.php +45 -0
  52. woo-includes/class-wc-dependencies.php +0 -29
  53. woo-includes/woo-functions.php +0 -97
  54. woocommerce-ac.php +3095 -2628
  55. woocommerce_guest_ac.class.php +0 -208
css/view.abadoned.orders.style.css → assets/css/view.abandoned.orders.style.css RENAMED
File without changes
{images → assets/images}/abandoned_cart_small.png RENAMED
File without changes
{images → assets/images}/ac_editor_icon.png RENAMED
File without changes
{images → assets/images}/ac_tab_icon.png RENAMED
File without changes
{images → assets/images}/check.jpg RENAMED
File without changes
{images → assets/images}/copy.png RENAMED
File without changes
{images → assets/images}/delete.png RENAMED
File without changes
{images → assets/images}/edit.png RENAMED
File without changes
{images → assets/images}/handbag.jpg RENAMED
File without changes
{images → assets/images}/shoes.jpg RENAMED
File without changes
{images → assets/images}/spectre.jpg RENAMED
File without changes
{js → assets/js}/abandoncart_plugin_button.js RENAMED
@@ -49,6 +49,13 @@
49
  onclick: function() {
50
  editor.insertContent(this.value());
51
  }
 
 
 
 
 
 
 
52
  }
53
 
54
  ]
49
  onclick: function() {
50
  editor.insertContent(this.value());
51
  }
52
+ },
53
+ {
54
+ text: 'Unsubscribe Link',
55
+ value: '{{cart.unsubscribe}}',
56
+ onclick: function() {
57
+ editor.insertContent(this.value());
58
+ }
59
  }
60
 
61
  ]
{js → assets/js}/jquery.tipTip.minified.js RENAMED
File without changes
class-abandoned-orders-table.php DELETED
@@ -1,438 +0,0 @@
1
- <?php
2
-
3
- // Load WP_List_Table if not loaded
4
- if ( ! class_exists( 'WP_List_Table' ) ) {
5
- require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
6
- }
7
-
8
- class WACP_Abandoned_Orders_Table extends WP_List_Table {
9
-
10
- /**
11
- * Number of results to show per page
12
- *
13
- * @var string
14
- * @since 2.5.2
15
- */
16
- public $per_page = 30;
17
-
18
- /**
19
- * URL of this page
20
- *
21
- * @var string
22
- * @since 2.5.2
23
- */
24
- public $base_url;
25
-
26
- /**
27
- * Total number of bookings
28
- *
29
- * @var int
30
- * @since 2.5.2
31
- */
32
- public $total_count;
33
-
34
- /**
35
- * Get things started
36
- *
37
- * @see WP_List_Table::__construct()
38
- */
39
- public function __construct() {
40
-
41
- global $status, $page;
42
-
43
- // Set parent defaults
44
- parent::__construct( array(
45
- 'singular' => __( 'abandoned_order_id', 'woocommerce-ac' ), //singular name of the listed records
46
- 'plural' => __( 'abandoned_order_ids', 'woocommerce-ac' ), //plural name of the listed records
47
- 'ajax' => false // Does this table support ajax?
48
- ) );
49
- $this->wcap_get_abadoned_orders_count_lite();
50
- $this->process_bulk_action();
51
- $this->base_url = admin_url( 'admin.php?page=woocommerce_ac_page' );
52
- }
53
-
54
- public function wcap_abadoned_order_prepare_items() {
55
-
56
- $columns = $this->get_columns();
57
- $hidden = array(); // No hidden columns
58
- $sortable = $this->get_sortable_columns();
59
- $data = $this->wacp_abandoned_cart_lite_data();
60
-
61
- $this->_column_headers = array( $columns, $hidden, $sortable);
62
- $total_items = $this->total_count;
63
-
64
- if ( count($data) > 0 ){
65
- $this->items = $data;
66
- }else{
67
- $this->items = '';
68
- }
69
- $this->set_pagination_args( array(
70
- 'total_items' => $total_items, // WE have to calculate the total number of items
71
- 'per_page' => $this->per_page, // WE have to determine how many items to show on a page
72
- 'total_pages' => ceil( $total_items / $this->per_page ) // WE have to calculate the total number of pages
73
- )
74
- );
75
- }
76
-
77
- public function get_columns() {
78
-
79
-
80
- $columns = array();
81
- $columns = array(
82
- 'cb' => '<input type="checkbox" />',
83
- 'id' => __( 'Id', 'woocommerce-ac' ),
84
- 'email' => __( 'Email Address', 'woocommerce-ac' ),
85
- 'customer' => __( 'Customer', 'woocommerce-ac' ),
86
- 'order_total' => __( 'Order Total', 'woocommerce-ac' ),
87
- 'date' => __( 'Abandoned Date', 'woocommerce-ac' ),
88
- 'status' => __( 'Status of Cart', 'woocommerce-ac' )
89
- );
90
-
91
- return apply_filters( 'wcap_abandoned_orders_columns', $columns );
92
- }
93
-
94
- /***
95
- * It is used to add the check box for the items
96
- */
97
- function column_cb( $item ){
98
-
99
- $abadoned_order_id = '';
100
- if( isset($item->id) && "" != $item->id ){
101
- $abadoned_order_id = $item->id;
102
- }
103
- return sprintf(
104
- '<input type="checkbox" name="%1$s[]" value="%2$s" />',
105
- 'abandoned_order_id',
106
- $abadoned_order_id
107
- );
108
- }
109
-
110
- public function get_sortable_columns() {
111
- $columns = array(
112
- 'date' => array( 'date', false ),
113
- 'status' => array( 'status',false),
114
- );
115
- return apply_filters( 'wcap_abandoned_orders_sortable_columns', $columns );
116
- }
117
-
118
- /**
119
- * Render the Email Column
120
- *
121
- * @access public
122
- * @since 2.4.8
123
- * @param array $abadoned_row_info Contains all the data of the abandoned order tabs row
124
- * @return string Data shown in the Email column
125
- *
126
- * This function used for individual delete of row, It is for hover effect delete.
127
- */
128
- public function column_email( $abadoned_row_info ) {
129
-
130
- $row_actions = array();
131
- $value = '';
132
- $abadoned_order_id = 0;
133
- if( isset($abadoned_row_info->email) ){
134
-
135
- $abadoned_order_id = $abadoned_row_info->id ;
136
- $row_actions['delete'] = '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'wcap_delete', 'abandoned_order_id' => $abadoned_row_info->id ), $this->base_url ), 'abandoned_order_nonce') . '">' . __( 'Delete', 'woocommerce-ac' ) . '</a>';
137
-
138
- $email = $abadoned_row_info->email;
139
-
140
- $value = $email . $this->row_actions( $row_actions );
141
-
142
- }
143
-
144
- return apply_filters( 'wcap_abandoned_orders_single_column', $value, $abadoned_order_id, 'email' );
145
- }
146
-
147
- /***
148
- * This function used to get the abadoned orders count
149
- */
150
- public function wcap_get_abadoned_orders_count_lite() {
151
-
152
- global $wpdb;
153
- $results = array();
154
-
155
- $blank_cart_info = '{"cart":[]}';
156
- $blank_cart_info_guest = '[]';
157
-
158
- // non-multisite - regular table name
159
- $query = "SELECT wpac . * , wpu.user_login, wpu.user_email
160
- FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac
161
- LEFT JOIN ".$wpdb->base_prefix."users AS wpu ON wpac.user_id = wpu.id
162
- WHERE recovered_cart = '0'
163
- AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' ORDER BY wpac.abandoned_cart_time DESC";
164
-
165
- $results = $wpdb->get_results($query);
166
-
167
- $abadoned_orders = count($results);
168
- $this->total_count = $abadoned_orders;
169
- }
170
- public function wacp_abandoned_cart_lite_data() {
171
- global $wpdb;
172
-
173
- $return_bookings = array();
174
- $per_page = $this->per_page;
175
- $results = array();
176
-
177
- $blank_cart_info = '{"cart":[]}';
178
- $blank_cart_info_guest = '[]';
179
-
180
- // non-multisite - regular table name
181
- $query = "SELECT wpac . * , wpu.user_login, wpu.user_email
182
- FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac
183
- LEFT JOIN ".$wpdb->base_prefix."users AS wpu ON wpac.user_id = wpu.id
184
- WHERE recovered_cart = '0'
185
- AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' ORDER BY wpac.abandoned_cart_time DESC";
186
-
187
- $results = $wpdb->get_results($query);
188
-
189
- $i = 0;
190
-
191
- foreach ( $results as $key => $value ) {
192
-
193
- $return_abadoned_orders[$i] = new stdClass();
194
-
195
- if ( $value->user_type == "GUEST" ) {
196
- $query_guest = "SELECT * from `" . $wpdb->prefix . "ac_guest_abandoned_cart_history_lite` WHERE id = %d";
197
- $results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $value->user_id ) );
198
- }
199
- $abandoned_order_id = $value->id;
200
- $user_id = $value->user_id;
201
- $user_login = $value->user_login;
202
-
203
- if ( $value->user_type == "GUEST" ) {
204
-
205
- if ( isset( $results_guest[0]->email_id ) ) $user_email = $results_guest[0]->email_id;
206
-
207
- if ( isset( $results_guest[0]->billing_first_name ) ) $user_first_name = $results_guest[0]->billing_first_name;
208
- else $user_first_name = "";
209
-
210
- if ( isset( $results_guest[0]->billing_last_name ) ) $user_last_name = $results_guest[0]->billing_last_name;
211
- else $user_last_name = "";
212
-
213
- } else {
214
-
215
- $user_email_temp = get_user_meta($value->user_id, 'billing_email');
216
- if ( isset( $user_email_temp[0] ) ) {
217
- $user_email = $user_email_temp[0];
218
- }else {
219
- $user_email = "";
220
- }
221
-
222
- $user_first_name_temp = get_user_meta($value->user_id, 'first_name');
223
- if ( isset( $user_first_name_temp[0] ) ) {
224
- $user_first_name = $user_first_name_temp[0];
225
- }else {
226
- $user_first_name = "";
227
- }
228
-
229
- $user_last_name_temp = get_user_meta($value->user_id, 'last_name');
230
- if ( isset( $user_last_name_temp[0] ) ) {
231
- $user_last_name = $user_last_name_temp[0];
232
- }else {
233
- $user_last_name = "";
234
- }
235
- }
236
-
237
- $cart_info = json_decode( $value->abandoned_cart_info );
238
- $order_date = "";
239
- $cart_update_time = $value->abandoned_cart_time;
240
-
241
- if ( $cart_update_time != "" && $cart_update_time != 0 ) {
242
- $order_date = date( 'd M, Y h:i A', $cart_update_time );
243
- }
244
-
245
- $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
246
- $cut_off_time = $ac_cutoff_time * 60;
247
- $current_time = current_time( 'timestamp' );
248
- $compare_time = $current_time - $cart_update_time;
249
- $cart_details = array();
250
- if( isset( $cart_info->cart ) ){
251
- $cart_details = $cart_info->cart;
252
- }
253
- $line_total = 0;
254
-
255
- if ( count( $cart_details ) > 0 ) {
256
-
257
- foreach ( $cart_details as $k => $v ) {
258
-
259
- if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
260
- $line_total = $line_total + $v->line_total + $v->line_subtotal_tax;
261
- } else {
262
- $line_total = $line_total + $v->line_total;
263
- }
264
- }
265
- }
266
- $line_total = round( $line_total, 2 );
267
- $quantity_total = 0;
268
-
269
- if ( count( $cart_details ) > 0) {
270
-
271
- foreach ( $cart_details as $k => $v ) {
272
- $quantity_total = $quantity_total + $v->quantity;
273
- }
274
- }
275
-
276
- if ( 1 == $quantity_total ) {
277
- $item_disp = __("item", "woocommerce-ac");
278
- } else {
279
- $item_disp = __("items", "woocommerce-ac");
280
- }
281
-
282
- if( $value->cart_ignored == 0 && $value->recovered_cart == 0 ) {
283
- $ac_status = __("Abandoned", "woocommerce-ac");
284
- } elseif( $value->cart_ignored == 1 && $value->recovered_cart == 0 ) {
285
- $ac_status = __("Abandoned but new","woocommerce-ac")."</br>". __("cart created after this", "woocommerce-ac");
286
- } else {
287
- $ac_status = "";
288
- }
289
-
290
- if ( $compare_time > $cut_off_time && $ac_status != "" ) {
291
-
292
- if( $quantity_total > 0 ) {
293
-
294
- $abandoned_order_id = $abandoned_order_id;
295
- $customer_information = $user_first_name . " ".$user_last_name;
296
- $return_abadoned_orders[ $i ]->id = $abandoned_order_id;
297
- $return_abadoned_orders[ $i ]->email = $user_email;
298
- $return_abadoned_orders[ $i ]->customer = $customer_information;
299
- $return_abadoned_orders[ $i ]->order_total = get_woocommerce_currency_symbol() . "" . $line_total;
300
- $return_abadoned_orders[ $i ]->date = $order_date;
301
- $return_abadoned_orders[ $i ]->status = $ac_status;
302
-
303
- }
304
- $i++;
305
- }
306
-
307
- }
308
-
309
- // sort for order date
310
- if (isset($_GET['orderby']) && $_GET['orderby'] == 'date') {
311
- if (isset($_GET['order']) && $_GET['order'] == 'asc') {
312
- usort( $return_abadoned_orders, array( __CLASS__ ,"wcap_class_order_date_asc") );
313
- }
314
- else {
315
- usort( $return_abadoned_orders, array( __CLASS__ ,"wcap_class_order_date_dsc") );
316
- }
317
- }
318
-
319
- // sort for customer name
320
- else if ( isset( $_GET['orderby']) && $_GET['orderby'] == 'status' ) {
321
- if ( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
322
- usort( $return_abadoned_orders, array( __CLASS__ ,"wcap_class_status_asc" ) );
323
- }
324
- else {
325
- usort( $return_abadoned_orders, array( __CLASS__ ,"wcap_class_status_dsc" ) );
326
- }
327
- }
328
-
329
- if (isset($_GET['paged']) && $_GET['paged'] > 1) {
330
- $page_number = $_GET['paged'] - 1;
331
- $k = $per_page * $page_number;
332
- }
333
- else {
334
- $k = 0;
335
- }
336
- $return_abadoned_orders_display = array();
337
- for ($j = $k;$j < ($k+$per_page);$j++) {
338
- if (isset($return_abadoned_orders[$j])) {
339
- $return_abadoned_orders_display[$j] = $return_abadoned_orders[$j];
340
- }
341
- else {
342
- break;
343
- }
344
- }
345
- return apply_filters( 'wcap_abandoned_orders_table_data', $return_abadoned_orders_display );
346
- }
347
- function wcap_class_order_date_asc($value1,$value2) {
348
-
349
- $date_two = $date_one = '';
350
- $value_one = $value1->date;
351
- $value_two = $value2->date;
352
-
353
- $date_formatted_one = date_create_from_format( 'd M, Y h:i A', $value_one );
354
- if ( isset( $date_formatted_one ) && $date_formatted_one != '' ) {
355
- $date_one = date_format( $date_formatted_one, 'Y-m-d' );
356
- }
357
-
358
- $date_formatted_two = date_create_from_format( 'd M, Y h:i A', $value_two );
359
- if ( isset( $date_formatted_two ) && $date_formatted_two != '' ) {
360
- $date_two = date_format( $date_formatted_two, 'Y-m-d' );
361
- }
362
- return strtotime($date_one) - strtotime($date_two);
363
- }
364
- function wcap_class_order_date_dsc($value1,$value2) {
365
-
366
- $date_two = $date_one = '';
367
- $value_one = $value1->date;
368
- $value_two = $value2->date;
369
-
370
- $date_formatted_one = date_create_from_format( 'd M, Y h:i A', $value_one );
371
- if ( isset( $date_formatted_one ) && $date_formatted_one != '' ) {
372
- $date_one = date_format( $date_formatted_one, 'Y-m-d' );
373
- }
374
-
375
- $date_formatted_two = date_create_from_format( 'd M, Y h:i A', $value_two );
376
- if ( isset( $date_formatted_two ) && $date_formatted_two != '' ) {
377
- $date_two = date_format( $date_formatted_two, 'Y-m-d' );
378
- }
379
-
380
- return strtotime($date_two) - strtotime($date_one);
381
- }
382
-
383
- function wcap_class_status_asc($value1,$value2) {
384
- return strcasecmp($value1->status,$value2->status );
385
- }
386
-
387
- function wcap_class_status_dsc ($value1,$value2) {
388
- return strcasecmp($value2->status,$value1->status );
389
- }
390
-
391
- public function column_default( $wcap_abadoned_orders, $column_name ) {
392
- $value = '';
393
- switch ( $column_name ) {
394
- case 'id' :
395
- if(isset($wcap_abadoned_orders->id)){
396
- $value = '<strong><a href="admin.php?page=woocommerce_ac_page&action=orderdetails&id='.$wcap_abadoned_orders->id.' ">'.$wcap_abadoned_orders->id.'</a> </strong>';
397
- }
398
- break;
399
- case 'customer' :
400
- if(isset($wcap_abadoned_orders->customer)){
401
- $value = $wcap_abadoned_orders->customer;
402
- }
403
- break;
404
-
405
- case 'order_total' :
406
- if(isset($wcap_abadoned_orders->order_total)){
407
- $value = $wcap_abadoned_orders->order_total;
408
- }
409
- break;
410
-
411
- case 'date' :
412
- if(isset($wcap_abadoned_orders->date)){
413
- $value = $wcap_abadoned_orders->date;
414
- }
415
- break;
416
-
417
- case 'status' :
418
- if(isset($wcap_abadoned_orders->status)){
419
- $value = $wcap_abadoned_orders->status;
420
- }
421
- break;
422
-
423
- default:
424
-
425
- $value = isset( $booking->$column_name ) ? $booking->$column_name : '';
426
- break;
427
- }
428
-
429
- return apply_filters( 'wcap_abandoned_orders_column_default', $value, $wcap_abadoned_orders, $column_name );
430
- }
431
-
432
- public function get_bulk_actions() {
433
- return array(
434
- 'wcap_delete' => __( 'Delete', 'woocommerce-ac' )
435
- );
436
- }
437
- }
438
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
class-product-report-table.php DELETED
@@ -1,301 +0,0 @@
1
- <?php
2
-
3
- if( session_id() === '' ){
4
- //session has not started
5
- session_start();
6
- }
7
-
8
-
9
- // Load WP_List_Table if not loaded
10
- if ( ! class_exists( 'WP_List_Table' ) ) {
11
- require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
12
- }
13
-
14
- class WACP_Product_Report_Table extends WP_List_Table {
15
-
16
- /**
17
- * Number of results to show per page
18
- *
19
- * @var string
20
- * @since 2.5.3
21
- */
22
- public $per_page = 30;
23
-
24
- /**
25
- * URL of this page
26
- *
27
- * @var string
28
- * @since 2.5.3
29
- */
30
- public $base_url;
31
-
32
- /**
33
- * Total number of recovred orders
34
- *
35
- * @var int
36
- * @since 2.5.3
37
- */
38
- public $total_count;
39
-
40
-
41
- /**
42
- * Total number of recovred orders
43
- *
44
- * @var int
45
- * @since 2.5.3
46
- */
47
- public $open_emails;
48
-
49
- /**
50
- * Total amount of abadoned orders
51
- *
52
- * @var int
53
- * @since 2.5.3
54
- */
55
- public $link_click_count;
56
-
57
- /**
58
- * Total number recovred orders
59
- *
60
- * @var int
61
- * @since 2.5.3
62
- */
63
- public $start_date_db;
64
-
65
- /**
66
- * Total number recovred orders total
67
- *
68
- * @var int
69
- * @since 2.5.3
70
- */
71
- public $end_date_db;
72
-
73
- public $duration;
74
-
75
- /**
76
- * Get things started
77
- *
78
- * @see WP_List_Table::__construct()
79
- */
80
- public function __construct() {
81
-
82
- global $status, $page;
83
-
84
- // Set parent defaults
85
- parent::__construct( array(
86
- 'singular' => __( 'product_id', 'woocommerce-ac' ), //singular name of the listed records
87
- 'plural' => __( 'product_ids', 'woocommerce-ac' ), //plural name of the listed records
88
- 'ajax' => false // Does this table support ajax?
89
- ) );
90
-
91
- $this->base_url = admin_url( 'admin.php?page=woocommerce_ac_page&action=stats' );
92
- }
93
-
94
- public function wcap_product_report_prepare_items_lite() {
95
-
96
- $columns = $this->get_columns();
97
- $hidden = array(); // No hidden columns
98
-
99
- //$sortable = $this->product_report_sortable_columns();
100
-
101
- $data = $this->wacp_product_report_lite_data ();
102
-
103
- $total_items = $this->total_count;
104
- $this->items = $data;
105
-
106
- //$this->_column_headers = array( $columns, $hidden, $sortable);
107
- $this->_column_headers = array( $columns, $hidden);
108
- $this->set_pagination_args( array(
109
- 'total_items' => $total_items, // WE have to calculate the total number of items
110
- 'per_page' => $this->per_page, // WE have to determine how many items to show on a page
111
- 'total_pages' => ceil( $total_items / $this->per_page ) // WE have to calculate the total number of pages
112
- )
113
- );
114
-
115
- }
116
-
117
- public function get_columns() {
118
-
119
- $columns = array(
120
-
121
- 'product_name' => __( 'Product Name', 'woocommerce-ac' ),
122
- 'abandoned_number' => __( 'Number of Times Abandoned', 'woocommerce-ac' ),
123
- 'recover_number' => __( 'Number of Times Recovered', 'woocommerce-ac' )
124
-
125
- );
126
-
127
- return apply_filters( 'wcap_product_report_columns', $columns );
128
- }
129
-
130
- // public function product_report_sortable_columns() {
131
- // $columns = array(
132
- // 'abandoned_number' => array( 'abandoned_number', false ),
133
- // 'recover_number' => array( 'recover_number',false),
134
- // );
135
- // return apply_filters( 'wcap_product_report_columns', $columns );
136
- // }
137
- /**
138
- * Render the user name Column
139
- *
140
- * @access public
141
- * @since 2.5.3
142
- * @param array $abadoned_row_info Contains all the data of the template row
143
- * @return string Data shown in the Email column
144
- *
145
- * This function used for individual delete of row, It is for hover effect delete.
146
- */
147
- public function wacp_product_report_lite_data () {
148
- global $wpdb;
149
-
150
- $wcap_class = new woocommerce_abandon_cart ();
151
- $i = 1;
152
-
153
- $order = "desc";
154
- $query = "SELECT abandoned_cart_time, abandoned_cart_info, recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` ORDER BY recovered_cart DESC";
155
- $recover_query = $wpdb->get_results( $query );
156
- $rec_carts_array = array ( );
157
- $recover_product_array = array( );
158
-
159
- foreach ( $recover_query as $recovered_cart_key => $recovered_cart_value ) {
160
- $recovered_cart_info = json_decode( $recovered_cart_value->abandoned_cart_info );
161
- $recovered_cart_dat = json_decode( $recovered_cart_value->recovered_cart);
162
- $order_date = "";
163
- $cart_update_time = $recovered_cart_value->abandoned_cart_time;
164
- $quantity_total = 0;
165
- $cart_details = array();
166
- if( isset( $recovered_cart_info->cart ) ){
167
- $cart_details = $recovered_cart_info->cart;
168
- }
169
- if ( count( $cart_details ) > 0) {
170
-
171
- foreach ( $cart_details as $k => $v ) {
172
-
173
- $quantity_total = $quantity_total + $v->quantity;
174
- }
175
- }
176
-
177
- if ( $cart_update_time != "" && $cart_update_time != 0 ) {
178
- $order_date = date( 'd M, Y h:i A', $cart_update_time );
179
- }
180
- $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
181
- $cut_off_time = $ac_cutoff_time * 60 ;
182
- $current_time = current_time( 'timestamp' );
183
- $compare_time = $current_time - $cart_update_time;
184
- if ( is_array( $recovered_cart_info ) || is_object( $recovered_cart_info ) ) {
185
- foreach ( $recovered_cart_info as $rec_cart_key => $rec_cart_value ) {
186
- foreach ( $rec_cart_value as $rec_product_id_key => $rec_product_id_value ) {
187
- $product_id = $rec_product_id_value->product_id;
188
- if ( $compare_time > $cut_off_time ) {
189
- $rec_carts_array [] = $product_id;
190
- }
191
- if($recovered_cart_dat != 0) {
192
- $recover_product_array[] = $product_id;
193
-
194
-
195
- }
196
- }
197
- }
198
- }
199
- }
200
-
201
- $count = array_count_values( $rec_carts_array );
202
- $count1 = $count;
203
- $count_new = $wcap_class->bubble_sort_function ( $count1 ,$order );
204
- $recover_cart = "0";
205
- $count_css = 0;
206
- $chunck_array = array_chunk( $count_new,10, true ); // keep True for retaing the Array Index number which is product ids in our case.
207
-
208
- $chunck_array_value = array();
209
-
210
- foreach ( $chunck_array as $chunck_array_key => $chunck_array_value ) {
211
-
212
- foreach ( $chunck_array_value as $k => $v){
213
-
214
- $return_product_report[$i] = new stdClass();
215
-
216
- $prod_name = get_post( $k );
217
- $product_name = $prod_name->post_title;
218
- $abandoned_count = $v;
219
- $recover = array_count_values( $recover_product_array );
220
- foreach ( $recover as $ke => $ve ) {
221
- if( array_key_exists ( $ke, $count ) ) {
222
-
223
- if ( $ke == $k ) {
224
- $recover_cart = $ve;
225
- }
226
- }
227
- if( ! array_key_exists ( $k, $recover ) ) {
228
- $recover_cart = "0";
229
- }
230
- }
231
-
232
- $return_product_report[ $i ]->product_name = $product_name ;
233
- $return_product_report[ $i ]->abandoned_number = $abandoned_count;
234
- $return_product_report[ $i ]->recover_number = $recover_cart;
235
- $return_product_report[ $i ]->product_id = $k;
236
- $i++;
237
-
238
- }
239
- }
240
-
241
- $this->total_count = count ( $chunck_array_value ) > 0 ? count ( $chunck_array_value ) : 0 ;
242
-
243
-
244
- $per_page = $this->per_page;
245
-
246
- if ( isset( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
247
- $page_number = $_GET['paged'] - 1;
248
- $k = $per_page * $page_number;
249
- }else {
250
- $k = 1;
251
- }
252
-
253
- $return_product_report_display = array();
254
-
255
-
256
- for ( $j = $k; $j < ( $k + $per_page ); $j++ ) {
257
-
258
- if ( isset( $return_product_report[ $j ] ) ) {
259
- $return_product_report_display[ $j ] = $return_product_report[ $j ];
260
- }else {
261
- break;
262
- }
263
- }
264
-
265
-
266
-
267
- return apply_filters( 'wcap_product_report_table_data', $return_product_report_display );
268
- }
269
-
270
- public function column_default( $wcap_sent_emails, $column_name ) {
271
- $value = '';
272
- switch ( $column_name ) {
273
-
274
- case 'product_name' :
275
- if(isset($wcap_sent_emails->product_name)){
276
-
277
- $value = "<a href= post.php?post=$wcap_sent_emails->product_id&action=edit title = product name > $wcap_sent_emails->product_name </a>";
278
- }
279
- break;
280
-
281
- case 'abandoned_number' :
282
- if(isset($wcap_sent_emails->abandoned_number)){
283
- $value = $wcap_sent_emails->abandoned_number;
284
- }
285
- break;
286
-
287
- case 'recover_number' :
288
- if(isset($wcap_sent_emails->recover_number)){
289
- $value = $wcap_sent_emails->recover_number;
290
- }
291
- break;
292
- default:
293
-
294
- $value = isset( $wcap_sent_emails->$column_name ) ? $wcap_sent_emails->$column_name : '';
295
- break;
296
- }
297
-
298
- return apply_filters( 'wcap_product_report_column_default', $value, $wcap_sent_emails, $column_name );
299
- }
300
- }
301
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
class-recover-orders-table.php DELETED
@@ -1,404 +0,0 @@
1
- <?php
2
-
3
- // Load WP_List_Table if not loaded
4
- if ( ! class_exists( 'WP_List_Table' ) ) {
5
- require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
6
- }
7
-
8
- class WACP_Recover_Orders_Table extends WP_List_Table {
9
-
10
- /**
11
- * Number of results to show per page
12
- *
13
- * @var string
14
- * @since 2.5.2
15
- */
16
- public $per_page = 30;
17
-
18
- /**
19
- * URL of this page
20
- *
21
- * @var string
22
- * @since 2.5.2
23
- */
24
- public $base_url;
25
-
26
- /**
27
- * Total number of recovred orders
28
- *
29
- * @var int
30
- * @since 2.5.2
31
- */
32
- public $total_count;
33
-
34
-
35
- /**
36
- * Total number of recovred orders
37
- *
38
- * @var int
39
- * @since 2.5.2
40
- */
41
- public $total_abandoned_cart_count;
42
-
43
- /**
44
- * Total amount of abadoned orders
45
- *
46
- * @var int
47
- * @since 2.5.2
48
- */
49
- public $total_order_amount;
50
-
51
- /**
52
- * Total number recovred orders
53
- *
54
- * @var int
55
- * @since 2.5.2
56
- */
57
- public $recovered_item;
58
-
59
- /**
60
- * Total number recovred orders total
61
- *
62
- * @var int
63
- * @since 2.5.2
64
- */
65
- public $total_recover_amount;
66
-
67
-
68
- /**
69
- * Get things started
70
- *
71
- * @see WP_List_Table::__construct()
72
- */
73
- public function __construct() {
74
-
75
- global $status, $page;
76
-
77
- // Set parent defaults
78
- parent::__construct( array(
79
- 'singular' => __( 'rec_abandoned_id', 'woocommerce-ac' ), //singular name of the listed records
80
- 'plural' => __( 'rec_abandoned_ids', 'woocommerce-ac' ), //plural name of the listed records
81
- 'ajax' => false // Does this table support ajax?
82
- ) );
83
- $this->wcap_get_recovered_orders_count_lite();
84
-
85
- $this->base_url = admin_url( 'admin.php?page=woocommerce_ac_page&action=stats' );
86
- }
87
-
88
- public function wcap_recovered_orders_prepare_items_lite() {
89
-
90
- $columns = $this->get_columns();
91
- $hidden = array(); // No hidden columns
92
- $sortable = $this->recovered_orders_get_sortable_columns();
93
- $data = $this->wacp_recovered_orders_data_lite();
94
-
95
- $total_items = $this->total_count;
96
- $total_abandoned_cart_count = $this->total_abandoned_cart_count;
97
- $total_order_amount = $this->total_order_amount;
98
- $total_recover_amount = $this->total_recover_amount;
99
- $recovered_item = $this->recovered_item;
100
- $this->items = $data;
101
-
102
- $this->_column_headers = array( $columns, $hidden, $sortable);
103
-
104
- $this->set_pagination_args( array(
105
- 'total_items' => $total_items, // WE have to calculate the total number of items
106
- 'per_page' => $this->per_page, // WE have to determine how many items to show on a page
107
- 'total_pages' => ceil( $total_items / $this->per_page ) // WE have to calculate the total number of pages
108
- )
109
- );
110
- }
111
-
112
- public function get_columns() {
113
-
114
- $columns = array(
115
-
116
- 'user_name' => __( 'User Name', 'woocommerce-ac' ),
117
- 'user_email_id' => __( 'User Email Address', 'woocommerce-ac' ),
118
- 'created_on' => __( 'Cart Abandoned Date', 'woocommerce-ac' ),
119
- 'recovered_date' => __( 'Cart Recovered Date' , 'woocommerce-ac'),
120
- 'order_total' => __( 'Order Total', 'woocommerce-ac' )
121
-
122
- );
123
-
124
- return apply_filters( 'wcap_recovered_orders_columns', $columns );
125
- }
126
-
127
- public function recovered_orders_get_sortable_columns() {
128
- $columns = array(
129
- 'created_on' => array( 'created_on', false ),
130
- 'recovered_date' => array( 'recovered_date',false)
131
- );
132
- return apply_filters( 'wcap_templates_sortable_columns', $columns );
133
- }
134
-
135
- /**
136
- * Render the user name Column
137
- *
138
- * @access public
139
- * @since 2.5.2
140
- * @param array $abadoned_row_info Contains all the data of the template row
141
- * @return string Data shown in the Email column
142
- *
143
- * This function used for individual delete of row, It is for hover effect delete.
144
- */
145
- public function column_user_name( $recovered_orders_row_info ) {
146
-
147
- $row_actions = array();
148
- $value = '';
149
- $recovered_id = 0;
150
-
151
- if( isset($recovered_orders_row_info->user_name ) ){
152
- $recovered_id = $recovered_orders_row_info->recovered_id ;
153
- $row_actions['view_details'] = "<a target=_blank href = post.php?post=$recovered_id&action=edit>". __( 'View Details', 'woocommerce-ac' )."</a>";
154
- $user_name = $recovered_orders_row_info->user_name;
155
- $value = $user_name . $this->row_actions( $row_actions );
156
- }
157
-
158
- return apply_filters( 'wcap_recovered_orders_single_column', $value, $recovered_id, 'email' );
159
- }
160
-
161
- /***
162
- * This function used to get the abadoned orders count
163
- */
164
- public function wcap_get_recovered_orders_count_lite() {
165
-
166
- global $wpdb;
167
-
168
- if ( isset( $_POST['start_date'] ) ) $start_date_range = $_POST['start_date'];
169
- else $start_date_range = "";
170
-
171
- if ( isset( $_POST['end_date'] ) ) $end_date_range = $_POST['end_date'];
172
- else $end_date_range = "";
173
-
174
- $start_date = strtotime( $start_date_range." 00:01:01" );
175
- $end_date = strtotime( $end_date_range." 23:59:59" );
176
-
177
- $query_ac = "SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history_lite WHERE abandoned_cart_time >= %d AND abandoned_cart_time <= %d AND recovered_cart > 0 ORDER BY recovered_cart desc";
178
- $ac_results = $wpdb->get_results( $wpdb->prepare( $query_ac, $start_date, $end_date ) );
179
-
180
- $templates_count = count($ac_results);
181
- $this->total_count = $templates_count;
182
- }
183
-
184
- public function wacp_recovered_orders_data_lite() {
185
- global $wpdb;
186
-
187
- $wcap_class = new woocommerce_abandon_cart ();
188
-
189
- if ( isset( $_POST['duration_select'] ) ) $duration_range = $_POST['duration_select'];
190
- else $duration_range = "";
191
-
192
- if ( $duration_range == "" ) {
193
-
194
- if ( isset( $_GET['duration_select'] ) ) $duration_range = $_GET['duration_select'];
195
- }
196
-
197
- if ( $duration_range == "" ) $duration_range = "last_seven";
198
- else $duration_range = "";
199
-
200
- if ( isset( $_POST['start_date'] ) ) $start_date_range = $_POST['start_date'];
201
- else $start_date_range = "";
202
-
203
- if ( $start_date_range == "" ) {
204
-
205
-
206
- $start_date_range = $wcap_class->start_end_dates[$duration_range]['start_date'];
207
-
208
- }
209
-
210
- if ( isset( $_POST['end_date'] ) ) $end_date_range = $_POST['end_date'];
211
- else $end_date_range = "";
212
-
213
- if ( $end_date_range == "" ) {
214
- $end_date_range = $wcap_class->start_end_dates[$duration_range]['end_date'];
215
- }
216
-
217
- $start_date = strtotime( $start_date_range." 00:01:01" );
218
- $end_date = strtotime( $end_date_range." 23:59:59" );
219
-
220
- $query_ac = "SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history_lite WHERE abandoned_cart_time >= %d AND abandoned_cart_time <= %d AND recovered_cart > 0 ORDER BY recovered_cart desc";
221
- $ac_results = $wpdb->get_results( $wpdb->prepare( $query_ac, $start_date, $end_date ) );
222
-
223
- $query_ac_carts = "SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history_lite WHERE abandoned_cart_time >= %d AND abandoned_cart_time <= %d ";
224
- $ac_carts_results = $wpdb->get_results( $wpdb->prepare( $query_ac_carts, $start_date, $end_date ) );
225
-
226
- $recovered_item = $recovered_total = $count_carts = $total_value = $order_total = 0;
227
-
228
- $return_recovered_orders = array();
229
- $per_page = $this->per_page;
230
- $i = 1;
231
-
232
-
233
- foreach ( $ac_carts_results as $key => $value ) {
234
-
235
- $count_carts += 1;
236
- $cart_detail = json_decode( $value->abandoned_cart_info );
237
- $product_details = array();
238
- if( isset( $cart_detail->cart ) ){
239
- $product_details = $cart_detail->cart;
240
- }
241
- $line_total = 0;
242
-
243
- if ( isset( $product_details ) && count( $product_details ) > 0 && $product_details != false ) {
244
-
245
- foreach ( $product_details as $k => $v ) {
246
-
247
- if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
248
- $line_total = $line_total + $v->line_total + $v->line_subtotal_tax;
249
- } else {
250
- $line_total = $line_total + $v->line_total;
251
- }
252
- }
253
- }
254
- $total_value += $line_total;
255
-
256
- }
257
- $total_value = round( $total_value, 2 );
258
-
259
-
260
- $this->total_order_amount = $total_value ;
261
- $this->total_abandoned_cart_count = $count_carts ;
262
-
263
- $recovered_order_total = 0;
264
-
265
- $this->total_recover_amount = round( $recovered_order_total, 2 ) ;
266
-
267
-
268
- $table_data = "";
269
-
270
- foreach ( $ac_results as $key => $value ) {
271
-
272
-
273
- if( $value->recovered_cart != 0 ) {
274
-
275
- $return_recovered_orders[$i] = new stdClass();
276
-
277
- $recovered_id = $value->recovered_cart;
278
- $rec_order = get_post_meta( $recovered_id );
279
- $woo_order = new WC_Order( $recovered_id );
280
- $recovered_date = strtotime( $woo_order->order_date );
281
- $recovered_date_new = date( 'd M, Y h:i A', $recovered_date );
282
- $recovered_item += 1;
283
-
284
- if ( isset($rec_order) && $rec_order != false ) {
285
- $recovered_total += $rec_order['_order_total'][0];
286
- }
287
- $abandoned_date = date( 'd M, Y h:i A', $value->abandoned_cart_time );
288
- $abandoned_order_id = $value->id;
289
- $billing_first_name = $billing_last_name = $billing_email = '';
290
- $recovered_order_total = 0;
291
-
292
- if ( isset( $rec_order['_billing_first_name'][0] ) ) {
293
- $billing_first_name = $rec_order['_billing_first_name'][0];
294
- }
295
-
296
- if ( isset( $rec_order['_billing_last_name'][0] ) ) {
297
- $billing_last_name = $rec_order['_billing_last_name'][0];
298
- }
299
-
300
- if ( isset( $rec_order['_billing_email'][0] ) ) {
301
- $billing_email = $rec_order['_billing_email'][0];
302
- }
303
-
304
- if ( isset( $rec_order['_order_total'][0] ) ) {
305
- $recovered_order_total = $rec_order['_order_total'][0];
306
- }
307
-
308
- $return_recovered_orders[ $i ]->user_name = $billing_first_name . " " . $billing_last_name ;
309
- $return_recovered_orders[ $i ]->user_email_id = $billing_email;
310
- $return_recovered_orders[ $i ]->created_on = $abandoned_date;
311
- $return_recovered_orders[ $i ]->recovered_date = $recovered_date_new;
312
- $return_recovered_orders[ $i ]->recovered_id = $recovered_id;
313
- $return_recovered_orders[ $i ]->recover_order_date = $recovered_date;
314
- $return_recovered_orders[ $i ]->abandoned_date = $value->abandoned_cart_time;
315
- $return_recovered_orders[ $i ]->order_total = get_woocommerce_currency_symbol() . $recovered_order_total;
316
-
317
-
318
- $this->recovered_item = $recovered_item;
319
- $this->total_recover_amount = round( ( $recovered_order_total + $this->total_recover_amount ) , 2 ) ;
320
-
321
- $i++;
322
- }
323
-
324
-
325
- }
326
-
327
- // sort for order date
328
- if (isset($_GET['orderby']) && $_GET['orderby'] == 'created_on') {
329
- if (isset($_GET['order']) && $_GET['order'] == 'asc') {
330
- usort( $return_recovered_orders, array( __CLASS__ ,"wcap_class_recovered_created_on_asc") );
331
- }else {
332
- usort( $return_recovered_orders, array( __CLASS__ ,"wcap_class_recovered_created_on_dsc") );
333
- }
334
- }
335
-
336
- // sort for customer name
337
- else if ( isset( $_GET['orderby']) && $_GET['orderby'] == 'recovered_date' ) {
338
- if ( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
339
- usort( $return_recovered_orders, array( __CLASS__ ,"wcap_class_recovered_date_asc" ) );
340
- }else {
341
- usort( $return_recovered_orders, array( __CLASS__ ,"wcap_class_recovered_date_dsc" ) );
342
- }
343
- }
344
-
345
-
346
- return apply_filters( 'wcap_recovered_orders_table_data', $return_recovered_orders );
347
- }
348
-
349
- function wcap_class_recovered_created_on_asc($value1,$value2) {
350
- return $value1->abandoned_date - $value2->abandoned_date;
351
- }
352
-
353
- function wcap_class_recovered_created_on_dsc ($value1,$value2) {
354
- return $value2->abandoned_date - $value1->abandoned_date;
355
- }
356
-
357
- function wcap_class_recovered_date_asc($value1,$value2) {
358
- return $value1->recover_order_date - $value2->recover_order_date;
359
- }
360
-
361
- function wcap_class_recovered_date_dsc ($value1,$value2) {
362
- return $value2->recover_order_date - $value1->recover_order_date;
363
- }
364
-
365
-
366
- public function column_default( $wcap_abadoned_orders, $column_name ) {
367
- $value = '';
368
- switch ( $column_name ) {
369
-
370
- case 'user_email_id' :
371
- if(isset($wcap_abadoned_orders->user_email_id)){
372
-
373
- $user_email_id = "<a href= mailto:$wcap_abadoned_orders->user_email_id>". $wcap_abadoned_orders->user_email_id."</a>" ;
374
- $value = $user_email_id;
375
- }
376
- break;
377
-
378
- case 'created_on' :
379
- if(isset($wcap_abadoned_orders->created_on)){
380
- $value = $wcap_abadoned_orders->created_on;
381
- }
382
- break;
383
-
384
- case 'recovered_date' :
385
- if(isset($wcap_abadoned_orders->recovered_date)){
386
- $value = $wcap_abadoned_orders->recovered_date;
387
- }
388
- break;
389
-
390
- case 'order_total' :
391
- if(isset($wcap_abadoned_orders->order_total)){
392
- $value = $wcap_abadoned_orders->order_total;
393
- }
394
- break;
395
- default:
396
-
397
- $value = isset( $wcap_abadoned_orders->$column_name ) ? $wcap_abadoned_orders->$column_name : '';
398
- break;
399
- }
400
-
401
- return apply_filters( 'wcap_recovered_orders_column_default', $value, $wcap_abadoned_orders, $column_name );
402
- }
403
- }
404
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
class-templates-table.php DELETED
@@ -1,295 +0,0 @@
1
- <?php
2
-
3
- // Load WP_List_Table if not loaded
4
- if ( ! class_exists( 'WP_List_Table' ) ) {
5
- require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
6
- }
7
-
8
- class WACP_Templates_Table extends WP_List_Table {
9
-
10
- /**
11
- * Number of results to show per page
12
- *
13
- * @var string
14
- * @since 2.5.2
15
- */
16
- public $per_page = 30;
17
-
18
- /**
19
- * URL of this page
20
- *
21
- * @var string
22
- * @since 2.5.2
23
- */
24
- public $base_url;
25
-
26
- /**
27
- * Total number of bookings
28
- *
29
- * @var int
30
- * @since 2.5.3
31
- */
32
- public $total_count;
33
-
34
- /**
35
- * Get things started
36
- *
37
- * @see WP_List_Table::__construct()
38
- */
39
- public function __construct() {
40
-
41
- global $status, $page;
42
-
43
- // Set parent defaults
44
- parent::__construct( array(
45
- 'singular' => __( 'template_id', 'woocommerce-ac' ), //singular name of the listed records
46
- 'plural' => __( 'template_ids', 'woocommerce-ac' ), //plural name of the listed records
47
- 'ajax' => false // Does this table support ajax?
48
- ) );
49
- $this->wcap_get_templates_count();
50
- $this->process_bulk_action();
51
- $this->base_url = admin_url( 'admin.php?page=woocommerce_ac_page&action=emailtemplates' );
52
- }
53
-
54
- public function wcap_templates_prepare_items() {
55
-
56
- $columns = $this->get_columns();
57
- $hidden = array(); // No hidden columns
58
- $sortable = $this->templates_get_sortable_columns();
59
- $data = $this->wacp_templates_data_lite();
60
-
61
- $this->_column_headers = array( $columns, $hidden, $sortable);
62
- $total_items = $this->total_count;
63
- $this->items = $data;
64
-
65
- $this->set_pagination_args( array(
66
- 'total_items' => $total_items, // WE have to calculate the total number of items
67
- 'per_page' => $this->per_page, // WE have to determine how many items to show on a page
68
- 'total_pages' => ceil( $total_items / $this->per_page ) // WE have to calculate the total number of pages
69
- )
70
- );
71
- }
72
-
73
- public function get_columns() {
74
-
75
- $columns = array(
76
- 'cb' => '<input type="checkbox" />',
77
- 'sr' => __( 'Sr', 'woocommerce-ac' ),
78
- 'template_name' => __( 'Name Of Template', 'woocommerce-ac' ),
79
- 'sent_time' => __( 'Sent After Set Time', 'woocommerce-ac' ),
80
- 'activate' => __( 'Active ?', 'woocommerce-ac' )
81
- );
82
-
83
- return apply_filters( 'wcap_templates_columns', $columns );
84
- }
85
-
86
- /***
87
- * It is used to add the check box for the items
88
- */
89
- function column_cb( $item ){
90
-
91
- $template_id = '';
92
- if( isset($item->id) && "" != $item->id ){
93
- $template_id = $item->id;
94
- }
95
- return sprintf(
96
- '<input type="checkbox" name="%1$s[]" value="%2$s" />',
97
- 'template_id',
98
- $template_id
99
- );
100
- }
101
-
102
- public function templates_get_sortable_columns() {
103
- $columns = array(
104
- 'template_name' => array( 'template_name', false ),
105
- 'sent_time' => array( 'sent_time',false),
106
- );
107
- return apply_filters( 'wcap_templates_sortable_columns', $columns );
108
- }
109
-
110
- /**
111
- * Render the Email Column
112
- *
113
- * @access public
114
- * @since 2.5.2
115
- * @param array $abadoned_row_info Contains all the data of the template row
116
- * @return string Data shown in the Email column
117
- *
118
- * This function used for individual delete of row, It is for hover effect delete.
119
- */
120
- public function column_template_name( $template_row_info ) {
121
-
122
- $row_actions = array();
123
- $value = '';
124
- $template_id = 0;
125
- if( isset($template_row_info->template_name) ){
126
-
127
- $template_id = $template_row_info->id ;
128
-
129
- $row_actions['edit'] = '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'emailtemplates', 'mode'=>'edittemplate', 'id' => $template_row_info->id ), $this->base_url ), 'abandoned_order_nonce') . '">' . __( 'Edit', 'woocommerce-ac' ) . '</a>';
130
- $row_actions['delete'] = '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'wcap_delete_template', 'template_id' => $template_row_info->id ), $this->base_url ), 'abandoned_order_nonce') . '">' . __( 'Delete', 'woocommerce-ac' ) . '</a>';
131
-
132
- $email = $template_row_info->template_name;
133
- $value = $email . $this->row_actions( $row_actions );
134
-
135
- }
136
-
137
- return apply_filters( 'wcap_template_single_column', $value, $template_id, 'email' );
138
- }
139
-
140
- /***
141
- * This function used to get the abadoned orders count
142
- */
143
- public function wcap_get_templates_count() {
144
-
145
- global $wpdb;
146
- $results = array();
147
-
148
- // get main site's table prefix
149
- $main_prefix = $wpdb->get_blog_prefix(1);
150
- $query = "SELECT * FROM `" . $wpdb->prefix."ac_email_templates_lite`";
151
- $results = $wpdb->get_results($query);
152
-
153
- $templates_count = count($results);
154
- $this->total_count = $templates_count;
155
- }
156
-
157
- public function wacp_templates_data_lite() {
158
- global $wpdb;
159
-
160
- $return_bookings = array();
161
- $per_page = $this->per_page;
162
- $results = array();
163
-
164
- $query = "SELECT wpet . * FROM `" . $wpdb->prefix . "ac_email_templates_lite` AS wpet ORDER BY day_or_hour desc , frequency asc";
165
- $results = $wpdb->get_results( $query );
166
-
167
- $i = 1;
168
-
169
- foreach ( $results as $key => $value ) {
170
-
171
- $return_templates_data[$i] = new stdClass();
172
-
173
-
174
- $id = $value->id;
175
- $query_no_emails = "SELECT * FROM " . $wpdb->prefix . "ac_sent_history_lite WHERE template_id= %d";
176
-
177
- $from = $value->from_email;
178
- $subject = $value->subject;
179
- $body = $value->body;
180
- $is_active = $value->is_active;
181
-
182
- if ( $is_active == '1' ) {
183
- $active = "Deactivate";
184
- } else {
185
- $active = "Activate";
186
- }
187
- $frequency = $value->frequency;
188
- $day_or_hour = $value->day_or_hour;
189
-
190
- $return_templates_data[ $i ]->sr = $i;
191
- $return_templates_data[ $i ]->id = $id;
192
- $return_templates_data[ $i ]->template_name = $value->template_name;
193
- $return_templates_data[ $i ]->sent_time = __( $frequency . " " . $day_or_hour . " After Abandonment", 'woocommerce-ac' );
194
- $return_templates_data[ $i ]->activate = $active;
195
- $return_templates_data[ $i ]->is_active = $is_active;
196
- $i++;
197
-
198
- }
199
-
200
- // sort for order date
201
- if (isset($_GET['orderby']) && $_GET['orderby'] == 'template_name') {
202
- if (isset($_GET['order']) && $_GET['order'] == 'asc') {
203
- usort( $return_templates_data, array( __CLASS__ ,"wcap_class_template_name_asc") );
204
- }else {
205
- usort( $return_templates_data, array( __CLASS__ ,"wcap_class_template_name_dsc") );
206
- }
207
- }
208
-
209
- // sort for customer name
210
- else if ( isset( $_GET['orderby']) && $_GET['orderby'] == 'sent_time' ) {
211
- if ( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
212
- usort( $return_templates_data, array( __CLASS__ ,"wcap_class_sent_time_asc" ) );
213
- }else {
214
- usort( $return_templates_data, array( __CLASS__ ,"wcap_class_sent_time_dsc" ) );
215
- }
216
- }
217
-
218
-
219
- return apply_filters( 'wcap_templates_table_data', $return_templates_data );
220
- }
221
-
222
- function wcap_class_template_name_asc($value1,$value2) {
223
- return strcasecmp($value1->template_name,$value2->template_name );
224
- }
225
-
226
- function wcap_class_template_name_dsc ($value1,$value2) {
227
- return strcasecmp($value2->template_name,$value1->template_name );
228
- }
229
-
230
- function wcap_class_sent_time_asc($value1,$value2) {
231
- return strnatcasecmp($value1->sent_time,$value2->sent_time );
232
- }
233
-
234
- function wcap_class_sent_time_dsc ($value1,$value2) {
235
- return strnatcasecmp($value2->sent_time,$value1->sent_time );
236
- }
237
-
238
-
239
- public function column_default( $wcap_abadoned_orders, $column_name ) {
240
- $value = '';
241
- switch ( $column_name ) {
242
-
243
- case 'sr' :
244
- if(isset($wcap_abadoned_orders->sr)){
245
- $value = $wcap_abadoned_orders->sr;
246
- }
247
- break;
248
-
249
- case 'template_name' :
250
- if(isset($wcap_abadoned_orders->template_name)){
251
- $value = $wcap_abadoned_orders->template_name;
252
- }
253
- break;
254
-
255
- case 'sent_time' :
256
- if(isset($wcap_abadoned_orders->sent_time)){
257
- $value = $wcap_abadoned_orders->sent_time;
258
- }
259
- break;
260
-
261
- case 'activate' :
262
- if(isset($wcap_abadoned_orders->activate)){
263
-
264
- $active = $wcap_abadoned_orders->activate;
265
- $id = $wcap_abadoned_orders->id;
266
- $is_active = $wcap_abadoned_orders->is_active;
267
-
268
- $active = '';
269
- if ( $is_active == '1' ) {
270
- $active = "Deactivate";
271
- } else {
272
- $active = "Activate";
273
- }
274
- $active_text = __( $active, 'woocommerce-ac' );
275
- $value = '<a href="#" onclick="activate_email_template('. $id.', '.$is_active.' )"> '.$active_text.'</a>';
276
- //$value = $wcap_abadoned_orders->activate;
277
- }
278
- break;
279
-
280
- default:
281
-
282
- $value = isset( $wcap_abadoned_orders->$column_name ) ? $wcap_abadoned_orders->$column_name : '';
283
- break;
284
- }
285
-
286
- return apply_filters( 'wcap_template_column_default', $value, $wcap_abadoned_orders, $column_name );
287
- }
288
-
289
- public function get_bulk_actions() {
290
- return array(
291
- 'wcap_delete_template' => __( 'Delete', 'woocommerce-ac' )
292
- );
293
- }
294
- }
295
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cron/send_email.php DELETED
@@ -1,447 +0,0 @@
1
- <?php
2
-
3
- if( defined('WP_CONTENT_FOLDERNAME' ) ) {
4
- $wp_content_dir_name = WP_CONTENT_FOLDERNAME;
5
- }elseif( defined( 'WP_CONTENT_DIR' ) ) {
6
- $url = WP_CONTENT_DIR;
7
- $explode_url = explode( "/", $url );
8
- $wp_content_dir_name = end( $explode_url );
9
- }else{
10
- $wp_content_dir_name = "wp-content";
11
- }
12
-
13
-
14
-
15
- $url = dirname( __FILE__ );
16
- $my_url = explode( $wp_content_dir_name , $url );
17
- $path = $my_url[0];
18
-
19
- require_once $path . 'wp-load.php';
20
- /**
21
- * woocommerce_abandon_cart_cron class
22
- **/
23
- if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
24
-
25
- class woocommerce_abandon_cart_cron {
26
-
27
- var $cart_settings_cron;
28
- var $cart_abandon_cut_off_time_cron;
29
-
30
- public function __construct() {
31
-
32
- $this->cart_settings_cron = get_option( 'ac_lite_cart_abandoned_time' );
33
-
34
- $this->cart_abandon_cut_off_time_cron = ( $this->cart_settings_cron ) * 60;
35
- }
36
-
37
- /*-----------------------------------------------------------------------------------*/
38
- /* Class Functions */
39
- /*-----------------------------------------------------------------------------------*/
40
-
41
- /**
42
- * Function to send emails
43
- */
44
- function woocommerce_ac_send_email() {
45
-
46
- global $wpdb, $woocommerce;
47
-
48
- // Delete any guest ac carts that might be pending because user did not go to Order Received page after payment
49
- //search for the guest carts
50
- $query_guest_records = "SELECT id,email_id FROM `" . $wpdb->prefix . "ac_guest_abandoned_cart_history_lite`";
51
- $results_guest_list = $wpdb->get_results( $query_guest_records );
52
-
53
- // This is to ensure that recovered guest carts r removed from the delete list
54
- $query_records = "SELECT user_id FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE user_type = 'GUEST' AND recovered_cart != '0'";
55
- $results_query = $wpdb->get_results( $query_records );
56
-
57
- foreach ( $results_guest_list as $key => $value ) {
58
- $record_found = "NO";
59
- foreach ( $results_query as $k => $v ) {
60
- if ( $value->id == $v->user_id ) {
61
- $record_found = "YES";
62
- }
63
- }
64
- if ( $record_found == "YES" ) {
65
- unset( $results_guest_list[ $key ] );
66
- }
67
- }
68
- foreach ( $results_guest_list as $key => $value ) {
69
- $query_email_id = "SELECT post_id FROM `" . $wpdb->prefix . "postmeta` WHERE meta_key = '_billing_email' AND meta_value = %s";
70
- $results_query_email = $wpdb->get_results( $wpdb->prepare( $query_email_id, $value->email_id ) );
71
-
72
- //if any orders are found with the same email addr..delete those ac records
73
- if ( $results_query_email ) {
74
-
75
- for ( $i = 0; $i < count( $results_query_email ); $i++ ) {
76
- $query_post = "SELECT post_date,post_status FROM `" . $wpdb->prefix . "posts` WHERE ID = %d";
77
- $results_post = $wpdb->get_results ( $wpdb->prepare( $query_post, $results_query_email[ $i ]->post_id ) );
78
-
79
- if ( $results_post[0]->post_status == "wc-pending" || $results_post[0]->post_status == "wc-failed" ) {
80
- continue;
81
- }
82
- $order_date_time = $results_post[0]->post_date;
83
- $order_date = substr( $order_date_time , 0 , 10 );
84
- $current_time = current_time( 'timestamp' );
85
- $today_date = date( 'Y-m-d', $current_time );
86
-
87
- if ( $order_date == $today_date ) {
88
- $query_delete = "DELETE FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE user_id = '" . $value->id . "'";
89
- $wpdb->query( $query_delete );
90
- $query_guest = "DELETE FROM `" . $wpdb->prefix . "ac_guest_abandoned_cart_history_lite` WHERE email_id = '" . $value->email_id . "'";
91
- $wpdb->query( $query_guest );
92
- break;
93
- }
94
- }
95
- }
96
- }
97
-
98
- // Delete any logged in user carts that might be pending because user did not go to Order Received page after payment
99
- $query_records = "SELECT DISTINCT user_id FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE user_type = 'REGISTERED' AND cart_ignored = '0' AND recovered_cart = '0'";
100
- $results_list = $wpdb->get_results( $query_records );
101
-
102
-
103
- foreach ( $results_list as $key => $value ) {
104
- $user_id = $value->user_id;
105
- $query_email = '';
106
- if ( is_multisite() ){
107
- // get main site's table prefix
108
- $main_prefix = $wpdb->get_blog_prefix(1);
109
- $query_email = "SELECT user_email FROM `".$main_prefix."users` WHERE ID = %d";
110
-
111
- }else{
112
- // non-multisite - regular table name
113
- $query_email = "SELECT user_email FROM `".$wpdb->prefix."users` WHERE ID = %d";
114
- }
115
-
116
-
117
- $results_email = $wpdb->get_results( $wpdb->prepare( $query_email, $user_id ) );
118
-
119
-
120
- $query_email_id = "SELECT post_id FROM `" . $wpdb->prefix . "postmeta` WHERE meta_key = '_billing_email' AND meta_value = %s";
121
- $results_query_email = $wpdb->get_results( $wpdb->prepare( $query_email_id, $results_email[0]->user_email ) );
122
-
123
-
124
- //if any orders are found with the same email addr..delete those ac records
125
- if ( is_array( $results_query_email ) && count( $results_query_email ) > 0 ) {
126
-
127
- for ( $i = 0; $i < count( $results_query_email ); $i++ ) {
128
-
129
- $query_post = "SELECT post_date,post_status FROM `" . $wpdb->prefix . "posts` WHERE ID = %d ";
130
- $results_post = $wpdb->get_results ( $wpdb->prepare( $query_post, $results_query_email[ $i ]->post_id ) );
131
-
132
- if ( $results_post[0]->post_status == "wc-pending" || $results_post[0]->post_status == "wc-failed" ) {
133
- continue;
134
-
135
- }
136
- $order_date_time = $results_post[0]->post_date;
137
- $order_date = substr( $order_date_time, 0, 10 );
138
- $current_time = current_time( 'timestamp' );
139
- $today_date = date( 'Y-m-d', $current_time );
140
-
141
- if ( $order_date == $today_date ) {
142
- $query_delete = "DELETE FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
143
- WHERE user_id = '" . $user_id . "'
144
- AND cart_ignored = '0'
145
- AND recovered_cart = '0'";
146
-
147
- $wpdb->query( $query_delete );
148
- break;
149
- }
150
- }
151
- }
152
- }
153
-
154
- //Grab the cart abandoned cut-off time from database.
155
- $cart_settings = get_option( 'ac_lite_cart_abandoned_time' );
156
-
157
- $cart_abandon_cut_off_time = $cart_settings * 60;
158
-
159
- //Fetch all active templates present in the system
160
- $query = "SELECT wpet . *
161
- FROM `".$wpdb->prefix."ac_email_templates_lite` AS wpet
162
- WHERE wpet.is_active = '1'
163
- ORDER BY `day_or_hour` DESC, `frequency` ASC ";
164
- $results = $wpdb->get_results( $query );
165
-
166
- $hour_seconds = 3600; // 60 * 60
167
- $day_seconds = 86400; // 24 * 60 * 60
168
- foreach ( $results as $key => $value )
169
- {
170
- if ( $value->day_or_hour == 'Days' )
171
- {
172
- $time_to_send_template_after = $value->frequency * $day_seconds;
173
- }
174
- elseif ( $value->day_or_hour == 'Hours' )
175
- {
176
- $time_to_send_template_after = $value->frequency * $hour_seconds;
177
- }
178
-
179
- $carts = $this->get_carts( $time_to_send_template_after, $cart_abandon_cut_off_time );
180
-
181
- $email_frequency = $value->frequency;
182
- $email_body_template = $value->body;
183
- $email_subject = $value->subject;
184
- $headers = "From: " . $value->from_name . " <" . $value->from_email . ">" . "\r\n";
185
- $headers .= "Content-Type: text/html"."\r\n";
186
- $headers .= "Reply-To: " . $value->reply_email . " " . "\r\n";
187
- $template_id = $value->id;
188
- $is_wc_template = $value->is_wc_template;
189
-
190
- foreach ( $carts as $key => $value )
191
- {
192
- if ( $value->user_type == "GUEST" ) {
193
- $value->user_login = "";
194
- $query_guest = "SELECT billing_first_name, billing_last_name, email_id FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d";
195
- $results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $value->user_id ) );
196
- $value->user_email = $results_guest[0]->email_id;
197
- }else{
198
-
199
- $user_id = $value->user_id;
200
- $key = 'billing_email';
201
- $single = true;
202
- $user_biiling_email = get_user_meta( $user_id, $key, $single );
203
- if( isset( $user_biiling_email ) && $user_biiling_email != '' ){
204
- $value->user_email = $user_biiling_email;
205
- }
206
- }
207
-
208
- $cart_info_db_field = json_decode( $value->abandoned_cart_info );
209
- if ( count( $cart_info_db_field->cart ) > 0 )
210
- {
211
- $cart_update_time = $value->abandoned_cart_time;
212
-
213
- $new_user = $this->check_sent_history( $value->user_id, $cart_update_time, $template_id, $value->id );
214
- if ( $new_user == true )
215
- {
216
- $cart_info_db = $value->abandoned_cart_info;
217
-
218
- $email_body = $email_body_template;
219
-
220
- if ( $value->user_type == "GUEST" ) {
221
- if ( isset( $results_guest[0]->billing_first_name ) ) {
222
- $email_body = str_replace( "{{customer.firstname}}", $results_guest[0]->billing_first_name, $email_body );
223
- $email_subject = str_replace( "{{customer.firstname}}", $results_guest[0]->billing_first_name, $email_subject );
224
- }
225
-
226
- if ( isset( $results_guest[0]->billing_last_name ) ) $email_body = str_replace( "{{customer.lastname}}", $results_guest[0]->billing_last_name, $email_body );
227
-
228
- if ( isset( $results_guest[0]->billing_first_name ) && isset( $results_guest[0]->billing_last_name ) ) $email_body = str_replace( "{{customer.fullname}}", $results_guest[0]->billing_first_name." ".$results_guest[0]->billing_last_name, $email_body );
229
- else if ( isset( $results_guest[0]->billing_first_name ) ) $email_body = str_replace( "{{customer.fullname}}", $results_guest[0]->billing_first_name, $email_body );
230
- else if ( isset( $results_guest[0]->billing_last_name)) $email_body = str_replace( "{{customer.fullname}}", $results_guest[0]->billing_last_name, $email_body );
231
- } else {
232
- $email_body = str_replace( "{{customer.firstname}}", get_user_meta( $value->user_id, 'first_name', true ), $email_body );
233
- $email_subject = str_replace( "{{customer.firstname}}", get_user_meta( $value->user_id, 'first_name', true ), $email_subject );
234
- $email_body = str_replace( "{{customer.lastname}}", get_user_meta( $value->user_id, 'last_name', true ), $email_body );
235
- $email_body = str_replace( "{{customer.fullname}}", get_user_meta( $value->user_id, 'first_name', true )." ".get_user_meta( $value->user_id, 'last_name', true ), $email_body );
236
- }
237
-
238
- $order_date = "";
239
-
240
- if ( $cart_update_time != "" && $cart_update_time != 0 ) {
241
- $order_date = date( 'd M, Y h:i A', $cart_update_time );
242
- }
243
-
244
- $email_body = str_replace( "{{cart.abandoned_date}}", $order_date, $email_body );
245
-
246
- $query_sent = "INSERT INTO `".$wpdb->prefix."ac_sent_history_lite` ( template_id, abandoned_order_id, sent_time, sent_email_id )
247
- VALUES ( %s, %s, '".current_time( 'mysql' )."', %s )";
248
-
249
- $wpdb->query( $wpdb->prepare( $query_sent, $template_id, $value->id, $value->user_email ) );
250
-
251
- $query_id = "SELECT * FROM `".$wpdb->prefix."ac_sent_history_lite`
252
- WHERE template_id = %s AND abandoned_order_id = %s
253
- ORDER BY id DESC
254
- LIMIT 1 ";
255
-
256
- $results_sent = $wpdb->get_results( $wpdb->prepare( $query_id, $template_id, $value->id ) );
257
-
258
-
259
- $email_sent_id = $results_sent[0]->id;
260
-
261
- $var = '';
262
- if( preg_match( "{{products.cart}}", $email_body, $matched ) ) {
263
- $var = '<h3>'.__( "Your Shopping Cart", "woocommerce-ac" ).'</h3>
264
- <table border="0" cellpadding="10" cellspacing="0" class="templateDataTable">
265
- <tr>
266
- <th>'.__( "Item", "woocommerce-ac" ).'</th>
267
- <th>'.__( "Name", "woocommerce-ac" ).'</th>
268
- <th>'.__( "Quantity", "woocommerce-ac" ).'</th>
269
- <th>'.__( "Price", "woocommerce-ac" ).'</th>
270
- <th>'.__( "Line Subtotal", "woocommerce-ac" ).'</th>
271
- </tr>';
272
-
273
- $cart_details = $cart_info_db_field->cart;
274
- $cart_total = $item_subtotal = $item_total = 0;
275
- $sub_line_prod_name = '';
276
- foreach ( $cart_details as $k => $v ) {
277
- $quantity_total = $v->quantity;
278
- $product_id = $v->product_id;
279
- $prod_name = get_post( $product_id );
280
- $product_link_track = get_permalink( $product_id );
281
- $product_name = $prod_name->post_title;
282
- if ( $sub_line_prod_name == '' ) {
283
- $sub_line_prod_name = $product_name;
284
- }
285
- // Item subtotal is calculated as product total including taxes
286
- if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
287
- $item_subtotal = $item_subtotal + $v->line_total + $v->line_subtotal_tax;
288
- } else {
289
- $item_subtotal = $item_subtotal + $v->line_total;
290
- }
291
-
292
- // Line total
293
- $item_total = $item_subtotal;
294
- $item_subtotal = $item_subtotal / $quantity_total;
295
- $item_total_display = number_format( $item_total, 2 );
296
- $item_subtotal = number_format( $item_subtotal, 2 );
297
- $product = get_product( $product_id );
298
- $prod_image = $product->get_image();
299
- $image_url = wp_get_attachment_url( get_post_thumbnail_id( $product_id ) );
300
- $var .='<tr align="center">
301
- <td> <a href="'.$product_link_track.'"> <img src="' . $image_url . '" alt="" height="42" width="42" /> </a></td>
302
- <td> <a href="'.$product_link_track.'">'.__( $product_name, "woocommerce-ac" ).'</a></td>
303
- <td> '.$quantity_total.'</td>
304
- <td> '.get_woocommerce_currency_symbol()."".$item_subtotal.'</td>
305
- <td> '.get_woocommerce_currency_symbol()."".$item_total_display.'</td>
306
- </tr>';
307
- $cart_total += $item_total;
308
- $item_subtotal = $item_total = 0;
309
- }
310
- $cart_total = number_format( $cart_total, 2 );
311
- $var .= '<tr align="center">
312
- <td> </td>
313
- <td> </td>
314
- <td> </td>
315
- <td>'.__( "Cart Total:", "woocommerce-ac" ).'</td>
316
- <td> '.get_woocommerce_currency_symbol()."".$cart_total.'</td>
317
- </tr>';
318
- $var .= '</table>
319
- ';
320
- $email_body = str_replace( "{{products.cart}}", $var, $email_body );
321
- $email_subject = str_replace( "{{product.name}}", __( $sub_line_prod_name, "woocommerce-ac" ), $email_subject );
322
- }
323
-
324
- if ( $woocommerce->version < '2.3' ) {
325
- $cart_page_link = $woocommerce->cart->get_cart_url();
326
- } else {
327
- $cart_page_id = woocommerce_get_page_id( 'cart' );
328
- $cart_page_link = $cart_page_id ? get_permalink( $cart_page_id ) : '';
329
- }
330
-
331
- $encoding_cart = $email_sent_id.'&url='.$cart_page_link;
332
-
333
- $validate_cart = $this->encrypt_validate ($encoding_cart);
334
- $cart_link_track = get_option('siteurl').'/?wacp_action=track_links&validate=' . $validate_cart;
335
- $email_body = str_replace( "{{cart.link}}", $cart_link_track, $email_body );
336
-
337
- $user_email = $value->user_email;
338
-
339
- $email_body_final = stripslashes( $email_body );
340
-
341
- if ( isset( $is_wc_template ) && "1" == $is_wc_template ){
342
-
343
- ob_start();
344
-
345
- $email_heading = __( 'Abandoned cart reminder', 'woocommerce' );
346
-
347
- wc_get_template( 'emails/email-header.php', array( 'email_heading' => $email_heading ) );
348
-
349
- $email_body_template_header = ob_get_clean();
350
-
351
- ob_start();
352
-
353
- wc_get_template( 'emails/email-footer.php' );
354
-
355
- $email_body_template_footer = ob_get_clean();
356
-
357
- $final_email_body = $email_body_template_header . $email_body_final . $email_body_template_footer;
358
-
359
- wc_mail( $user_email, $email_subject, $final_email_body, $headers );
360
-
361
- }else{
362
- wp_mail( $user_email, $email_subject, __( $email_body_final, 'woocommerce-ac' ), $headers );
363
- }
364
- }
365
-
366
- }
367
- }
368
-
369
- }
370
-
371
- }
372
-
373
- /**
374
- * get all carts which have the creation time earlier than the one that is passed
375
- *
376
- */
377
- function get_carts( $template_to_send_after_time, $cart_abandon_cut_off_time ) {
378
-
379
- global $wpdb;
380
-
381
- $cart_time = current_time( 'timestamp' ) - $template_to_send_after_time - $cart_abandon_cut_off_time;
382
-
383
- $cart_ignored = 0;
384
- $query = "SELECT wpac . * , wpu.user_login, wpu.user_email
385
- FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac
386
- LEFT JOIN ".$wpdb->base_prefix."users AS wpu ON wpac.user_id = wpu.id
387
- WHERE cart_ignored = %s
388
- AND abandoned_cart_time < $cart_time
389
- ORDER BY `id` ASC ";
390
-
391
- $results = $wpdb->get_results( $wpdb->prepare( $query, $cart_ignored ) );
392
-
393
- return $results;
394
-
395
- exit;
396
- }
397
-
398
- /******
399
- * This function is used to encode the validate string.
400
- ******/
401
- function encrypt_validate( $validate ) {
402
-
403
- $cryptKey = 'qJB0rGtIn5UB1xG03efyCp';
404
- $validate_encoded = base64_encode( mcrypt_encrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), $validate, MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ) );
405
- return $validate_encoded;
406
- }
407
-
408
- function check_sent_history( $user_id, $cart_update_time, $template_id, $id ) {
409
-
410
- global $wpdb;
411
-
412
- $query = "SELECT wpcs . * , wpac . abandoned_cart_time , wpac . user_id
413
- FROM `".$wpdb->prefix."ac_sent_history_lite` AS wpcs
414
- LEFT JOIN ".$wpdb->prefix."ac_abandoned_cart_history_lite AS wpac ON wpcs.abandoned_order_id = wpac.id
415
- WHERE
416
- template_id = %s
417
- AND
418
- wpcs.abandoned_order_id = %d
419
- ORDER BY 'id' DESC
420
- LIMIT 1 ";
421
-
422
- $results = $wpdb->get_results( $wpdb->prepare( $query, $template_id, $id ) );
423
- if ( count( $results ) == 0 )
424
- {
425
- return true;
426
- }
427
- elseif ( $results[0]->abandoned_cart_time < $cart_update_time )
428
- {
429
- return true;
430
- }
431
- else
432
- {
433
- return false;
434
- }
435
-
436
- }
437
-
438
-
439
- }
440
-
441
- }
442
-
443
- $woocommerce_abandon_cart_cron = new woocommerce_abandon_cart_cron();
444
-
445
- $woocommerce_abandon_cart_cron->woocommerce_ac_send_email();
446
-
447
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cron/wcal_send_email.php ADDED
@@ -0,0 +1,496 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ static $wp_load; // Since this will be called twice, hold onto it.
4
+ if ( ! isset( $wp_load ) ) {
5
+ $wp_load = false;
6
+ $dir = __FILE__;
7
+ while( '/' != ( $dir = dirname( $dir ) ) ) {
8
+ if( file_exists( $wp_load = "{$dir}/wp-load.php" ) ) {
9
+ break;
10
+ }
11
+ }
12
+ }
13
+ $wcal_root = dirname( dirname(__FILE__) ); // go two level up for directory from this file.
14
+ require_once $wp_load;
15
+ require_once $wcal_root.'/includes/classes/class-wcal-aes.php';
16
+ require_once $wcal_root.'/includes/classes/class-wcal-aes-counter.php';
17
+ /**
18
+ * woocommerce_abandon_cart_cron class
19
+ **/
20
+ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
21
+
22
+ class woocommerce_abandon_cart_cron {
23
+ var $cart_settings_cron;
24
+ var $cart_abandon_cut_off_time_cron;
25
+ public function __construct() {
26
+ $this->cart_settings_cron = get_option( 'ac_lite_cart_abandoned_time' );
27
+ $this->cart_abandon_cut_off_time_cron = ( $this->cart_settings_cron ) * 60;
28
+ }
29
+ /**
30
+ * Function to send emails
31
+ */
32
+ function wcal_send_email_notification() {
33
+ global $wpdb, $woocommerce;
34
+ //Grab the cart abandoned cut-off time from database.
35
+ $cart_settings = get_option( 'ac_lite_cart_abandoned_time' );
36
+ $cart_abandon_cut_off_time = $cart_settings * 60;
37
+ //Fetch all active templates present in the system
38
+ $query = "SELECT wpet . * FROM `".$wpdb->prefix."ac_email_templates_lite` AS wpet
39
+ WHERE wpet.is_active = '1' ORDER BY `day_or_hour` DESC, `frequency` ASC ";
40
+ $results = $wpdb->get_results( $query );
41
+ $hour_seconds = 3600; // 60 * 60
42
+ $day_seconds = 86400; // 24 * 60 * 60
43
+ foreach ( $results as $key => $value ) {
44
+ if ( $value->day_or_hour == 'Days' ) {
45
+ $time_to_send_template_after = $value->frequency * $day_seconds;
46
+ } elseif ( $value->day_or_hour == 'Hours' ) {
47
+ $time_to_send_template_after = $value->frequency * $hour_seconds;
48
+ }
49
+ $carts = $this->wcal_get_carts( $time_to_send_template_after, $cart_abandon_cut_off_time );
50
+ /**
51
+ * When there are 3 templates and for cart id 1 all template time has been reached. BUt all templates are deactivated.
52
+ * If we activate all 3 template then at a 1 time all 3 email templates send to the users.
53
+ * So below function check that after first email is sent time and then from that time it will send the 2nd template time. ( It will not consider the cart abadoned time in this case. )
54
+ */
55
+ $carts = $this->wcal_remove_cart_for_mutiple_templates( $carts, $time_to_send_template_after, $value->id );
56
+ $carts = woocommerce_abandon_cart_cron ::wcal_update_abandoned_cart_status_for_placed_orders ( $carts, $time_to_send_template_after );
57
+ $email_frequency = $value->frequency;
58
+ $email_body_template = $value->body;
59
+ $email_subject = stripslashes ( $value->subject );
60
+ $wcal_from_name = get_option ( 'wcal_from_name' );
61
+ $wcal_from_email = get_option ( 'wcal_from_email' );
62
+ $wcal_reply_email = get_option ( 'wcal_reply_email' );
63
+ if ( class_exists( 'WP_Better_Emails' ) ) {
64
+ $headers = "From: " . $wcal_from_name . " <" . $wcal_from_email . ">" . "\r\n";
65
+ $headers .= "Content-Type: text/plain"."\r\n";
66
+ $headers .= "Reply-To: " . $wcal_reply_email . " " . "\r\n";
67
+ } else {
68
+ $headers = "From: " . $wcal_from_name . " <" . $wcal_from_email . ">" . "\r\n";
69
+ $headers .= "Content-Type: text/html"."\r\n";
70
+ $headers .= "Reply-To: " . $wcal_reply_email . " " . "\r\n";
71
+ }
72
+ $template_id = $value->id;
73
+ $is_wc_template = $value->is_wc_template;
74
+ $wc_template_header_text = $value->wc_email_header != '' ? $value->wc_email_header : __( 'Abandoned cart reminder', 'woocommerce-ac');
75
+ $wc_template_header = stripslashes( $wc_template_header_text );
76
+ if ( '' != $email_body_template ) {
77
+ foreach ( $carts as $key => $value ) {
78
+ if ( $value->user_type == "GUEST" && $value->user_id != '0' ) {
79
+ $value->user_login = "";
80
+ $query_guest = "SELECT billing_first_name, billing_last_name, email_id FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite`
81
+ WHERE id = %d";
82
+ $results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $value->user_id ) );
83
+ $value->user_email = $results_guest[0]->email_id;
84
+ } else {
85
+ if( isset( $value->user_id ) ) {
86
+ $user_id = $value->user_id;
87
+ }
88
+ $key = 'billing_email';
89
+ $single = true;
90
+ $user_biiling_email = get_user_meta( $user_id, $key, $single );
91
+ if ( isset( $user_biiling_email ) && $user_biiling_email != '' ) {
92
+ $value->user_email = $user_biiling_email;
93
+ }
94
+ }
95
+ if( isset( $value->abandoned_cart_info ) ) {
96
+ $cart_info_db_field = json_decode( $value->abandoned_cart_info );
97
+ }
98
+ if( count( $cart_info_db_field->cart ) > 0 && $value->user_id != '0') {
99
+ $cart_update_time = $value->abandoned_cart_time;
100
+ $new_user = $this->wcal_check_sent_history( $value->user_id, $cart_update_time, $template_id, $value->id );
101
+ if ( $new_user == true ) {
102
+ $cart_info_db = $value->abandoned_cart_info;
103
+ $email_body = $email_body_template;
104
+ if ( $value->user_type == "GUEST" ) {
105
+ if ( isset( $results_guest[0]->billing_first_name ) ) {
106
+ $email_body = str_replace( "{{customer.firstname}}", $results_guest[0]->billing_first_name, $email_body );
107
+ $email_subject = str_replace( "{{customer.firstname}}", $results_guest[0]->billing_first_name, $email_subject );
108
+ }
109
+ if ( isset( $results_guest[0]->billing_last_name ) ) {
110
+ $email_body = str_replace( "{{customer.lastname}}", $results_guest[0]->billing_last_name, $email_body );
111
+ }
112
+ if ( isset( $results_guest[0]->billing_first_name ) && isset( $results_guest[0]->billing_last_name ) ) {
113
+ $email_body = str_replace( "{{customer.fullname}}", $results_guest[0]->billing_first_name." ".$results_guest[0]->billing_last_name, $email_body );
114
+ }
115
+ else if ( isset( $results_guest[0]->billing_first_name ) ) {
116
+ $email_body = str_replace( "{{customer.fullname}}", $results_guest[0]->billing_first_name, $email_body );
117
+ }
118
+ else if ( isset( $results_guest[0]->billing_last_name ) ) {
119
+ $email_body = str_replace( "{{customer.fullname}}", $results_guest[0]->billing_last_name, $email_body );
120
+ }
121
+ } else {
122
+ $user_first_name = '';
123
+ $user_first_name_temp = get_user_meta( $value->user_id, 'billing_first_name', true );
124
+ if( isset( $user_first_name_temp ) && "" == $user_first_name_temp ) {
125
+ $user_data = get_userdata( $user_id );
126
+ $user_first_name = $user_data->first_name;
127
+ } else {
128
+ $user_first_name = $user_first_name_temp;
129
+ }
130
+ $email_body = str_replace( "{{customer.firstname}}", $user_first_name, $email_body );
131
+ $email_subject = str_replace( "{{customer.firstname}}", $user_first_name, $email_subject );
132
+ $user_last_name = '';
133
+ $user_last_name_temp = get_user_meta( $value->user_id, 'billing_last_name', true );
134
+ if( isset( $user_last_name_temp ) && "" == $user_last_name_temp ) {
135
+ $user_data = get_userdata( $user_id );
136
+ $user_last_name = $user_data->last_name;
137
+ } else {
138
+ $user_last_name = $user_last_name_temp;
139
+ }
140
+ $email_body = str_replace( "{{customer.lastname}}", $user_last_name, $email_body );
141
+ $email_body = str_replace( "{{customer.fullname}}", $user_first_name." ".$user_last_name, $email_body );
142
+ }
143
+ $order_date = "";
144
+ if( $cart_update_time != "" && $cart_update_time != 0 ) {
145
+ $order_date = date( 'd M, Y h:i A', $cart_update_time );
146
+ }
147
+ $email_body = str_replace( "{{cart.abandoned_date}}", $order_date, $email_body );
148
+ $query_sent = "INSERT INTO `".$wpdb->prefix."ac_sent_history_lite` ( template_id, abandoned_order_id, sent_time, sent_email_id )
149
+ VALUES ( %s, %s, '".current_time( 'mysql' )."', %s )";
150
+
151
+ $wpdb->query( $wpdb->prepare( $query_sent, $template_id, $value->id, $value->user_email ) );
152
+
153
+ $query_id = "SELECT * FROM `".$wpdb->prefix."ac_sent_history_lite`
154
+ WHERE template_id = %s AND abandoned_order_id = %s
155
+ ORDER BY id DESC
156
+ LIMIT 1 ";
157
+ $results_sent = $wpdb->get_results( $wpdb->prepare( $query_id, $template_id, $value->id ) );
158
+ $email_sent_id = $results_sent[0]->id;
159
+
160
+ if( $woocommerce->version < '2.3' ) {
161
+ $cart_page_link = $woocommerce->cart->get_cart_url();
162
+ } else {
163
+ $cart_page_id = woocommerce_get_page_id( 'cart' );
164
+ $cart_page_link = $cart_page_id ? get_permalink( $cart_page_id ) : '';
165
+ }
166
+
167
+ $encoding_cart = $email_sent_id.'&url='.$cart_page_link;
168
+ $validate_cart = $this->wcal_encrypt_validate( $encoding_cart );
169
+ $cart_link_track = get_option('siteurl').'/?wcal_action=track_links&validate=' . $validate_cart;
170
+ $email_body = str_replace( "{{cart.link}}", $cart_link_track, $email_body );
171
+
172
+ $validate_unsubscribe = $this->wcal_encrypt_validate( $email_sent_id );
173
+ $email_sent_id_address = $results_sent[0]->sent_email_id;
174
+ $encrypt_email_sent_id_address = hash( 'sha256', $email_sent_id_address );
175
+ $plugins_url = get_option( 'siteurl' ) . "/?wcal_track_unsubscribe=wcal_unsubscribe&validate=" . $validate_unsubscribe . "&track_email_id=" . $encrypt_email_sent_id_address;
176
+ $unsubscribe_link_track = $plugins_url;
177
+ $email_body = str_replace( "{{cart.unsubscribe}}" , $unsubscribe_link_track , $email_body );
178
+ $var = '';
179
+ if( preg_match( "{{products.cart}}", $email_body, $matched ) ) {
180
+ if ( class_exists( 'WP_Better_Emails' ) ) {
181
+ $var = '<table width = 100%>
182
+ <tr> <td colspan="5"> <h3>'.__( "Your Shopping Cart", "woocommerce-ac" ).'</h3> </td></tr>
183
+ <tr>
184
+ <th>'.__( "Item", "woocommerce-ac" ).'</th>
185
+ <th>'.__( "Name", "woocommerce-ac" ).'</th>
186
+ <th>'.__( "Quantity", "woocommerce-ac" ).'</th>
187
+ <th>'.__( "Price", "woocommerce-ac" ).'</th>
188
+ <th>'.__( "Line Subtotal", "woocommerce-ac" ).'</th>
189
+ </tr>';
190
+ } else {
191
+ $var = '<h3>'.__( "Your Shopping Cart", "woocommerce-ac" ).'</h3>
192
+ <table border="0" cellpadding="10" cellspacing="0" class="templateDataTable">
193
+ <tr>
194
+ <th>'.__( "Item", "woocommerce-ac" ).'</th>
195
+ <th>'.__( "Name", "woocommerce-ac" ).'</th>
196
+ <th>'.__( "Quantity", "woocommerce-ac" ).'</th>
197
+ <th>'.__( "Price", "woocommerce-ac" ).'</th>
198
+ <th>'.__( "Line Subtotal", "woocommerce-ac" ).'</th>
199
+ </tr>';
200
+ }
201
+ $cart_details = $cart_info_db_field->cart;
202
+ $cart_total = $item_subtotal = $item_total = 0;
203
+ $sub_line_prod_name = '';
204
+ foreach ( $cart_details as $k => $v ) {
205
+ $quantity_total = $v->quantity;
206
+ $product_id = $v->product_id;
207
+ $prod_name = get_post( $product_id );
208
+ $product_link_track = get_permalink( $product_id );
209
+ $product_name = $prod_name->post_title;
210
+ if( $sub_line_prod_name == '' ) {
211
+ $sub_line_prod_name = $product_name;
212
+ }
213
+ // Item subtotal is calculated as product total including taxes
214
+ if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
215
+ $item_subtotal = $item_subtotal + $v->line_total + $v->line_subtotal_tax;
216
+ } else {
217
+ $item_subtotal = $item_subtotal + $v->line_total;
218
+ }
219
+ // Line total
220
+ $item_total = $item_subtotal;
221
+ $item_subtotal = $item_subtotal / $quantity_total;
222
+ $item_total_display = wc_price( $item_total );
223
+ $item_subtotal = wc_price( $item_subtotal );
224
+ $product = get_product( $product_id );
225
+ $prod_image = $product->get_image();
226
+ $image_url = wp_get_attachment_url( get_post_thumbnail_id( $product_id ) );
227
+ if ( isset( $v->variation_id ) && '' != $v->variation_id ) {
228
+ $variation_id = $v->variation_id;
229
+ $variation = wc_get_product( $variation_id );
230
+ $name = $variation->get_formatted_name() ;
231
+ $explode_all = explode ( "&ndash;", $name );
232
+ $pro_name_variation = array_slice( $explode_all, 1, -1 );
233
+ $product_name_with_variable = '';
234
+ $explode_many_varaition = array();
235
+ foreach ( $pro_name_variation as $pro_name_variation_key => $pro_name_variation_value ){
236
+ $explode_many_varaition = explode ( ",", $pro_name_variation_value );
237
+ if ( !empty( $explode_many_varaition ) ) {
238
+ foreach( $explode_many_varaition as $explode_many_varaition_key => $explode_many_varaition_value ){
239
+ $product_name_with_variable = $product_name_with_variable . "<br>". html_entity_decode ( $explode_many_varaition_value );
240
+ }
241
+ } else {
242
+ $product_name_with_variable = $product_name_with_variable . "<br>". html_entity_decode ( $explode_many_varaition_value );
243
+ }
244
+ }
245
+ $product_name = $product_name_with_variable;
246
+ }
247
+ $var .='<tr align="center">
248
+ <td> <a href="'.$cart_link_track.'"> <img src="' . $image_url . '" alt="" height="42" width="42" /> </a></td>
249
+ <td> <a href="'.$cart_link_track.'">'.__( $product_name, "woocommerce-ac" ).'</a></td>
250
+ <td> '.$quantity_total.'</td>
251
+ <td> '.$item_subtotal.'</td>
252
+ <td> '.$item_total_display.'</td>
253
+ </tr>';
254
+ $cart_total += $item_total;
255
+ $item_subtotal = $item_total = 0;
256
+ }
257
+ $cart_total = wc_price( $cart_total );
258
+ $var .= '<tr align="center">
259
+ <td> </td>
260
+ <td> </td>
261
+ <td> </td>
262
+ <td>'.__( "Cart Total:", "woocommerce-ac" ).'</td>
263
+ <td> '.$cart_total.'</td>
264
+ </tr>';
265
+ $var .= '</table>
266
+ ';
267
+ $email_body = str_replace( "{{products.cart}}", $var, $email_body );
268
+ $email_subject = str_replace( "{{product.name}}", __( $sub_line_prod_name, "woocommerce-ac" ), $email_subject );
269
+ }
270
+
271
+ $user_email = $value->user_email;
272
+ $email_body_final = stripslashes( $email_body );
273
+
274
+ if ( isset( $is_wc_template ) && "1" == $is_wc_template ){
275
+ ob_start();
276
+
277
+ wc_get_template( 'emails/email-header.php', array( 'email_heading' => $wc_template_header ) );
278
+ $email_body_template_header = ob_get_clean();
279
+
280
+ ob_start();
281
+
282
+ wc_get_template( 'emails/email-footer.php' );
283
+ $email_body_template_footer = ob_get_clean();
284
+
285
+ $final_email_body = $email_body_template_header . $email_body_final . $email_body_template_footer;
286
+
287
+ wc_mail( $user_email, $email_subject, $final_email_body, $headers );
288
+
289
+ } else {
290
+ wp_mail( $user_email, $email_subject, __( $email_body_final, 'woocommerce-ac' ), $headers );
291
+ }
292
+ }
293
+ }
294
+ }
295
+ }
296
+ }
297
+ }
298
+ /**
299
+ * get all carts which have the creation time earlier than the one that is passed
300
+ */
301
+ function wcal_get_carts( $template_to_send_after_time, $cart_abandon_cut_off_time ) {
302
+ global $wpdb;
303
+ $cart_time = current_time( 'timestamp' ) - $template_to_send_after_time - $cart_abandon_cut_off_time;
304
+ $cart_ignored = 0;
305
+ $unsubscribe = 0;
306
+ $query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac
307
+ LEFT JOIN ".$wpdb->base_prefix."users AS wpu ON wpac.user_id = wpu.id
308
+ WHERE cart_ignored = %s AND unsubscribe_link = %s AND abandoned_cart_time < $cart_time
309
+ ORDER BY `id` ASC ";
310
+
311
+ $results = $wpdb->get_results( $wpdb->prepare( $query, $cart_ignored, $unsubscribe ) );
312
+ return $results;
313
+ exit;
314
+ }
315
+
316
+ public static function wcal_update_abandoned_cart_status_for_placed_orders( $carts, $time_to_send_template_after ){
317
+ global $wpdb;
318
+ foreach( $carts as $carts_key => $carts_value ) {
319
+ $abandoned_cart_time = $carts_value->abandoned_cart_time;
320
+ $user_id = $carts_value->user_id;
321
+ $user_type = $carts_value->user_type;
322
+ $cart_id = $carts_value->id;
323
+ if( $user_id >= '63000000' && 'GUEST' == $user_type ) {
324
+ $query_guest_records = "SELECT id FROM `" . $wpdb->prefix . "ac_guest_abandoned_cart_history_lite` ORDER BY id DESC LIMIT 1";
325
+ $results_guest_list = $wpdb->get_results( $query_guest_records );
326
+ $last_guest_id = 0 ;
327
+ $get_last_checked_id = get_option( 'wcal_guest_last_id_checked' );
328
+ if( isset( $results_guest_list ) && count( $results_guest_list ) > 0 ) {
329
+ $last_guest_id = $results_guest_list[0]->id;
330
+ }
331
+ if( false == $get_last_checked_id || $get_last_checked_id < $last_guest_id ) {
332
+ $updated_value = woocommerce_abandon_cart_cron ::wcal_update_status_of_guest( $cart_id, $abandoned_cart_time , $time_to_send_template_after );
333
+ if( 1 == $updated_value ) {
334
+ unset ( $carts [ $carts_key ] );
335
+ }
336
+ update_option ( 'wcal_guest_last_id_checked' , $last_guest_id );
337
+ }
338
+ } elseif ( $user_id < '63000000' && 'REGISTERED' == $user_type ) {
339
+ $updated_value = woocommerce_abandon_cart_cron ::wcal_update_status_of_loggedin ( $cart_id, $abandoned_cart_time , $time_to_send_template_after );
340
+ if( 1 == $updated_value ) {
341
+ unset( $carts [ $carts_key ] );
342
+ }
343
+ }
344
+ }
345
+ return $carts;
346
+ }
347
+
348
+ public static function wcal_update_status_of_guest( $cart_id, $abandoned_cart_time , $time_to_send_template_after ) {
349
+ global $wpdb;
350
+ $get_last_checked_id = get_option( 'wcal_guest_last_id_checked' );
351
+ if( false == $get_last_checked_id ) {
352
+ $get_last_checked_id = 63000000;
353
+ }
354
+ $query_guest_records = "SELECT id,email_id FROM `" . $wpdb->prefix . "ac_guest_abandoned_cart_history_lite` WHERE id > $get_last_checked_id";
355
+ $results_guest_list = $wpdb->get_results( $query_guest_records );
356
+ // This is to ensure that recovered guest carts r removed from the delete list
357
+ $query_records = "SELECT user_id FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE user_type = 'GUEST' AND recovered_cart != '0'";
358
+ $results_query = $wpdb->get_results( $query_records );
359
+ foreach( $results_guest_list as $key => $value ) {
360
+ $record_found = "NO";
361
+ foreach( $results_query as $k => $v ) {
362
+ if ( $value->id == $v->user_id ) {
363
+ $record_found = "YES";
364
+ }
365
+ }
366
+ if( $record_found == "YES" ) {
367
+ unset( $results_guest_list[ $key ] );
368
+ }
369
+ }
370
+ if ( ! empty( $results_query ) ) {
371
+ foreach( $results_guest_list as $key => $value ) {
372
+ $query_email_id = "SELECT post_id FROM `" . $wpdb->prefix . "postmeta` WHERE meta_key = '_billing_email' AND meta_value = %s";
373
+ $results_query_email = $wpdb->get_results( $wpdb->prepare( $query_email_id, $value->email_id ) );
374
+ //if any orders are found with the same email addr..delete those ac records
375
+ if( $results_query_email ) {
376
+ for( $i = 0; $i < count( $results_query_email ); $i++ ) {
377
+ $query_post = "SELECT post_date,post_status FROM `" . $wpdb->prefix . "posts` WHERE ID = %d";
378
+ $results_post = $wpdb->get_results ( $wpdb->prepare( $query_post, $results_query_email[ $i ]->post_id ) );
379
+ if( $results_post[0]->post_status == "wc-pending" || $results_post[0]->post_status == "wc-failed" ) {
380
+ continue;
381
+ }
382
+ $order_date_time = $results_post[0]->post_date;
383
+ $order_date_with_time = $results_post[0]->post_date;
384
+ $order_date = substr( $order_date_with_time, 0, 10 );
385
+ $current_time = current_time( 'timestamp' );
386
+ $today_date = date( 'Y-m-d', $current_time );
387
+ if( strtotime( $order_date_time ) > $abandoned_cart_time || $order_date == $today_date ) {
388
+ $query_ignored = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET cart_ignored = '1' WHERE id ='" . $cart_id . "'";
389
+ $wpdb->query( $query_ignored );
390
+ return 1; //We return here 1 so it indicate that the cart has been modifed so do not sent email and delete from the array.
391
+ }
392
+ }
393
+ }
394
+ }
395
+ return 0;
396
+ }
397
+ }
398
+ public static function wcal_update_status_of_loggedin( $cart_id, $abandoned_cart_time , $time_to_send_template_after ) {
399
+ global $wpdb;
400
+ // Update the record of the loggedin user who had paid before the first abandoned cart reminder email send to customer.
401
+ $query_records = "SELECT DISTINCT user_id FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE user_type = 'REGISTERED' AND id = $cart_id AND recovered_cart = '0'";
402
+ $results_list = $wpdb->get_results( $query_records );
403
+ foreach( $results_list as $key => $value ) {
404
+ $user_id = $value->user_id;
405
+ $key = 'billing_email';
406
+ $single = true;
407
+ $user_billing_email = get_user_meta( $user_id, $key, $single );
408
+ if( isset( $user_billing_email ) && $user_billing_email == '' ){
409
+ $user_id = $value->user_id;
410
+ if( is_multisite() ) {
411
+ $main_prefix = $wpdb->get_blog_prefix(1);
412
+ $query_email = "SELECT user_email FROM `".$main_prefix."users` WHERE ID = %d";
413
+ } else {
414
+ $query_email = "SELECT user_email FROM `".$wpdb->prefix."users` WHERE ID = %d";
415
+ }
416
+ $results_email = $wpdb->get_results( $wpdb->prepare( $query_email, $user_id ) );
417
+ if( !empty( $results_email[0]->user_email ) ) {
418
+ $user_billing_email = $results_email[0]->user_email;
419
+ }
420
+ }
421
+ $query_email_id = "SELECT post_id FROM `" . $wpdb->prefix . "postmeta` WHERE meta_key = '_billing_email' AND meta_value = %s";
422
+ $results_query_email = $wpdb->get_results( $wpdb->prepare( $query_email_id, $user_billing_email ) );
423
+ //if any orders are found with the same email addr..delete those ac records
424
+ if( is_array( $results_query_email ) && count( $results_query_email ) > 0 ) {
425
+ for( $i = 0; $i < count( $results_query_email ); $i++ ) {
426
+ $cart_abandoned_time = date ('Y-m-d h:i:s', $abandoned_cart_time);
427
+ $query_post = "SELECT post_date,post_status FROM `" . $wpdb->prefix . "posts` WHERE ID = %d AND post_date >= %s";
428
+ $results_post = $wpdb->get_results( $wpdb->prepare( $query_post, $results_query_email[ $i ]->post_id, $cart_abandoned_time ) );
429
+ if( count ($results_post) > 0 ) {
430
+ if( $results_post[0]->post_status == "wc-pending" || $results_post[0]->post_status == "wc-failed" ) {
431
+ return 0; //if status of the order is pending or falied then return 0 so it will not delete that cart and send reminder email
432
+ }
433
+ $order_date_time = $results_post[0]->post_date;
434
+ $order_date_with_time = $results_post[0]->post_date;
435
+ $order_date = substr( $order_date_with_time, 0, 10 );
436
+ $current_time = current_time( 'timestamp' );
437
+ $today_date = date( 'Y-m-d', $current_time );
438
+ if ( strtotime( $order_date_time ) >= $abandoned_cart_time || $order_date == $today_date ) {
439
+ $query_ignored = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET cart_ignored = '1' WHERE id ='" . $cart_id . "'";
440
+ $wpdb->query( $query_ignored );
441
+ return 1; //We return here 1 so it indicate that the cart has been modifed so do not sent email and delete from the array.
442
+ }
443
+ }
444
+ }
445
+ }
446
+ }
447
+ return 0;
448
+ }
449
+
450
+ public static function wcal_remove_cart_for_mutiple_templates( $carts, $time_to_send_template_after, $template_id ) {
451
+ global $wpdb;
452
+
453
+ foreach( $carts as $carts_key => $carts_value ) {
454
+ $wcal_get_last_email_sent_time = "SELECT * FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE abandoned_order_id = $carts_value->id ORDER BY `sent_time` DESC LIMIT 1";
455
+ $wcal_get_last_email_sent_time_results_list = $wpdb->get_results( $wcal_get_last_email_sent_time );
456
+ if( count( $wcal_get_last_email_sent_time_results_list ) > 0 ) {
457
+ $last_template_send_time = strtotime( $wcal_get_last_email_sent_time_results_list[0]->sent_time );
458
+ $second_template_send_time = $last_template_send_time + $time_to_send_template_after ;
459
+ $current_time_test = current_time( 'timestamp' );
460
+ if( $second_template_send_time > $current_time_test ) {
461
+ unset( $carts [ $carts_key ] );
462
+ }
463
+ }
464
+ }
465
+ return $carts;
466
+ }
467
+ /******
468
+ * This function is used to encode the validate string.
469
+ ******/
470
+ function wcal_encrypt_validate( $validate ) {
471
+ $cryptKey = get_option( 'wcal_security_key' );
472
+ $validate_encoded = Wcal_Aes_Ctr::encrypt( $validate, $cryptKey, 256 );
473
+ return( $validate_encoded );
474
+ }
475
+
476
+ function wcal_check_sent_history( $user_id, $cart_update_time, $template_id, $id ) {
477
+ global $wpdb;
478
+ $query = "SELECT wpcs . * , wpac . abandoned_cart_time , wpac . user_id FROM `".$wpdb->prefix."ac_sent_history_lite` AS wpcs
479
+ LEFT JOIN ".$wpdb->prefix."ac_abandoned_cart_history_lite AS wpac ON wpcs.abandoned_order_id = wpac.id
480
+ WHERE template_id = %s AND wpcs.abandoned_order_id = %d ORDER BY 'id' DESC LIMIT 1 ";
481
+
482
+ $results = $wpdb->get_results( $wpdb->prepare( $query, $template_id, $id ) );
483
+ if ( count( $results ) == 0 ) {
484
+ return true;
485
+ } elseif ( $results[0]->abandoned_cart_time < $cart_update_time ) {
486
+ return true;
487
+ } else {
488
+ return false;
489
+ }
490
+ }
491
+ }
492
+ }
493
+ $woocommerce_abandon_cart_cron = new woocommerce_abandon_cart_cron();
494
+ $woocommerce_abandon_cart_cron->wcal_send_email_notification();
495
+
496
+ ?>
{languages → i18n/languages}/messages.pot RENAMED
File without changes
{languages → i18n/languages}/woocommerce-ac-de_DE.mo RENAMED
File without changes
{languages → i18n/languages}/woocommerce-ac-de_DE.po RENAMED
File without changes
{languages → i18n/languages}/woocommerce-ac-he_IL.mo RENAMED
File without changes
{languages → i18n/languages}/woocommerce-ac-he_IL.po RENAMED
File without changes
{languages → i18n/languages}/woocommerce-ac-sk_SK.mo RENAMED
File without changes
{languages → i18n/languages}/woocommerce-ac-sk_SK.po RENAMED
File without changes
{languages → i18n/languages}/woocommerce-ac.mo RENAMED
Binary file
i18n/languages/woocommerce-ac.po ADDED
@@ -0,0 +1,500 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: woocommerce-ac\n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2017-01-21 15:02+0530\n"
11
+ "PO-Revision-Date: 2017-01-21 15:03+0530\n"
12
+ "Last-Translator: \n"
13
+ "Language-Team: \n"
14
+ "MIME-Version: 1.0\n"
15
+ "Content-Type: text/plain; charset=UTF-8\n"
16
+ "Content-Transfer-Encoding: 8bit\n"
17
+ "X-Generator: Poedit 1.8.11\n"
18
+ "X-Poedit-KeywordsList: __;_e\n"
19
+ "X-Poedit-Basepath: .\n"
20
+
21
+ #: woocommerce-ac.php:28
22
+ msgid "Once Every Fifteen Minutes"
23
+ msgstr ""
24
+
25
+ #: woocommerce-ac.php:298 woocommerce-ac.php:1317
26
+ msgid "This order was abandoned & subsequently recovered."
27
+ msgstr ""
28
+
29
+ #: woocommerce-ac.php:323
30
+ msgid ""
31
+ "The Lite & Pro version of Abandoned Cart plugin for WooCommerce (from Tyche "
32
+ "Softwares) are active on your website. <br> In this case, the abandoned "
33
+ "carts will be captured in both plugins & email reminders will also be sent "
34
+ "from both plugins. <br> It is recommended that you deactivate the Lite "
35
+ "version & keep the Pro version active."
36
+ msgstr ""
37
+
38
+ #: woocommerce-ac.php:350
39
+ msgid "HTML Email Template"
40
+ msgstr ""
41
+
42
+ #: woocommerce-ac.php:356
43
+ msgid "Abandoned cart Email Template"
44
+ msgstr ""
45
+
46
+ #: woocommerce-ac.php:490 woocommerce-ac.php:1471
47
+ msgid "Settings"
48
+ msgstr ""
49
+
50
+ #: woocommerce-ac.php:497
51
+ msgid "Cart abandoned cut-off time"
52
+ msgstr ""
53
+
54
+ #: woocommerce-ac.php:501
55
+ msgid ""
56
+ "Consider cart abandoned after X minutes of item being added to cart & order "
57
+ "not placed."
58
+ msgstr ""
59
+
60
+ #: woocommerce-ac.php:506
61
+ msgid "Email admin On Order Recovery"
62
+ msgstr ""
63
+
64
+ #: woocommerce-ac.php:510
65
+ msgid "Sends email to Admin if an Abandoned Cart Order is recovered."
66
+ msgstr ""
67
+
68
+ #: woocommerce-ac.php:558
69
+ msgid ""
70
+ "Abandoned cart cut off time should be numeric and has to be greater than 0."
71
+ msgstr ""
72
+
73
+ #: woocommerce-ac.php:769 woocommerce-ac.php:816
74
+ msgid "New Customer Order - Recovered"
75
+ msgstr ""
76
+
77
+ #: woocommerce-ac.php:843
78
+ msgid "Abandoned Carts"
79
+ msgstr ""
80
+
81
+ #: woocommerce-ac.php:1469
82
+ msgid "Abandoned Orders"
83
+ msgstr ""
84
+
85
+ #: woocommerce-ac.php:1470
86
+ msgid "Email Templates"
87
+ msgstr ""
88
+
89
+ #: woocommerce-ac.php:1472
90
+ msgid "Recovered Orders"
91
+ msgstr ""
92
+
93
+ #: woocommerce-ac.php:1473
94
+ msgid "Product Report"
95
+ msgstr ""
96
+
97
+ #: woocommerce-ac.php:1570
98
+ msgid "You do not have sufficient permissions to access this page."
99
+ msgstr ""
100
+
101
+ #: woocommerce-ac.php:1574
102
+ msgid "WooCommerce - Abandon Cart Lite"
103
+ msgstr ""
104
+
105
+ #: woocommerce-ac.php:1640
106
+ msgid "The Abandoned cart has been successfully deleted."
107
+ msgstr ""
108
+
109
+ #: woocommerce-ac.php:1646
110
+ msgid "The Template has been successfully deleted."
111
+ msgstr ""
112
+
113
+ #: woocommerce-ac.php:1660
114
+ msgid ""
115
+ "Change settings for sending email notifications to Customers after X minute."
116
+ msgstr ""
117
+
118
+ #: woocommerce-ac.php:1673
119
+ msgid ""
120
+ "The list below shows all Abandoned Carts which have remained in cart for a "
121
+ "time higher than the \"Cart abandoned cut-off time\" setting."
122
+ msgstr ""
123
+
124
+ #: woocommerce-ac.php:1694
125
+ msgid ""
126
+ "Add email templates at different intervals to maximize the possibility of "
127
+ "recovering your abandoned carts."
128
+ msgstr ""
129
+
130
+ #: woocommerce-ac.php:2011
131
+ msgid "The Email Template has been successfully added."
132
+ msgstr ""
133
+
134
+ #: woocommerce-ac.php:2014
135
+ msgid ""
136
+ " There was a problem adding the email template. Please contact the plugin "
137
+ "author via <a href= \"https://wordpress.org/support/plugin/woocommerce-"
138
+ "abandoned-cart\">support forum</a>."
139
+ msgstr ""
140
+
141
+ #: woocommerce-ac.php:2019
142
+ msgid "The Email Template has been successfully updated."
143
+ msgstr ""
144
+
145
+ #: woocommerce-ac.php:2022
146
+ msgid ""
147
+ " There was a problem updating the email template. Please contact the plugin "
148
+ "author via <a href= \"https://wordpress.org/support/plugin/woocommerce-"
149
+ "abandoned-cart\">support forum</a>."
150
+ msgstr ""
151
+
152
+ #: woocommerce-ac.php:2028
153
+ msgid "Add New Template"
154
+ msgstr ""
155
+
156
+ #: woocommerce-ac.php:2120
157
+ msgid ""
158
+ "The Report below shows how many Abandoned Carts we were able to recover for "
159
+ "you by sending automatic emails to encourage shoppers."
160
+ msgstr ""
161
+
162
+ #: woocommerce-ac.php:2172
163
+ msgid "Start Date:"
164
+ msgstr ""
165
+
166
+ #: woocommerce-ac.php:2174
167
+ msgid "End Date:"
168
+ msgstr ""
169
+
170
+ #: woocommerce-ac.php:2176
171
+ msgid "Go"
172
+ msgstr ""
173
+
174
+ #: woocommerce-ac.php:2182
175
+ msgid "During the selected range "
176
+ msgstr ""
177
+
178
+ #: woocommerce-ac.php:2187
179
+ msgid "carts totaling"
180
+ msgstr ""
181
+
182
+ #: woocommerce-ac.php:2193
183
+ msgid " were abandoned. We were able to recover"
184
+ msgstr ""
185
+
186
+ #: woocommerce-ac.php:2200
187
+ msgid " of them, which led to an extra"
188
+ msgstr ""
189
+
190
+ #: woocommerce-ac.php:2226 woocommerce-ac.php:2964 cron/wcal_send_email.php:310
191
+ msgid "Item"
192
+ msgstr ""
193
+
194
+ #: woocommerce-ac.php:2227 woocommerce-ac.php:2965 cron/wcal_send_email.php:311
195
+ msgid "Name"
196
+ msgstr ""
197
+
198
+ #: woocommerce-ac.php:2228 woocommerce-ac.php:2966 cron/wcal_send_email.php:312
199
+ msgid "Quantity"
200
+ msgstr ""
201
+
202
+ #: woocommerce-ac.php:2229 woocommerce-ac.php:2968 cron/wcal_send_email.php:314
203
+ msgid "Line Subtotal"
204
+ msgstr ""
205
+
206
+ #: woocommerce-ac.php:2230
207
+ msgid "Line Total"
208
+ msgstr ""
209
+
210
+ #: woocommerce-ac.php:2474
211
+ msgid "Customer Details"
212
+ msgstr ""
213
+
214
+ #: woocommerce-ac.php:2478
215
+ msgid "Billing Details"
216
+ msgstr ""
217
+
218
+ #: woocommerce-ac.php:2479
219
+ msgid "Name:"
220
+ msgstr ""
221
+
222
+ #: woocommerce-ac.php:2482 woocommerce-ac.php:2502
223
+ msgid "Address:"
224
+ msgstr ""
225
+
226
+ #: woocommerce-ac.php:2492
227
+ msgid "Email:"
228
+ msgstr ""
229
+
230
+ #: woocommerce-ac.php:2496
231
+ msgid "Phone:"
232
+ msgstr ""
233
+
234
+ #: woocommerce-ac.php:2501
235
+ msgid "Shipping Details"
236
+ msgstr ""
237
+
238
+ #: woocommerce-ac.php:2586
239
+ msgid "Template Name:"
240
+ msgstr ""
241
+
242
+ #: woocommerce-ac.php:2597
243
+ msgid "Enter a template name for reference"
244
+ msgstr ""
245
+
246
+ #: woocommerce-ac.php:2603
247
+ msgid "Send From This Name:"
248
+ msgstr ""
249
+
250
+ #: woocommerce-ac.php:2614
251
+ msgid "Enter the name that should appear in the email sent"
252
+ msgstr ""
253
+
254
+ #: woocommerce-ac.php:2620
255
+ msgid "Send From This Email Address:"
256
+ msgstr ""
257
+
258
+ #: woocommerce-ac.php:2630
259
+ msgid ""
260
+ "Which email address should be shown in the \"From Email\" field for this "
261
+ "email?"
262
+ msgstr ""
263
+
264
+ #: woocommerce-ac.php:2636
265
+ msgid "Send Reply Emails to:"
266
+ msgstr ""
267
+
268
+ #: woocommerce-ac.php:2647
269
+ msgid ""
270
+ "When a contact receives your email and clicks reply, which email address "
271
+ "should that reply be sent to?"
272
+ msgstr ""
273
+
274
+ #: woocommerce-ac.php:2653
275
+ msgid "Subject:"
276
+ msgstr ""
277
+
278
+ #: woocommerce-ac.php:2664
279
+ msgid "Enter the subject that should appear in the email sent"
280
+ msgstr ""
281
+
282
+ #: woocommerce-ac.php:2670
283
+ msgid "Email Body:"
284
+ msgstr ""
285
+
286
+ #: woocommerce-ac.php:2698
287
+ msgid "Message to be sent in the reminder email."
288
+ msgstr ""
289
+
290
+ #: woocommerce-ac.php:2705
291
+ msgid "Use WooCommerce Template Style:"
292
+ msgstr ""
293
+
294
+ #: woocommerce-ac.php:2720
295
+ msgid ""
296
+ "Use WooCommerce default style template for abandoned cart reminder emails."
297
+ msgstr ""
298
+
299
+ #: woocommerce-ac.php:2727
300
+ msgid "Email Template Header Text: "
301
+ msgstr ""
302
+
303
+ #: woocommerce-ac.php:2742
304
+ msgid ""
305
+ "Enter the header which will appear in the abandoned WooCommerce email sent. "
306
+ "This is only applicable when only used when \"Use WooCommerce Template Style:"
307
+ "\" is checked."
308
+ msgstr ""
309
+
310
+ #: woocommerce-ac.php:2748
311
+ msgid "Active:"
312
+ msgstr ""
313
+
314
+ #: woocommerce-ac.php:2773
315
+ msgid ""
316
+ "The email template will be sent to customers only if the \"Active\" checkbox "
317
+ "is enabled. Leave this unchecked if you want to add the email template but "
318
+ "not send it to customers."
319
+ msgstr ""
320
+
321
+ #: woocommerce-ac.php:2779
322
+ msgid "Send this email:"
323
+ msgstr ""
324
+
325
+ #: woocommerce-ac.php:2825
326
+ msgid "after cart is abandoned."
327
+ msgstr ""
328
+
329
+ #: woocommerce-ac.php:2832
330
+ msgid "Send a test email to:"
331
+ msgstr ""
332
+
333
+ #: woocommerce-ac.php:2837
334
+ msgid "Enter the email id to which the test email needs to be sent."
335
+ msgstr ""
336
+
337
+ #: woocommerce-ac.php:2961 cron/wcal_send_email.php:307
338
+ msgid "Your Shopping Cart"
339
+ msgstr ""
340
+
341
+ #: woocommerce-ac.php:2967 cron/wcal_send_email.php:313
342
+ msgid "Price"
343
+ msgstr ""
344
+
345
+ #: woocommerce-ac.php:2972
346
+ msgid "Men\\'\\s Formal Shoes"
347
+ msgstr ""
348
+
349
+ #: woocommerce-ac.php:2979
350
+ msgid "Woman\\'\\s Hand Bags"
351
+ msgstr ""
352
+
353
+ #: woocommerce-ac.php:2988 cron/wcal_send_email.php:381
354
+ msgid "Cart Total:"
355
+ msgstr ""
356
+
357
+ #: cron/wcal_send_email.php:191
358
+ msgid "Abandoned cart reminder"
359
+ msgstr ""
360
+
361
+ #: includes/classes/class-wcal-abandoned-orders-table.php:42
362
+ msgid "abandoned_order_id"
363
+ msgstr ""
364
+
365
+ #: includes/classes/class-wcal-abandoned-orders-table.php:43
366
+ msgid "abandoned_order_ids"
367
+ msgstr ""
368
+
369
+ #: includes/classes/class-wcal-abandoned-orders-table.php:76
370
+ msgid "Id"
371
+ msgstr ""
372
+
373
+ #: includes/classes/class-wcal-abandoned-orders-table.php:77
374
+ #: includes/classes/class-wcal-recover-orders-table.php:106
375
+ msgid "Email Address"
376
+ msgstr ""
377
+
378
+ #: includes/classes/class-wcal-abandoned-orders-table.php:78
379
+ msgid "Customer"
380
+ msgstr ""
381
+
382
+ #: includes/classes/class-wcal-abandoned-orders-table.php:79
383
+ #: includes/classes/class-wcal-recover-orders-table.php:109
384
+ msgid "Order Total"
385
+ msgstr ""
386
+
387
+ #: includes/classes/class-wcal-abandoned-orders-table.php:80
388
+ msgid "Abandoned Date"
389
+ msgstr ""
390
+
391
+ #: includes/classes/class-wcal-abandoned-orders-table.php:81
392
+ msgid "Status of Cart"
393
+ msgstr ""
394
+
395
+ #: includes/classes/class-wcal-abandoned-orders-table.php:127
396
+ msgid "View order"
397
+ msgstr ""
398
+
399
+ #: includes/classes/class-wcal-abandoned-orders-table.php:128
400
+ #: includes/classes/class-wcal-abandoned-orders-table.php:394
401
+ #: includes/classes/class-wcal-templates-table.php:120
402
+ #: includes/classes/class-wcal-templates-table.php:256
403
+ msgid "Delete"
404
+ msgstr ""
405
+
406
+ #: includes/classes/class-wcal-abandoned-orders-table.php:246
407
+ msgid "item"
408
+ msgstr ""
409
+
410
+ #: includes/classes/class-wcal-abandoned-orders-table.php:248
411
+ msgid "items"
412
+ msgstr ""
413
+
414
+ #: includes/classes/class-wcal-abandoned-orders-table.php:252
415
+ msgid "Abandoned"
416
+ msgstr ""
417
+
418
+ #: includes/classes/class-wcal-abandoned-orders-table.php:254
419
+ msgid "Abandoned but new"
420
+ msgstr ""
421
+
422
+ #: includes/classes/class-wcal-abandoned-orders-table.php:254
423
+ msgid "cart created after this"
424
+ msgstr ""
425
+
426
+ #: includes/classes/class-wcal-product-report-table.php:82
427
+ msgid "product_id"
428
+ msgstr ""
429
+
430
+ #: includes/classes/class-wcal-product-report-table.php:83
431
+ msgid "product_ids"
432
+ msgstr ""
433
+
434
+ #: includes/classes/class-wcal-product-report-table.php:106
435
+ msgid "Product Name"
436
+ msgstr ""
437
+
438
+ #: includes/classes/class-wcal-product-report-table.php:107
439
+ msgid "Number of Times Abandoned"
440
+ msgstr ""
441
+
442
+ #: includes/classes/class-wcal-product-report-table.php:108
443
+ msgid "Number of Times Recovered"
444
+ msgstr ""
445
+
446
+ #: includes/classes/class-wcal-recover-orders-table.php:76
447
+ msgid "rec_abandoned_id"
448
+ msgstr ""
449
+
450
+ #: includes/classes/class-wcal-recover-orders-table.php:77
451
+ msgid "rec_abandoned_ids"
452
+ msgstr ""
453
+
454
+ #: includes/classes/class-wcal-recover-orders-table.php:105
455
+ msgid "Customer Name"
456
+ msgstr ""
457
+
458
+ #: includes/classes/class-wcal-recover-orders-table.php:107
459
+ msgid "Cart Abandoned Date"
460
+ msgstr ""
461
+
462
+ #: includes/classes/class-wcal-recover-orders-table.php:108
463
+ msgid "Cart Recovered Date"
464
+ msgstr ""
465
+
466
+ #: includes/classes/class-wcal-recover-orders-table.php:139
467
+ msgid "View Details"
468
+ msgstr ""
469
+
470
+ #: includes/classes/class-wcal-templates-table.php:43
471
+ msgid "template_id"
472
+ msgstr ""
473
+
474
+ #: includes/classes/class-wcal-templates-table.php:44
475
+ msgid "template_ids"
476
+ msgstr ""
477
+
478
+ #: includes/classes/class-wcal-templates-table.php:72
479
+ msgid "Sr"
480
+ msgstr ""
481
+
482
+ #: includes/classes/class-wcal-templates-table.php:73
483
+ msgid "Name Of Template"
484
+ msgstr ""
485
+
486
+ #: includes/classes/class-wcal-templates-table.php:74
487
+ msgid "Sent After Set Time"
488
+ msgstr ""
489
+
490
+ #: includes/classes/class-wcal-templates-table.php:75
491
+ msgid "Active ?"
492
+ msgstr ""
493
+
494
+ #: includes/classes/class-wcal-templates-table.php:119
495
+ msgid "Edit"
496
+ msgstr ""
497
+
498
+ #: includes/classes/class-wcal-templates-table.php:156
499
+ msgid " "
500
+ msgstr ""
i18n/languages/woocommerce-ac.pot ADDED
@@ -0,0 +1,505 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2016-12-27 18:29+0530\n"
12
+ "PO-Revision-Date: 2016-12-27 18:30+0500\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=UTF-8\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+ "Plural-Forms: \n"
20
+ "X-Generator: Eazy Po 0.9.5.3\n"
21
+
22
+ #: woocommerce-ac.php:28
23
+ msgid "Once Every Fifteen Minutes"
24
+ msgstr ""
25
+
26
+ #: woocommerce-ac.php:298 woocommerce-ac.php:1317
27
+ msgid "This order was abandoned & subsequently recovered."
28
+ msgstr ""
29
+
30
+ #: woocommerce-ac.php:323
31
+ msgid ""
32
+ "The Lite & Pro version of Abandoned Cart plugin for WooCommerce (from Tyche "
33
+ "Softwares) are active on your website. <br> In this case, the abandoned "
34
+ "carts will be captured in both plugins & email reminders will also be sent "
35
+ "from both plugins. <br> It is recommended that you deactivate the Lite "
36
+ "version & keep the Pro version active."
37
+ msgstr ""
38
+
39
+ #: woocommerce-ac.php:350
40
+ msgid "HTML Email Template"
41
+ msgstr ""
42
+
43
+ #: woocommerce-ac.php:356
44
+ msgid "Abandoned cart Email Template"
45
+ msgstr ""
46
+
47
+ #: woocommerce-ac.php:490 woocommerce-ac.php:1471
48
+ msgid "Settings"
49
+ msgstr ""
50
+
51
+ #: woocommerce-ac.php:497
52
+ msgid "Cart abandoned cut-off time"
53
+ msgstr ""
54
+
55
+ #: woocommerce-ac.php:501
56
+ msgid ""
57
+ "Consider cart abandoned after X minutes of item being added to cart & order "
58
+ "not placed."
59
+ msgstr ""
60
+
61
+ #: woocommerce-ac.php:506
62
+ msgid "Email admin On Order Recovery"
63
+ msgstr ""
64
+
65
+ #: woocommerce-ac.php:510
66
+ msgid "Sends email to Admin if an Abandoned Cart Order is recovered."
67
+ msgstr ""
68
+
69
+ #: woocommerce-ac.php:558
70
+ msgid ""
71
+ "Abandoned cart cut off time should be numeric and has to be greater than 0."
72
+ msgstr ""
73
+
74
+ #: woocommerce-ac.php:769 woocommerce-ac.php:816
75
+ msgid "New Customer Order - Recovered"
76
+ msgstr ""
77
+
78
+ #: woocommerce-ac.php:843
79
+ msgid "Abandoned Carts"
80
+ msgstr ""
81
+
82
+ #: woocommerce-ac.php:1469
83
+ msgid "Abandoned Orders"
84
+ msgstr ""
85
+
86
+ #: woocommerce-ac.php:1470
87
+ msgid "Email Templates"
88
+ msgstr ""
89
+
90
+ #: woocommerce-ac.php:1472
91
+ msgid "Recovered Orders"
92
+ msgstr ""
93
+
94
+ #: woocommerce-ac.php:1473
95
+ msgid "Product Report"
96
+ msgstr ""
97
+
98
+ #: woocommerce-ac.php:1570
99
+ msgid "You do not have sufficient permissions to access this page."
100
+ msgstr ""
101
+
102
+ #: woocommerce-ac.php:1574
103
+ msgid "WooCommerce - Abandon Cart Lite"
104
+ msgstr ""
105
+
106
+ #: woocommerce-ac.php:1640
107
+ msgid "The Abandoned cart has been successfully deleted."
108
+ msgstr ""
109
+
110
+ #: woocommerce-ac.php:1646
111
+ msgid "The Template has been successfully deleted."
112
+ msgstr ""
113
+
114
+ #: woocommerce-ac.php:1660
115
+ msgid ""
116
+ "Change settings for sending email notifications to Customers after X minute."
117
+ msgstr ""
118
+
119
+ #: woocommerce-ac.php:1673
120
+ msgid ""
121
+ "The list below shows all Abandoned Carts which have remained in cart for a "
122
+ "time higher than the \"Cart abandoned cut-off time\" setting."
123
+ msgstr ""
124
+
125
+ #: woocommerce-ac.php:1694
126
+ msgid ""
127
+ "Add email templates at different intervals to maximize the possibility of "
128
+ "recovering your abandoned carts."
129
+ msgstr ""
130
+
131
+ #: woocommerce-ac.php:2011
132
+ msgid "The Email Template has been successfully added."
133
+ msgstr ""
134
+
135
+ #: woocommerce-ac.php:2014
136
+ msgid ""
137
+ " There was a problem adding the email template. Please contact the plugin "
138
+ "author via <a href= \"https://wordpress.org/support/plugin/woocommerce-"
139
+ "abandoned-cart\">support forum</a>."
140
+ msgstr ""
141
+
142
+ #: woocommerce-ac.php:2019
143
+ msgid "The Email Template has been successfully updated."
144
+ msgstr ""
145
+
146
+ #: woocommerce-ac.php:2022
147
+ msgid ""
148
+ " There was a problem updating the email template. Please contact the plugin "
149
+ "author via <a href= \"https://wordpress.org/support/plugin/woocommerce-"
150
+ "abandoned-cart\">support forum</a>."
151
+ msgstr ""
152
+
153
+ #: woocommerce-ac.php:2028
154
+ msgid "Add New Template"
155
+ msgstr ""
156
+
157
+ #: woocommerce-ac.php:2120
158
+ msgid ""
159
+ "The Report below shows how many Abandoned Carts we were able to recover for "
160
+ "you by sending automatic emails to encourage shoppers."
161
+ msgstr ""
162
+
163
+ #: woocommerce-ac.php:2172
164
+ msgid "Start Date:"
165
+ msgstr ""
166
+
167
+ #: woocommerce-ac.php:2174
168
+ msgid "End Date:"
169
+ msgstr ""
170
+
171
+ #: woocommerce-ac.php:2176
172
+ msgid "Go"
173
+ msgstr ""
174
+
175
+ #: woocommerce-ac.php:2182
176
+ msgid "During the selected range "
177
+ msgstr ""
178
+
179
+ #: woocommerce-ac.php:2187
180
+ msgid "carts totaling"
181
+ msgstr ""
182
+
183
+ #: woocommerce-ac.php:2193
184
+ msgid " were abandoned. We were able to recover"
185
+ msgstr ""
186
+
187
+ #: woocommerce-ac.php:2200
188
+ msgid " of them, which led to an extra"
189
+ msgstr ""
190
+
191
+ #: woocommerce-ac.php:2226 woocommerce-ac.php:2964
192
+ #: cron/wcal_send_email.php:310
193
+ msgid "Item"
194
+ msgstr ""
195
+
196
+ #: woocommerce-ac.php:2227 woocommerce-ac.php:2965
197
+ #: cron/wcal_send_email.php:311
198
+ msgid "Name"
199
+ msgstr ""
200
+
201
+ #: woocommerce-ac.php:2228 woocommerce-ac.php:2966
202
+ #: cron/wcal_send_email.php:312
203
+ msgid "Quantity"
204
+ msgstr ""
205
+
206
+ #: woocommerce-ac.php:2229 woocommerce-ac.php:2968
207
+ #: cron/wcal_send_email.php:314
208
+ msgid "Line Subtotal"
209
+ msgstr ""
210
+
211
+ #: woocommerce-ac.php:2230
212
+ msgid "Line Total"
213
+ msgstr ""
214
+
215
+ #: woocommerce-ac.php:2474
216
+ msgid "Customer Details"
217
+ msgstr ""
218
+
219
+ #: woocommerce-ac.php:2478
220
+ msgid "Billing Details"
221
+ msgstr ""
222
+
223
+ #: woocommerce-ac.php:2479
224
+ msgid "Name:"
225
+ msgstr ""
226
+
227
+ #: woocommerce-ac.php:2482 woocommerce-ac.php:2502
228
+ msgid "Address:"
229
+ msgstr ""
230
+
231
+ #: woocommerce-ac.php:2492
232
+ msgid "Email:"
233
+ msgstr ""
234
+
235
+ #: woocommerce-ac.php:2496
236
+ msgid "Phone:"
237
+ msgstr ""
238
+
239
+ #: woocommerce-ac.php:2501
240
+ msgid "Shipping Details"
241
+ msgstr ""
242
+
243
+ #: woocommerce-ac.php:2586
244
+ msgid "Template Name:"
245
+ msgstr ""
246
+
247
+ #: woocommerce-ac.php:2597
248
+ msgid "Enter a template name for reference"
249
+ msgstr ""
250
+
251
+ #: woocommerce-ac.php:2603
252
+ msgid "Send From This Name:"
253
+ msgstr ""
254
+
255
+ #: woocommerce-ac.php:2614
256
+ msgid "Enter the name that should appear in the email sent"
257
+ msgstr ""
258
+
259
+ #: woocommerce-ac.php:2620
260
+ msgid "Send From This Email Address:"
261
+ msgstr ""
262
+
263
+ #: woocommerce-ac.php:2630
264
+ msgid ""
265
+ "Which email address should be shown in the \"From Email\" field for this "
266
+ "email?"
267
+ msgstr ""
268
+
269
+ #: woocommerce-ac.php:2636
270
+ msgid "Send Reply Emails to:"
271
+ msgstr ""
272
+
273
+ #: woocommerce-ac.php:2647
274
+ msgid ""
275
+ "When a contact receives your email and clicks reply, which email address "
276
+ "should that reply be sent to?"
277
+ msgstr ""
278
+
279
+ #: woocommerce-ac.php:2653
280
+ msgid "Subject:"
281
+ msgstr ""
282
+
283
+ #: woocommerce-ac.php:2664
284
+ msgid "Enter the subject that should appear in the email sent"
285
+ msgstr ""
286
+
287
+ #: woocommerce-ac.php:2670
288
+ msgid "Email Body:"
289
+ msgstr ""
290
+
291
+ #: woocommerce-ac.php:2698
292
+ msgid "Message to be sent in the reminder email."
293
+ msgstr ""
294
+
295
+ #: woocommerce-ac.php:2705
296
+ msgid "Use WooCommerce Template Style:"
297
+ msgstr ""
298
+
299
+ #: woocommerce-ac.php:2720
300
+ msgid ""
301
+ "Use WooCommerce default style template for abandoned cart reminder emails."
302
+ msgstr ""
303
+
304
+ #: woocommerce-ac.php:2727
305
+ msgid "Email Template Header Text: "
306
+ msgstr ""
307
+
308
+ #: woocommerce-ac.php:2742
309
+ msgid ""
310
+ "Enter the header which will appear in the abandoned WooCommerce email sent. "
311
+ "This is only applicable when only used when \"Use WooCommerce Template Style:"
312
+ "\" is checked."
313
+ msgstr ""
314
+
315
+ #: woocommerce-ac.php:2748
316
+ msgid "Active:"
317
+ msgstr ""
318
+
319
+ #: woocommerce-ac.php:2773
320
+ msgid ""
321
+ "The email template will be sent to customers only if the \"Active\" checkbox "
322
+ "is enabled. Leave this unchecked if you want to add the email template but "
323
+ "not send it to customers."
324
+ msgstr ""
325
+
326
+ #: woocommerce-ac.php:2779
327
+ msgid "Send this email:"
328
+ msgstr ""
329
+
330
+ #: woocommerce-ac.php:2825
331
+ msgid "after cart is abandoned."
332
+ msgstr ""
333
+
334
+ #: woocommerce-ac.php:2832
335
+ msgid "Send a test email to:"
336
+ msgstr ""
337
+
338
+ #: woocommerce-ac.php:2837
339
+ msgid "Enter the email id to which the test email needs to be sent."
340
+ msgstr ""
341
+
342
+ #: woocommerce-ac.php:2961 cron/wcal_send_email.php:307
343
+ msgid "Your Shopping Cart"
344
+ msgstr ""
345
+
346
+ #: woocommerce-ac.php:2967 cron/wcal_send_email.php:313
347
+ msgid "Price"
348
+ msgstr ""
349
+
350
+ #: woocommerce-ac.php:2972
351
+ msgid "Men\\'\\s Formal Shoes"
352
+ msgstr ""
353
+
354
+ #: woocommerce-ac.php:2979
355
+ msgid "Woman\\'\\s Hand Bags"
356
+ msgstr ""
357
+
358
+ #: woocommerce-ac.php:2988 cron/wcal_send_email.php:381
359
+ msgid "Cart Total:"
360
+ msgstr ""
361
+
362
+ #: cron/wcal_send_email.php:191
363
+ msgid "Abandoned cart reminder"
364
+ msgstr ""
365
+
366
+ #: includes/classes/class-wcal-abandoned-orders-table.php:42
367
+ msgid "abandoned_order_id"
368
+ msgstr ""
369
+
370
+ #: includes/classes/class-wcal-abandoned-orders-table.php:43
371
+ msgid "abandoned_order_ids"
372
+ msgstr ""
373
+
374
+ #: includes/classes/class-wcal-abandoned-orders-table.php:76
375
+ msgid "Id"
376
+ msgstr ""
377
+
378
+ #: includes/classes/class-wcal-abandoned-orders-table.php:77
379
+ #: includes/classes/class-wcal-recover-orders-table.php:106
380
+ msgid "Email Address"
381
+ msgstr ""
382
+
383
+ #: includes/classes/class-wcal-abandoned-orders-table.php:78
384
+ msgid "Customer"
385
+ msgstr ""
386
+
387
+ #: includes/classes/class-wcal-abandoned-orders-table.php:79
388
+ #: includes/classes/class-wcal-recover-orders-table.php:109
389
+ msgid "Order Total"
390
+ msgstr ""
391
+
392
+ #: includes/classes/class-wcal-abandoned-orders-table.php:80
393
+ msgid "Abandoned Date"
394
+ msgstr ""
395
+
396
+ #: includes/classes/class-wcal-abandoned-orders-table.php:81
397
+ msgid "Status of Cart"
398
+ msgstr ""
399
+
400
+ #: includes/classes/class-wcal-abandoned-orders-table.php:127
401
+ msgid "View order"
402
+ msgstr ""
403
+
404
+ #: includes/classes/class-wcal-abandoned-orders-table.php:128
405
+ #: includes/classes/class-wcal-abandoned-orders-table.php:394
406
+ #: includes/classes/class-wcal-templates-table.php:120
407
+ #: includes/classes/class-wcal-templates-table.php:256
408
+ msgid "Delete"
409
+ msgstr ""
410
+
411
+ #: includes/classes/class-wcal-abandoned-orders-table.php:246
412
+ msgid "item"
413
+ msgstr ""
414
+
415
+ #: includes/classes/class-wcal-abandoned-orders-table.php:248
416
+ msgid "items"
417
+ msgstr ""
418
+
419
+ #: includes/classes/class-wcal-abandoned-orders-table.php:252
420
+ msgid "Abandoned"
421
+ msgstr ""
422
+
423
+ #: includes/classes/class-wcal-abandoned-orders-table.php:254
424
+ msgid "Abandoned but new"
425
+ msgstr ""
426
+
427
+ #: includes/classes/class-wcal-abandoned-orders-table.php:254
428
+ msgid "cart created after this"
429
+ msgstr ""
430
+
431
+ #: includes/classes/class-wcal-product-report-table.php:82
432
+ msgid "product_id"
433
+ msgstr ""
434
+
435
+ #: includes/classes/class-wcal-product-report-table.php:83
436
+ msgid "product_ids"
437
+ msgstr ""
438
+
439
+ #: includes/classes/class-wcal-product-report-table.php:106
440
+ msgid "Product Name"
441
+ msgstr ""
442
+
443
+ #: includes/classes/class-wcal-product-report-table.php:107
444
+ msgid "Number of Times Abandoned"
445
+ msgstr ""
446
+
447
+ #: includes/classes/class-wcal-product-report-table.php:108
448
+ msgid "Number of Times Recovered"
449
+ msgstr ""
450
+
451
+ #: includes/classes/class-wcal-recover-orders-table.php:76
452
+ msgid "rec_abandoned_id"
453
+ msgstr ""
454
+
455
+ #: includes/classes/class-wcal-recover-orders-table.php:77
456
+ msgid "rec_abandoned_ids"
457
+ msgstr ""
458
+
459
+ #: includes/classes/class-wcal-recover-orders-table.php:105
460
+ msgid "Customer Name"
461
+ msgstr ""
462
+
463
+ #: includes/classes/class-wcal-recover-orders-table.php:107
464
+ msgid "Cart Abandoned Date"
465
+ msgstr ""
466
+
467
+ #: includes/classes/class-wcal-recover-orders-table.php:108
468
+ msgid "Cart Recovered Date"
469
+ msgstr ""
470
+
471
+ #: includes/classes/class-wcal-recover-orders-table.php:139
472
+ msgid "View Details"
473
+ msgstr ""
474
+
475
+ #: includes/classes/class-wcal-templates-table.php:43
476
+ msgid "template_id"
477
+ msgstr ""
478
+
479
+ #: includes/classes/class-wcal-templates-table.php:44
480
+ msgid "template_ids"
481
+ msgstr ""
482
+
483
+ #: includes/classes/class-wcal-templates-table.php:72
484
+ msgid "Sr"
485
+ msgstr ""
486
+
487
+ #: includes/classes/class-wcal-templates-table.php:73
488
+ msgid "Name Of Template"
489
+ msgstr ""
490
+
491
+ #: includes/classes/class-wcal-templates-table.php:74
492
+ msgid "Sent After Set Time"
493
+ msgstr ""
494
+
495
+ #: includes/classes/class-wcal-templates-table.php:75
496
+ msgid "Active ?"
497
+ msgstr ""
498
+
499
+ #: includes/classes/class-wcal-templates-table.php:119
500
+ msgid "Edit"
501
+ msgstr ""
502
+
503
+ #: includes/classes/class-wcal-templates-table.php:156
504
+ msgid " "
505
+ msgstr ""
includes/classes/class-wcal-abandoned-orders-table.php ADDED
@@ -0,0 +1,479 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Load WP_List_Table if not loaded
3
+ if ( ! class_exists( 'WP_List_Table' ) ) {
4
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
5
+ }
6
+
7
+ class WCAL_Abandoned_Orders_Table extends WP_List_Table {
8
+
9
+ /**
10
+ * Number of results to show per page
11
+ *
12
+ * @var string
13
+ * @since 2.5.2
14
+ */
15
+ public $per_page = 30;
16
+
17
+ /**
18
+ * URL of this page
19
+ *
20
+ * @var string
21
+ * @since 2.5.2
22
+ */
23
+ public $base_url;
24
+
25
+ /**
26
+ * Total number of bookings
27
+ *
28
+ * @var int
29
+ * @since 2.5.2
30
+ */
31
+ public $total_count;
32
+
33
+ /**
34
+ * Get things started
35
+ *
36
+ * @see WP_List_Table::__construct()
37
+ */
38
+ public function __construct() {
39
+ global $status, $page;
40
+ // Set parent defaults
41
+ parent::__construct( array(
42
+ 'singular' => __( 'abandoned_order_id', 'woocommerce-ac' ), //singular name of the listed records
43
+ 'plural' => __( 'abandoned_order_ids', 'woocommerce-ac' ), //plural name of the listed records
44
+ 'ajax' => false // Does this table support ajax?
45
+ ) );
46
+ $this->process_bulk_action();
47
+ $this->base_url = admin_url( 'admin.php?page=woocommerce_ac_page' );
48
+ }
49
+
50
+ public function wcal_abandoned_order_prepare_items() {
51
+ $columns = $this->get_columns();
52
+ $hidden = array(); // No hidden columns
53
+ $sortable = $this->get_sortable_columns();
54
+ $this->total_count = 0;
55
+ $data = $this->wcal_abandoned_cart_data();
56
+ $this->_column_headers = array( $columns, $hidden, $sortable );
57
+ $total_items = $this->total_count;
58
+
59
+ if( count( $data ) > 0 ) {
60
+ $this->items = $data;
61
+ } else {
62
+ $this->items = array();
63
+ }
64
+ $this->set_pagination_args( array(
65
+ 'total_items' => $total_items, // WE have to calculate the total number of items
66
+ 'per_page' => $this->per_page, // WE have to determine how many items to show on a page
67
+ 'total_pages' => ceil( $total_items / $this->per_page ) // WE have to calculate the total number of pages
68
+ )
69
+ );
70
+ }
71
+
72
+ public function get_columns() {
73
+ $columns = array();
74
+ $columns = array(
75
+ 'cb' => '<input type="checkbox" />',
76
+ 'id' => __( 'Id', 'woocommerce-ac' ),
77
+ 'email' => __( 'Email Address', 'woocommerce-ac' ),
78
+ 'customer' => __( 'Customer', 'woocommerce-ac' ),
79
+ 'order_total' => __( 'Order Total', 'woocommerce-ac' ),
80
+ 'date' => __( 'Abandoned Date', 'woocommerce-ac' ),
81
+ 'status' => __( 'Status of Cart', 'woocommerce-ac' )
82
+ );
83
+ return apply_filters( 'wcal_abandoned_orders_columns', $columns );
84
+ }
85
+
86
+ /***
87
+ * It is used to add the check box for the items
88
+ */
89
+ function column_cb( $item ){
90
+ $abandoned_order_id = '';
91
+ if( isset( $item->id ) && "" != $item->id ) {
92
+ $abandoned_order_id = $item->id;
93
+ }
94
+ return sprintf(
95
+ '<input type="checkbox" name="%1$s[]" value="%2$s" />',
96
+ 'abandoned_order_id',
97
+ $abandoned_order_id
98
+ );
99
+ }
100
+
101
+ public function get_sortable_columns() {
102
+ $columns = array(
103
+ 'date' => array( 'date', false ),
104
+ 'status' => array( 'status',false),
105
+ );
106
+ return apply_filters( 'wcal_abandoned_orders_sortable_columns', $columns );
107
+ }
108
+
109
+ /**
110
+ * Render the Email Column
111
+ *
112
+ * @access public
113
+ * @since 2.4.8
114
+ * @param array $abandoned_row_info Contains all the data of the abandoned order tabs row
115
+ * @return string Data shown in the Email column
116
+ *
117
+ * This function used for individual delete of row, It is for hover effect delete.
118
+ */
119
+ public function column_email( $abandoned_row_info ) {
120
+ $row_actions = array();
121
+ $value = '';
122
+ $abandoned_order_id = 0;
123
+
124
+ if( isset( $abandoned_row_info->email ) ) {
125
+ $abandoned_order_id = $abandoned_row_info->id ;
126
+ $row_actions['edit'] = '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'orderdetails', 'id' => $abandoned_row_info->id ), $this->base_url ), 'abandoned_order_nonce') . '">' . __( 'View order', 'woocommerce-ac' ) . '</a>';
127
+ $row_actions['delete'] = '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'wcal_delete', 'abandoned_order_id' => $abandoned_row_info->id ), $this->base_url ), 'abandoned_order_nonce') . '">' . __( 'Delete', 'woocommerce-ac' ) . '</a>';
128
+ $email = $abandoned_row_info->email;
129
+ $value = $email . $this->row_actions( $row_actions );
130
+ }
131
+ return apply_filters( 'wcal_abandoned_orders_single_column', $value, $abandoned_order_id, 'email' );
132
+ }
133
+
134
+ public function wcal_abandoned_cart_data() {
135
+ global $wpdb;
136
+ $return_abandoned_orders = array();
137
+ $per_page = $this->per_page;
138
+ $results = array();
139
+ $blank_cart_info = '{"cart":[]}';
140
+ $blank_cart_info_guest = '[]';
141
+
142
+ $get_section_of_page = WCAL_Abandoned_Orders_Table::wcal_get_current_section ();
143
+
144
+ $results = array();
145
+
146
+ switch ( $get_section_of_page ) {
147
+ case 'wcal_all_abandoned':
148
+ # code...
149
+ if( is_multisite() ) {
150
+ // get main site's table prefix
151
+ $main_prefix = $wpdb->get_blog_prefix(1);
152
+ $query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$main_prefix."users AS wpu ON wpac.user_id = wpu.id
153
+ WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' ORDER BY wpac.abandoned_cart_time DESC";
154
+ $results = $wpdb->get_results($query);
155
+ } else {
156
+ // non-multisite - regular table name
157
+ $query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$wpdb->prefix."users AS wpu ON wpac.user_id = wpu.id
158
+ WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' ORDER BY wpac.abandoned_cart_time DESC ";
159
+
160
+ $results = $wpdb->get_results($query);
161
+ }
162
+ break;
163
+
164
+ case 'wcal_all_registered':
165
+ # code...
166
+ if( is_multisite() ) {
167
+ // get main site's table prefix
168
+ $main_prefix = $wpdb->get_blog_prefix(1);
169
+ $query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$main_prefix."users AS wpu ON wpac.user_id = wpu.id
170
+ WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' ORDER BY wpac.abandoned_cart_time DESC ";
171
+ $results = $wpdb->get_results($query);
172
+ } else {
173
+ // non-multisite - regular table name
174
+ $query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$wpdb->prefix."users AS wpu ON wpac.user_id = wpu.id
175
+ WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND wpac.user_type = 'REGISTERED' ORDER BY wpac.abandoned_cart_time DESC ";
176
+
177
+
178
+ $results = $wpdb->get_results($query);
179
+ }
180
+ break;
181
+
182
+ case 'wcal_all_guest':
183
+ # code...
184
+ if( is_multisite() ) {
185
+ // get main site's table prefix
186
+ $main_prefix = $wpdb->get_blog_prefix(1);
187
+ $query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$main_prefix."users AS wpu ON wpac.user_id = wpu.id
188
+ WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' wpac.user_id >= 63000000 ORDER BY wpac.abandoned_cart_time DESC ";
189
+ $results = $wpdb->get_results($query);
190
+ } else {
191
+ // non-multisite - regular table name
192
+ $query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$wpdb->prefix."users AS wpu ON wpac.user_id = wpu.id
193
+ WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND wpac.user_id >= 63000000 ORDER BY wpac.abandoned_cart_time DESC ";
194
+ $results = $wpdb->get_results($query);
195
+ }
196
+ break;
197
+
198
+ case 'wcal_all_visitor':
199
+ # code...
200
+ if( is_multisite() ) {
201
+ // get main site's table prefix
202
+ $main_prefix = $wpdb->get_blog_prefix(1);
203
+ $query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$main_prefix."users AS wpu ON wpac.user_id = wpu.id
204
+ WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' wpac.user_id >= 63000000 ORDER BY wpac.abandoned_cart_time DESC ";
205
+ $results = $wpdb->get_results($query);
206
+ } else {
207
+ // non-multisite - regular table name
208
+ $query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$wpdb->prefix."users AS wpu ON wpac.user_id = wpu.id
209
+ WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND wpac.user_id = 0 ORDER BY wpac.abandoned_cart_time DESC ";
210
+ $results = $wpdb->get_results($query);
211
+ }
212
+ break;
213
+
214
+
215
+ default:
216
+ # code...
217
+ break;
218
+ }
219
+ $i = 0;
220
+
221
+ foreach( $results as $key => $value ) {
222
+ if( $value->user_type == "GUEST" ) {
223
+ $query_guest = "SELECT * from `" . $wpdb->prefix . "ac_guest_abandoned_cart_history_lite` WHERE id = %d";
224
+ $results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $value->user_id ) );
225
+ }
226
+ $abandoned_order_id = $value->id;
227
+ $user_id = $value->user_id;
228
+ $user_login = $value->user_login;
229
+
230
+ if ( $value->user_type == "GUEST" ) {
231
+
232
+ if ( isset( $results_guest[0]->email_id ) ) {
233
+ $user_email = $results_guest[0]->email_id;
234
+ } elseif ( $value->user_id == "0" ) {
235
+ $user_email = '';
236
+ } else {
237
+ $user_email = '';
238
+ }
239
+
240
+ if ( isset( $results_guest[0]->billing_first_name ) ) {
241
+ $user_first_name = $results_guest[0]->billing_first_name;
242
+ } else if( $value->user_id == "0" ) {
243
+ $user_first_name = "Visitor";
244
+ } else {
245
+ $user_first_name = "";
246
+ }
247
+
248
+ if ( isset( $results_guest[0]->billing_last_name ) ) {
249
+ $user_last_name = $results_guest[0]->billing_last_name;
250
+ } else if( $value->user_id == "0" ) {
251
+ $user_last_name = "";
252
+ } else {
253
+ $user_last_name = "";
254
+ }
255
+ } else {
256
+ $user_email_billing = get_user_meta( $value->user_id, 'billing_email', true );
257
+ if( $user_email_billing != '' ) {
258
+ $user_email = $user_email_billing;
259
+ } else {
260
+ $user_data = get_userdata( $value->user_id );
261
+ $user_email = $user_data->user_email;
262
+ }
263
+ $user_first_name = "";
264
+ $user_first_name_temp = get_user_meta( $user_id, 'billing_first_name', true );
265
+ if( isset( $user_first_name_temp ) && "" == $user_first_name_temp ) {
266
+ $user_data = get_userdata( $user_id );
267
+ $user_first_name = $user_data->first_name;
268
+ } else {
269
+ $user_first_name = $user_first_name_temp;
270
+ }
271
+
272
+ $user_last_name = "";
273
+ $user_last_name_temp = get_user_meta( $user_id, 'billing_last_name', true );
274
+ if( isset( $user_last_name_temp ) && "" == $user_last_name_temp ) {
275
+ $user_data = get_userdata( $user_id );
276
+ $user_last_name = $user_data->last_name;
277
+ } else {
278
+ $user_last_name = $user_last_name_temp;
279
+ }
280
+ }
281
+
282
+ $cart_info = json_decode( $value->abandoned_cart_info );
283
+ $order_date = "";
284
+ $cart_update_time = $value->abandoned_cart_time;
285
+
286
+ if ( $cart_update_time != "" && $cart_update_time != 0 ) {
287
+ $order_date = date( 'd M, Y h:i A', $cart_update_time );
288
+ }
289
+
290
+ $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
291
+ $cut_off_time = $ac_cutoff_time * 60;
292
+ $current_time = current_time( 'timestamp' );
293
+ $compare_time = $current_time - $cart_update_time;
294
+ $cart_details = array();
295
+ if( isset( $cart_info->cart ) ){
296
+ $cart_details = $cart_info->cart;
297
+ }
298
+ $line_total = 0;
299
+
300
+ if( count( $cart_details ) > 0 ) {
301
+ foreach( $cart_details as $k => $v ) {
302
+ if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
303
+ $line_total = $line_total + $v->line_total + $v->line_subtotal_tax;
304
+ } else {
305
+ $line_total = $line_total + $v->line_total;
306
+ }
307
+ }
308
+ }
309
+ //$number_decimal = wc_get_price_decimals();
310
+ $line_total = wc_price( $line_total );
311
+ $quantity_total = 0;
312
+
313
+ if ( count( $cart_details ) > 0) {
314
+ foreach( $cart_details as $k => $v ) {
315
+ $quantity_total = $quantity_total + $v->quantity;
316
+ }
317
+ }
318
+
319
+ if ( 1 == $quantity_total ) {
320
+ $item_disp = __("item", "woocommerce-ac");
321
+ } else {
322
+ $item_disp = __("items", "woocommerce-ac");
323
+ }
324
+
325
+ if( $value->cart_ignored == 0 && $value->recovered_cart == 0 ) {
326
+ $ac_status = __( "Abandoned", "woocommerce-ac" );
327
+ } elseif( $value->cart_ignored == 1 && $value->recovered_cart == 0 ) {
328
+ $ac_status = __( "Abandoned but new","woocommerce-ac" )."</br>". __( "cart created after this", "woocommerce-ac" );
329
+ } else {
330
+ $ac_status = "";
331
+ }
332
+
333
+ if( $compare_time > $cut_off_time && $ac_status != "" ) {
334
+ $return_abandoned_orders[$i] = new stdClass();
335
+ if( $quantity_total > 0 ) {
336
+ $abandoned_order_id = $abandoned_order_id;
337
+ $customer_information = $user_first_name . " ".$user_last_name;
338
+ $return_abandoned_orders[ $i ]->id = $abandoned_order_id;
339
+ $return_abandoned_orders[ $i ]->email = $user_email;
340
+ $return_abandoned_orders[ $i ]->customer = $customer_information;
341
+ $return_abandoned_orders[ $i ]->order_total = $line_total;
342
+ $return_abandoned_orders[ $i ]->date = $order_date;
343
+ $return_abandoned_orders[ $i ]->status = $ac_status;
344
+ }else {
345
+ $abandoned_order_id = $abandoned_order_id;
346
+ $return_abandoned_orders[ $i ]->id = $abandoned_order_id;
347
+ $return_abandoned_orders[ $i ]->date = $order_date;
348
+ $return_abandoned_orders[ $i ]->status = $ac_status;
349
+ }
350
+ // To get the abandoned orders count
351
+ $this->total_count = count( $return_abandoned_orders );
352
+ $i++;
353
+ }
354
+ }
355
+ // sort for order date
356
+ if( isset( $_GET['orderby'] ) && $_GET['orderby'] == 'date' ) {
357
+ if( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
358
+ usort( $return_abandoned_orders, array( __CLASS__ , "wcal_class_order_date_asc") );
359
+ }
360
+ else {
361
+ usort( $return_abandoned_orders, array( __CLASS__ , "wcal_class_order_date_dsc") );
362
+ }
363
+ }
364
+ // sort for customer name
365
+ else if( isset( $_GET['orderby'] ) && $_GET['orderby'] == 'status' ) {
366
+ if( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
367
+ usort( $return_abandoned_orders, array( __CLASS__ , "wcal_class_status_asc" ) );
368
+ } else {
369
+ usort( $return_abandoned_orders, array( __CLASS__ , "wcal_class_status_dsc" ) );
370
+ }
371
+ }
372
+
373
+ if( isset( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
374
+ $page_number = $_GET['paged'] - 1;
375
+ $k = $per_page * $page_number;
376
+ } else {
377
+ $k = 0;
378
+ }
379
+ $return_abandoned_orders_display = array();
380
+ for( $j = $k; $j < ( $k+$per_page ); $j++ ) {
381
+ if( isset( $return_abandoned_orders[$j] ) ) {
382
+ $return_abandoned_orders_display[$j] = $return_abandoned_orders[$j];
383
+ } else {
384
+ break;
385
+ }
386
+ }
387
+ return apply_filters( 'wcal_abandoned_orders_table_data', $return_abandoned_orders_display );
388
+ }
389
+
390
+ function wcal_class_order_date_asc( $value1,$value2 ) {
391
+ $date_two = $date_one = '';
392
+ $value_one = $value1->date;
393
+ $value_two = $value2->date;
394
+ $date_formatted_one = date_create_from_format( 'd M, Y h:i A', $value_one );
395
+ if( isset( $date_formatted_one ) && $date_formatted_one != '' ) {
396
+ $date_one = date_format( $date_formatted_one, 'Y-m-d h:i A' );
397
+ }
398
+
399
+ $date_formatted_two = date_create_from_format( 'd M, Y h:i A', $value_two );
400
+ if( isset( $date_formatted_two ) && $date_formatted_two != '' ) {
401
+ $date_two = date_format( $date_formatted_two, 'Y-m-d h:i A' );
402
+ }
403
+ return strtotime( $date_one ) - strtotime( $date_two );
404
+ }
405
+
406
+ function wcal_class_order_date_dsc( $value1,$value2 ) {
407
+ $date_two = $date_one = '';
408
+ $value_one = $value1->date;
409
+ $value_two = $value2->date;
410
+ $date_formatted_one = date_create_from_format( 'd M, Y h:i A', $value_one );
411
+ if( isset( $date_formatted_one ) && $date_formatted_one != '' ) {
412
+ $date_one = date_format( $date_formatted_one, 'Y-m-d h:i A' );
413
+ }
414
+
415
+ $date_formatted_two = date_create_from_format( 'd M, Y h:i A', $value_two );
416
+ if( isset( $date_formatted_two ) && $date_formatted_two != '' ) {
417
+ $date_two = date_format( $date_formatted_two, 'Y-m-d h:i A' );
418
+ }
419
+ return strtotime($date_two) - strtotime($date_one);
420
+ }
421
+
422
+ function wcal_class_status_asc( $value1,$value2 ) {
423
+ return strcasecmp( $value1->status,$value2->status );
424
+ }
425
+
426
+ function wcal_class_status_dsc( $value1,$value2 ) {
427
+ return strcasecmp( $value2->status,$value1->status );
428
+ }
429
+
430
+ public function column_default( $wcal_abandoned_orders, $column_name ) {
431
+ $value = '';
432
+ switch( $column_name ) {
433
+ case 'id' :
434
+ if( isset($wcal_abandoned_orders->id ) ) {
435
+ $value = '<strong><a href="admin.php?page=woocommerce_ac_page&action=orderdetails&id='.$wcal_abandoned_orders->id.' ">'.$wcal_abandoned_orders->id.'</a> </strong>';
436
+ }
437
+ break;
438
+ case 'customer' :
439
+ if( isset( $wcal_abandoned_orders->customer ) ) {
440
+ $value = $wcal_abandoned_orders->customer;
441
+ }
442
+ break;
443
+ case 'order_total' :
444
+ if( isset( $wcal_abandoned_orders->order_total ) ) {
445
+ $value = $wcal_abandoned_orders->order_total;
446
+ }
447
+ break;
448
+ case 'date' :
449
+ if( isset( $wcal_abandoned_orders->date ) ) {
450
+ $value = $wcal_abandoned_orders->date;
451
+ }
452
+ break;
453
+ case 'status' :
454
+ if( isset( $wcal_abandoned_orders->status ) ) {
455
+ $value = $wcal_abandoned_orders->status;
456
+ }
457
+ break;
458
+ default:
459
+ $value = isset( $wcal_abandoned_orders->$column_name ) ? $wcal_abandoned_orders->$column_name : '';
460
+ break;
461
+ }
462
+ return apply_filters( 'wcal_abandoned_orders_column_default', $value, $wcal_abandoned_orders, $column_name );
463
+ }
464
+
465
+ public function get_bulk_actions() {
466
+ return array(
467
+ 'wcal_delete' => __( 'Delete', 'woocommerce-ac' )
468
+ );
469
+ }
470
+
471
+ public function wcal_get_current_section () {
472
+ $section = 'wcal_all_abandoned';
473
+ if ( isset( $_GET[ 'wcal_section' ] ) ) {
474
+ $section = $_GET[ 'wcal_section' ];
475
+ }
476
+ return $section ;
477
+ }
478
+ }
479
+ ?>
includes/classes/class-wcal-aes-counter.php ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
3
+ /* AES counter (CTR) mode implementation in PHP */
4
+ /* (c) Chris Veness 2005-2014 www.movable-type.co.uk/scripts */
5
+ /* Right of free use is granted for all commercial or non-commercial use under CC-BY licence. */
6
+ /* No warranty of any form is offered. */
7
+ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
8
+
9
+ Class Wcal_Aes_Ctr extends Wcal_Aes
10
+ {
11
+
12
+ /**
13
+ * Encrypt a text using AES encryption in Counter mode of operation
14
+ * - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
15
+ *
16
+ * Unicode multi-byte character safe
17
+ *
18
+ * @param plaintext source text to be encrypted
19
+ * @param password the password to use to generate a key
20
+ * @param nBits number of bits to be used in the key (128, 192, or 256)
21
+ * @return encrypted text
22
+ */
23
+ public static function encrypt($plaintext, $password, $nBits)
24
+ {
25
+ $blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
26
+ if (!($nBits == 128 || $nBits == 192 || $nBits == 256)) return ''; // standard allows 128/192/256 bit keys
27
+ // note PHP (5) gives us plaintext and password in UTF8 encoding!
28
+
29
+ // use AES itself to encrypt password to get cipher key (using plain password as source for
30
+ // key expansion) - gives us well encrypted key
31
+ $nBytes = $nBits / 8; // no bytes in key
32
+ $pwBytes = array();
33
+ for ($i = 0; $i < $nBytes; $i++) $pwBytes[$i] = ord(substr($password, $i, 1)) & 0xff;
34
+ $key = Wcal_Aes::cipher($pwBytes, Wcal_Aes::keyExpansion($pwBytes));
35
+ $key = array_merge($key, array_slice($key, 0, $nBytes - 16)); // expand key to 16/24/32 bytes long
36
+
37
+ // initialise 1st 8 bytes of counter block with nonce (NIST SP800-38A �B.2): [0-1] = millisec,
38
+ // [2-3] = random, [4-7] = seconds, giving guaranteed sub-ms uniqueness up to Feb 2106
39
+ $counterBlock = array();
40
+ $nonce = floor(microtime(true) * 1000); // timestamp: milliseconds since 1-Jan-1970
41
+ $nonceMs = $nonce % 1000;
42
+ $nonceSec = floor($nonce / 1000);
43
+ $nonceRnd = floor(rand(0, 0xffff));
44
+
45
+ for ($i = 0; $i < 2; $i++) $counterBlock[$i] = self::urs($nonceMs, $i * 8) & 0xff;
46
+ for ($i = 0; $i < 2; $i++) $counterBlock[$i + 2] = self::urs($nonceRnd, $i * 8) & 0xff;
47
+ for ($i = 0; $i < 4; $i++) $counterBlock[$i + 4] = self::urs($nonceSec, $i * 8) & 0xff;
48
+
49
+ // and convert it to a string to go on the front of the ciphertext
50
+ $ctrTxt = '';
51
+ for ($i = 0; $i < 8; $i++) $ctrTxt .= chr($counterBlock[$i]);
52
+
53
+ // generate key schedule - an expansion of the key into distinct Key Rounds for each round
54
+ $keySchedule = Wcal_Aes::keyExpansion($key);
55
+ //print_r($keySchedule);
56
+
57
+ $blockCount = ceil(strlen($plaintext) / $blockSize);
58
+ $ciphertxt = array(); // ciphertext as array of strings
59
+
60
+ for ($b = 0; $b < $blockCount; $b++) {
61
+ // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
62
+ // done in two stages for 32-bit ops: using two words allows us to go past 2^32 blocks (68GB)
63
+ for ($c = 0; $c < 4; $c++) $counterBlock[15 - $c] = self::urs($b, $c * 8) & 0xff;
64
+ for ($c = 0; $c < 4; $c++) $counterBlock[15 - $c - 4] = self::urs($b / 0x100000000, $c * 8);
65
+
66
+ $cipherCntr = Wcal_Aes::cipher($counterBlock, $keySchedule); // -- encrypt counter block --
67
+
68
+ // block size is reduced on final block
69
+ $blockLength = $b < $blockCount - 1 ? $blockSize : (strlen($plaintext) - 1) % $blockSize + 1;
70
+ $cipherByte = array();
71
+
72
+ for ($i = 0; $i < $blockLength; $i++) { // -- xor plaintext with ciphered counter byte-by-byte --
73
+ $cipherByte[$i] = $cipherCntr[$i] ^ ord(substr($plaintext, $b * $blockSize + $i, 1));
74
+ $cipherByte[$i] = chr($cipherByte[$i]);
75
+ }
76
+ $ciphertxt[$b] = implode('', $cipherByte); // escape troublesome characters in ciphertext
77
+ }
78
+
79
+ // implode is more efficient than repeated string concatenation
80
+ $ciphertext = $ctrTxt . implode('', $ciphertxt);
81
+ $ciphertext = base64_encode($ciphertext);
82
+ return $ciphertext;
83
+ }
84
+
85
+
86
+ /**
87
+ * Decrypt a text encrypted by AES in counter mode of operation
88
+ *
89
+ * @param ciphertext source text to be decrypted
90
+ * @param password the password to use to generate a key
91
+ * @param nBits number of bits to be used in the key (128, 192, or 256)
92
+ * @return decrypted text
93
+ */
94
+ public static function decrypt($ciphertext, $password, $nBits)
95
+ {
96
+ $blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
97
+ if (!($nBits == 128 || $nBits == 192 || $nBits == 256)) return ''; // standard allows 128/192/256 bit keys
98
+ $ciphertext = base64_decode($ciphertext);
99
+
100
+ // use AES to encrypt password (mirroring encrypt routine)
101
+ $nBytes = $nBits / 8; // no bytes in key
102
+ $pwBytes = array();
103
+ for ($i = 0; $i < $nBytes; $i++) $pwBytes[$i] = ord(substr($password, $i, 1)) & 0xff;
104
+ $key = Wcal_Aes::cipher($pwBytes, Wcal_Aes::keyExpansion($pwBytes));
105
+ $key = array_merge($key, array_slice($key, 0, $nBytes - 16)); // expand key to 16/24/32 bytes long
106
+
107
+ // recover nonce from 1st element of ciphertext
108
+ $counterBlock = array();
109
+ $ctrTxt = substr($ciphertext, 0, 8);
110
+ for ($i = 0; $i < 8; $i++) $counterBlock[$i] = ord(substr($ctrTxt, $i, 1));
111
+
112
+ // generate key schedule
113
+ $keySchedule = Wcal_Aes::keyExpansion($key);
114
+
115
+ // separate ciphertext into blocks (skipping past initial 8 bytes)
116
+ $nBlocks = ceil((strlen($ciphertext) - 8) / $blockSize);
117
+ $ct = array();
118
+ for ($b = 0; $b < $nBlocks; $b++) $ct[$b] = substr($ciphertext, 8 + $b * $blockSize, 16);
119
+ $ciphertext = $ct; // ciphertext is now array of block-length strings
120
+
121
+ // plaintext will get generated block-by-block into array of block-length strings
122
+ $plaintxt = array();
123
+
124
+ for ($b = 0; $b < $nBlocks; $b++) {
125
+ // set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
126
+ for ($c = 0; $c < 4; $c++) $counterBlock[15 - $c] = self::urs($b, $c * 8) & 0xff;
127
+ for ($c = 0; $c < 4; $c++) $counterBlock[15 - $c - 4] = self::urs(($b + 1) / 0x100000000 - 1, $c * 8) & 0xff;
128
+
129
+ $cipherCntr = Wcal_Aes::cipher($counterBlock, $keySchedule); // encrypt counter block
130
+
131
+ $plaintxtByte = array();
132
+ for ($i = 0; $i < strlen($ciphertext[$b]); $i++) {
133
+ // -- xor plaintext with ciphered counter byte-by-byte --
134
+ $plaintxtByte[$i] = $cipherCntr[$i] ^ ord(substr($ciphertext[$b], $i, 1));
135
+ $plaintxtByte[$i] = chr($plaintxtByte[$i]);
136
+
137
+ }
138
+ $plaintxt[$b] = implode('', $plaintxtByte);
139
+ }
140
+
141
+ // join array of blocks into single plaintext string
142
+ $plaintext = implode('', $plaintxt);
143
+
144
+ return $plaintext;
145
+ }
146
+
147
+
148
+ /*
149
+ * Unsigned right shift function, since PHP has neither >>> operator nor unsigned ints
150
+ *
151
+ * @param a number to be shifted (32-bit integer)
152
+ * @param b number of bits to shift a to the right (0..31)
153
+ * @return a right-shifted and zero-filled by b bits
154
+ */
155
+ private static function urs($a, $b)
156
+ {
157
+ $a &= 0xffffffff;
158
+ $b &= 0x1f; // (bounds check)
159
+ if ($a & 0x80000000 && $b > 0) { // if left-most bit set
160
+ $a = ($a >> 1) & 0x7fffffff; // right-shift one bit & clear left-most bit
161
+ $check = $b - 1 ;
162
+ $a = $a >> ($check); // remaining right-shifts
163
+ } else { // otherwise
164
+ $a = ($a >> $b); // use normal right-shift
165
+ }
166
+ return $a;
167
+ }
168
+
169
+ }
170
+
171
+ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
includes/classes/class-wcal-aes.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
3
+ /* AES implementation in PHP */
4
+ /* (c) Chris Veness 2005-2014 www.movable-type.co.uk/scripts */
5
+ /* Right of free use is granted for all commercial or non-commercial use under CC-BY licence. */
6
+ /* No warranty of any form is offered. */
7
+ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
8
+
9
+ Class Wcal_Aes
10
+ {
11
+ /**
12
+ * AES Cipher function [�5.1]: encrypt 'input' with Rijndael algorithm
13
+ *
14
+ * @param input message as byte-array (16 bytes)
15
+ * @param w key schedule as 2D byte-array (Nr+1 x Nb bytes) -
16
+ * generated from the cipher key by keyExpansion()
17
+ * @return ciphertext as byte-array (16 bytes)
18
+ */
19
+ public static function cipher($input, $w)
20
+ {
21
+ $Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
22
+ $Nr = count($w) / $Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys
23
+ $state = array(); // initialise 4xNb byte-array 'state' with input [�3.4]
24
+ for( $i = 0; $i < 4 * $Nb; $i++ ) $state[$i % 4][floor($i / 4)] = $input[$i];
25
+
26
+ $state = self::addRoundKey( $state, $w, 0, $Nb );
27
+
28
+ for ( $round = 1; $round < $Nr; $round++ ) { // apply Nr rounds
29
+ $state = self::subBytes( $state, $Nb );
30
+ $state = self::shiftRows( $state, $Nb );
31
+ $state = self::mixColumns( $state, $Nb );
32
+ $state = self::addRoundKey( $state, $w, $round, $Nb );
33
+ }
34
+
35
+ $state = self::subBytes( $state, $Nb );
36
+ $state = self::shiftRows( $state, $Nb );
37
+ $state = self::addRoundKey( $state, $w, $Nr, $Nb );
38
+
39
+ $output = array( 4 * $Nb ); // convert state to 1-d array before returning [�3.4]
40
+ for( $i = 0; $i < 4 * $Nb; $i++ ) $output[$i] = $state[$i % 4][floor($i / 4)];
41
+ return $output;
42
+ }
43
+ /**
44
+ * Xor Round Key into state S [�5.1.4].
45
+ */
46
+ private static function addRoundKey( $state, $w, $rnd, $Nb )
47
+ {
48
+ for( $r = 0; $r < 4; $r++ ) {
49
+ for ($c = 0; $c < $Nb; $c++) $state[$r][$c] ^= $w[$rnd * 4 + $c][$r];
50
+ }
51
+ return $state;
52
+ }
53
+
54
+ /**
55
+ * Apply SBox to state S [�5.1.1].
56
+ */
57
+ private static function subBytes($s, $Nb)
58
+ {
59
+ for( $r = 0; $r < 4; $r++ ) {
60
+ for( $c = 0; $c < $Nb; $c++ ) $s[$r][$c] = self::$sBox[$s[$r][$c]];
61
+ }
62
+ return $s;
63
+ }
64
+
65
+ /**
66
+ * Shift row r of state S left by r bytes [�5.1.2].
67
+ */
68
+ private static function shiftRows($s, $Nb)
69
+ {
70
+ $t = array(4);
71
+ for ($r = 1; $r < 4; $r++) {
72
+ for ($c = 0; $c < 4; $c++) $t[$c] = $s[$r][($c + $r) % $Nb]; // shift into temp copy
73
+ for ($c = 0; $c < 4; $c++) $s[$r][$c] = $t[$c]; // and copy back
74
+ } // note that this will work for Nb=4,5,6, but not 7,8 (always 4 for AES):
75
+ return $s; // see fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.311.pdf
76
+ }
77
+
78
+ /**
79
+ * Combine bytes of each col of state S [�5.1.3].
80
+ */
81
+ private static function mixColumns($s, $Nb)
82
+ {
83
+ for ($c = 0; $c < 4; $c++) {
84
+ $a = array(4); // 'a' is a copy of the current column from 's'
85
+ $b = array(4); // 'b' is a�{02} in GF(2^8)
86
+ for ($i = 0; $i < 4; $i++) {
87
+ $a[$i] = $s[$i][$c];
88
+ $b[$i] = $s[$i][$c] & 0x80 ? $s[$i][$c] << 1 ^ 0x011b : $s[$i][$c] << 1;
89
+ }
90
+ // a[n] ^ b[n] is a�{03} in GF(2^8)
91
+ $s[0][$c] = $b[0] ^ $a[1] ^ $b[1] ^ $a[2] ^ $a[3]; // 2*a0 + 3*a1 + a2 + a3
92
+ $s[1][$c] = $a[0] ^ $b[1] ^ $a[2] ^ $b[2] ^ $a[3]; // a0 * 2*a1 + 3*a2 + a3
93
+ $s[2][$c] = $a[0] ^ $a[1] ^ $b[2] ^ $a[3] ^ $b[3]; // a0 + a1 + 2*a2 + 3*a3
94
+ $s[3][$c] = $a[0] ^ $b[0] ^ $a[1] ^ $a[2] ^ $b[3]; // 3*a0 + a1 + a2 + 2*a3
95
+ }
96
+ return $s;
97
+ }
98
+
99
+ /**
100
+ * Generate Key Schedule from Cipher Key [�5.2].
101
+ *
102
+ * Perform key expansion on cipher key to generate a key schedule.
103
+ *
104
+ * @param key cipher key byte-array (16 bytes).
105
+ * @return key schedule as 2D byte-array (Nr+1 x Nb bytes).
106
+ */
107
+ public static function keyExpansion($key)
108
+ {
109
+ $Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
110
+ $Nk = count($key) / 4; // key length (in words): 4/6/8 for 128/192/256-bit keys
111
+ $Nr = $Nk + 6; // no of rounds: 10/12/14 for 128/192/256-bit keys
112
+
113
+ $w = array();
114
+ $temp = array();
115
+
116
+ for ($i = 0; $i < $Nk; $i++) {
117
+ $r = array($key[4 * $i], $key[4 * $i + 1], $key[4 * $i + 2], $key[4 * $i + 3]);
118
+ $w[$i] = $r;
119
+ }
120
+
121
+ for ($i = $Nk; $i < ($Nb * ($Nr + 1)); $i++) {
122
+ $w[$i] = array();
123
+ for ($t = 0; $t < 4; $t++) $temp[$t] = $w[$i - 1][$t];
124
+ if ($i % $Nk == 0) {
125
+ $temp = self::subWord(self::rotWord($temp));
126
+ for ($t = 0; $t < 4; $t++) $temp[$t] ^= self::$rCon[$i / $Nk][$t];
127
+ } else if ($Nk > 6 && $i % $Nk == 4) {
128
+ $temp = self::subWord($temp);
129
+ }
130
+ for ($t = 0; $t < 4; $t++) $w[$i][$t] = $w[$i - $Nk][$t] ^ $temp[$t];
131
+ }
132
+ return $w;
133
+ }
134
+
135
+ /**
136
+ * Apply SBox to 4-byte word w.
137
+ */
138
+ private static function subWord($w)
139
+ {
140
+ for ($i = 0; $i < 4; $i++) $w[$i] = self::$sBox[$w[$i]];
141
+ return $w;
142
+ }
143
+
144
+ /**
145
+ * Rotate 4-byte word w left by one byte.
146
+ */
147
+ private static function rotWord($w)
148
+ {
149
+ $tmp = $w[0];
150
+ for ($i = 0; $i < 3; $i++) $w[$i] = $w[$i + 1];
151
+ $w[3] = $tmp;
152
+ return $w;
153
+ }
154
+
155
+ // sBox is pre-computed multiplicative inverse in GF(2^8) used in subBytes and keyExpansion [�5.1.1]
156
+ private static $sBox = array(
157
+ 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
158
+ 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
159
+ 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
160
+ 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
161
+ 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
162
+ 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
163
+ 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
164
+ 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
165
+ 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
166
+ 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
167
+ 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
168
+ 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
169
+ 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
170
+ 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
171
+ 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
172
+ 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16);
173
+
174
+ // rCon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [�5.2]
175
+ private static $rCon = array(
176
+ array(0x00, 0x00, 0x00, 0x00),
177
+ array(0x01, 0x00, 0x00, 0x00),
178
+ array(0x02, 0x00, 0x00, 0x00),
179
+ array(0x04, 0x00, 0x00, 0x00),
180
+ array(0x08, 0x00, 0x00, 0x00),
181
+ array(0x10, 0x00, 0x00, 0x00),
182
+ array(0x20, 0x00, 0x00, 0x00),
183
+ array(0x40, 0x00, 0x00, 0x00),
184
+ array(0x80, 0x00, 0x00, 0x00),
185
+ array(0x1b, 0x00, 0x00, 0x00),
186
+ array(0x36, 0x00, 0x00, 0x00));
187
+
188
+ }
189
+
190
+ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
includes/classes/class-wcal-product-report-table.php ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if( session_id() === '' ){
4
+ //session has not started
5
+ session_start();
6
+ }
7
+ // Load WP_List_Table if not loaded
8
+ if ( ! class_exists( 'WP_List_Table' ) ) {
9
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
10
+ }
11
+
12
+ class WCAL_Product_Report_Table extends WP_List_Table {
13
+
14
+ /**
15
+ * Number of results to show per page
16
+ *
17
+ * @var string
18
+ * @since 2.5.3
19
+ */
20
+ public $per_page = 30;
21
+
22
+ /**
23
+ * URL of this page
24
+ *
25
+ * @var string
26
+ * @since 2.5.3
27
+ */
28
+ public $base_url;
29
+
30
+ /**
31
+ * Total number of recovred orders
32
+ *
33
+ * @var int
34
+ * @since 2.5.3
35
+ */
36
+ public $total_count;
37
+
38
+
39
+ /**
40
+ * Total number of recovred orders
41
+ *
42
+ * @var int
43
+ * @since 2.5.3
44
+ */
45
+ public $open_emails;
46
+
47
+ /**
48
+ * Total amount of abandoned orders
49
+ *
50
+ * @var int
51
+ * @since 2.5.3
52
+ */
53
+ public $link_click_count;
54
+
55
+ /**
56
+ * Total number recovred orders
57
+ *
58
+ * @var int
59
+ * @since 2.5.3
60
+ */
61
+ public $start_date_db;
62
+
63
+ /**
64
+ * Total number recovred orders total
65
+ *
66
+ * @var int
67
+ * @since 2.5.3
68
+ */
69
+ public $end_date_db;
70
+
71
+ public $duration;
72
+
73
+ /**
74
+ * Get things started
75
+ *
76
+ * @see WP_List_Table::__construct()
77
+ */
78
+ public function __construct() {
79
+ global $status, $page;
80
+ // Set parent defaults
81
+ parent::__construct( array(
82
+ 'singular' => __( 'product_id', 'woocommerce-ac' ), //singular name of the listed records
83
+ 'plural' => __( 'product_ids', 'woocommerce-ac' ), //plural name of the listed records
84
+ 'ajax' => false // Does this table support ajax?
85
+ ) );
86
+ $this->base_url = admin_url( 'admin.php?page=woocommerce_ac_page&action=stats' );
87
+ }
88
+
89
+ public function wcal_product_report_prepare_items() {
90
+ $columns = $this->get_columns();
91
+ $hidden = array(); // No hidden columns
92
+ $data = $this->wcal_product_report_data ();
93
+ $total_items = $this->total_count;
94
+ $this->items = $data;
95
+ $this->_column_headers = array( $columns, $hidden);
96
+ $this->set_pagination_args( array(
97
+ 'total_items' => $total_items, // WE have to calculate the total number of items
98
+ 'per_page' => $this->per_page, // WE have to determine how many items to show on a page
99
+ 'total_pages' => ceil( $total_items / $this->per_page ) // WE have to calculate the total number of pages
100
+ )
101
+ );
102
+ }
103
+
104
+ public function get_columns() {
105
+ $columns = array(
106
+ 'product_name' => __( 'Product Name', 'woocommerce-ac' ),
107
+ 'abandoned_number' => __( 'Number of Times Abandoned', 'woocommerce-ac' ),
108
+ 'recover_number' => __( 'Number of Times Recovered', 'woocommerce-ac' )
109
+ );
110
+ return apply_filters( 'wcal_product_report_columns', $columns );
111
+ }
112
+
113
+ /**
114
+ * Render the user name Column
115
+ *
116
+ * @access public
117
+ * @since 2.5.3
118
+ * @param array $abandoned_row_info Contains all the data of the template row
119
+ * @return string Data shown in the Email column
120
+ *
121
+ * This function used for individual delete of row, It is for hover effect delete.
122
+ */
123
+ public function wcal_product_report_data () {
124
+ global $wpdb;
125
+ $wcal_class = new woocommerce_abandon_cart_lite ();
126
+ $per_page = $this->per_page;
127
+ $i = 0;
128
+ $order = "desc";
129
+ $query = "SELECT abandoned_cart_time, abandoned_cart_info, recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` ORDER BY recovered_cart DESC";
130
+ $recover_query = $wpdb->get_results( $query );
131
+ $rec_carts_array = array ( );
132
+ $recover_product_array = array( );
133
+ $return_product_report = array();
134
+
135
+ foreach( $recover_query as $recovered_cart_key => $recovered_cart_value ) {
136
+ $recovered_cart_info = json_decode( $recovered_cart_value->abandoned_cart_info );
137
+ $recovered_cart_dat = json_decode( $recovered_cart_value->recovered_cart);
138
+ $order_date = "";
139
+ $cart_update_time = $recovered_cart_value->abandoned_cart_time;
140
+ $quantity_total = 0;
141
+ $cart_details = array();
142
+ if( isset( $recovered_cart_info->cart ) ){
143
+ $cart_details = $recovered_cart_info->cart;
144
+ }
145
+ if ( count( $cart_details ) > 0) {
146
+ foreach ( $cart_details as $k => $v ) {
147
+ $quantity_total = $quantity_total + $v->quantity;
148
+ }
149
+ }
150
+
151
+ if ( $cart_update_time != "" && $cart_update_time != 0 ) {
152
+ $order_date = date( 'd M, Y h:i A', $cart_update_time );
153
+ }
154
+ $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
155
+ $cut_off_time = $ac_cutoff_time * 60 ;
156
+ $current_time = current_time( 'timestamp' );
157
+ $compare_time = $current_time - $cart_update_time;
158
+ if ( is_array( $recovered_cart_info ) || is_object( $recovered_cart_info ) ) {
159
+ foreach ( $recovered_cart_info as $rec_cart_key => $rec_cart_value ) {
160
+ foreach ( $rec_cart_value as $rec_product_id_key => $rec_product_id_value ) {
161
+ $product_id = $rec_product_id_value->product_id;
162
+ if ( $compare_time > $cut_off_time ) {
163
+ $rec_carts_array [] = $product_id;
164
+ }
165
+ if($recovered_cart_dat != 0) {
166
+ $recover_product_array[] = $product_id;
167
+ }
168
+ }
169
+ }
170
+ }
171
+ }
172
+
173
+ $count = array_count_values( $rec_carts_array );
174
+ $count1 = $count;
175
+ $count_new = $wcal_class->bubble_sort_function ( $count1 ,$order );
176
+ $recover_cart = "0";
177
+ $count_css = 0;
178
+ $chunck_array = array_chunk( $count_new,10, true ); // keep True for retaing the Array Index number which is product ids in our case.
179
+ $chunck_array_value = array();
180
+
181
+ foreach ( $chunck_array as $chunck_array_key => $chunck_array_value ) {
182
+ foreach ( $chunck_array_value as $k => $v ) {
183
+ $return_product_report[$i] = new stdClass();
184
+ $prod_name = get_post( $k );
185
+ if ( NULL != $prod_name || '' != $prod_name ) {
186
+ $product_name = $prod_name->post_title;
187
+ $abandoned_count = $v;
188
+ $recover = array_count_values( $recover_product_array );
189
+ foreach ( $recover as $ke => $ve ) {
190
+ if( array_key_exists ( $ke, $count ) ) {
191
+ if ( $ke == $k ) {
192
+ $recover_cart = $ve;
193
+ }
194
+ }
195
+ if( ! array_key_exists ( $k, $recover ) ) {
196
+ $recover_cart = "0";
197
+ }
198
+ }
199
+
200
+ $return_product_report[ $i ]->product_name = $product_name ;
201
+ $return_product_report[ $i ]->abandoned_number = $abandoned_count;
202
+ $return_product_report[ $i ]->recover_number = $recover_cart;
203
+ $return_product_report[ $i ]->product_id = $k;
204
+ $i++;
205
+ }
206
+ }
207
+ }
208
+ $this->total_count = count ( $return_product_report ) > 0 ? count ( $return_product_report ) : 0 ;
209
+
210
+ // Pagination per page
211
+ if( isset( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
212
+ $page_number = $_GET['paged'] - 1;
213
+ $k = $per_page * $page_number;
214
+ } else {
215
+ $k = 0;
216
+ }
217
+ $return_product_report_display = array();
218
+ for( $j = $k; $j < ( $k+$per_page ); $j++ ) {
219
+ if( isset( $return_product_report[$j] ) ) {
220
+ $return_product_report_display[$j] = $return_product_report[$j];
221
+ } else {
222
+ break;
223
+ }
224
+ }
225
+ return apply_filters( 'wcal_product_report_table_data', $return_product_report_display );
226
+ }
227
+
228
+ public function column_default( $wcal_sent_emails, $column_name ) {
229
+ $value = '';
230
+ switch ( $column_name ) {
231
+
232
+ case 'product_name' :
233
+ if( isset( $wcal_sent_emails->product_name ) ) {
234
+ $value = "<a href= post.php?post=$wcal_sent_emails->product_id&action=edit title = product name > $wcal_sent_emails->product_name </a>";
235
+ }
236
+ break;
237
+
238
+ case 'abandoned_number' :
239
+ if( isset( $wcal_sent_emails->abandoned_number ) ) {
240
+ $value = $wcal_sent_emails->abandoned_number;
241
+ }
242
+ break;
243
+
244
+ case 'recover_number' :
245
+ if( isset( $wcal_sent_emails->recover_number ) ) {
246
+ $value = $wcal_sent_emails->recover_number;
247
+ }
248
+ break;
249
+ default:
250
+
251
+ $value = isset( $wcal_sent_emails->$column_name ) ? $wcal_sent_emails->$column_name : '';
252
+ break;
253
+ }
254
+
255
+ return apply_filters( 'wcal_product_report_column_default', $value, $wcal_sent_emails, $column_name );
256
+ }
257
+ }
258
+ ?>
includes/classes/class-wcal-recover-orders-table.php ADDED
@@ -0,0 +1,371 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Load WP_List_Table if not loaded
4
+ if ( ! class_exists( 'WP_List_Table' ) ) {
5
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
6
+ }
7
+
8
+ class wcal_Recover_Orders_Table extends WP_List_Table {
9
+
10
+ /**
11
+ * Number of results to show per page
12
+ *
13
+ * @var string
14
+ * @since 2.5.2
15
+ */
16
+ public $per_page = 30;
17
+
18
+ /**
19
+ * URL of this page
20
+ *
21
+ * @var string
22
+ * @since 2.5.2
23
+ */
24
+ public $base_url;
25
+
26
+ /**
27
+ * Total number of recovered orders
28
+ *
29
+ * @var int
30
+ * @since 2.5.2
31
+ */
32
+ public $total_count;
33
+
34
+
35
+ /**
36
+ * Total number of abandoned orders
37
+ *
38
+ * @var int
39
+ * @since 2.5.2
40
+ */
41
+ public $total_abandoned_cart_count;
42
+
43
+ /**
44
+ * Total amount of abandoned orders
45
+ *
46
+ * @var int
47
+ * @since 2.5.2
48
+ */
49
+ public $total_order_amount;
50
+
51
+ /**
52
+ * Total number recovered orders
53
+ *
54
+ * @var int
55
+ * @since 2.5.2
56
+ */
57
+ public $recovered_item;
58
+
59
+ /**
60
+ * Total number recovred orders total
61
+ *
62
+ * @var int
63
+ * @since 2.5.2
64
+ */
65
+ public $total_recover_amount;
66
+
67
+ /**
68
+ * Get things started
69
+ *
70
+ * @see WP_List_Table::__construct()
71
+ */
72
+ public function __construct() {
73
+ global $status, $page;
74
+ // Set parent defaults
75
+ parent::__construct( array(
76
+ 'singular' => __( 'rec_abandoned_id', 'woocommerce-ac' ), //singular name of the listed records
77
+ 'plural' => __( 'rec_abandoned_ids', 'woocommerce-ac' ), //plural name of the listed records
78
+ 'ajax' => false // Does this table support ajax?
79
+ ) );
80
+ $this->base_url = admin_url( 'admin.php?page=woocommerce_ac_page&action=stats' );
81
+ }
82
+
83
+ public function wcal_recovered_orders_prepare_items() {
84
+ $columns = $this->get_columns();
85
+ $hidden = array(); // No hidden columns
86
+ $sortable = $this->recovered_orders_get_sortable_columns();
87
+ $data = $this->wcal_recovered_orders_data();
88
+ $total_items = $this->total_count;
89
+ $total_abandoned_cart_count = $this->total_abandoned_cart_count;
90
+ $total_order_amount = $this->total_order_amount;
91
+ $total_recover_amount = $this->total_recover_amount;
92
+ $recovered_item = $this->recovered_item;
93
+ $this->items = $data;
94
+ $this->_column_headers = array( $columns, $hidden, $sortable);
95
+ $this->set_pagination_args( array(
96
+ 'total_items' => $total_items, // WE have to calculate the total number of items
97
+ 'per_page' => $this->per_page, // WE have to determine how many items to show on a page
98
+ 'total_pages' => ceil( $total_items / $this->per_page ) // WE have to calculate the total number of pages
99
+ )
100
+ );
101
+ }
102
+
103
+ public function get_columns() {
104
+ $columns = array(
105
+ 'user_name' => __( 'Customer Name', 'woocommerce-ac' ),
106
+ 'user_email_id' => __( 'Email Address', 'woocommerce-ac' ),
107
+ 'created_on' => __( 'Cart Abandoned Date', 'woocommerce-ac' ),
108
+ 'recovered_date' => __( 'Cart Recovered Date' , 'woocommerce-ac'),
109
+ 'order_total' => __( 'Order Total', 'woocommerce-ac' )
110
+ );
111
+ return apply_filters( 'wcal_recovered_orders_columns', $columns );
112
+ }
113
+
114
+ public function recovered_orders_get_sortable_columns() {
115
+ $columns = array(
116
+ 'created_on' => array( 'created_on', false ),
117
+ 'recovered_date' => array( 'recovered_date',false)
118
+ );
119
+ return apply_filters( 'wcal_templates_sortable_columns', $columns );
120
+ }
121
+
122
+ /**
123
+ * Render the user name Column
124
+ *
125
+ * @access public
126
+ * @since 2.5.2
127
+ * @param array $abandoned_row_info Contains all the data of the template row
128
+ * @return string Data shown in the Email column
129
+ *
130
+ * This function used for individual delete of row, It is for hover effect delete.
131
+ */
132
+ public function column_user_name( $recovered_orders_row_info ) {
133
+ $row_actions = array();
134
+ $value = '';
135
+ $recovered_id = 0;
136
+
137
+ if( isset( $recovered_orders_row_info->user_name ) ) {
138
+ $recovered_id = $recovered_orders_row_info->recovered_id ;
139
+ $row_actions['view_details'] = "<a target=_blank href = post.php?post=$recovered_id&action=edit>". __( 'View Details', 'woocommerce-ac' )."</a>";
140
+ $user_name = $recovered_orders_row_info->user_name;
141
+ $value = $user_name . $this->row_actions( $row_actions );
142
+ }
143
+ return apply_filters( 'wcal_recovered_orders_single_column', $value, $recovered_id, 'email' );
144
+ }
145
+
146
+ public function wcal_recovered_orders_data() {
147
+ global $wpdb;
148
+ $wcal_class = new woocommerce_abandon_cart_lite ();
149
+ $number_decimal = wc_get_price_decimals();
150
+
151
+ if ( isset( $_POST['duration_select'] ) ) {
152
+ $duration_range = $_POST['duration_select'];
153
+ }
154
+ else {
155
+ $duration_range = "";
156
+ }
157
+
158
+ if ( $duration_range == "" ) {
159
+ if ( isset( $_GET['duration_select'] ) ) {
160
+ $duration_range = $_GET['duration_select'];
161
+ }
162
+ }
163
+
164
+ if ( $duration_range == "" ) {
165
+ $duration_range = "last_seven";
166
+ }
167
+ else {
168
+ $duration_range = "";
169
+ }
170
+
171
+ if ( isset( $_POST['start_date'] ) ) {
172
+ $start_date_range = $_POST['start_date'];
173
+ }
174
+ else {
175
+ $start_date_range = "";
176
+ }
177
+
178
+ if ( $start_date_range == "" ) {
179
+ $start_date_range = $wcal_class->start_end_dates[$duration_range]['start_date'];
180
+ }
181
+
182
+ if ( isset( $_POST['end_date'] ) ) $end_date_range = $_POST['end_date'];
183
+ else $end_date_range = "";
184
+
185
+ if ( $end_date_range == "" ) {
186
+ $end_date_range = $wcal_class->start_end_dates[$duration_range]['end_date'];
187
+ }
188
+
189
+ $start_date = strtotime( $start_date_range." 00:01:01" );
190
+ $end_date = strtotime( $end_date_range." 23:59:59" );
191
+
192
+ $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
193
+ $cut_off_time = $ac_cutoff_time * 60;
194
+ $current_time = current_time( 'timestamp' );
195
+ $compare_time = $current_time - $cut_off_time;
196
+
197
+ $query_ac = "SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history_lite
198
+ WHERE abandoned_cart_time >= %d AND abandoned_cart_time <= %d AND recovered_cart > 0 AND abandoned_cart_time <= '$compare_time' ORDER BY recovered_cart desc";
199
+ $ac_results = $wpdb->get_results( $wpdb->prepare( $query_ac, $start_date, $end_date ) );
200
+
201
+ $query_ac_carts = "SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history_lite
202
+ WHERE abandoned_cart_time >= %d AND abandoned_cart_time <= %d AND abandoned_cart_time <= '$compare_time' ";
203
+ $ac_carts_results = $wpdb->get_results( $wpdb->prepare( $query_ac_carts, $start_date, $end_date ) );
204
+
205
+ $recovered_item = $recovered_total = $count_carts = $total_value = $order_total = 0;
206
+ $return_recovered_orders = array();
207
+ $per_page = $this->per_page;
208
+ $i = 0;
209
+
210
+ foreach ( $ac_carts_results as $key => $value ) {
211
+ $count_carts += 1;
212
+ $cart_detail = json_decode( $value->abandoned_cart_info );
213
+ $product_details = array();
214
+ if( isset( $cart_detail->cart ) ) {
215
+ $product_details = $cart_detail->cart;
216
+ }
217
+ $line_total = 0;
218
+
219
+ if ( isset( $product_details ) && count( $product_details ) > 0 && $product_details != false ) {
220
+ foreach ( $product_details as $k => $v ) {
221
+ if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
222
+ $line_total = $line_total + $v->line_total + $v->line_subtotal_tax;
223
+ } else {
224
+ $line_total = $line_total + $v->line_total;
225
+ }
226
+ }
227
+ }
228
+ $total_value += $line_total;
229
+ }
230
+ $total_value = wc_price( $total_value );
231
+ $this->total_order_amount = $total_value ;
232
+ $this->total_abandoned_cart_count = $count_carts ;
233
+ $recovered_order_total = 0;
234
+ $this->total_recover_amount = round( $recovered_order_total, $number_decimal ) ;
235
+ $this->recovered_item = 0;
236
+ $table_data = "";
237
+
238
+ foreach ( $ac_results as $key => $value ) {
239
+ if( $value->recovered_cart != 0 ) {
240
+ $return_recovered_orders[$i] = new stdClass();
241
+
242
+ $recovered_id = $value->recovered_cart;
243
+ $rec_order = get_post_meta( $recovered_id );
244
+ $woo_order = new WC_Order( $recovered_id );
245
+ $recovered_date = strtotime( $woo_order->order_date );
246
+ $recovered_date_new = date( 'd M, Y h:i A', $recovered_date );
247
+ $recovered_item += 1;
248
+
249
+ if ( isset( $rec_order ) && $rec_order != false ) {
250
+ $recovered_total += $rec_order['_order_total'][0];
251
+ }
252
+ $abandoned_date = date( 'd M, Y h:i A', $value->abandoned_cart_time );
253
+ $abandoned_order_id = $value->id;
254
+ $billing_first_name = $billing_last_name = $billing_email = '';
255
+ $recovered_order_total = 0;
256
+
257
+ if ( isset( $rec_order['_billing_first_name'][0] ) ) {
258
+ $billing_first_name = $rec_order['_billing_first_name'][0];
259
+ }
260
+
261
+ if ( isset( $rec_order['_billing_last_name'][0] ) ) {
262
+ $billing_last_name = $rec_order['_billing_last_name'][0];
263
+ }
264
+
265
+ if ( isset( $rec_order['_billing_email'][0] ) ) {
266
+ $billing_email = $rec_order['_billing_email'][0];
267
+ }
268
+
269
+ if ( isset( $rec_order['_order_total'][0] ) ) {
270
+ $recovered_order_total = $rec_order['_order_total'][0];
271
+ }
272
+
273
+ $return_recovered_orders[ $i ]->user_name = $billing_first_name . " " . $billing_last_name ;
274
+ $return_recovered_orders[ $i ]->user_email_id = $billing_email;
275
+ $return_recovered_orders[ $i ]->created_on = $abandoned_date;
276
+ $return_recovered_orders[ $i ]->recovered_date = $recovered_date_new;
277
+ $return_recovered_orders[ $i ]->recovered_id = $recovered_id;
278
+ $return_recovered_orders[ $i ]->recover_order_date = $recovered_date;
279
+ $return_recovered_orders[ $i ]->abandoned_date = $value->abandoned_cart_time;
280
+ $return_recovered_orders[ $i ]->order_total = wc_price($recovered_order_total);
281
+
282
+ $this->recovered_item = $recovered_item;
283
+ $this->total_recover_amount = round( ( $recovered_order_total + $this->total_recover_amount ) , $number_decimal );
284
+ $i++;
285
+ }
286
+ }
287
+ $templates_count = count( $return_recovered_orders );
288
+ $this->total_count = $templates_count;
289
+ // sort for order date
290
+ if( isset( $_GET['orderby'] ) && $_GET['orderby'] == 'created_on' ) {
291
+ if( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
292
+ usort( $return_recovered_orders, array( __CLASS__ , "wcal_class_recovered_created_on_asc" ) );
293
+ } else {
294
+ usort( $return_recovered_orders, array( __CLASS__ , "wcal_class_recovered_created_on_dsc" ) );
295
+ }
296
+ }
297
+ // sort for customer name
298
+ else if ( isset( $_GET['orderby']) && $_GET['orderby'] == 'recovered_date' ) {
299
+ if( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
300
+ usort( $return_recovered_orders, array( __CLASS__ , "wcal_class_recovered_date_asc" ) );
301
+ }else {
302
+ usort( $return_recovered_orders, array( __CLASS__ , "wcal_class_recovered_date_dsc" ) );
303
+ }
304
+ }
305
+ // Pagination per page
306
+ if( isset( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
307
+ $page_number = $_GET['paged'] - 1;
308
+ $k = $per_page * $page_number;
309
+ } else {
310
+ $k = 0;
311
+ }
312
+ $return_recovered_orders_display = array();
313
+ for( $j = $k; $j < ( $k+$per_page ); $j++ ) {
314
+ if( isset( $return_recovered_orders[$j] ) ) {
315
+ $return_recovered_orders_display[$j] = $return_recovered_orders[$j];
316
+ } else {
317
+ break;
318
+ }
319
+ }
320
+ return apply_filters( 'wcal_recovered_orders_table_data', $return_recovered_orders_display );
321
+ }
322
+
323
+ function wcal_class_recovered_created_on_asc( $value1,$value2 ) {
324
+ return $value1->abandoned_date - $value2->abandoned_date;
325
+ }
326
+
327
+ function wcal_class_recovered_created_on_dsc( $value1,$value2 ) {
328
+ return $value2->abandoned_date - $value1->abandoned_date;
329
+ }
330
+
331
+ function wcal_class_recovered_date_asc( $value1,$value2 ) {
332
+ return $value1->recover_order_date - $value2->recover_order_date;
333
+ }
334
+
335
+ function wcal_class_recovered_date_dsc( $value1,$value2 ) {
336
+ return $value2->recover_order_date - $value1->recover_order_date;
337
+ }
338
+
339
+ public function column_default( $wcal_abandoned_orders, $column_name ) {
340
+ $value = '';
341
+ switch ( $column_name ) {
342
+ case 'user_email_id' :
343
+ if( isset( $wcal_abandoned_orders->user_email_id ) ) {
344
+
345
+ $user_email_id = "<a href= mailto:$wcal_abandoned_orders->user_email_id>". $wcal_abandoned_orders->user_email_id."</a>" ;
346
+ $value = $user_email_id;
347
+ }
348
+ break;
349
+ case 'created_on' :
350
+ if( isset( $wcal_abandoned_orders->created_on ) ) {
351
+ $value = $wcal_abandoned_orders->created_on;
352
+ }
353
+ break;
354
+ case 'recovered_date' :
355
+ if( isset( $wcal_abandoned_orders->recovered_date ) ) {
356
+ $value = $wcal_abandoned_orders->recovered_date;
357
+ }
358
+ break;
359
+ case 'order_total' :
360
+ if( isset( $wcal_abandoned_orders->order_total ) ) {
361
+ $value = $wcal_abandoned_orders->order_total;
362
+ }
363
+ break;
364
+ default:
365
+ $value = isset( $wcal_abandoned_orders->$column_name ) ? $wcal_abandoned_orders->$column_name : '';
366
+ break;
367
+ }
368
+ return apply_filters( 'wcal_recovered_orders_column_default', $value, $wcal_abandoned_orders, $column_name );
369
+ }
370
+ }
371
+ ?>
includes/classes/class-wcal-templates-table.php ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Load WP_List_Table if not loaded
4
+ if ( ! class_exists( 'WP_List_Table' ) ) {
5
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
6
+ }
7
+
8
+ class WCAL_Templates_Table extends WP_List_Table {
9
+
10
+ /**
11
+ * Number of results to show per page
12
+ *
13
+ * @var string
14
+ * @since 2.5.2
15
+ */
16
+ public $per_page = 30;
17
+
18
+ /**
19
+ * URL of this page
20
+ *
21
+ * @var string
22
+ * @since 2.5.2
23
+ */
24
+ public $base_url;
25
+
26
+ /**
27
+ * Total number of email templates
28
+ *
29
+ * @var int
30
+ * @since 2.5.3
31
+ */
32
+ public $total_count;
33
+
34
+ /**
35
+ * Get things started
36
+ *
37
+ * @see WP_List_Table::__construct()
38
+ */
39
+ public function __construct() {
40
+ global $status, $page;
41
+ // Set parent defaults
42
+ parent::__construct( array(
43
+ 'singular' => __( 'template_id', 'woocommerce-ac' ), //singular name of the listed records
44
+ 'plural' => __( 'template_ids', 'woocommerce-ac' ), //plural name of the listed records
45
+ 'ajax' => false // Does this table support ajax?
46
+ ) );
47
+ $this->process_bulk_action();
48
+ $this->base_url = admin_url( 'admin.php?page=woocommerce_ac_page&action=emailtemplates' );
49
+ }
50
+
51
+ public function wcal_templates_prepare_items() {
52
+ $columns = $this->get_columns();
53
+ $hidden = array(); // No hidden columns
54
+ $sortable = $this->templates_get_sortable_columns();
55
+ $data = $this->wcal_templates_data();
56
+
57
+ $this->_column_headers = array( $columns, $hidden, $sortable );
58
+ $total_items = $this->total_count;
59
+ $this->items = $data;
60
+
61
+ $this->set_pagination_args( array(
62
+ 'total_items' => $total_items, // WE have to calculate the total number of items
63
+ 'per_page' => $this->per_page, // WE have to determine how many items to show on a page
64
+ 'total_pages' => ceil( $total_items / $this->per_page ) // WE have to calculate the total number of pages
65
+ )
66
+ );
67
+ }
68
+
69
+ public function get_columns() {
70
+ $columns = array(
71
+ 'cb' => '<input type="checkbox" />',
72
+ 'sr' => __( 'Sr', 'woocommerce-ac' ),
73
+ 'template_name' => __( 'Name Of Template', 'woocommerce-ac' ),
74
+ 'sent_time' => __( 'Sent After Set Time', 'woocommerce-ac' ),
75
+ 'activate' => __( 'Active ?', 'woocommerce-ac' )
76
+ );
77
+ return apply_filters( 'wcal_templates_columns', $columns );
78
+ }
79
+ /***
80
+ * It is used to add the check box for the items
81
+ */
82
+ function column_cb( $item ) {
83
+ $template_id = '';
84
+ if( isset( $item->id ) && "" != $item->id ) {
85
+ $template_id = $item->id;
86
+ }
87
+ return sprintf(
88
+ '<input type="checkbox" name="%1$s[]" value="%2$s" />',
89
+ 'template_id',
90
+ $template_id
91
+ );
92
+ }
93
+
94
+ public function templates_get_sortable_columns() {
95
+ $columns = array(
96
+ 'template_name' => array( 'template_name', false ),
97
+ 'sent_time' => array( 'sent_time',false),
98
+ );
99
+ return apply_filters( 'wcal_templates_sortable_columns', $columns );
100
+ }
101
+
102
+ /**
103
+ * Render the Email Column
104
+ *
105
+ * @access public
106
+ * @since 2.5.2
107
+ * @param array $abandoned_row_info Contains all the data of the template row
108
+ * @return string Data shown in the Email column
109
+ *
110
+ * This function used for individual delete of row, It is for hover effect delete.
111
+ */
112
+ public function column_template_name( $template_row_info ) {
113
+ $row_actions = array();
114
+ $value = '';
115
+ $template_id = 0;
116
+ if( isset( $template_row_info->template_name ) ) {
117
+ $template_id = $template_row_info->id ;
118
+
119
+ $row_actions['edit'] = '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'emailtemplates', 'mode'=>'edittemplate', 'id' => $template_row_info->id ), $this->base_url ), 'abandoned_order_nonce') . '">' . __( 'Edit', 'woocommerce-ac' ) . '</a>';
120
+ $row_actions['delete'] = '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'wcal_delete_template', 'template_id' => $template_row_info->id ), $this->base_url ), 'abandoned_order_nonce') . '">' . __( 'Delete', 'woocommerce-ac' ) . '</a>';
121
+
122
+ $email = $template_row_info->template_name;
123
+ $value = $email . $this->row_actions( $row_actions );
124
+ }
125
+ return apply_filters( 'wcal_template_single_column', $value, $template_id, 'email' );
126
+ }
127
+
128
+ public function wcal_templates_data() {
129
+ global $wpdb;
130
+ $return_templates_data = array();
131
+ $per_page = $this->per_page;
132
+ $results = array();
133
+ $query = "SELECT wpet . * FROM `" . $wpdb->prefix . "ac_email_templates_lite` AS wpet ORDER BY day_or_hour desc , frequency asc";
134
+ $results = $wpdb->get_results( $query );
135
+ $i = 0;
136
+
137
+ foreach ( $results as $key => $value ) {
138
+ $return_templates_data[$i] = new stdClass();
139
+ $id = $value->id;
140
+ $query_no_emails = "SELECT * FROM " . $wpdb->prefix . "ac_sent_history_lite WHERE template_id= %d";
141
+ $subject = $value->subject;
142
+ $body = $value->body;
143
+ $is_active = $value->is_active;
144
+
145
+ if ( $is_active == '1' ) {
146
+ $active = "Deactivate";
147
+ } else {
148
+ $active = "Activate";
149
+ }
150
+ $frequency = $value->frequency;
151
+ $day_or_hour = $value->day_or_hour;
152
+ $return_templates_data[ $i ]->sr = $i+1;
153
+ $return_templates_data[ $i ]->id = $id;
154
+ $return_templates_data[ $i ]->template_name = $value->template_name;
155
+ $return_templates_data[ $i ]->sent_time = __( $frequency . " " . $day_or_hour . " After Abandonment", 'woocommerce-ac' );
156
+ $return_templates_data[ $i ]->activate = $active;
157
+ $return_templates_data[ $i ]->is_active = $is_active;
158
+ $i++;
159
+ }
160
+ $templates_count = count( $return_templates_data );
161
+ $this->total_count = $templates_count;
162
+ // sort for order date
163
+ if( isset( $_GET['orderby'] ) && $_GET['orderby'] == 'template_name' ) {
164
+ if( isset($_GET['order'] ) && $_GET['order'] == 'asc' ) {
165
+ usort( $return_templates_data, array( __CLASS__ , "wcal_class_template_name_asc" ) );
166
+ } else {
167
+ usort( $return_templates_data, array( __CLASS__ , "wcal_class_template_name_dsc") );
168
+ }
169
+ }
170
+ // sort for customer name
171
+ else if ( isset( $_GET['orderby']) && $_GET['orderby'] == 'sent_time' ) {
172
+ if ( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
173
+ usort( $return_templates_data, array( __CLASS__ , "wcal_class_sent_time_asc" ) );
174
+ } else {
175
+ usort( $return_templates_data, array( __CLASS__ , "wcal_class_sent_time_dsc" ) );
176
+ }
177
+ }
178
+ // Pagination per page
179
+ if( isset( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
180
+ $page_number = $_GET['paged'] - 1;
181
+ $k = $per_page * $page_number;
182
+ } else {
183
+ $k = 0;
184
+ }
185
+ $return_templates_data_display = array();
186
+ for( $j = $k; $j < ( $k+$per_page ); $j++ ) {
187
+ if( isset( $return_templates_data[$j] ) ) {
188
+ $return_templates_data_display[$j] = $return_templates_data[$j];
189
+ } else {
190
+ break;
191
+ }
192
+ }
193
+
194
+ return apply_filters( 'wcal_templates_table_data', $return_templates_data_display );
195
+ }
196
+
197
+ function wcal_class_template_name_asc( $value1,$value2 ) {
198
+ return strcasecmp( $value1->template_name,$value2->template_name );
199
+ }
200
+
201
+ function wcal_class_template_name_dsc( $value1,$value2 ) {
202
+ return strcasecmp( $value2->template_name,$value1->template_name );
203
+ }
204
+
205
+ function wcal_class_sent_time_asc( $value1,$value2 ) {
206
+ return strnatcasecmp( $value1->sent_time,$value2->sent_time );
207
+ }
208
+
209
+ function wcal_class_sent_time_dsc( $value1,$value2 ) {
210
+ return strnatcasecmp( $value2->sent_time,$value1->sent_time );
211
+ }
212
+
213
+ public function column_default( $wcal_abandoned_orders, $column_name ) {
214
+ $value = '';
215
+ switch ( $column_name ) {
216
+ case 'sr' :
217
+ if( isset( $wcal_abandoned_orders->sr ) ) {
218
+ $value = $wcal_abandoned_orders->sr;
219
+ }
220
+ break;
221
+ case 'template_name' :
222
+ if( isset( $wcal_abandoned_orders->template_name ) ) {
223
+ $value = $wcal_abandoned_orders->template_name;
224
+ }
225
+ break;
226
+ case 'sent_time' :
227
+ if( isset( $wcal_abandoned_orders->sent_time ) ) {
228
+ $value = $wcal_abandoned_orders->sent_time;
229
+ }
230
+ break;
231
+ case 'activate' :
232
+ if( isset( $wcal_abandoned_orders->activate ) ) {
233
+ $active = $wcal_abandoned_orders->activate;
234
+ $id = $wcal_abandoned_orders->id;
235
+ $is_active = $wcal_abandoned_orders->is_active;
236
+ $active = '';
237
+ if ( $is_active == '1' ) {
238
+ $active = "Deactivate";
239
+ } else {
240
+ $active = "Activate";
241
+ }
242
+ $active_text = __( $active, 'woocommerce-ac' );
243
+ $value = '<a href="#" onclick="wcal_activate_email_template('. $id.', '.$is_active.' )"> '.$active_text.'</a>';
244
+ }
245
+ break;
246
+ default:
247
+ $value = isset( $wcal_abandoned_orders->$column_name ) ? $wcal_abandoned_orders->$column_name : '';
248
+ break;
249
+ }
250
+ return apply_filters( 'wcal_template_column_default', $value, $wcal_abandoned_orders, $column_name );
251
+ }
252
+
253
+ public function get_bulk_actions() {
254
+ return array(
255
+ 'wcal_delete_template' => __( 'Delete', 'woocommerce-ac' )
256
+ );
257
+ }
258
+ }
259
+ ?>
includes/wcal-common.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class wcal_common {
4
+ public static function wcal_get_abandoned_order_count( $get_section_result ){
5
+ global $wpdb;
6
+ $return_abandoned_count = 0;
7
+ $blank_cart_info = '{"cart":[]}';
8
+ $blank_cart_info_guest = '[]';
9
+ $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
10
+ $cut_off_time = $ac_cutoff_time * 60;
11
+ $current_time = current_time( 'timestamp' );
12
+ $compare_time = $current_time - $cut_off_time;
13
+
14
+ switch ( $get_section_result ) {
15
+ case 'wcal_all_abandoned':
16
+ $query_ac = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE ( user_type = 'REGISTERED' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 ) OR ( user_type = 'GUEST' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 ) ORDER BY recovered_cart desc ";
17
+ $ac_results = $wpdb->get_results( $query_ac );
18
+ $return_abandoned_count = count( $ac_results );
19
+ break;
20
+
21
+ case 'wcal_all_registered':
22
+ $query_ac = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE ( user_type = 'REGISTERED' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 ) ORDER BY recovered_cart desc ";
23
+ $ac_results = $wpdb->get_results( $query_ac );
24
+ $return_abandoned_count = count( $ac_results );
25
+ break;
26
+
27
+ case 'wcal_all_guest':
28
+ $query_ac = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE ( user_type = 'GUEST' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 AND user_id >= 63000000 ) ORDER BY recovered_cart desc ";
29
+ $ac_results = $wpdb->get_results( $query_ac );
30
+ $return_abandoned_count = count( $ac_results );
31
+ break;
32
+
33
+ case 'wcal_all_visitor':
34
+ $query_ac = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE ( user_type = 'GUEST' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 AND user_id = 0 ) ORDER BY recovered_cart desc ";
35
+ $ac_results = $wpdb->get_results( $query_ac );
36
+ $return_abandoned_count = count( $ac_results );
37
+ break;
38
+
39
+ default:
40
+ # code...
41
+ break;
42
+ }
43
+ return $return_abandoned_count;
44
+ }
45
+ }
46
+ ?>
actions.php → includes/wcal_actions.php RENAMED
@@ -1,46 +1,46 @@
1
  <?php
2
-
3
  // Exit if accessed directly
4
- if ( ! defined( 'ABSPATH' ) ) exit;
 
 
5
 
6
  /**
7
- * Trigger a abadoned cart Deletion
8
  *
9
  * @since 2.5.2
10
- * @param $abadoned_cart_id Arguments passed
11
  * @return void
12
  */
13
 
14
- class wcap_delete_bulk_action_handler{
15
 
16
- function wcap_delete_bulk_action_handler_function_lite( $abadoned_cart_id ) {
17
  global $wpdb;
18
-
19
- $get_user_id = "SELECT user_id FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE id = '$abadoned_cart_id' ";
20
  $results_get_user_id = $wpdb->get_results( $get_user_id );
21
  $user_id_of_guest = $results_get_user_id[0]->user_id;
22
 
23
- $query_delete = "DELETE FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE id = '$abadoned_cart_id' ";
 
24
  $results_delete = $wpdb->get_results( $query_delete );
25
-
26
-
27
  if ( $user_id_of_guest >= '63000000' ) {
28
- $guest_query_delete = "DELETE FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE id = '" . $user_id_of_guest . "'";
 
29
  $results_guest = $wpdb->get_results( $guest_query_delete );
30
  //guest user
31
  }
32
-
33
- wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&wcap_deleted=YES' ) );
34
-
35
  }
36
- function wcap_delete_template_bulk_action_handler_function_lite( $template_id ) {
37
  global $wpdb;
38
-
39
  $id_remove = $template_id;
40
- $query_remove = "DELETE FROM `" . $wpdb->prefix . "ac_email_templates_lite` WHERE id='" . $id_remove . "' ";
 
41
  $wpdb->query( $query_remove );
42
 
43
- wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&action=emailtemplates&wcap_template_deleted=YES' ) );
44
 
45
  }
46
  }
1
  <?php
 
2
  // Exit if accessed directly
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
 
7
  /**
8
+ * Trigger a abandoned cart Deletion
9
  *
10
  * @since 2.5.2
11
+ * @param $abandoned_cart_id Arguments passed
12
  * @return void
13
  */
14
 
15
+ class wcal_delete_bulk_action_handler {
16
 
17
+ function wcal_delete_bulk_action_handler_function( $abandoned_cart_id ) {
18
  global $wpdb;
19
+ $get_user_id = "SELECT user_id FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
20
+ WHERE id = '$abandoned_cart_id' ";
21
  $results_get_user_id = $wpdb->get_results( $get_user_id );
22
  $user_id_of_guest = $results_get_user_id[0]->user_id;
23
 
24
+ $query_delete = "DELETE FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
25
+ WHERE id = '$abandoned_cart_id' ";
26
  $results_delete = $wpdb->get_results( $query_delete );
27
+
 
28
  if ( $user_id_of_guest >= '63000000' ) {
29
+ $guest_query_delete = "DELETE FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
30
+ WHERE id = '" . $user_id_of_guest . "'";
31
  $results_guest = $wpdb->get_results( $guest_query_delete );
32
  //guest user
33
  }
34
+ wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&wcal_deleted=YES' ) );
 
 
35
  }
36
+ function wcal_delete_template_bulk_action_handler_function( $template_id ) {
37
  global $wpdb;
 
38
  $id_remove = $template_id;
39
+ $query_remove = "DELETE FROM `" . $wpdb->prefix . "ac_email_templates_lite`
40
+ WHERE id='" . $id_remove . "' ";
41
  $wpdb->query( $query_remove );
42
 
43
+ wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&action=emailtemplates&wcal_template_deleted=YES' ) );
44
 
45
  }
46
  }
includes/wcal_class-guest.php ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Woocommerce Abandoned Cart Lite Plugin - Saves guest cart information
4
+ */
5
+ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
6
+
7
+ class woocommerce_guest_ac {
8
+ var $a;
9
+ public function __construct() {
10
+ add_action( 'woocommerce_after_checkout_billing_form', 'user_side_js' );
11
+ add_action( 'init','load_ac_ajax' );
12
+ add_filter( 'woocommerce_checkout_fields', 'guest_checkout_fields' );
13
+ }
14
+ }
15
+ /*-----------------------------------------------------------------------------------*/
16
+ /* Class Functions */
17
+ /*-----------------------------------------------------------------------------------*/
18
+ function load_ac_ajax() {
19
+ if ( ! is_user_logged_in() ) {
20
+ add_action( 'wp_ajax_nopriv_save_data', 'save_data' );
21
+ } else {
22
+ add_action( 'wp_ajax_save_data', 'save_data' );
23
+ }
24
+ }
25
+
26
+ function user_side_js() {
27
+ ?>
28
+ <script type="text/javascript">
29
+ jQuery( 'input#billing_email' ).on( 'change', function() {
30
+ var data = {
31
+ billing_first_name : jQuery('#billing_first_name').val(),
32
+ billing_last_name : jQuery('#billing_last_name').val(),
33
+ billing_company : jQuery('#billing_company').val(),
34
+ billing_address_1 : jQuery('#billing_address_1').val(),
35
+ billing_address_2 : jQuery('#billing_address_2').val(),
36
+ billing_city : jQuery('#billing_city').val(),
37
+ billing_state : jQuery('#billing_state').val(),
38
+ billing_postcode : jQuery('#billing_postcode').val(),
39
+ billing_country : jQuery('#billing_country').val(),
40
+ billing_phone : jQuery('#billing_phone').val(),
41
+ billing_email : jQuery('#billing_email').val(),
42
+ order_notes : jQuery('#order_comments').val(),
43
+ shipping_first_name : jQuery('#shipping_first_name').val(),
44
+ shipping_last_name : jQuery('#shipping_last_name').val(),
45
+ shipping_company : jQuery('#shipping_company').val(),
46
+ shipping_address_1 : jQuery('#shipping_address_1').val(),
47
+ shipping_address_2 : jQuery('#shipping_address_2').val(),
48
+ shipping_city : jQuery('#shipping_city').val(),
49
+ shipping_state : jQuery('#shipping_state').val(),
50
+ shipping_postcode : jQuery('#shipping_postcode').val(),
51
+ shipping_country : jQuery('#shipping_country').val(),
52
+ ship_to_billing : jQuery('#shiptobilling-checkbox').val(),
53
+ action: 'save_data'
54
+ };
55
+ jQuery.post( "<?php echo get_admin_url();?>admin-ajax.php", data, function(response) {
56
+ });
57
+ });
58
+ </script>
59
+ <?php
60
+ }
61
+
62
+ function save_data() {
63
+ if ( ! is_user_logged_in() ) {
64
+ if( session_id() === '' ) {
65
+ //session has not started
66
+ session_start();
67
+ }
68
+ global $wpdb, $woocommerce;
69
+ if ( isset($_POST['billing_first_name']) && $_POST['billing_first_name'] != '' ){
70
+ $_SESSION['billing_first_name'] = $_POST['billing_first_name'];
71
+ }
72
+ if ( isset($_POST['billing_last_name']) && $_POST['billing_last_name'] != '' ) {
73
+ $_SESSION['billing_last_name'] = $_POST['billing_last_name'];
74
+ }
75
+ if ( isset($_POST['billing_company']) && $_POST['billing_company'] != '' ) {
76
+ $_SESSION['billing_company'] = $_POST['billing_company'];
77
+ }
78
+ if ( isset($_POST['billing_address_1']) && $_POST['billing_address_1'] != '' ) {
79
+ $_SESSION['billing_address_1'] = $_POST['billing_address_1'];
80
+ }
81
+ if ( isset($_POST['billing_address_2']) && $_POST['billing_address_2'] != '' ) {
82
+ $_SESSION['billing_address_2'] = $_POST['billing_address_2'];
83
+ }
84
+ if ( isset($_POST['billing_city']) && $_POST['billing_city'] != '' ) {
85
+ $_SESSION['billing_city'] = $_POST['billing_city'];
86
+ }
87
+ if ( isset($_POST['billing_state']) && $_POST['billing_state'] != '' ) {
88
+ $_SESSION['billing_state'] = $_POST['billing_state'];
89
+ }
90
+ if ( isset($_POST['billing_postcode']) && $_POST['billing_postcode'] != '' ) {
91
+ $_SESSION['billing_postcode'] = $_POST['billing_postcode'];
92
+ }
93
+ if ( isset($_POST['billing_country']) && $_POST['billing_country'] != '' ) {
94
+ $_SESSION['billing_country'] = $_POST['billing_country'];
95
+ }
96
+ if ( isset($_POST['billing_email']) && $_POST['billing_email'] != '' ) {
97
+ $_SESSION['billing_email'] = $_POST['billing_email'];
98
+ }
99
+ if ( isset($_POST['billing_phone']) && $_POST['billing_phone'] != '' ) {
100
+ $_SESSION['billing_phone'] = $_POST['billing_phone'];
101
+ }
102
+ if ( isset($_POST['order_notes']) && $_POST['order_notes'] != '' ) {
103
+ $_SESSION['order_notes'] = $_POST['order_notes'];
104
+ }
105
+ if( isset( $_POST['ship_to_billing'] ) && $_POST['ship_to_billing'] != '' ) {
106
+ $_SESSION['ship_to_billing'] = $_POST['ship_to_billing'];
107
+ }
108
+ if ( isset($_POST['shipping_first_name']) && $_POST['shipping_first_name'] != '' ) {
109
+ $_SESSION['shipping_first_name'] = $_POST['shipping_first_name'];
110
+ }
111
+ if ( isset($_POST['shipping_last_name']) && $_POST['shipping_last_name'] != '' ) {
112
+ $_SESSION['shipping_last_name'] = $_POST['shipping_last_name'];
113
+ }
114
+ if ( isset($_POST['shipping_company']) && $_POST['shipping_company'] != '' ) {
115
+ $_SESSION['shipping_company'] = $_POST['shipping_company'];
116
+ }
117
+ if ( isset($_POST['shipping_address_1']) && $_POST['shipping_address_1'] != '' ) {
118
+ $_SESSION['shipping_address_1'] = $_POST['shipping_address_1'];
119
+ }
120
+ if ( isset($_POST['shipping_address_2']) && $_POST['shipping_address_2'] != '' ) {
121
+ $_SESSION['shipping_address_2'] = $_POST['shipping_address_2'];
122
+ }
123
+ if ( isset($_POST['shipping_city']) && $_POST['shipping_city'] != '' ) {
124
+ $_SESSION['shipping_city'] = $_POST['shipping_city'];
125
+ }
126
+ if ( isset($_POST['shipping_state']) && $_POST['shipping_state'] != '' ) {
127
+ $_SESSION['shipping_state'] = $_POST['shipping_state'];
128
+ }
129
+ if ( isset($_POST['shipping_postcode']) && $_POST['shipping_postcode'] != '' ) {
130
+ $_SESSION['shipping_postcode'] = $_POST['shipping_postcode'];
131
+ }
132
+ if ( isset($_POST['shipping_country']) && $_POST['shipping_country'] != '' ) {
133
+ $_SESSION['shipping_country'] = $_POST['shipping_country'];
134
+ }
135
+ // If a record is present in the guest cart history table for the same email id, then delete the previous records
136
+ $query_guest = "SELECT id FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite`
137
+ WHERE email_id = %s";
138
+ $results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $_SESSION['billing_email'] ) );
139
+
140
+ if ( $results_guest ) {
141
+ foreach ( $results_guest as $key => $value ) {
142
+ $query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
143
+ WHERE user_id = %d AND recovered_cart = '0'" ;
144
+ $result = $wpdb->get_results( $wpdb->prepare( $query, $value->id ) );
145
+
146
+ if ( $result ) {
147
+ $delete_sent_email = "DELETE FROM `".$wpdb->prefix."ac_sent_history_lite`
148
+ WHERE abandoned_order_id = '".$result[0]->id."'";
149
+ $wpdb->query( $delete_sent_email );
150
+ $delete_query = "DELETE FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
151
+ WHERE user_id = '".$value->id."'";
152
+ $wpdb->query( $delete_query );
153
+ }
154
+ $guest_delete = "DELETE FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite`
155
+ WHERE id = '".$value->id."'";
156
+ $wpdb->query( $guest_delete );
157
+ }
158
+ }
159
+ // Insert record in guest table
160
+ if ( isset( $_SESSION['billing_first_name'] ) ) {
161
+ $billing_first_name = $_SESSION['billing_first_name'];
162
+ } else {
163
+ $billing_first_name = '';
164
+ }
165
+ if ( isset( $_SESSION['billing_last_name'] ) ) {
166
+ $billing_last_name = $_SESSION['billing_last_name'];
167
+ } else {
168
+ $billing_last_name = '';
169
+ }
170
+ $shipping_zipcode = $billing_zipcode = '';
171
+
172
+ if ( isset( $_SESSION['shipping_postcode'] ) && $_SESSION['shipping_postcode'] != "" ) {
173
+ $shipping_zipcode = $_SESSION['shipping_postcode'];
174
+ } elseif( isset( $_SESSION['billing_postcode'] ) && $_SESSION['billing_postcode'] != "" ) {
175
+ $shipping_zipcode = $billing_zipcode = $_SESSION['billing_postcode'];
176
+ }
177
+ $shipping_charges = $woocommerce->cart->shipping_total;
178
+ $insert_guest = "INSERT INTO `".$wpdb->prefix . "ac_guest_abandoned_cart_history_lite`( billing_first_name, billing_last_name, email_id, billing_zipcode, shipping_zipcode, shipping_charges )
179
+ VALUES ( '".$billing_first_name."', '".$billing_last_name."', '".$_SESSION['billing_email']."', '".$billing_zipcode."', '".$shipping_zipcode."', '".$shipping_charges."' )";
180
+ $wpdb->query( $insert_guest );
181
+
182
+ //Insert record in abandoned cart table for the guest user
183
+ $user_id = $wpdb->insert_id;
184
+ $_SESSION['user_id'] = $user_id;
185
+ $current_time = current_time( 'timestamp' );
186
+ $cut_off_time = get_option( 'ac_cart_abandoned_time' );
187
+ $cart_cut_off_time = $cut_off_time * 60;
188
+ $compare_time = $current_time - $cart_cut_off_time;
189
+
190
+ $query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
191
+ WHERE user_id = %d AND cart_ignored = '0' AND recovered_cart = '0' AND user_type = 'GUEST'";
192
+ $results = $wpdb->get_results( $wpdb->prepare( $query, $user_id ) );
193
+
194
+ $cart = array();
195
+
196
+ if ( function_exists('WC') ) {
197
+ $cart['cart'] = WC()->session->cart;
198
+ } else {
199
+ $cart['cart'] = $woocommerce->session->cart;
200
+ }
201
+
202
+ if ( count( $results ) == 0 ) {
203
+ $get_cookie = WC()->session->get_session_cookie();
204
+ $cart_info = addslashes( json_encode( $cart ) );
205
+
206
+ $query = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
207
+ WHERE session_id LIKE %s AND cart_ignored = '0' AND recovered_cart = '0' ";
208
+ $results = $wpdb->get_results( $wpdb->prepare( $query, $get_cookie[0] ) );
209
+
210
+ if ( count( $results ) == 0 ) {
211
+ $insert_query = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`( user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, recovered_cart, user_type )
212
+ VALUES ( '".$user_id."', '".$cart_info."', '".$current_time."', '0', '0', 'GUEST' )";
213
+ $wpdb->query( $insert_query );
214
+
215
+ $abandoned_cart_id = $wpdb->insert_id;
216
+ $_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
217
+
218
+ $insert_persistent_cart = "INSERT INTO `".$wpdb->prefix."usermeta`( user_id, meta_key, meta_value )
219
+ VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
220
+ $wpdb->query( $insert_persistent_cart );
221
+ } else {
222
+ $query_update = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET user_id = '" . $user_id . "', abandoned_cart_info = '" . $cart_info . "', abandoned_cart_time = '" . $current_time . "' WHERE session_id ='" . $get_cookie[0] . "' AND cart_ignored='0' ";
223
+ $wpdb->query( $query_update );
224
+ $query_update_get = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
225
+ WHERE user_id ='" . $user_id . "' AND cart_ignored='0' AND session_id ='" . $get_cookie[0] . "' ";
226
+ $get_abandoned_record = $wpdb->get_results( $query_update_get );
227
+
228
+ $abandoned_cart_id = $get_abandoned_record[0]->id;
229
+ $_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
230
+
231
+ $insert_persistent_cart = "INSERT INTO `".$wpdb->prefix."usermeta`( user_id, meta_key, meta_value )
232
+ VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
233
+ $wpdb->query( $insert_persistent_cart );
234
+ }
235
+ }
236
+ }
237
+ }
238
+
239
+ function guest_checkout_fields( $fields ) {
240
+ if ( isset( $_SESSION['guest_first_name'] ) && $_SESSION['guest_first_name'] != "" ) {
241
+ $_POST['billing_first_name'] = $_SESSION['guest_first_name'];
242
+ }
243
+ if ( isset( $_SESSION['guest_last_name'] ) && $_SESSION['guest_last_name'] != "" ) {
244
+ $_POST['billing_last_name'] = $_SESSION['guest_last_name'];
245
+ }
246
+ if ( isset( $_SESSION['guest_email']) && $_SESSION['guest_email'] != "" ) {
247
+ $_POST['billing_email'] = $_SESSION['guest_email'];
248
+ }
249
+ if ( isset( $_SESSION['guest_phone']) && $_SESSION['guest_phone'] != "" ) {
250
+ $_POST['billing_phone'] = $_SESSION['guest_phone'];
251
+ }
252
+ return $fields;
253
+ }
254
+ }
255
+ $woocommerce_guest_ac = new woocommerce_guest_ac();
256
+ ?>
default-settings.php → includes/wcal_default-settings.php RENAMED
@@ -1,12 +1,11 @@
1
  <?php
2
- class default_template_settings {
3
  /* This function will load default template while activating the plugin.
4
  *
5
  * @since: AFter 2.5 version
6
  */
7
- function create_default_templates() {
8
  global $wpdb;
9
-
10
  $template_name_array = 'Initial';
11
  $site_title = get_bloginfo( 'name' );
12
  $site_url = get_option( 'siteurl' );
@@ -14,8 +13,8 @@ class default_template_settings {
14
  $active_post_array = 0;
15
  $email_frequency_array = 1;
16
  $day_or_hour_array = 'Hours';
17
- $body_content_array = addslashes("<html>
18
- <body>
19
  <p> Hello {{customer.fullname}}, </p>
20
  <p> &nbsp; </p>
21
  <p> We\'re following up with you, because we noticed that on {{cart.abandoned_date}} you attempted to purchase the following products on $site_title. </p>
@@ -26,31 +25,24 @@ class default_template_settings {
26
  <p> &nbsp; </p>
27
  <p> Otherwise, how about giving us another chance? Shop <a href= $site_url >$site_title</a>. </p>
28
  <hr></hr>
 
 
29
  <p> <a href=$site_url>$site_title</a> appreciates your business. </p>
30
  </body>
31
- </html>");
32
-
33
- $ac_from_name = 'Admin';
34
- $is_wc_template = 1 ;
35
- $default_template = 1;
36
- $from_email = get_option( 'admin_email' );
37
- $ac_email_reply = get_option( 'admin_email' );
38
 
39
- $query = "INSERT INTO `" . $wpdb->prefix . "ac_email_templates_lite`
40
- ( subject, body, is_active, frequency, day_or_hour, template_name, from_name, is_wc_template, default_template, reply_email, from_email )
41
  VALUES ( '" . $template_subject_array . "',
42
  '" . $body_content_array . "',
43
  '" . $active_post_array . "',
44
  '" . $email_frequency_array . "',
45
  '" . $day_or_hour_array . "',
46
  '" . $template_name_array . "',
47
- '" . $ac_from_name . "',
48
  '" . $is_wc_template . "',
49
- '" . $default_template . "',
50
- '" . $ac_email_reply . "',
51
- '" . $from_email . "' )";
52
-
53
- $wpdb->query( $query );
54
-
55
  }
56
  }
1
  <?php
2
+ class wcal_default_template_settings {
3
  /* This function will load default template while activating the plugin.
4
  *
5
  * @since: AFter 2.5 version
6
  */
7
+ function wcal_create_default_templates() {
8
  global $wpdb;
 
9
  $template_name_array = 'Initial';
10
  $site_title = get_bloginfo( 'name' );
11
  $site_url = get_option( 'siteurl' );
13
  $active_post_array = 0;
14
  $email_frequency_array = 1;
15
  $day_or_hour_array = 'Hours';
16
+ $body_content_array = addslashes( "<html>
17
+ <body>
18
  <p> Hello {{customer.fullname}}, </p>
19
  <p> &nbsp; </p>
20
  <p> We\'re following up with you, because we noticed that on {{cart.abandoned_date}} you attempted to purchase the following products on $site_title. </p>
25
  <p> &nbsp; </p>
26
  <p> Otherwise, how about giving us another chance? Shop <a href= $site_url >$site_title</a>. </p>
27
  <hr></hr>
28
+ <p> You may <a href='{{cart.unsubscribe}}'>unsubscribe</a> to stop receiving these emails. </p>
29
+ <p> &nbsp; </p>
30
  <p> <a href=$site_url>$site_title</a> appreciates your business. </p>
31
  </body>
32
+ </html>" );
33
+ $is_wc_template = 1 ;
34
+ $default_template = 1;
 
 
 
 
35
 
36
+ $query = "INSERT INTO `" . $wpdb->prefix . "ac_email_templates_lite`
37
+ ( subject, body, is_active, frequency, day_or_hour, template_name, is_wc_template, default_template )
38
  VALUES ( '" . $template_subject_array . "',
39
  '" . $body_content_array . "',
40
  '" . $active_post_array . "',
41
  '" . $email_frequency_array . "',
42
  '" . $day_or_hour_array . "',
43
  '" . $template_name_array . "',
 
44
  '" . $is_wc_template . "',
45
+ '" . $default_template . "' )";
46
+ $wpdb->query( $query );
 
 
 
 
47
  }
48
  }
languages/woocommerce-ac.po DELETED
@@ -1,269 +0,0 @@
1
- # SOME DESCRIPTIVE TITLE.
2
- # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
- # This file is distributed under the same license as the PACKAGE package.
4
- # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
- #
6
- msgid ""
7
- msgstr ""
8
- "Project-Id-Version: woocommerce-ac\n"
9
- "Report-Msgid-Bugs-To: \n"
10
- "POT-Creation-Date: 2015-07-08 16:30+0530\n"
11
- "PO-Revision-Date: 2015-07-16 11:02+0530\n"
12
- "Last-Translator: \n"
13
- "Language-Team: \n"
14
- "MIME-Version: 1.0\n"
15
- "Content-Type: text/plain; charset=UTF-8\n"
16
- "Content-Transfer-Encoding: 8bit\n"
17
- "X-Generator: Poedit 1.5.7\n"
18
- "X-Poedit-KeywordsList: __;_e\n"
19
- "X-Poedit-Basepath: .\n"
20
-
21
- #: woocommerce-ac.php:22
22
- msgid "Once Every Five Minutes"
23
- msgstr ""
24
-
25
- #: woocommerce-ac.php:204
26
- #, php-format
27
- msgid ""
28
- "You can upgrade to the <a href=\"https://www.tychesoftwares.com/store/"
29
- "premium-plugins/woocommerce-abandoned-cart-pro/\">PRO version of WooCommerce "
30
- "Abandoned Cart plugin</a> at a <b>20% discount</b>. Use the coupon code: "
31
- "<b>ACPRO20</b>.<a href=\"https://www.tychesoftwares.com/store/premium-"
32
- "plugins/woocommerce-abandoned-cart-pro/\"> Purchase now </a> & save $24!"
33
- msgstr ""
34
-
35
- #: woocommerce-ac.php:314
36
- msgid "Abandoned Carts"
37
- msgstr ""
38
-
39
- #: woocommerce-ac.php:516
40
- msgid "Abandoned Orders"
41
- msgstr ""
42
-
43
- #: woocommerce-ac.php:517
44
- msgid "Email Templates"
45
- msgstr ""
46
-
47
- #: woocommerce-ac.php:518 woocommerce-ac.php:712
48
- msgid "Settings"
49
- msgstr ""
50
-
51
- #: woocommerce-ac.php:519
52
- msgid "Recovered Orders"
53
- msgstr ""
54
-
55
- #: woocommerce-ac.php:661
56
- msgid "You do not have sufficient permissions to access this page."
57
- msgstr ""
58
-
59
- #: woocommerce-ac.php:670
60
- msgid "WooCommerce - Abandon Cart Lite"
61
- msgstr ""
62
-
63
- #: woocommerce-ac.php:696
64
- msgid "Your settings have been saved."
65
- msgstr ""
66
-
67
- #: woocommerce-ac.php:718
68
- msgid "Cart abandoned cut-off time"
69
- msgstr ""
70
-
71
- #: woocommerce-ac.php:741
72
- msgid "minutes"
73
- msgstr ""
74
-
75
- #: woocommerce-ac.php:742 woocommerce-ac.php:743
76
- msgid ""
77
- "Consider cart abandoned after X minutes of item being added to cart & order "
78
- "not placed"
79
- msgstr ""
80
-
81
- #: woocommerce-ac.php:753
82
- msgid "Save Changes"
83
- msgstr ""
84
-
85
- #: woocommerce-ac.php:763
86
- msgid ""
87
- "The list below shows all Abandoned Carts which have remained in cart for a "
88
- "time higher than the \"Cart abandoned cut-off time\" setting."
89
- msgstr ""
90
-
91
- #: woocommerce-ac.php:858 woocommerce-ac.php:1501
92
- msgid "Customer"
93
- msgstr ""
94
-
95
- #: woocommerce-ac.php:859 woocommerce-ac.php:1514
96
- msgid "Order Total"
97
- msgstr ""
98
-
99
- #: woocommerce-ac.php:862
100
- msgid "Date"
101
- msgstr ""
102
-
103
- #: woocommerce-ac.php:868
104
- msgid "Status"
105
- msgstr ""
106
-
107
- #: woocommerce-ac.php:872 woocommerce-ac.php:1159
108
- msgid "Actions"
109
- msgstr ""
110
-
111
- #: woocommerce-ac.php:953
112
- msgid ""
113
- "Add email templates at different intervals to maximize the possibility of "
114
- "recovering your abandoned carts."
115
- msgstr ""
116
-
117
- #: woocommerce-ac.php:1054
118
- msgid "The Email Template has been successfully added."
119
- msgstr ""
120
-
121
- #: woocommerce-ac.php:1057
122
- msgid "The Email Template has been successfully updated."
123
- msgstr ""
124
-
125
- #: woocommerce-ac.php:1145
126
- msgid "Sr"
127
- msgstr ""
128
-
129
- #: woocommerce-ac.php:1148
130
- msgid "Template Name"
131
- msgstr ""
132
-
133
- #: woocommerce-ac.php:1154
134
- msgid "Sent"
135
- msgstr ""
136
-
137
- #: woocommerce-ac.php:1158
138
- msgid "Active ?"
139
- msgstr ""
140
-
141
- #: woocommerce-ac.php:1276
142
- msgid ""
143
- "The Report below shows how many Abandoned Carts we were able to recover for "
144
- "you by sending automatic emails to encourage shoppers."
145
- msgstr ""
146
-
147
- #: woocommerce-ac.php:1331
148
- msgid "Start Date:"
149
- msgstr ""
150
-
151
- #: woocommerce-ac.php:1334
152
- msgid "End Date:"
153
- msgstr ""
154
-
155
- #: woocommerce-ac.php:1337
156
- msgid "Go"
157
- msgstr ""
158
-
159
- #: woocommerce-ac.php:1495
160
- msgid "During the selected range"
161
- msgstr ""
162
-
163
- #: woocommerce-ac.php:1495
164
- msgid "carts totaling"
165
- msgstr ""
166
-
167
- #: woocommerce-ac.php:1495
168
- msgid "were abandoned. We were able to recover"
169
- msgstr ""
170
-
171
- #: woocommerce-ac.php:1495
172
- msgid "of them, which led to an extra"
173
- msgstr ""
174
-
175
- #: woocommerce-ac.php:1495
176
- msgid "in sales"
177
- msgstr ""
178
-
179
- #: woocommerce-ac.php:1504
180
- msgid "Created On"
181
- msgstr ""
182
-
183
- #: woocommerce-ac.php:1510
184
- msgid "Recovered Date"
185
- msgstr ""
186
-
187
- #: woocommerce-ac.php:1561
188
- msgid "Template Name:"
189
- msgstr ""
190
-
191
- #: woocommerce-ac.php:1572
192
- msgid "Enter a template name for reference"
193
- msgstr ""
194
-
195
- #: woocommerce-ac.php:1577
196
- msgid "Send From This Name:"
197
- msgstr ""
198
-
199
- #: woocommerce-ac.php:1588
200
- msgid "Enter the name that should appear in the email sent"
201
- msgstr ""
202
-
203
- #: woocommerce-ac.php:1594
204
- msgid "Subject:"
205
- msgstr ""
206
-
207
- #: woocommerce-ac.php:1605
208
- msgid "Enter the subject that should appear in the email sent"
209
- msgstr ""
210
-
211
- #: woocommerce-ac.php:1611
212
- msgid "Email Body:"
213
- msgstr ""
214
-
215
- #: woocommerce-ac.php:1627
216
- msgid "Message to be sent in the reminder email."
217
- msgstr ""
218
-
219
- #: woocommerce-ac.php:1634
220
- msgid "Send this email:"
221
- msgstr ""
222
-
223
- #: woocommerce-ac.php:1686
224
- msgid "after cart is abandoned."
225
- msgstr ""
226
-
227
- #: woocommerce-ac.php:1693
228
- msgid "Send a test email to:"
229
- msgstr ""
230
-
231
- #: woocommerce-ac.php:1699
232
- msgid "Enter the email id to which the test email needs to be sent."
233
- msgstr ""
234
-
235
- #: woocommerce-ac.php:1835 send_email.php:109
236
- msgid "Your Shopping Cart"
237
- msgstr ""
238
-
239
- #: woocommerce-ac.php:1838 send_email.php:112
240
- msgid "Item"
241
- msgstr ""
242
-
243
- #: woocommerce-ac.php:1839 send_email.php:113
244
- msgid "Name"
245
- msgstr ""
246
-
247
- #: woocommerce-ac.php:1840 send_email.php:114
248
- msgid "Quantity"
249
- msgstr ""
250
-
251
- #: woocommerce-ac.php:1841 send_email.php:115
252
- msgid "Price"
253
- msgstr ""
254
-
255
- #: woocommerce-ac.php:1842 send_email.php:116
256
- msgid "Line Subtotal"
257
- msgstr ""
258
-
259
- #: woocommerce-ac.php:1846
260
- msgid "Men\\'\\s Formal Shoes"
261
- msgstr ""
262
-
263
- #: woocommerce-ac.php:1853
264
- msgid "Woman\\'\\s Hand Bags"
265
- msgstr ""
266
-
267
- #: woocommerce-ac.php:1862 send_email.php:160
268
- msgid "Cart Total:"
269
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pagination.class.php DELETED
@@ -1,204 +0,0 @@
1
- <?php
2
- class pagination{
3
- /*
4
- Script Name: *Digg Style Paginator Class
5
- Script URI: http://www.mis-algoritmos.com/2007/05/27/digg-style-pagination-class/
6
- Description: Class in PHP that allows to use a pagination like a digg or sabrosus style.
7
- Script Version: 0.4
8
- Author: Victor De la Rocha
9
- Author URI: http://www.mis-algoritmos.com
10
- */
11
- /*Default values*/
12
- var $total_pages = -1;//items
13
- var $limit = null;
14
- var $target = "";
15
- var $page = 1;
16
- var $adjacents = 2;
17
- var $showCounter = false;
18
- var $className = "pagination";
19
- var $parameterName = "page";
20
- var $urlF = false;//urlFriendly
21
-
22
- /*Buttons next and previous*/
23
- var $nextT = "Next";
24
- var $nextI = "&#187;"; //&#9658;
25
- var $prevT = "Previous";
26
- var $prevI = "&#171;"; //&#9668;
27
-
28
- /*****/
29
- var $calculate = false;
30
-
31
- #Total items
32
- function items($value){$this->total_pages = (int) $value;}
33
-
34
- #how many items to show per page
35
- function limit($value){$this->limit = (int) $value;}
36
-
37
- #Page to sent the page value
38
- function target($value){$this->target = $value;}
39
-
40
- #Current page
41
- function currentPage($value){$this->page = (int) $value;}
42
-
43
- #How many adjacent pages should be shown on each side of the current page?
44
- function adjacents($value){$this->adjacents = (int) $value;}
45
-
46
- #show counter?
47
- function showCounter($value=""){$this->showCounter=($value===true)?true:false;}
48
-
49
- #to change the class name of the pagination div
50
- function changeClass($value=""){$this->className=$value;}
51
-
52
- function nextLabel($value){$this->nextT = $value;}
53
- function nextIcon($value){$this->nextI = $value;}
54
- function prevLabel($value){$this->prevT = $value;}
55
- function prevIcon($value){$this->prevI = $value;}
56
-
57
- #to change the class name of the pagination div
58
- function parameterName($value=""){$this->parameterName=$value;}
59
-
60
- #to change urlFriendly
61
- function urlFriendly($value="%"){
62
- if(eregi('^ *$',$value)){
63
- $this->urlF=false;
64
- return false;
65
- }
66
- $this->urlF=$value;
67
- }
68
-
69
- var $pagination;
70
-
71
- function pagination(){}
72
- function show(){
73
- if(!$this->calculate)
74
- if($this->calculate())
75
- echo "<div class=\"$this->className\">$this->pagination</div>\n";
76
- }
77
- function getOutput(){
78
- if(!$this->calculate)
79
- if($this->calculate())
80
- return "<div class=\"$this->className\">$this->pagination</div>\n";
81
- }
82
- function get_pagenum_link($id){
83
- if(strpos($this->target,'?')===false)
84
- if($this->urlF)
85
- return str_replace($this->urlF,$id,$this->target);
86
- else
87
- return "$this->target?$this->parameterName=$id";
88
- else
89
- return "$this->target&$this->parameterName=$id";
90
- }
91
-
92
- function calculate(){
93
- $this->pagination = "";
94
- $this->calculate == true;
95
- $error = false;
96
- if($this->urlF and $this->urlF != '%' and strpos($this->target,$this->urlF)===false){
97
- //Es necesario especificar el comodin para sustituir
98
- echo "Especificaste un wildcard para sustituir, pero no existe en el target<br />";
99
- $error = true;
100
- }elseif($this->urlF and $this->urlF == '%' and strpos($this->target,$this->urlF)===false){
101
- echo "Es necesario especificar en el target el comodin % para sustituir el n�mero de p�gina<br />";
102
- $error = true;
103
- }
104
-
105
- if($this->total_pages < 0){
106
- echo "It is necessary to specify the <strong>number of pages</strong> (\$class->items(1000))<br />";
107
- $error = true;
108
- }
109
- if($this->limit == null){
110
- echo "It is necessary to specify the <strong>limit of items</strong> to show per page (\$class->limit(10))<br />";
111
- $error = true;
112
- }
113
- if($error)return false;
114
-
115
- $n = trim($this->nextT.' '.$this->nextI);
116
- $p = trim($this->prevI.' '.$this->prevT);
117
-
118
- /* Setup vars for query. */
119
- if($this->page)
120
- $start = ($this->page - 1) * $this->limit; //first item to display on this page
121
- else
122
- $start = 0; //if no page var is given, set start to 0
123
-
124
- /* Setup page vars for display. */
125
- $prev = $this->page - 1; //previous page is page - 1
126
- $next = $this->page + 1; //next page is page + 1
127
- $lastpage = ceil($this->total_pages/$this->limit); //lastpage is = total pages / items per page, rounded up.
128
- $lpm1 = $lastpage - 1; //last page minus 1
129
-
130
- /*
131
- Now we apply our rules and draw the pagination object.
132
- We're actually saving the code to a variable in case we want to draw it more than once.
133
- */
134
-
135
- if($lastpage > 1){
136
- if($this->page){
137
- //anterior button
138
- if($this->page > 1)
139
- $this->pagination .= "<a href=\"".$this->get_pagenum_link($prev)."\" class=\"prev\">$p</a>";
140
- else
141
- $this->pagination .= "<span class=\"disabled\">$p</span>";
142
- }
143
- //pages
144
- if ($lastpage < 7 + ($this->adjacents * 2)){//not enough pages to bother breaking it up
145
- for ($counter = 1; $counter <= $lastpage; $counter++){
146
- if ($counter == $this->page)
147
- $this->pagination .= "<span class=\"current\">$counter</span>";
148
- else
149
- $this->pagination .= "<a href=\"".$this->get_pagenum_link($counter)."\">$counter</a>";
150
- }
151
- }
152
- elseif($lastpage > 5 + ($this->adjacents * 2)){//enough pages to hide some
153
- //close to beginning; only hide later pages
154
- if($this->page < 1 + ($this->adjacents * 2)){
155
- for ($counter = 1; $counter < 4 + ($this->adjacents * 2); $counter++){
156
- if ($counter == $this->page)
157
- $this->pagination .= "<span class=\"current\">$counter</span>";
158
- else
159
- $this->pagination .= "<a href=\"".$this->get_pagenum_link($counter)."\">$counter</a>";
160
- }
161
- $this->pagination .= "...";
162
- $this->pagination .= "<a href=\"".$this->get_pagenum_link($lpm1)."\">$lpm1</a>";
163
- $this->pagination .= "<a href=\"".$this->get_pagenum_link($lastpage)."\">$lastpage</a>";
164
- }
165
- //in middle; hide some front and some back
166
- elseif($lastpage - ($this->adjacents * 2) > $this->page && $this->page > ($this->adjacents * 2)){
167
- $this->pagination .= "<a href=\"".$this->get_pagenum_link(1)."\">1</a>";
168
- $this->pagination .= "<a href=\"".$this->get_pagenum_link(2)."\">2</a>";
169
- $this->pagination .= "...";
170
- for ($counter = $this->page - $this->adjacents; $counter <= $this->page + $this->adjacents; $counter++)
171
- if ($counter == $this->page)
172
- $this->pagination .= "<span class=\"current\">$counter</span>";
173
- else
174
- $this->pagination .= "<a href=\"".$this->get_pagenum_link($counter)."\">$counter</a>";
175
- $this->pagination .= "...";
176
- $this->pagination .= "<a href=\"".$this->get_pagenum_link($lpm1)."\">$lpm1</a>";
177
- $this->pagination .= "<a href=\"".$this->get_pagenum_link($lastpage)."\">$lastpage</a>";
178
- }
179
- //close to end; only hide early pages
180
- else{
181
- $this->pagination .= "<a href=\"".$this->get_pagenum_link(1)."\">1</a>";
182
- $this->pagination .= "<a href=\"".$this->get_pagenum_link(2)."\">2</a>";
183
- $this->pagination .= "...";
184
- for ($counter = $lastpage - (2 + ($this->adjacents * 2)); $counter <= $lastpage; $counter++)
185
- if ($counter == $this->page)
186
- $this->pagination .= "<span class=\"current\">$counter</span>";
187
- else
188
- $this->pagination .= "<a href=\"".$this->get_pagenum_link($counter)."\">$counter</a>";
189
- }
190
- }
191
- if($this->page){
192
- //siguiente button
193
- if ($this->page < $counter - 1)
194
- $this->pagination .= "<a href=\"".$this->get_pagenum_link($next)."\" class=\"next\">$n</a>";
195
- else
196
- $this->pagination .= "<span class=\"displaying-num\">$n</span>";
197
- if($this->showCounter)$this->pagination = "<span class=\"displaying-num\">($this->total_pages Items)</span>".$this->pagination;
198
- }
199
- }
200
-
201
- return true;
202
- }
203
- }
204
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,18 +1,22 @@
1
- === Woocommerce Abandoned Cart Lite ===
2
- Contributors: ashokrane, pinal.shah, mansishah, dharakothari, bhavik.kiri
3
- Tags: abandon cart, shopping cart abandonment
 
 
 
 
4
  Requires at least: 1.3
5
- Tested up to: 4.4
6
  Stable tag: trunk
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Donate link: http://www.tychesoftwares.com/
10
 
11
- This easy-to-use plugin gives store owners the ability to recover sales that are lost to abandoned shopping carts by logged-in customers.
12
 
13
  == Description ==
14
 
15
- Abandoned Cart plugin works in the background, sending email notifications to your customers, reminding them about their abandoned orders.
16
 
17
  The Abandoned Cart plugin allows you to recover orders that were just a step away from closing. It enables you to create automatic & well-timed email reminders to be sent to your customers who have added your products to their cart, but did not complete the order. As a result, with this plugin you will start recovering at least 30% or more of your lost sales. Why let this 30% revenue go unclaimed?
18
 
@@ -35,7 +39,7 @@ Abandoned Cart PRO plugin enables to do the following additional things:
35
  <li>Works off-the-shelf as it comes with 3 default email templates</li>
36
  <li>Offer incentives to customers to return and complete their checkout with discounts and coupons</li>
37
  <li>Add custom variables like Customer Name, Product Information, Coupons, etc. in the email template</li>
38
- <li>Embed Woocommerce coupons & also generate unique coupons in the emails being sent to customers</li>
39
  <li>Track whether expired coupons are causing cart abandonment</li>
40
  <li>Track emails sent, emails opened, links clicked for each template/email</li>
41
  <li>Product report allows you to see which products are being abandoned & which are being recovered the most</li>
@@ -44,7 +48,7 @@ Abandoned Cart PRO plugin enables to do the following additional things:
44
 
45
  **Pro Version:**
46
 
47
- **[WooCommerce Abandoned Cart Pro 2.6](http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro "WooCommerce Abandoned Cart Pro")** - The PRO version allows you to track products in abandoned carts, create unlimited email templates, track coupons, keep a track of sent emails & much more.
48
 
49
 
50
  **Email Sending Setup:**
@@ -53,9 +57,24 @@ From version 1.3, it is not mandatory to set a cron job via CPanel for the aband
53
 
54
  Abandoned Cart Plugin relies on a function called WP-Cron, and this function only runs when there is a page requested. So, if there are no visits to your website, then the scheduled jobs are not run. Generally this method of sending the abandoned cart notification emails is reliable. However, if you are not very confident about the traffic volume of your website, then you can set a manual cron job via Cpanel or any other control panel that your host provides.
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  == Installation ==
57
 
58
- 1. Ensure you have latest version of Woocommerce plugin installed
59
  2. Unzip and upload contents of the plugin to your /wp-content/plugins/ directory
60
  3. Activate the plugin through the 'Plugins' menu in WordPress
61
  4. The plugin will start working as per the settings entered.
@@ -87,8 +106,117 @@ The documentation can be found **[here](https://www.tychesoftwares.com/woocommer
87
 
88
  4. Lists Recovered Orders.
89
 
 
 
90
  == Changelog ==
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  = 2.6 =
93
 
94
  * The plugin is now using the TinyMCE editor available in WordPress core for the email body content. The external TinyMCE library is removed from the plugin.
1
+ === Abandoned Cart Lite for WooCommerce ===
2
+ Contributors: ashokrane, pinal.shah, bhavik.kiri, chetnapatel
3
+ Tags: abandon cart, shopping cart abandonment, sales recovery, conversion rate,
4
+ cart recovery
5
+ , recover lost sales
6
+ , woocommerce conversion rate
7
+ , increase sales with woocommerce
8
  Requires at least: 1.3
9
+ Tested up to: 4.7.2
10
  Stable tag: trunk
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
  Donate link: http://www.tychesoftwares.com/
14
 
15
+ This easy-to-use plugin allows WooCommerce store owners to recover sales that are lost to abandoned shopping carts by customers.
16
 
17
  == Description ==
18
 
19
+ Abandoned Cart plugin works in the background, sending email notifications to your guests customers & logged-in customers, reminding them about their abandoned orders.
20
 
21
  The Abandoned Cart plugin allows you to recover orders that were just a step away from closing. It enables you to create automatic & well-timed email reminders to be sent to your customers who have added your products to their cart, but did not complete the order. As a result, with this plugin you will start recovering at least 30% or more of your lost sales. Why let this 30% revenue go unclaimed?
22
 
39
  <li>Works off-the-shelf as it comes with 3 default email templates</li>
40
  <li>Offer incentives to customers to return and complete their checkout with discounts and coupons</li>
41
  <li>Add custom variables like Customer Name, Product Information, Coupons, etc. in the email template</li>
42
+ <li>Embed WooCommerce coupons & also generate unique coupons in the emails being sent to customers</li>
43
  <li>Track whether expired coupons are causing cart abandonment</li>
44
  <li>Track emails sent, emails opened, links clicked for each template/email</li>
45
  <li>Product report allows you to see which products are being abandoned & which are being recovered the most</li>
48
 
49
  **Pro Version:**
50
 
51
+ **[Abandoned Cart Pro for WooCommerce 4.7](http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro "Abandoned Cart Pro for WooCommerce")** - The PRO version allows you to track products in abandoned carts, create unlimited email templates, track coupons, keep a track of sent emails & much more.
52
 
53
 
54
  **Email Sending Setup:**
57
 
58
  Abandoned Cart Plugin relies on a function called WP-Cron, and this function only runs when there is a page requested. So, if there are no visits to your website, then the scheduled jobs are not run. Generally this method of sending the abandoned cart notification emails is reliable. However, if you are not very confident about the traffic volume of your website, then you can set a manual cron job via Cpanel or any other control panel that your host provides.
59
 
60
+ **Some of our other free plugins:**
61
+
62
+ **[Order Delivery Date for WooCommerce](https://wordpress.org/plugins/order-delivery-date-for-woocommerce/ "Order Delivery Date for WooCommerce")**
63
+
64
+ **[Product Delivery Date for WooCommerce - Lite](https://wordpress.org/plugins/product-delivery-date-for-woocommerce-lite/ "Product Delivery Date for WooCommerce")**
65
+
66
+
67
+ **Some of our Pro plugins:**
68
+
69
+ **[Booking & Appointment Plugin for WooCommerce 3.5.1](https://www.tychesoftwares.com/store/premium-plugins/woocommerce-booking-plugin/ "Booking & Appointment Plugin for WooCommerce")**
70
+
71
+ **[Order Delivery Date Pro for WooCommerce 6.4.3](https://www.tychesoftwares.com/store/premium-plugins/order-delivery-date-for-woocommerce-pro-21/ "Order Delivery Date Pro for WooCommerce")**
72
+
73
+ **[Product Delivery Date Pro for WooCommerce 2.0.1](https://www.tychesoftwares.com/store/premium-plugins/product-delivery-date-pro-for-woocommerce/ "Product Delivery Date Pro for WooCommerce")**
74
+
75
  == Installation ==
76
 
77
+ 1. Ensure you have latest version of WooCommerce plugin installed
78
  2. Unzip and upload contents of the plugin to your /wp-content/plugins/ directory
79
  3. Activate the plugin through the 'Plugins' menu in WordPress
80
  4. The plugin will start working as per the settings entered.
106
 
107
  4. Lists Recovered Orders.
108
 
109
+ 5. Product Report Tab.
110
+
111
  == Changelog ==
112
 
113
+ = 3.5 =
114
+
115
+ * This version has 1 new feature and 3 enhancements.
116
+
117
+ * New Feature - New setting named as "Enable tracking carts when customer doesn't enter details" on the settings page. When this setting is enabled it will enable tracking of abandoned products & carts even if the customer does not visit the checkout page or does not enter any details on the checkout page like Name or Email. Tracking will begin as soon as a visitor adds a product to their cart and visits the cart page.
118
+
119
+ * Enhancement - The default settings value for "Cart abandoned cut-off time" for logged-in users has been modified to 10 minutes.
120
+
121
+ * Enhancement - The Settings tab of the plugin has been redesigned. Now, the plugin will display 2 sub-tabs for different settings. The sub-tabs are named as "General Settings" & "Email Sending Settings". The settings of add/edit email template "Send From This Name", "Send From This Email Address" & "Send Reply Emails to" has been moved to the Settings -> Email Sending Setting tab.
122
+
123
+ * Enhancement - In this version we have introduced three new views of abandoned orders in the Abandoned Orders tab. The views named are "All", "Registered Users", "Guest Users" & "Carts without Customer Details". The "Registered Users" view will display only the logged-in user's abandoned carts. The "Guest Users" view will display the guest user's carts & "Carts without Customer Details" view will display all the abandoned carts of the guest users who have not entered an email address or any information on the checkout page.
124
+
125
+ = 3.4 =
126
+
127
+ * This version has 3 enhancements.
128
+
129
+ * Enhancement - We have made our plugin compatible with the "Loco Translation" plugin. Now, all the strings from Abandoned Cart Lite for WooCommerce plugin can be translated using the Loco Translation plugin.
130
+
131
+ * Enhancement - The email template are now compatible with the "WP Better Emails" plugin. If the "WP Better Emails" plugin is activated on the site then CSS style of this plugin will be applied to the test email and abandoned cart reminder email.
132
+
133
+ * Enhancement - When the email sending script is executed on the server, it was running a large number of MySQL queries for guest users. That was causing an increase in the server load. In this version, we have optimised the queries. Now, the plugin will not fetch all the guest users record as it will fetch the necessary record which needs to be checked. This will improve the site performance.
134
+
135
+ = 3.3 =
136
+
137
+ * This version has 2 bug fixes.
138
+
139
+ * Bug fixed: If the store has the wrong guest user id in the database then it was creating issues where guest users cart was not populating the correct cart data while recovering their cart from reminder email received. This has been fixed.
140
+
141
+ * Bug fixed: If plugin is being used with PHP7, it was showing an error "Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0". This has been fixed.
142
+
143
+ = 3.2 =
144
+
145
+ * This version has 3 enhancements along with 2 bug fixes.
146
+
147
+ * Enhancements - The plugin will now display the user's billing first name & billing last name for the "Customer Details" column of the abandoned orders tab.
148
+
149
+ * Enhancements - Earlier rounding off of the decimal values was hardcoded in the plugin. Now, it will round the decimal values based on the WooCommerce setting named "Number of Decimals" which is located at WooCommerce -> Settings menu.
150
+
151
+ * Enhancements - Earlier plugin was sending the abandoned cart reminder to the customer if the email body content was blank. Now, the plugin will not consider the blank email body template for sending the abandoned cart reminder emails.
152
+
153
+ * Bug Fixed - If "Send the Abandoned cart emails to the admin" setting is enabled and Admin of the store create manual order from WooCommerce -> Orders page then abandoned cart recovered email was getting sent to the Admin. This has been fixed.
154
+
155
+ * Bug Fixed - The count of abandoned carts on Recovered Orders tab was updated before "Cart abandoned cut-off time" limit is passed. This has been fixed.
156
+
157
+ = 3.1 =
158
+
159
+ * New Feature - The email sending logic has been changed. Due to some reason, the abandoned cart remainder emails are not sent to the customers at the time they are intended to be sent, and if after some time, the emails start sending, then multiple email templates whose interval has been reached were all sent together. Now, the plugin will also consider the last abandoned cart reminder email sent time and will keep a time gap between the last email template that was sent & the current email template's time, thereby ensuring emails are not sent together.
160
+
161
+ * Bug Fixed - The "Alter" table queries have been changed in the plugin. Instead of using get_results(), it now uses the query().
162
+
163
+ * Bug Fixed - We have used the encryption libraries mcrypt_encrypt, MCRYPT_MODE_CBC, MCRYPT_RIJNDAEL_256 to generate the cart links sent in the abandoned cart reminder emails. Due to this on some servers where these libraries were not enabled, the abandoned cart email notification were not sent to the recipients. This has been fixed.
164
+
165
+ * Bug Fixed - Earlier the "InnoDB" table engine type was hardcoded in plugin queries. As a result, the plugins tables were not created where the engine type was other than "InnoDB". This has been fixed.
166
+
167
+ * Bug Fixed - Some warnings were displayed in the Debug log file. This has been fixed.
168
+
169
+ = 3.0 =
170
+
171
+ * Enhancements - In this version, the code has been refined throughout the plugin & the folder structure has also been modified.
172
+
173
+ * Enhancements - Earlier rounding off of the decimal values was hardcoded in the plugin. Now, it will round the decimal values based on the WooCommerce setting named "Number of Decimals" which is located at WooCommerce -> Settings menu.
174
+
175
+ * Bugs Fixed - When setting "Email admin On Order Recovery" is enabled & order is recovered from the abandoned cart reminder notifications using "Cash On Delivery" payment gateway. Then the order is not considered as recovered & the order was not displayed in the "Recovered Orders" tab. This has been fixed.
176
+
177
+ * Bugs Fixed - Earlier the abandoned cart reminder emails & abandoned orders details page was not displaying the selected attributes for the variable products. This has been fixed.
178
+
179
+ * Bugs Fixed - The "Abandoned Date" column of the abandoned orders tab was not considering the time for sorting. This has been fixed.
180
+
181
+ = 2.9 =
182
+
183
+ * New Feature - New merge tag {{cart.unsubscribe}} has been added for email templates. This merge tag allows user to stop receiving further abandoned cart reminder email notifications. This merge tag has been added to comply with email sending laws in different countries.
184
+
185
+ * Bugs Fixed - Earlier if any user came from abandoned cart reminder email and place the order using PayPal payment gateway and do not reach the order received page. Then plugin was not considering that order as a recovered order. From now onwards if the user came from the abandoned cart reminder email and place the order using PayPal and does not reach the order received the page. Then plugin will consider that cart as a recovered order.
186
+
187
+ * Bugs Fixed - When the cart is abandoned as a guest & product have the special character in the attributes name, then it was displaying a blank row with only a checkbox on the Abandoned Orders tab. This has been fixed.
188
+
189
+ * Tweak - If the order is recovered from the abandoned cart reminder email then it will add a note "This order was abandoned & subsequently recovered." for the order.
190
+
191
+ = 2.8 =
192
+
193
+ * We have changed the encryption for the links that are sent in the Abandoned cart email notifications. Earlier we were using the mcrypt library for encoding the data. If mcrypt library was not installed on the server, then abandoned cart email notifications were not sent. Now we have used different functions for encoding the string. We have used microtime function & a security key. Using this security key, and after applying an algorithm on it, we generate the encoded string.
194
+
195
+ * The session now starts only on required pages of the store. Earlier it was started globally. This will help to improve the site performance.
196
+
197
+ * If billing email address of the logged-in user is not set then it was showing blank space on the abandoned orders list. This has been fixed. Now it will show the email address which was used while registering to the store.
198
+
199
+ * Earlier if email body was blank and we send the test email then blank email was sent. This has been fixed. Now if email body is blank then test email will not be sent.
200
+
201
+ * Tweak - Earlier we were populating the guest cart information by looping into the global WooCommerce cart. Now we are not looping & instead using the WooCommerce session object itself.
202
+
203
+ * Tweak - Earlier if the 'wp-content' directory has been renamed, then wp-load.php file was not included and abandoned cart reminder email was not sent. Now, we have changed the way of including the wp-load.php file for sending the abandoned cart reminder notifications.
204
+
205
+ * Tweak - Earlier when {{products.cart}} merge tag is used in abandoned cart email template, then on click of the product name and product image, it was redirecting to the product page. Now it will redirect the user to the cart page.
206
+
207
+ * Tweak - We are now rounding off the prices with the 'round' function.
208
+
209
+ = 2.7 =
210
+
211
+ * New setting named as "Email Template Header Text" is added in Add / Edit template page. It will allow to change the header text of the email which have WooCommerce template style setting enabled for the template.
212
+
213
+ * From this version, the email sending process will run every 15 minutes instead of every 5 minutes. This will result in improved overall performance of the website.
214
+
215
+ * When Lite version of the plugin is activated on the site then it was not allowing to activate the PRO version of the plugin. This has been fixed.
216
+
217
+ * When templates are created / updated and if it has the same duration as one of the existing templates, then new template was not saved. This has been fixed.
218
+
219
+
220
  = 2.6 =
221
 
222
  * The plugin is now using the TinyMCE editor available in WordPress core for the email body content. The external TinyMCE library is removed from the plugin.
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file
screenshot-4.png CHANGED
Binary file
screenshot-5.png ADDED
Binary file
views/wacp-email-template-preview.php DELETED
@@ -1,52 +0,0 @@
1
- <?php
2
- /**
3
- * Admin View: Abadoned Cart reminder Email Template Preview
4
- */
5
-
6
- if ( ! defined( 'ABSPATH' ) ) {
7
- exit; // Exit if accessed directly
8
- }
9
-
10
- ?>
11
- <html>
12
- <head>
13
- <title>My document title</title>
14
- </head>
15
- <body>
16
-
17
- <p align="center"> Hello John Carter, </p>
18
- <p> &nbsp; </p>
19
- <p align="center"> We're following up with you, because we noticed that on 12-12-2015 you attempted to purchase the following products on <?php echo get_option( 'blogname' );?>. </p>
20
- <p> &nbsp; </p>
21
- <p>
22
-
23
- <table border="0" cellspacing="5" align="center"><caption><b>Cart Details</b></caption>
24
- <tbody>
25
- <tr>
26
- <th></th>
27
- <th>Product</th>
28
- <th>Price</th>
29
- <th>Quantity</th>
30
- <th>Total</th>
31
- </tr>
32
- <tr style="background-color:#f4f5f4;">
33
- <td><img src = "<?php echo plugins_url();?>/woocommerce-abandoned-cart/images/spectre.jpg" height="40px" width="40px"></td><td>Spectre</td><td>$150</td><td>2</td><td>$300</td>
34
- </tr>
35
- <tr>
36
- <td>&nbsp;</td>
37
- <td>&nbsp;</td>
38
- <td>&nbsp;</td>
39
- <th>Cart Total:</th>
40
- <td>$300</td>
41
- </tr></tbody></table> </p>
42
- <p> &nbsp; </p>
43
- <p align="center"> If you had any purchase troubles, could you please Contact to share them? </p>
44
- <p> &nbsp; </p>
45
- <p align="center"> Otherwise, how about giving us another chance? Shop <a href="<?php echo get_option( 'siteurl' );?>"><?php echo get_option( 'blogname' );?></a>. </p>
46
- <hr></hr>
47
- <p align="center"> You may <a href="<?php echo get_option( 'siteurl' );?>">unsubscribe</a> to stop receiving these emails. </p>
48
- <p> &nbsp; </p>
49
- <p align="center"> <a href="<?php echo get_option( 'siteurl' );?>"><?php echo get_option( 'blogname' );?></a> appreciates your business. </p>
50
-
51
- </body>
52
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
views/wacp-wc-email-template-preview.php DELETED
@@ -1,47 +0,0 @@
1
- <?php
2
- /**
3
- * Admin View: Abadoned Cart reminder Email Template Preview
4
- */
5
-
6
- if ( ! defined( 'ABSPATH' ) ) {
7
- exit; // Exit if accessed directly
8
- }
9
-
10
- ?>
11
- <body>
12
-
13
- <p > Hello John Carter, </p>
14
- <p> &nbsp; </p>
15
- <p > We're following up with you, because we noticed that on 12-12-2015 you attempted to purchase the following products on <?php echo get_option( 'blogname' );?>. </p>
16
- <p> &nbsp; </p>
17
- <p>
18
-
19
- <table border="0" cellspacing="5" align="center"><caption><b>Cart Details</b></caption>
20
- <tbody>
21
- <tr>
22
- <th></th>
23
- <th>Product</th>
24
- <th>Price</th>
25
- <th>Quantity</th>
26
- <th>Total</th>
27
- </tr>
28
- <tr style="background-color:#f4f5f4;">
29
- <td><img src = "<?php echo plugins_url();?>/woocommerce-abandoned-cart/images/spectre.jpg" height="40px" width="40px"></td><td>Spectre</td><td>$150</td><td>2</td><td>$300</td>
30
- </tr>
31
- <tr>
32
- <td>&nbsp;</td>
33
- <td>&nbsp;</td>
34
- <td>&nbsp;</td>
35
- <th>Cart Total:</th>
36
- <td>$300</td>
37
- </tr></tbody></table> </p>
38
- <p> &nbsp; </p>
39
- <p > If you had any purchase troubles, could you please Contact to share them? </p>
40
- <p> &nbsp; </p>
41
- <p > Otherwise, how about giving us another chance? Shop <a href="<?php echo get_option( 'siteurl' );?>"><?php echo get_option( 'blogname' );?></a>. </p>
42
- <hr></hr>
43
- <p > You may <a href="<?php echo get_option( 'siteurl' );?>">unsubscribe</a> to stop receiving these emails. </p>
44
- <p> &nbsp; </p>
45
- <p > <a href="<?php echo get_option( 'siteurl' );?>"><?php echo get_option( 'blogname' );?></a> appreciates your business. </p>
46
-
47
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
views/wcal-email-template-preview.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Abandoned Cart reminder Email Template Preview
4
+ */
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit; // Exit if accessed directly
7
+ }
8
+ ?>
9
+ <html>
10
+ <head>
11
+ <title>My document title</title>
12
+ </head>
13
+ <body>
14
+ <p align="center"> Hello John Carter, </p>
15
+ <p> &nbsp; </p>
16
+ <p align="center"> We're following up with you, because we noticed that on 12-12-2015 you attempted to purchase the following products on <?php echo get_option( 'blogname' );?>. </p>
17
+ <p> &nbsp; </p>
18
+ <p>
19
+ <table border="0" cellspacing="5" align="center"><caption><b>Cart Details</b></caption>
20
+ <tbody>
21
+ <tr>
22
+ <th></th>
23
+ <th>Product</th>
24
+ <th>Price</th>
25
+ <th>Quantity</th>
26
+ <th>Total</th>
27
+ </tr>
28
+ <tr style="background-color:#f4f5f4;">
29
+ <td><img src = "<?php echo plugins_url();?>/woocommerce-abandoned-cart/assets/images/spectre.jpg" height="40px" width="40px"></td><td>Spectre</td><td>$150</td><td>2</td><td>$300</td>
30
+ </tr>
31
+ <tr>
32
+ <td>&nbsp;</td>
33
+ <td>&nbsp;</td>
34
+ <td>&nbsp;</td>
35
+ <th>Cart Total:</th>
36
+ <td>$300</td>
37
+ </tr>
38
+ </tbody>
39
+ </table>
40
+ </p>
41
+ <p> &nbsp; </p>
42
+ <p align="center"> If you had any purchase troubles, could you please Contact to share them? </p>
43
+ <p> &nbsp; </p>
44
+ <p align="center"> Otherwise, how about giving us another chance? Shop <a href="<?php echo get_option( 'siteurl' );?>"><?php echo get_option( 'blogname' );?></a>. </p>
45
+ <hr></hr>
46
+ <p align="center"> You may <a href="<?php echo get_option( 'siteurl' );?>">unsubscribe</a> to stop receiving these emails. </p>
47
+ <p> &nbsp; </p>
48
+ <p align="center"> <a href="<?php echo get_option( 'siteurl' );?>"><?php echo get_option( 'blogname' );?></a> appreciates your business. </p>
49
+ </body>
50
+ </html>
views/wcal-wc-email-template-preview.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin View: Abandoned Cart reminder Email Template Preview
4
+ */
5
+ if( ! defined( 'ABSPATH' ) ) {
6
+ exit; // Exit if accessed directly
7
+ }
8
+ ?>
9
+ <body>
10
+ <p> Hello John Carter, </p>
11
+ <p> &nbsp; </p>
12
+ <p> We're following up with you, because we noticed that on 12-12-2015 you attempted to purchase the following products on <?php echo get_option( 'blogname' );?>. </p>
13
+ <p> &nbsp; </p>
14
+ <p>
15
+ <table border="0" cellspacing="5" align="center"><caption><b>Cart Details</b></caption>
16
+ <tbody>
17
+ <tr>
18
+ <th></th>
19
+ <th>Product</th>
20
+ <th>Price</th>
21
+ <th>Quantity</th>
22
+ <th>Total</th>
23
+ </tr>
24
+ <tr style="background-color:#f4f5f4;">
25
+ <td><img src = "<?php echo plugins_url();?>/woocommerce-abandoned-cart/assets/images/spectre.jpg" height="40px" width="40px"></td><td>Spectre</td><td>$150</td><td>2</td><td>$300</td>
26
+ </tr>
27
+ <tr>
28
+ <td>&nbsp;</td>
29
+ <td>&nbsp;</td>
30
+ <td>&nbsp;</td>
31
+ <th>Cart Total:</th>
32
+ <td>$300</td>
33
+ </tr>
34
+ </tbody>
35
+ </table>
36
+ </p>
37
+ <p> &nbsp; </p>
38
+ <p> If you had any purchase troubles, could you please Contact to share them? </p>
39
+ <p> &nbsp; </p>
40
+ <p> Otherwise, how about giving us another chance? Shop <a href="<?php echo get_option( 'siteurl' );?>"><?php echo get_option( 'blogname' );?></a>. </p>
41
+ <hr></hr>
42
+ <p> You may <a href="<?php echo get_option( 'siteurl' );?>">unsubscribe</a> to stop receiving these emails. </p>
43
+ <p> &nbsp; </p>
44
+ <p> <a href="<?php echo get_option( 'siteurl' );?>"><?php echo get_option( 'blogname' );?></a> appreciates your business. </p>
45
+ </body>
woo-includes/class-wc-dependencies.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
- /**
3
- * WC Dependency Checker
4
- *
5
- * Checks if WooCommerce is enabled
6
- */
7
- class WC_Dependencies {
8
-
9
- private static $active_plugins;
10
-
11
- function init() {
12
-
13
- self::$active_plugins = (array) get_option( 'active_plugins', array() );
14
-
15
- if ( is_multisite() )
16
- self::$active_plugins = array_merge( self::$active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
17
- }
18
-
19
- function woocommerce_active_check() {
20
-
21
- if ( ! self::$active_plugins ) self::init();
22
-
23
- return in_array( 'woocommerce/woocommerce.php', self::$active_plugins ) || array_key_exists( 'woocommerce/woocommerce.php', self::$active_plugins );
24
-
25
- }
26
-
27
- }
28
-
29
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
woo-includes/woo-functions.php DELETED
@@ -1,97 +0,0 @@
1
- <?php
2
- /**
3
- * Functions used by plugins
4
- */
5
- if ( ! class_exists( 'WC_Dependencies' ) )
6
- require_once 'class-wc-dependencies.php';
7
-
8
- /**
9
- * WC Detection
10
- */
11
- if ( ! function_exists( 'is_woocommerce_active' ) ) {
12
- function is_woocommerce_active() {
13
- return WC_Dependencies::woocommerce_active_check();
14
- }
15
- }
16
-
17
- /**
18
- * Queue updates for the WooUpdater
19
- */
20
- if ( ! function_exists( 'woothemes_queue_update' ) ) {
21
- function woothemes_queue_update( $file, $file_id, $product_id ) {
22
- global $woothemes_queued_updates;
23
-
24
- if ( ! isset( $woothemes_queued_updates ) )
25
- $woothemes_queued_updates = array();
26
-
27
- $plugin = new stdClass();
28
- $plugin->file = $file;
29
- $plugin->file_id = $file_id;
30
- $plugin->product_id = $product_id;
31
-
32
- $woothemes_queued_updates[] = $plugin;
33
- }
34
- }
35
-
36
- /**
37
- * Load installer for the WooThemes Updater.
38
- * @return $api Object
39
- */
40
- if ( ! class_exists( 'WooThemes_Updater' ) && ! function_exists( 'woothemes_updater_install' ) ) {
41
- function woothemes_updater_install( $api, $action, $args ) {
42
- $download_url = 'http://woodojo.s3.amazonaws.com/downloads/woothemes-updater/woothemes-updater.zip';
43
-
44
- if ( 'plugin_information' != $action ||
45
- false !== $api ||
46
- ! isset( $args->slug ) ||
47
- 'woothemes-updater' != $args->slug
48
- ) return $api;
49
-
50
- $api = new stdClass();
51
- $api->name = 'WooThemes Updater';
52
- $api->version = '1.0.0';
53
- $api->download_link = esc_url( $download_url );
54
- return $api;
55
- }
56
-
57
- add_filter( 'plugins_api', 'woothemes_updater_install', 10, 3 );
58
- }
59
-
60
- /**
61
- * WooUpdater Installation Prompts
62
- */
63
- if ( ! class_exists( 'WooThemes_Updater' ) && ! function_exists( 'woothemes_updater_notice' ) ) {
64
-
65
- /**
66
- * Display a notice if the "WooThemes Updater" plugin hasn't been installed.
67
- * @return void
68
- */
69
- function woothemes_updater_notice() {
70
- $active_plugins = apply_filters( 'active_plugins', get_option('active_plugins' ) );
71
- if ( in_array( 'woothemes-updater/woothemes-updater.php', $active_plugins ) ) return;
72
-
73
- $slug = 'woothemes-updater';
74
- $install_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $slug ), 'install-plugin_' . $slug );
75
- $activate_url = 'plugins.php?action=activate&plugin=' . urlencode( 'woothemes-updater/woothemes-updater.php' ) . '&plugin_status=all&paged=1&s&_wpnonce=' . urlencode( wp_create_nonce( 'activate-plugin_woothemes-updater/woothemes-updater.php' ) );
76
-
77
- $message = '<a href="' . esc_url( $install_url ) . '">Install the WooThemes Updater plugin</a> to get updates for your WooThemes plugins.';
78
- $is_downloaded = false;
79
- $plugins = array_keys( get_plugins() );
80
- foreach ( $plugins as $plugin ) {
81
- if ( strpos( $plugin, 'woothemes-updater.php' ) !== false ) {
82
- $is_downloaded = true;
83
- $message = '<a href="' . esc_url( admin_url( $activate_url ) ) . '">Activate the WooThemes Updater plugin</a> to get updates for your WooThemes plugins.';
84
- }
85
- }
86
- echo '<div class="updated fade"><p>' . $message . '</p></div>' . "\n";
87
- }
88
-
89
- add_action( 'admin_notices', 'woothemes_updater_notice' );
90
- }
91
-
92
- /**
93
- * Prevent conflicts with older versions
94
- */
95
- if ( ! class_exists( 'WooThemes_Plugin_Updater' ) ) {
96
- class WooThemes_Plugin_Updater { function init() {} }
97
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
woocommerce-ac.php CHANGED
@@ -1,2713 +1,3180 @@
1
  <?php
2
  /*
3
- Plugin Name: WooCommerce Abandon Cart Lite Plugin
4
  Plugin URI: http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro
5
  Description: This plugin captures abandoned carts by logged-in users & emails them about it. <strong><a href="http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro">Click here to get the PRO Version.</a></strong>
6
- Version: 2.6
7
  Author: Tyche Softwares
8
  Author URI: http://www.tychesoftwares.com/
 
 
9
  */
10
 
11
- if( session_id() === '' ){
12
- //session has not started
13
- session_start();
14
- }
15
  // Deletion Settings
16
- register_uninstall_hook( __FILE__, 'woocommerce_ac_delete' );
17
 
18
- include_once( "woocommerce_guest_ac.class.php" );
19
- include_once( "default-settings.php" );
20
- require_once( "actions.php" );
21
- // Add a new interval of 5 minutes
22
- add_filter( 'cron_schedules', 'woocommerce_ac_add_cron_schedule' );
 
 
 
23
 
24
- function woocommerce_ac_add_cron_schedule( $schedules ) {
25
-
26
- $schedules['5_minutes'] = array(
27
- 'interval' => 300 , // 5 minutes in seconds
28
- 'display' => __( 'Once Every Five Minutes' ),
29
  );
30
  return $schedules;
31
  }
32
-
33
  // Schedule an action if it's not already scheduled
34
  if ( ! wp_next_scheduled( 'woocommerce_ac_send_email_action' ) ) {
35
- wp_schedule_event( time(), '5_minutes', 'woocommerce_ac_send_email_action' );
36
  }
37
 
38
- // Hook into that action that'll fire every 5 minutes
39
- add_action( 'woocommerce_ac_send_email_action', 'woocommerce_ac_send_email_cron' );
40
- function woocommerce_ac_send_email_cron() {
 
41
  //require_once( ABSPATH.'wp-content/plugins/woocommerce-abandoned-cart/cron/send_email.php' );
42
  $plugin_dir_path = plugin_dir_path( __FILE__ );
43
- require_once( $plugin_dir_path . 'cron/send_email.php' );
44
  }
45
 
46
- function woocommerce_ac_delete(){
47
-
48
  global $wpdb;
49
- $table_name_ac_abandoned_cart_history = $wpdb->prefix . "ac_abandoned_cart_history_lite";
50
- $sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_abandoned_cart_history ;
51
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
52
- $wpdb->get_results( $sql_ac_abandoned_cart_history );
53
-
54
- $table_name_ac_email_templates = $wpdb->prefix . "ac_email_templates_lite";
55
- $sql_ac_email_templates = "DROP TABLE " . $table_name_ac_email_templates ;
56
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
57
- $wpdb->get_results( $sql_ac_email_templates );
58
-
59
- $table_name_ac_sent_history = $wpdb->prefix . "ac_sent_history_lite";
60
- $sql_ac_sent_history = "DROP TABLE " . $table_name_ac_sent_history ;
61
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
62
- $wpdb->get_results( $sql_ac_sent_history );
63
-
64
- $table_name_ac_guest_abandoned_cart_history = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
65
- $sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_guest_abandoned_cart_history ;
66
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
67
- $wpdb->get_results( $sql_ac_abandoned_cart_history );
68
-
69
- $sql_table_user_meta_cart = "DELETE FROM `" . $wpdb->prefix . "usermeta` WHERE meta_key = '_woocommerce_persistent_cart'";
70
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
71
- $wpdb->get_results( $sql_table_user_meta_cart );
72
-
73
- $sql_table_user_meta_cart_modified = "DELETE FROM `" . $wpdb->prefix . "usermeta` WHERE meta_key = '_woocommerce_ac_modified_cart'";
74
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
75
- $wpdb->get_results( $sql_table_user_meta_cart_modified );
76
-
77
- $query = "SELECT blog_id FROM `".$wpdb->prefix."blogs`";
78
- $results = $wpdb->get_results( $query );
79
-
80
-
81
-
82
- foreach( $results as $key => $value ) {
83
-
84
- $table_name_ac_abandoned_cart_history = $wpdb->prefix .$value->blog_id."_"."ac_abandoned_cart_history_lite";
85
- $sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_abandoned_cart_history ;
86
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
87
- $wpdb->get_results( $sql_ac_abandoned_cart_history );
88
-
89
- $table_name_ac_email_templates = $wpdb->prefix .$value->blog_id."_"."ac_email_templates_lite";
90
- $sql_ac_email_templates = "DROP TABLE " . $table_name_ac_email_templates ;
91
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
92
- $wpdb->get_results( $sql_ac_email_templates );
93
-
94
- $table_name_ac_sent_history = $wpdb->prefix .$value->blog_id."_"."ac_sent_history_lite";
95
- $sql_ac_sent_history = "DROP TABLE " . $table_name_ac_sent_history ;
96
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
97
- $wpdb->get_results( $sql_ac_sent_history );
98
-
99
- $table_name_ac_guest_abandoned_cart_history = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
100
- $sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_guest_abandoned_cart_history ;
101
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
102
- $wpdb->get_results( $sql_ac_abandoned_cart_history );
103
-
104
- $sql_table_user_meta_cart = "DELETE FROM `" . $wpdb->prefix.$value->blog_id."_"."usermeta` WHERE meta_key = '_woocommerce_persistent_cart'";
105
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
106
- $wpdb->get_results( $sql_table_user_meta_cart );
107
-
108
- $sql_table_user_meta_cart_modified = "DELETE FROM `" . $wpdb->prefix.$value->blog_id."_"."usermeta` WHERE meta_key = '_woocommerce_ac_modified_cart'";
109
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
110
- $wpdb->get_results( $sql_table_user_meta_cart_modified );
111
-
112
- }
113
-
114
- delete_option ( 'woocommerce_ac_email_body' );
115
  delete_option( 'ac_lite_cart_abandoned_time' );
116
  delete_option( 'ac_lite_email_admin_on_recovery' );
117
  delete_option( 'ac_lite_settings_status' );
118
- delete_option( 'woocommerce_ac_default_templates_installed' );
119
-
120
-
 
 
 
121
  }
122
  /**
123
- * woocommerce_abandon_cart class
124
  **/
125
- if ( !class_exists( 'woocommerce_abandon_cart' ) ) {
126
 
127
- class woocommerce_abandon_cart {
128
-
129
- var $one_hour;
130
- var $three_hours;
131
- var $six_hours;
132
- var $twelve_hours;
133
- var $one_day;
134
- var $one_week;
135
-
136
- var $duration_range_select = array();
137
- var $start_end_dates = array();
138
-
139
- public function __construct() {
140
-
141
- $this->one_hour = 60 * 60;
142
- $this->three_hours = 3 * $this->one_hour;
143
- $this->six_hours = 6 * $this->one_hour;
144
- $this->twelve_hours = 12 * $this->one_hour;
145
- $this->one_day = 24 * $this->one_hour;
146
- $this->one_week = 7 * $this->one_day;
147
-
148
- $this->duration_range_select = array( 'yesterday' => 'Yesterday',
149
- 'today' => 'Today',
150
- 'last_seven' => 'Last 7 days',
151
- 'last_fifteen' => 'Last 15 days',
152
- 'last_thirty' => 'Last 30 days',
153
- 'last_ninety' => 'Last 90 days',
154
- 'last_year_days' => 'Last 365'
155
- );
156
-
157
- $this->start_end_dates = array( 'yesterday' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 24*60*60 ) ),
158
- 'end_date' => date( "d M Y", ( current_time( 'timestamp' ) - 7*24*60*60 ) ) ),
159
- 'today' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ),
160
- 'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
161
- 'last_seven' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 7*24*60*60 ) ),
162
- 'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
163
- 'last_fifteen' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 15*24*60*60 ) ),
164
- 'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
165
- 'last_thirty' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 30*24*60*60 ) ),
166
- 'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
167
- 'last_ninety' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 90*24*60*60 ) ),
168
- 'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
169
- 'last_year_days' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 365*24*60*60 ) ),
170
- 'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) )
171
- );
172
-
173
-
174
- // Initialize settings
175
- register_activation_hook ( __FILE__, array( &$this, 'woocommerce_ac_activate' ) );
176
-
177
- // WordPress Administration Menu
178
- add_action ( 'admin_menu', array( &$this, 'woocommerce_ac_admin_menu' ) );
179
-
180
- // Actions to be done on cart update
181
- add_action ( 'woocommerce_cart_updated', array( &$this, 'woocommerce_ac_store_cart_timestamp' ) );
182
-
183
- // delete added temp fields after order is placed
184
- add_filter ( 'woocommerce_order_details_after_order_table', array( &$this, 'action_after_delivery_session' ) );
185
-
186
- add_action ( 'admin_init', array( &$this, 'action_admin_init' ) );
187
-
188
- // Update the options as per settings API
189
- add_action ( 'admin_init', array( &$this, 'ac_lite_update_db_check' ) );
190
 
191
- // Wordpress settings API
192
- add_action( 'admin_init', array( &$this, 'ac_lite_initialize_plugin_options' ) );
193
-
194
- // Language Translation
195
- add_action ( 'init', array( &$this, 'update_po_file' ) );
196
-
197
- // track links
198
- add_filter( 'template_include', array( &$this, 'email_track_links_lite' ), 99, 1 );
199
-
200
- //Discount Coupon Notice
201
- add_action ( 'admin_notices', array( &$this, 'ac_lite_coupon_notice' ) );
202
-
203
- add_action ( 'admin_enqueue_scripts', array( &$this, 'my_enqueue_scripts_js' ) );
204
- add_action ( 'admin_enqueue_scripts', array( &$this, 'my_enqueue_scripts_css' ) );
205
-
206
- if ( is_admin() ) {
207
- // Load "admin-only" scripts here
208
- add_action ( 'admin_head', array( &$this, 'my_action_javascript' ) );
209
- add_action ( 'wp_ajax_remove_cart_data', array( &$this, 'remove_cart_data' ) );
210
-
211
- add_action ( 'admin_head', array( &$this, 'my_action_send_preview' ) );
212
- add_action ( 'wp_ajax_preview_email_sent', array( &$this, 'preview_email_sent' ) );
213
-
214
- }
215
-
216
- // Send Email on order recovery
217
- add_action('woocommerce_order_status_pending_to_processing_notification', array(&$this, 'ac_email_admin_recovery'));
218
- add_action('woocommerce_order_status_pending_to_completed_notification', array(&$this, 'ac_email_admin_recovery'));
219
- add_action('woocommerce_order_status_pending_to_on-hold_notification', array(&$this, 'ac_email_admin_recovery'));
220
- add_action('woocommerce_order_status_failed_to_processing_notification', array(&$this, 'ac_email_admin_recovery'));
221
- add_action('woocommerce_order_status_failed_to_completed_notification', array(&$this, 'ac_email_admin_recovery'));
222
- add_action( 'admin_init', array( $this, 'wcap_preview_emails' ) );
223
- add_action('init', array( $this, 'app_output_buffer') );
224
- }
225
-
226
- /*-----------------------------------------------------------------------------------*/
227
- /* Class Functions */
228
- /*-----------------------------------------------------------------------------------*/
229
- /**
230
- * Preview email template
231
- *
232
- * @return string
233
- */
234
- public function wcap_preview_emails() {
235
-
236
- global $woocommerce;
237
-
238
- if ( isset( $_GET['wacp_preview_woocommerce_mail'] ) ) {
239
- if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-ac') ) {
240
- die( 'Security check' );
241
- }
242
-
243
- $message = '';
244
- // create a new email
245
-
246
- if ( $woocommerce->version < '2.3' ) {
247
- global $email_heading;
248
-
249
- ob_start();
250
-
251
- include( 'views/wacp-wc-email-template-preview.php' );
252
-
253
- $mailer = WC()->mailer();
254
- $message = ob_get_clean();
255
- $email_heading = __( 'HTML Email Template', 'woocommerce' );
256
-
257
- $message = $mailer->wrap_message( $email_heading, $message );
258
- }else{
259
-
260
- // load the mailer class
261
- $mailer = WC()->mailer();
262
-
263
- // get the preview email subject
264
- $email_heading = __( 'Abandoned cart Email Template', 'woocommerce-ac' );
265
-
266
- // get the preview email content
267
- ob_start();
268
- include( 'views/wacp-wc-email-template-preview.php' );
269
- $message = ob_get_clean();
270
-
271
- // create a new email
272
- $email = new WC_Email();
273
-
274
- // wrap the content with the email template and then add styles
275
- $message = $email->style_inline( $mailer->wrap_message( $email_heading, $message ) );
276
- }
277
 
278
- echo $message;
279
- exit;
280
- }
281
-
282
- if ( isset( $_GET['wacp_preview_mail'] ) ) {
283
- if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-ac') ) {
284
- die( 'Security check' );
285
- }
286
-
287
- // get the preview email content
288
- ob_start();
289
- include( 'views/wacp-email-template-preview.php' );
290
- $message = ob_get_clean();
291
-
292
- // print the preview email
293
- echo $message;
294
- exit;
295
- }
296
- }
297
  // Language Translation
298
- function update_po_file() {
299
- $domain = 'woocommerce-ac';
300
- $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
301
- if ( $loaded = load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '-' . $locale . '.mo' ) ) {
302
- return $loaded;
303
- } else {
304
- load_plugin_textdomain( $domain, FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
305
- }
306
- }
307
-
308
- function ac_lite_coupon_notice() {
309
-
310
- if ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == "woocommerce_ac_page" ) {
311
- ?>
312
- <div class = "updated">
313
- <p><?php _e( 'You can upgrade to the <a href = "https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/">PRO version of WooCommerce Abandoned Cart plugin</a> at a <b>20% discount</b>. Use the coupon code: <b>ACPRO20</b>.<a href="https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/"> Purchase now </a> & save $24!', 'woocommerce-ac' ); ?></p>
314
- </div>
315
- <?php
316
- }
317
- }
318
- /*-----------------------------------------------------------------------------------*/
319
- /* Class Functions */
320
- /*-----------------------------------------------------------------------------------*/
321
-
322
- function woocommerce_ac_activate() {
323
 
324
- global $wpdb;
325
-
326
- $table_name = $wpdb->prefix . "ac_email_templates_lite";
327
 
328
- $sql = "CREATE TABLE IF NOT EXISTS $table_name (
329
- `id` int(11) NOT NULL AUTO_INCREMENT,
330
- `subject` text COLLATE utf8_unicode_ci NOT NULL,
331
- `body` mediumtext COLLATE utf8_unicode_ci NOT NULL,
332
- `is_active` enum('0','1') COLLATE utf8_unicode_ci NOT NULL,
333
- `frequency` int(11) NOT NULL,
334
- `day_or_hour` enum('Days','Hours') COLLATE utf8_unicode_ci NOT NULL,
335
- `template_name` text COLLATE utf8_unicode_ci NOT NULL,
336
- `from_name` text COLLATE utf8_unicode_ci NOT NULL,
337
- PRIMARY KEY (`id`)
338
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ";
339
 
340
- require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' );
341
- dbDelta( $sql );
342
-
343
-
344
- $table_name = $wpdb->prefix . "ac_email_templates_lite";
345
- $check_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'is_wc_template' ";
346
- $results = $wpdb->get_results( $check_template_table_query );
347
-
348
- if ( count( $results ) == 0 ) {
349
- $alter_template_table_query = "ALTER TABLE $table_name
350
- ADD COLUMN `is_wc_template` enum('0','1') COLLATE utf8_unicode_ci NOT NULL AFTER `from_name`,
351
- ADD COLUMN `default_template` int(11) NOT NULL AFTER `is_wc_template`";
352
-
353
- $wpdb->get_results( $alter_template_table_query );
354
- }
355
- $table_name = $wpdb->prefix . "ac_email_templates_lite";
356
- $check_email_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'reply_email' ";
357
- $results_email = $wpdb->get_results( $check_email_template_table_query );
358
-
359
- if ( count( $results_email ) == 0 ) {
360
- $alter_email_template_table_query = "ALTER TABLE $table_name
361
- ADD COLUMN `reply_email` varchar(50) COLLATE utf8_unicode_ci NOT NULL AFTER `default_template`,
362
- ADD COLUMN `from_email` varchar(50) COLLATE utf8_unicode_ci NOT NULL AFTER `reply_email`";
363
- $wpdb->get_results( $alter_email_template_table_query );
364
- }
365
-
366
- $sent_table_name = $wpdb->prefix . "ac_sent_history_lite";
367
 
368
- $sql_query = "CREATE TABLE IF NOT EXISTS $sent_table_name (
369
- `id` int(11) NOT NULL auto_increment,
370
- `template_id` varchar(40) collate utf8_unicode_ci NOT NULL,
371
- `abandoned_order_id` int(11) NOT NULL,
372
- `sent_time` datetime NOT NULL,
373
- `sent_email_id` text COLLATE utf8_unicode_ci NOT NULL,
374
- PRIMARY KEY (`id`)
375
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ";
376
-
377
- require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' );
378
- dbDelta ( $sql_query );
379
-
380
- $ac_history_table_name = $wpdb->prefix . "ac_abandoned_cart_history_lite";
381
-
382
- $history_query = "CREATE TABLE IF NOT EXISTS $ac_history_table_name (
383
- `id` int(11) NOT NULL AUTO_INCREMENT,
384
- `user_id` int(11) NOT NULL,
385
- `abandoned_cart_info` text COLLATE utf8_unicode_ci NOT NULL,
386
- `abandoned_cart_time` int(11) NOT NULL,
387
- `cart_ignored` enum('0','1') COLLATE utf8_unicode_ci NOT NULL,
388
- `recovered_cart` int(11) NOT NULL,
389
- PRIMARY KEY (`id`)
390
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
391
-
392
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
393
- dbDelta( $history_query );
394
-
395
- // Default templates: function call to create default templates.
396
- $check_table_empty = $wpdb->get_var( "SELECT COUNT(*) FROM `" . $wpdb->prefix . "ac_email_templates_lite`" );
397
-
398
- if( !get_option( 'woocommerce_ac_default_templates_installed' ) ) {
399
 
400
- if( 0 == $check_table_empty ) {
401
- $default_template = new default_template_settings;
402
- $default_template->create_default_templates();
403
- update_option( 'woocommerce_ac_default_templates_installed', "yes" );
404
- }
405
- }
406
- }
407
-
408
-
409
- /***************************************************************
410
- * WP Settings API
411
- **************************************************************/
412
- function ac_lite_initialize_plugin_options() {
413
- // First, we register a section. This is necessary since all future options must belong to a
414
- add_settings_section(
415
- 'ac_lite_general_settings_section', // ID used to identify this section and with which to register options
416
- __( 'Settings', 'woocommerce-ac' ), // Title to be displayed on the administration page
417
- array($this, 'ac_lite_general_options_callback' ), // Callback used to render the description of the section
418
- 'woocommerce_ac_page' // Page on which to add this section of options
419
- );
420
-
421
- add_settings_field(
422
- 'ac_lite_cart_abandoned_time',
423
- __( 'Cart abandoned cut-off time', 'woocommerce-ac' ),
424
- array( $this, 'ac_lite_cart_abandoned_time_callback' ),
425
- 'woocommerce_ac_page',
426
- 'ac_lite_general_settings_section',
427
- array( __( 'Consider cart abandoned after X minutes of item being added to cart & order not placed.', 'woocommerce-ac' ) )
428
- );
429
-
430
- add_settings_field(
431
- 'ac_lite_email_admin_on_recovery',
432
- __( 'Email admin On Order Recovery', 'woocommerce-ac' ),
433
- array( $this, 'ac_lite_email_admin_on_recovery' ),
434
- 'woocommerce_ac_page',
435
- 'ac_lite_general_settings_section',
436
- array( __( 'Sends email to Admin if an Abandoned Cart Order is recovered.', 'woocommerce-ac' ) )
437
- );
438
 
439
- // Finally, we register the fields with WordPress
440
- register_setting(
441
- 'woocommerce_ac_settings',
442
- 'ac_lite_cart_abandoned_time',
443
- array ( $this, 'ac_lite_cart_time_validation' )
444
- );
 
 
 
 
 
 
445
 
446
- register_setting(
447
- 'woocommerce_ac_settings',
448
- 'ac_lite_email_admin_on_recovery'
449
- );
450
-
451
- }
452
-
453
- /***************************************************************
454
- * WP Settings API callback for section
455
- **************************************************************/
456
- function ac_lite_general_options_callback() {
457
-
458
- }
459
-
460
- /***************************************************************
461
- * WP Settings API callback for cart time field
462
- **************************************************************/
463
- function ac_lite_cart_abandoned_time_callback($args) {
464
-
465
- // First, we read the option
466
- $cart_abandoned_time = get_option( 'ac_lite_cart_abandoned_time' );
467
-
468
- // Next, we update the name attribute to access this element's ID in the context of the display options array
469
- // We also access the show_header element of the options collection in the call to the checked() helper function
470
- printf(
471
- '<input type="text" id="ac_lite_cart_abandoned_time" name="ac_lite_cart_abandoned_time" value="%s" />',
472
- isset( $cart_abandoned_time ) ? esc_attr( $cart_abandoned_time ) : ''
473
- );
474
-
475
- // Here, we'll take the first argument of the array and add it to a label next to the checkbox
476
- $html = '<label for="ac_lite_cart_abandoned_time"> ' . $args[0] . '</label>';
477
- echo $html;
478
- }
479
-
480
- /***************************************************************
481
- * WP Settings API cart time field validation
482
- **************************************************************/
483
- function ac_lite_cart_time_validation( $input ) {
484
- $output = '';
485
- if ( $input == '' || is_numeric( $input) ) {
486
- $output = stripslashes( $input) ;
487
- } else {
488
- add_settings_error( 'ac_lite_cart_abandoned_time', 'error found', __( 'Abandoned cart cut off time should be numeric.', 'woocommerce-ac' ) );
489
- }
490
- return $output;
491
- }
492
-
493
- /***************************************************************
494
- * WP Settings API callback for email admin on cart recovery field
495
- **************************************************************/
496
- function ac_lite_email_admin_on_recovery( $args ) {
497
-
498
- // First, we read the option
499
- $email_admin_on_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
500
-
501
- // This condition added to avoid the notie displyed while Check box is unchecked.
502
- if ( isset( $email_admin_on_recovery ) && $email_admin_on_recovery == '' ) {
503
- $email_admin_on_recovery = 'off';
504
- }
505
-
506
- // Next, we update the name attribute to access this element's ID in the context of the display options array
507
- // We also access the show_header element of the options collection in the call to the checked() helper function
508
- $html='';
509
- printf(
510
- '<input type="checkbox" id="ac_lite_email_admin_on_recovery" name="ac_lite_email_admin_on_recovery" value="on"
511
- ' . checked('on', $email_admin_on_recovery, false).' />'
512
- );
513
-
514
- // Here, we'll take the first argument of the array and add it to a label next to the checkbox
515
- $html .= '<label for="ac_lite_email_admin_on_recovery"> ' . $args[0] . '</label>';
516
- echo $html;
517
- }
518
-
519
- /**************************************************
520
- * This function is run when the plugin is upgraded
521
- *************************************************/
522
-
523
- function ac_lite_update_db_check() {
524
- global $wpdb;
525
-
526
- if( get_option( 'ac_lite_delete_alter_table_queries' ) != 'yes' ) {
527
- update_option( 'ac_lite_alter_table_queries', '' );
528
- update_option( 'ac_lite_delete_alter_table_queries', 'yes' );
529
- }
530
- if( get_option( 'ac_lite_alter_table_queries' ) != 'yes' ) {
531
- if( $wpdb->get_var( "SHOW TABLES LIKE '" . $wpdb->prefix . "ac_email_templates'" ) === $wpdb->prefix . 'ac_email_templates' ) {
532
- $old_table_name = $wpdb->prefix . "ac_email_templates";
533
- $table_name = $wpdb->prefix . "ac_email_templates_lite";
534
-
535
- $alter_ac_email_table_query = "ALTER TABLE $old_table_name
536
- RENAME TO $table_name";
537
- $wpdb->get_results ( $alter_ac_email_table_query );
538
-
539
- }
540
-
541
- if( $wpdb->get_var( "SHOW TABLES LIKE '" . $wpdb->prefix . "ac_sent_history'" ) === $wpdb->prefix . 'ac_sent_history' ) {
542
- $old_sent_table_name = $wpdb->prefix . "ac_sent_history";
543
- $sent_table_name = $wpdb->prefix . "ac_sent_history_lite";
544
- $alter_ac_sent_history_table_query = "ALTER TABLE $old_sent_table_name
545
- RENAME TO $sent_table_name";
546
- $wpdb->get_results ( $alter_ac_sent_history_table_query );
547
- }
548
-
549
- if( $wpdb->get_var( "SHOW TABLES LIKE '" . $wpdb->prefix . "ac_abandoned_cart_history'" ) === $wpdb->prefix . 'ac_abandoned_cart_history' ) {
550
- $old_ac_history_table_name = $wpdb->prefix . "ac_abandoned_cart_history";
551
- $ac_history_table_name = $wpdb->prefix . "ac_abandoned_cart_history_lite";
552
-
553
- $alter_ac_abandoned_cart_history_table_query = "ALTER TABLE $old_ac_history_table_name
554
- RENAME TO $ac_history_table_name";
555
- $wpdb->get_results ( $alter_ac_abandoned_cart_history_table_query );
556
- }
557
-
558
- update_option( 'ac_lite_alter_table_queries', 'yes' );
559
- }
560
-
561
- $ac_history_table_name = $wpdb->prefix."ac_abandoned_cart_history_lite";
562
- $check_table_query = "SHOW COLUMNS FROM $ac_history_table_name LIKE 'user_type'";
563
- $results = $wpdb->get_results( $check_table_query );
564
-
565
- if ( count( $results ) == 0 ) {
566
- $alter_table_query = "ALTER TABLE $ac_history_table_name ADD `user_type` text AFTER `recovered_cart`";
567
- $wpdb->get_results( $alter_table_query );
568
- }
569
-
570
- $table_name = $wpdb->prefix . "ac_email_templates_lite";
571
- $check_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'is_wc_template' ";
572
- $results = $wpdb->get_results( $check_template_table_query );
573
-
574
- if ( count( $results ) == 0 ) {
575
- $alter_template_table_query = "ALTER TABLE $table_name
576
- ADD COLUMN `is_wc_template` enum('0','1') COLLATE utf8_unicode_ci NOT NULL AFTER `from_name`,
577
- ADD COLUMN `default_template` int(11) NOT NULL AFTER `is_wc_template`";
578
- $wpdb->get_results( $alter_template_table_query );
579
- }
580
- $table_name = $wpdb->prefix . "ac_email_templates_lite";
581
- $check_email_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'reply_email' ";
582
- $results_email = $wpdb->get_results( $check_email_template_table_query );
583
-
584
- if ( count( $results_email ) == 0 ) {
585
- $alter_email_template_table_query = "ALTER TABLE $table_name
586
- ADD COLUMN `reply_email` varchar(50) COLLATE utf8_unicode_ci NOT NULL AFTER `default_template`,
587
- ADD COLUMN `from_email` varchar(50) COLLATE utf8_unicode_ci NOT NULL AFTER `reply_email`";
588
- $wpdb->get_results( $alter_email_template_table_query );
589
- }
590
- $guest_table = $wpdb->prefix."ac_guest_abandoned_cart_history_lite" ;
591
- $query_guest_table = "SHOW TABLES LIKE '$guest_table' ";
592
- $result_guest_table = $wpdb->get_results( $query_guest_table );
593
-
594
- if ( count( $result_guest_table ) == 0 ) {
595
-
596
- $ac_guest_history_table_name = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
597
- $ac_guest_history_query = "CREATE TABLE IF NOT EXISTS $ac_guest_history_table_name (
598
- `id` int(15) NOT NULL AUTO_INCREMENT,
599
- `billing_first_name` text,
600
- `billing_last_name` text,
601
- `billing_company_name` text,
602
- `billing_address_1` text,
603
- `billing_address_2` text,
604
- `billing_city` text,
605
- `billing_county` text,
606
- `billing_zipcode` text,
607
- `email_id` text,
608
- `phone` text,
609
- `ship_to_billing` text,
610
- `order_notes` text,
611
- `shipping_first_name` text,
612
- `shipping_last_name` text,
613
- `shipping_company_name` text,
614
- `shipping_address_1` text,
615
- `shipping_address_2` text,
616
- `shipping_city` text,
617
- `shipping_county` text,
618
- `shipping_zipcode` double,
619
- `shipping_charges` double,
620
- PRIMARY KEY (`id`)
621
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=63000000";
622
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php');
623
- $wpdb->query( $ac_guest_history_query );
624
- }
625
-
626
- //get the option, if it is not set to individual then convert to individual records and delete the base record
627
- $ac_settings = get_option( 'ac_lite_settings_status' );
628
- if ( $ac_settings != 'INDIVIDUAL' ) {
629
- //fetch the existing settings and save them as inidividual to be used for the settings API
630
- $woocommerce_ac_settings = json_decode( get_option( 'woocommerce_ac_settings' ) );
631
- if( isset($woocommerce_ac_settings[0]->cart_time) ){
632
- add_option( 'ac_lite_cart_abandoned_time', $woocommerce_ac_settings[0]->cart_time );
633
- }else{
634
- add_option( 'ac_lite_cart_abandoned_time', '60' );
635
- }
636
-
637
- if( isset($woocommerce_ac_settings[0]->email_admin) ){
638
- add_option( 'ac_lite_email_admin_on_recovery', $woocommerce_ac_settings[0]->email_admin );
639
- }else{
640
- add_option( 'ac_lite_email_admin_on_recovery', "" );
641
- }
642
-
643
- update_option( 'ac_lite_settings_status', 'INDIVIDUAL' );
644
- //Delete the main settings record
645
- delete_option( 'woocommerce_ac_settings' );
646
- }
647
-
648
- }
649
-
650
- /******
651
- * Send email to admin when cart is recover.
652
- * @since 2.3 version
653
- */
654
-
655
- function ac_email_admin_recovery ($order_id) {
656
-
657
- $user_id = get_current_user_id();
658
-
659
- $ac_email_admin_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
660
-
661
- if( $ac_email_admin_recovery == 'on' ){
662
- if ( get_user_meta($user_id, '_woocommerce_ac_modified_cart', true) == md5("yes") || get_user_meta($user_id, '_woocommerce_ac_modified_cart', true) == md5("no") ){ // indicates cart is abandoned
663
- $order = new WC_Order( $order_id );
664
-
665
- $email_heading = __('New Customer Order - Recovered', 'woocommerce-ac');
666
-
667
- $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
668
-
669
- $email_subject = "New Customer Order - Recovered";
670
-
671
- $user_email = get_option('admin_email');
672
- $headers[] = "From: Admin <".$user_email.">";
673
- $headers[] = "Content-Type: text/html";
674
-
675
- // Buffer
676
- ob_start();
677
-
678
- // Get mail template
679
- woocommerce_get_template('emails/admin-new-order.php', array(
680
- 'order' => $order,
681
- 'email_heading' => $email_heading,
682
- 'sent_to_admin' => false,
683
- 'plain_text' => false
684
- ));
685
-
686
- // Get contents
687
- $email_body = ob_get_clean();
688
-
689
- //$email_body .= "Recovered Order";
690
- woocommerce_mail( $user_email, $email_subject, $email_body, $headers );
691
- }
692
- }
693
-
694
- }
695
-
696
- function woocommerce_ac_admin_menu() {
697
 
698
- $page = add_submenu_page ( 'woocommerce', __( 'Abandoned Carts', 'woocommerce-ac' ), __( 'Abandoned Carts', 'woocommerce-ac' ), 'manage_woocommerce', 'woocommerce_ac_page', array( &$this, 'woocommerce_ac_page' ) );
 
 
 
 
 
 
 
699
 
700
- }
 
 
 
 
 
 
 
 
701
 
702
- function woocommerce_ac_store_cart_timestamp() {
703
-
704
- global $wpdb,$woocommerce;
705
-
706
- $current_time = current_time( 'timestamp' );
707
- $cut_off_time = get_option( 'ac_lite_cart_abandoned_time' );
708
-
709
- $cart_ignored = 0;
710
- $recovered_cart = 0;
711
-
712
- if( isset( $cut_off_time ) ) {
713
- $cart_cut_off_time = $cut_off_time * 60;
714
- } else {
715
- $cart_cut_off_time = 60 * 60;
716
- }
717
-
718
- $compare_time = $current_time - $cart_cut_off_time;
719
-
720
- if ( is_user_logged_in() ) {
721
-
722
- $user_id = get_current_user_id();
723
- $query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
724
- WHERE user_id = %d
725
- AND cart_ignored = %s
726
- AND recovered_cart = %d ";
727
- $results = $wpdb->get_results($wpdb->prepare( $query, $user_id, $cart_ignored, $recovered_cart ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
728
 
729
- if ( count($results) == 0 ) {
 
 
 
 
 
 
 
 
 
 
730
 
731
- $cart_info = json_encode( get_user_meta( $user_id, '_woocommerce_persistent_cart', true ) );
732
- $user_type = "REGISTERED";
733
- $insert_query = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
734
- ( user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type )
735
- VALUES ( %d, %s, %d, %s, %s )";
736
- $wpdb->query( $wpdb->prepare( $insert_query, $user_id, $cart_info,$current_time, $cart_ignored, $user_type ) );
737
- }
738
- elseif ( isset( $results[0]->abandoned_cart_time ) && $compare_time > $results[0]->abandoned_cart_time ) {
739
-
740
- $updated_cart_info = json_encode( get_user_meta( $user_id, '_woocommerce_persistent_cart', true ) );
741
-
742
- if ( ! $this->compare_carts( $user_id, $results[0]->abandoned_cart_info ) ) {
743
-
744
- $updated_cart_ignored = 1;
745
- $query_ignored = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
746
- SET cart_ignored = %s
747
- WHERE user_id = %d ";
748
- $wpdb->query( $wpdb->prepare( $query_ignored, $updated_cart_ignored, $user_id ) );
749
-
750
- $user_type = "REGISTERED";
751
-
752
- $query_update = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
753
- (user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type)
754
- VALUES (%d, %s, %d, %s, %s)";
755
- $wpdb->query( $wpdb->prepare( $query_update, $user_id, $updated_cart_info, $current_time, $cart_ignored, $user_type ) );
756
-
757
- update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "yes" ) );
758
- } else {
759
- update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "no" ) );
760
- }
761
- } else {
762
- $updated_cart_info = json_encode( get_user_meta( $user_id, '_woocommerce_persistent_cart', true ) );
763
 
764
- $query_update = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
765
- SET abandoned_cart_info = %s,
766
- abandoned_cart_time = %d
767
- WHERE user_id = %d
768
- AND cart_ignored = %s ";
769
- $wpdb->query( $wpdb->prepare( $query_update, $updated_cart_info, $current_time, $user_id, $cart_ignored ) );
770
- }
771
- } else{ //start here guest user
772
-
773
- if ( isset( $_SESSION['user_id'] ) ) $user_id = $_SESSION['user_id'];
774
- else $user_id = "";
775
-
776
- $query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id = %d AND cart_ignored = '0' AND recovered_cart = '0'";
777
- $results = $wpdb->get_results( $wpdb->prepare( $query, $user_id ) );
778
- $cart = array();
779
-
780
- foreach ( $woocommerce->cart->cart_contents as $cart_id => $value ) {
781
- $cart['cart'][$cart_id] = array();
782
-
783
- foreach ( $value as $k=>$v ) {
784
- $cart['cart'][$cart_id][$k] = $v;
785
-
786
- if ( $k == "quantity" ) {
787
- $price = get_post_meta( $cart['cart'][$cart_id]['product_id'], '_price', true );
788
- $cart['cart'][$cart_id]['line_total'] = $cart['cart'][$cart_id]['quantity'] * $price;
789
- $cart['cart'][$cart_id]['line_tax'] = '0';
790
- $cart['cart'][$cart_id]['line_subtotal'] = $cart['cart'][$cart_id]['line_total'];
791
- $cart['cart'][$cart_id]['line_subtotal_tax'] = $cart['cart'][$cart_id]['line_tax'];
792
- break;
793
- }
794
- }
795
- }
796
- $updated_cart_info = json_encode($cart);
797
-
798
- if ( $results ) {
799
-
800
- if ( $compare_time > $results[0]->abandoned_cart_time ) {
801
-
802
- if ( $updated_cart_info != $results[0]->abandoned_cart_info ) {
803
- $query_ignored = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite` SET cart_ignored = '1' WHERE user_id ='".$user_id."'";
804
-
805
- $wpdb->query( $query_ignored );
806
- $user_type = 'GUEST';
807
-
808
- $query_update = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
809
- (user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type)
810
- VALUES (%d, %s, %d, %s, %s)";
811
- $wpdb->query( $wpdb->prepare( $query_update, $user_id, $updated_cart_info, $current_time, $cart_ignored, $user_type ) );
812
-
813
-
814
- $wpdb->query( $query_update );
815
- update_user_meta( $user_id, '_woocommerce_ac_modified_cart', md5("yes") );
816
- } else {
817
- update_user_meta( $user_id, '_woocommerce_ac_modified_cart', md5("no") );
818
- }
819
- } else {
820
- $query_update = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite` SET abandoned_cart_info = '".$updated_cart_info."', abandoned_cart_time = '".$current_time."' WHERE user_id='".$user_id."' AND cart_ignored='0' ";
821
- $wpdb->query( $query_update );
822
- }
823
- }
824
- }
825
-
826
-
827
- }
828
-
829
- function decrypt_validate( $validate ) {
830
- $cryptKey = 'qJB0rGtIn5UB1xG03efyCp';
831
- $validate_decoded = rtrim( mcrypt_decrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), base64_decode( $validate ), MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ), "\0");
832
- return( $validate_decoded );
833
- }
834
-
835
- function email_track_links_lite( $template ) {
836
- global $woocommerce;
837
- $track_link = '';
838
-
839
- if ( isset( $_GET['wacp_action'] ) ) $track_link = $_GET['wacp_action'];
840
-
841
- if ( $track_link == 'track_links' ) {
842
- global $wpdb;
843
-
844
- $validate_server_string = rawurldecode ( $_SERVER["QUERY_STRING"] );
845
- $validate_server_string = str_replace ( " " , "+", $validate_server_string);
846
-
847
- $validate_server_arr = explode("validate=", $validate_server_string);
848
- $validate_encoded_string = end($validate_server_arr);
849
-
850
- $link_decode_test = base64_decode( $validate_encoded_string );
851
-
852
- if ( preg_match( '/&url=/', $link_decode_test ) ){ // it will check if any old email have open the link
853
- $link_decode = $link_decode_test;
854
- }else{
855
- $link_decode = $this->decrypt_validate( $validate_encoded_string );
856
- }
857
- $sent_email_id_pos = strpos( $link_decode, '&' );
858
- $email_sent_id = substr( $link_decode , 0, $sent_email_id_pos );
859
- $_SESSION[ 'email_sent_id' ] = $email_sent_id;
860
- $url_pos = strpos( $link_decode, '=' );
861
- $url_pos = $url_pos + 1;
862
- $url = substr( $link_decode, $url_pos );
863
- $get_ac_id_query = "SELECT abandoned_order_id FROM `".$wpdb->prefix."ac_sent_history_lite` WHERE id = %d";
864
- $get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query, $email_sent_id ) );
865
- $get_user_id_query = "SELECT user_id FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE id = %d";
866
- $get_user_results = $wpdb->get_results( $wpdb->prepare( $get_user_id_query, $get_ac_id_results[0]->abandoned_order_id ) );
867
- $user_id = 0;
868
-
869
- if ( isset( $get_user_results ) && count( $get_user_results ) > 0 ) {
870
- $user_id = $get_user_results[0]->user_id;
871
- }
872
-
873
- if ( $user_id == 0 ) {
874
- echo "Link expired";
875
- exit;
876
- }
877
- $user = wp_set_current_user( $user_id );
878
-
879
-
880
-
881
- if ( $user_id >= "63000000" ) {
882
- $query_guest = "SELECT * from `". $wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d";
883
- $results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $user_id ) );
884
- $query_cart = "SELECT recovered_cart FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id = %d";
885
- $results = $wpdb->get_results( $wpdb->prepare( $query_cart, $user_id ) );
886
-
887
- if ( $results_guest && $results[0]->recovered_cart == '0' ) {
888
- $_SESSION[ 'guest_first_name' ] = $results_guest[0]->billing_first_name;
889
- $_SESSION[ 'guest_last_name' ] = $results_guest[0]->billing_last_name;
890
- $_SESSION[ 'guest_email' ] = $results_guest[0]->email_id;
891
- $_SESSION[ 'user_id' ] = $user_id;
892
- } else {
893
- wp_redirect( get_permalink( woocommerce_get_page_id( 'shop' ) ) );
894
- }
895
- }
896
-
897
- if ( $user_id < "63000000" ) {
898
- $user_login = $user->data->user_login;
899
- wp_set_auth_cookie( $user_id );
900
- $my_temp = woocommerce_load_persistent_cart( $user_login, $user );
901
- do_action( 'wp_login', $user_login, $user );
902
-
903
- if ( isset( $sign_in ) && is_wp_error( $sign_in ) ) {
904
- echo $sign_in->get_error_message();
905
- exit;
906
- }
907
- } else
908
- $my_temp = $this->woocommerce_load_guest_persistent_cart( $user_id );
909
-
910
- if ( $email_sent_id > 0 && is_numeric( $email_sent_id ) ) {
911
-
912
- header( "Location: $url" );
913
- }
914
- } else
915
- return $template;
916
- }
917
-
918
- function woocommerce_load_guest_persistent_cart() {
919
- global $woocommerce;
920
-
921
-
922
- $saved_cart = json_decode( get_user_meta( $_SESSION['user_id'], '_woocommerce_persistent_cart',true ), true );
923
-
924
- $c = array();
925
- $cart_contents_total = $cart_contents_weight = $cart_contents_count = $cart_contents_tax = $total = $subtotal = $subtotal_ex_tax = $tax_total = 0;
926
-
927
- foreach ( $saved_cart as $key => $value ) {
928
-
929
- foreach ( $value as $a => $b ) {
930
- $c['product_id'] = $b['product_id'];
931
- $c['variation_id'] = $b['variation_id'];
932
- $c['variation'] = $b['variation'];
933
- $c['quantity'] = $b['quantity'];
934
- $product_id = $b['product_id'];
935
- $c['data'] = get_product($product_id);
936
- $c['line_total'] = $b['line_total'];
937
- $c['line_tax'] = $cart_contents_tax;
938
- $c['line_subtotal'] = $b['line_subtotal'];
939
- $c['line_subtotal_tax'] = $cart_contents_tax;
940
- $value_new[$a] = $c;
941
- $cart_contents_total = $b['line_subtotal'] + $cart_contents_total;
942
- $cart_contents_count = $cart_contents_count + $b['quantity'];
943
- $total = $total + $b['line_total'];
944
- $subtotal = $subtotal + $b['line_subtotal'];
945
- $subtotal_ex_tax = $subtotal_ex_tax + $b['line_subtotal'];
946
- }
947
- $saved_cart_data[$key] = $value_new;
948
- $woocommerce_cart_hash = $a;
949
- }
950
-
951
- if ( $saved_cart ) {
952
-
953
- if ( empty( $woocommerce->session->cart ) || ! is_array( $woocommerce->session->cart ) || sizeof( $woocommerce->session->cart ) == 0 ) {
954
- $woocommerce->session->cart = $saved_cart['cart'];
955
- $woocommerce->session->cart_contents_total = $cart_contents_total;
956
- $woocommerce->session->cart_contents_weight = $cart_contents_weight;
957
- $woocommerce->session->cart_contents_count = $cart_contents_count;
958
- $woocommerce->session->cart_contents_tax = $cart_contents_tax;
959
- $woocommerce->session->total = $total;
960
- $woocommerce->session->subtotal = $subtotal;
961
- $woocommerce->session->subtotal_ex_tax = $subtotal_ex_tax;
962
- $woocommerce->session->tax_total = $tax_total;
963
- $woocommerce->session->shipping_taxes = array();
964
- $woocommerce->session->taxes = array();
965
- $woocommerce->session->ac_customer = array();
966
- $woocommerce->cart->cart_contents = $saved_cart_data['cart'];
967
- $woocommerce->cart->cart_contents_total = $cart_contents_total;
968
- $woocommerce->cart->cart_contents_weight = $cart_contents_weight;
969
- $woocommerce->cart->cart_contents_count = $cart_contents_count;
970
- $woocommerce->cart->cart_contents_tax = $cart_contents_tax;
971
- $woocommerce->cart->total = $total;
972
- $woocommerce->cart->subtotal = $subtotal;
973
- $woocommerce->cart->subtotal_ex_tax = $subtotal_ex_tax;
974
- $woocommerce->cart->tax_total = $tax_total;
975
- }
976
- }
977
- }
978
-
979
-
980
- function compare_carts( $user_id, $last_abandoned_cart )
981
- {
982
- $current_woo_cart = get_user_meta( $user_id, '_woocommerce_persistent_cart', true );
983
- $abandoned_cart_arr = json_decode( $last_abandoned_cart, true );
984
-
985
- $temp_variable = "";
986
- if ( count( $current_woo_cart['cart'] ) >= count( $abandoned_cart_arr['cart'] ) ) {
987
- //do nothing
988
- } else {
989
- $temp_variable = $current_woo_cart;
990
- $current_woo_cart = $abandoned_cart_arr;
991
- $abandoned_cart_arr = $temp_variable;
992
- }
993
- foreach ( $current_woo_cart as $key => $value )
994
- {
995
- foreach ( $value as $item_key => $item_value )
996
- {
997
- $current_cart_product_id = $item_value['product_id'];
998
- $current_cart_variation_id = $item_value['variation_id'];
999
- $current_cart_quantity = $item_value['quantity'];
1000
-
1001
- if ( isset( $abandoned_cart_arr[ $key ][ $item_key ][ 'product_id' ] ) ) {
1002
- $abandoned_cart_product_id = $abandoned_cart_arr[$key][$item_key]['product_id'];
1003
- } else {
1004
- $abandoned_cart_product_id = "";
1005
- }
1006
- if ( isset( $abandoned_cart_arr[$key][$item_key]['variation_id'] ) ) {
1007
- $abandoned_cart_variation_id = $abandoned_cart_arr[$key][$item_key]['variation_id'];
1008
- } else {
1009
- $abandoned_cart_variation_id = "";
1010
- }
1011
- if ( isset( $abandoned_cart_arr[$key][$item_key]['quantity'] ) ) {
1012
- $abandoned_cart_quantity = $abandoned_cart_arr[$key][$item_key]['quantity'];
1013
- } else {
1014
- $abandoned_cart_quantity = "";
1015
- }
1016
- if ( ( $current_cart_product_id != $abandoned_cart_product_id ) ||
1017
- ( $current_cart_variation_id != $abandoned_cart_variation_id ) ||
1018
- ( $current_cart_quantity != $abandoned_cart_quantity ) )
1019
- {
1020
- return false;
1021
- }
1022
- }
1023
- }
1024
- return true;
1025
- }
1026
-
1027
- function action_after_delivery_session( $order ) {
1028
-
1029
- global $wpdb;
1030
- $user_id = get_current_user_id();
1031
- $sent_email = '';
1032
- if ( isset( $_SESSION[ 'email_sent_id' ] ) ){
1033
- $sent_email = $_SESSION[ 'email_sent_id' ];
1034
- }
1035
- if ( $user_id == "" ) {
1036
- $user_id = $_SESSION['user_id'];
1037
- // Set the session variables to blanks
1038
- $_SESSION['guest_first_name'] = $_SESSION['guest_last_name'] = $_SESSION['guest_email'] = $_SESSION['user_id'] = "";
1039
- }
1040
-
1041
- delete_user_meta( $user_id, '_woocommerce_ac_persistent_cart_time' );
1042
- delete_user_meta( $user_id, '_woocommerce_ac_persistent_cart_temp_time' );
1043
-
1044
- // get all latest abandoned carts that were modified
1045
-
1046
- $cart_ignored = 0;
1047
- $recovered_cart = 0;
1048
- $query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1049
- WHERE user_id = %d
1050
- AND cart_ignored = %s
1051
- AND recovered_cart = %d
1052
- ORDER BY id DESC
1053
- LIMIT 1";
1054
- $results = $wpdb->get_results( $wpdb->prepare( $query, $user_id, $cart_ignored, $recovered_cart ) );
1055
- if ( count( $results ) > 0 ) {
1056
- if ( get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true ) == md5( "yes" ) ||
1057
- get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true ) == md5( "no" ) )
1058
- {
1059
- $order_id = $order->id;
1060
-
1061
- $updated_cart_ignored = 1;
1062
- $query_order = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1063
- SET recovered_cart = %d,
1064
- cart_ignored = %s
1065
- WHERE id = %d ";
1066
- $wpdb->query( $wpdb->prepare( $query_order, $order_id, $updated_cart_ignored, $results[0]->id ) );
1067
- delete_user_meta( $user_id, '_woocommerce_ac_modified_cart' );
1068
- } else {
1069
- $delete_query = "DELETE FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1070
- WHERE
1071
- id= %d ";
1072
- $wpdb->query( $wpdb->prepare( $delete_query, $results[0]->id ) );
1073
- }
1074
- }else {
1075
- $email_id = $order->billing_email;
1076
- $query = "SELECT * FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE email_id = %s";
1077
- $results_id = $wpdb->get_results( $wpdb->prepare( $query, $email_id ) );
1078
-
1079
- if ( $results_id ) {
1080
- $record_status = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id = %d AND recovered_cart = '0'";
1081
- $results_status = $wpdb->get_results( $wpdb->prepare( $record_status, $results_id[0]->id ) );
1082
-
1083
- if ( $results_status ) {
1084
-
1085
- if ( get_user_meta( $results_id[0]->id, '_woocommerce_ac_modified_cart', true ) == md5("yes") ||
1086
- get_user_meta( $results_id[0]->id, '_woocommerce_ac_modified_cart', true ) == md5("no") ) {
1087
-
1088
- $order_id = $order->id;
1089
- $query_order = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite` SET recovered_cart= '".$order_id."', cart_ignored = '1' WHERE id='".$results_status[0]->id."' ";
1090
- $wpdb->query( $query_order );
1091
- delete_user_meta( $results_id[0]->id, '_woocommerce_ac_modified_cart' );
1092
-
1093
- $sent_email = $_SESSION[ 'email_sent_id' ];
1094
- $recover_order = "UPDATE `".$wpdb->prefix."ac_sent_history` SET recovered_order = '1'
1095
- WHERE id ='".$sent_email."' ";
1096
- $wpdb->query( $recover_order );
1097
- } else {
1098
- $delete_guest = "DELETE FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = '".$results_id[0]->id."'";
1099
- $wpdb->query( $delete_guest );
1100
-
1101
- $delete_query = "DELETE FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id='".$results_id[0]->id."' ";
1102
- $wpdb->query( $delete_query );
1103
  }
1104
- }
 
 
 
 
 
 
 
 
1105
  }
1106
- }
1107
- }
1108
-
1109
- function action_admin_init() {
1110
- global $typenow;
1111
- // only hook up these filters if we're in the admin panel, and the current user has permission
1112
- // to edit posts and pages
1113
- if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) ) {
1114
- return;
1115
- }
1116
-
1117
- if ( !isset( $_GET['page'] ) || $_GET['page'] != "woocommerce_ac_page" ) {
1118
- return;
1119
- }
1120
-
1121
- if ( get_user_option( 'rich_editing' ) == 'true' ) {
1122
- remove_filter( 'the_excerpt', 'wpautop' );
1123
- add_filter('tiny_mce_before_init', array( &$this, 'myformatTinyMCE_ac'));
1124
- add_filter( 'mce_buttons', array( &$this, 'filter_mce_button' ) );
1125
- add_filter( 'mce_external_plugins', array( &$this, 'filter_mce_plugin' ) );
1126
- }
1127
- }
1128
-
1129
- function filter_mce_button( $buttons ) {
1130
- // add a separation before our button, here our button's id is &quot;mygallery_button&quot;
1131
- array_push( $buttons, 'abandoncart', '|' );
1132
- return $buttons;
1133
- }
1134
-
1135
- function filter_mce_plugin( $plugins ) {
1136
- // this plugin file will work the magic of our button
1137
- $plugins['abandoncart'] = plugin_dir_url( __FILE__ ) . 'js/abandoncart_plugin_button.js';
1138
- return $plugins;
1139
- }
1140
-
1141
- function display_tabs() {
1142
-
1143
- if ( isset( $_GET[ 'action' ] ) ) {
1144
- $action = $_GET[ 'action' ];
1145
- } else {
1146
- $action = "";
1147
- $active_listcart = "";
1148
- $active_emailtemplates = "";
1149
- $active_settings = "";
1150
- $active_stats = "";
1151
- }
1152
- if ( ( $action == 'listcart' || $action == 'orderdetails' ) || $action == '' ) {
1153
- $active_listcart = "nav-tab-active";
1154
- }
1155
- if ( $action == 'emailtemplates' ) {
1156
- $active_emailtemplates = "nav-tab-active";
1157
- }
1158
- if ( $action == 'emailsettings' ) {
1159
- $active_settings = "nav-tab-active";
1160
- }
1161
- if ( $action == 'stats' ) {
1162
- $active_stats = "nav-tab-active";
1163
- }
1164
- if ( $action == 'report' ) {
1165
- $active_report = "nav-tab-active";
1166
- }
1167
-
1168
- ?>
1169
-
1170
- <div style="background-image: url('<?php echo plugins_url(); ?>/woocommerce-abandoned-cart/images/ac_tab_icon.png') !important;" class="icon32"><br></div>
1171
-
1172
- <h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
1173
- <a href="admin.php?page=woocommerce_ac_page&action=listcart" class="nav-tab <?php if (isset($active_listcart)) echo $active_listcart; ?>"> <?php _e( 'Abandoned Orders', 'woocommerce-ac' );?> </a>
1174
- <a href="admin.php?page=woocommerce_ac_page&action=emailtemplates" class="nav-tab <?php if (isset($active_emailtemplates)) echo $active_emailtemplates; ?>"> <?php _e( 'Email Templates', 'woocommerce-ac' );?> </a>
1175
- <a href="admin.php?page=woocommerce_ac_page&action=emailsettings" class="nav-tab <?php if (isset($active_settings)) echo $active_settings; ?>"> <?php _e( 'Settings', 'woocommerce-ac' );?> </a>
1176
- <a href="admin.php?page=woocommerce_ac_page&action=stats" class="nav-tab <?php if (isset($active_stats)) echo $active_stats; ?>"> <?php _e( 'Recovered Orders', 'woocommerce-ac' );?> </a>
1177
- <a href="admin.php?page=woocommerce_ac_page&action=report" class="nav-tab <?php if( isset( $active_report ) ) echo $active_report; ?>"> <?php _e( 'Product Report', 'woocommerce-ac' );?> </a>
1178
- </h2>
1179
-
1180
- <?php
1181
- }
1182
-
1183
- function my_enqueue_scripts_js( $hook ) {
1184
-
1185
- if ( $hook != 'woocommerce_page_woocommerce_ac_page' ) {
1186
- return;
1187
- } else {
1188
- wp_enqueue_script( 'jquery' );
1189
- wp_enqueue_script(
1190
- 'jquery-ui-min',
1191
- '//ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js',
1192
- '',
1193
- '',
1194
- false
1195
- );
1196
- wp_enqueue_script( 'jquery-ui-datepicker' );
1197
-
1198
- wp_enqueue_script(
1199
- 'jquery-tip',
1200
- plugins_url( '/js/jquery.tipTip.minified.js', __FILE__ ),
1201
- '',
1202
- '',
1203
- false
1204
- );
1205
- wp_register_script( 'woocommerce_admin', plugins_url() . '/woocommerce/assets/js/admin/woocommerce_admin.js', array( 'jquery', 'jquery-ui-widget', 'jquery-ui-core' ) );
1206
- wp_enqueue_script( 'woocommerce_admin' );
1207
-
1208
- ?>
1209
- <script type="text/javascript" >
1210
- function delete_email_template( id )
1211
- {
1212
- var y=confirm( 'Are you sure you want to delete this Email Template' );
1213
- if( y==true ) {
1214
- location.href='admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=removetemplate&id='+id;
1215
- }
1216
- }
1217
 
1218
- function activate_email_template( template_id, active_state ) {
1219
-
1220
- location.href = 'admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=activate_template&id='+template_id+'&active_state='+active_state ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1221
  }
1222
- </script>
1223
-
1224
- <?php
1225
- $js_src = includes_url('js/tinymce/') . 'tinymce.min.js';
1226
-
1227
- wp_enqueue_script( 'tinyMce_ac',$js_src );
1228
- wp_enqueue_script( 'ac_email_variables', plugins_url() . '/woocommerce-abandoned-cart/js/abandoncart_plugin_button.js' );
1229
-
1230
- }
1231
-
1232
- }
1233
-
1234
- function myformatTinyMCE_ac( $in ) {
1235
-
1236
- $in['force_root_block'] = false;
1237
- $in['valid_children'] = '+body[style]';
1238
- $in['remove_linebreaks'] = false;
1239
- $in['gecko_spellcheck'] = false;
1240
- $in['keep_styles'] = true;
1241
- $in['accessibility_focus'] = true;
1242
- $in['tabfocus_elements'] = 'major-publishing-actions';
1243
- $in['media_strict'] = false;
1244
- $in['paste_remove_styles'] = false;
1245
- $in['paste_remove_spans'] = false;
1246
- $in['paste_strip_class_attributes'] = 'none';
1247
- $in['paste_text_use_dialog'] = true;
1248
- $in['wpeditimage_disable_captions'] = true;
1249
- $in['wpautop'] = false;
1250
- $in['apply_source_formatting'] = true;
1251
- $in['cleanup'] = true;
1252
- $in['convert_newlines_to_brs'] = FALSE;
1253
- $in['fullpage_default_xml_pi'] = false;
1254
- $in['convert_urls'] = false;
1255
- // Do not remove redundant BR tags
1256
- $in['remove_redundant_brs'] = false;
1257
-
1258
- return $in;
1259
- }
1260
-
1261
- function my_enqueue_scripts_css( $hook ) {
1262
-
1263
- if ( $hook != 'woocommerce_page_woocommerce_ac_page' ) {
1264
- return;
1265
- } else {
1266
- wp_enqueue_style( 'jquery-ui', "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" , '', '', false );
1267
- wp_enqueue_style( 'woocommerce_admin_styles', plugins_url() . '/woocommerce/assets/css/admin.css' );
1268
- wp_enqueue_style( 'jquery-ui-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
1269
- wp_enqueue_style( 'abandoned-orders-list', plugins_url() . '/woocommerce-abandoned-cart/css/view.abadoned.orders.style.css' );
1270
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1271
  }
1272
- }
1273
-
1274
- //bulk action
1275
- // to over come the wp redirect warning while deleting
1276
- function app_output_buffer() {
1277
- ob_start();
1278
- }
1279
-
1280
- /**
1281
- * Abandon Cart Settings Page
1282
- */
1283
- function woocommerce_ac_page()
1284
- {
1285
- if ( is_user_logged_in() ) {
1286
- global $wpdb;
1287
-
1288
- // Check the user capabilities
1289
- if ( !current_user_can( 'manage_woocommerce' ) ) {
1290
- wp_die( __( 'You do not have sufficient permissions to access this page.', 'woocommerce-ac' ) );
1291
- }
1292
- ?>
1293
-
1294
- <div class="wrap">
1295
- <div class="icon32" style="background-image: url('<?php echo plugins_url(); ?>/woocommerce-abandoned-cart/images/abandoned_cart_small.png') !important;">
1296
- <br />
1297
- </div>
1298
- <h2><?php _e( 'WooCommerce - Abandon Cart Lite', 'woocommerce-ac' ); ?></h2>
1299
- <?php
1300
-
1301
- if ( isset( $_GET[ 'action' ] ) ) {
1302
- $action = $_GET[ 'action' ];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1303
  } else {
1304
  $action = "";
1305
  }
1306
- if ( isset( $_GET[ 'mode' ] ) ) {
1307
- $mode = $_GET[ 'mode' ];
1308
- } else {
1309
- $mode = "";
1310
- }
1311
-
1312
- $this->display_tabs();
1313
- /**
1314
- * When we delete the item from the below drop down it is registred in action 2
1315
- */
1316
- if ( isset( $_GET['action2'] ) ) $action_two = $_GET['action2'];
1317
- else $action_two = "";
1318
-
1319
- // Detect when a bulk action is being triggered on abadoned orders page.
1320
- if( 'wcap_delete' === $action || 'wcap_delete' === $action_two ){
1321
-
1322
- $ids = isset( $_GET['abandoned_order_id'] ) ? $_GET['abandoned_order_id'] : false;
1323
- if ( ! is_array( $ids ) ){
1324
- $ids = array( $ids );
1325
- }
1326
-
1327
- foreach ( $ids as $id ) {
1328
- $class = new wcap_delete_bulk_action_handler();
1329
- $class->wcap_delete_bulk_action_handler_function_lite( $id );
1330
- }
1331
- }
1332
-
1333
- //Detect when a bulk action is being triggered on temnplates page.
1334
- if( 'wcap_delete_template' === $action || 'wcap_delete_template' === $action_two ){
1335
-
1336
- $ids = isset( $_GET['template_id'] ) ? $_GET['template_id'] : false;
1337
-
1338
- if ( ! is_array( $ids ) ){
1339
- $ids = array( $ids );
1340
- }
1341
-
1342
- foreach ( $ids as $id ) {
1343
- $class = new wcap_delete_bulk_action_handler();
1344
- $class->wcap_delete_template_bulk_action_handler_function_lite( $id );
1345
- }
1346
- }
1347
-
1348
- if ( isset($_GET ['wcap_deleted']) && 'YES' == $_GET['wcap_deleted'] ) { ?>
1349
- <div id="message" class="updated fade"><p><strong><?php _e( 'The Abadoned cart has been successfully deleted.', 'woocommerce-ac' ); ?></strong></p></div>
1350
- <?php }
1351
-
1352
- if ( isset($_GET ['wcap_template_deleted']) && 'YES' == $_GET['wcap_template_deleted'] ) { ?>
1353
- <div id="message" class="updated fade"><p><strong><?php _e( 'The Template has been successfully deleted.', 'woocommerce-ac' ); ?></strong></p></div>
1354
- <?php }
1355
-
1356
- if ( $action == 'emailsettings' ) {
1357
- // Save the field values
1358
  ?>
1359
- <p><?php _e( 'Change settings for sending email notifications to Customers after X minute.', 'woocommerce-ac' ); ?></p>
1360
- <div id="content">
1361
-
1362
- <form method="post" action="options.php">
1363
- <?php settings_fields( 'woocommerce_ac_settings' ); ?>
1364
- <?php do_settings_sections( 'woocommerce_ac_page' ); ?>
1365
- <?php settings_errors(); ?>
1366
- <?php submit_button(); ?>
1367
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1368
  </form>
1369
- </div>
1370
- <?php
1371
- } elseif ( $action == 'listcart' || $action == '' ) {
1372
- ?>
1373
-
1374
- <p> <?php _e( 'The list below shows all Abandoned Carts which have remained in cart for a time higher than the "Cart abandoned cut-off time" setting.', 'woocommerce-ac' );?> </p>
1375
-
1376
- <?php
1377
- global $wpdb;
1378
-
1379
- include_once('class-abandoned-orders-table.php');
1380
- $wcap_abandoned_order_list = new WACP_Abandoned_Orders_Table();
1381
- $wcap_abandoned_order_list->wcap_abadoned_order_prepare_items();
1382
- ?>
1383
- <div class="wrap">
1384
- <form id="wacp-abandoned-orders" method="get" >
1385
- <input type="hidden" name="page" value="woocommerce_ac_page" />
1386
- <?php $wcap_abandoned_order_list->display(); ?>
1387
- </form>
1388
- </div>
1389
-
1390
- <?php
1391
- } elseif ( $action == 'emailtemplates' && ( $mode != 'edittemplate' && $mode != 'addnewtemplate' ) ) {
1392
- ?>
1393
- <p> <?php _e( 'Add email templates at different intervals to maximize the possibility of recovering your abandoned carts.', 'woocommerce-ac' );?> </p>
1394
- <?php
1395
-
1396
- // Save the field values
1397
- $insert_template_successfuly = $update_template_successfuly = '';
1398
- if ( isset( $_POST[ 'ac_settings_frm' ] ) && $_POST[ 'ac_settings_frm' ] == 'save' ) {
1399
-
1400
-
1401
- $active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
1402
- $is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
1403
-
1404
- if ( $active_post == 1 ) {
1405
-
1406
- $is_active = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
1407
- $email_frequency = trim( $_POST[ 'email_frequency' ] );
1408
- $day_or_hour = trim( $_POST[ 'day_or_hour' ] );
1409
-
1410
- $check_query = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite`
1411
- WHERE is_active = %s
1412
- AND frequency = %d
1413
- AND day_or_hour = %s ";
1414
- $check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $is_active, $email_frequency, $day_or_hour ) );
1415
-
1416
- $default_value = 0 ;
1417
-
1418
-
1419
- if ( count( $check_results ) == 0 ) {
1420
-
1421
-
1422
- $active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
1423
- $woocommerce_ac_email_subject = trim( $_POST[ 'woocommerce_ac_email_subject' ] );
1424
- $woocommerce_ac_email_body = trim( $_POST[ 'woocommerce_ac_email_body' ] );
1425
- $woocommerce_ac_template_name = trim( $_POST[ 'woocommerce_ac_template_name' ] );
1426
- $woocommerce_ac_from_name = trim( $_POST[ 'woocommerce_ac_from_name' ] );
1427
- $woocommerce_ac_email_reply = trim( $_POST['woocommerce_ac_email_reply'] );
1428
- $woocommerce_ac_email_from = trim( $_POST[ 'woocommerce_ac_email_from' ] );
1429
-
1430
- $query = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
1431
- (subject, body, is_active, frequency, day_or_hour, template_name, from_name, is_wc_template, default_template, reply_email, from_email )
1432
- VALUES ( %s, %s, %s, %d, %s, %s, %s, %s, %d, %s, %s )"; //It is fix
1433
-
1434
- $insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query,
1435
- $woocommerce_ac_email_subject,
1436
- $woocommerce_ac_email_body,
1437
- $active_post,
1438
- $email_frequency,
1439
- $day_or_hour,
1440
- $woocommerce_ac_template_name,
1441
- $woocommerce_ac_from_name,
1442
- $is_wc_template,
1443
- $default_value,
1444
- $woocommerce_ac_email_reply,
1445
- $woocommerce_ac_email_from)
1446
- );
1447
-
1448
- }
1449
- else {
1450
-
1451
- $update_is_active = 0;
1452
- $query_update = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
1453
- SET
1454
- is_active = %s
1455
- WHERE frequency = %d
1456
- AND day_or_hour = %s ";
1457
- $update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update, $update_is_active, $email_frequency, $day_or_hour ) );
1458
-
1459
-
1460
- $woocommerce_ac_email_subject = trim( $_POST[ 'woocommerce_ac_email_subject' ] );
1461
- $woocommerce_ac_email_body = trim( $_POST[ 'woocommerce_ac_email_body' ] );
1462
- $woocommerce_ac_template_name = trim( $_POST[ 'woocommerce_ac_template_name' ] );
1463
- $woocommerce_ac_from_name = trim( $_POST[ 'woocommerce_ac_from_name' ] );
1464
- $woocommerce_ac_email_from = trim( $_POST['woocommerce_ac_email_from'] );
1465
- $woocommerce_ac_email_reply = trim( $_POST[ 'woocommerce_ac_email_reply' ] );
1466
-
1467
- $query_insert_new = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
1468
- (subject, body, is_active, frequency, day_or_hour, template_name, from_name, is_wc_template, default_template, reply_email, from_email )
1469
- VALUES ( %s, %s, %s, %d, %s, %s, %s, %s, %d, %s, %s )";
1470
-
1471
- $insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query_insert_new,
1472
- $woocommerce_ac_email_subject,
1473
- $woocommerce_ac_email_body,
1474
- $active_post,
1475
- $email_frequency,
1476
- $day_or_hour,
1477
- $woocommerce_ac_template_name,
1478
- $woocommerce_ac_from_name,
1479
- $is_wc_template,
1480
- $woocommerce_ac_email_reply,
1481
- $woocommerce_ac_email_from )
1482
- );
1483
- }
1484
- }else{
1485
-
1486
-
1487
- $woocommerce_ac_email_subject = trim( $_POST[ 'woocommerce_ac_email_subject' ] );
1488
- $woocommerce_ac_email_body = trim( $_POST[ 'woocommerce_ac_email_body' ] );
1489
- $woocommerce_ac_template_name = trim( $_POST[ 'woocommerce_ac_template_name' ] );
1490
- $woocommerce_ac_from_name = trim( $_POST[ 'woocommerce_ac_from_name' ] );
1491
- $woocommerce_ac_email_reply = trim( $_POST[ 'woocommerce_ac_email_reply' ] );
1492
- $woocommerce_ac_email_from = trim( $_POST['woocommerce_ac_email_from'] );
1493
-
1494
- $active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
1495
- $email_frequency = trim( $_POST[ 'email_frequency' ] );
1496
- $day_or_hour = trim( $_POST[ 'day_or_hour' ] );
1497
- $is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
1498
- $default_value = 0 ;
1499
-
1500
-
1501
- $query = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
1502
- (subject, body, is_active, frequency, day_or_hour, template_name, from_name, is_wc_template, default_template, reply_email, from_email )
1503
- VALUES ( %s, %s, %s, %d, %s, %s, %s, %s, %d, %s, %s )";
1504
-
1505
- $insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query,
1506
- $woocommerce_ac_email_subject,
1507
- $woocommerce_ac_email_body,
1508
- $active_post,
1509
- $email_frequency,
1510
- $day_or_hour,
1511
- $woocommerce_ac_template_name,
1512
- $woocommerce_ac_from_name,
1513
- $is_wc_template,
1514
- $default_value,
1515
- $woocommerce_ac_email_reply,
1516
- $woocommerce_ac_email_from )
1517
- );
1518
-
1519
- }
1520
- }
1521
-
1522
- if ( isset( $_POST[ 'ac_settings_frm' ] ) && $_POST[ 'ac_settings_frm' ] == 'update' )
1523
- {
1524
-
1525
- $active = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
1526
- $is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
1527
- if ( $active == 1 )
1528
- {
1529
- $is_active = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
1530
- $email_frequency = trim( $_POST[ 'email_frequency' ] );
1531
- $day_or_hour = trim( $_POST[ 'day_or_hour' ] );
1532
- $check_query = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite`
1533
- WHERE is_active= %s
1534
- AND frequency = %d
1535
- AND day_or_hour= %s ";
1536
- $check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $is_active, $email_frequency, $day_or_hour ) );
1537
-
1538
- $default_value = '';
1539
- foreach($check_results as $result_key => $result_value) {
1540
- $default_value = ( empty( $result_value->default_template ) ) ? 0 : $result_value->default_template;
1541
-
1542
- }
1543
-
1544
- if (count($check_results) == 0 )
1545
- {
1546
-
1547
- $woocommerce_ac_email_subject = trim( $_POST[ 'woocommerce_ac_email_subject' ] );
1548
- $woocommerce_ac_email_body = trim( $_POST[ 'woocommerce_ac_email_body' ] );
1549
- $woocommerce_ac_template_name = trim( $_POST[ 'woocommerce_ac_template_name' ] );
1550
- $woocommerce_ac_from_name = trim( $_POST[ 'woocommerce_ac_from_name' ] );
1551
- $woocommerce_ac_email_from = trim( $_POST['woocommerce_ac_email_from'] );
1552
- $woocommerce_ac_email_reply = trim( $_POST[ 'woocommerce_ac_email_reply' ] );
1553
- $id = trim( $_POST[ 'id' ] );
1554
-
1555
- $query_update = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
1556
- SET
1557
- subject = %s,
1558
- body = %s,
1559
- is_active = %s,
1560
- frequency = %d,
1561
- day_or_hour = %s,
1562
- template_name = %s,
1563
- from_name = %s,
1564
- is_wc_template = %s,
1565
- default_template = %d,
1566
- reply_email = %s,
1567
- from_email = %s
1568
- WHERE id = %d ";
1569
- $update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update,
1570
- $woocommerce_ac_email_subject,
1571
- $woocommerce_ac_email_body,
1572
- $active,
1573
- $email_frequency,
1574
- $day_or_hour,
1575
- $woocommerce_ac_template_name,
1576
- $woocommerce_ac_from_name,
1577
- $is_wc_template,
1578
- $default_value,
1579
- $woocommerce_ac_email_from,
1580
- $woocommerce_ac_email_reply,
1581
- $id )
1582
-
1583
- );
1584
- }
1585
- else {
1586
-
1587
- $updated_is_active = 0;
1588
- $query_update_new = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
1589
- SET is_active = %s
1590
- WHERE frequency = %d
1591
- AND day_or_hour = %s ";
1592
- $update_template_successfuly = $wpdb->query( $wpdb->prepare( $query_update_new, $updated_is_active, $email_frequency, $day_or_hour ) );
1593
-
1594
- $woocommerce_ac_email_subject = trim( $_POST[ 'woocommerce_ac_email_subject' ] );
1595
- $woocommerce_ac_email_body = trim( $_POST[ 'woocommerce_ac_email_body' ] );
1596
- $woocommerce_ac_template_name = trim( $_POST[ 'woocommerce_ac_template_name' ] );
1597
- $woocommerce_ac_from_name = trim( $_POST[ 'woocommerce_ac_from_name' ] );
1598
- $woocommerce_ac_email_from = trim( $_POST['woocommerce_ac_email_from'] );
1599
- $woocommerce_ac_email_reply = trim( $_POST[ 'woocommerce_ac_email_reply' ] );
1600
- $id = trim( $_POST[ 'id' ] );
1601
-
1602
- $query_update_latest = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
1603
- SET
1604
- subject = %s,
1605
- body = %s,
1606
- is_active = %s,
1607
- frequency = %d,
1608
- day_or_hour = %s,
1609
- template_name = %s,
1610
- from_name = %s,
1611
- is_wc_template = %s,
1612
- default_template = %d,
1613
- reply_email = %s,
1614
- from_email = %s
1615
- WHERE id = %d ";
1616
- $update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update_latest,
1617
- $woocommerce_ac_email_subject,
1618
- $woocommerce_ac_email_body,
1619
- $active,
1620
- $email_frequency,
1621
- $day_or_hour,
1622
- $woocommerce_ac_template_name,
1623
- $woocommerce_ac_from_name,
1624
- $is_wc_template,
1625
- $default_value,
1626
- $woocommerce_ac_email_reply,
1627
- $woocommerce_ac_email_from,
1628
- $id )
1629
-
1630
- );
1631
-
1632
- }
1633
- }else{
1634
-
1635
- $updated_is_active = '0';
1636
- $is_active = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
1637
- $email_frequency = trim( $_POST[ 'email_frequency' ] );
1638
- $day_or_hour = trim( $_POST[ 'day_or_hour' ] );
1639
- $is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
1640
-
1641
- $query_update_new = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
1642
- SET is_active = %s
1643
- WHERE frequency = %d
1644
- AND day_or_hour = %s ";
1645
- $wpdb->query( $wpdb->prepare( $query_update_new, $updated_is_active, $email_frequency, $day_or_hour ) );
1646
-
1647
- $woocommerce_ac_email_subject = trim( $_POST[ 'woocommerce_ac_email_subject' ] );
1648
- $woocommerce_ac_email_body = trim( $_POST[ 'woocommerce_ac_email_body' ] );
1649
- $woocommerce_ac_template_name = trim( $_POST[ 'woocommerce_ac_template_name' ] );
1650
- $woocommerce_ac_from_name = trim( $_POST[ 'woocommerce_ac_from_name' ] );
1651
- $woocommerce_ac_email_from = trim( $_POST['woocommerce_ac_email_from'] );
1652
- $woocommerce_ac_email_reply = trim( $_POST[ 'woocommerce_ac_email_reply' ] );
1653
- $id = trim( $_POST[ 'id' ] );
1654
-
1655
-
1656
- $check_query = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite`
1657
- WHERE is_active= %s
1658
- AND frequency = %d
1659
- AND day_or_hour= %s ";
1660
- $check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $is_active, $email_frequency, $day_or_hour ) );
1661
-
1662
- $default_value = '';
1663
- foreach($check_results as $result_key => $result_value) {
1664
- $default_value = ( empty( $result_value->default_template ) ) ? 0 : $result_value->default_template;
1665
-
1666
- }
1667
-
1668
- $query_update_latest = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
1669
- SET
1670
  subject = %s,
1671
  body = %s,
1672
  is_active = %s,
1673
- frequency = %d,
1674
  day_or_hour = %s,
1675
  template_name = %s,
1676
- from_name = %s,
1677
- is_wc_template = %s,
1678
- default_template = %d,
1679
- reply_email = %s,
1680
- from_email = %s
1681
  WHERE id = %d ";
1682
-
1683
- $update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update_latest,
1684
- $woocommerce_ac_email_subject,
1685
- $woocommerce_ac_email_body,
1686
- $is_active,
1687
- $email_frequency,
1688
- $day_or_hour,
1689
- $woocommerce_ac_template_name,
1690
- $woocommerce_ac_from_name,
1691
- $is_wc_template,
1692
- $default_value,
1693
- $woocommerce_ac_email_reply,
1694
- $woocommerce_ac_email_from,
1695
- $id )
1696
-
1697
- );
1698
-
1699
- }
1700
- }
1701
-
1702
- if ( $action == 'emailtemplates' && $mode == 'removetemplate' ){
1703
- $id_remove = $_GET[ 'id' ];
1704
-
1705
- $query_remove = "DELETE FROM `".$wpdb->prefix."ac_email_templates_lite` WHERE id= %d ";
1706
- $wpdb->query( $wpdb->prepare( $query_remove, $id_remove ) );
1707
- }
1708
-
1709
- if ( $action == 'emailtemplates' && $mode == 'activate_template' ) {
1710
- $template_id = $_GET['id'];
1711
- $current_template_status = $_GET['active_state'];
1712
-
1713
- if( "1" == $current_template_status ) {
1714
- $active = "0";
1715
- } else {
1716
- $active = "1";
1717
- }
1718
- $query_update = "UPDATE `" . $wpdb->prefix . "ac_email_templates_lite`
1719
- SET
1720
- is_active = '" . $active . "'
1721
- WHERE id = '" . $template_id . "' ";
1722
- $wpdb->query( $query_update );
1723
-
1724
- wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&action=emailtemplates' ) );
1725
- }
1726
-
1727
- if ( isset( $_POST[ 'ac_settings_frm' ] ) && $_POST[ 'ac_settings_frm' ] == 'save' && (isset($insert_template_successfuly) && $insert_template_successfuly != '')) { ?>
1728
- <div id="message" class="updated fade"><p><strong><?php _e( 'The Email Template has been successfully added.', 'woocommerce-ac' ); ?></strong></p></div>
1729
- <?php } else if ( isset( $_POST[ 'ac_settings_frm' ] ) && $_POST[ 'ac_settings_frm' ] == 'save' && (isset($insert_template_successfuly) && $insert_template_successfuly == '')){
1730
- ?>
1731
- <div id="message" class="error fade"><p><strong><?php _e( ' There was a problem adding the email template. Please contact the plugin author via <a href= "https://wordpress.org/support/plugin/woocommerce-abandoned-cart">support forum</a>.', 'woocommerce-ac' ); ?></strong></p></div>
1732
- <?php
1733
- }
1734
-
1735
-
1736
- if ( isset( $_POST[ 'ac_settings_frm' ] ) && $_POST[ 'ac_settings_frm' ] == 'update' && isset($update_template_successfuly) && $update_template_successfuly >= 0 ) { ?>
1737
- <div id="message" class="updated fade"><p><strong><?php _e( 'The Email Template has been successfully updated.', 'woocommerce-ac' ); ?></strong></p></div>
1738
- <?php } else if ( isset( $_POST[ 'ac_settings_frm' ] ) && $_POST[ 'ac_settings_frm' ] == 'update' && isset($update_template_successfuly) && $update_template_successfuly === false ){
1739
- ?>
1740
- <div id="message" class="error fade"><p><strong><?php _e( ' There was a problem updating the email template. Please contact the plugin author via <a href= "https://wordpress.org/support/plugin/woocommerce-abandoned-cart">support forum</a>.', 'woocommerce-ac' ); ?></strong></p></div>
1741
- <?php
1742
- }
1743
- ?>
1744
- <div class="tablenav">
1745
- <p style="float:left;">
1746
- <a cursor: pointer; href="<?php echo "admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=addnewtemplate"; ?>" class="button-secondary"><?php _e( 'Add New Template', 'woocommerce-ac' ); ?></a>
1747
- </p>
1748
-
1749
- <?php
1750
- /* From here you can do whatever you want with the data from the $result link. */
1751
- include_once('class-templates-table.php');
1752
- $wcap_template_list = new WACP_Templates_Table();
1753
- $wcap_template_list->wcap_templates_prepare_items();
1754
- ?>
1755
- <div class="wrap">
1756
- <form id="wacp-abandoned-templates" method="get" >
1757
- <input type="hidden" name="page" value="woocommerce_ac_page" />
1758
- <?php $wcap_template_list->display(); ?>
1759
- </form>
1760
- </div>
1761
- <?php
1762
-
1763
- }
1764
- elseif ($action == 'stats' || $action == '')
1765
- {
1766
- ?>
1767
- <p>
1768
- <script language='javascript'>
1769
- jQuery( document ).ready( function()
1770
- {
1771
- jQuery( '#duration_select' ).change( function()
1772
- {
1773
- var group_name = jQuery( '#duration_select' ).val();
1774
- var today = new Date();
1775
- var start_date = "";
1776
- var end_date = "";
1777
- if ( group_name == "yesterday" )
1778
- {
1779
- start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 1 );
1780
- end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 1 );
1781
- }
1782
- else if ( group_name == "today")
1783
- {
1784
- start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
1785
- end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
1786
- }
1787
- else if ( group_name == "last_seven" )
1788
- {
1789
- start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 7 );
1790
- end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
1791
- }
1792
- else if ( group_name == "last_fifteen" )
1793
- {
1794
- start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 15 );
1795
- end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
1796
- }
1797
- else if ( group_name == "last_thirty" )
1798
- {
1799
- start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 30 );
1800
- end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
1801
- }
1802
- else if ( group_name == "last_ninety" )
1803
- {
1804
- start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 90 );
1805
- end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
1806
- }
1807
- else if ( group_name == "last_year_days" )
1808
- {
1809
- start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 365 );
1810
- end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
1811
- }
1812
-
1813
- var monthNames = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
1814
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
1815
-
1816
- var start_date_value = start_date.getDate() + " " + monthNames[start_date.getMonth()] + " " + start_date.getFullYear();
1817
- var end_date_value = end_date.getDate() + " " + monthNames[end_date.getMonth()] + " " + end_date.getFullYear();
1818
-
1819
- jQuery( '#start_date' ).val( start_date_value );
1820
- jQuery( '#end_date' ).val( end_date_value );
1821
-
1822
- });
1823
- });
1824
- </script>
1825
- <?php
1826
-
1827
- if ( isset( $_POST[ 'duration_select' ] ) ){
1828
- $duration_range = $_POST['duration_select'];
1829
- } else {
1830
- $duration_range = "";
1831
- }
1832
- if ( $duration_range == "" ) {
1833
- if ( isset( $_GET[ 'duration_select' ] ) ){
1834
- $duration_range = $_GET[ 'duration_select' ];
1835
- }
1836
- }
1837
- if ($duration_range == "") $duration_range = "last_seven";
1838
-
1839
-
1840
- _e( 'The Report below shows how many Abandoned Carts we were able to recover for you by sending automatic emails to encourage shoppers.', 'woocommerce-ac');
1841
- ?>
1842
- <div id="recovered_stats" class="postbox" style="display:block">
1843
-
1844
- <div class="inside">
1845
- <form method="post" action="admin.php?page=woocommerce_ac_page&action=stats" id="ac_stats">
1846
- <select id="duration_select" name="duration_select" >
1847
- <?php
1848
- foreach ( $this->duration_range_select as $key => $value )
1849
- {
1850
- $sel = "";
1851
- if ($key == $duration_range) {
1852
- $sel = " selected ";
1853
- }
1854
- echo"<option value='$key' $sel> $value </option>";
1855
- }
1856
-
1857
- $date_sett = $this->start_end_dates[ $duration_range ];
1858
-
1859
- ?>
1860
- </select>
1861
-
1862
- <script type="text/javascript">
1863
- jQuery( document ).ready( function()
1864
- {
1865
- var formats = [ "d.m.y", "d M yy","MM d, yy" ];
1866
- jQuery( "#start_date" ).datepicker( { dateFormat: formats[ 1 ] } );
1867
- });
1868
-
1869
- jQuery( document ).ready( function()
1870
- {
1871
- var formats = [ "d.m.y", "d M yy","MM d, yy" ];
1872
- jQuery( "#end_date" ).datepicker( { dateFormat: formats[ 1 ] } );
1873
- });
1874
- </script>
1875
-
1876
-
1877
- <?php
1878
-
1879
- include_once('class-recover-orders-table.php');
1880
-
1881
- $wcap_recover_orders_list = new WACP_Recover_Orders_Table();
1882
- $wcap_recover_orders_list->wcap_recovered_orders_prepare_items_lite();
1883
 
1884
- if ( isset( $_POST['start_date'] ) ) $start_date_range = $_POST['start_date'];
1885
- else $start_date_range = "";
1886
-
1887
- if ( $start_date_range == "" ) {
1888
- $start_date_range = $date_sett['start_date'];
1889
- }
1890
-
1891
- if ( isset( $_POST['end_date'] ) ) $end_date_range = $_POST['end_date'];
1892
- else $end_date_range = "";
1893
 
1894
- if ( $end_date_range == "" ) {
1895
- $end_date_range = $date_sett['end_date'];
1896
- }
1897
- ?>
1898
- <label class="start_label" for="start_day"> <?php _e( 'Start Date:', 'woocommerce-ac' ); ?> </label>
1899
- <input type="text" id="start_date" name="start_date" readonly="readonly" value="<?php echo $start_date_range; ?>"/>
1900
- <label class="end_label" for="end_day"> <?php _e( 'End Date:', 'woocommerce-ac' ); ?> </label>
1901
- <input type="text" id="end_date" name="end_date" readonly="readonly" value="<?php echo $end_date_range; ?>"/>
1902
- <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e( 'Go', 'woocommerce-ac' ); ?>" />
1903
- </form>
1904
- </div>
1905
- </div>
1906
- <div id="recovered_stats" class="postbox" style="display:block">
1907
- <div class="inside" >
1908
- <p style="font-size: 15px"><?php _e( 'During the selected range ', 'woocommerce-ac' ); ?>
1909
- <strong>
1910
- <?php $count = $wcap_recover_orders_list->total_abandoned_cart_count;
1911
- echo $count; ?>
1912
- </strong>
1913
- <?php _e( 'carts totaling', 'woocommerce-ac' ); ?>
1914
- <strong>
1915
- <?php $total_of_all_order = $wcap_recover_orders_list->total_order_amount;
1916
-
1917
- echo get_woocommerce_currency_symbol().$total_of_all_order; ?>
1918
- </strong>
1919
- <?php _e( ' were abandoned. We were able to recover', 'woocommerce-ac' ); ?>
1920
- <strong>
1921
- <?php
1922
- $recovered_item = $wcap_recover_orders_list->recovered_item;
1923
-
1924
- echo $recovered_item; ?>
1925
- </strong>
1926
- <?php _e( ' of them, which led to an extra', 'woocommerce-ac' ); ?>
1927
- <strong>
1928
- <?php
1929
- $recovered_total = $wcap_recover_orders_list->total_recover_amount;
1930
- echo get_woocommerce_currency_symbol().$recovered_total; ?>
1931
- </strong>
1932
- <?php //_e( ' in sales', 'woocommerce-ac' ); ?>
1933
- </p>
1934
- </div>
1935
- </div>
1936
-
1937
- <div class="wrap">
1938
- <form id="wacp-recover-orders" method="get" >
1939
- <input type="hidden" name="page" value="woocommerce_ac_page" />
1940
- <?php $wcap_recover_orders_list->display(); ?>
1941
- </form>
1942
- </div>
1943
- <?php
1944
- }elseif ( $action == 'orderdetails' ) {
1945
- $ac_order_id = $_GET['id'];
1946
- ?>
1947
- <p> </p>
1948
- <div id="ac_order_details" class="postbox" style="display:block">
 
 
1949
  <h3> <p> <?php _e( "Abandoned Order #$ac_order_id Details", "woocommerce-ac" ); ?> </p> </h3>
1950
- <div class="inside">
1951
- <table cellpadding="0" cellspacing="0" class="wp-list-table widefat fixed posts">
1952
  <tr>
1953
- <th> <?php _e( 'Item', 'woocommerce-ac' ); ?> </th>
1954
- <th> <?php _e( 'Id', 'woocommerce-ac' ); ?> </th>
1955
- <th> <?php _e( 'Name', 'woocommerce-ac' ); ?> </th>
1956
- <th> <?php _e( 'Quantity', 'woocommerce-ac' ); ?> </th>
1957
- <th> <?php _e( 'Line Subtotal', 'woocommerce-ac' ); ?> </th>
1958
- <th> <?php _e( 'Line Total', 'woocommerce-ac' ); ?> </th>
1959
  </tr>
1960
- <?php
1961
- $query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE id = %d ";
1962
- $results = $wpdb->get_results( $wpdb->prepare( $query,$_GET['id'] ) );
1963
- $shipping_charges = 0;
1964
- $currency_symbol = get_woocommerce_currency_symbol();
1965
-
1966
- if ( $results[0]->user_type == "GUEST" ) {
1967
- $query_guest = "SELECT * FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d";
1968
- $results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $results[0]->user_id ) );
1969
- $user_email = $results_guest[0]->email_id;
1970
- $user_first_name = $results_guest[0]->billing_first_name;
1971
- $user_last_name = $results_guest[0]->billing_last_name;
1972
- $user_billing_postcode = $results_guest[0]->billing_zipcode;
1973
- $user_shipping_postcode = $results_guest[0]->shipping_zipcode;
1974
- $shipping_charges = $results_guest[0]->shipping_charges;
1975
- $user_billing_company = $user_billing_address_1 = $user_billing_address_2 = $user_billing_city = $user_billing_state = $user_billing_country = $user_billing_phone = "";
1976
- $user_shipping_company = $user_shipping_address_1 = $user_shipping_address_2 = $user_shipping_city = $user_shipping_state = $user_shipping_country = "";
1977
- } else {
1978
- $user_id = $results[0]->user_id;
1979
- if ( isset( $results[0]->user_login ) ) $user_login = $results[0]->user_login;
1980
-
1981
- $user_email = get_user_meta( $results[0]->user_id, 'billing_email', true );
1982
-
1983
- if($user_email == ""){
1984
- $user_data = get_userdata( $results[0]->user_id );
1985
- $user_email = $user_data->user_email;
1986
- }
1987
-
1988
- $user_first_name_temp = get_user_meta( $results[0]->user_id, 'first_name');
1989
- if ( isset( $user_first_name_temp[0] ) ) $user_first_name = $user_first_name_temp[0];
1990
- else $user_first_name = "";
1991
-
1992
- $user_last_name_temp = get_user_meta($results[0]->user_id, 'last_name');
1993
- if ( isset( $user_last_name_temp[0] ) ) $user_last_name = $user_last_name_temp[0];
1994
- else $user_last_name = "";
1995
-
1996
- $user_billing_first_name = get_user_meta( $results[0]->user_id, 'billing_first_name' );
1997
- $user_billing_last_name = get_user_meta( $results[0]->user_id, 'billing_last_name' );
1998
-
1999
- $user_billing_company_temp = get_user_meta( $results[0]->user_id, 'billing_company' );
2000
- if ( isset( $user_billing_company_temp[0] ) ) $user_billing_company = $user_billing_company_temp[0];
2001
- else $user_billing_company = "";
2002
-
2003
- $user_billing_address_1_temp = get_user_meta( $results[0]->user_id, 'billing_address_1' );
2004
- if ( isset( $user_billing_address_1_temp[0] ) ) $user_billing_address_1 = $user_billing_address_1_temp[0];
2005
- else $user_billing_address_1 = "";
2006
-
2007
- $user_billing_address_2_temp = get_user_meta( $results[0]->user_id, 'billing_address_2' );
2008
- if ( isset( $user_billing_address_2_temp[0] ) ) $user_billing_address_2 = $user_billing_address_2_temp[0];
2009
- else $user_billing_address_2 = "";
2010
-
2011
- $user_billing_city_temp = get_user_meta( $results[0]->user_id, 'billing_city' );
2012
- if ( isset( $user_billing_city_temp[0] ) ) $user_billing_city = $user_billing_city_temp[0];
2013
- else $user_billing_city = "";
2014
-
2015
- $user_billing_postcode_temp = get_user_meta( $results[0]->user_id, 'billing_postcode' );
2016
- if ( isset( $user_billing_postcode_temp[0] ) ) $user_billing_postcode = $user_billing_postcode_temp[0];
2017
- else $user_billing_postcode = "";
2018
-
2019
- $user_billing_state_temp = get_user_meta( $results[0]->user_id, 'billing_state' );
2020
- if ( isset( $user_billing_state_temp[0] ) ) $user_billing_state = $user_billing_state_temp[0];
2021
- else $user_billing_state = "";
2022
-
2023
- $user_billing_country_temp = get_user_meta( $results[0]->user_id, 'billing_country' );
2024
- if ( isset( $user_billing_country_temp[0] ) ) $user_billing_country = $user_billing_country_temp[0];
2025
- else $user_billing_country = "";
2026
-
2027
- $user_billing_phone_temp = get_user_meta( $results[0]->user_id, 'billing_phone' );
2028
- if ( isset( $user_billing_phone_temp[0] ) ) $user_billing_phone = $user_billing_phone_temp[0];
2029
- else $user_billing_phone = "";
2030
-
2031
- $user_shipping_first_name = get_user_meta( $results[0]->user_id, 'shipping_first_name' );
2032
- $user_shipping_last_name = get_user_meta( $results[0]->user_id, 'shipping_last_name' );
2033
-
2034
- $user_shipping_company_temp = get_user_meta( $results[0]->user_id, 'shipping_company' );
2035
- if ( isset( $user_shipping_company_temp[0] ) ) $user_shipping_company = $user_shipping_company_temp[0];
2036
- else $user_shipping_company = "";
2037
-
2038
- $user_shipping_address_1_temp = get_user_meta( $results[0]->user_id, 'shipping_address_1' );
2039
- if ( isset( $user_shipping_address_1_temp[0] ) ) $user_shipping_address_1 = $user_shipping_address_1_temp[0];
2040
- else $user_shipping_address_1 = "";
2041
-
2042
- $user_shipping_address_2_temp = get_user_meta( $results[0]->user_id, 'shipping_address_2' );
2043
- if ( isset( $user_shipping_address_2_temp[0] ) ) $user_shipping_address_2 = $user_shipping_address_2_temp[0];
2044
- else $user_shipping_address_2 = "";
2045
-
2046
- $user_shipping_city_temp = get_user_meta( $results[0]->user_id, 'shipping_city' );
2047
- if ( isset( $user_shipping_city_temp[0] ) ) $user_shipping_city = $user_shipping_city_temp[0];
2048
- else $user_shipping_city = "";
2049
-
2050
- $user_shipping_postcode_temp = get_user_meta( $results[0]->user_id, 'shipping_postcode' );
2051
- if ( isset( $user_shipping_postcode_temp[0] ) ) $user_shipping_postcode = $user_shipping_postcode_temp[0];
2052
- else $user_shipping_postcode = "";
2053
-
2054
- $user_shipping_state_temp = get_user_meta( $results[0]->user_id, 'shipping_state' );
2055
- if ( isset( $user_shipping_state_temp[0] ) ) $user_shipping_state = $user_shipping_state_temp[0];
2056
- else $user_shipping_state = "";
2057
-
2058
- $user_shipping_country_temp = get_user_meta( $results[0]->user_id, 'shipping_country' );
2059
- if ( isset( $user_shipping_country_temp[0] ) ) $user_shipping_country = $user_shipping_country_temp[0];
2060
- else $user_shipping_country = "";
2061
- }
2062
- $cart_details = array();
2063
- $cart_info = json_decode( $results[0]->abandoned_cart_info );
2064
- $cart_details = (array) $cart_info->cart;
2065
- $item_subtotal = $item_total = 0;
2066
-
2067
- if ( is_array ( $cart_details ) && count($cart_details) > 0 ) {
2068
- foreach ( $cart_details as $k => $v ) {
2069
- $quantity_total = $v->quantity;
2070
- $product_id = $v->product_id;
2071
- $prod_name = get_post($product_id);
2072
- $product_name = $prod_name->post_title;
2073
 
2074
- // Item subtotal is calculated as product total including taxes
2075
- if ( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
2076
- $item_subtotal = $item_subtotal + $v->line_total + $v->line_subtotal_tax;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2077
  } else {
2078
- $item_subtotal = $item_subtotal + $v->line_total;
2079
- }
2080
-
2081
- // Line total
2082
- $item_total = $item_subtotal;
2083
- $item_subtotal = $item_subtotal / $quantity_total;
2084
- $item_total = number_format( $item_total, 2 );
2085
- $item_subtotal = number_format( $item_subtotal, 2 );
2086
- $product = get_product( $product_id );
2087
- $prod_image = $product->get_image();
2088
- ?>
2089
- <tr>
2090
- <td> <?php echo $prod_image; ?></td>
2091
- <td> <?php echo $product->id; ?> </td>
2092
- <td> <?php echo $product_name; ?></td>
2093
- <td> <?php echo $quantity_total; ?></td>
2094
- <td> <?php echo get_woocommerce_currency_symbol()." ".$item_subtotal; ?></td>
2095
- <td> <?php echo get_woocommerce_currency_symbol()." ".$item_total; ?></td>
2096
- </tr>
2097
 
2098
- <?php
2099
- $item_subtotal = $item_total = 0;
2100
- }
2101
- }
2102
- ?>
2103
- </table>
2104
- </div>
2105
- </div>
2106
- <div id="ac_order_customer_details" class="postbox" style="display:block">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2107
  <h3> <p> <?php _e( 'Customer Details' , 'woocommerce-ac' ); ?> </p> </h3>
2108
  <div class="inside" style="height: 300px;" >
2109
- <div id="order_data" class="panel">
2110
- <div style="width:500px;float:left">
2111
- <h3> <p> <?php _e( 'Billing Details' , 'woocommerce-ac' ); ?> </p> </h3>
2112
- <p> <strong> <?php _e( 'Name:' , 'woocommerce-ac' ); ?> </strong>
2113
- <?php echo $user_first_name." ".$user_last_name;?>
2114
- </p>
2115
- <p> <strong> <?php _e( 'Address:' , 'woocommerce-ac' ); ?> </strong>
2116
- <?php echo $user_billing_company."</br>".
2117
- $user_billing_address_1."</br>".
2118
- $user_billing_address_2."</br>".
2119
- $user_billing_city."</br>".
2120
- $user_billing_postcode."</br>".
2121
- $user_billing_state."</br>".
2122
- $user_billing_country."</br>";
2123
- ?>
2124
- </p>
2125
- <p> <strong> <?php _e( 'Email:', 'woocommerce-ac' ); ?> </strong>
2126
- <?php $user_mail_to = "mailto:".$user_email; ?>
2127
- <a href=<?php echo $user_mail_to;?>><?php echo $user_email;?> </a>
2128
- </p>
2129
- <p> <strong> <?php _e( 'Phone:', 'woocommerce-ac' ); ?> </strong>
2130
- <?php echo $user_billing_phone;?>
2131
- </p>
2132
- </div>
2133
- <div style="width:500px;float:right">
2134
  <h3> <p> <?php _e( 'Shipping Details', 'woocommerce-ac' ); ?> </p> </h3>
2135
- <p> <strong> <?php _e( 'Address:', 'woocommerce-ac' ); ?> </strong>
2136
-
2137
- <?php
2138
- if ( $user_shipping_company == '' &&
2139
- $user_shipping_address_1 == '' &&
2140
- $user_shipping_address_2 == '' &&
2141
- $user_shipping_city == '' &&
2142
- $user_shipping_postcode == '' &&
2143
- $user_shipping_state == '' &&
2144
- $user_shipping_country == '') {
2145
- echo "Shipping Address same as Billing Address";
2146
  } else { ?>
2147
- <?php echo $user_shipping_company."</br>".
2148
- $user_shipping_address_1."</br>".
2149
- $user_shipping_address_2."</br>".
2150
- $user_shipping_city."</br>".
2151
- $user_shipping_postcode."</br>".
2152
- $user_shipping_state."</br>".
2153
- $user_shipping_country."</br>";
2154
- ?>
2155
  <br><br>
2156
  <strong> Shipping Charges: </strong>
2157
  <?php if ( $shipping_charges != 0 ) echo $currency_symbol . $shipping_charges;?>
2158
- </p>
2159
- <?php }?>
2160
- </div>
2161
  </div>
2162
  </div>
2163
- </div>
2164
- <?php } elseif ( $action == 'report' ) {
2165
- include_once('class-product-report-table.php');
2166
-
2167
- $wcap_product_report_list = new WACP_Product_Report_Table();
2168
- $wcap_product_report_list->wcap_product_report_prepare_items_lite();
2169
-
2170
- ?>
2171
- <div class="wrap">
2172
- <form id="wacp-sent-emails" method="get" >
2173
- <input type="hidden" name="page" value="woocommerce_ac_page" />
2174
- <?php $wcap_product_report_list->display(); ?>
2175
- </form>
2176
- </div>
2177
-
2178
- <?php }
2179
- }
2180
- echo( "</table>" );
2181
-
2182
- if ( isset( $_GET[ 'action' ] ) ){
2183
- $action = $_GET[ 'action' ];
2184
- }
2185
- if ( isset( $_GET[ 'mode' ] ) ){
2186
- $mode = $_GET[ 'mode' ];
2187
- }
2188
- if ( $action == 'emailtemplates' && ( $mode == 'addnewtemplate' || $mode == 'edittemplate' ) )
2189
- {
2190
- if( $mode=='edittemplate' )
2191
- {
2192
- $edit_id = $_GET[ 'id' ];
2193
-
2194
- $query="SELECT wpet . * FROM `".$wpdb->prefix."ac_email_templates_lite` AS wpet WHERE id = %d ";
2195
- $results = $wpdb->get_results( $wpdb->prepare( $query, $edit_id ) );
2196
- }
2197
-
2198
- $active_post = ( empty( $_POST[ 'is_active' ] ) ) ? '0' : '1';
2199
-
2200
- ?>
2201
-
2202
- <div id="content">
2203
- <form method="post" action="admin.php?page=woocommerce_ac_page&action=emailtemplates" id="ac_settings">
2204
- <input type="hidden" name="mode" value="<?php echo $mode;?>" />
2205
- <?php
2206
- $id_by = "";
2207
- if ( isset( $_GET[ 'id' ] ) ){
2208
- $id_by = $_GET[ 'id' ];
2209
- }
2210
- ?>
2211
- <input type="hidden" name="id" value="<?php echo $id_by ;?>" />
2212
-
2213
- <?php
2214
- $button_mode = "save";
2215
- $display_message = "Add Email Template";
2216
- if ( $mode == 'edittemplate' )
2217
- {
2218
- $button_mode = "update";
2219
- $display_message = "Edit Email Template";
2220
- }
2221
- print'<input type="hidden" name="ac_settings_frm" value="'.$button_mode.'">';?>
2222
- <div id="poststuff">
2223
- <div> <!-- <div class="postbox" > -->
2224
- <h3 class="hndle"><?php _e( $display_message, 'woocommerce-ac' ); ?></h3>
2225
- <div>
2226
- <table class="form-table" id="addedit_template">
2227
-
2228
- <tr>
2229
- <th>
2230
- <label for="woocommerce_ac_template_name"><b><?php _e( 'Template Name:', 'woocommerce-ac');?></b></label>
2231
- </th>
2232
- <td>
2233
- <?php
2234
- $template_name = "";
2235
- if( $mode == 'edittemplate' )
2236
- {
2237
- $template_name = $results[0]->template_name;
2238
- }
2239
-
2240
- print'<input type="text" name="woocommerce_ac_template_name" id="woocommerce_ac_template_name" class="regular-text" value="'.$template_name.'">';?>
2241
- <img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter a template name for reference', 'woocommerce-ac') ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" /></p>
2242
- </tr>
2243
-
2244
- <tr>
2245
- <th>
2246
- <label for="woocommerce_ac_from_name"><b><?php _e( 'Send From This Name:', 'woocommerce-ac' ); ?></b></label>
2247
- </th>
2248
- <td>
2249
- <?php
2250
- $from_name = "Admin";
2251
- if ( $mode == 'edittemplate' )
2252
- {
2253
- $from_name=$results[0]->from_name;
2254
- }
2255
-
2256
- print'<input type="text" name="woocommerce_ac_from_name" id="woocommerce_ac_from_name" class="regular-text" value="'.$from_name.'">';?>
2257
- <img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter the name that should appear in the email sent', 'woocommerce-ac') ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" /></p>
2258
-
2259
- </tr>
2260
- <tr>
2261
- <th>
2262
- <label for="woocommerce_ac_email_from"><b><?php _e( 'Send From This Email Address:', 'woocommerce-ac' ); ?></b></label>
2263
- </th>
2264
- <td>
2265
-
2266
- <?php
2267
- $from_edit = get_option( 'admin_email' );
2268
-
2269
- if ( $mode == 'edittemplate' && $results[0]->from_email != '') { // this is the fix
2270
- $from_edit = $results[0]->from_email;
2271
- }
2272
- print'<input type="text" name="woocommerce_ac_email_from" id="woocommerce_ac_email_from" class="regular-text" value="' . $from_edit . '">'; ?>
2273
- <img class="help_tip" width="16" height="16" data-tip='<?php _e( 'Which email address should be shown in the "From Email" field for this email?', 'woocommerce' ) ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" /></p>
2274
- <?php ?></textarea>
2275
- </td>
2276
- </tr>
2277
- <tr>
2278
- <th>
2279
- <label for="woocommerce_ac_email_reply"><b><?php _e( 'Send Reply Emails to:', 'woocommerce-ac' ); ?></b></label>
2280
- </th>
2281
- <td>
2282
-
2283
- <?php
2284
- $reply_edit = get_option( 'admin_email' );
2285
-
2286
- if ( $mode == 'edittemplate' && $results[0]->reply_email != '' ) { // this is the fix
2287
- $reply_edit = $results[0]->reply_email;
2288
- }
2289
-
2290
- print'<input type="text" name="woocommerce_ac_email_reply" id="woocommerce_ac_email_reply" class="regular-text" value="' . $reply_edit . '">'; ?>
2291
- <img class="help_tip" width="16" height="16" data-tip='<?php _e( 'When a contact receives your email and clicks reply, which email address should that reply be sent to?', 'woocommerce' ) ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" /></p>
2292
- <?php ?></textarea>
2293
- </td>
2294
- </tr>
2295
-
2296
- <tr>
2297
- <th>
2298
- <label for="woocommerce_ac_email_subject"><b><?php _e( 'Subject:', 'woocommerce-ac' ); ?></b></label>
2299
- </th>
2300
- <td>
2301
- <?php
2302
- $subject_edit = "";
2303
- if ( $mode == 'edittemplate' )
2304
- {
2305
- $subject_edit=$results[0]->subject;
2306
- }
2307
-
2308
- print'<input type="text" name="woocommerce_ac_email_subject" id="woocommerce_ac_email_subject" class="regular-text" value="'.$subject_edit.'">';?>
2309
- <img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter the subject that should appear in the email sent', 'woocommerce-ac') ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" /></p>
2310
-
2311
- </tr>
2312
-
2313
- <tr>
2314
- <th>
2315
- <label for="woocommerce_ac_email_body"><b><?php _e( 'Email Body:', 'woocommerce-ac' ); ?></b></label>
2316
- </th>
2317
- <td>
2318
-
2319
- <?php
2320
- $initial_data = "";
2321
- if ( $mode == 'edittemplate' )
2322
- {
2323
- $initial_data = stripslashes( $results[0]->body );
2324
- }
2325
-
2326
- $initial_data = str_replace ( "My document title", "", $initial_data );
2327
-
2328
- wp_editor(
2329
- $initial_data,
2330
- 'woocommerce_ac_email_body',
2331
- array(
2332
- 'media_buttons' => true,
2333
- 'textarea_rows' => 15,
2334
- 'tabindex' => 4,
2335
- 'tinymce' => array(
2336
- 'theme_advanced_buttons1' => 'bold,italic,underline,|,bullist,numlist,blockquote,|,link,unlink,|,spellchecker,fullscreen,|,formatselect,styleselect'
2337
-
2338
- ),
2339
- )
2340
- );
2341
-
2342
- ?>
2343
- <?php echo stripslashes(get_option( 'woocommerce_ac_email_body' )); ?>
2344
- <span class="description"><?php
2345
- echo __( 'Message to be sent in the reminder email.', 'woocommerce-ac' );
2346
- ?></span>
2347
- </td>
2348
- </tr>
2349
-
2350
- <tr>
2351
- <th>
2352
- <label for="is_wc_template"><b><?php _e( 'Use WooCommerce Template Style:', 'woocommerce-ac' ); ?></b></label>
2353
- </th>
2354
- <td>
2355
 
2356
- <?php
2357
- $is_wc_template="";
2358
-
2359
- if ( $mode == 'edittemplate' ) {
2360
- $use_wc_template = $results[0]->is_wc_template;
2361
-
2362
- if ( $use_wc_template == '1' ) {
2363
- $is_wc_template = "checked";
2364
- } else {
2365
- $is_wc_template = "";
2366
- }
2367
- }
2368
- print'<input type="checkbox" name="is_wc_template" id="is_wc_template" ' . $is_wc_template . '> </input>'; ?>
2369
- <img class="help_tip" width="16" height="16" data-tip='<?php _e( 'Use WooCommerce default style template for abandoned cart reminder emails.', 'woocommerce' ) ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" /> <a target = '_blank' href= <?php echo wp_nonce_url( admin_url( '?wacp_preview_woocommerce_mail=true' ), 'woocommerce-ac' ) ; ?> >
2370
- Click here to preview </a>how the email template will look with WooCommerce Template Style enabled. Alternatively, if this is unchecked, the template will appear as <a target = '_blank' href=<?php echo wp_nonce_url( admin_url( '?wacp_preview_mail=true' ), 'woocommerce-ac' ) ; ?>>shown here</a>. <br> <strong>Note: </strong>When this setting is enabled, then "Send From This Name:" & "Send From This Email Address:" will be overwritten with WooCommerce -> Settings -> Email -> Email Sender Options.
2371
- </p>
2372
- </td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2373
 
2374
- </tr>
2375
-
2376
- <tr>
2377
- <th>
2378
- <label for="is_active"><b><?php _e( 'Active:', 'woocommerce-ac' ); ?></b></label>
2379
- </th>
2380
- <td>
 
 
 
 
 
 
 
 
 
 
2381
 
2382
- <?php
2383
- $is_active_edit="";
2384
-
2385
- if ( $mode == 'edittemplate' ) {
2386
- $active_edit = $results[0]->is_active;
2387
-
2388
- if ( $active_edit == '1' ) {
2389
- $is_active_edit = "checked";
2390
- } else {
2391
- $is_active_edit = "";
2392
- }
2393
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2394
 
2395
- if ( $mode == 'copytemplate' ) {
2396
- $active_edit = $results_copy[0]->is_active;
2397
-
2398
- if($active_edit == '1') {
2399
- $is_active_edit = "checked";
2400
- } else {
2401
- $is_active_edit = "";
2402
- }
2403
- }
2404
- print'<input type="checkbox" name="is_active" id="is_active" ' . $is_active_edit . '> </input>'; ?>
2405
- <img class="help_tip" width="16" height="16" data-tip='<?php _e( 'Yes, This email should be sent to shoppers with abandoned carts', 'woocommerce' ) ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" /></p>
2406
- </td>
2407
- </tr>
2408
- <tr>
2409
- <th>
2410
- <label for="woocommerce_ac_email_frequency"><b><?php _e( 'Send this email:', 'woocommerce-ac' ); ?></b></label>
2411
- </th>
2412
- <td>
2413
-
2414
- <select name="email_frequency" id="email_frequency">
2415
-
2416
- <?php
2417
- $frequency_edit = "";
2418
- if( $mode == 'edittemplate')
2419
- {
2420
- $frequency_edit = $results[0]->frequency;
2421
- }
2422
-
2423
- for ( $i = 1; $i < 4; $i++ )
2424
- {
2425
- printf( "<option %s value='%s'>%s</option>\n",
2426
- selected( $i, $frequency_edit, false ),
2427
- esc_attr( $i ),
2428
- $i
2429
- );
2430
- }
2431
-
2432
- ?>
2433
-
2434
- </select>
2435
-
2436
- <select name="day_or_hour" id="day_or_hour">
2437
-
2438
- <?php
2439
- $days_or_hours_edit = "";
2440
- if ( $mode == 'edittemplate')
2441
- {
2442
- $days_or_hours_edit = $results[0]->day_or_hour;
2443
- }
2444
-
2445
- $days_or_hours = array(
2446
- 'Days' => 'Day(s)',
2447
- 'Hours' => 'Hour(s)'
2448
- );
2449
- foreach( $days_or_hours as $k => $v )
2450
- {
2451
- printf( "<option %s value='%s'>%s</option>\n",
2452
- selected( $k, $days_or_hours_edit, false ),
2453
- esc_attr( $k ),
2454
- $v
2455
- );
2456
- }
2457
- ?>
2458
-
2459
- </select>
2460
-
2461
- <span class="description"><?php
2462
- echo __( 'after cart is abandoned.', 'woocommerce-ac' );
2463
- ?></span>
2464
- </td>
2465
- </tr>
2466
-
2467
- <tr>
2468
- <th>
2469
- <label for="woocommerce_ac_email_preview"><b><?php _e( 'Send a test email to:', 'woocommerce-ac' ); ?></b></label>
2470
- </th>
2471
- <td>
2472
-
2473
- <input type="text" id="send_test_email" name="send_test_email" class="regular-text" >
2474
- <input type="button" value="Send a test email" id="preview_email" onclick="javascript:void(0);">
2475
- <img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter the email id to which the test email needs to be sent.', 'woocommerce-ac') ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" />
2476
- <div id="preview_email_sent_msg" style="display:none;"></div>
2477
- </p>
2478
-
2479
- </td>
2480
- </tr>
2481
- </table>
2482
- </div>
2483
- </div>
2484
- </div>
2485
- <p class="submit">
2486
- <?php
2487
- $button_value = "Save Changes";
2488
- if ( $mode == 'edittemplate' )
2489
- {
2490
- $button_value = "Update Changes";
2491
- }?>
2492
- <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e( $button_value, 'woocommerce-ac' ); ?>" />
2493
- </p>
2494
- </form>
2495
- </div>
2496
- <?php
2497
-
2498
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2499
 
2500
- }
 
 
 
 
2501
 
2502
- function bubble_sort_function( $unsort_array, $order ) {
2503
-
2504
- $temp = array();
2505
- foreach ( $unsort_array as $key => $value )
2506
- $temp[$key] = $value; //concatenate something unique to make sure two equal weights don't overwrite each other
2507
-
2508
- asort( $temp, SORT_NUMERIC ); // or ksort($temp, SORT_NATURAL); see paragraph above to understand why
2509
-
2510
- if( $order == 'desc' ) {
2511
- $array = array_reverse( $temp, true );
2512
- }
2513
- else if($order == 'asc') {
2514
- $array = $temp;
2515
- }
2516
- unset( $temp );
2517
-
2518
- return $array;
2519
- }
2520
-
2521
- function my_action_javascript()
2522
- {
2523
- ?>
2524
- <script type="text/javascript" >
2525
- jQuery( document ).ready( function($)
2526
- {
2527
- $( "table#cart_data a.remove_cart" ).click( function()
2528
- {
2529
- var y = confirm( 'Are you sure you want to delete this Abandoned Order' );
2530
- if( y == true )
2531
- {
2532
- var passed_id = this.id;
2533
- var arr = passed_id.split('-');
2534
- var abandoned_order_id = arr[0];
2535
- var user_id = arr[1];
2536
- var data = {
2537
- abandoned_order_id: abandoned_order_id,
2538
- user_id : user_id,
2539
- action : 'remove_cart_data'
2540
- };
2541
-
2542
- // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
2543
- $.post( ajaxurl, data, function( response )
2544
- {
2545
- //alert('Got this from the server: ' + response);
2546
- $( "#row_" + abandoned_order_id ).hide();
2547
- });
2548
- }
2549
- });
2550
- });
2551
- </script>
2552
- <?php
2553
-
2554
- }
2555
-
2556
- function remove_cart_data() {
2557
-
2558
- global $wpdb; // this is how you get access to the database
2559
-
2560
- $abandoned_order_id = $_POST[ 'abandoned_order_id' ];
2561
- $user_id = $_POST[ 'user_id' ];
2562
- $action = $_POST[ 'action' ];
2563
-
2564
- $query = "DELETE FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
2565
- WHERE
2566
- id = '%d' ";
2567
-
2568
- $results = $wpdb->get_results( $wpdb->prepare( $query, $abandoned_order_id ) );
2569
-
2570
- if ( $user_id >= '63000000' ) {
2571
- $guest_query = "DELETE FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = '".$user_id."'";
2572
- $results_guest = $wpdb->get_results( $guest_query );
2573
- }
2574
-
2575
- die();
2576
- }
2577
-
2578
- function my_action_send_preview()
2579
- {
2580
- ?>
2581
- <script type="text/javascript" >
2582
-
2583
- jQuery( document ).ready( function( $ )
2584
- {
2585
- $( "table#addedit_template input#preview_email" ).click( function()
2586
- {
2587
-
2588
- var from_name_preview = $( '#woocommerce_ac_from_name' ).val();
2589
- var reply_name_preview = $( '#woocommerce_ac_email_reply' ).val();
2590
- var from_email_preview = $( '#woocommerce_ac_email_from' ).val();
2591
- var subject_email_preview = $( '#woocommerce_ac_email_subject' ).val();
2592
- var body_email_preview = tinyMCE.activeEditor.getContent();
2593
- var send_email_id = $( '#send_test_email' ).val();
2594
- var is_wc_template = document.getElementById("is_wc_template").checked;
2595
- var data = {
2596
- from_name_preview : from_name_preview,
2597
- reply_name_preview : reply_name_preview,
2598
- from_email_preview : from_email_preview,
2599
- subject_email_preview: subject_email_preview,
2600
- body_email_preview : body_email_preview,
2601
- send_email_id : send_email_id,
2602
- is_wc_template : is_wc_template,
2603
- action : 'preview_email_sent'
2604
- };
2605
-
2606
- // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
2607
- $.post( ajaxurl, data, function( response )
2608
- {
2609
- $( "#preview_email_sent_msg" ).html( "<img src='<?php echo plugins_url(); ?>/woocommerce-abandoned-cart/images/check.jpg'>&nbsp;Email has been sent successfully." );
2610
- $( "#preview_email_sent_msg" ).fadeIn();
2611
- setTimeout( function(){$( "#preview_email_sent_msg" ).fadeOut();}, 3000 );
2612
- //alert('Got this from the server: ' + response);
2613
- });
2614
- });
2615
- });
2616
- </script>
2617
- <?php
2618
- }
2619
-
2620
- function preview_email_sent() {
2621
-
2622
- $from_email_name = $_POST[ 'from_name_preview' ];
2623
- $reply_name_preview = $_POST['reply_name_preview'];
2624
- $from_email_preview = $_POST['from_email_preview'];
2625
- $subject_email_preview = $_POST[ 'subject_email_preview' ];
2626
- $body_email_preview = $_POST[ 'body_email_preview' ];
2627
- $is_wc_template = $_POST['is_wc_template'];
2628
-
2629
- $headers = "From: " . $from_email_name . " <" . $from_email_preview . ">" . "\r\n";
2630
- $headers .= "Content-Type: text/html" . "\r\n";
2631
- $headers .= "Reply-To: " . $reply_name_preview . " " . "\r\n";
2632
-
2633
- $body_email_preview = str_replace( '{{customer.firstname}}', 'John', $body_email_preview );
2634
- $body_email_preview = str_replace( '{{customer.lastname}}', 'Doe', $body_email_preview );
2635
- $body_email_preview = str_replace( '{{customer.fullname}}', 'John'." ".'Doe', $body_email_preview );
2636
- $current_time_stamp = current_time( 'timestamp' );
2637
- $test_date = date( 'd M, Y h:i A', $current_time_stamp );
2638
- $body_email_preview = str_replace( '{{cart.abandoned_date}}', $test_date, $body_email_preview );
2639
-
2640
- $var = '<h3>'.__( "Your Shopping Cart", "woocommerce-ac" ).'</h3>
2641
- <table border="0" cellpadding="10" cellspacing="0" class="templateDataTable">
2642
- <tr align="center">
2643
- <th>'.__( "Item", "woocommerce-ac" ).'</th>
2644
- <th>'.__( "Name", "woocommerce-ac" ).'</th>
2645
- <th>'.__( "Quantity", "woocommerce-ac" ).'</th>
2646
- <th>'.__( "Price", "woocommerce-ac" ).'</th>
2647
- <th>'.__( "Line Subtotal", "woocommerce-ac" ).'</th>
2648
- </tr>
2649
- <tr align="center">
2650
- <td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/images/shoes.jpg"/></td>
2651
- <td>'.__( "Men\'\s Formal Shoes", "woocommerce-ac" ).'</td>
2652
- <td>1</td>
2653
- <td>$100</td>
2654
- <td>$100</td>
2655
- </tr>
2656
- <tr align="center">
2657
- <td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/images/handbag.jpg"/></td>
2658
- <td>'.__( "Woman\'\s Hand Bags", "woocommerce-ac" ).'</td>
2659
- <td>1</td>
2660
- <td>$100</td>
2661
- <td>$100</td>
2662
- </tr>
2663
- <tr align="center">
2664
- <td></td>
2665
- <td></td>
2666
- <td></td>
2667
- <td>'.__( "Cart Total:", "woocommerce-ac" ).'</td>
2668
- <td>$200</td>
2669
- </tr>
2670
- </table>';
2671
-
2672
- $body_email_preview = str_replace( '{{products.cart}}', $var, $body_email_preview );
2673
- if ( isset( $_POST[ 'send_email_id' ] ) ) {
2674
- $to_email_preview = $_POST[ 'send_email_id' ];
2675
- } else {
2676
- $to_email_preview = "";
2677
- }
2678
- $user_email_from = get_option( 'admin_email' );
2679
-
2680
- $body_email_final_preview = stripslashes( $body_email_preview );
2681
- if ( isset( $is_wc_template ) && "true" == $is_wc_template ){
2682
-
2683
- $email_heading = __( 'Abandoned cart reminder', 'woocommerce-ac' );
2684
-
2685
- ob_start();
2686
-
2687
- wc_get_template( 'emails/email-header.php', array( 'email_heading' => $email_heading ) );
2688
-
2689
- $email_body_template_header = ob_get_clean();
2690
-
2691
- ob_start();
2692
-
2693
- wc_get_template( 'emails/email-footer.php' );
2694
-
2695
- $email_body_template_footer = ob_get_clean();
2696
-
2697
- $final_email_body = $email_body_template_header . $body_email_final_preview . $email_body_template_footer;
2698
- wc_mail( $to_email_preview, $subject_email_preview, $final_email_body , $headers );
2699
-
2700
- }else{
2701
- wp_mail( $to_email_preview, $subject_email_preview, stripslashes( $body_email_preview ), $headers );
2702
- }
2703
-
2704
- echo "email sent";
2705
-
2706
- die();
2707
- }
2708
- }
2709
-
2710
- }
2711
-
2712
- $woocommerce_abandon_cart = new woocommerce_abandon_cart();
2713
- ?>
1
  <?php
2
  /*
3
+ Plugin Name: Abandoned Cart Lite for WooCommerce
4
  Plugin URI: http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro
5
  Description: This plugin captures abandoned carts by logged-in users & emails them about it. <strong><a href="http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro">Click here to get the PRO Version.</a></strong>
6
+ Version: 3.5
7
  Author: Tyche Softwares
8
  Author URI: http://www.tychesoftwares.com/
9
+ Text Domain: woocommerce-ac
10
+ Domain Path: /i18n/languages/
11
  */
12
 
 
 
 
 
13
  // Deletion Settings
14
+ register_uninstall_hook( __FILE__, 'woocommerce_ac_delete_lite' );
15
 
16
+ require_once( "includes/wcal_class-guest.php" );
17
+ require_once( "includes/wcal_default-settings.php" );
18
+ require_once( "includes/wcal_actions.php" );
19
+ require_once( "includes/classes/class-wcal-aes.php" );
20
+ require_once( "includes/classes/class-wcal-aes-counter.php" );
21
+ require_once( "includes/wcal-common.php" );
22
+ // Add a new interval of 15 minutes
23
+ add_filter( 'cron_schedules', 'wcal_add_cron_schedule' );
24
 
25
+ function wcal_add_cron_schedule( $schedules ) {
26
+ $schedules['15_minutes_lite'] = array(
27
+ 'interval' => 900, // 15 minutes in seconds
28
+ 'display' => __( 'Once Every Fifteen Minutes' ),
 
29
  );
30
  return $schedules;
31
  }
 
32
  // Schedule an action if it's not already scheduled
33
  if ( ! wp_next_scheduled( 'woocommerce_ac_send_email_action' ) ) {
34
+ wp_schedule_event( time(), '15_minutes_lite', 'woocommerce_ac_send_email_action' );
35
  }
36
 
37
+ // Hook into that action that'll fire every 15 minutes
38
+ add_action( 'woocommerce_ac_send_email_action', 'wcal_send_email_cron' );
39
+
40
+ function wcal_send_email_cron() {
41
  //require_once( ABSPATH.'wp-content/plugins/woocommerce-abandoned-cart/cron/send_email.php' );
42
  $plugin_dir_path = plugin_dir_path( __FILE__ );
43
+ require_once( $plugin_dir_path . 'cron/wcal_send_email.php' );
44
  }
45
 
46
+ function woocommerce_ac_delete_lite() {
 
47
  global $wpdb;
48
+ if ( ! is_multisite() ) {
49
+ $table_name_ac_abandoned_cart_history = $wpdb->prefix . "ac_abandoned_cart_history_lite";
50
+ $sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_abandoned_cart_history ;
51
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
52
+ $wpdb->get_results( $sql_ac_abandoned_cart_history );
53
+
54
+ $table_name_ac_email_templates = $wpdb->prefix . "ac_email_templates_lite";
55
+ $sql_ac_email_templates = "DROP TABLE " . $table_name_ac_email_templates ;
56
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
57
+ $wpdb->get_results( $sql_ac_email_templates );
58
+
59
+ $table_name_ac_sent_history = $wpdb->prefix . "ac_sent_history_lite";
60
+ $sql_ac_sent_history = "DROP TABLE " . $table_name_ac_sent_history ;
61
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
62
+ $wpdb->get_results( $sql_ac_sent_history );
63
+
64
+ $table_name_ac_guest_abandoned_cart_history = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
65
+ $sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_guest_abandoned_cart_history ;
66
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
67
+ $wpdb->get_results( $sql_ac_abandoned_cart_history );
68
+
69
+ $sql_table_user_meta_cart = "DELETE FROM `" . $wpdb->prefix . "usermeta` WHERE meta_key = '_woocommerce_persistent_cart'";
70
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
71
+ $wpdb->get_results( $sql_table_user_meta_cart );
72
+
73
+ $sql_table_user_meta_cart_modified = "DELETE FROM `" . $wpdb->prefix . "usermeta` WHERE meta_key = '_woocommerce_ac_modified_cart'";
74
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
75
+ $wpdb->get_results( $sql_table_user_meta_cart_modified );
76
+ } else {
77
+ $query = "SELECT blog_id FROM `".$wpdb->prefix."blogs`";
78
+ $results = $wpdb->get_results( $query );
79
+
80
+ foreach( $results as $key => $value ) {
81
+ $table_name_ac_abandoned_cart_history = $wpdb->prefix .$value->blog_id."_"."ac_abandoned_cart_history_lite";
82
+ $sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_abandoned_cart_history ;
83
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
84
+ $wpdb->get_results( $sql_ac_abandoned_cart_history );
85
+
86
+ $table_name_ac_email_templates = $wpdb->prefix .$value->blog_id."_"."ac_email_templates_lite";
87
+ $sql_ac_email_templates = "DROP TABLE " . $table_name_ac_email_templates ;
88
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
89
+ $wpdb->get_results( $sql_ac_email_templates );
90
+
91
+ $table_name_ac_sent_history = $wpdb->prefix .$value->blog_id."_"."ac_sent_history_lite";
92
+ $sql_ac_sent_history = "DROP TABLE " . $table_name_ac_sent_history ;
93
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
94
+ $wpdb->get_results( $sql_ac_sent_history );
95
+
96
+ $table_name_ac_guest_abandoned_cart_history = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
97
+ $sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_guest_abandoned_cart_history ;
98
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
99
+ $wpdb->get_results( $sql_ac_abandoned_cart_history );
100
+
101
+ $sql_table_user_meta_cart = "DELETE FROM `" . $wpdb->prefix.$value->blog_id."_"."usermeta` WHERE meta_key = '_woocommerce_persistent_cart'";
102
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
103
+ $wpdb->get_results( $sql_table_user_meta_cart );
104
+
105
+ $sql_table_user_meta_cart_modified = "DELETE FROM `" . $wpdb->prefix.$value->blog_id."_"."usermeta` WHERE meta_key = '_woocommerce_ac_modified_cart'";
106
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
107
+ $wpdb->get_results( $sql_table_user_meta_cart_modified );
108
+ }
109
+ }
110
+ delete_option( 'woocommerce_ac_email_body' );
 
 
 
111
  delete_option( 'ac_lite_cart_abandoned_time' );
112
  delete_option( 'ac_lite_email_admin_on_recovery' );
113
  delete_option( 'ac_lite_settings_status' );
114
+ delete_option( 'woocommerce_ac_default_templates_installed' );
115
+ delete_option( 'wcal_security_key' );
116
+ delete_option( 'ac_lite_track_guest_cart_from_cart_page' );
117
+ delete_option( 'wcal_from_name' );
118
+ delete_option( 'wcal_from_email' );
119
+ delete_option( 'wcal_reply_email' );
120
  }
121
  /**
122
+ * woocommerce_abandon_cart_lite class
123
  **/
124
+ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
125
 
126
+ class woocommerce_abandon_cart_lite {
127
+ var $one_hour;
128
+ var $three_hours;
129
+ var $six_hours;
130
+ var $twelve_hours;
131
+ var $one_day;
132
+ var $one_week;
133
+ var $duration_range_select = array();
134
+ var $start_end_dates = array();
135
+
136
+ public function __construct() {
137
+ $this->one_hour = 60 * 60;
138
+ $this->three_hours = 3 * $this->one_hour;
139
+ $this->six_hours = 6 * $this->one_hour;
140
+ $this->twelve_hours = 12 * $this->one_hour;
141
+ $this->one_day = 24 * $this->one_hour;
142
+ $this->one_week = 7 * $this->one_day;
143
+ $this->duration_range_select = array( 'yesterday' => 'Yesterday',
144
+ 'today' => 'Today',
145
+ 'last_seven' => 'Last 7 days',
146
+ 'last_fifteen' => 'Last 15 days',
147
+ 'last_thirty' => 'Last 30 days',
148
+ 'last_ninety' => 'Last 90 days',
149
+ 'last_year_days' => 'Last 365'
150
+ );
151
+
152
+ $this->start_end_dates = array( 'yesterday' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 24*60*60 ) ),
153
+ 'end_date' => date( "d M Y", ( current_time( 'timestamp' ) - 7*24*60*60 ) ) ),
154
+ 'today' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ),
155
+ 'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
156
+ 'last_seven' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 7*24*60*60 ) ),
157
+ 'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
158
+ 'last_fifteen' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 15*24*60*60 ) ),
159
+ 'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
160
+ 'last_thirty' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 30*24*60*60 ) ),
161
+ 'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
162
+ 'last_ninety' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 90*24*60*60 ) ),
163
+ 'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
164
+ 'last_year_days' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 365*24*60*60 ) ),
165
+ 'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) )
166
+ );
167
+
168
+ // Initialize settings
169
+ register_activation_hook ( __FILE__, array( &$this, 'wcal_activate' ) );
170
+
171
+ // WordPress Administration Menu
172
+ add_action ( 'admin_menu', array( &$this, 'wcal_admin_menu' ) );
173
+
174
+ // Actions to be done on cart update
175
+ add_action ( 'woocommerce_cart_updated', array( &$this, 'wcal_store_cart_timestamp' ) );
176
+
177
+ // delete added temp fields after order is placed
178
+ add_filter ( 'woocommerce_order_details_after_order_table', array( &$this, 'wcal_action_after_delivery_session' ) );
179
+
180
+ add_action ( 'admin_init', array( &$this, 'wcal_action_admin_init' ) );
181
+
182
+ // Update the options as per settings API
183
+ add_action ( 'admin_init', array( &$this, 'wcal_update_db_check' ) );
 
 
 
 
 
184
 
185
+ // Wordpress settings API
186
+ add_action( 'admin_init', array( &$this, 'wcal_initialize_plugin_options' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  // Language Translation
189
+ add_action ( 'init', array( &$this, 'wcal_update_po_file' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
 
191
+ // track links
192
+ add_filter( 'template_include', array( &$this, 'wcal_email_track_links' ), 99, 1 );
 
193
 
194
+ //It will used to unsubcribe the emails.
195
+ add_action( 'template_include', array( &$this, 'wcal_email_unsubscribe'),99, 1 );
 
 
 
 
 
 
 
 
 
196
 
197
+ add_action ( 'admin_enqueue_scripts', array( &$this, 'wcal_enqueue_scripts_js' ) );
198
+ add_action ( 'admin_enqueue_scripts', array( &$this, 'wcal_enqueue_scripts_css' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
 
200
+ if ( is_admin() ) {
201
+ // Load "admin-only" scripts here
202
+ add_action ( 'admin_head', array( &$this, 'wcal_action_send_preview' ) );
203
+ add_action ( 'wp_ajax_wcal_preview_email_sent', array( &$this, 'wcal_preview_email_sent' ) );
204
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
 
206
+ // Send Email on order recovery
207
+ add_action( 'woocommerce_order_status_pending_to_processing_notification', array( &$this, 'wcal_email_admin_recovery' ) );
208
+ add_action( 'woocommerce_order_status_pending_to_completed_notification', array( &$this, 'wcal_email_admin_recovery' ) );
209
+ add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( &$this, 'wcal_email_admin_recovery' ) );
210
+ add_action( 'woocommerce_order_status_failed_to_processing_notification', array( &$this, 'wcal_email_admin_recovery' ) );
211
+ add_action( 'woocommerce_order_status_failed_to_completed_notification', array( &$this, 'wcal_email_admin_recovery' ) );
212
+
213
+ add_action('woocommerce_order_status_changed', array( &$this, 'wcal_email_admin_recovery_for_paypal' ), 10, 3);
214
+
215
+ add_action( 'admin_init', array( $this, 'wcal_preview_emails' ) );
216
+ add_action( 'init', array( $this, 'wcal_app_output_buffer') );
217
+ add_action( 'admin_init', array( &$this, 'wcal_check_pro_activated' ) );
218
+ add_action( 'woocommerce_checkout_order_processed', array( &$this, 'wcal_order_placed' ), 10 , 1 );
219
+ add_filter( 'woocommerce_payment_complete_order_status', array( &$this , 'wcal_order_complete_action' ), 10 , 2 );
220
+ add_filter( 'admin_footer_text', array( $this, 'wcal_admin_footer_text' ), 1 );
221
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
 
223
+ public static function wcal_order_placed( $order_id ) {
224
+ if( session_id() === '' ) {
225
+ //session has not started
226
+ session_start();
227
+ }
228
+
229
+ if ( isset( $_SESSION['email_sent_id'] ) && $_SESSION['email_sent_id'] !='' ) {
230
+ global $woocommerce, $wpdb;
231
+ $email_sent_id = $_SESSION['email_sent_id'];
232
+ $get_ac_id_query = "SELECT abandoned_order_id FROM `" . $wpdb->prefix."ac_sent_history_lite` WHERE id = %d";
233
+ $get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query, $email_sent_id ) );
234
+ $abandoned_order_id = $get_ac_id_results[0]->abandoned_order_id;
235
 
236
+ update_post_meta( $order_id , 'wcal_recover_order_placed', $abandoned_order_id );
237
+ update_post_meta( $order_id , 'wcal_recover_order_placed_sent_id', $email_sent_id );
238
+ } else if ( isset( $_SESSION['abandoned_cart_id_lite'] ) && $_SESSION['abandoned_cart_id_lite'] !='' ) {
239
+ global $woocommerce, $wpdb;
240
+ $results_sent = array();
241
+ $abandoned_cart_id = $_SESSION['abandoned_cart_id_lite'];
242
+ $get_email_sent_for_abandoned_id = "SELECT * FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE abandoned_order_id = %d ";
243
+ $results_sent = $wpdb->get_results ( $wpdb->prepare( $get_email_sent_for_abandoned_id, $abandoned_cart_id ) );
244
+ if ( empty( $results_sent ) && count( $results_sent ) == 0 ) {
245
+ /*
246
+ * If logeged in user place the order once it isdisplyed under the abandoned orders tab.
247
+ * But the email has been not sent to the user. And order is placed successfuly
248
+ * Then We are deleteing those order. But for those orders Recovered email has been set to the Admin.
249
+ * Below code ensure that admin recovery email will not be sent for those orders.
250
+ */
251
+ $get_user_id_of_abandoned_cart = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE id = %d ";
252
+ $get_results_of_user_id = $wpdb->get_results ( $wpdb->prepare( $get_user_id_of_abandoned_cart, $abandoned_cart_id ) );
253
+ $user_id = $get_results_of_user_id[0]->user_id;
254
+ delete_user_meta( $user_id, '_woocommerce_ac_modified_cart' );
255
+ /*
256
+ * It will delete the order from history table if the order is placed before any email sent to the user.
257
+ *
258
+ */
259
+ $table_name = $wpdb->prefix . 'ac_abandoned_cart_history_lite';
260
+ $wpdb->delete( $table_name , array( 'id' => $abandoned_cart_id ) );
261
+ } else {
262
+ $email_sent_id = $results_sent[0]->id;
263
+ update_post_meta( $order_id , 'wcal_recover_order_placed', $abandoned_cart_id );
264
+ update_post_meta( $order_id , 'wcal_recover_order_placed_sent_id', $email_sent_id );
265
+ }
266
+ }
267
+ }
268
+
269
+ public function wcal_order_complete_action( $order_status, $order_id ) {
270
+ if ( 'failed' != $order_status ) {
271
+ global $woocommerce, $wpdb;
272
+ $order = new WC_Order( $order_id );
273
+ $get_abandoned_id_of_order = '';
274
+ $get_sent_email_id_of_order = '';
275
+ $get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
276
+
277
+ if ( isset( $get_abandoned_id_of_order ) && $get_abandoned_id_of_order != '' ){
278
+ $get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
279
+ $get_sent_email_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed_sent_id', true );
280
+
281
+ $query_order = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET recovered_cart= '" . $order_id . "', cart_ignored = '1'
282
+ WHERE id = '".$get_abandoned_id_of_order."' ";
283
+ $wpdb->query( $query_order );
284
+
285
+ $order->add_order_note( __( 'This order was abandoned & subsequently recovered.', 'woocommerce-ac' ) );
286
+
287
+ delete_post_meta( $order_id, 'wcal_recover_order_placed', $get_abandoned_id_of_order );
288
+ delete_post_meta( $order_id, 'wcal_recover_order_placed_sent_id', $get_sent_email_id_of_order );
289
+ delete_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
290
+ }
291
+ }
292
+ return $order_status;
293
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
 
295
+ /**
296
+ * Check If Pro is activated along with Lite version.
297
+ */
298
+ public static function wcal_check_pro_activated() {
299
+ if( is_plugin_active( 'woocommerce-abandon-cart-pro/woocommerce-ac.php' ) && class_exists( 'woocommerce_abandon_cart' ) ) {
300
+ add_action( 'admin_notices', array( 'woocommerce_abandon_cart_lite', 'wcal_check_pro_notice' ) );
301
+ }
302
+ }
303
 
304
+ /**
305
+ * Display a notice in the admin Plugins page if the LITE version is
306
+ * activated with PRO version is activated.
307
+ */
308
+ public static function wcal_check_pro_notice() {
309
+ $class = 'notice notice-error is-dismissible';
310
+ $message = __( 'The Lite & Pro version of Abandoned Cart plugin for WooCommerce (from Tyche Softwares) are active on your website. <br> In this case, the abandoned carts will be captured in both plugins & email reminders will also be sent from both plugins. <br> It is recommended that you deactivate the Lite version & keep the Pro version active.', 'woocommerce-ac' );
311
+ printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
312
+ }
313
 
314
+ /*-----------------------------------------------------------------------------------*/
315
+ /* Class Functions */
316
+ /*-----------------------------------------------------------------------------------*/
317
+ /**
318
+ * Preview email template
319
+ *
320
+ * @return string
321
+ */
322
+ public function wcal_preview_emails() {
323
+ global $woocommerce;
324
+ if( isset( $_GET['wcal_preview_woocommerce_mail'] ) ) {
325
+ if( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-ac') ) {
326
+ die( 'Security check' );
327
+ }
328
+ $message = '';
329
+ // create a new email
330
+ if( $woocommerce->version < '2.3' ) {
331
+ global $email_heading;
332
+ ob_start();
333
+
334
+ include( 'views/wcal-wc-email-template-preview.php' );
335
+ $mailer = WC()->mailer();
336
+ $message = ob_get_clean();
337
+ $email_heading = __( 'HTML Email Template', 'woocommerce' );
338
+ $message = $mailer->wrap_message( $email_heading, $message );
339
+ } else {
340
+ // load the mailer class
341
+ $mailer = WC()->mailer();
342
+ // get the preview email subject
343
+ $email_heading = __( 'Abandoned cart Email Template', 'woocommerce-ac' );
344
+ // get the preview email content
345
+ ob_start();
346
+ include( 'views/wcal-wc-email-template-preview.php' );
347
+ $message = ob_get_clean();
348
+ // create a new email
349
+ $email = new WC_Email();
350
+ // wrap the content with the email template and then add styles
351
+ $message = $email->style_inline( $mailer->wrap_message( $email_heading, $message ) );
352
+ }
353
+ echo $message;
354
+ exit;
355
+ }
356
+
357
+ if ( isset( $_GET['wcal_preview_mail'] ) ) {
358
+ if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-ac') ) {
359
+ die( 'Security check' );
360
+ }
361
+ // get the preview email content
362
+ ob_start();
363
+ include( 'views/wcal-email-template-preview.php' );
364
+ $message = ob_get_clean();
365
+ // print the preview email
366
+ echo $message;
367
+ exit;
368
+ }
369
+ }
370
+ // Language Translation
371
+ function wcal_update_po_file() {
372
+ $domain = 'woocommerce-ac';
373
+ $locale = apply_filters( 'plugin_locale', get_locale(), $domain );
374
+ if ( $loaded = load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '-' . $locale . '.mo' ) ) {
375
+ return $loaded;
376
+ } else {
377
+ load_plugin_textdomain( $domain, FALSE, basename( dirname( __FILE__ ) ) . '/i18n/languages/' );
378
+ }
379
+ }
380
+
381
+ /*-----------------------------------------------------------------------------------*/
382
+ /* Class Functions */
383
+ /*-----------------------------------------------------------------------------------*/
384
+ function wcal_activate() {
385
+ global $wpdb;
386
+ $wcap_collate = '';
387
+ if ( $wpdb->has_cap( 'collation' ) ) {
388
+ $wcap_collate = $wpdb->get_charset_collate();
389
+ }
390
+ $table_name = $wpdb->prefix . "ac_email_templates_lite";
391
+ $sql = "CREATE TABLE IF NOT EXISTS $table_name (
392
+ `id` int(11) NOT NULL AUTO_INCREMENT,
393
+ `subject` text COLLATE utf8_unicode_ci NOT NULL,
394
+ `body` mediumtext COLLATE utf8_unicode_ci NOT NULL,
395
+ `is_active` enum('0','1') COLLATE utf8_unicode_ci NOT NULL,
396
+ `frequency` int(11) NOT NULL,
397
+ `day_or_hour` enum('Days','Hours') COLLATE utf8_unicode_ci NOT NULL,
398
+ `template_name` text COLLATE utf8_unicode_ci NOT NULL,
399
+ PRIMARY KEY (`id`)
400
+ ) $wcap_collate AUTO_INCREMENT=1 ";
401
+
402
+ require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' );
403
+ dbDelta( $sql );
404
+
405
+ $table_name = $wpdb->prefix . "ac_email_templates_lite";
406
+ $check_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'is_wc_template' ";
407
+ $results = $wpdb->get_results( $check_template_table_query );
408
+
409
+ if ( count( $results ) == 0 ) {
410
+ $alter_template_table_query = "ALTER TABLE $table_name
411
+ ADD COLUMN `is_wc_template` enum('0','1') COLLATE utf8_unicode_ci NOT NULL AFTER `template_name`,
412
+ ADD COLUMN `default_template` int(11) NOT NULL AFTER `is_wc_template`";
413
+
414
+ $wpdb->get_results( $alter_template_table_query );
415
+ }
416
+
417
+ $sent_table_name = $wpdb->prefix . "ac_sent_history_lite";
418
+
419
+ $sql_query = "CREATE TABLE IF NOT EXISTS $sent_table_name (
420
+ `id` int(11) NOT NULL auto_increment,
421
+ `template_id` varchar(40) collate utf8_unicode_ci NOT NULL,
422
+ `abandoned_order_id` int(11) NOT NULL,
423
+ `sent_time` datetime NOT NULL,
424
+ `sent_email_id` text COLLATE utf8_unicode_ci NOT NULL,
425
+ PRIMARY KEY (`id`)
426
+ ) $wcap_collate AUTO_INCREMENT=1 ";
427
+
428
+ require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' );
429
+ dbDelta ( $sql_query );
430
+
431
+ $ac_history_table_name = $wpdb->prefix . "ac_abandoned_cart_history_lite";
432
+
433
+ $history_query = "CREATE TABLE IF NOT EXISTS $ac_history_table_name (
434
+ `id` int(11) NOT NULL AUTO_INCREMENT,
435
+ `user_id` int(11) NOT NULL,
436
+ `abandoned_cart_info` text COLLATE utf8_unicode_ci NOT NULL,
437
+ `abandoned_cart_time` int(11) NOT NULL,
438
+ `cart_ignored` enum('0','1') COLLATE utf8_unicode_ci NOT NULL,
439
+ `recovered_cart` int(11) NOT NULL,
440
+ PRIMARY KEY (`id`)
441
+ ) $wcap_collate";
442
+
443
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
444
+ dbDelta( $history_query );
445
+
446
+ // Default templates: function call to create default templates.
447
+ $check_table_empty = $wpdb->get_var( "SELECT COUNT(*) FROM `" . $wpdb->prefix . "ac_email_templates_lite`" );
448
+
449
+ if( !get_option( 'woocommerce_ac_default_templates_installed' ) ) {
450
+ if( 0 == $check_table_empty ) {
451
+ $default_template = new wcal_default_template_settings;
452
+ $default_template->wcal_create_default_templates();
453
+ update_option( 'woocommerce_ac_default_templates_installed', "yes" );
454
+ }
455
+ }
456
+ /**
457
+ * This is add for thos user who Install the plguin first time.
458
+ * So for them this option will be cheked.
459
+ */
460
+ if( !get_option( 'ac_lite_track_guest_cart_from_cart_page' ) ) {
461
+ add_option( 'ac_lite_track_guest_cart_from_cart_page', 'on' );
462
+ }
463
+ if( !get_option( 'wcal_from_name' ) ) {
464
+ add_option( 'wcal_from_name', 'Admin' );
465
+ }
466
+ $wcal_get_admin_email = get_option( 'admin_email' );
467
+ if( !get_option( 'wcal_from_email' ) ) {
468
+ add_option( 'wcal_from_email', $wcal_get_admin_email );
469
+ }
470
+
471
+ if( !get_option( 'wcal_reply_email' ) ) {
472
+ add_option( 'wcal_reply_email', $wcal_get_admin_email );
473
+ }
474
+ }
475
+
476
+ /***************************************************************
477
+ * WP Settings API
478
+ **************************************************************/
479
+ function wcal_initialize_plugin_options() {
480
+ // First, we register a section. This is necessary since all future options must belong to a
481
+ add_settings_section(
482
+ 'ac_lite_general_settings_section', // ID used to identify this section and with which to register options
483
+ __( 'Settings', 'woocommerce-ac' ), // Title to be displayed on the administration page
484
+ array($this, 'ac_lite_general_options_callback' ), // Callback used to render the description of the section
485
+ 'woocommerce_ac_page' // Page on which to add this section of options
486
+ );
487
+
488
+ add_settings_field(
489
+ 'ac_lite_cart_abandoned_time',
490
+ __( 'Cart abandoned cut-off time', 'woocommerce-ac' ),
491
+ array( $this, 'ac_lite_cart_abandoned_time_callback' ),
492
+ 'woocommerce_ac_page',
493
+ 'ac_lite_general_settings_section',
494
+ array( __( 'Consider cart abandoned after X minutes of item being added to cart & order not placed.', 'woocommerce-ac' ) )
495
+ );
496
+
497
+ add_settings_field(
498
+ 'ac_lite_email_admin_on_recovery',
499
+ __( 'Email admin On Order Recovery', 'woocommerce-ac' ),
500
+ array( $this, 'ac_lite_email_admin_on_recovery' ),
501
+ 'woocommerce_ac_page',
502
+ 'ac_lite_general_settings_section',
503
+ array( __( 'Sends email to Admin if an Abandoned Cart Order is recovered.', 'woocommerce-ac' ) )
504
+ );
505
+
506
+ add_settings_field(
507
+ 'ac_lite_track_guest_cart_from_cart_page',
508
+ __( 'Enable tracking carts when customer doesn\'t enter details', 'woocommerce-ac' ),
509
+ array( $this, 'wcal_track_guest_cart_from_cart_page_callback' ),
510
+ 'woocommerce_ac_page',
511
+ 'ac_lite_general_settings_section',
512
+ array( __( 'Enable tracking of abandoned products & carts even if customer does not visit the checkout page or does not enter any details on the checkout page like Name or Email. Tracking will begin as soon as a visitor adds a product to their cart and visits the cart page.', 'woocommerce-ac' ) )
513
+ );
514
+ /*
515
+ * New section for the Adding the abandoned cart setting.
516
+ * Since @: 4.7
517
+ */
518
+
519
+ add_settings_section(
520
+ 'ac_email_settings_section', // ID used to identify this section and with which to register options
521
+ __( 'Settings for abandoned cart recovery emails', 'woocommerce-ac' ), // Title to be displayed on the administration page
522
+ array($this, 'wcal_email_callback' ),// Callback used to render the description of the section
523
+ 'woocommerce_ac_email_page' // Page on which to add this section of options
524
+ );
525
+
526
+ add_settings_field(
527
+ 'wcal_from_name',
528
+ __( '"From" Name', 'woocommerce-ac' ),
529
+ array( $this, 'wcal_from_name_callback' ),
530
+ 'woocommerce_ac_email_page',
531
+ 'ac_email_settings_section',
532
+ array( 'Enter the name that should appear in the email sent.', 'woocommerce-ac' )
533
+ );
534
+
535
+ add_settings_field(
536
+ 'wcal_from_email',
537
+ __( '"From" Address', 'woocommerce-ac' ),
538
+ array( $this, 'wcal_from_email_callback' ),
539
+ 'woocommerce_ac_email_page',
540
+ 'ac_email_settings_section',
541
+ array( 'Email address from which the reminder emails should be sent.', 'woocommerce-ac' )
542
+ );
543
+
544
+ add_settings_field(
545
+ 'wcal_reply_email',
546
+ __( 'Send Reply Emails to', 'woocommerce-ac' ),
547
+ array( $this, 'wcal_reply_email_callback' ),
548
+ 'woocommerce_ac_email_page',
549
+ 'ac_email_settings_section',
550
+ array( 'When a contact receives your email and clicks reply, which email address should that reply be sent to?', 'woocommerce-ac' )
551
+ );
552
+
553
+
554
+ // Finally, we register the fields with WordPress
555
+ register_setting(
556
+ 'woocommerce_ac_settings',
557
+ 'ac_lite_cart_abandoned_time',
558
+ array ( $this, 'ac_lite_cart_time_validation' )
559
+ );
560
+
561
+ register_setting(
562
+ 'woocommerce_ac_settings',
563
+ 'ac_lite_email_admin_on_recovery'
564
+ );
565
+
566
+ register_setting(
567
+ 'woocommerce_ac_settings',
568
+ 'ac_lite_track_guest_cart_from_cart_page'
569
+ );
570
+
571
+ register_setting(
572
+ 'woocommerce_ac_email_settings',
573
+ 'wcal_from_name'
574
+ );
575
+ register_setting(
576
+ 'woocommerce_ac_email_settings',
577
+ 'wcal_from_email'
578
+ );
579
+ register_setting(
580
+ 'woocommerce_ac_email_settings',
581
+ 'wcal_reply_email'
582
+ );
583
+ }
584
+
585
+ /***************************************************************
586
+ * WP Settings API callback for section
587
+ **************************************************************/
588
+ function ac_lite_general_options_callback() {
589
+
590
+ }
591
+
592
+ /***************************************************************
593
+ * WP Settings API callback for cart time field
594
+ **************************************************************/
595
+ function ac_lite_cart_abandoned_time_callback( $args ) {
596
+ // First, we read the option
597
+ $cart_abandoned_time = get_option( 'ac_lite_cart_abandoned_time' );
598
+ // Next, we update the name attribute to access this element's ID in the context of the display options array
599
+ // We also access the show_header element of the options collection in the call to the checked() helper function
600
+ printf(
601
+ '<input type="text" id="ac_lite_cart_abandoned_time" name="ac_lite_cart_abandoned_time" value="%s" />',
602
+ isset( $cart_abandoned_time ) ? esc_attr( $cart_abandoned_time ) : ''
603
+ );
604
+ // Here, we'll take the first argument of the array and add it to a label next to the checkbox
605
+ $html = '<label for="ac_lite_cart_abandoned_time"> ' . $args[0] . '</label>';
606
+ echo $html;
607
+ }
608
+
609
+ /***************************************************************
610
+ * WP Settings API cart time field validation
611
+ **************************************************************/
612
+ function ac_lite_cart_time_validation( $input ) {
613
+ $output = '';
614
+ if ( $input != '' && ( is_numeric( $input) && $input > 0 ) ) {
615
+ $output = stripslashes( $input) ;
616
+ } else {
617
+ add_settings_error( 'ac_lite_cart_abandoned_time', 'error found', __( 'Abandoned cart cut off time should be numeric and has to be greater than 0.', 'woocommerce-ac' ) );
618
+ }
619
+ return $output;
620
+ }
621
+
622
+ /***************************************************************
623
+ * WP Settings API callback for email admin on cart recovery field
624
+ **************************************************************/
625
+ function ac_lite_email_admin_on_recovery( $args ) {
626
+ // First, we read the option
627
+ $email_admin_on_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
628
+
629
+ // This condition added to avoid the notie displyed while Check box is unchecked.
630
+ if( isset( $email_admin_on_recovery ) && $email_admin_on_recovery == '' ) {
631
+ $email_admin_on_recovery = 'off';
632
+ }
633
+ // Next, we update the name attribute to access this element's ID in the context of the display options array
634
+ // We also access the show_header element of the options collection in the call to the checked() helper function
635
+ $html='';
636
+ printf(
637
+ '<input type="checkbox" id="ac_lite_email_admin_on_recovery" name="ac_lite_email_admin_on_recovery" value="on"
638
+ ' . checked('on', $email_admin_on_recovery, false).' />'
639
+ );
640
+
641
+ // Here, we'll take the first argument of the array and add it to a label next to the checkbox
642
+ $html .= '<label for="ac_lite_email_admin_on_recovery"> ' . $args[0] . '</label>';
643
+ echo $html;
644
+ }
645
+ /***************************************************************
646
+ * @since : 2.7
647
+ * WP Settings API callback for capturing guest cart which do not reach the checkout page.
648
+ **************************************************************/
649
+ function wcal_track_guest_cart_from_cart_page_callback( $args ) {
650
+ // First, we read the option
651
+ $disable_guest_cart_from_cart_page = get_option( 'ac_lite_track_guest_cart_from_cart_page' );
652
+
653
+ // This condition added to avoid the notice displyed while Check box is unchecked.
654
+ if ( isset( $disable_guest_cart_from_cart_page ) && $disable_guest_cart_from_cart_page == '' ) {
655
+ $disable_guest_cart_from_cart_page = 'off';
656
+ }
657
+ // Next, we update the name attribute to access this element's ID in the context of the display options array
658
+ // We also access the show_header element of the options collection in the call to the checked() helper function
659
+ $html = '';
660
+
661
+ printf(
662
+ '<input type="checkbox" id="ac_lite_track_guest_cart_from_cart_page" name="ac_lite_track_guest_cart_from_cart_page" value="on"
663
+ '.checked( 'on', $disable_guest_cart_from_cart_page, false ) . ' />' );
664
+ // Here, we'll take the first argument of the array and add it to a label next to the checkbox
665
+ $html .= '<label for="ac_lite_track_guest_cart_from_cart_page"> ' . $args[0] . '</label>';
666
+ echo $html;
667
+ }
668
+
669
+ /***************************************************************
670
+ * WP Settings API callback for Abandoned cart email settings of the plugin
671
+ **************************************************************/
672
+ function wcal_email_callback () {
673
+
674
+ }
675
+
676
+ public static function wcal_from_name_callback( $args ) {
677
+ // First, we read the option
678
+ $wcal_from_name = get_option( 'wcal_from_name' );
679
+ // Next, we update the name attribute to access this element's ID in the context of the display options array
680
+ // We also access the show_header element of the options collection in the call to the checked() helper function
681
+ printf(
682
+ '<input type="text" id="wcal_from_name" name="wcal_from_name" value="%s" />',
683
+ isset( $wcal_from_name ) ? esc_attr( $wcal_from_name ) : ''
684
+ );
685
+ // Here, we'll take the first argument of the array and add it to a label next to the checkbox
686
+ $html = '<label for="wcal_from_name_label"> ' . $args[0] . '</label>';
687
+ echo $html;
688
+ }
689
+
690
+ public static function wcal_from_email_callback( $args ) {
691
+ // First, we read the option
692
+ $wcal_from_email = get_option( 'wcal_from_email' );
693
+ // Next, we update the name attribute to access this element's ID in the context of the display options array
694
+ // We also access the show_header element of the options collection in the call to the checked() helper function
695
+ printf(
696
+ '<input type="text" id="wcal_from_email" name="wcal_from_email" value="%s" />',
697
+ isset( $wcal_from_email ) ? esc_attr( $wcal_from_email ) : ''
698
+ );
699
+ // Here, we'll take the first argument of the array and add it to a label next to the checkbox
700
+ $html = '<label for="wcal_from_email_label"> ' . $args[0] . '</label>';
701
+ echo $html;
702
+ }
703
+
704
+ public static function wcal_reply_email_callback( $args ) {
705
+ // First, we read the option
706
+ $wcal_reply_email = get_option( 'wcal_reply_email' );
707
+ // Next, we update the name attribute to access this element's ID in the context of the display options array
708
+ // We also access the show_header element of the options collection in the call to the checked() helper function
709
+ printf(
710
+ '<input type="text" id="wcal_reply_email" name="wcal_reply_email" value="%s" />',
711
+ isset( $wcal_reply_email ) ? esc_attr( $wcal_reply_email ) : ''
712
+ );
713
+ // Here, we'll take the first argument of the array and add it to a label next to the checkbox
714
+ $html = '<label for="wcal_reply_email_label"> ' . $args[0] . '</label>';
715
+ echo $html;
716
+ }
717
+ /**************************************************
718
+ * This function is run when the plugin is upgraded
719
+ *************************************************/
720
+ function wcal_update_db_check() {
721
+ global $wpdb;
722
+ $wcap_collate = '';
723
+ if ( $wpdb->has_cap( 'collation' ) ) {
724
+ $wcap_collate = $wpdb->get_charset_collate();
725
+ }
726
+ if( get_option( 'ac_lite_delete_alter_table_queries' ) != 'yes' ) {
727
+ update_option( 'ac_lite_alter_table_queries', '' );
728
+ update_option( 'ac_lite_delete_alter_table_queries', 'yes' );
729
+ }
730
+ if( get_option( 'ac_lite_alter_table_queries' ) != 'yes' ) {
731
+ if( $wpdb->get_var( "SHOW TABLES LIKE '" . $wpdb->prefix . "ac_email_templates'" ) === $wpdb->prefix . 'ac_email_templates' ) {
732
+ $old_table_name = $wpdb->prefix . "ac_email_templates";
733
+ $table_name = $wpdb->prefix . "ac_email_templates_lite";
734
+
735
+ $alter_ac_email_table_query = "ALTER TABLE $old_table_name
736
+ RENAME TO $table_name";
737
+ $wpdb->get_results ( $alter_ac_email_table_query );
738
+ }
739
+
740
+ if( $wpdb->get_var( "SHOW TABLES LIKE '" . $wpdb->prefix . "ac_sent_history'" ) === $wpdb->prefix . 'ac_sent_history' ) {
741
+ $old_sent_table_name = $wpdb->prefix . "ac_sent_history";
742
+ $sent_table_name = $wpdb->prefix . "ac_sent_history_lite";
743
+ $alter_ac_sent_history_table_query = "ALTER TABLE $old_sent_table_name
744
+ RENAME TO $sent_table_name";
745
+ $wpdb->get_results ( $alter_ac_sent_history_table_query );
746
+ }
747
+
748
+ if( $wpdb->get_var( "SHOW TABLES LIKE '" . $wpdb->prefix . "ac_abandoned_cart_history'" ) === $wpdb->prefix . 'ac_abandoned_cart_history' ) {
749
+ $old_ac_history_table_name = $wpdb->prefix . "ac_abandoned_cart_history";
750
+ $ac_history_table_name = $wpdb->prefix . "ac_abandoned_cart_history_lite";
751
+
752
+ $alter_ac_abandoned_cart_history_table_query = "ALTER TABLE $old_ac_history_table_name
753
+ RENAME TO $ac_history_table_name";
754
+ $wpdb->get_results ( $alter_ac_abandoned_cart_history_table_query );
755
+ }
756
+ update_option( 'ac_lite_alter_table_queries', 'yes' );
757
+ }
758
+
759
+ $ac_history_table_name = $wpdb->prefix."ac_abandoned_cart_history_lite";
760
+ $check_table_query = "SHOW COLUMNS FROM $ac_history_table_name LIKE 'user_type'";
761
+ $results = $wpdb->get_results( $check_table_query );
762
+
763
+ if ( count( $results ) == 0 ) {
764
+ $alter_table_query = "ALTER TABLE $ac_history_table_name ADD `user_type` text AFTER `recovered_cart`";
765
+ $wpdb->get_results( $alter_table_query );
766
+ }
767
+
768
+ $table_name = $wpdb->prefix . "ac_email_templates_lite";
769
+ $check_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'is_wc_template' ";
770
+ $results = $wpdb->get_results( $check_template_table_query );
771
+
772
+ if ( count( $results ) == 0 ) {
773
+ $alter_template_table_query = "ALTER TABLE $table_name
774
+ ADD COLUMN `is_wc_template` enum('0','1') COLLATE utf8_unicode_ci NOT NULL AFTER `template_name`,
775
+ ADD COLUMN `default_template` int(11) NOT NULL AFTER `is_wc_template`";
776
+ $wpdb->get_results( $alter_template_table_query );
777
+ }
778
+
779
+
780
+ $table_name = $wpdb->prefix . "ac_email_templates_lite";
781
+ $check_email_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'wc_email_header' ";
782
+ $results_email = $wpdb->get_results( $check_email_template_table_query );
783
+
784
+ if ( count( $results_email ) == 0 ) {
785
+ $alter_email_template_table_query = "ALTER TABLE $table_name
786
+ ADD COLUMN `wc_email_header` varchar(50) COLLATE utf8_unicode_ci NOT NULL AFTER `default_template`";
787
+ $wpdb->get_results( $alter_email_template_table_query );
788
+ }
789
+
790
+ $guest_table = $wpdb->prefix."ac_guest_abandoned_cart_history_lite" ;
791
+ $query_guest_table = "SHOW TABLES LIKE '$guest_table' ";
792
+ $result_guest_table = $wpdb->get_results( $query_guest_table );
793
+
794
+ if ( count( $result_guest_table ) == 0 ) {
795
+
796
+ $ac_guest_history_table_name = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
797
+ $ac_guest_history_query = "CREATE TABLE IF NOT EXISTS $ac_guest_history_table_name (
798
+ `id` int(15) NOT NULL AUTO_INCREMENT,
799
+ `billing_first_name` text,
800
+ `billing_last_name` text,
801
+ `billing_company_name` text,
802
+ `billing_address_1` text,
803
+ `billing_address_2` text,
804
+ `billing_city` text,
805
+ `billing_county` text,
806
+ `billing_zipcode` text,
807
+ `email_id` text,
808
+ `phone` text,
809
+ `ship_to_billing` text,
810
+ `order_notes` text,
811
+ `shipping_first_name` text,
812
+ `shipping_last_name` text,
813
+ `shipping_company_name` text,
814
+ `shipping_address_1` text,
815
+ `shipping_address_2` text,
816
+ `shipping_city` text,
817
+ `shipping_county` text,
818
+ `shipping_zipcode` double,
819
+ `shipping_charges` double,
820
+ PRIMARY KEY (`id`)
821
+ ) $wcap_collate AUTO_INCREMENT=63000000";
822
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php');
823
+ $wpdb->query( $ac_guest_history_query );
824
+ }
825
+ //get the option, if it is not set to individual then convert to individual records and delete the base record
826
+ $ac_settings = get_option( 'ac_lite_settings_status' );
827
+ if ( $ac_settings != 'INDIVIDUAL' ) {
828
+ //fetch the existing settings and save them as inidividual to be used for the settings API
829
+ $woocommerce_ac_settings = json_decode( get_option( 'woocommerce_ac_settings' ) );
830
+ if( isset( $woocommerce_ac_settings[0]->cart_time ) ) {
831
+ add_option( 'ac_lite_cart_abandoned_time', $woocommerce_ac_settings[0]->cart_time );
832
+ } else {
833
+ add_option( 'ac_lite_cart_abandoned_time', '10' );
834
+ }
835
+
836
+ if( isset( $woocommerce_ac_settings[0]->email_admin ) ) {
837
+ add_option( 'ac_lite_email_admin_on_recovery', $woocommerce_ac_settings[0]->email_admin );
838
+ } else {
839
+ add_option( 'ac_lite_email_admin_on_recovery', "" );
840
+ }
841
+
842
+ if( isset( $woocommerce_ac_settings[0]->disable_guest_cart_from_cart_page ) ) {
843
+ add_option( 'ac_lite_track_guest_cart_from_cart_page', $woocommerce_ac_settings[0]->disable_guest_cart_from_cart_page );
844
+ } else {
845
+ add_option( 'ac_lite_track_guest_cart_from_cart_page', "" );
846
+ }
847
+
848
+ update_option( 'ac_lite_settings_status', 'INDIVIDUAL' );
849
+ //Delete the main settings record
850
+ delete_option( 'woocommerce_ac_settings' );
851
+ }
852
+ if ( !get_option( 'wcal_security_key' ) ){
853
+ update_option( 'wcal_security_key', 'qJB0rGtIn5UB1xG03efyCp' );
854
+ }
855
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_abandoned_cart_history_lite';" ) ) {
856
+ if ( ! $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_abandoned_cart_history_lite` LIKE 'unsubscribe_link';" ) ) {
857
+ $wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_abandoned_cart_history_lite ADD `unsubscribe_link` enum('0','1') COLLATE utf8_unicode_ci NOT NULL AFTER `user_type`;" );
858
+ }
859
+ }
860
+
861
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_abandoned_cart_history_lite';" ) ) {
862
+ if ( ! $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_abandoned_cart_history_lite` LIKE 'session_id';" ) ) {
863
+ $wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_abandoned_cart_history_lite ADD `session_id` varchar(50) COLLATE utf8_unicode_ci NOT NULL AFTER `unsubscribe_link`;" );
864
+ }
865
+ }
866
+ /*
867
+ * This is used to prevent guest users wrong Id. If guest users id is less then 63000000 then this code will ensure that we will change the id of guest tables so it wont affect on the next guest users.
868
+ */
869
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_guest_abandoned_cart_history_lite';" ) && 'yes' != get_option( 'wcal_guest_user_id_altered' ) ) {
870
+ $last_id = $wpdb->get_var( "SELECT max(id) FROM `{$wpdb->prefix}ac_guest_abandoned_cart_history_lite`;" );
871
+ if ( NULL != $last_id && $last_id <= 63000000 ) {
872
+ $wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_guest_abandoned_cart_history_lite AUTO_INCREMENT = 63000000;" );
873
+ update_option ( 'wcal_guest_user_id_altered', 'yes' );
874
+ }
875
+ }
876
+
877
+ /*
878
+ * Since 4.7
879
+ * We have moved email templates fields in the setings section. SO to remove that fields column fro the db we need it.
880
+ * For existing user we need to fill this setting with the first template.
881
+ */
882
+ if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_email_templates_lite';" ) ) {
883
+ if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'from_email';" ) ) {
884
+ $get_email_template_query = "SELECT `from_email` FROM {$wpdb->prefix}ac_email_templates_lite WHERE `is_active` = '1' ORDER BY `id` ASC LIMIT 1";
885
+ $get_email_template_result = $wpdb->get_results ($get_email_template_query);
886
+ $wcal_from_email = '';
887
+ if ( isset( $get_email_template_result ) && count ( $get_email_template_result ) > 0 ){
888
+ $wcal_from_email = $get_email_template_result[0]->from_email;
889
+ /* Store data in setings api*/
890
+ update_option ( 'wcal_from_email', $wcal_from_email );
891
+ /* Delete table from the Db*/
892
+ $wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_email_templates_lite DROP COLUMN `from_email`;" );
893
+ }
894
+ }
895
+
896
+ if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'from_name';" ) ) {
897
+ $get_email_template_from_name_query = "SELECT `from_name` FROM {$wpdb->prefix}ac_email_templates_lite WHERE `is_active` = '1' ORDER BY `id` ASC LIMIT 1";
898
+ $get_email_template_from_name_result = $wpdb->get_results ($get_email_template_from_name_query);
899
+ $wcal_from_name = '';
900
+ if ( isset( $get_email_template_from_name_result ) && count ( $get_email_template_from_name_result ) > 0 ){
901
+ $wcal_from_name = $get_email_template_from_name_result[0]->from_name;
902
+ /* Store data in setings api*/
903
+ add_option ( 'wcal_from_name', $wcal_from_name );
904
+ /* Delete table from the Db*/
905
+ $wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_email_templates_lite DROP COLUMN `from_name`;" );
906
+ }
907
+ }
908
+
909
+ if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'reply_email';" ) ) {
910
+ $get_email_template_reply_email_query = "SELECT `reply_email` FROM {$wpdb->prefix}ac_email_templates_lite WHERE `is_active` = '1' ORDER BY `id` ASC LIMIT 1";
911
+ $get_email_template_reply_email_result = $wpdb->get_results ($get_email_template_reply_email_query);
912
+ $wcal_reply_email = '';
913
+ if ( isset( $get_email_template_reply_email_result ) && count ( $get_email_template_reply_email_result ) > 0 ){
914
+ $wcal_reply_email = $get_email_template_reply_email_result[0]->reply_email;
915
+ /* Store data in setings api*/
916
+ update_option ( 'wcal_reply_email', $wcal_reply_email );
917
+ /* Delete table from the Db*/
918
+ $wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_email_templates_lite DROP COLUMN `reply_email`;" );
919
+ }
920
+ }
921
+ }
922
+ }
923
+
924
+ /******
925
+ * Send email to admin when cart is recovered only via PayPal.
926
+ * @since 2.9 version
927
+ */
928
+ public static function wcal_email_admin_recovery_for_paypal ( $order_id, $old, $new_status ) {
929
+ if ( 'pending' == $old && 'processing' == $new_status ) {
930
+ $user_id = get_current_user_id();
931
+ $ac_email_admin_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
932
+ $order = new WC_Order( $order_id );
933
+ $user_id = $order->user_id;
934
+
935
+ if( $ac_email_admin_recovery == 'on' ) {
936
+ $recovered_email_sent = get_post_meta( $order_id, 'wcap_recovered_email_sent', true );
937
+ $check_abandoned_cart = get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true );
938
+ $created_via = get_post_meta ( $order_id, '_created_via', true );
939
+
940
+ // mention here why are we comparing both "yes" and "no" values
941
+ if ( 'checkout' == $created_via && 'yes' != $recovered_email_sent && ( $check_abandoned_cart == md5( "yes" ) || $check_abandoned_cart == md5( "no" ) ) ) { // indicates cart is abandoned
942
+ $order = new WC_Order( $order_id );
943
+ $email_heading = __( 'New Customer Order - Recovered', 'woocommerce' );
944
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
945
+ $email_subject = "New Customer Order - Recovered";
946
+ $user_email = get_option( 'admin_email' );
947
+ $headers[] = "From: Admin <".$user_email.">";
948
+ $headers[] = "Content-Type: text/html";
949
+ // Buffer
950
+ ob_start();
951
+ // Get mail template
952
+ woocommerce_get_template( 'emails/admin-new-order.php', array(
953
+ 'order' => $order,
954
+ 'email_heading' => $email_heading,
955
+ 'sent_to_admin' => false,
956
+ 'plain_text' => false,
957
+ 'email' => true
958
+ )
959
+ );
960
+ // Get contents
961
+ $email_body = ob_get_clean();
962
+ woocommerce_mail( $user_email, $email_subject, $email_body, $headers );
963
+ update_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
964
+ }
965
+ }
966
+ }
967
+ }
968
+
969
+ /******
970
+ * Send email to admin when cart is recovered via any other payment gateway other than PayPal.
971
+ * @since 2.3 version
972
+ */
973
+ function wcal_email_admin_recovery ( $order_id ) {
974
+ $user_id = get_current_user_id();
975
+ $ac_email_admin_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
976
+ if( $ac_email_admin_recovery == 'on' ) {
977
+ $order = new WC_Order( $order_id );
978
+ $user_id = $order->user_id;
979
+ $recovered_email_sent = get_post_meta( $order_id, 'wcap_recovered_email_sent', true );
980
+ $check_abandoned_cart = get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true );
981
+ $created_via = get_post_meta( $order_id, '_created_via', true );
982
+ if ( 'checkout' == $created_via && 'yes' != $recovered_email_sent && ( $check_abandoned_cart == md5( "yes" ) || $check_abandoned_cart == md5( "no" ) ) ) { // indicates cart is abandoned
983
+ $email_heading = __( 'New Customer Order - Recovered', 'woocommerce-ac' );
984
+ $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
985
+ $email_subject = "New Customer Order - Recovered";
986
+ $user_email = get_option( 'admin_email' );
987
+ $headers[] = "From: Admin <".$user_email.">";
988
+ $headers[] = "Content-Type: text/html";
989
+ // Buffer
990
+ ob_start();
991
+ // Get mail template
992
+ woocommerce_get_template( 'emails/admin-new-order.php', array(
993
+ 'order' => $order,
994
+ 'email_heading' => $email_heading,
995
+ 'sent_to_admin' => false,
996
+ 'plain_text' => false,
997
+ 'email' => true
998
+ ) );
999
+ // Get contents
1000
+ $email_body = ob_get_clean();
1001
+ woocommerce_mail( $user_email, $email_subject, $email_body, $headers );
1002
+
1003
+ update_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
1004
+ }
1005
+ }
1006
+ }
1007
+
1008
+ // Add a submenu page.
1009
+ function wcal_admin_menu() {
1010
+ $page = add_submenu_page ( 'woocommerce', __( 'Abandoned Carts', 'woocommerce-ac' ), __( 'Abandoned Carts', 'woocommerce-ac' ), 'manage_woocommerce', 'woocommerce_ac_page', array( &$this, 'wcal_menu_page' ) );
1011
+ }
1012
+
1013
+ // Capture the cart and insert the information of the cart into DataBase
1014
+ function wcal_store_cart_timestamp() {
1015
+
1016
+ if( session_id() === '' ){
1017
+ //session has not started
1018
+ session_start();
1019
+ }
1020
+ global $wpdb,$woocommerce;
1021
+ $current_time = current_time( 'timestamp' );
1022
+ $cut_off_time = get_option( 'ac_lite_cart_abandoned_time' );
1023
+ $track_guest_cart_from_cart_page = get_option( 'ac_lite_track_guest_cart_from_cart_page' );
1024
+ $cart_ignored = 0;
1025
+ $recovered_cart = 0;
1026
+
1027
+ $track_guest_user_cart_from_cart = "";
1028
+ if ( isset( $track_guest_cart_from_cart_page ) ) {
1029
+ $track_guest_user_cart_from_cart = $track_guest_cart_from_cart_page;
1030
+ }
1031
+
1032
+ if( isset( $cut_off_time ) ) {
1033
+ $cart_cut_off_time = $cut_off_time * 60;
1034
+ } else {
1035
+ $cart_cut_off_time = 60 * 60;
1036
+ }
1037
+ $compare_time = $current_time - $cart_cut_off_time;
1038
+
1039
+ if ( is_user_logged_in() ) {
1040
+ $user_id = get_current_user_id();
1041
+ $query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1042
+ WHERE user_id = %d
1043
+ AND cart_ignored = %s
1044
+ AND recovered_cart = %d ";
1045
+ $results = $wpdb->get_results($wpdb->prepare( $query, $user_id, $cart_ignored, $recovered_cart ) );
1046
+
1047
+ if ( count($results) == 0 ) {
1048
+ $cart_info = json_encode( get_user_meta( $user_id, '_woocommerce_persistent_cart', true ) );
1049
+ $user_type = "REGISTERED";
1050
+ $insert_query = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1051
+ ( user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type )
1052
+ VALUES ( %d, %s, %d, %s, %s )";
1053
+ $wpdb->query( $wpdb->prepare( $insert_query, $user_id, $cart_info,$current_time, $cart_ignored, $user_type ) );
1054
 
1055
+ $abandoned_cart_id = $wpdb->insert_id;
1056
+ $_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
1057
+ } elseif ( isset( $results[0]->abandoned_cart_time ) && $compare_time > $results[0]->abandoned_cart_time ) {
1058
+ $updated_cart_info = json_encode( get_user_meta( $user_id, '_woocommerce_persistent_cart', true ) );
1059
+
1060
+ if ( ! $this->wcal_compare_carts( $user_id, $results[0]->abandoned_cart_info ) ) {
1061
+ $updated_cart_ignored = 1;
1062
+ $query_ignored = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1063
+ SET cart_ignored = %s
1064
+ WHERE user_id = %d ";
1065
+ $wpdb->query( $wpdb->prepare( $query_ignored, $updated_cart_ignored, $user_id ) );
1066
 
1067
+ $user_type = "REGISTERED";
1068
+ $query_update = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1069
+ (user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type)
1070
+ VALUES (%d, %s, %d, %s, %s)";
1071
+ $wpdb->query( $wpdb->prepare( $query_update, $user_id, $updated_cart_info, $current_time, $cart_ignored, $user_type ) );
1072
+
1073
+ update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "yes" ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1074
 
1075
+ $abandoned_cart_id = $wpdb->insert_id;
1076
+ $_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
1077
+ } else {
1078
+ update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "no" ) );
1079
+ }
1080
+ } else {
1081
+ $updated_cart_info = json_encode( get_user_meta( $user_id, '_woocommerce_persistent_cart', true ) );
1082
+
1083
+ $query_update = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1084
+ SET abandoned_cart_info = %s,
1085
+ abandoned_cart_time = %d
1086
+ WHERE user_id = %d
1087
+ AND cart_ignored = %s ";
1088
+ $wpdb->query( $wpdb->prepare( $query_update, $updated_cart_info, $current_time, $user_id, $cart_ignored ) );
1089
+
1090
+ $query_update = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE user_id ='" . $user_id . "' AND cart_ignored='0' ";
1091
+ $get_abandoned_record = $wpdb->get_results( $query_update );
1092
+ $abandoned_cart_id = $get_abandoned_record[0]->id;
1093
+
1094
+ $_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
1095
+ }
1096
+ } else {
1097
+ //start here guest user
1098
+ if ( isset( $_SESSION['user_id'] ) ) {
1099
+ $user_id = $_SESSION['user_id'];
1100
+ } else {
1101
+ $user_id = "";
1102
+ }
1103
+
1104
+ $query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id = %d AND cart_ignored = '0' AND recovered_cart = '0' AND user_id != '0'";
1105
+ $results = $wpdb->get_results( $wpdb->prepare( $query, $user_id ) );
1106
+ $cart = array();
1107
+ $get_cookie = WC()->session->get_session_cookie();
1108
+ if ( function_exists('WC') ) {
1109
+ $cart['cart'] = WC()->session->cart;
1110
+ } else {
1111
+ $cart['cart'] = $woocommerce->session->cart;
1112
+ }
1113
+
1114
+ $updated_cart_info = json_encode($cart);
1115
+ $updated_cart_info = addslashes ( $updated_cart_info );
1116
+
1117
+ if ( count($results) > 0 ) {
1118
+ if ( $compare_time > $results[0]->abandoned_cart_time ) {
1119
+ if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
1120
+
1121
+ $query_ignored = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1122
+ SET cart_ignored = '1'
1123
+ WHERE user_id ='".$user_id."'";
1124
+ $wpdb->query( $query_ignored );
1125
+ $user_type = 'GUEST';
1126
+ $query_update = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1127
+ (user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type)
1128
+ VALUES (%d, %s, %d, %s, %s)";
1129
+ $wpdb->query( $wpdb->prepare( $query_update, $user_id, $updated_cart_info, $current_time, $cart_ignored, $user_type ) );
1130
+ update_user_meta( $user_id, '_woocommerce_ac_modified_cart', md5("yes") );
1131
+ } else {
1132
+ update_user_meta( $user_id, '_woocommerce_ac_modified_cart', md5("no") );
1133
+ }
1134
+ } else {
1135
+ $query_update = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1136
+ SET abandoned_cart_info = '".$updated_cart_info."', abandoned_cart_time = '".$current_time."'
1137
+ WHERE user_id='".$user_id."' AND cart_ignored='0' ";
1138
+ $wpdb->query( $query_update );
1139
+ }
1140
+ } else {
1141
+ /***
1142
+ * @Since: 3.5
1143
+ * Here we capture the guest cart from the cart page.
1144
+ */
1145
+ if ( $track_guest_user_cart_from_cart == "on" && $get_cookie[0] != '' ) {
1146
+ $query = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE session_id LIKE %s AND cart_ignored = '0' AND recovered_cart = '0' ";
1147
+ $results = $wpdb->get_results( $wpdb->prepare( $query, $get_cookie[0] ) );
1148
+ if ( count( $results ) == 0 ) {
1149
+ $cart_info = $updated_cart_info;
1150
+ $blank_cart_info = '[]';
1151
+ if ( $blank_cart_info != $cart_info ) {
1152
+ $insert_query = "INSERT INTO `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
1153
+ ( abandoned_cart_info , abandoned_cart_time , cart_ignored , recovered_cart, user_type, session_id )
1154
+ VALUES ( '" . $cart_info."' , '" . $current_time . "' , '0' , '0' , 'GUEST', '". $get_cookie[0] ."' )";
1155
+ $wpdb->query( $insert_query );
1156
+ }
1157
+ } elseif ( $compare_time > $results[0]->abandoned_cart_time ) {
1158
+ $blank_cart_info = '[]';
1159
+ if ( $blank_cart_info != $updated_cart_info ) {
1160
+ if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
1161
+ $query_ignored = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET cart_ignored = '1' WHERE session_id ='" . $get_cookie[0] . "'";
1162
+ $wpdb->query( $query_ignored );
1163
+ $query_update = "INSERT INTO `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
1164
+ ( abandoned_cart_info, abandoned_cart_time, cart_ignored, recovered_cart, user_type, session_id )
1165
+ VALUES ( '" . $updated_cart_info . "', '" . $current_time . "', '0', '0', 'GUEST', '". $get_cookie[0] ."' )";
1166
+ $wpdb->query( $query_update );
1167
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1168
  }
1169
+ } else {
1170
+ $blank_cart_info = '[]';
1171
+ if ( $blank_cart_info != $updated_cart_info ) {
1172
+ if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
1173
+ $query_update = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET abandoned_cart_info = '" . $updated_cart_info . "', abandoned_cart_time = '" . $current_time . "' WHERE session_id ='" . $get_cookie[0] . "' AND cart_ignored='0' ";
1174
+ $wpdb->query( $query_update );
1175
+ }
1176
+ }
1177
+ }
1178
  }
1179
+ }
1180
+ }
1181
+ }
1182
+
1183
+ // Decrypt Function
1184
+ function wcal_decrypt_validate( $validate ) {
1185
+ $cryptKey = get_option( 'wcal_security_key' );
1186
+ $validate_decoded = rtrim( mcrypt_decrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), base64_decode( $validate ), MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ), "\0");
1187
+ return( $validate_decoded );
1188
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1189
 
1190
+ function wcal_email_unsubscribe( $args ) {
1191
+ global $wpdb;
1192
+
1193
+ if ( isset( $_GET['wcal_track_unsubscribe'] ) && $_GET['wcal_track_unsubscribe'] == 'wcal_unsubscribe' ) {
1194
+ $encoded_email_id = rawurldecode( $_GET['validate'] );
1195
+ $validate_email_id_string = str_replace( " " , "+", $encoded_email_id);
1196
+ $validate_email_address_string = '';
1197
+ $validate_email_id_decode = 0;
1198
+ if( isset( $_GET['track_email_id'] ) ) {
1199
+ $encoded_email_address = rawurldecode( $_GET['track_email_id'] );
1200
+ $validate_email_address_string = str_replace( " " , "+", $encoded_email_address );
1201
+ if( isset( $validate_email_id_string ) ) {
1202
+ if( function_exists( "mcrypt_encrypt" ) ) {
1203
+ $validate_email_id_decode = $this->wcal_decrypt_validate( $validate_email_id_string );
1204
+ } else {
1205
+ $validate_email_id_decode = base64_decode( $validate_email_id_string );
1206
+ }
1207
+ }
1208
+ $validate_email_address_string = $validate_email_address_string;
1209
+ }
1210
+ if( !preg_match('/^[1-9][0-9]*$/', $validate_email_id_decode ) ) { // This will decrypt more security
1211
+ $cryptKey = get_option( 'wcal_security_key' );
1212
+ $validate_email_id_decode = Wcal_Aes_Ctr::decrypt( $validate_email_id_string, $cryptKey, 256 );
1213
+ }
1214
+ $query_id = "SELECT * FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE id = %d ";
1215
+ $results_sent = $wpdb->get_results ( $wpdb->prepare( $query_id, $validate_email_id_decode ) );
1216
+ $email_address = '';
1217
+ if( isset( $results_sent[0] ) ) {
1218
+ $email_address = $results_sent[0]->sent_email_id;
1219
+ }
1220
+ if( $validate_email_address_string == hash( 'sha256', $email_address ) ) {
1221
+ $email_sent_id = $validate_email_id_decode;
1222
+ $get_ac_id_query = "SELECT abandoned_order_id FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE id = %d";
1223
+ $get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query , $email_sent_id ) );
1224
+ $user_id = 0;
1225
+ if( isset( $get_ac_id_results[0] ) ) {
1226
+ $get_user_id_query = "SELECT user_id FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE id = %d";
1227
+ $get_user_results = $wpdb->get_results( $wpdb->prepare( $get_user_id_query , $get_ac_id_results[0]->abandoned_order_id ) );
1228
  }
1229
+ if( isset( $get_user_results[0] ) ) {
1230
+ $user_id = $get_user_results[0]->user_id;
1231
+ }
1232
+
1233
+ $unsubscribe_query = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
1234
+ SET unsubscribe_link = '1'
1235
+ WHERE user_id= %d AND cart_ignored='0' ";
1236
+ $wpdb->query( $wpdb->prepare( $unsubscribe_query , $user_id ) );
1237
+ echo "Unsubscribed Successfully";
1238
+ sleep( 2 );
1239
+ $url = get_option( 'siteurl' );
1240
+ ?>
1241
+ <script>
1242
+ location.href = "<?php echo $url; ?>";
1243
+ </script>
1244
+ <?php
1245
+ }
1246
+ } else {
1247
+ return $args;
1248
+ }
1249
+ }
1250
+
1251
+ // It will track the URL of cart link from email
1252
+ function wcal_email_track_links( $template ) {
1253
+ global $woocommerce;
1254
+ $track_link = '';
1255
+
1256
+ if ( isset( $_GET['wcal_action'] ) ) {
1257
+ $track_link = $_GET['wcal_action'];
1258
+ }
1259
+ if ( $track_link == 'track_links' ) {
1260
+ if( session_id() === '' ) {
1261
+ //session has not started
1262
+ session_start();
1263
+ }
1264
+ global $wpdb;
1265
+ $validate_server_string = rawurldecode( $_GET ['validate'] );
1266
+ $validate_server_string = str_replace( " " , "+", $validate_server_string );
1267
+ $validate_encoded_string = $validate_server_string;
1268
+ $link_decode_test = base64_decode( $validate_encoded_string );
1269
+ // it will check if any old email have open the link
1270
+ if ( preg_match( '/&url=/', $link_decode_test ) ) {
1271
+ $link_decode = $link_decode_test;
1272
+ } else {
1273
+ if( function_exists( "mcrypt_encrypt" ) ) {
1274
+ $link_decode = $this->wcal_decrypt_validate( $validate_encoded_string );
1275
+ } else {
1276
+ $link_decode = base64_decode( $validate_encoded_string );
1277
+ }
1278
+ }
1279
+ if ( !preg_match( '/&url=/', $link_decode ) ) { // This will decrypt more security
1280
+ $cryptKey = get_option( 'wcal_security_key' );
1281
+ $link_decode = Wcal_Aes_Ctr::decrypt( $validate_encoded_string, $cryptKey, 256 );
1282
+ }
1283
+ $sent_email_id_pos = strpos( $link_decode, '&' );
1284
+ $email_sent_id = substr( $link_decode , 0, $sent_email_id_pos );
1285
+ $_SESSION['email_sent_id'] = $email_sent_id;
1286
+ $url_pos = strpos( $link_decode, '=' );
1287
+ $url_pos = $url_pos + 1;
1288
+ $url = substr( $link_decode, $url_pos );
1289
+ $get_ac_id_query = "SELECT abandoned_order_id FROM `".$wpdb->prefix."ac_sent_history_lite` WHERE id = %d";
1290
+ $get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query, $email_sent_id ) );
1291
+ $get_user_id_query = "SELECT user_id FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE id = %d";
1292
+ $get_user_results = $wpdb->get_results( $wpdb->prepare( $get_user_id_query, $get_ac_id_results[0]->abandoned_order_id ) );
1293
+ $user_id = 0;
1294
+ if ( isset( $get_user_results ) && count( $get_user_results ) > 0 ) {
1295
+ $user_id = $get_user_results[0]->user_id;
1296
+ }
1297
+ if ( $user_id == 0 ) {
1298
+ echo "Link expired";
1299
+ exit;
1300
+ }
1301
+ $user = wp_set_current_user( $user_id );
1302
+ if ( $user_id >= "63000000" ) {
1303
+ $query_guest = "SELECT * from `". $wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d";
1304
+ $results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $user_id ) );
1305
+ $query_cart = "SELECT recovered_cart FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id = %d";
1306
+ $results = $wpdb->get_results( $wpdb->prepare( $query_cart, $user_id ) );
1307
+ if ( $results_guest && $results[0]->recovered_cart == '0' ) {
1308
+ $_SESSION['guest_first_name'] = $results_guest[0]->billing_first_name;
1309
+ $_SESSION['guest_last_name'] = $results_guest[0]->billing_last_name;
1310
+ $_SESSION['guest_email'] = $results_guest[0]->email_id;
1311
+ $_SESSION['user_id'] = $user_id;
1312
+ } else {
1313
+ wp_redirect( get_permalink( woocommerce_get_page_id( 'shop' ) ) );
1314
+ }
1315
+ }
1316
+
1317
+ if ( $user_id < "63000000" ) {
1318
+ $user_login = $user->data->user_login;
1319
+ wp_set_auth_cookie( $user_id );
1320
+ $my_temp = woocommerce_load_persistent_cart( $user_login, $user );
1321
+ do_action( 'wp_login', $user_login, $user );
1322
+ if ( isset( $sign_in ) && is_wp_error( $sign_in ) ) {
1323
+ echo $sign_in->get_error_message();
1324
+ exit;
1325
+ }
1326
+ } else
1327
+ $my_temp = $this->wcal_load_guest_persistent_cart( $user_id );
1328
+
1329
+ if ( $email_sent_id > 0 && is_numeric( $email_sent_id ) ) {
1330
+ header( "Location: $url" );
1331
+ }
1332
+ } else
1333
+ return $template;
1334
+ }
1335
+
1336
+ // load the information of the guest user
1337
+ function wcal_load_guest_persistent_cart() {
1338
+ global $woocommerce;
1339
+ $saved_cart = json_decode( get_user_meta( $_SESSION['user_id'], '_woocommerce_persistent_cart',true ), true );
1340
+ $c = array();
1341
+ $cart_contents_total = $cart_contents_weight = $cart_contents_count = $cart_contents_tax = $total = $subtotal = $subtotal_ex_tax = $tax_total = 0;
1342
+
1343
+ foreach ( $saved_cart as $key => $value ) {
1344
+ foreach ( $value as $a => $b ) {
1345
+ $c['product_id'] = $b['product_id'];
1346
+ $c['variation_id'] = $b['variation_id'];
1347
+ $c['variation'] = $b['variation'];
1348
+ $c['quantity'] = $b['quantity'];
1349
+ $product_id = $b['product_id'];
1350
+ $c['data'] = get_product($product_id);
1351
+ $c['line_total'] = $b['line_total'];
1352
+ $c['line_tax'] = $cart_contents_tax;
1353
+ $c['line_subtotal'] = $b['line_subtotal'];
1354
+ $c['line_subtotal_tax'] = $cart_contents_tax;
1355
+ $value_new[ $a ] = $c;
1356
+ $cart_contents_total = $b['line_subtotal'] + $cart_contents_total;
1357
+ $cart_contents_count = $cart_contents_count + $b['quantity'];
1358
+ $total = $total + $b['line_total'];
1359
+ $subtotal = $subtotal + $b['line_subtotal'];
1360
+ $subtotal_ex_tax = $subtotal_ex_tax + $b['line_subtotal'];
1361
+ }
1362
+ $saved_cart_data[ $key ] = $value_new;
1363
+ $woocommerce_cart_hash = $a;
1364
+ }
1365
+
1366
+ if( $saved_cart ) {
1367
+ if ( empty( $woocommerce->session->cart ) || ! is_array( $woocommerce->session->cart ) || sizeof( $woocommerce->session->cart ) == 0 ) {
1368
+ $woocommerce->session->cart = $saved_cart['cart'];
1369
+ $woocommerce->session->cart_contents_total = $cart_contents_total;
1370
+ $woocommerce->session->cart_contents_weight = $cart_contents_weight;
1371
+ $woocommerce->session->cart_contents_count = $cart_contents_count;
1372
+ $woocommerce->session->cart_contents_tax = $cart_contents_tax;
1373
+ $woocommerce->session->total = $total;
1374
+ $woocommerce->session->subtotal = $subtotal;
1375
+ $woocommerce->session->subtotal_ex_tax = $subtotal_ex_tax;
1376
+ $woocommerce->session->tax_total = $tax_total;
1377
+ $woocommerce->session->shipping_taxes = array();
1378
+ $woocommerce->session->taxes = array();
1379
+ $woocommerce->session->ac_customer = array();
1380
+ $woocommerce->cart->cart_contents = $saved_cart_data['cart'];
1381
+ $woocommerce->cart->cart_contents_total = $cart_contents_total;
1382
+ $woocommerce->cart->cart_contents_weight = $cart_contents_weight;
1383
+ $woocommerce->cart->cart_contents_count = $cart_contents_count;
1384
+ $woocommerce->cart->cart_contents_tax = $cart_contents_tax;
1385
+ $woocommerce->cart->total = $total;
1386
+ $woocommerce->cart->subtotal = $subtotal;
1387
+ $woocommerce->cart->subtotal_ex_tax = $subtotal_ex_tax;
1388
+ $woocommerce->cart->tax_total = $tax_total;
1389
+ }
1390
+ }
1391
+ }
1392
+
1393
+ function wcal_compare_only_guest_carts( $new_cart, $last_abandoned_cart ) {
1394
+ $current_woo_cart = array();
1395
+ $current_woo_cart = json_decode( stripslashes( $new_cart ), true );
1396
+ $abandoned_cart_arr = array();
1397
+ $abandoned_cart_arr = json_decode( $last_abandoned_cart, true );
1398
+ $temp_variable = "";
1399
+
1400
+ if ( count( $current_woo_cart['cart'] ) >= count( $abandoned_cart_arr['cart'] ) ) {
1401
+ //do nothing
1402
+ } else {
1403
+ $temp_variable = $current_woo_cart;
1404
+ $current_woo_cart = $abandoned_cart_arr;
1405
+ $abandoned_cart_arr = $temp_variable;
1406
+ }
1407
+ if ( is_array( $current_woo_cart ) || is_object( $current_woo_cart ) ) {
1408
+ foreach( $current_woo_cart as $key => $value ) {
1409
+ foreach( $value as $item_key => $item_value ) {
1410
+ $current_cart_product_id = $item_value['product_id'];
1411
+ $current_cart_variation_id = $item_value['variation_id'];
1412
+ $current_cart_quantity = $item_value['quantity'];
1413
+
1414
+ if ( isset( $abandoned_cart_arr[$key][$item_key]['product_id'] ) ){
1415
+ $abandoned_cart_product_id = $abandoned_cart_arr[$key][$item_key]['product_id'];
1416
+ } else {
1417
+ $abandoned_cart_product_id = "";
1418
+ }
1419
+ if ( isset( $abandoned_cart_arr[$key][$item_key]['variation_id'] ) ) {
1420
+ $abandoned_cart_variation_id = $abandoned_cart_arr[$key][$item_key]['variation_id'];
1421
+ } else {
1422
+ $abandoned_cart_variation_id = "";
1423
+ }
1424
+ if ( isset( $abandoned_cart_arr[$key][$item_key]['quantity'] ) ) {
1425
+ $abandoned_cart_quantity = $abandoned_cart_arr[$key][$item_key]['quantity'];
1426
+ } else {
1427
+ $abandoned_cart_quantity = "";
1428
+ }
1429
+ if ( ( $current_cart_product_id != $abandoned_cart_product_id ) ||
1430
+ ( $current_cart_variation_id != $abandoned_cart_variation_id ) ||
1431
+ ( $current_cart_quantity != $abandoned_cart_quantity ) ) {
1432
+ return false;
1433
+ }
1434
+ }
1435
+ }
1436
+ }
1437
+ return true;
1438
+ }
1439
+
1440
+ // Compare the existing cart with new cart
1441
+ function wcal_compare_carts( $user_id, $last_abandoned_cart ) {
1442
+ $current_woo_cart = get_user_meta( $user_id, '_woocommerce_persistent_cart', true );
1443
+ $abandoned_cart_arr = json_decode( $last_abandoned_cart, true );
1444
+ $temp_variable = "";
1445
+ if ( count( $current_woo_cart['cart'] ) >= count( $abandoned_cart_arr['cart'] ) ) {
1446
+ //do nothing
1447
+ } else {
1448
+ $temp_variable = $current_woo_cart;
1449
+ $current_woo_cart = $abandoned_cart_arr;
1450
+ $abandoned_cart_arr = $temp_variable;
1451
+ }
1452
+ foreach ( $current_woo_cart as $key => $value ) {
1453
+
1454
+ foreach ( $value as $item_key => $item_value ) {
1455
+ $current_cart_product_id = $item_value['product_id'];
1456
+ $current_cart_variation_id = $item_value['variation_id'];
1457
+ $current_cart_quantity = $item_value['quantity'];
1458
+
1459
+ if ( isset( $abandoned_cart_arr[$key][$item_key]['product_id'] ) ) {
1460
+ $abandoned_cart_product_id = $abandoned_cart_arr[$key][$item_key]['product_id'];
1461
+ } else {
1462
+ $abandoned_cart_product_id = "";
1463
+ }
1464
+ if ( isset( $abandoned_cart_arr[$key][$item_key]['variation_id'] ) ) {
1465
+ $abandoned_cart_variation_id = $abandoned_cart_arr[$key][$item_key]['variation_id'];
1466
+ } else {
1467
+ $abandoned_cart_variation_id = "";
1468
+ }
1469
+ if ( isset( $abandoned_cart_arr[$key][$item_key]['quantity'] ) ) {
1470
+ $abandoned_cart_quantity = $abandoned_cart_arr[$key][$item_key]['quantity'];
1471
+ } else {
1472
+ $abandoned_cart_quantity = "";
1473
+ }
1474
+ if ( ( $current_cart_product_id != $abandoned_cart_product_id ) ||
1475
+ ( $current_cart_variation_id != $abandoned_cart_variation_id ) ||
1476
+ ( $current_cart_quantity != $abandoned_cart_quantity ) )
1477
+ {
1478
+ return false;
1479
+ }
1480
+ }
1481
+ }
1482
+ return true;
1483
+ }
1484
+
1485
+ // function is call when order is recovered
1486
+ function wcal_action_after_delivery_session( $order ) {
1487
+
1488
+ if( session_id() === '' ){
1489
+ //session has not started
1490
+ session_start();
1491
+ }
1492
+ global $wpdb;
1493
+ $order_id = $order->id;
1494
+ $get_abandoned_id_of_order = '';
1495
+ $get_sent_email_id_of_order = '';
1496
+ $get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
1497
+ if( isset( $get_abandoned_id_of_order ) && $get_abandoned_id_of_order != '' ){
1498
+ $get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
1499
+ $get_sent_email_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed_sent_id', true );
1500
+
1501
+ $query_order = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET recovered_cart= '" . $order_id . "', cart_ignored = '1'
1502
+ WHERE id = '".$get_abandoned_id_of_order."' ";
1503
+ $wpdb->query( $query_order );
1504
+
1505
+ $order->add_order_note( __( 'This order was abandoned & subsequently recovered.', 'woocommerce-ac' ) );
1506
+
1507
+ delete_post_meta( $order_id, 'wcal_recover_order_placed', $get_abandoned_id_of_order );
1508
+ delete_post_meta( $order_id , 'wcal_recover_order_placed_sent_id', $get_sent_email_id_of_order );
1509
+ }
1510
+ $user_id = get_current_user_id();
1511
+ $sent_email = '';
1512
+ if( isset( $_SESSION['email_sent_id'] ) ){
1513
+ $sent_email = $_SESSION['email_sent_id'];
1514
+ }
1515
+ if( $user_id == "" ) {
1516
+ $user_id = $_SESSION['user_id'];
1517
+ // Set the session variables to blanks
1518
+ $_SESSION['guest_first_name'] = $_SESSION['guest_last_name'] = $_SESSION['guest_email'] = $_SESSION['user_id'] = "";
1519
+ }
1520
+ delete_user_meta( $user_id, '_woocommerce_ac_persistent_cart_time' );
1521
+ delete_user_meta( $user_id, '_woocommerce_ac_persistent_cart_temp_time' );
1522
+ // get all latest abandoned carts that were modified
1523
+ $cart_ignored = 0;
1524
+ $recovered_cart = 0;
1525
+ $query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1526
+ WHERE user_id = %d
1527
+ AND cart_ignored = %s
1528
+ AND recovered_cart = %d
1529
+ ORDER BY id DESC
1530
+ LIMIT 1";
1531
+ $results = $wpdb->get_results( $wpdb->prepare( $query, $user_id, $cart_ignored, $recovered_cart ) );
1532
+ if ( count( $results ) > 0 ) {
1533
+ if ( get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true ) == md5( "yes" ) ||
1534
+ get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true ) == md5( "no" ) ) {
1535
+
1536
+ $order_id = $order->id;
1537
+ $updated_cart_ignored = 1;
1538
+ $query_order = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1539
+ SET recovered_cart = %d,
1540
+ cart_ignored = %s
1541
+ WHERE id = %d ";
1542
+ $wpdb->query( $wpdb->prepare( $query_order, $order_id, $updated_cart_ignored, $results[0]->id ) );
1543
+ delete_user_meta( $user_id, '_woocommerce_ac_modified_cart' );
1544
+ delete_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
1545
+ } else {
1546
+ $delete_query = "DELETE FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1547
+ WHERE id= %d ";
1548
+ $wpdb->query( $wpdb->prepare( $delete_query, $results[0]->id ) );
1549
  }
1550
+ } else {
1551
+ $email_id = $order->billing_email;
1552
+ $query = "SELECT * FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE email_id = %s";
1553
+ $results_id = $wpdb->get_results( $wpdb->prepare( $query, $email_id ) );
1554
+
1555
+ if ( $results_id ) {
1556
+ $record_status = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1557
+ WHERE user_id = %d AND recovered_cart = '0'";
1558
+ $results_status = $wpdb->get_results( $wpdb->prepare( $record_status, $results_id[0]->id ) );
1559
+
1560
+ if ( $results_status ) {
1561
+ if ( get_user_meta( $results_id[0]->id, '_woocommerce_ac_modified_cart', true ) == md5("yes") ||
1562
+ get_user_meta( $results_id[0]->id, '_woocommerce_ac_modified_cart', true ) == md5("no") ) {
1563
+
1564
+ $order_id = $order->id;
1565
+ $query_order = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1566
+ SET recovered_cart= '".$order_id."', cart_ignored = '1'
1567
+ WHERE id='".$results_status[0]->id."' ";
1568
+ $wpdb->query( $query_order );
1569
+ delete_user_meta( $results_id[0]->id, '_woocommerce_ac_modified_cart' );
1570
+ delete_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
1571
+ } else {
1572
+ $delete_guest = "DELETE FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = '".$results_id[0]->id."'";
1573
+ $wpdb->query( $delete_guest );
1574
+
1575
+ $delete_query = "DELETE FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id='".$results_id[0]->id."' ";
1576
+ $wpdb->query( $delete_query );
1577
+ }
1578
+ }
1579
+ }
1580
+ }
1581
+ }
1582
+
1583
+ function wcal_action_admin_init() {
1584
+ global $typenow;
1585
+ // only hook up these filters if we're in the admin panel and the current user has permission
1586
+ // to edit posts and pages
1587
+ if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) ) {
1588
+ return;
1589
+ }
1590
+ if ( !isset( $_GET['page'] ) || $_GET['page'] != "woocommerce_ac_page" ) {
1591
+ return;
1592
+ }
1593
+ if ( get_user_option( 'rich_editing' ) == 'true' ) {
1594
+ remove_filter( 'the_excerpt', 'wpautop' );
1595
+ add_filter( 'tiny_mce_before_init', array( &$this, 'wcal_format_tiny_MCE' ) );
1596
+ add_filter( 'mce_buttons', array( &$this, 'wcal_filter_mce_button' ) );
1597
+ add_filter( 'mce_external_plugins', array( &$this, 'wcal_filter_mce_plugin' ) );
1598
+ }
1599
+ if ( isset( $_GET['page'] ) && 'woocommerce_ac_page' == $_GET['page'] ) {
1600
+ if( session_id() === '' ){
1601
+ //session has not started
1602
+ session_start();
1603
+ }
1604
+ }
1605
+ }
1606
+
1607
+ function wcal_filter_mce_button( $buttons ) {
1608
+ // add a separation before our button, here our button's id is &quot;mygallery_button&quot;
1609
+ array_push( $buttons, 'abandoncart', '|' );
1610
+ return $buttons;
1611
+ }
1612
+
1613
+ function wcal_filter_mce_plugin( $plugins ) {
1614
+ // this plugin file will work the magic of our button
1615
+ $plugins['abandoncart'] = plugin_dir_url( __FILE__ ) . 'assets/js/abandoncart_plugin_button.js';
1616
+ return $plugins;
1617
+ }
1618
+
1619
+ function wcal_display_tabs() {
1620
+
1621
+ if ( isset( $_GET['action'] ) ) {
1622
+ $action = $_GET['action'];
1623
+ } else {
1624
+ $action = "";
1625
+ $active_listcart = "";
1626
+ $active_emailtemplates = "";
1627
+ $active_settings = "";
1628
+ $active_stats = "";
1629
+ }
1630
+ if ( ( $action == 'listcart' || $action == 'orderdetails' ) || $action == '' ) {
1631
+ $active_listcart = "nav-tab-active";
1632
+ }
1633
+ if ( $action == 'emailtemplates' ) {
1634
+ $active_emailtemplates = "nav-tab-active";
1635
+ }
1636
+ if ( $action == 'emailsettings' ) {
1637
+ $active_settings = "nav-tab-active";
1638
+ }
1639
+ if ( $action == 'stats' ) {
1640
+ $active_stats = "nav-tab-active";
1641
+ }
1642
+ if ( $action == 'report' ) {
1643
+ $active_report = "nav-tab-active";
1644
+ }
1645
+ ?>
1646
+ <div style="background-image: url('<?php echo plugins_url(); ?>/woocommerce-abandoned-cart/assets/images/ac_tab_icon.png') !important;" class="icon32"><br>
1647
+ </div>
1648
+ <h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
1649
+ <a href="admin.php?page=woocommerce_ac_page&action=listcart" class="nav-tab <?php if (isset($active_listcart)) echo $active_listcart; ?>"> <?php _e( 'Abandoned Orders', 'woocommerce-ac' );?> </a>
1650
+ <a href="admin.php?page=woocommerce_ac_page&action=emailtemplates" class="nav-tab <?php if (isset($active_emailtemplates)) echo $active_emailtemplates; ?>"> <?php _e( 'Email Templates', 'woocommerce-ac' );?> </a>
1651
+ <a href="admin.php?page=woocommerce_ac_page&action=emailsettings" class="nav-tab <?php if (isset($active_settings)) echo $active_settings; ?>"> <?php _e( 'Settings', 'woocommerce-ac' );?> </a>
1652
+ <a href="admin.php?page=woocommerce_ac_page&action=stats" class="nav-tab <?php if (isset($active_stats)) echo $active_stats; ?>"> <?php _e( 'Recovered Orders', 'woocommerce-ac' );?> </a>
1653
+ <a href="admin.php?page=woocommerce_ac_page&action=report" class="nav-tab <?php if( isset( $active_report ) ) echo $active_report; ?>"> <?php _e( 'Product Report', 'woocommerce-ac' );?> </a>
1654
+ </h2>
1655
+ <?php
1656
+ }
1657
+
1658
+ function wcal_enqueue_scripts_js( $hook ) {
1659
+
1660
+ if ( $hook != 'woocommerce_page_woocommerce_ac_page' ) {
1661
+ return;
1662
+ } else {
1663
+ wp_enqueue_script( 'jquery' );
1664
+ wp_enqueue_script(
1665
+ 'jquery-ui-min',
1666
+ '//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js',
1667
+ '',
1668
+ '',
1669
+ false
1670
+ );
1671
+ wp_enqueue_script( 'jquery-ui-datepicker' );
1672
+
1673
+ wp_enqueue_script(
1674
+ 'jquery-tip',
1675
+ plugins_url( '/assets/js/jquery.tipTip.minified.js', __FILE__ ),
1676
+ '',
1677
+ '',
1678
+ false
1679
+ );
1680
+ wp_register_script( 'woocommerce_admin', plugins_url() . '/woocommerce/assets/js/admin/woocommerce_admin.js', array( 'jquery', 'jquery-ui-widget', 'jquery-ui-core' ) );
1681
+ wp_enqueue_script( 'woocommerce_admin' );
1682
+ ?>
1683
+ <script type="text/javascript" >
1684
+ function wcal_activate_email_template( template_id, active_state ) {
1685
+ location.href = 'admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=activate_template&id='+template_id+'&active_state='+active_state ;
1686
+ }
1687
+ </script>
1688
+ <?php
1689
+ $js_src = includes_url('js/tinymce/') . 'tinymce.min.js';
1690
+ wp_enqueue_script( 'tinyMce_ac',$js_src );
1691
+ wp_enqueue_script( 'ac_email_variables', plugins_url() . '/woocommerce-abandoned-cart/assets/js/abandoncart_plugin_button.js' );
1692
+ }
1693
+ }
1694
+
1695
+ function wcal_format_tiny_MCE( $in ) {
1696
+ $in['force_root_block'] = false;
1697
+ $in['valid_children'] = '+body[style]';
1698
+ $in['remove_linebreaks'] = false;
1699
+ $in['gecko_spellcheck'] = false;
1700
+ $in['keep_styles'] = true;
1701
+ $in['accessibility_focus'] = true;
1702
+ $in['tabfocus_elements'] = 'major-publishing-actions';
1703
+ $in['media_strict'] = false;
1704
+ $in['paste_remove_styles'] = false;
1705
+ $in['paste_remove_spans'] = false;
1706
+ $in['paste_strip_class_attributes'] = 'none';
1707
+ $in['paste_text_use_dialog'] = true;
1708
+ $in['wpeditimage_disable_captions'] = true;
1709
+ $in['wpautop'] = false;
1710
+ $in['apply_source_formatting'] = true;
1711
+ $in['cleanup'] = true;
1712
+ $in['convert_newlines_to_brs'] = FALSE;
1713
+ $in['fullpage_default_xml_pi'] = false;
1714
+ $in['convert_urls'] = false;
1715
+ // Do not remove redundant BR tags
1716
+ $in['remove_redundant_brs'] = false;
1717
+ return $in;
1718
+ }
1719
+
1720
+ function wcal_enqueue_scripts_css( $hook ) {
1721
+ if ( $hook != 'woocommerce_page_woocommerce_ac_page' ) {
1722
+ return;
1723
+ } else {
1724
+ wp_enqueue_style( 'jquery-ui', "//ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" , '', '', false );
1725
+ wp_enqueue_style( 'woocommerce_admin_styles', plugins_url() . '/woocommerce/assets/css/admin.css' );
1726
+ wp_enqueue_style( 'jquery-ui-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
1727
+ wp_enqueue_style( 'abandoned-orders-list', plugins_url() . '/woocommerce-abandoned-cart/assets/css/view.abandoned.orders.style.css' );
1728
+
1729
+ }
1730
+ }
1731
+ //bulk action
1732
+ // to over come the wp redirect warning while deleting
1733
+ function wcal_app_output_buffer() {
1734
+ ob_start();
1735
+ }
1736
+
1737
+ /**
1738
+ * Abandon Cart Settings Page
1739
+ */
1740
+ function wcal_menu_page() {
1741
+
1742
+ if ( is_user_logged_in() ) {
1743
+ global $wpdb;
1744
+ // Check the user capabilities
1745
+ if ( !current_user_can( 'manage_woocommerce' ) ) {
1746
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'woocommerce-ac' ) );
1747
+ }
1748
+ ?>
1749
+ <div class="wrap">
1750
+ <h2><?php _e( 'WooCommerce - Abandon Cart Lite', 'woocommerce-ac' ); ?></h2>
1751
+ <?php
1752
+
1753
+ if ( isset( $_GET['action'] ) ) {
1754
+ $action = $_GET['action'];
1755
  } else {
1756
  $action = "";
1757
  }
1758
+ if ( isset( $_GET['mode'] ) ) {
1759
+ $mode = $_GET['mode'];
1760
+ } else {
1761
+ $mode = "";
1762
+ }
1763
+ $this->wcal_display_tabs();
1764
+
1765
+ /**
1766
+ * When we delete the item from the below drop down it is registred in action 2
1767
+ */
1768
+ if ( isset( $_GET['action2'] ) ) {
1769
+ $action_two = $_GET['action2'];
1770
+ } else {
1771
+ $action_two = "";
1772
+ }
1773
+ // Detect when a bulk action is being triggered on abandoned orders page.
1774
+ if( 'wcal_delete' === $action || 'wcal_delete' === $action_two ) {
1775
+ $ids = isset( $_GET['abandoned_order_id'] ) ? $_GET['abandoned_order_id'] : false;
1776
+ if ( ! is_array( $ids ) ) {
1777
+ $ids = array( $ids );
1778
+ }
1779
+ foreach ( $ids as $id ) {
1780
+ $class = new wcal_delete_bulk_action_handler();
1781
+ $class->wcal_delete_bulk_action_handler_function( $id );
1782
+ }
1783
+ }
1784
+ //Detect when a bulk action is being triggered on temnplates page.
1785
+ if( 'wcal_delete_template' === $action || 'wcal_delete_template' === $action_two ) {
1786
+ $ids = isset( $_GET['template_id'] ) ? $_GET['template_id'] : false;
1787
+ if ( ! is_array( $ids ) ) {
1788
+ $ids = array( $ids );
1789
+ }
1790
+ foreach ( $ids as $id ) {
1791
+ $class = new wcal_delete_bulk_action_handler();
1792
+ $class->wcal_delete_template_bulk_action_handler_function( $id );
1793
+ }
1794
+ }
1795
+
1796
+ if ( isset( $_GET['wcal_deleted'] ) && 'YES' == $_GET['wcal_deleted'] ) { ?>
1797
+ <div id="message" class="updated fade">
1798
+ <p><strong><?php _e( 'The Abandoned cart has been successfully deleted.', 'woocommerce-ac' ); ?></strong></p>
1799
+ </div>
1800
+ <?php }
1801
+ if ( isset( $_GET ['wcal_template_deleted'] ) && 'YES' == $_GET['wcal_template_deleted'] ) { ?>
1802
+ <div id="message" class="updated fade">
1803
+ <p><strong><?php _e( 'The Template has been successfully deleted.', 'woocommerce-ac' ); ?></strong></p>
1804
+ </div>
1805
+ <?php }
1806
+ if ( $action == 'emailsettings' ) {
1807
+ // Save the field values
 
 
1808
  ?>
1809
+ <p><?php _e( 'Change settings for sending email notifications to Customers, to Admin etc.', 'woocommerce-ac' ); ?></p>
1810
+ <div id="content">
1811
+ <?php
1812
+ $wcal_general_settings_class = $wcal_email_setting = "";
1813
+ if ( isset( $_GET[ 'wcal_section' ] ) ) {
1814
+ $section = $_GET[ 'wcal_section' ];
1815
+ } else {
1816
+ $section = '';
1817
+ }
1818
+ if ( $section == 'wcal_general_settings' || $section == '' ) {
1819
+ $wcal_general_settings_class = "current";
1820
+ }
1821
+ if( $section == 'wcal_email_settings' ) {
1822
+ $wcal_email_setting = "current";
1823
+ }
1824
+
1825
+ ?>
1826
+ <ul class="subsubsub" id="wcal_general_settings_list">
1827
+ <li>
1828
+ <a href="admin.php?page=woocommerce_ac_page&action=emailsettings&wcal_section=wcal_general_settings" class="<?php echo $wcal_general_settings_class; ?>"><?php _e( 'General Settings', 'woocommerce-ac' );?> </a> |
1829
+ </li>
1830
+ <li>
1831
+ <a href="admin.php?page=woocommerce_ac_page&action=emailsettings&wcal_section=wcal_email_settings" class="<?php echo $wcal_email_setting; ?>"><?php _e( 'Email Sending Settings', 'woocommerce-ac' );?> </a>
1832
+ </li>
1833
+
1834
+ </ul>
1835
+ <br class="clear">
1836
+ <?php
1837
+ if ( $section == 'wcal_general_settings' || $section == '' ) {
1838
+ ?>
1839
+ <form method="post" action="options.php">
1840
+ <?php settings_fields( 'woocommerce_ac_settings' ); ?>
1841
+ <?php do_settings_sections( 'woocommerce_ac_page' ); ?>
1842
+ <?php settings_errors(); ?>
1843
+ <?php submit_button(); ?>
1844
+ </form>
1845
+ <?php
1846
+ } else if ( $section == 'wcal_email_settings' ) {
1847
+ ?><form method="post" action="options.php">
1848
+ <?php settings_fields ( 'woocommerce_ac_email_settings' ); ?>
1849
+ <?php do_settings_sections( 'woocommerce_ac_email_page' ); ?>
1850
+ <?php settings_errors(); ?>
1851
+ <?php submit_button(); ?>
1852
+ </form>
1853
+ <?php
1854
+ }
1855
+ ?>
1856
+ </div>
1857
+ <?php
1858
+ } elseif ( $action == 'listcart' || '' == $action || '-1' == $action || '-1' == $action_two ) {
1859
+ ?>
1860
+ <p> <?php _e( 'The list below shows all Abandoned Carts which have remained in cart for a time higher than the "Cart abandoned cut-off time" setting.', 'woocommerce-ac' );?> </p>
1861
+ <?php
1862
+ $get_all_abandoned_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_abandoned' );
1863
+ $get_registered_user_ac_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_registered' );
1864
+ $get_guest_user_ac_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_guest' );
1865
+ $get_visitor_user_ac_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_visitor' );
1866
+
1867
+ $wcal_user_reg_text = 'User';
1868
+ if ( $get_registered_user_ac_count > 1){
1869
+ $wcal_user_reg_text = 'Users';
1870
+ }
1871
+ $wcal_user_gus_text = 'User';
1872
+ if ( $get_guest_user_ac_count > 1){
1873
+ $wcal_user_gus_text = 'Users';
1874
+ }
1875
+ $wcal_all_abandoned_carts = $section = $wcal_all_registered = $wcal_all_guest = $wcal_all_visitor = "" ;
1876
+
1877
+ if ( isset( $_GET[ 'wcal_section' ] ) ) {
1878
+ $section = $_GET[ 'wcal_section' ];
1879
+ } else {
1880
+ $section = '';
1881
+ }
1882
+ if ( $section == 'wcal_all_abandoned' || $section == '' ) {
1883
+ $wcal_all_abandoned_carts = "current";
1884
+ }
1885
+
1886
+ if( $section == 'wcal_all_registered' ) {
1887
+ $wcal_all_registered = "current";
1888
+ $wcal_all_abandoned_carts = "";
1889
+ }
1890
+ if( $section == 'wcal_all_guest' ) {
1891
+ $wcal_all_guest = "current";
1892
+ $wcal_all_abandoned_carts = "";
1893
+ }
1894
+
1895
+ if( $section == 'wcal_all_visitor' ) {
1896
+ $wcal_all_visitor = "current";
1897
+ $wcal_all_abandoned_carts = "";
1898
+ }
1899
+ ?>
1900
+ <ul class="subsubsub" id="wcal_recovered_orders_list">
1901
+ <li>
1902
+ <a href="admin.php?page=woocommerce_ac_page&action=listcart&wcal_section=wcal_all_abandoned" class="<?php echo $wcal_all_abandoned_carts; ?>"><?php _e( "All ", 'woocommerce-ac' ) ;?> <span class = "count" > <?php echo "( $get_all_abandoned_count )" ?> </span></a>
1903
+ </li>
1904
+
1905
+ <?php if ($get_registered_user_ac_count > 0 ) { ?>
1906
+ <li>
1907
+ | <a href="admin.php?page=woocommerce_ac_page&action=listcart&wcal_section=wcal_all_registered" class="<?php echo $wcal_all_registered; ?>"><?php _e( " Registered $wcal_user_reg_text ", 'woocommerce-ac' ) ;?> <span class = "count" > <?php echo "( $get_registered_user_ac_count )" ?> </span></a>
1908
+ </li>
1909
+ <?php } ?>
1910
+
1911
+ <?php if ($get_guest_user_ac_count > 0 ) { ?>
1912
+ <li>
1913
+ | <a href="admin.php?page=woocommerce_ac_page&action=listcart&wcal_section=wcal_all_guest" class="<?php echo $wcal_all_guest; ?>"><?php _e( " Guest $wcal_user_gus_text ", 'woocommerce-ac' ) ;?> <span class = "count" > <?php echo "( $get_guest_user_ac_count )" ?> </span></a>
1914
+ </li>
1915
+ <?php } ?>
1916
+
1917
+ <?php if ($get_visitor_user_ac_count > 0 ) { ?>
1918
+ <li>
1919
+ | <a href="admin.php?page=woocommerce_ac_page&action=listcart&wcal_section=wcal_all_visitor" class="<?php echo $wcal_all_visitor; ?>"><?php _e( " Carts without Customer Details ", 'woocommerce-ac' ) ;?> <span class = "count" > <?php echo "( $get_visitor_user_ac_count )" ?> </span></a>
1920
+ </li>
1921
+ <?php } ?>
1922
+ </ul>
1923
+
1924
+ <?php
1925
+ global $wpdb;
1926
+ include_once( 'includes/classes/class-wcal-abandoned-orders-table.php' );
1927
+ $wcal_abandoned_order_list = new WCAL_Abandoned_Orders_Table();
1928
+ $wcal_abandoned_order_list->wcal_abandoned_order_prepare_items();
1929
+ ?>
1930
+ <div class="wrap">
1931
+ <form id="wcal-abandoned-orders" method="get" >
1932
+ <input type="hidden" name="page" value="woocommerce_ac_page" />
1933
+ <input type="hidden" name="action" value="listcart" />
1934
+ <?php $wcal_abandoned_order_list->display(); ?>
1935
  </form>
1936
+ </div>
1937
+ <?php
1938
+ } elseif ( $action == 'emailtemplates' && ( $mode != 'edittemplate' && $mode != 'addnewtemplate' ) ) {
1939
+ ?>
1940
+ <p> <?php _e( 'Add email templates at different intervals to maximize the possibility of recovering your abandoned carts.', 'woocommerce-ac' );?> </p>
1941
+ <?php
1942
+ // Save the field values
1943
+ $insert_template_successfuly = $update_template_successfuly = '';
1944
+ if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' ) {
1945
+ $active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
1946
+ $is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
1947
+ if ( $active_post == 1 ) {
1948
+ $is_active = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
1949
+ $email_frequency = trim( $_POST['email_frequency'] );
1950
+ $day_or_hour = trim( $_POST['day_or_hour'] );
1951
+
1952
+ $check_query = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite`
1953
+ WHERE is_active = %s
1954
+ AND frequency = %d
1955
+ AND day_or_hour = %s ";
1956
+ $check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $is_active, $email_frequency, $day_or_hour ) );
1957
+ $default_value = 0 ;
1958
+
1959
+ if ( count( $check_results ) == 0 ) {
1960
+ $active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
1961
+ $woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
1962
+ $woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
1963
+ $woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
1964
+
1965
+ $woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
1966
+ $query = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
1967
+ (subject, body, is_active, frequency, day_or_hour, template_name, is_wc_template, default_template, wc_email_header )
1968
+ VALUES ( %s, %s, %s, %d, %s, %s, %s, %d, %s )";
1969
+
1970
+ $insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query,
1971
+ $woocommerce_ac_email_subject,
1972
+ $woocommerce_ac_email_body,
1973
+ $active_post,
1974
+ $email_frequency,
1975
+ $day_or_hour,
1976
+ $woocommerce_ac_template_name,
1977
+ $is_wc_template,
1978
+ $default_value,
1979
+ $woocommerce_ac_email_header)
1980
+ );
1981
+ } else {
1982
+ $update_is_active = 0;
1983
+ $query_update = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
1984
+ SET
1985
+ is_active = %s
1986
+ WHERE frequency = %d
1987
+ AND day_or_hour = %s ";
1988
+ $update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update, $update_is_active, $email_frequency, $day_or_hour ) );
1989
+
1990
+ $woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
1991
+ $woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
1992
+ $woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
1993
+ $woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
1994
+ $query_insert_new = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
1995
+ (subject, body, is_active, frequency, day_or_hour, template_name, is_wc_template, default_template, wc_email_header )
1996
+ VALUES ( %s, %s, %s, %d, %s, %s, %s, %d, %s )";
1997
+
1998
+ $insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query_insert_new,
1999
+ $woocommerce_ac_email_subject,
2000
+ $woocommerce_ac_email_body,
2001
+ $active_post,
2002
+ $email_frequency,
2003
+ $day_or_hour,
2004
+ $woocommerce_ac_template_name,
2005
+ $is_wc_template,
2006
+ $default_value,
2007
+ $woocommerce_ac_email_header )
2008
+ );
2009
+ }
2010
+ } else {
2011
+ $woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
2012
+ $woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
2013
+ $woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
2014
+ $woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
2015
+ $active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
2016
+ $email_frequency = trim( $_POST['email_frequency'] );
2017
+ $day_or_hour = trim( $_POST['day_or_hour'] );
2018
+ $is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
2019
+ $default_value = 0 ;
2020
+
2021
+ $query = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
2022
+ (subject, body, is_active, frequency, day_or_hour, template_name, is_wc_template, default_template, wc_email_header )
2023
+ VALUES ( %s, %s, %s, %d, %s, %s, %s, %d, %s )";
2024
+
2025
+ $insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query,
2026
+ $woocommerce_ac_email_subject,
2027
+ $woocommerce_ac_email_body,
2028
+ $active_post,
2029
+ $email_frequency,
2030
+ $day_or_hour,
2031
+ $woocommerce_ac_template_name,
2032
+ $is_wc_template,
2033
+ $default_value,
2034
+ $woocommerce_ac_email_header )
2035
+ );
2036
+ }
2037
+ }
2038
+
2039
+ if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' ) {
2040
+ $active = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
2041
+ $is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
2042
+
2043
+ if ( $active == 1 ) {
2044
+ $is_active = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
2045
+ $email_frequency = trim( $_POST['email_frequency'] );
2046
+ $day_or_hour = trim( $_POST['day_or_hour'] );
2047
+ $check_query = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite`
2048
+ WHERE is_active= %s
2049
+ AND frequency = %d
2050
+ AND day_or_hour= %s ";
2051
+ $check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $is_active, $email_frequency, $day_or_hour ) );
2052
+ $default_value = '';
2053
+
2054
+ foreach( $check_results as $result_key => $result_value ) {
2055
+ $default_value = ( empty( $result_value->default_template ) ) ? 0 : $result_value->default_template;
2056
+ }
2057
+
2058
+ if( count( $check_results ) == 0 ) {
2059
+ $woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
2060
+ $woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
2061
+ $woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
2062
+ $woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
2063
+ $id = trim( $_POST['id'] );
2064
+
2065
+ $query_update = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
2066
+ SET
2067
+ subject = %s,
2068
+ body = %s,
2069
+ is_active = %s,
2070
+ frequency = %d,
2071
+ day_or_hour = %s,
2072
+ template_name = %s,
2073
+ is_wc_template = %s,
2074
+ default_template = %d,
2075
+ wc_email_header = %s
2076
+ WHERE id = %d ";
2077
+ $update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update,
2078
+ $woocommerce_ac_email_subject,
2079
+ $woocommerce_ac_email_body,
2080
+ $active,
2081
+ $email_frequency,
2082
+ $day_or_hour,
2083
+ $woocommerce_ac_template_name,
2084
+ $is_wc_template,
2085
+ $default_value,
2086
+ $woocommerce_ac_email_header,
2087
+ $id )
2088
+
2089
+ );
2090
+ } else {
2091
+ $updated_is_active = 0;
2092
+ $query_update_new = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
2093
+ SET is_active = %s
2094
+ WHERE frequency = %d
2095
+ AND day_or_hour = %s ";
2096
+ $update_template_successfuly = $wpdb->query( $wpdb->prepare( $query_update_new, $updated_is_active, $email_frequency, $day_or_hour ) );
2097
+ $woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
2098
+ $woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
2099
+ $woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
2100
+ $woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
2101
+ $id = trim( $_POST['id'] );
2102
+
2103
+ $query_update_latest = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
2104
+ SET
2105
+ subject = %s,
2106
+ body = %s,
2107
+ is_active = %s,
2108
+ frequency = %d,
2109
+ day_or_hour = %s,
2110
+ template_name = %s,
2111
+ is_wc_template = %s,
2112
+ default_template = %d,
2113
+ wc_email_header = %s
2114
+ WHERE id = %d ";
2115
+ $update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update_latest,
2116
+ $woocommerce_ac_email_subject,
2117
+ $woocommerce_ac_email_body,
2118
+ $active,
2119
+ $email_frequency,
2120
+ $day_or_hour,
2121
+ $woocommerce_ac_template_name,
2122
+ $is_wc_template,
2123
+ $default_value,
2124
+ $woocommerce_ac_email_header,
2125
+ $id )
2126
+
2127
+ );
2128
+ }
2129
+ } else {
2130
+ $updated_is_active = '0';
2131
+ $is_active = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
2132
+ $email_frequency = trim( $_POST['email_frequency'] );
2133
+ $day_or_hour = trim( $_POST['day_or_hour'] );
2134
+ $is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
2135
+
2136
+ $query_update_new = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
2137
+ SET is_active = %s
2138
+ WHERE frequency = %d
2139
+ AND day_or_hour = %s ";
2140
+ $wpdb->query( $wpdb->prepare( $query_update_new, $updated_is_active, $email_frequency, $day_or_hour ) );
2141
+
2142
+ $woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
2143
+ $woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
2144
+ $woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
2145
+ $woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
2146
+ $id = trim( $_POST['id'] );
2147
+ $check_query = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite`
2148
+ WHERE is_active= %s
2149
+ AND frequency = %d
2150
+ AND day_or_hour= %s ";
2151
+ $check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $is_active, $email_frequency, $day_or_hour ) );
2152
+ $default_value = '';
2153
+
2154
+ foreach( $check_results as $result_key => $result_value ) {
2155
+ $default_value = ( empty( $result_value->default_template ) ) ? 0 : $result_value->default_template;
2156
+ }
2157
+
2158
+ $query_update_latest = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
2159
+ SET
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2160
  subject = %s,
2161
  body = %s,
2162
  is_active = %s,
2163
+ frequency = %d,
2164
  day_or_hour = %s,
2165
  template_name = %s,
2166
+ is_wc_template = %s,
2167
+ default_template = %d,
2168
+ wc_email_header = %s
 
 
2169
  WHERE id = %d ";
2170
+
2171
+ $update_template_successfuly = $wpdb->query( $wpdb->prepare( $query_update_latest,
2172
+ $woocommerce_ac_email_subject,
2173
+ $woocommerce_ac_email_body,
2174
+ $is_active,
2175
+ $email_frequency,
2176
+ $day_or_hour,
2177
+ $woocommerce_ac_template_name,
2178
+ $is_wc_template,
2179
+ $default_value,
2180
+ $woocommerce_ac_email_header,
2181
+ $id )
2182
+ );
2183
+ }
2184
+ }
2185
+
2186
+ if ( $action == 'emailtemplates' && $mode == 'removetemplate' ) {
2187
+ $id_remove = $_GET['id'];
2188
+ $query_remove = "DELETE FROM `".$wpdb->prefix."ac_email_templates_lite` WHERE id= %d ";
2189
+ $wpdb->query( $wpdb->prepare( $query_remove, $id_remove ) );
2190
+ }
2191
+
2192
+ if ( $action == 'emailtemplates' && $mode == 'activate_template' ) {
2193
+ $template_id = $_GET['id'];
2194
+ $current_template_status = $_GET['active_state'];
2195
+
2196
+ if( "1" == $current_template_status ) {
2197
+ $active = "0";
2198
+ } else {
2199
+ $active = "1";
2200
+ }
2201
+ $query_update = "UPDATE `" . $wpdb->prefix . "ac_email_templates_lite`
2202
+ SET
2203
+ is_active = '" . $active . "'
2204
+ WHERE id = '" . $template_id . "' ";
2205
+ $wpdb->query( $query_update );
2206
+
2207
+ wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&action=emailtemplates' ) );
2208
+ }
2209
+
2210
+ if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' && ( isset( $insert_template_successfuly ) && $insert_template_successfuly != '' ) ) { ?>
2211
+ <div id="message" class="updated fade"><p><strong><?php _e( 'The Email Template has been successfully added.', 'woocommerce-ac' ); ?></strong></p></div>
2212
+ <?php } else if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' && ( isset( $insert_template_successfuly ) && $insert_template_successfuly == '' ) ) {
2213
+ ?>
2214
+ <div id="message" class="error fade"><p><strong><?php _e( ' There was a problem adding the email template. Please contact the plugin author via <a href= "https://wordpress.org/support/plugin/woocommerce-abandoned-cart">support forum</a>.', 'woocommerce-ac' ); ?></strong></p></div>
2215
+ <?php
2216
+ }
2217
+
2218
+ if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' && isset($update_template_successfuly) && $update_template_successfuly >= 0 ) { ?>
2219
+ <div id="message" class="updated fade"><p><strong><?php _e( 'The Email Template has been successfully updated.', 'woocommerce-ac' ); ?></strong></p></div>
2220
+ <?php } else if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' && isset($update_template_successfuly) && $update_template_successfuly === false ){
2221
+ ?>
2222
+ <div id="message" class="error fade"><p><strong><?php _e( ' There was a problem updating the email template. Please contact the plugin author via <a href= "https://wordpress.org/support/plugin/woocommerce-abandoned-cart">support forum</a>.', 'woocommerce-ac' ); ?></strong></p></div>
2223
+ <?php
2224
+ }
2225
+ ?>
2226
+ <div class="tablenav">
2227
+ <p style="float:left;">
2228
+ <a cursor: pointer; href="<?php echo "admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=addnewtemplate"; ?>" class="button-secondary"><?php _e( 'Add New Template', 'woocommerce-ac' ); ?></a>
2229
+ </p>
2230
+
2231
+ <?php
2232
+ /* From here you can do whatever you want with the data from the $result link. */
2233
+ include_once('includes/classes/class-wcal-templates-table.php');
2234
+ $wcal_template_list = new WCAL_Templates_Table();
2235
+ $wcal_template_list->wcal_templates_prepare_items();
2236
+ ?>
2237
+ <div class="wrap">
2238
+ <form id="wcal-abandoned-templates" method="get" >
2239
+ <input type="hidden" name="page" value="woocommerce_ac_page" />
2240
+ <input type="hidden" name="action" value="emailtemplates" />
2241
+ <?php $wcal_template_list->display(); ?>
2242
+ </form>
2243
+ </div>
2244
+ </div>
2245
+ <?php
2246
+ } elseif ($action == 'stats' || $action == '') {
2247
+ ?>
2248
+ <p>
2249
+ <script language='javascript'>
2250
+ jQuery( document ).ready( function()
2251
+ {
2252
+ jQuery( '#duration_select' ).change( function()
2253
+ {
2254
+ var group_name = jQuery( '#duration_select' ).val();
2255
+ var today = new Date();
2256
+ var start_date = "";
2257
+ var end_date = "";
2258
+ if ( group_name == "yesterday" )
2259
+ {
2260
+ start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 1 );
2261
+ end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 1 );
2262
+ }
2263
+ else if ( group_name == "today")
2264
+ {
2265
+ start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
2266
+ end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
2267
+ }
2268
+ else if ( group_name == "last_seven" )
2269
+ {
2270
+ start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 7 );
2271
+ end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
2272
+ }
2273
+ else if ( group_name == "last_fifteen" )
2274
+ {
2275
+ start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 15 );
2276
+ end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
2277
+ }
2278
+ else if ( group_name == "last_thirty" )
2279
+ {
2280
+ start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 30 );
2281
+ end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
2282
+ }
2283
+ else if ( group_name == "last_ninety" )
2284
+ {
2285
+ start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 90 );
2286
+ end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
2287
+ }
2288
+ else if ( group_name == "last_year_days" )
2289
+ {
2290
+ start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 365 );
2291
+ end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
2292
+ }
2293
+
2294
+ var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
2295
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
2296
+
2297
+ var start_date_value = start_date.getDate() + " " + monthNames[start_date.getMonth()] + " " + start_date.getFullYear();
2298
+ var end_date_value = end_date.getDate() + " " + monthNames[end_date.getMonth()] + " " + end_date.getFullYear();
2299
+
2300
+ jQuery( '#start_date' ).val( start_date_value );
2301
+ jQuery( '#end_date' ).val( end_date_value );
2302
+
2303
+ });
2304
+ });
2305
+ </script>
2306
+ <?php
2307
+
2308
+ if ( isset( $_POST['duration_select'] ) ){
2309
+ $duration_range = $_POST['duration_select'];
2310
+ } else {
2311
+ $duration_range = "";
2312
+ }
2313
+ if ( $duration_range == "" ) {
2314
+ if ( isset( $_GET['duration_select'] ) ){
2315
+ $duration_range = $_GET['duration_select'];
2316
+ }
2317
+ }
2318
+ if ($duration_range == "") $duration_range = "last_seven";
2319
+
2320
+ _e( 'The Report below shows how many Abandoned Carts we were able to recover for you by sending automatic emails to encourage shoppers.', 'woocommerce-ac');
2321
+ ?>
2322
+ <div id="recovered_stats" class="postbox" style="display:block">
2323
+ <div class="inside">
2324
+ <form method="post" action="admin.php?page=woocommerce_ac_page&action=stats" id="ac_stats">
2325
+ <select id="duration_select" name="duration_select" >
2326
+ <?php
2327
+ foreach ( $this->duration_range_select as $key => $value ) {
2328
+ $sel = "";
2329
+ if ($key == $duration_range) {
2330
+ $sel = " selected ";
2331
+ }
2332
+ echo"<option value='$key' $sel> $value </option>";
2333
+ }
2334
+ $date_sett = $this->start_end_dates[ $duration_range ];
2335
+ ?>
2336
+ </select>
2337
+ <script type="text/javascript">
2338
+ jQuery( document ).ready( function()
2339
+ {
2340
+ var formats = ["d.m.y", "d M yy","MM d, yy"];
2341
+ jQuery( "#start_date" ).datepicker( { dateFormat: formats[1] } );
2342
+ });
2343
+
2344
+ jQuery( document ).ready( function()
2345
+ {
2346
+ var formats = ["d.m.y", "d M yy","MM d, yy"];
2347
+ jQuery( "#end_date" ).datepicker( { dateFormat: formats[1] } );
2348
+ });
2349
+ </script>
2350
+ <?php
2351
+ include_once('includes/classes/class-wcal-recover-orders-table.php');
2352
+ $wcal_recover_orders_list = new WCAL_Recover_Orders_Table();
2353
+ $wcal_recover_orders_list->wcal_recovered_orders_prepare_items();
2354
+
2355
+ if ( isset( $_POST['start_date'] ) ) $start_date_range = $_POST['start_date'];
2356
+ else $start_date_range = "";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2357
 
2358
+ if ( $start_date_range == "" ) {
2359
+ $start_date_range = $date_sett['start_date'];
2360
+ }
 
 
 
 
 
 
2361
 
2362
+ if ( isset( $_POST['end_date'] ) ) $end_date_range = $_POST['end_date'];
2363
+ else $end_date_range = "";
2364
+
2365
+ if ( $end_date_range == "" ) {
2366
+ $end_date_range = $date_sett['end_date'];
2367
+ }
2368
+ ?>
2369
+ <label class="start_label" for="start_day"> <?php _e( 'Start Date:', 'woocommerce-ac' ); ?> </label>
2370
+ <input type="text" id="start_date" name="start_date" readonly="readonly" value="<?php echo $start_date_range; ?>"/>
2371
+ <label class="end_label" for="end_day"> <?php _e( 'End Date:', 'woocommerce-ac' ); ?> </label>
2372
+ <input type="text" id="end_date" name="end_date" readonly="readonly" value="<?php echo $end_date_range; ?>"/>
2373
+ <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e( 'Go', 'woocommerce-ac' ); ?>" />
2374
+ </form>
2375
+ </div>
2376
+ </div>
2377
+ <div id="recovered_stats" class="postbox" style="display:block">
2378
+ <div class="inside" >
2379
+ <p style="font-size: 15px"><?php _e( 'During the selected range ', 'woocommerce-ac' ); ?>
2380
+ <strong>
2381
+ <?php $count = $wcal_recover_orders_list->total_abandoned_cart_count;
2382
+ echo $count; ?>
2383
+ </strong>
2384
+ <?php _e( 'carts totaling', 'woocommerce-ac' ); ?>
2385
+ <strong>
2386
+ <?php $total_of_all_order = $wcal_recover_orders_list->total_order_amount;
2387
+
2388
+ echo $total_of_all_order; ?>
2389
+ </strong>
2390
+ <?php _e( ' were abandoned. We were able to recover', 'woocommerce-ac' ); ?>
2391
+ <strong>
2392
+ <?php
2393
+ $recovered_item = $wcal_recover_orders_list->recovered_item;
2394
+
2395
+ echo $recovered_item; ?>
2396
+ </strong>
2397
+ <?php _e( ' of them, which led to an extra', 'woocommerce-ac' ); ?>
2398
+ <strong>
2399
+ <?php
2400
+ $recovered_total = $wcal_recover_orders_list->total_recover_amount;
2401
+ echo wc_price( $recovered_total ); ?>
2402
+ </strong>
2403
+ </p>
2404
+ </div>
2405
+ </div>
2406
+ <div class="wrap">
2407
+ <form id="wcal-recover-orders" method="get" >
2408
+ <input type="hidden" name="page" value="woocommerce_ac_page" />
2409
+ <input type="hidden" name="action" value="stats" />
2410
+ <?php $wcal_recover_orders_list->display(); ?>
2411
+ </form>
2412
+ </div>
2413
+ <?php
2414
+ } elseif ( $action == 'orderdetails' ) {
2415
+ $ac_order_id = $_GET['id'];
2416
+ ?>
2417
+ <p> </p>
2418
+ <div id="ac_order_details" class="postbox" style="display:block">
2419
  <h3> <p> <?php _e( "Abandoned Order #$ac_order_id Details", "woocommerce-ac" ); ?> </p> </h3>
2420
+ <div class="inside">
2421
+ <table cellpadding="0" cellspacing="0" class="wp-list-table widefat fixed posts">
2422
  <tr>
2423
+ <th> <?php _e( 'Item', 'woocommerce-ac' ); ?> </th>
2424
+ <th> <?php _e( 'Name', 'woocommerce-ac' ); ?> </th>
2425
+ <th> <?php _e( 'Quantity', 'woocommerce-ac' ); ?> </th>
2426
+ <th> <?php _e( 'Line Subtotal', 'woocommerce-ac' ); ?> </th>
2427
+ <th> <?php _e( 'Line Total', 'woocommerce-ac' ); ?> </th>
 
2428
  </tr>
2429
+ <?php
2430
+ $query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE id = %d ";
2431
+ $results = $wpdb->get_results( $wpdb->prepare( $query,$_GET['id'] ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2432
 
2433
+ $shipping_charges = 0;
2434
+ $currency_symbol = get_woocommerce_currency_symbol();
2435
+ $number_decimal = wc_get_price_decimals();
2436
+ if ( $results[0]->user_type == "GUEST" && "0" != $results[0]->user_id ) {
2437
+ $query_guest = "SELECT * FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d";
2438
+ $results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $results[0]->user_id ) );
2439
+ $user_email = $results_guest[0]->email_id;
2440
+ $user_first_name = $results_guest[0]->billing_first_name;
2441
+ $user_last_name = $results_guest[0]->billing_last_name;
2442
+ $user_billing_postcode = $results_guest[0]->billing_zipcode;
2443
+ $user_shipping_postcode = $results_guest[0]->shipping_zipcode;
2444
+ $shipping_charges = $results_guest[0]->shipping_charges;
2445
+ $user_billing_company = $user_billing_address_1 = $user_billing_address_2 = $user_billing_city = $user_billing_state = $user_billing_country = $user_billing_phone = "";
2446
+ $user_shipping_company = $user_shipping_address_1 = $user_shipping_address_2 = $user_shipping_city = $user_shipping_state = $user_shipping_country = "";
2447
+ } else if ( $results[0]->user_type == "GUEST" && $results[0]->user_id == "0" ) {
2448
+ $user_email = '';
2449
+ $user_first_name = "Visitor";
2450
+ $user_last_name = "";
2451
+ $user_billing_postcode = '';
2452
+ $user_shipping_postcode = '';
2453
+ $shipping_charges = '';
2454
+ $user_billing_phone = '';
2455
+ $user_billing_company = $user_billing_address_1 = $user_billing_address_2 = $user_billing_city = $user_billing_state = $user_billing_country = "";
2456
+ $user_shipping_company = $user_shipping_address_1 = $user_shipping_address_2 = $user_shipping_city = $user_shipping_state = $user_shipping_country = "";
2457
  } else {
2458
+ $user_id = $results[0]->user_id;
2459
+ if ( isset( $results[0]->user_login ) ) {
2460
+ $user_login = $results[0]->user_login;
2461
+ }
2462
+ $user_email = get_user_meta( $results[0]->user_id, 'billing_email', true );
2463
+ if( "" == $user_email ) {
2464
+ $user_data = get_userdata( $results[0]->user_id );
2465
+ $user_email = $user_data->user_email;
2466
+ }
 
 
 
 
 
 
 
 
 
 
2467
 
2468
+ $user_first_name = "";
2469
+ $user_first_name_temp = get_user_meta( $user_id, 'billing_first_name', true );
2470
+ if( isset( $user_first_name_temp ) && "" == $user_first_name_temp ) {
2471
+ $user_data = get_userdata( $user_id );
2472
+ $user_first_name = $user_data->first_name;
2473
+ } else {
2474
+ $user_first_name = $user_first_name_temp;
2475
+ }
2476
+ $user_last_name = "";
2477
+ $user_last_name_temp = get_user_meta( $user_id, 'billing_last_name', true );
2478
+ if( isset( $user_last_name_temp ) && "" == $user_last_name_temp ) {
2479
+ $user_data = get_userdata( $user_id );
2480
+ $user_last_name = $user_data->last_name;
2481
+ } else {
2482
+ $user_last_name = $user_last_name_temp;
2483
+ }
2484
+ $user_billing_first_name = get_user_meta( $results[0]->user_id, 'billing_first_name' );
2485
+ $user_billing_last_name = get_user_meta( $results[0]->user_id, 'billing_last_name' );
2486
+ $user_billing_company_temp = get_user_meta( $results[0]->user_id, 'billing_company' );
2487
+ if ( isset( $user_billing_company_temp[0] ) ) {
2488
+ $user_billing_company = $user_billing_company_temp[0];
2489
+ } else {
2490
+ $user_billing_company = "";
2491
+ }
2492
+ $user_billing_address_1_temp = get_user_meta( $results[0]->user_id, 'billing_address_1' );
2493
+ if ( isset( $user_billing_address_1_temp[0] ) ) {
2494
+ $user_billing_address_1 = $user_billing_address_1_temp[0];
2495
+ } else {
2496
+ $user_billing_address_1 = "";
2497
+ }
2498
+ $user_billing_address_2_temp = get_user_meta( $results[0]->user_id, 'billing_address_2' );
2499
+ if ( isset( $user_billing_address_2_temp[0] ) ) {
2500
+ $user_billing_address_2 = $user_billing_address_2_temp[0];
2501
+ } else {
2502
+ $user_billing_address_2 = "";
2503
+ }
2504
+ $user_billing_city_temp = get_user_meta( $results[0]->user_id, 'billing_city' );
2505
+ if ( isset( $user_billing_city_temp[0] ) ) {
2506
+ $user_billing_city = $user_billing_city_temp[0];
2507
+ } else {
2508
+ $user_billing_city = "";
2509
+ }
2510
+ $user_billing_postcode_temp = get_user_meta( $results[0]->user_id, 'billing_postcode' );
2511
+ if ( isset( $user_billing_postcode_temp[0] ) ) {
2512
+ $user_billing_postcode = $user_billing_postcode_temp[0];
2513
+ } else {
2514
+ $user_billing_postcode = "";
2515
+ }
2516
+ $user_billing_state_temp = get_user_meta( $results[0]->user_id, 'billing_state' );
2517
+ if ( isset( $user_billing_state_temp[0] ) ) {
2518
+ $user_billing_state = $user_billing_state_temp[0];
2519
+ } else {
2520
+ $user_billing_state = "";
2521
+ }
2522
+ $user_billing_country_temp = get_user_meta( $results[0]->user_id, 'billing_country' );
2523
+ if ( isset( $user_billing_country_temp[0] ) ) {
2524
+ $user_billing_country = $user_billing_country_temp[0];
2525
+ } else {
2526
+ $user_billing_country = "";
2527
+ }
2528
+ $user_billing_phone_temp = get_user_meta( $results[0]->user_id, 'billing_phone' );
2529
+ if ( isset( $user_billing_phone_temp[0] ) ) {
2530
+ $user_billing_phone = $user_billing_phone_temp[0];
2531
+ } else {
2532
+ $user_billing_phone = "";
2533
+ }
2534
+ $user_shipping_first_name = get_user_meta( $results[0]->user_id, 'shipping_first_name' );
2535
+ $user_shipping_last_name = get_user_meta( $results[0]->user_id, 'shipping_last_name' );
2536
+ $user_shipping_company_temp = get_user_meta( $results[0]->user_id, 'shipping_company' );
2537
+ if ( isset( $user_shipping_company_temp[0] ) ) {
2538
+ $user_shipping_company = $user_shipping_company_temp[0];
2539
+ } else {
2540
+ $user_shipping_company = "";
2541
+ }
2542
+ $user_shipping_address_1_temp = get_user_meta( $results[0]->user_id, 'shipping_address_1' );
2543
+ if ( isset( $user_shipping_address_1_temp[0] ) ) {
2544
+ $user_shipping_address_1 = $user_shipping_address_1_temp[0];
2545
+ } else {
2546
+ $user_shipping_address_1 = "";
2547
+ }
2548
+ $user_shipping_address_2_temp = get_user_meta( $results[0]->user_id, 'shipping_address_2' );
2549
+ if ( isset( $user_shipping_address_2_temp[0] ) ) {
2550
+ $user_shipping_address_2 = $user_shipping_address_2_temp[0];
2551
+ } else {
2552
+ $user_shipping_address_2 = "";
2553
+ }
2554
+ $user_shipping_city_temp = get_user_meta( $results[0]->user_id, 'shipping_city' );
2555
+ if ( isset( $user_shipping_city_temp[0] ) ) {
2556
+ $user_shipping_city = $user_shipping_city_temp[0];
2557
+ } else {
2558
+ $user_shipping_city = "";
2559
+ }
2560
+ $user_shipping_postcode_temp = get_user_meta( $results[0]->user_id, 'shipping_postcode' );
2561
+ if ( isset( $user_shipping_postcode_temp[0] ) ) {
2562
+ $user_shipping_postcode = $user_shipping_postcode_temp[0];
2563
+ } else {
2564
+ $user_shipping_postcode = "";
2565
+ }
2566
+ $user_shipping_state_temp = get_user_meta( $results[0]->user_id, 'shipping_state' );
2567
+ if ( isset( $user_shipping_state_temp[0] ) ) {
2568
+ $user_shipping_state = $user_shipping_state_temp[0];
2569
+ } else {
2570
+ $user_shipping_state = "";
2571
+ }
2572
+ $user_shipping_country_temp = get_user_meta( $results[0]->user_id, 'shipping_country' );
2573
+ if ( isset( $user_shipping_country_temp[0] ) ) {
2574
+ $user_shipping_country = $user_shipping_country_temp[0];
2575
+ } else {
2576
+ $user_shipping_country = "";
2577
+ }
2578
+ }
2579
+ $cart_details = array();
2580
+ $cart_info = json_decode( $results[0]->abandoned_cart_info );
2581
+ $cart_details = (array) $cart_info->cart;
2582
+ $item_subtotal = $item_total = 0;
2583
+
2584
+ if ( is_array ( $cart_details ) && count( $cart_details ) > 0 ) {
2585
+ foreach ( $cart_details as $k => $v ) {
2586
+ $quantity_total = $v->quantity;
2587
+ $product_id = $v->product_id;
2588
+ $prod_name = get_post($product_id);
2589
+ $product_name = $prod_name->post_title;
2590
+ if ( isset( $v->variation_id ) && '' != $v->variation_id ){
2591
+ $variation_id = $v->variation_id;
2592
+ $variation = wc_get_product( $variation_id );
2593
+ $name = $variation->get_formatted_name() ;
2594
+ $explode_all = explode ( "&ndash;", $name );
2595
+ $pro_name_variation = array_slice( $explode_all, 1, -1 );
2596
+ $product_name_with_variable = '';
2597
+ $explode_many_varaition = array();
2598
+ foreach ( $pro_name_variation as $pro_name_variation_key => $pro_name_variation_value ){
2599
+ $explode_many_varaition = explode ( ",", $pro_name_variation_value );
2600
+ if ( !empty( $explode_many_varaition ) ) {
2601
+ foreach( $explode_many_varaition as $explode_many_varaition_key => $explode_many_varaition_value ){
2602
+ $product_name_with_variable = $product_name_with_variable . "<br>". html_entity_decode ( $explode_many_varaition_value );
2603
+ }
2604
+ } else {
2605
+ $product_name_with_variable = $product_name_with_variable . "<br>". html_entity_decode ( $explode_many_varaition_value );
2606
+ }
2607
+ }
2608
+ $product_name = $product_name_with_variable;
2609
+ }
2610
+ // Item subtotal is calculated as product total including taxes
2611
+ if ( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
2612
+ $item_subtotal = $item_subtotal + $v->line_total + $v->line_subtotal_tax;
2613
+ } else {
2614
+ $item_subtotal = $item_subtotal + $v->line_total;
2615
+ }
2616
+ // Line total
2617
+ $item_total = $item_subtotal;
2618
+ $item_subtotal = $item_subtotal / $quantity_total;
2619
+ $item_total = wc_price( $item_total );
2620
+ $item_subtotal = wc_price( $item_subtotal );
2621
+ $product = get_product( $product_id );
2622
+ $prod_image = $product->get_image();
2623
+ ?>
2624
+ <tr>
2625
+ <td> <?php echo $prod_image; ?></td>
2626
+ <td> <?php echo $product_name; ?></td>
2627
+ <td> <?php echo $quantity_total; ?></td>
2628
+ <td> <?php echo $item_subtotal; ?></td>
2629
+ <td> <?php echo $item_total; ?></td>
2630
+ </tr>
2631
+ <?php
2632
+ $item_subtotal = $item_total = 0;
2633
+ }
2634
+ }
2635
+ ?>
2636
+ </table>
2637
+ </div>
2638
+ </div>
2639
+ <div id="ac_order_customer_details" class="postbox" style="display:block">
2640
  <h3> <p> <?php _e( 'Customer Details' , 'woocommerce-ac' ); ?> </p> </h3>
2641
  <div class="inside" style="height: 300px;" >
2642
+ <div id="order_data" class="panel">
2643
+ <div style="width:50%;float:left">
2644
+ <h3> <p> <?php _e( 'Billing Details' , 'woocommerce-ac' ); ?> </p> </h3>
2645
+ <p> <strong> <?php _e( 'Name:' , 'woocommerce-ac' ); ?> </strong>
2646
+ <?php echo $user_first_name." ".$user_last_name;?>
2647
+ </p>
2648
+ <p> <strong> <?php _e( 'Address:' , 'woocommerce-ac' ); ?> </strong>
2649
+ <?php echo $user_billing_company."</br>".
2650
+ $user_billing_address_1."</br>".
2651
+ $user_billing_address_2."</br>".
2652
+ $user_billing_city."</br>".
2653
+ $user_billing_postcode."</br>".
2654
+ $user_billing_state."</br>".
2655
+ $user_billing_country."</br>";
2656
+ ?>
2657
+ </p>
2658
+ <p> <strong> <?php _e( 'Email:', 'woocommerce-ac' ); ?> </strong>
2659
+ <?php $user_mail_to = "mailto:".$user_email; ?>
2660
+ <a href=<?php echo $user_mail_to;?>><?php echo $user_email;?> </a>
2661
+ </p>
2662
+ <p> <strong> <?php _e( 'Phone:', 'woocommerce-ac' ); ?> </strong>
2663
+ <?php echo $user_billing_phone;?>
2664
+ </p>
2665
+ </div>
2666
+ <div style="width:50%;float:right">
2667
  <h3> <p> <?php _e( 'Shipping Details', 'woocommerce-ac' ); ?> </p> </h3>
2668
+ <p> <strong> <?php _e( 'Address:', 'woocommerce-ac' ); ?> </strong>
2669
+ <?php
2670
+ if ( $user_shipping_company == '' &&
2671
+ $user_shipping_address_1 == '' &&
2672
+ $user_shipping_address_2 == '' &&
2673
+ $user_shipping_city == '' &&
2674
+ $user_shipping_postcode == '' &&
2675
+ $user_shipping_state == '' &&
2676
+ $user_shipping_country == '') {
2677
+ echo "Shipping Address same as Billing Address";
 
2678
  } else { ?>
2679
+ <?php echo $user_shipping_company."</br>".
2680
+ $user_shipping_address_1."</br>".
2681
+ $user_shipping_address_2."</br>".
2682
+ $user_shipping_city."</br>".
2683
+ $user_shipping_postcode."</br>".
2684
+ $user_shipping_state."</br>".
2685
+ $user_shipping_country."</br>";
2686
+ ?>
2687
  <br><br>
2688
  <strong> Shipping Charges: </strong>
2689
  <?php if ( $shipping_charges != 0 ) echo $currency_symbol . $shipping_charges;?>
2690
+ </p>
2691
+ <?php }?>
 
2692
  </div>
2693
  </div>
2694
+ </div>
2695
+ </div>
2696
+ <?php } elseif ( $action == 'report' ) {
2697
+ include_once('includes/classes/class-wcal-product-report-table.php');
2698
+ $wcal_product_report_list = new WCAL_Product_Report_Table();
2699
+ $wcal_product_report_list->wcal_product_report_prepare_items();
2700
+ ?>
2701
+ <div class="wrap">
2702
+ <form id="wcal-sent-emails" method="get" >
2703
+ <input type="hidden" name="page" value="woocommerce_ac_page" />
2704
+ <input type="hidden" name="action" value="report" />
2705
+ <?php $wcal_product_report_list->display(); ?>
2706
+ </form>
2707
+ </div>
2708
+ <?php }
2709
+ }
2710
+ echo( "</table>" );
2711
+
2712
+ if ( isset( $_GET['action'] ) ) {
2713
+ $action = $_GET['action'];
2714
+ }
2715
+ if ( isset( $_GET['mode'] ) ){
2716
+ $mode = $_GET['mode'];
2717
+ }
2718
+ if ( $action == 'emailtemplates' && ( $mode == 'addnewtemplate' || $mode == 'edittemplate' ) ) {
2719
+ if ( $mode=='edittemplate' ) {
2720
+ $edit_id = $_GET['id'];
2721
+ $query = "SELECT wpet . * FROM `".$wpdb->prefix."ac_email_templates_lite` AS wpet WHERE id = %d ";
2722
+ $results = $wpdb->get_results( $wpdb->prepare( $query, $edit_id ) );
2723
+ }
2724
+ $active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
2725
+ ?>
2726
+ <div id="content">
2727
+ <form method="post" action="admin.php?page=woocommerce_ac_page&action=emailtemplates" id="ac_settings">
2728
+ <input type="hidden" name="mode" value="<?php echo $mode;?>" />
2729
+ <?php
2730
+ $id_by = "";
2731
+ if ( isset( $_GET['id'] ) ) {
2732
+ $id_by = $_GET['id'];
2733
+ }
2734
+ ?>
2735
+ <input type="hidden" name="id" value="<?php echo $id_by ;?>" />
2736
+ <?php
2737
+ $button_mode = "save";
2738
+ $display_message = "Add Email Template";
2739
+ if ( $mode == 'edittemplate' ) {
2740
+ $button_mode = "update";
2741
+ $display_message = "Edit Email Template";
2742
+ }
2743
+ print'<input type="hidden" name="ac_settings_frm" value="'.$button_mode.'">';?>
2744
+ <div id="poststuff">
2745
+ <div> <!-- <div class="postbox" > -->
2746
+ <h3 class="hndle"><?php _e( $display_message, 'woocommerce-ac' ); ?></h3>
2747
+ <div>
2748
+ <table class="form-table" id="addedit_template">
2749
+ <tr>
2750
+ <th>
2751
+ <label for="woocommerce_ac_template_name"><b><?php _e( 'Template Name:', 'woocommerce-ac');?></b></label>
2752
+ </th>
2753
+ <td>
2754
+ <?php
2755
+ $template_name = "";
2756
+ if( $mode == 'edittemplate' ) {
2757
+ $template_name = $results[0]->template_name;
2758
+ }
2759
+ print'<input type="text" name="woocommerce_ac_template_name" id="woocommerce_ac_template_name" class="regular-text" value="'.$template_name.'">';?>
2760
+ <img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter a template name for reference', 'woocommerce-ac') ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" />
2761
+ </td>
2762
+ </tr>
2763
+
2764
+ <tr>
2765
+ <th>
2766
+ <label for="woocommerce_ac_email_subject"><b><?php _e( 'Subject:', 'woocommerce-ac' ); ?></b></label>
2767
+ </th>
2768
+ <td>
2769
+ <?php
2770
+ $subject_edit = "";
2771
+ if ( $mode == 'edittemplate' ) {
2772
+ $subject_edit= stripslashes ( $results[0]->subject );
2773
+ }
2774
+ print'<input type="text" name="woocommerce_ac_email_subject" id="woocommerce_ac_email_subject" class="regular-text" value="'.$subject_edit.'">';?>
2775
+ <img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter the subject that should appear in the email sent', 'woocommerce-ac') ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" />
2776
+ </td>
2777
+ </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2778
 
2779
+ <tr>
2780
+ <th>
2781
+ <label for="woocommerce_ac_email_body"><b><?php _e( 'Email Body:', 'woocommerce-ac' ); ?></b></label>
2782
+ </th>
2783
+ <td>
2784
+ <?php
2785
+ $initial_data = "";
2786
+ if ( $mode == 'edittemplate' ) {
2787
+ $initial_data = stripslashes( $results[0]->body );
2788
+ }
2789
+
2790
+ $initial_data = str_replace ( "My document title", "", $initial_data );
2791
+ wp_editor(
2792
+ $initial_data,
2793
+ 'woocommerce_ac_email_body',
2794
+ array(
2795
+ 'media_buttons' => true,
2796
+ 'textarea_rows' => 15,
2797
+ 'tabindex' => 4,
2798
+ 'tinymce' => array(
2799
+ 'theme_advanced_buttons1' => 'bold,italic,underline,|,bullist,numlist,blockquote,|,link,unlink,|,spellchecker,fullscreen,|,formatselect,styleselect'
2800
+ ),
2801
+ )
2802
+ );
2803
+
2804
+ ?>
2805
+ <?php echo stripslashes( get_option( 'woocommerce_ac_email_body' ) ); ?>
2806
+ <span class="description"><?php
2807
+ echo __( 'Message to be sent in the reminder email.', 'woocommerce-ac' );
2808
+ ?></span>
2809
+ </td>
2810
+ </tr>
2811
+
2812
+ <tr>
2813
+ <th>
2814
+ <label for="is_wc_template"><b><?php _e( 'Use WooCommerce Template Style:', 'woocommerce-ac' ); ?></b></label>
2815
+ </th>
2816
+ <td>
2817
+ <?php
2818
+ $is_wc_template = "";
2819
+ if ( $mode == 'edittemplate' ) {
2820
+ $use_wc_template = $results[0]->is_wc_template;
2821
 
2822
+ if ( $use_wc_template == '1' ) {
2823
+ $is_wc_template = "checked";
2824
+ } else {
2825
+ $is_wc_template = "";
2826
+ }
2827
+ }
2828
+ print'<input type="checkbox" name="is_wc_template" id="is_wc_template" ' . $is_wc_template . '> </input>'; ?>
2829
+ <img class="help_tip" width="16" height="16" data-tip='<?php _e( 'Use WooCommerce default style template for abandoned cart reminder emails.', 'woocommerce' ) ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" /> <a target = '_blank' href= <?php echo wp_nonce_url( admin_url( '?wcal_preview_woocommerce_mail=true' ), 'woocommerce-ac' ) ; ?> >
2830
+ Click here to preview </a>how the email template will look with WooCommerce Template Style enabled. Alternatively, if this is unchecked, the template will appear as <a target = '_blank' href=<?php echo wp_nonce_url( admin_url( '?wcal_preview_mail=true' ), 'woocommerce-ac' ) ; ?>>shown here</a>. <br> <strong>Note: </strong>When this setting is enabled, then "Send From This Name:" & "Send From This Email Address:" will be overwritten with WooCommerce -> Settings -> Email -> Email Sender Options.
2831
+ </td>
2832
+ </tr>
2833
+
2834
+ <tr>
2835
+ <th>
2836
+ <label for="wcal_wc_email_header"><b><?php _e( 'Email Template Header Text: ', 'woocommerce-ac' ); ?></b></label>
2837
+ </th>
2838
+ <td>
2839
 
2840
+ <?php
2841
+
2842
+ $wcal_wc_email_header = "";
2843
+ if ( $mode == 'edittemplate' ) {
2844
+ $wcal_wc_email_header = $results[0]->wc_email_header;
2845
+ }
2846
+ if ( $wcal_wc_email_header == "" ) {
2847
+ $wcal_wc_email_header = "Abandoned cart reminder";
2848
+ }
2849
+ print'<input type="text" name="wcal_wc_email_header" id="wcal_wc_email_header" class="regular-text" value="' . $wcal_wc_email_header . '">'; ?>
2850
+ <img class="help_tip" width="16" height="16" data-tip='<?php _e( 'Enter the header which will appear in the abandoned WooCommerce email sent. This is only applicable when only used when "Use WooCommerce Template Style:" is checked.', 'woocommerce-ac' ) ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" />
2851
+ </td>
2852
+ </tr>
2853
+
2854
+ <tr>
2855
+ <th>
2856
+ <label for="is_active"><b><?php _e( 'Active:', 'woocommerce-ac' ); ?></b></label>
2857
+ </th>
2858
+ <td>
2859
+ <?php
2860
+ $is_active_edit="";
2861
+ if ( $mode == 'edittemplate' ) {
2862
+ $active_edit = $results[0]->is_active;
2863
+ if ( $active_edit == '1' ) {
2864
+ $is_active_edit = "checked";
2865
+ } else {
2866
+ $is_active_edit = "";
2867
+ }
2868
+ }
2869
+ if ( $mode == 'copytemplate' ) {
2870
+ $active_edit = $results_copy[0]->is_active;
2871
+ if( $active_edit == '1' ) {
2872
+ $is_active_edit = "checked";
2873
+ } else {
2874
+ $is_active_edit = "";
2875
+ }
2876
+ }
2877
+ print'<input type="checkbox" name="is_active" id="is_active" ' . $is_active_edit . '> </input>'; ?>
2878
+ <img class="help_tip" width="16" height="16" data-tip='<?php _e( 'The email template will be sent to customers only if the "Active" checkbox is enabled. Leave this unchecked if you want to add the email template but not send it to customers.', 'woocommerce' ) ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" /></p>
2879
+ </td>
2880
+ </tr>
2881
+
2882
+ <tr>
2883
+ <th>
2884
+ <label for="woocommerce_ac_email_frequency"><b><?php _e( 'Send this email:', 'woocommerce-ac' ); ?></b></label>
2885
+ </th>
2886
+ <td>
2887
+ <select name="email_frequency" id="email_frequency">
2888
+ <?php
2889
+ $frequency_edit = "";
2890
+ if( $mode == 'edittemplate' ) {
2891
+ $frequency_edit = $results[0]->frequency;
2892
+ }
2893
+ for ( $i = 1; $i < 4; $i++ ) {
2894
+ printf( "<option %s value='%s'>%s</option>\n",
2895
+ selected( $i, $frequency_edit, false ),
2896
+ esc_attr( $i ),
2897
+ $i
2898
+ );
2899
+ }
2900
+ ?>
2901
+ </select>
2902
 
2903
+ <select name="day_or_hour" id="day_or_hour">
2904
+ <?php
2905
+ $days_or_hours_edit = "";
2906
+ if ( $mode == 'edittemplate')
2907
+ {
2908
+ $days_or_hours_edit = $results[0]->day_or_hour;
2909
+ }
2910
+ $days_or_hours = array(
2911
+ 'Days' => 'Day(s)',
2912
+ 'Hours' => 'Hour(s)'
2913
+ );
2914
+ foreach( $days_or_hours as $k => $v )
2915
+ {
2916
+ printf( "<option %s value='%s'>%s</option>\n",
2917
+ selected( $k, $days_or_hours_edit, false ),
2918
+ esc_attr( $k ),
2919
+ $v
2920
+ );
2921
+ }
2922
+ ?>
2923
+ </select>
2924
+ <span class="description">
2925
+ <?php echo __( 'after cart is abandoned.', 'woocommerce-ac' ); ?>
2926
+ </span>
2927
+ </td>
2928
+ </tr>
2929
+
2930
+ <tr>
2931
+ <th>
2932
+ <label for="woocommerce_ac_email_preview"><b><?php _e( 'Send a test email to:', 'woocommerce-ac' ); ?></b></label>
2933
+ </th>
2934
+ <td>
2935
+ <input type="text" id="send_test_email" name="send_test_email" class="regular-text" >
2936
+ <input type="button" value="Send a test email" id="preview_email" onclick="javascript:void(0);">
2937
+ <img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter the email id to which the test email needs to be sent.', 'woocommerce-ac') ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" />
2938
+ <div id="preview_email_sent_msg" style="display:none;"></div>
2939
+ </td>
2940
+ </tr>
2941
+ </table>
2942
+ </div>
2943
+ </div>
2944
+ </div>
2945
+ <p class="submit">
2946
+ <?php
2947
+ $button_value = "Save Changes";
2948
+ if ( $mode == 'edittemplate' )
2949
+ {
2950
+ $button_value = "Update Changes";
2951
+ }?>
2952
+ <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e( $button_value, 'woocommerce-ac' ); ?>" />
2953
+ </p>
2954
+ </form>
2955
+ </div>
2956
+ <?php
2957
+ }
2958
+ }
2959
+ function wcal_admin_footer_text( $footer_text ) {
2960
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
2961
+ return;
2962
+ }
2963
+ $current_screen = get_current_screen();
2964
+ $wc_pages = wc_get_screen_ids();
2965
+ // Set only wc pages
2966
+ $wc_pages = array_flip( $wc_pages );
2967
+ if ( isset( $wc_pages['profile'] ) ) {
2968
+ unset( $wc_pages['profile'] );
2969
+ }
2970
+ if ( isset( $wc_pages['user-edit'] ) ) {
2971
+ unset( $wc_pages['user-edit'] );
2972
+ }
2973
+ $wc_pages = array_flip( $wc_pages );
2974
+ $wc_pages[] = 'woocommerce_page_woocommerce_ac_page';
2975
+ // Check to make sure we're on a WooCommerce admin page
2976
+ if ( isset( $current_screen->id ) && apply_filters( 'woocommerce_display_admin_footer_text', in_array( $current_screen->id, $wc_pages ) ) ) {
2977
+ // Change the footer text
2978
+ if ( ! get_option( 'woocommerce_admin_footer_text_rated' ) ) {
2979
+ $footer_text = sprintf( __( 'If you like <strong>Abandoned Cart Lite for WooCommerce</strong> then please <a href="https://wordpress.org/support/plugin/woocommerce-abandoned-cart/reviews/">leave a review </a> for us and let us know how we are doing. A review will help us immensely.', 'woocommerce-ac' ) );
2980
+ wc_enqueue_js( "
2981
+ jQuery( 'a.wc-rating-link' ).click( function() {
2982
+ jQuery.post( '" . WC()->ajax_url() . "', { action: 'woocommerce_rated' } );
2983
+ jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) );
2984
+ });
2985
+ " );
2986
+ } else {
2987
+ $footer_text = __( 'Thank you for selling with Abandoned Cart Lite for WooCommerce.', 'woocommerce-ac' );
2988
+ }
2989
+ }
2990
+ return $footer_text;
2991
+ }
2992
+
2993
+ function bubble_sort_function( $unsort_array, $order ) {
2994
+ $temp = array();
2995
+ foreach ( $unsort_array as $key => $value )
2996
+ $temp[ $key ] = $value; //concatenate something unique to make sure two equal weights don't overwrite each other
2997
+ asort( $temp, SORT_NUMERIC ); // or ksort($temp, SORT_NATURAL); see paragraph above to understand why
2998
+
2999
+ if( $order == 'desc' ) {
3000
+ $array = array_reverse( $temp, true );
3001
+ } else if( $order == 'asc' ) {
3002
+ $array = $temp;
3003
+ }
3004
+ unset( $temp );
3005
+ return $array;
3006
+ }
3007
+
3008
+ function wcal_action_send_preview() {
3009
+ ?>
3010
+ <script type="text/javascript" >
3011
+ jQuery( document ).ready( function( $ )
3012
+ {
3013
+ $( "table#addedit_template input#preview_email" ).click( function()
3014
+ {
3015
+ var email_body = '';
3016
+ if ( jQuery("#wp-woocommerce_ac_email_body-wrap").hasClass( "tmce-active" ) ) {
3017
+ email_body = tinyMCE.get('woocommerce_ac_email_body').getContent();
3018
+ } else {
3019
+ email_body = jQuery('#woocommerce_ac_email_body').val();
3020
+ }
3021
+ var subject_email_preview = $( '#woocommerce_ac_email_subject' ).val();
3022
+ var body_email_preview = email_body;
3023
+ var send_email_id = $( '#send_test_email' ).val();
3024
+ var is_wc_template = document.getElementById( "is_wc_template" ).checked;
3025
+ var wc_template_header = $( '#wcal_wc_email_header' ).val() != '' ? $( '#wcal_wc_email_header' ).val() : 'Abandoned cart reminder';
3026
+ var data = {
3027
+ subject_email_preview: subject_email_preview,
3028
+ body_email_preview : body_email_preview,
3029
+ send_email_id : send_email_id,
3030
+ is_wc_template : is_wc_template,
3031
+ wc_template_header : wc_template_header,
3032
+ action : 'wcal_preview_email_sent'
3033
+ };
3034
+
3035
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
3036
+ $.post( ajaxurl, data, function( response )
3037
+ {
3038
+ if ( 'not sent' == response ) {
3039
+ $( "#preview_email_sent_msg" ).html( "Test email is not sent as the Email body is empty." );
3040
+ $( "#preview_email_sent_msg" ).fadeIn();
3041
+ setTimeout( function(){$( "#preview_email_sent_msg" ).fadeOut();}, 4000 );
3042
+ } else {
3043
+ $( "#preview_email_sent_msg" ).html( "<img src='<?php echo plugins_url(); ?>/woocommerce-abandoned-cart/assets/images/check.jpg'>&nbsp;Email has been sent successfully." );
3044
+ $( "#preview_email_sent_msg" ).fadeIn();
3045
+ setTimeout( function(){$( "#preview_email_sent_msg" ).fadeOut();}, 3000 );
3046
+ }
3047
+ //alert('Got this from the server: ' + response);
3048
+ });
3049
+ });
3050
+ });
3051
+ </script>
3052
+ <?php
3053
+ }
3054
+ // Send Test Email
3055
+ function wcal_preview_email_sent() {
3056
+ if ( '' != $_POST['body_email_preview'] ) {
3057
+ $from_email_name = get_option ( 'wcal_from_name' );
3058
+ $reply_name_preview = get_option ( 'wcal_from_email' );
3059
+ $from_email_preview = get_option ( 'wcal_reply_email' );
3060
+ $subject_email_preview = stripslashes ( $_POST['subject_email_preview'] );
3061
+ $body_email_preview = $_POST['body_email_preview'];
3062
+ $is_wc_template = $_POST['is_wc_template'];
3063
+ $wc_template_header = stripslashes( $_POST['wc_template_header'] );
3064
+ $body_email_preview = str_replace( '{{customer.firstname}}', 'John', $body_email_preview );
3065
+ $body_email_preview = str_replace( '{{customer.lastname}}', 'Doe', $body_email_preview );
3066
+ $body_email_preview = str_replace( '{{customer.fullname}}', 'John'." ".'Doe', $body_email_preview );
3067
+ $current_time_stamp = current_time( 'timestamp' );
3068
+ $test_date = date( 'd M, Y h:i A', $current_time_stamp );
3069
+ $body_email_preview = str_replace( '{{cart.abandoned_date}}', $test_date, $body_email_preview );
3070
+ $cart_url = wc_get_page_permalink( 'cart' );
3071
+ $body_email_preview = str_replace( '{{cart.link}}', $cart_url, $body_email_preview );
3072
+ $body_email_preview = str_replace( '{{cart.unsubscribe}}', '<a href=#>unsubscribe</a>', $body_email_preview );
3073
+ if ( class_exists( 'WP_Better_Emails' ) ) {
3074
+ $headers = "From: " . $from_email_name . " <" . $from_email_preview . ">" . "\r\n";
3075
+ $headers .= "Content-Type: text/plain" . "\r\n";
3076
+ $headers .= "Reply-To: " . $reply_name_preview . " " . "\r\n";
3077
+ $var = '<table width = 100%>
3078
+ <tr> <td colspan="5"> <h3>'.__( "Your Shopping Cart", "woocommerce-ac" ).'</h3> </td></tr>
3079
+ <tr align="center">
3080
+ <th>'.__( "Item", "woocommerce-ac" ).'</th>
3081
+ <th>'.__( "Name", "woocommerce-ac" ).'</th>
3082
+ <th>'.__( "Quantity", "woocommerce-ac" ).'</th>
3083
+ <th>'.__( "Price", "woocommerce-ac" ).'</th>
3084
+ <th>'.__( "Line Subtotal", "woocommerce-ac" ).'</th>
3085
+ </tr>
3086
+ <tr align="center">
3087
+ <td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/shoes.jpg"/></td>
3088
+ <td>'.__( "Men\'\s Formal Shoes", "woocommerce-ac" ).'</td>
3089
+ <td>1</td>
3090
+ <td>$100</td>
3091
+ <td>$100</td>
3092
+ </tr>
3093
+ <tr align="center">
3094
+ <td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/handbag.jpg"/></td>
3095
+ <td>'.__( "Woman\'\s Hand Bags", "woocommerce-ac" ).'</td>
3096
+ <td>1</td>
3097
+ <td>$100</td>
3098
+ <td>$100</td>
3099
+ </tr>
3100
+ <tr align="center">
3101
+ <td></td>
3102
+ <td></td>
3103
+ <td></td>
3104
+ <td>'.__( "Cart Total:", "woocommerce-ac" ).'</td>
3105
+ <td>$200</td>
3106
+ </tr>
3107
+ </table>';
3108
+ } else {
3109
+ $headers = "From: " . $from_email_name . " <" . $from_email_preview . ">" . "\r\n";
3110
+ $headers .= "Content-Type: text/html" . "\r\n";
3111
+ $headers .= "Reply-To: " . $reply_name_preview . " " . "\r\n";
3112
+ $var = '<h3>'.__( "Your Shopping Cart", "woocommerce-ac" ).'</h3>
3113
+ <table border="0" cellpadding="10" cellspacing="0" class="templateDataTable">
3114
+ <tr align="center">
3115
+ <th>'.__( "Item", "woocommerce-ac" ).'</th>
3116
+ <th>'.__( "Name", "woocommerce-ac" ).'</th>
3117
+ <th>'.__( "Quantity", "woocommerce-ac" ).'</th>
3118
+ <th>'.__( "Price", "woocommerce-ac" ).'</th>
3119
+ <th>'.__( "Line Subtotal", "woocommerce-ac" ).'</th>
3120
+ </tr>
3121
+ <tr align="center">
3122
+ <td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/shoes.jpg"/></td>
3123
+ <td>'.__( "Men\'\s Formal Shoes", "woocommerce-ac" ).'</td>
3124
+ <td>1</td>
3125
+ <td>$100</td>
3126
+ <td>$100</td>
3127
+ </tr>
3128
+ <tr align="center">
3129
+ <td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/handbag.jpg"/></td>
3130
+ <td>'.__( "Woman\'\s Hand Bags", "woocommerce-ac" ).'</td>
3131
+ <td>1</td>
3132
+ <td>$100</td>
3133
+ <td>$100</td>
3134
+ </tr>
3135
+ <tr align="center">
3136
+ <td></td>
3137
+ <td></td>
3138
+ <td></td>
3139
+ <td>'.__( "Cart Total:", "woocommerce-ac" ).'</td>
3140
+ <td>$200</td>
3141
+ </tr>
3142
+ </table>';
3143
+ }
3144
+ $body_email_preview = str_replace( '{{products.cart}}', $var, $body_email_preview );
3145
+ if ( isset( $_POST['send_email_id'] ) ) {
3146
+ $to_email_preview = $_POST['send_email_id'];
3147
+ } else {
3148
+ $to_email_preview = "";
3149
+ }
3150
+ $user_email_from = get_option( 'admin_email' );
3151
+ $body_email_final_preview = stripslashes( $body_email_preview );
3152
 
3153
+ if ( isset( $is_wc_template ) && "true" == $is_wc_template ) {
3154
+ ob_start();
3155
+ // Get email heading
3156
+ wc_get_template( 'emails/email-header.php', array( 'email_heading' => $wc_template_header ) );
3157
+ $email_body_template_header = ob_get_clean();
3158
 
3159
+ ob_start();
3160
+ wc_get_template( 'emails/email-footer.php' );
3161
+ $email_body_template_footer = ob_get_clean();
3162
+
3163
+ $final_email_body = $email_body_template_header . $body_email_final_preview . $email_body_template_footer;
3164
+
3165
+ wc_mail( $to_email_preview, $subject_email_preview, $final_email_body , $headers );
3166
+ }
3167
+ else {
3168
+ wp_mail( $to_email_preview, $subject_email_preview, stripslashes( $body_email_preview ), $headers );
3169
+ }
3170
+ echo "email sent";
3171
+ die();
3172
+ } else {
3173
+ echo "not sent";
3174
+ die();
3175
+ }
3176
+ }
3177
+ }
3178
+ }
3179
+ $woocommerce_abandon_cart = new woocommerce_abandon_cart_lite();
3180
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
woocommerce_guest_ac.class.php DELETED
@@ -1,208 +0,0 @@
1
- <?php
2
- /* Woocommerce Abandoned Cart Plugin Addon - Saves guest cart information
3
- *
4
- */
5
- {
6
- /**
7
- * Localisation
8
- **/
9
-
10
- /**
11
- * woocommerce_abandon_cart class
12
- **/
13
- if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
14
-
15
- class woocommerce_guest_ac {
16
- var $a;
17
- public function __construct() {
18
- add_action( 'woocommerce_after_checkout_billing_form', 'user_side_js' );
19
- add_action( 'init','load_ac_ajax' );
20
- add_filter( 'woocommerce_checkout_fields', 'guest_checkout_fields' );
21
- }
22
- }
23
-
24
- /*-----------------------------------------------------------------------------------*/
25
- /* Class Functions */
26
- /*-----------------------------------------------------------------------------------*/
27
- function load_ac_ajax() {
28
-
29
- if ( ! is_user_logged_in() ) {
30
- add_action( 'wp_ajax_nopriv_save_data', 'save_data' );
31
- } else {
32
- add_action( 'wp_ajax_save_data', 'save_data' );
33
- }
34
- }
35
-
36
- function user_side_js() {
37
- ?>
38
- <script type="text/javascript">
39
- jQuery( 'input#billing_email' ).on( 'change', function() {
40
- var data = {
41
- billing_first_name : jQuery('#billing_first_name').val(),
42
- billing_last_name : jQuery('#billing_last_name').val(),
43
- billing_company : jQuery('#billing_company').val(),
44
- billing_address_1 : jQuery('#billing_address_1').val(),
45
- billing_address_2 : jQuery('#billing_address_2').val(),
46
- billing_city : jQuery('#billing_city').val(),
47
- billing_state : jQuery('#billing_state').val(),
48
- billing_postcode : jQuery('#billing_postcode').val(),
49
- billing_country : jQuery('#billing_country').val(),
50
- billing_phone : jQuery('#billing_phone').val(),
51
- billing_email : jQuery('#billing_email').val(),
52
- order_notes : jQuery('#order_comments').val(),
53
- shipping_first_name : jQuery('#shipping_first_name').val(),
54
- shipping_last_name : jQuery('#shipping_last_name').val(),
55
- shipping_company : jQuery('#shipping_company').val(),
56
- shipping_address_1 : jQuery('#shipping_address_1').val(),
57
- shipping_address_2 : jQuery('#shipping_address_2').val(),
58
- shipping_city : jQuery('#shipping_city').val(),
59
- shipping_state : jQuery('#shipping_state').val(),
60
- shipping_postcode : jQuery('#shipping_postcode').val(),
61
- shipping_country : jQuery('#shipping_country').val(),
62
- ship_to_billing : jQuery('#shiptobilling-checkbox').val(),
63
- action: 'save_data'
64
- };
65
- jQuery.post( "<?php echo get_home_url();?>/wp-admin/admin-ajax.php", data, function(response) {
66
- });
67
- });
68
- </script>
69
- <?php
70
- }
71
-
72
- function save_data() {
73
-
74
- if ( ! is_user_logged_in() ) {
75
- global $wpdb, $woocommerce;
76
-
77
- $_SESSION['billing_first_name'] = $_POST['billing_first_name'];
78
- $_SESSION['billing_last_name'] = $_POST['billing_last_name'];
79
- $_SESSION['billing_company'] = $_POST['billing_company'];
80
- $_SESSION['billing_address_1'] = $_POST['billing_address_1'];
81
- $_SESSION['billing_address_2'] = $_POST['billing_address_2'];
82
- $_SESSION['billing_city'] = $_POST['billing_city'];
83
- $_SESSION['billing_state'] = $_POST['billing_state'];
84
- $_SESSION['billing_postcode'] = $_POST['billing_postcode'];
85
- $_SESSION['billing_country'] = $_POST['billing_country'];
86
- $_SESSION['billing_email'] = $_POST['billing_email'];
87
- $_SESSION['billing_phone'] = $_POST['billing_phone'];
88
- $_SESSION['order_notes'] = $_POST['order_notes'];
89
- $_SESSION['ship_to_billing'] = $_POST['ship_to_billing'];
90
- $_SESSION['shipping_first_name'] = $_POST['shipping_first_name'];
91
- $_SESSION['shipping_last_name'] = $_POST['shipping_last_name'];
92
- $_SESSION['shipping_company'] = $_POST['shipping_company'];
93
- $_SESSION['shipping_address_1'] = $_POST['shipping_address_1'];
94
- $_SESSION['shipping_address_2'] = $_POST['shipping_address_2'];
95
- $_SESSION['shipping_city'] = $_POST['shipping_city'];
96
- $_SESSION['shipping_state'] = $_POST['shipping_state'];
97
- $_SESSION['shipping_postcode'] = $_POST['shipping_postcode'];
98
- $_SESSION['shipping_country'] = $_POST['shipping_country'];
99
-
100
- // If a record is present in the guest cart history table for the same email id, then delete the previous records
101
- $query_guest = "SELECT id FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE email_id = %s";
102
- $results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $_SESSION['billing_email'] ) );
103
-
104
- if ( $results_guest ) {
105
-
106
- foreach ( $results_guest as $key => $value ) {
107
- $query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
108
- WHERE user_id = %d AND recovered_cart = '0'" ;
109
- $result = $wpdb->get_results( $wpdb->prepare( $query, $value->id ) );
110
-
111
- if ( $result ) {
112
- $delete_sent_email = "DELETE FROM `".$wpdb->prefix."ac_sent_history` WHERE abandoned_order_id = '".$result[0]->id."'";
113
- $wpdb->query( $delete_sent_email );
114
- $delete_query = "DELETE FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id = '".$value->id."'";
115
- $wpdb->query( $delete_query );
116
- }
117
- $guest_delete = "DELETE FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = '".$value->id."'";
118
- $wpdb->query( $guest_delete );
119
- }
120
- }
121
-
122
- // Insert record in guest table
123
- if ( isset( $_SESSION['billing_first_name'] ) ) $billing_first_name = $_SESSION['billing_first_name'];
124
- else $billing_first_name = '';
125
-
126
- if ( isset( $_SESSION['billing_last_name'] ) ) $billing_last_name = $_SESSION['billing_last_name'];
127
- else $billing_last_name = '';
128
-
129
- $shipping_zipcode = $billing_zipcode = '';
130
-
131
- if ( isset( $_SESSION['shipping_postcode'] ) && $_SESSION['shipping_postcode'] != "" ) $shipping_zipcode = $_SESSION['shipping_postcode'];
132
- else $shipping_zipcode = $billing_zipcode = $_SESSION['billing_postcode'];
133
- $shipping_charges = $woocommerce->cart->shipping_total;
134
- $insert_guest = "INSERT INTO `".$wpdb->prefix . "ac_guest_abandoned_cart_history_lite`( billing_first_name, billing_last_name, email_id, billing_zipcode, shipping_zipcode, shipping_charges )
135
- VALUES ( '".$billing_first_name."', '".$billing_last_name."', '".$_SESSION['billing_email']."', '".$billing_zipcode."', '".$shipping_zipcode."', '".$shipping_charges."' )";
136
- $wpdb->query( $insert_guest );
137
-
138
- //Insert record in abandoned cart table for the guest user
139
- $user_id = $wpdb->insert_id;
140
- $_SESSION['user_id'] = $user_id;
141
- $current_time = current_time('timestamp');
142
- $cut_off_time = get_option('ac_cart_abandoned_time');
143
- $cart_cut_off_time = $cut_off_time * 60;
144
- $compare_time = $current_time - $cart_cut_off_time;
145
-
146
- $query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id = %d AND cart_ignored = '0' AND recovered_cart = '0' AND user_type = 'GUEST'";
147
- $results = $wpdb->get_results( $wpdb->prepare( $query, $user_id ) );
148
- $cart = array();
149
-
150
- foreach ( $woocommerce->cart->cart_contents as $cart_id => $value ) {
151
- $cart['cart'][$cart_id] = array();
152
- foreach ( $value as $k=>$v ) {
153
- $cart['cart'][$cart_id][$k] = $v;
154
- if ( $k == "quantity" ) {
155
- $product = get_product( $cart['cart'][$cart_id]['product_id'] );
156
- $product_type = $product->product_type;
157
-
158
- if ( $product_type == "variable" ) {
159
- if(is_plugin_active('woocommerce-dynamic-pricing/woocommerce-dynamic-pricing.php')) {
160
- $price = floatval( preg_replace( '#[^\d.]#', '', $woocommerce->cart->total ) );
161
- } else {
162
- $price = get_post_meta( $cart['cart'][$cart_id]['variation_id'], '_price', true);
163
- }
164
- } else {
165
- if(is_plugin_active('woocommerce-dynamic-pricing/woocommerce-dynamic-pricing.php')) {
166
- $price = floatval( preg_replace( '#[^\d.]#', '', $woocommerce->cart->total ) );
167
- } else {
168
- $price = get_post_meta( $cart['cart'][$cart_id]['product_id'], '_price', true);
169
- }
170
- }
171
- if(is_plugin_active('woocommerce-dynamic-pricing/woocommerce-dynamic-pricing.php')) {
172
- $cart['cart'][$cart_id]['line_total'] = $price;
173
- }else {
174
- $cart['cart'][$cart_id]['line_total'] = $cart['cart'][$cart_id]['quantity'] * $price;
175
- }
176
- $cart['cart'][$cart_id]['line_tax'] = '0';
177
- $cart['cart'][$cart_id]['line_subtotal'] = $cart['cart'][$cart_id]['line_total'];
178
- $cart['cart'][$cart_id]['line_subtotal_tax'] = $cart['cart'][$cart_id]['line_tax'];
179
- break;
180
- }
181
- }
182
- }
183
-
184
- if ( count( $results ) == 0 ) {
185
- $cart_info = json_encode( $cart );
186
- $insert_query = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`( user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, recovered_cart, user_type )
187
- VALUES ( '".$user_id."', '".$cart_info."', '".$current_time."', '0', '0', 'GUEST' )";
188
- $wpdb->query( $insert_query );
189
- $insert_persistent_cart = "INSERT INTO `".$wpdb->prefix."usermeta`( user_id, meta_key, meta_value )
190
- VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
191
- $wpdb->query( $insert_persistent_cart );
192
- }
193
- }
194
- }
195
-
196
- function guest_checkout_fields( $fields ) {
197
-
198
- if ( isset( $_SESSION['guest_first_name']) && $_SESSION['guest_first_name'] != "" ) $_POST['billing_first_name'] = $_SESSION['guest_first_name'];
199
-
200
- if ( isset( $_SESSION['guest_last_name']) && $_SESSION['guest_last_name'] != "" ) $_POST['billing_last_name'] = $_SESSION['guest_last_name'];
201
-
202
- if ( isset( $_SESSION['guest_email']) && $_SESSION['guest_email'] != "" ) $_POST['billing_email'] = $_SESSION['guest_email'];
203
- return $fields;
204
- }
205
- }
206
- $woocommerce_guest_ac = new woocommerce_guest_ac();
207
- }
208
- ?>