Abandoned Cart Lite for WooCommerce - Version 5.1.1

Version Description

(01.11.2018) =

  • Bug Fixed - Changed the file name in the plugin.
Download this release

Release Info

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

Code changes from version 5.0.2 to 5.1.1

Files changed (92) hide show
  1. {woocommerce-abandoned-cart/assets → assets}/css/view.abandoned.orders.style.css +0 -0
  2. {woocommerce-abandoned-cart/assets → assets}/css/wcal_template_activate.css +0 -0
  3. {woocommerce-abandoned-cart/assets → assets}/images/abandon-cart-cut-off-time.png +0 -0
  4. {woocommerce-abandoned-cart/assets → assets}/images/abandoned-cart-lite-email-templates.png +0 -0
  5. {woocommerce-abandoned-cart/assets → assets}/images/abandoned_cart_small.png +0 -0
  6. {woocommerce-abandoned-cart/assets → assets}/images/ac_editor_icon.png +0 -0
  7. {woocommerce-abandoned-cart/assets → assets}/images/ac_tab_icon.png +0 -0
  8. {woocommerce-abandoned-cart/assets → assets}/images/check.jpg +0 -0
  9. {woocommerce-abandoned-cart/assets → assets}/images/copy.png +0 -0
  10. {woocommerce-abandoned-cart/assets → assets}/images/delete.png +0 -0
  11. {woocommerce-abandoned-cart/assets → assets}/images/edit.png +0 -0
  12. {woocommerce-abandoned-cart/assets → assets}/images/email-templates-send-time.png +0 -0
  13. {woocommerce-abandoned-cart/assets → assets}/images/handbag.jpg +0 -0
  14. {woocommerce-abandoned-cart/assets → assets}/images/icon-256x256.png +0 -0
  15. {woocommerce-abandoned-cart/assets → assets}/images/shoes.jpg +0 -0
  16. {woocommerce-abandoned-cart/assets → assets}/images/site-logo-new.jpg +0 -0
  17. {woocommerce-abandoned-cart/assets → assets}/images/spectre.jpg +0 -0
  18. {woocommerce-abandoned-cart/assets → assets}/js/abandoncart_plugin_button.js +0 -0
  19. {woocommerce-abandoned-cart/assets → assets}/js/jquery.tipTip.minified.js +0 -0
  20. {woocommerce-abandoned-cart/assets → assets}/js/wcal_template_activate.js +0 -0
  21. {woocommerce-abandoned-cart/assets → assets}/js/wcal_ts_dismiss_notice.js +0 -0
  22. {woocommerce-abandoned-cart/cron → cron}/wcal_send_email.php +112 -107
  23. {woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart-de_DE.mo +0 -0
  24. {woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart-he_IL.mo +0 -0
  25. {woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart-he_IL.po +0 -0
  26. {woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart-hu_HU.mo +0 -0
  27. {woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart-hu_HU.po +0 -0
  28. {woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart-sk_SK.mo +0 -0
  29. {woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart-sk_SK.po +0 -0
  30. {woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart.mo +0 -0
  31. {woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart.po +0 -0
  32. {woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart.pot +0 -0
  33. {woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart_DE.po +0 -0
  34. {woocommerce-abandoned-cart/includes → includes}/admin/wcal_privacy_erase.php +13 -13
  35. {woocommerce-abandoned-cart/includes → includes}/admin/wcal_privacy_export.php +48 -48
  36. includes/background-processes/wcal-async-request.php +36 -0
  37. includes/background-processes/wcal-background-process.php +52 -0
  38. includes/background-processes/wcal_process_base.php +63 -0
  39. {woocommerce-abandoned-cart/includes → includes}/classes/class-wcal-abandoned-orders-table.php +2 -4
  40. {woocommerce-abandoned-cart/includes → includes}/classes/class-wcal-aes-counter.php +0 -0
  41. {woocommerce-abandoned-cart/includes → includes}/classes/class-wcal-aes.php +0 -0
  42. {woocommerce-abandoned-cart/includes → includes}/classes/class-wcal-product-report-table.php +0 -0
  43. {woocommerce-abandoned-cart/includes → includes}/classes/class-wcal-recover-orders-table.php +2 -2
  44. {woocommerce-abandoned-cart/includes → includes}/classes/class-wcal-templates-table.php +0 -0
  45. {woocommerce-abandoned-cart/includes → includes}/component/README.md +0 -0
  46. {woocommerce-abandoned-cart/includes → includes}/component/WooCommerce-Check/Instructions +0 -0
  47. {woocommerce-abandoned-cart/includes → includes}/component/WooCommerce-Check/ts-woo-active.php +0 -0
  48. {woocommerce-abandoned-cart/includes → includes}/component/deactivate-survey-popup/Instructions +0 -0
  49. {woocommerce-abandoned-cart/includes → includes}/component/deactivate-survey-popup/class-ts-deactivation.php +0 -0
  50. {woocommerce-abandoned-cart/includes → includes}/component/deactivate-survey-popup/template/ts-deactivate-modal.php +0 -0
  51. {woocommerce-abandoned-cart/includes → includes}/component/faq-support/Instructions +0 -0
  52. {woocommerce-abandoned-cart/includes → includes}/component/faq-support/templates/faq-page/faq-page.php +0 -0
  53. {woocommerce-abandoned-cart/includes → includes}/component/faq-support/ts-faq-support.php +0 -0
  54. {woocommerce-abandoned-cart/includes → includes}/component/pro-notices-in-lite/Instructions +0 -0
  55. {woocommerce-abandoned-cart/includes → includes}/component/pro-notices-in-lite/ts-pro-notices.php +0 -0
  56. {woocommerce-abandoned-cart/includes → includes}/component/tracking-data/Instructions +0 -0
  57. {woocommerce-abandoned-cart/includes → includes}/component/tracking-data/assets/images/site-logo-new.jpg +0 -0
  58. {woocommerce-abandoned-cart/includes → includes}/component/tracking-data/assets/js/dismiss-notice.js +0 -0
  59. {woocommerce-abandoned-cart/includes → includes}/component/tracking-data/class-ts-tracker.php +0 -0
  60. {woocommerce-abandoned-cart/includes → includes}/component/tracking-data/ts-tracking.php +1 -1
  61. {woocommerce-abandoned-cart/includes → includes}/component/welcome-page/Instructions +0 -0
  62. {woocommerce-abandoned-cart/includes → includes}/component/welcome-page/assets/images/abandon-cart-cut-off-time.png +0 -0
  63. {woocommerce-abandoned-cart/includes → includes}/component/welcome-page/assets/images/abandoned-cart-lite-email-templates.png +0 -0
  64. {woocommerce-abandoned-cart/includes → includes}/component/welcome-page/assets/images/email-templates-send-time.png +0 -0
  65. {woocommerce-abandoned-cart/includes → includes}/component/welcome-page/assets/images/icon-256x256.png +0 -0
  66. {woocommerce-abandoned-cart/includes → includes}/component/welcome-page/assets/images/site-logo-new.jpg +0 -0
  67. {woocommerce-abandoned-cart/includes → includes}/component/welcome-page/templates/social-media-elements.php +0 -0
  68. {woocommerce-abandoned-cart/includes → includes}/component/welcome-page/templates/welcome/welcome-page.php +2 -2
  69. {woocommerce-abandoned-cart/includes → includes}/component/welcome-page/ts-welcome.php +0 -0
  70. includes/templates/template_1.php +144 -0
  71. includes/wcal-common.php +776 -0
  72. {woocommerce-abandoned-cart/includes → includes}/wcal_actions.php +38 -33
  73. {woocommerce-abandoned-cart/includes → includes}/wcal_admin_notice.php +2 -2
  74. {woocommerce-abandoned-cart/includes → includes}/wcal_all_component.php +49 -48
  75. {woocommerce-abandoned-cart/includes → includes}/wcal_class-guest.php +78 -88
  76. {woocommerce-abandoned-cart/includes → includes}/wcal_data_tracking_message.php +6 -6
  77. includes/wcal_default-settings.php +53 -0
  78. {woocommerce-abandoned-cart/includes → includes}/wcal_ts_tracking.php +0 -0
  79. {woocommerce-abandoned-cart/includes → includes}/welcome.php +0 -0
  80. woocommerce-abandoned-cart/readme.txt → readme.txt +32 -2
  81. woocommerce-abandoned-cart/screenshot-1.png → screenshot-1.png +0 -0
  82. woocommerce-abandoned-cart/screenshot-2.png → screenshot-2.png +0 -0
  83. woocommerce-abandoned-cart/screenshot-3.png → screenshot-3.png +0 -0
  84. woocommerce-abandoned-cart/screenshot-4.png → screenshot-4.png +0 -0
  85. woocommerce-abandoned-cart/screenshot-5.png → screenshot-5.png +0 -0
  86. views/wcal-email-template-preview.php +188 -0
  87. views/wcal-wc-email-template-preview.php +187 -0
  88. woocommerce-abandoned-cart/includes/wcal-common.php +0 -741
  89. woocommerce-abandoned-cart/includes/wcal_default-settings.php +0 -61
  90. woocommerce-abandoned-cart/views/wcal-email-template-preview.php +0 -67
  91. woocommerce-abandoned-cart/views/wcal-wc-email-template-preview.php +0 -61
  92. woocommerce-abandoned-cart/woocommerce-ac.php → woocommerce-ac.php +484 -453
{woocommerce-abandoned-cart/assets → assets}/css/view.abandoned.orders.style.css RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/css/wcal_template_activate.css RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/images/abandon-cart-cut-off-time.png RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/images/abandoned-cart-lite-email-templates.png RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/images/abandoned_cart_small.png RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/images/ac_editor_icon.png RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/images/ac_tab_icon.png RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/images/check.jpg RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/images/copy.png RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/images/delete.png RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/images/edit.png RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/images/email-templates-send-time.png RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/images/handbag.jpg RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/images/icon-256x256.png RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/images/shoes.jpg RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/images/site-logo-new.jpg RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/images/spectre.jpg RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/js/abandoncart_plugin_button.js RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/js/jquery.tipTip.minified.js RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/js/wcal_template_activate.js RENAMED
File without changes
{woocommerce-abandoned-cart/assets → assets}/js/wcal_ts_dismiss_notice.js RENAMED
File without changes
{woocommerce-abandoned-cart/cron → cron}/wcal_send_email.php RENAMED
@@ -1,4 +1,4 @@
1
- <?php
2
  /**
3
  * It will send the automatic reminder emails to the customers.
4
  *
@@ -19,6 +19,12 @@ if ( ! isset( $wp_load ) ) {
19
  break;
20
  }
21
  }
 
 
 
 
 
 
22
  }
23
  $wcal_root = dirname( dirname(__FILE__) ); // go two level up for directory from this file.
24
  require_once $wp_load;
@@ -32,12 +38,12 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
32
  * It will send the automatic reminder emails to the customers
33
  * @since 1.3
34
  */
35
- class woocommerce_abandon_cart_cron {
36
  var $cart_settings_cron;
37
- var $cart_abandon_cut_off_time_cron;
38
- public function __construct() {
39
- $this->cart_settings_cron = get_option( 'ac_lite_cart_abandoned_time' );
40
- $this->cart_abandon_cut_off_time_cron = ( $this->cart_settings_cron ) * 60;
41
  }
42
  /**
43
  * It will send the reminder emails to the cutomers.
@@ -47,15 +53,15 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
47
  * @globals mixed $woocommerce
48
  * @since 1.3
49
  */
50
- function wcal_send_email_notification() {
51
- global $wpdb, $woocommerce;
52
  //Grab the cart abandoned cut-off time from database.
53
- $cart_settings = get_option( 'ac_lite_cart_abandoned_time' );
54
- $cart_abandon_cut_off_time = $cart_settings * 60;
55
  //Fetch all active templates present in the system
56
  $query = "SELECT wpet . * FROM `".$wpdb->prefix."ac_email_templates_lite` AS wpet
57
  WHERE wpet.is_active = '1' ORDER BY `day_or_hour` DESC, `frequency` ASC ";
58
- $results = $wpdb->get_results( $query );
59
  $hour_seconds = 3600; // 60 * 60
60
  $day_seconds = 86400; // 24 * 60 * 60
61
  foreach ( $results as $key => $value ) {
@@ -63,10 +69,11 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
63
  $time_to_send_template_after = $value->frequency * $day_seconds;
64
  } elseif ( $value->day_or_hour == 'Hours' ) {
65
  $time_to_send_template_after = $value->frequency * $hour_seconds;
66
- }
 
67
  $carts = $this->wcal_get_carts( $time_to_send_template_after, $cart_abandon_cut_off_time );
68
  $email_frequency = $value->frequency;
69
- $email_body_template = $value->body;
70
  $email_subject = stripslashes ( $value->subject );
71
  $email_subject = convert_smilies ( $email_subject );
72
  $wcal_from_name = get_option ( 'wcal_from_name' );
@@ -85,7 +92,7 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
85
  $is_wc_template = $value->is_wc_template;
86
  $wc_template_header_text = $value->wc_email_header != '' ? $value->wc_email_header : __( 'Abandoned cart reminder', 'woocommerce-abandoned-cart');
87
  $wc_template_header = stripslashes( $wc_template_header_text );
88
- if ( '' != $email_body_template ) {
89
  foreach ( $carts as $key => $value ) {
90
 
91
  $wcal_is_guest_id_correct = $this->wcal_get_is_guest_valid ( $value->user_id, $value->user_type ) ;
@@ -93,7 +100,7 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
93
 
94
  if ( $value->user_type == "GUEST" && $value->user_id != '0' ) {
95
  $value->user_login = "";
96
- $query_guest = "SELECT billing_first_name, billing_last_name, email_id FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite`
97
  WHERE id = %d";
98
  $results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $value->user_id ) );
99
  if ( count( $results_guest ) > 0 && isset( $results_guest[0]->email_id ) ) {
@@ -105,7 +112,7 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
105
  }
106
  $key = 'billing_email';
107
  $single = true;
108
- $user_biiling_email = get_user_meta( $user_id, $key, $single );
109
  if ( isset( $user_biiling_email ) && $user_biiling_email != '' ) {
110
  $value->user_email = $user_biiling_email;
111
  }
@@ -119,43 +126,43 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
119
  }
120
  if( count( get_object_vars( $cart ) ) > 0 && isset( $value->user_id ) && '0' != $value->user_id && isset( $value->id ) ) {
121
  $cart_update_time = $value->abandoned_cart_time;
122
- $new_user = $this->wcal_check_sent_history( $value->user_id, $cart_update_time, $template_id, $value->id );
123
  if ( $new_user == true ) {
124
 
125
  /**
126
- * When there are 3 templates and for cart id 1 all template time has been reached. BUt all templates
127
  * are deactivated.
128
  * If we activate all 3 template then at a 1 time all 3 email templates send to the users.
129
- * So below function check that after first email is sent time and then from that time it will send the
130
  * 2nd template time. ( It will not consider the cart abadoned time in this case. )
131
  */
132
 
133
  $wcal_check_cart_needed_for_multiple_template = $this->wcal_remove_cart_for_mutiple_templates( $value->id, $time_to_send_template_after, $template_id );
134
 
135
  /**
136
- * When we click on the place order button, we check if the order is placed after the
137
- * cut off time. And if yes then if the status of the order is pending or falied then
138
- * we keep it as the abandonoed and we need to send reminder emails. So in below function
139
- * we first check if any order is placed with todays date then we do not send the
140
- * reminder email. But what if placed order status is pending or falied? So this
141
- * condition will not call that function andthe reminder email will be sent.
142
  */
143
 
144
  $wcal_check_if_cart_is_present_in_post_meta = "SELECT wpm.post_id, wpost.post_date, wpost.post_status FROM `" . $wpdb->prefix . "postmeta` AS wpm
145
- LEFT JOIN `" . $wpdb->prefix . "posts` AS wpost
146
  ON wpm.post_id = wpost.ID
147
- WHERE wpm.meta_key = 'wcap_recover_order_placed' AND
148
- wpm.meta_value = %s AND wpm.post_id = wpost.ID AND
149
- wpost.post_type = 'shop_order'
150
  ORDER BY wpm.post_id DESC LIMIT 1";
151
 
152
  $results_wcal_check_if_cart_is_present_in_post_meta = $wpdb->get_results( $wpdb->prepare( $wcal_check_if_cart_is_present_in_post_meta, $value->id ) );
153
 
154
  $wcap_check_cart_staus_need_to_update = false;
155
 
156
- if ( empty ($results_wcal_check_if_cart_is_present_in_post_meta) ||
157
- ( isset( $results_wcal_check_if_cart_is_present_in_post_meta[0] ) &&
158
- $results_wcal_check_if_cart_is_present_in_post_meta[0]->post_status != "wc-failed" &&
159
  $results_wcal_check_if_cart_is_present_in_post_meta [0]->post_status != "wc-pending" ) ){
160
 
161
  $wcap_check_cart_staus_need_to_update = woocommerce_abandon_cart_cron::wcal_update_abandoned_cart_status_for_placed_orders ( $time_to_send_template_after, $cart_update_time, $value->user_id, $value->user_type, $value->id, $value->user_email );
@@ -165,17 +172,17 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
165
  false == $wcap_check_cart_staus_need_to_update ) {
166
 
167
  $cart_info_db = $value->abandoned_cart_info;
168
- $email_body = $email_body_template;
169
  $wcal_check_cart_total = $this->wcal_check_cart_total( $cart );
170
  if( true == $wcal_check_cart_total ) {
171
  if ( $value->user_type == "GUEST" ) {
172
  if ( isset( $results_guest[0]->billing_first_name ) ) {
173
  $email_body = str_replace( "{{customer.firstname}}", $results_guest[0]->billing_first_name, $email_body );
174
  $email_subject = str_replace( "{{customer.firstname}}", $results_guest[0]->billing_first_name, $email_subject );
175
- }
176
  if ( isset( $results_guest[0]->billing_last_name ) ) {
177
  $email_body = str_replace( "{{customer.lastname}}", $results_guest[0]->billing_last_name, $email_body );
178
- }
179
  if ( isset( $results_guest[0]->billing_first_name ) && isset( $results_guest[0]->billing_last_name ) ) {
180
  $email_body = str_replace( "{{customer.fullname}}", $results_guest[0]->billing_first_name." ".$results_guest[0]->billing_last_name, $email_body );
181
  }
@@ -186,7 +193,7 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
186
  $email_body = str_replace( "{{customer.fullname}}", $results_guest[0]->billing_last_name, $email_body );
187
  }
188
  } else {
189
- $user_first_name = '';
190
  $user_first_name_temp = get_user_meta( $value->user_id, 'billing_first_name', true );
191
  if( isset( $user_first_name_temp ) && "" == $user_first_name_temp ) {
192
  $user_data = get_userdata( $user_id );
@@ -197,9 +204,9 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
197
  }
198
  } else {
199
  $user_first_name = $user_first_name_temp;
200
- }
201
- $email_body = str_replace( "{{customer.firstname}}", $user_first_name, $email_body );
202
- $email_subject = str_replace( "{{customer.firstname}}", $user_first_name, $email_subject );
203
  $user_last_name = '';
204
  $user_last_name_temp = get_user_meta( $value->user_id, 'billing_last_name', true );
205
  if( isset( $user_last_name_temp ) && "" == $user_last_name_temp ) {
@@ -212,46 +219,46 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
212
  } else {
213
  $user_last_name = $user_last_name_temp;
214
  }
215
- $email_body = str_replace( "{{customer.lastname}}", $user_last_name, $email_body );
216
  $email_body = str_replace( "{{customer.fullname}}", $user_first_name." ".$user_last_name, $email_body );
217
- }
218
- $order_date = "";
219
  if( $cart_update_time != "" && $cart_update_time != 0 ) {
220
  $date_format = date_i18n( get_option( 'date_format' ), $cart_update_time );
221
  $time_format = date_i18n( get_option( 'time_format' ), $cart_update_time );
222
  $order_date = $date_format . ' ' . $time_format;
223
- }
224
- $email_body = str_replace( "{{cart.abandoned_date}}", $order_date, $email_body );
225
  $query_sent = "INSERT INTO `".$wpdb->prefix."ac_sent_history_lite` ( template_id, abandoned_order_id, sent_time, sent_email_id )
226
  VALUES ( %s, %s, '".current_time( 'mysql' )."', %s )";
227
-
228
  $wpdb->query( $wpdb->prepare( $query_sent, $template_id, $value->id, $value->user_email ) );
229
-
230
- $query_id = "SELECT * FROM `".$wpdb->prefix."ac_sent_history_lite`
231
  WHERE template_id = %s AND abandoned_order_id = %s
232
  ORDER BY id DESC
233
- LIMIT 1 ";
234
- $results_sent = $wpdb->get_results( $wpdb->prepare( $query_id, $template_id, $value->id ) );
235
- if ( count( $results_sent ) > 0 ) {
236
  $email_sent_id = $results_sent[0]->id;
237
  } else {
238
  $email_sent_id = '';
239
  }
240
 
241
  if ( '' != $email_sent_id ) {
242
-
243
  if( $woocommerce->version < '2.3' ) {
244
  $cart_page_link = $woocommerce->cart->get_cart_url();
245
  } else {
246
  $cart_page_id = wc_get_page_id( 'cart' );
247
  $cart_page_link = $cart_page_id ? get_permalink( $cart_page_id ) : '';
248
  }
249
-
250
  $encoding_cart = $email_sent_id.'&url='.$cart_page_link;
251
  $validate_cart = $this->wcal_encrypt_validate( $encoding_cart );
252
  $cart_link_track = get_option('siteurl').'/?wcal_action=track_links&validate=' . $validate_cart;
253
  $email_body = str_replace( "{{cart.link}}", $cart_link_track, $email_body );
254
-
255
  $validate_unsubscribe = $this->wcal_encrypt_validate( $email_sent_id );
256
  if ( count( $results_sent ) > 0 && isset( $results_sent[0]->sent_email_id ) ) {
257
  $email_sent_id_address = $results_sent[0]->sent_email_id;
@@ -282,7 +289,7 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
282
  <th>'.__( "Price", 'woocommerce-abandoned-cart' ).'</th>
283
  <th>'.__( "Line Subtotal", 'woocommerce-abandoned-cart' ).'</th>
284
  </tr>';
285
- }
286
  $cart_details = $cart_info_db_field->cart;
287
  $cart_total = $item_subtotal = $item_total = 0;
288
  $sub_line_prod_name = '';
@@ -296,11 +303,11 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
296
  $sub_line_prod_name = $product_name;
297
  }
298
  // Item subtotal is calculated as product total including taxes
299
- if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
300
- $item_subtotal = $item_subtotal + $v->line_total + $v->line_subtotal_tax;
301
  } else {
302
  $item_subtotal = $item_subtotal + $v->line_total;
303
- }
304
  // Line total
305
  $item_total = $item_subtotal;
306
  $item_subtotal = $item_subtotal / $quantity_total;
@@ -308,13 +315,13 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
308
  $item_subtotal = wc_price( $item_subtotal );
309
  $product = wc_get_product( $product_id );
310
  $prod_image = $product->get_image();
311
- $image_url = wp_get_attachment_url( get_post_thumbnail_id( $product_id ) );
312
  if ( isset( $v->variation_id ) && '' != $v->variation_id ) {
313
  $variation_id = $v->variation_id;
314
  $variation = wc_get_product( $variation_id );
315
  $name = $variation->get_formatted_name() ;
316
  $explode_all = explode ( "&ndash;", $name );
317
- if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
318
  $wcap_sku = '';
319
  if ( $variation->get_sku() ) {
320
  $wcap_sku = "SKU: " . $variation->get_sku() . "<br>";
@@ -322,8 +329,8 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
322
  $wcap_get_formatted_variation = wc_get_formatted_variation( $variation, true );
323
 
324
  $add_product_name = $product_name . ' - ' . $wcap_sku . $wcap_get_formatted_variation;
325
-
326
- $pro_name_variation = (array) $add_product_name;
327
  }else{
328
  $pro_name_variation = array_slice( $explode_all, 1, -1 );
329
  }
@@ -364,40 +371,40 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
364
  $email_body = str_replace( "{{products.cart}}", $var, $email_body );
365
  $email_subject = str_replace( "{{product.name}}", __( $sub_line_prod_name, 'woocommerce-abandoned-cart' ), $email_subject );
366
  }
367
-
368
  $user_email = $value->user_email;
369
  $email_body_final = stripslashes( $email_body );
370
  $email_body_final = convert_smilies( $email_body_final );
371
  if ( isset( $is_wc_template ) && "1" == $is_wc_template ){
372
  ob_start();
373
-
374
  wc_get_template( 'emails/email-header.php', array( 'email_heading' => $wc_template_header ) );
375
  $email_body_template_header = ob_get_clean();
376
-
377
  ob_start();
378
-
379
- wc_get_template( 'emails/email-footer.php' );
380
  $email_body_template_footer = ob_get_clean();
381
 
382
- $site_title = get_bloginfo( 'name' );
383
  $email_body_template_footer = str_replace( '{site_title}', $site_title, $email_body_template_footer );
384
-
385
  $final_email_body = $email_body_template_header . $email_body_final . $email_body_template_footer;
386
-
387
  wc_mail( $user_email, $email_subject, $final_email_body, $headers );
388
-
389
  } else {
390
  wp_mail( $user_email, $email_subject, __( $email_body_final, 'woocommerce-abandoned-cart' ), $headers );
391
  }
392
  }
393
- }
394
  }
395
  }
396
  }
397
  }
398
  }
399
  }
400
- }
401
  }
402
 
403
  /**
@@ -437,7 +444,7 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
437
  }
438
  }
439
  return false;
440
- }
441
  /**
442
  * Get all carts which have the creation time earlier than the one that is passed.
443
  * @param string | timestamp $template_to_send_after_time Template time
@@ -446,21 +453,21 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
446
  * @return array | object $results
447
  * @since 1.3
448
  */
449
- function wcal_get_carts( $template_to_send_after_time, $cart_abandon_cut_off_time ) {
450
- global $wpdb;
451
- $cart_time = current_time( 'timestamp' ) - $template_to_send_after_time - $cart_abandon_cut_off_time;
452
  $cart_ignored = 0;
453
  $unsubscribe = 0;
454
  $query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac
455
  LEFT JOIN ".$wpdb->base_prefix."users AS wpu ON wpac.user_id = wpu.id
456
  WHERE cart_ignored = %s AND unsubscribe_link = %s AND abandoned_cart_time < $cart_time
457
  ORDER BY `id` ASC ";
458
-
459
- $results = $wpdb->get_results( $wpdb->prepare( $query, $cart_ignored, $unsubscribe ) );
460
- return $results;
461
  exit;
462
  }
463
-
464
  /**
465
  * It will update the abandoned cart staus if the order has been placed before sending the reminder emails.
466
  * @param string | timestamp $time_to_send_template_after Template time
@@ -471,7 +478,7 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
471
  * @param string $wcal_user_email User Email
472
  * @globals mixed $wpdb
473
  * @return boolean true | false
474
- * @since 4.3
475
  */
476
  public static function wcal_update_abandoned_cart_status_for_placed_orders( $time_to_send_template_after, $wcal_cart_time, $wcal_user_id, $wcal_user_type, $wcal_cart_id, $wcal_user_email ){
477
  global $wpdb;
@@ -489,7 +496,7 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
489
  }
490
  return false;
491
  }
492
-
493
  /**
494
  * It will update the Guest users abandoned cart staus if the order has been placed before sending the reminder emails.
495
  * @param string | int $cart_id Abandoned cart id
@@ -498,7 +505,7 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
498
  * @param string $wcal_user_email_address User Email
499
  * @globals mixed $wpdb
500
  * @return int 0 | 1
501
- * @since 4.3
502
  */
503
  public static function wcal_update_status_of_guest ( $cart_id, $abandoned_cart_time , $time_to_send_template_after, $wcal_user_email_address ) {
504
  global $wpdb;
@@ -520,7 +527,7 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
520
  if ( $order_date == $todays_date ) {
521
 
522
  /**
523
- * in some case the cart is recovered but it is not marked as the recovered. So here we check if any
524
  * record is found for that cart id if yes then update the record respectively.
525
  */
526
  $wcal_check_email_sent_to_cart = woocommerce_abandon_cart_cron::wcal_get_cart_sent_data ( $cart_id );
@@ -557,14 +564,14 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
557
  } else if( "wc-pending" == $results_query_email[0]->post_status || "wc-failed" == $results_query_email[0]->post_status ) {
558
 
559
  /**
560
- * If the post status are pending or failed the send them for abandoned cart reminder emails.
561
- */
562
  return 0;
563
  }
564
  }
565
  return 0;
566
  }
567
-
568
  /**
569
  * It will update the Loggedin users abandoned cart staus if the order has been placed before sending the reminder emails.
570
  * @param string | int $cart_id Abandoned cart id
@@ -573,7 +580,7 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
573
  * @param string $user_billing_email User Email
574
  * @globals mixed $wpdb
575
  * @return int 0 | 1
576
- * @since 4.3
577
  */
578
  public static function wcal_update_status_of_loggedin( $cart_id, $abandoned_cart_time , $time_to_send_template_after, $user_billing_email ) {
579
  global $wpdb;
@@ -653,56 +660,56 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
653
  * the time and further email will sent from first email sent time. So all template will not sent at the same time.
654
  * @param string | int $wcal_cart_id Abandoned cart id
655
  * @param string | timestamp $time_to_send_template_after Template time
656
- * @param string | int $template_id Template id
657
  * @return boolean true | false
658
  * @globals mixed $wpdb
659
  * @since 3.1
660
  */
661
  public static function wcal_remove_cart_for_mutiple_templates( $wcal_cart_id, $time_to_send_template_after, $template_id ) {
662
  global $wpdb;
663
-
664
  $wcal_get_last_email_sent_time = "SELECT * FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE abandoned_order_id = $wcal_cart_id ORDER BY `sent_time` DESC LIMIT 1";
665
  $wcal_get_last_email_sent_time_results_list = $wpdb->get_results( $wcal_get_last_email_sent_time );
666
 
667
  if( count( $wcal_get_last_email_sent_time_results_list ) > 0 ) {
668
  $last_template_send_time = strtotime( $wcal_get_last_email_sent_time_results_list[0]->sent_time );
669
  $second_template_send_time = $last_template_send_time + $time_to_send_template_after ;
670
- $current_time_test = current_time( 'timestamp' );
671
  if( $second_template_send_time > $current_time_test ) {
672
  return true;
673
  }
674
  }
675
-
676
  return false;
677
  }
678
  /**
679
  * This function is used to encode the validate string.
680
- * @param string $validate
681
  * @return encoded data $validate_encoded
682
  * @since 1.3
683
  */
684
- function wcal_encrypt_validate( $validate ) {
685
- $cryptKey = get_option( 'wcal_security_key' );
686
  $validate_encoded = Wcal_Aes_Ctr::encrypt( $validate, $cryptKey, 256 );
687
  return( $validate_encoded );
688
  }
689
-
690
  /**
691
  * It will check if the reminder email has been sent to the abandoned cart.
692
  * @param string | int $user_id User id
693
  * @param string | timestamp $cart_update_time Abandoned cart time
694
  * @param string | int $template_id Template id
695
  * @param string | int $id Abandoned cart id
696
- * @globals mixed $wpdb
697
  * @return boolean true | false
698
- * @since 1.3
699
  */
700
- function wcal_check_sent_history( $user_id, $cart_update_time, $template_id, $id ) {
701
- global $wpdb;
702
  $query = "SELECT wpcs . * , wpac . abandoned_cart_time , wpac . user_id FROM `".$wpdb->prefix."ac_sent_history_lite` AS wpcs
703
  LEFT JOIN ".$wpdb->prefix."ac_abandoned_cart_history_lite AS wpac ON wpcs.abandoned_order_id = wpac.id
704
  WHERE template_id = %s AND wpcs.abandoned_order_id = %d ORDER BY 'id' DESC LIMIT 1 ";
705
-
706
  $results = $wpdb->get_results( $wpdb->prepare( $query, $template_id, $id ) );
707
  if ( count( $results ) == 0 ) {
708
  return true;
@@ -710,11 +717,9 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
710
  return true;
711
  } else {
712
  return false;
713
- }
714
- }
715
- }
716
- }
717
  $woocommerce_abandon_cart_cron = new woocommerce_abandon_cart_cron();
718
- $woocommerce_abandon_cart_cron->wcal_send_email_notification();
719
-
720
  ?>
1
+ <?php
2
  /**
3
  * It will send the automatic reminder emails to the customers.
4
  *
19
  break;
20
  }
21
  }
22
+ /*
23
+ * In case wp-content folder is seperated from WP core folders (like Bedrock setup from Roots.io) the above while loop will not find wp-load correctly, so we must use ABSPATH
24
+ */
25
+ if ( ! file_exists( $wp_load ) ) {
26
+ $wp_load = trailingslashit( ABSPATH ) . 'wp-load.php';
27
+ }
28
  }
29
  $wcal_root = dirname( dirname(__FILE__) ); // go two level up for directory from this file.
30
  require_once $wp_load;
38
  * It will send the automatic reminder emails to the customers
39
  * @since 1.3
40
  */
41
+ class woocommerce_abandon_cart_cron {
42
  var $cart_settings_cron;
43
+ var $cart_abandon_cut_off_time_cron;
44
+ public function __construct() {
45
+ $this->cart_settings_cron = get_option( 'ac_lite_cart_abandoned_time' );
46
+ $this->cart_abandon_cut_off_time_cron = ( $this->cart_settings_cron ) * 60;
47
  }
48
  /**
49
  * It will send the reminder emails to the cutomers.
53
  * @globals mixed $woocommerce
54
  * @since 1.3
55
  */
56
+ function wcal_send_email_notification() {
57
+ global $wpdb, $woocommerce;
58
  //Grab the cart abandoned cut-off time from database.
59
+ $cart_settings = get_option( 'ac_lite_cart_abandoned_time' );
60
+ $cart_abandon_cut_off_time = $cart_settings * 60;
61
  //Fetch all active templates present in the system
62
  $query = "SELECT wpet . * FROM `".$wpdb->prefix."ac_email_templates_lite` AS wpet
63
  WHERE wpet.is_active = '1' ORDER BY `day_or_hour` DESC, `frequency` ASC ";
64
+ $results = $wpdb->get_results( $query );
65
  $hour_seconds = 3600; // 60 * 60
66
  $day_seconds = 86400; // 24 * 60 * 60
67
  foreach ( $results as $key => $value ) {
69
  $time_to_send_template_after = $value->frequency * $day_seconds;
70
  } elseif ( $value->day_or_hour == 'Hours' ) {
71
  $time_to_send_template_after = $value->frequency * $hour_seconds;
72
+ }
73
+
74
  $carts = $this->wcal_get_carts( $time_to_send_template_after, $cart_abandon_cut_off_time );
75
  $email_frequency = $value->frequency;
76
+ $email_body_template = $value->body;
77
  $email_subject = stripslashes ( $value->subject );
78
  $email_subject = convert_smilies ( $email_subject );
79
  $wcal_from_name = get_option ( 'wcal_from_name' );
92
  $is_wc_template = $value->is_wc_template;
93
  $wc_template_header_text = $value->wc_email_header != '' ? $value->wc_email_header : __( 'Abandoned cart reminder', 'woocommerce-abandoned-cart');
94
  $wc_template_header = stripslashes( $wc_template_header_text );
95
+ if ( '' != $email_body_template ) {
96
  foreach ( $carts as $key => $value ) {
97
 
98
  $wcal_is_guest_id_correct = $this->wcal_get_is_guest_valid ( $value->user_id, $value->user_type ) ;
100
 
101
  if ( $value->user_type == "GUEST" && $value->user_id != '0' ) {
102
  $value->user_login = "";
103
+ $query_guest = "SELECT billing_first_name, billing_last_name, email_id FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite`
104
  WHERE id = %d";
105
  $results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $value->user_id ) );
106
  if ( count( $results_guest ) > 0 && isset( $results_guest[0]->email_id ) ) {
112
  }
113
  $key = 'billing_email';
114
  $single = true;
115
+ $user_biiling_email = get_user_meta( $user_id, $key, $single );
116
  if ( isset( $user_biiling_email ) && $user_biiling_email != '' ) {
117
  $value->user_email = $user_biiling_email;
118
  }
126
  }
127
  if( count( get_object_vars( $cart ) ) > 0 && isset( $value->user_id ) && '0' != $value->user_id && isset( $value->id ) ) {
128
  $cart_update_time = $value->abandoned_cart_time;
129
+ $new_user = $this->wcal_check_sent_history( $value->user_id, $cart_update_time, $template_id, $value->id );
130
  if ( $new_user == true ) {
131
 
132
  /**
133
+ * When there are 3 templates and for cart id 1 all template time has been reached. BUt all templates
134
  * are deactivated.
135
  * If we activate all 3 template then at a 1 time all 3 email templates send to the users.
136
+ * So below function check that after first email is sent time and then from that time it will send the
137
  * 2nd template time. ( It will not consider the cart abadoned time in this case. )
138
  */
139
 
140
  $wcal_check_cart_needed_for_multiple_template = $this->wcal_remove_cart_for_mutiple_templates( $value->id, $time_to_send_template_after, $template_id );
141
 
142
  /**
143
+ * When we click on the place order button, we check if the order is placed after the
144
+ * cut off time. And if yes then if the status of the order is pending or falied then
145
+ * we keep it as the abandonoed and we need to send reminder emails. So in below function
146
+ * we first check if any order is placed with todays date then we do not send the
147
+ * reminder email. But what if placed order status is pending or falied? So this
148
+ * condition will not call that function andthe reminder email will be sent.
149
  */
150
 
151
  $wcal_check_if_cart_is_present_in_post_meta = "SELECT wpm.post_id, wpost.post_date, wpost.post_status FROM `" . $wpdb->prefix . "postmeta` AS wpm
152
+ LEFT JOIN `" . $wpdb->prefix . "posts` AS wpost
153
  ON wpm.post_id = wpost.ID
154
+ WHERE wpm.meta_key = 'wcap_recover_order_placed' AND
155
+ wpm.meta_value = %s AND wpm.post_id = wpost.ID AND
156
+ wpost.post_type = 'shop_order'
157
  ORDER BY wpm.post_id DESC LIMIT 1";
158
 
159
  $results_wcal_check_if_cart_is_present_in_post_meta = $wpdb->get_results( $wpdb->prepare( $wcal_check_if_cart_is_present_in_post_meta, $value->id ) );
160
 
161
  $wcap_check_cart_staus_need_to_update = false;
162
 
163
+ if ( empty ($results_wcal_check_if_cart_is_present_in_post_meta) ||
164
+ ( isset( $results_wcal_check_if_cart_is_present_in_post_meta[0] ) &&
165
+ $results_wcal_check_if_cart_is_present_in_post_meta[0]->post_status != "wc-failed" &&
166
  $results_wcal_check_if_cart_is_present_in_post_meta [0]->post_status != "wc-pending" ) ){
167
 
168
  $wcap_check_cart_staus_need_to_update = woocommerce_abandon_cart_cron::wcal_update_abandoned_cart_status_for_placed_orders ( $time_to_send_template_after, $cart_update_time, $value->user_id, $value->user_type, $value->id, $value->user_email );
172
  false == $wcap_check_cart_staus_need_to_update ) {
173
 
174
  $cart_info_db = $value->abandoned_cart_info;
175
+ $email_body = $email_body_template;
176
  $wcal_check_cart_total = $this->wcal_check_cart_total( $cart );
177
  if( true == $wcal_check_cart_total ) {
178
  if ( $value->user_type == "GUEST" ) {
179
  if ( isset( $results_guest[0]->billing_first_name ) ) {
180
  $email_body = str_replace( "{{customer.firstname}}", $results_guest[0]->billing_first_name, $email_body );
181
  $email_subject = str_replace( "{{customer.firstname}}", $results_guest[0]->billing_first_name, $email_subject );
182
+ }
183
  if ( isset( $results_guest[0]->billing_last_name ) ) {
184
  $email_body = str_replace( "{{customer.lastname}}", $results_guest[0]->billing_last_name, $email_body );
185
+ }
186
  if ( isset( $results_guest[0]->billing_first_name ) && isset( $results_guest[0]->billing_last_name ) ) {
187
  $email_body = str_replace( "{{customer.fullname}}", $results_guest[0]->billing_first_name." ".$results_guest[0]->billing_last_name, $email_body );
188
  }
193
  $email_body = str_replace( "{{customer.fullname}}", $results_guest[0]->billing_last_name, $email_body );
194
  }
195
  } else {
196
+ $user_first_name = '';
197
  $user_first_name_temp = get_user_meta( $value->user_id, 'billing_first_name', true );
198
  if( isset( $user_first_name_temp ) && "" == $user_first_name_temp ) {
199
  $user_data = get_userdata( $user_id );
204
  }
205
  } else {
206
  $user_first_name = $user_first_name_temp;
207
+ }
208
+ $email_body = str_replace( "{{customer.firstname}}", $user_first_name, $email_body );
209
+ $email_subject = str_replace( "{{customer.firstname}}", $user_first_name, $email_subject );
210
  $user_last_name = '';
211
  $user_last_name_temp = get_user_meta( $value->user_id, 'billing_last_name', true );
212
  if( isset( $user_last_name_temp ) && "" == $user_last_name_temp ) {
219
  } else {
220
  $user_last_name = $user_last_name_temp;
221
  }
222
+ $email_body = str_replace( "{{customer.lastname}}", $user_last_name, $email_body );
223
  $email_body = str_replace( "{{customer.fullname}}", $user_first_name." ".$user_last_name, $email_body );
224
+ }
225
+ $order_date = "";
226
  if( $cart_update_time != "" && $cart_update_time != 0 ) {
227
  $date_format = date_i18n( get_option( 'date_format' ), $cart_update_time );
228
  $time_format = date_i18n( get_option( 'time_format' ), $cart_update_time );
229
  $order_date = $date_format . ' ' . $time_format;
230
+ }
231
+ $email_body = str_replace( "{{cart.abandoned_date}}", $order_date, $email_body );
232
  $query_sent = "INSERT INTO `".$wpdb->prefix."ac_sent_history_lite` ( template_id, abandoned_order_id, sent_time, sent_email_id )
233
  VALUES ( %s, %s, '".current_time( 'mysql' )."', %s )";
234
+
235
  $wpdb->query( $wpdb->prepare( $query_sent, $template_id, $value->id, $value->user_email ) );
236
+
237
+ $query_id = "SELECT * FROM `".$wpdb->prefix."ac_sent_history_lite`
238
  WHERE template_id = %s AND abandoned_order_id = %s
239
  ORDER BY id DESC
240
+ LIMIT 1 ";
241
+ $results_sent = $wpdb->get_results( $wpdb->prepare( $query_id, $template_id, $value->id ) );
242
+ if ( count( $results_sent ) > 0 ) {
243
  $email_sent_id = $results_sent[0]->id;
244
  } else {
245
  $email_sent_id = '';
246
  }
247
 
248
  if ( '' != $email_sent_id ) {
249
+
250
  if( $woocommerce->version < '2.3' ) {
251
  $cart_page_link = $woocommerce->cart->get_cart_url();
252
  } else {
253
  $cart_page_id = wc_get_page_id( 'cart' );
254
  $cart_page_link = $cart_page_id ? get_permalink( $cart_page_id ) : '';
255
  }
256
+
257
  $encoding_cart = $email_sent_id.'&url='.$cart_page_link;
258
  $validate_cart = $this->wcal_encrypt_validate( $encoding_cart );
259
  $cart_link_track = get_option('siteurl').'/?wcal_action=track_links&validate=' . $validate_cart;
260
  $email_body = str_replace( "{{cart.link}}", $cart_link_track, $email_body );
261
+
262
  $validate_unsubscribe = $this->wcal_encrypt_validate( $email_sent_id );
263
  if ( count( $results_sent ) > 0 && isset( $results_sent[0]->sent_email_id ) ) {
264
  $email_sent_id_address = $results_sent[0]->sent_email_id;
289
  <th>'.__( "Price", 'woocommerce-abandoned-cart' ).'</th>
290
  <th>'.__( "Line Subtotal", 'woocommerce-abandoned-cart' ).'</th>
291
  </tr>';
292
+ }
293
  $cart_details = $cart_info_db_field->cart;
294
  $cart_total = $item_subtotal = $item_total = 0;
295
  $sub_line_prod_name = '';
303
  $sub_line_prod_name = $product_name;
304
  }
305
  // Item subtotal is calculated as product total including taxes
306
+ if( $v->line_tax != 0 && $v->line_tax > 0 ) {
307
+ $item_subtotal = $item_subtotal + $v->line_total + $v->line_tax;
308
  } else {
309
  $item_subtotal = $item_subtotal + $v->line_total;
310
+ }
311
  // Line total
312
  $item_total = $item_subtotal;
313
  $item_subtotal = $item_subtotal / $quantity_total;
315
  $item_subtotal = wc_price( $item_subtotal );
316
  $product = wc_get_product( $product_id );
317
  $prod_image = $product->get_image();
318
+ $image_url = wp_get_attachment_url( get_post_thumbnail_id( $product_id ) );
319
  if ( isset( $v->variation_id ) && '' != $v->variation_id ) {
320
  $variation_id = $v->variation_id;
321
  $variation = wc_get_product( $variation_id );
322
  $name = $variation->get_formatted_name() ;
323
  $explode_all = explode ( "&ndash;", $name );
324
+ if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
325
  $wcap_sku = '';
326
  if ( $variation->get_sku() ) {
327
  $wcap_sku = "SKU: " . $variation->get_sku() . "<br>";
329
  $wcap_get_formatted_variation = wc_get_formatted_variation( $variation, true );
330
 
331
  $add_product_name = $product_name . ' - ' . $wcap_sku . $wcap_get_formatted_variation;
332
+
333
+ $pro_name_variation = (array) $add_product_name;
334
  }else{
335
  $pro_name_variation = array_slice( $explode_all, 1, -1 );
336
  }
371
  $email_body = str_replace( "{{products.cart}}", $var, $email_body );
372
  $email_subject = str_replace( "{{product.name}}", __( $sub_line_prod_name, 'woocommerce-abandoned-cart' ), $email_subject );
373
  }
374
+
375
  $user_email = $value->user_email;
376
  $email_body_final = stripslashes( $email_body );
377
  $email_body_final = convert_smilies( $email_body_final );
378
  if ( isset( $is_wc_template ) && "1" == $is_wc_template ){
379
  ob_start();
380
+
381
  wc_get_template( 'emails/email-header.php', array( 'email_heading' => $wc_template_header ) );
382
  $email_body_template_header = ob_get_clean();
383
+
384
  ob_start();
385
+
386
+ wc_get_template( 'emails/email-footer.php' );
387
  $email_body_template_footer = ob_get_clean();
388
 
389
+ $site_title = get_bloginfo( 'name' );
390
  $email_body_template_footer = str_replace( '{site_title}', $site_title, $email_body_template_footer );
391
+
392
  $final_email_body = $email_body_template_header . $email_body_final . $email_body_template_footer;
393
+
394
  wc_mail( $user_email, $email_subject, $final_email_body, $headers );
395
+
396
  } else {
397
  wp_mail( $user_email, $email_subject, __( $email_body_final, 'woocommerce-abandoned-cart' ), $headers );
398
  }
399
  }
400
+ }
401
  }
402
  }
403
  }
404
  }
405
  }
406
  }
407
+ }
408
  }
409
 
410
  /**
444
  }
445
  }
446
  return false;
447
+ }
448
  /**
449
  * Get all carts which have the creation time earlier than the one that is passed.
450
  * @param string | timestamp $template_to_send_after_time Template time
453
  * @return array | object $results
454
  * @since 1.3
455
  */
456
+ function wcal_get_carts( $template_to_send_after_time, $cart_abandon_cut_off_time ) {
457
+ global $wpdb;
458
+ $cart_time = current_time( 'timestamp' ) - $template_to_send_after_time - $cart_abandon_cut_off_time;
459
  $cart_ignored = 0;
460
  $unsubscribe = 0;
461
  $query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac
462
  LEFT JOIN ".$wpdb->base_prefix."users AS wpu ON wpac.user_id = wpu.id
463
  WHERE cart_ignored = %s AND unsubscribe_link = %s AND abandoned_cart_time < $cart_time
464
  ORDER BY `id` ASC ";
465
+
466
+ $results = $wpdb->get_results( $wpdb->prepare( $query, $cart_ignored, $unsubscribe ) );
467
+ return $results;
468
  exit;
469
  }
470
+
471
  /**
472
  * It will update the abandoned cart staus if the order has been placed before sending the reminder emails.
473
  * @param string | timestamp $time_to_send_template_after Template time
478
  * @param string $wcal_user_email User Email
479
  * @globals mixed $wpdb
480
  * @return boolean true | false
481
+ * @since 4.3
482
  */
483
  public static function wcal_update_abandoned_cart_status_for_placed_orders( $time_to_send_template_after, $wcal_cart_time, $wcal_user_id, $wcal_user_type, $wcal_cart_id, $wcal_user_email ){
484
  global $wpdb;
496
  }
497
  return false;
498
  }
499
+
500
  /**
501
  * It will update the Guest users abandoned cart staus if the order has been placed before sending the reminder emails.
502
  * @param string | int $cart_id Abandoned cart id
505
  * @param string $wcal_user_email_address User Email
506
  * @globals mixed $wpdb
507
  * @return int 0 | 1
508
+ * @since 4.3
509
  */
510
  public static function wcal_update_status_of_guest ( $cart_id, $abandoned_cart_time , $time_to_send_template_after, $wcal_user_email_address ) {
511
  global $wpdb;
527
  if ( $order_date == $todays_date ) {
528
 
529
  /**
530
+ * in some case the cart is recovered but it is not marked as the recovered. So here we check if any
531
  * record is found for that cart id if yes then update the record respectively.
532
  */
533
  $wcal_check_email_sent_to_cart = woocommerce_abandon_cart_cron::wcal_get_cart_sent_data ( $cart_id );
564
  } else if( "wc-pending" == $results_query_email[0]->post_status || "wc-failed" == $results_query_email[0]->post_status ) {
565
 
566
  /**
567
+ * If the post status are pending or failed the send them for abandoned cart reminder emails.
568
+ */
569
  return 0;
570
  }
571
  }
572
  return 0;
573
  }
574
+
575
  /**
576
  * It will update the Loggedin users abandoned cart staus if the order has been placed before sending the reminder emails.
577
  * @param string | int $cart_id Abandoned cart id
580
  * @param string $user_billing_email User Email
581
  * @globals mixed $wpdb
582
  * @return int 0 | 1
583
+ * @since 4.3
584
  */
585
  public static function wcal_update_status_of_loggedin( $cart_id, $abandoned_cart_time , $time_to_send_template_after, $user_billing_email ) {
586
  global $wpdb;
660
  * the time and further email will sent from first email sent time. So all template will not sent at the same time.
661
  * @param string | int $wcal_cart_id Abandoned cart id
662
  * @param string | timestamp $time_to_send_template_after Template time
663
+ * @param string | int $template_id Template id
664
  * @return boolean true | false
665
  * @globals mixed $wpdb
666
  * @since 3.1
667
  */
668
  public static function wcal_remove_cart_for_mutiple_templates( $wcal_cart_id, $time_to_send_template_after, $template_id ) {
669
  global $wpdb;
670
+
671
  $wcal_get_last_email_sent_time = "SELECT * FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE abandoned_order_id = $wcal_cart_id ORDER BY `sent_time` DESC LIMIT 1";
672
  $wcal_get_last_email_sent_time_results_list = $wpdb->get_results( $wcal_get_last_email_sent_time );
673
 
674
  if( count( $wcal_get_last_email_sent_time_results_list ) > 0 ) {
675
  $last_template_send_time = strtotime( $wcal_get_last_email_sent_time_results_list[0]->sent_time );
676
  $second_template_send_time = $last_template_send_time + $time_to_send_template_after ;
677
+ $current_time_test = current_time( 'timestamp' );
678
  if( $second_template_send_time > $current_time_test ) {
679
  return true;
680
  }
681
  }
682
+
683
  return false;
684
  }
685
  /**
686
  * This function is used to encode the validate string.
687
+ * @param string $validate
688
  * @return encoded data $validate_encoded
689
  * @since 1.3
690
  */
691
+ function wcal_encrypt_validate( $validate ) {
692
+ $cryptKey = get_option( 'wcal_security_key' );
693
  $validate_encoded = Wcal_Aes_Ctr::encrypt( $validate, $cryptKey, 256 );
694
  return( $validate_encoded );
695
  }
696
+
697
  /**
698
  * It will check if the reminder email has been sent to the abandoned cart.
699
  * @param string | int $user_id User id
700
  * @param string | timestamp $cart_update_time Abandoned cart time
701
  * @param string | int $template_id Template id
702
  * @param string | int $id Abandoned cart id
703
+ * @globals mixed $wpdb
704
  * @return boolean true | false
705
+ * @since 1.3
706
  */
707
+ function wcal_check_sent_history( $user_id, $cart_update_time, $template_id, $id ) {
708
+ global $wpdb;
709
  $query = "SELECT wpcs . * , wpac . abandoned_cart_time , wpac . user_id FROM `".$wpdb->prefix."ac_sent_history_lite` AS wpcs
710
  LEFT JOIN ".$wpdb->prefix."ac_abandoned_cart_history_lite AS wpac ON wpcs.abandoned_order_id = wpac.id
711
  WHERE template_id = %s AND wpcs.abandoned_order_id = %d ORDER BY 'id' DESC LIMIT 1 ";
712
+
713
  $results = $wpdb->get_results( $wpdb->prepare( $query, $template_id, $id ) );
714
  if ( count( $results ) == 0 ) {
715
  return true;
717
  return true;
718
  } else {
719
  return false;
720
+ }
721
+ }
722
+ }
723
+ }
724
  $woocommerce_abandon_cart_cron = new woocommerce_abandon_cart_cron();
 
 
725
  ?>
{woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart-de_DE.mo RENAMED
File without changes
{woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart-he_IL.mo RENAMED
File without changes
{woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart-he_IL.po RENAMED
File without changes
{woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart-hu_HU.mo RENAMED
File without changes
{woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart-hu_HU.po RENAMED
File without changes
{woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart-sk_SK.mo RENAMED
File without changes
{woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart-sk_SK.po RENAMED
File without changes
{woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart.mo RENAMED
File without changes
{woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart.po RENAMED
File without changes
{woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart.pot RENAMED
File without changes
{woocommerce-abandoned-cart/i18n → i18n}/languages/woocommerce-abandoned-cart_DE.po RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/admin/wcal_privacy_erase.php RENAMED
@@ -8,7 +8,7 @@
8
  // Exit if accessed directly
9
  if ( ! defined( 'ABSPATH' ) ) exit;
10
 
11
- if ( !class_exists('Wcal_Personal_Data_Eraser' ) ) {
12
 
13
  /**
14
  * Export Abandoned Carts data in
@@ -39,7 +39,7 @@ if ( !class_exists('Wcal_Personal_Data_Eraser' ) ) {
39
  // Add our eraser and it's callback function
40
  $eraser_list[ 'wcal_carts' ] = array(
41
  'eraser_friendly_name' => __( 'Abandoned & Recovered Carts', 'woocommerce-abandoned-cart' ),
42
- 'callback' => array( 'Wcal_Personal_Data_Eraser', 'wcal_data_eraser' )
43
  );
44
 
45
  $erasers = array_merge( $erasers, $eraser_list );
@@ -86,7 +86,7 @@ if ( !class_exists('Wcal_Personal_Data_Eraser' ) ) {
86
 
87
  $guest_user_ids = $wpdb->get_results( $wpdb->prepare( $guest_query, $email_address ) );
88
 
89
- if( count( $guest_user_ids ) == 0 ) {
90
  return array( 'messages' => array( __( 'No personal data found for any abandoned carts.', 'woocommerce-abandoned-cart' ) ),
91
  'items_removed' => false,
92
  'items_retained' => true,
@@ -98,8 +98,8 @@ if ( !class_exists('Wcal_Personal_Data_Eraser' ) ) {
98
  foreach( $guest_user_ids as $ids ) {
99
  // get the cart data
100
  $cart_query = "SELECT id FROM `" . $wpdb->prefix . 'ac_abandoned_cart_history_lite' . "`
101
- WHERE user_id = %d AND
102
- user_type = 'GUEST'";
103
 
104
  $cart_data = $wpdb->get_results( $wpdb->prepare( $cart_query, $ids->id ) );
105
 
@@ -156,7 +156,7 @@ if ( !class_exists('Wcal_Personal_Data_Eraser' ) ) {
156
 
157
  // list the props we'll be anonymizing for cart history table
158
  $props_to_remove_cart = apply_filters( 'wcal_privacy_remove_cart_personal_data_props', array(
159
- 'session_id' => 'numeric_id',
160
  ),
161
  $abandoned_id
162
  );
@@ -172,8 +172,8 @@ if ( !class_exists('Wcal_Personal_Data_Eraser' ) ) {
172
  if ( ! empty( $props_to_remove_cart ) && is_array( $props_to_remove_cart ) ) {
173
 
174
  // get the data from cart history
175
- $cart_query = "SELECT session_id, user_type, user_id FROM `" . $wpdb->prefix . 'ac_abandoned_cart_history_lite' . "`
176
- WHERE id = %d";
177
  $cart_details = $wpdb->get_results( $wpdb->prepare( $cart_query, $abandoned_id ) );
178
 
179
  if( count( $cart_details ) > 0 ) {
@@ -182,7 +182,7 @@ if ( !class_exists('Wcal_Personal_Data_Eraser' ) ) {
182
  return;
183
  }
184
 
185
- $user_id = $cart_details->user_id;
186
  $user_type = $cart_details->user_type;
187
 
188
  foreach ( $props_to_remove_cart as $prop => $data_type ) {
@@ -207,14 +207,14 @@ if ( !class_exists('Wcal_Personal_Data_Eraser' ) ) {
207
  }
208
 
209
  // check whether it's a guest user
210
- if( $user_type == 'GUEST' && ! empty( $props_to_remove_guest ) && is_array( $props_to_remove_guest ) ) {
211
 
212
  // get the data from guest cart history
213
- $guest_query = "SELECT billing_first_name, billing_last_name, phone, email_id FROM `" . $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite' . "`
214
- WHERE id = %d";
215
  $guest_details = $wpdb->get_results( $wpdb->prepare( $guest_query, $user_id ) );
216
 
217
- if( count( $guest_details ) > 0 ) {
218
  $guest_details = $guest_details[0];
219
  } else {
220
  return;
8
  // Exit if accessed directly
9
  if ( ! defined( 'ABSPATH' ) ) exit;
10
 
11
+ if ( ! class_exists('Wcal_Personal_Data_Eraser' ) ) {
12
 
13
  /**
14
  * Export Abandoned Carts data in
39
  // Add our eraser and it's callback function
40
  $eraser_list[ 'wcal_carts' ] = array(
41
  'eraser_friendly_name' => __( 'Abandoned & Recovered Carts', 'woocommerce-abandoned-cart' ),
42
+ 'callback' => array( 'Wcal_Personal_Data_Eraser', 'wcal_data_eraser' )
43
  );
44
 
45
  $erasers = array_merge( $erasers, $eraser_list );
86
 
87
  $guest_user_ids = $wpdb->get_results( $wpdb->prepare( $guest_query, $email_address ) );
88
 
89
+ if ( 0 == count( $guest_user_ids ) ) {
90
  return array( 'messages' => array( __( 'No personal data found for any abandoned carts.', 'woocommerce-abandoned-cart' ) ),
91
  'items_removed' => false,
92
  'items_retained' => true,
98
  foreach( $guest_user_ids as $ids ) {
99
  // get the cart data
100
  $cart_query = "SELECT id FROM `" . $wpdb->prefix . 'ac_abandoned_cart_history_lite' . "`
101
+ WHERE user_id = %d AND
102
+ user_type = 'GUEST'";
103
 
104
  $cart_data = $wpdb->get_results( $wpdb->prepare( $cart_query, $ids->id ) );
105
 
156
 
157
  // list the props we'll be anonymizing for cart history table
158
  $props_to_remove_cart = apply_filters( 'wcal_privacy_remove_cart_personal_data_props', array(
159
+ 'session_id' => 'numeric_id',
160
  ),
161
  $abandoned_id
162
  );
172
  if ( ! empty( $props_to_remove_cart ) && is_array( $props_to_remove_cart ) ) {
173
 
174
  // get the data from cart history
175
+ $cart_query = "SELECT session_id, user_type, user_id FROM `" . $wpdb->prefix . 'ac_abandoned_cart_history_lite' . "`
176
+ WHERE id = %d";
177
  $cart_details = $wpdb->get_results( $wpdb->prepare( $cart_query, $abandoned_id ) );
178
 
179
  if( count( $cart_details ) > 0 ) {
182
  return;
183
  }
184
 
185
+ $user_id = $cart_details->user_id;
186
  $user_type = $cart_details->user_type;
187
 
188
  foreach ( $props_to_remove_cart as $prop => $data_type ) {
207
  }
208
 
209
  // check whether it's a guest user
210
+ if( 'GUEST' == $user_type && ! empty( $props_to_remove_guest ) && is_array( $props_to_remove_guest ) ) {
211
 
212
  // get the data from guest cart history
213
+ $guest_query = "SELECT billing_first_name, billing_last_name, phone, email_id FROM `" . $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite' . "`
214
+ WHERE id = %d";
215
  $guest_details = $wpdb->get_results( $wpdb->prepare( $guest_query, $user_id ) );
216
 
217
+ if ( count( $guest_details ) > 0 ) {
218
  $guest_details = $guest_details[0];
219
  } else {
220
  return;
{woocommerce-abandoned-cart/includes → includes}/admin/wcal_privacy_export.php RENAMED
@@ -8,7 +8,7 @@
8
  // Exit if accessed directly
9
  if ( ! defined( 'ABSPATH' ) ) exit;
10
 
11
- if ( !class_exists('Wcal_Personal_Data_Export' ) ) {
12
 
13
  /**
14
  * Export Abandoned Carts data in
@@ -64,21 +64,21 @@ if ( !class_exists('Wcal_Personal_Data_Export' ) ) {
64
 
65
  global $wpdb;
66
 
67
- $done = false;
68
- $page = (int) $page;
69
- $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
70
- $data_to_export = array();
71
  $blank_cart_info = '{"cart":[]}';
72
  $blank_cart_info_guest = '[]';
73
  $blank_cart = '""';
74
 
75
  $user_id = $user ? (int) $user->ID : 0;
76
 
77
- if( $user_id > 0 ) { // registered user
78
 
79
  $cart_query = "SELECT id FROM `" . $wpdb->prefix . 'ac_abandoned_cart_history_lite' . "`
80
- WHERE user_id = %d AND
81
- user_type = 'REGISTERED' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart'";
82
 
83
  $cart_ids = $wpdb->get_results( $wpdb->prepare( $cart_query, $user_id ) );
84
  } else { // guest carts
@@ -87,7 +87,7 @@ if ( !class_exists('Wcal_Personal_Data_Export' ) ) {
87
 
88
  $guest_user_ids = $wpdb->get_results( $wpdb->prepare( $guest_query, $email_address ) );
89
 
90
- if( count( $guest_user_ids ) == 0 )
91
  return array(
92
  'data' => array(),
93
  'done' => true,
@@ -95,11 +95,11 @@ if ( !class_exists('Wcal_Personal_Data_Export' ) ) {
95
 
96
  $cart_ids = array();
97
 
98
- foreach( $guest_user_ids as $ids ) {
99
  // get the cart data
100
  $cart_query = "SELECT id, abandoned_cart_info AS cart_info FROM `" . $wpdb->prefix . 'ac_abandoned_cart_history_lite' . "`
101
- WHERE user_id = %d AND
102
- user_type = 'GUEST'";
103
 
104
  $cart_data = $wpdb->get_results( $wpdb->prepare( $cart_query, $ids->id ) );
105
 
@@ -112,12 +112,12 @@ if ( !class_exists('Wcal_Personal_Data_Export' ) ) {
112
  $cart_chunks = array_chunk( $cart_ids, 10, true );
113
 
114
  $cart_export = isset( $cart_chunks[ $page - 1 ] ) ? $cart_chunks[ $page - 1 ] : array();
115
- if( count( $cart_export ) > 0 ) {
116
 
117
  foreach ( $cart_export as $abandoned_ids ) {
118
 
119
  $cart_id = $abandoned_ids->id;
120
- if( count( $abandoned_ids->id ) > 0 ) {
121
  $data_to_export[] = array(
122
  'group_id' => 'wcal_carts',
123
  'group_label' => __( 'Abandoned Carts', 'woocommerce-abandoned-cart' ),
@@ -150,18 +150,18 @@ if ( !class_exists('Wcal_Personal_Data_Export' ) ) {
150
  * @since 4.9
151
  */
152
  static function get_cart_data( $abandoned_id ) {
153
- $personal_data = array();
154
 
155
  global $wpdb;
156
 
157
- $cart_query = "SELECT * FROM `" . $wpdb->prefix . 'ac_abandoned_cart_history_lite' . "`
158
- WHERE id = %d";
159
  $cart_details = $wpdb->get_results( $wpdb->prepare( $cart_query, $abandoned_id ) );
160
  $cart_details = $cart_details[0];
161
- $user_id = $cart_details->user_id;
162
- $user_type = $cart_details->user_type;
163
 
164
- if( $user_type == 'GUEST' ) {
165
 
166
  $cart_details_to_export = apply_filters( 'wcal_personal_export_cart_details_prop', array(
167
  'cart_id' => __( 'Abandoned Cart ID', 'woocommerce-abandoned-cart' ),
@@ -190,16 +190,16 @@ if ( !class_exists('Wcal_Personal_Data_Export' ) ) {
190
  $cart_data = json_decode( stripslashes( $cart_details->abandoned_cart_info ) );
191
  $cart_info = $cart_data->cart;
192
 
193
- if( count( $cart_info ) > 0 ) {
194
  $cart_details_formatted = self::wcal_get_cart_details_export( $cart_info );
195
  }
196
 
197
- if( $user_type == 'GUEST' ) {
198
  $guest_details = self::wcal_get_guest_personal_info( $user_id );
199
  }
200
- foreach( $cart_details_to_export as $prop => $name ) {
201
 
202
- switch( $prop ) {
203
  case 'cart_id':
204
  $value = $cart_details->id;
205
  break;
@@ -225,8 +225,8 @@ if ( !class_exists('Wcal_Personal_Data_Export' ) ) {
225
  case 'total':
226
  $total = 0;
227
 
228
- if( count( $cart_info ) > 0 ) {
229
- foreach( $cart_info as $k => $v ) {
230
 
231
  $total += $cart_details_formatted[$k][ 'item_total' ];
232
  }
@@ -236,8 +236,8 @@ if ( !class_exists('Wcal_Personal_Data_Export' ) ) {
236
  case 'items':
237
  $value = '';
238
 
239
- if( count( $cart_info ) > 0 ) {
240
- foreach( $cart_info as $k => $v ) {
241
 
242
  $product_name = $cart_details_formatted[$k][ 'product_name' ];
243
  $qty = $cart_details_formatted[$k][ 'qty' ];
@@ -248,21 +248,21 @@ if ( !class_exists('Wcal_Personal_Data_Export' ) ) {
248
  break;
249
  case 'formatted_billing_address':
250
 
251
- if( $user_type == 'REGISTERED' ) { // registered user
252
 
253
  $billing = wcal_common::wcal_get_billing_details( $user_id );
254
  $value = get_user_meta( $user_id, 'billing_first_name', true ); // First Name
255
  $value .= ' ' . get_user_meta( $user_id, 'billing_last_name', true ); // Last Name
256
- if( count( $billing ) > 0 ) {
257
- foreach( $billing as $details ) {
258
- if( $details != '' ) {
259
  $value .= ",$details ";
260
  }
261
  }
262
 
263
  }
264
- } elseif ( $user_type == 'GUEST' ) {
265
- if( count( $guest_details ) > 0 ) {
266
  $value = $guest_details->billing_first_name; // First Name
267
  $value .= ' ' . $guest_details->billing_last_name; // Last Name
268
  }
@@ -270,10 +270,10 @@ if ( !class_exists('Wcal_Personal_Data_Export' ) ) {
270
  break;
271
 
272
  case 'billing_email':
273
- if( $user_type == 'REGISTERED' ) { // registered user
274
  $value = get_user_meta( $user_id, $prop, true );
275
- } else if( $user_type == 'GUEST' ) {
276
- if( count( $guest_details ) > 0 ) {
277
  $value = $guest_details->$prop;
278
  }
279
  }
@@ -286,7 +286,7 @@ if ( !class_exists('Wcal_Personal_Data_Export' ) ) {
286
  $value = apply_filters( 'wcal_personal_export_cart_details_prop_value', $value, $prop, $cart_details );
287
 
288
  $personal_data[] = array(
289
- 'name' => $name,
290
  'value' => $value,
291
  );
292
 
@@ -309,12 +309,12 @@ if ( !class_exists('Wcal_Personal_Data_Export' ) ) {
309
  global $wpdb;
310
  $guest_details = array();
311
 
312
- $guest_query = "SELECT billing_first_name, billing_last_name, email_id AS billing_email, phone AS billing_phone FROM `" . $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite' . "`
313
- WHERE id = %d";
314
 
315
  $guest_details = $wpdb->get_results( $wpdb->prepare( $guest_query, $user_id ) );
316
 
317
- if( is_array( $guest_details ) && count( $guest_details ) > 0 ) {
318
  $guest_details = $guest_details[0];
319
  }
320
 
@@ -333,10 +333,10 @@ if ( !class_exists('Wcal_Personal_Data_Export' ) ) {
333
 
334
  $cart_details = array();
335
 
336
- if( count( $cart_info ) > 0 ) {
337
 
338
  $cart_total = 0;
339
- foreach( $cart_info as $k => $item_detail ) {
340
 
341
  // Qty
342
  $qty = $item_detail->quantity;
@@ -347,9 +347,9 @@ if ( !class_exists('Wcal_Personal_Data_Export' ) ) {
347
  $product_name = $prod_obj->get_name();
348
 
349
  // Variation Name
350
- if( isset( $item_detail->variation_id ) && $item_detail->variation_id > 0 ) {
351
- $variation_id = $item_detail->variation_id;
352
- $variation = wc_get_product( $variation_id );
353
  $variation_name = $variation->get_name();
354
 
355
  $product_name = $variation_name;
@@ -362,9 +362,9 @@ if ( !class_exists('Wcal_Personal_Data_Export' ) ) {
362
  }
363
 
364
  // Populate the array
365
- $cart_details[ $k ][ 'qty' ] = $qty;
366
  $cart_details[ $k ][ 'product_name' ] = $product_name;
367
- $cart_details[ $k ][ 'item_total' ] = $item_total;
368
 
369
  $cart_total += $item_total;
370
  }
8
  // Exit if accessed directly
9
  if ( ! defined( 'ABSPATH' ) ) exit;
10
 
11
+ if ( ! class_exists('Wcal_Personal_Data_Export' ) ) {
12
 
13
  /**
14
  * Export Abandoned Carts data in
64
 
65
  global $wpdb;
66
 
67
+ $done = false;
68
+ $page = (int) $page;
69
+ $user = get_user_by( 'email', $email_address ); // Check if user has an ID in the DB to load stored personal data.
70
+ $data_to_export = array();
71
  $blank_cart_info = '{"cart":[]}';
72
  $blank_cart_info_guest = '[]';
73
  $blank_cart = '""';
74
 
75
  $user_id = $user ? (int) $user->ID : 0;
76
 
77
+ if ( $user_id > 0 ) { // registered user
78
 
79
  $cart_query = "SELECT id FROM `" . $wpdb->prefix . 'ac_abandoned_cart_history_lite' . "`
80
+ WHERE user_id = %d AND
81
+ user_type = 'REGISTERED' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart'";
82
 
83
  $cart_ids = $wpdb->get_results( $wpdb->prepare( $cart_query, $user_id ) );
84
  } else { // guest carts
87
 
88
  $guest_user_ids = $wpdb->get_results( $wpdb->prepare( $guest_query, $email_address ) );
89
 
90
+ if ( 0 == count( $guest_user_ids ) )
91
  return array(
92
  'data' => array(),
93
  'done' => true,
95
 
96
  $cart_ids = array();
97
 
98
+ foreach ( $guest_user_ids as $ids ) {
99
  // get the cart data
100
  $cart_query = "SELECT id, abandoned_cart_info AS cart_info FROM `" . $wpdb->prefix . 'ac_abandoned_cart_history_lite' . "`
101
+ WHERE user_id = %d AND
102
+ user_type = 'GUEST'";
103
 
104
  $cart_data = $wpdb->get_results( $wpdb->prepare( $cart_query, $ids->id ) );
105
 
112
  $cart_chunks = array_chunk( $cart_ids, 10, true );
113
 
114
  $cart_export = isset( $cart_chunks[ $page - 1 ] ) ? $cart_chunks[ $page - 1 ] : array();
115
+ if ( count( $cart_export ) > 0 ) {
116
 
117
  foreach ( $cart_export as $abandoned_ids ) {
118
 
119
  $cart_id = $abandoned_ids->id;
120
+ if ( count( $abandoned_ids->id ) > 0 ) {
121
  $data_to_export[] = array(
122
  'group_id' => 'wcal_carts',
123
  'group_label' => __( 'Abandoned Carts', 'woocommerce-abandoned-cart' ),
150
  * @since 4.9
151
  */
152
  static function get_cart_data( $abandoned_id ) {
153
+ $personal_data = array();
154
 
155
  global $wpdb;
156
 
157
+ $cart_query = "SELECT * FROM `" . $wpdb->prefix . 'ac_abandoned_cart_history_lite' . "`
158
+ WHERE id = %d";
159
  $cart_details = $wpdb->get_results( $wpdb->prepare( $cart_query, $abandoned_id ) );
160
  $cart_details = $cart_details[0];
161
+ $user_id = $cart_details->user_id;
162
+ $user_type = $cart_details->user_type;
163
 
164
+ if ( $user_type == 'GUEST' ) {
165
 
166
  $cart_details_to_export = apply_filters( 'wcal_personal_export_cart_details_prop', array(
167
  'cart_id' => __( 'Abandoned Cart ID', 'woocommerce-abandoned-cart' ),
190
  $cart_data = json_decode( stripslashes( $cart_details->abandoned_cart_info ) );
191
  $cart_info = $cart_data->cart;
192
 
193
+ if ( count( $cart_info ) > 0 ) {
194
  $cart_details_formatted = self::wcal_get_cart_details_export( $cart_info );
195
  }
196
 
197
+ if ( 'GUEST' == $user_type ) {
198
  $guest_details = self::wcal_get_guest_personal_info( $user_id );
199
  }
200
+ foreach ( $cart_details_to_export as $prop => $name ) {
201
 
202
+ switch ( $prop ) {
203
  case 'cart_id':
204
  $value = $cart_details->id;
205
  break;
225
  case 'total':
226
  $total = 0;
227
 
228
+ if ( count( $cart_info ) > 0 ) {
229
+ foreach ( $cart_info as $k => $v ) {
230
 
231
  $total += $cart_details_formatted[$k][ 'item_total' ];
232
  }
236
  case 'items':
237
  $value = '';
238
 
239
+ if ( count( $cart_info ) > 0 ) {
240
+ foreach ( $cart_info as $k => $v ) {
241
 
242
  $product_name = $cart_details_formatted[$k][ 'product_name' ];
243
  $qty = $cart_details_formatted[$k][ 'qty' ];
248
  break;
249
  case 'formatted_billing_address':
250
 
251
+ if ( $user_type == 'REGISTERED' ) { // registered user
252
 
253
  $billing = wcal_common::wcal_get_billing_details( $user_id );
254
  $value = get_user_meta( $user_id, 'billing_first_name', true ); // First Name
255
  $value .= ' ' . get_user_meta( $user_id, 'billing_last_name', true ); // Last Name
256
+ if ( count( $billing ) > 0 ) {
257
+ foreach ( $billing as $details ) {
258
+ if ( '' != $details ) {
259
  $value .= ",$details ";
260
  }
261
  }
262
 
263
  }
264
+ } elseif ( 'GUEST' == $user_type ) {
265
+ if ( count( $guest_details ) > 0 ) {
266
  $value = $guest_details->billing_first_name; // First Name
267
  $value .= ' ' . $guest_details->billing_last_name; // Last Name
268
  }
270
  break;
271
 
272
  case 'billing_email':
273
+ if ( 'REGISTERED' == $user_type ) { // registered user
274
  $value = get_user_meta( $user_id, $prop, true );
275
+ } else if ( 'GUEST' == $user_type ) {
276
+ if ( count( $guest_details ) > 0 ) {
277
  $value = $guest_details->$prop;
278
  }
279
  }
286
  $value = apply_filters( 'wcal_personal_export_cart_details_prop_value', $value, $prop, $cart_details );
287
 
288
  $personal_data[] = array(
289
+ 'name' => $name,
290
  'value' => $value,
291
  );
292
 
309
  global $wpdb;
310
  $guest_details = array();
311
 
312
+ $guest_query = "SELECT billing_first_name, billing_last_name, email_id AS billing_email, phone AS billing_phone FROM `" . $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite' . "`
313
+ WHERE id = %d";
314
 
315
  $guest_details = $wpdb->get_results( $wpdb->prepare( $guest_query, $user_id ) );
316
 
317
+ if ( is_array( $guest_details ) && count( $guest_details ) > 0 ) {
318
  $guest_details = $guest_details[0];
319
  }
320
 
333
 
334
  $cart_details = array();
335
 
336
+ if ( count( $cart_info ) > 0 ) {
337
 
338
  $cart_total = 0;
339
+ foreach ( $cart_info as $k => $item_detail ) {
340
 
341
  // Qty
342
  $qty = $item_detail->quantity;
347
  $product_name = $prod_obj->get_name();
348
 
349
  // Variation Name
350
+ if ( isset( $item_detail->variation_id ) && $item_detail->variation_id > 0 ) {
351
+ $variation_id = $item_detail->variation_id;
352
+ $variation = wc_get_product( $variation_id );
353
  $variation_name = $variation->get_name();
354
 
355
  $product_name = $variation_name;
362
  }
363
 
364
  // Populate the array
365
+ $cart_details[ $k ][ 'qty' ] = $qty;
366
  $cart_details[ $k ][ 'product_name' ] = $product_name;
367
+ $cart_details[ $k ][ 'item_total' ] = $item_total;
368
 
369
  $cart_total += $item_total;
370
  }
includes/background-processes/wcal-async-request.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if( !class_exists( 'WP_Async_Request' ) ) {
3
+ include_once( WP_PLUGIN_DIR . '/woocommerce/includes/libraries/wp-async-request.php' );
4
+ include_once( WP_PLUGIN_DIR . '/woocommerce/includes/libraries/wp-background-process.php' );
5
+ }
6
+ class WCAL_Async_Request extends WP_Async_Request {
7
+
8
+
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ protected $action = 'wcal_single_request';
14
+
15
+ /**
16
+ * Handle
17
+ *
18
+ * Override this method to perform any actions required
19
+ * during the async request.
20
+ */
21
+ protected function handle() {
22
+
23
+ $reminder_method = $_POST[ 'method' ];
24
+
25
+ if( isset( $reminder_method ) ) {
26
+
27
+ switch( $reminder_method ) {
28
+ case 'emails':
29
+ $wcal_cron = new woocommerce_abandon_cart_cron();
30
+ $wcal_cron->wcal_send_email_notification();
31
+ break;
32
+ }
33
+ }
34
+ }
35
+
36
+ }
includes/background-processes/wcal-background-process.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WCAL_Background_Process extends WP_Background_Process {
4
+
5
+
6
+
7
+ /**
8
+ * @var string
9
+ */
10
+ protected $action = 'wcal_all_process';
11
+
12
+ /**
13
+ * Task
14
+ *
15
+ * Override this method to perform any actions required on each
16
+ * queue item. Return the modified item for further processing
17
+ * in the next pass through. Or, return false to remove the
18
+ * item from the queue.
19
+ *
20
+ * @param mixed $item Queue item to iterate over
21
+ *
22
+ * @return mixed
23
+ */
24
+ protected function task( $item ) {
25
+
26
+ if( isset( $item ) ) {
27
+
28
+ switch( $item ) {
29
+ case 'emails':
30
+ $wcal_cron = new woocommerce_abandon_cart_cron();
31
+ $wcal_cron->wcal_send_email_notification();
32
+ break;
33
+ }
34
+
35
+ }
36
+ return false;
37
+
38
+ }
39
+
40
+ /**
41
+ * Complete
42
+ *
43
+ * Override if applicable, but ensure that the below actions are
44
+ * performed, or, call parent::complete().
45
+ */
46
+ protected function complete() {
47
+ parent::complete();
48
+
49
+ // Show notice to user or perform some other arbitrary task...
50
+ }
51
+
52
+ }
includes/background-processes/wcal_process_base.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Wcal_Process_Base {
4
+
5
+ /**
6
+ * @var WCAL_Background_Process
7
+ */
8
+ protected $process;
9
+
10
+ /**
11
+ * @var WCAL_Async_Request
12
+ */
13
+ protected $request;
14
+
15
+
16
+ public function __construct() {
17
+ add_action( 'plugins_loaded', array( $this, 'init' ) );
18
+ // Hook into that action that'll fire every 15 minutes
19
+ add_action( 'woocommerce_ac_send_email_action', array( &$this, 'wcal_process_handler' ), 11 );
20
+
21
+ }
22
+
23
+ public function init() {
24
+
25
+ require_once plugin_dir_path( __FILE__ ) . 'wcal-async-request.php';
26
+ require_once plugin_dir_path( __FILE__ ) . 'wcal-background-process.php';
27
+
28
+ $this->request = new WCAL_Async_Request();
29
+ $this->process = new WCAL_Background_Process();
30
+
31
+ }
32
+
33
+ public function wcal_process_handler() {
34
+ // add any new reminder methods added in the future for cron here
35
+ $reminders_list = array( 'emails' );
36
+
37
+ if( is_array( $reminders_list ) && count( $reminders_list ) > 0 ) {
38
+ $this->start( $reminders_list );
39
+ }
40
+
41
+ }
42
+
43
+ public function start( $reminders_list ) {
44
+
45
+ $this->handle_all( $reminders_list );
46
+
47
+ }
48
+ public function handle_single() {
49
+
50
+ }
51
+
52
+ public function handle_all( $list_reminders ) {
53
+
54
+ foreach( $list_reminders as $reminders ) {
55
+
56
+ $this->process->push_to_queue( $reminders );
57
+ }
58
+ $this->process->save()->dispatch();
59
+ }
60
+
61
+ }
62
+ new Wcal_Process_Base();
63
+ ?>
{woocommerce-abandoned-cart/includes → includes}/classes/class-wcal-abandoned-orders-table.php RENAMED
@@ -336,8 +336,8 @@ class WCAL_Abandoned_Orders_Table extends WP_List_Table {
336
 
337
  if( count( get_object_vars( $cart_details ) ) > 0 ) {
338
  foreach( $cart_details as $k => $v ) {
339
- if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
340
- $line_total = $line_total + $v->line_total + $v->line_subtotal_tax;
341
  } else {
342
  $line_total = $line_total + $v->line_total;
343
  }
@@ -363,8 +363,6 @@ class WCAL_Abandoned_Orders_Table extends WP_List_Table {
363
  $ac_status = __( "Unsubscribed", "woocommerce-abandoned-cart" );
364
  } elseif( $value->cart_ignored == 0 && $value->recovered_cart == 0 ) {
365
  $ac_status = __( "Abandoned", "woocommerce-abandoned-cart" );
366
- } elseif( $value->cart_ignored == 1 && $value->recovered_cart == 0 ) {
367
- $ac_status = __( "Abandoned but new","woocommerce-abandoned-cart" )."</br>". __( "cart created after this", "woocommerce-abandoned-cart" );
368
  } else {
369
  $ac_status = "";
370
  }
336
 
337
  if( count( get_object_vars( $cart_details ) ) > 0 ) {
338
  foreach( $cart_details as $k => $v ) {
339
+ if( $v->line_tax != 0 && $v->line_tax > 0 ) {
340
+ $line_total = $line_total + $v->line_total + $v->line_tax;
341
  } else {
342
  $line_total = $line_total + $v->line_total;
343
  }
363
  $ac_status = __( "Unsubscribed", "woocommerce-abandoned-cart" );
364
  } elseif( $value->cart_ignored == 0 && $value->recovered_cart == 0 ) {
365
  $ac_status = __( "Abandoned", "woocommerce-abandoned-cart" );
 
 
366
  } else {
367
  $ac_status = "";
368
  }
{woocommerce-abandoned-cart/includes → includes}/classes/class-wcal-aes-counter.php RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/classes/class-wcal-aes.php RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/classes/class-wcal-product-report-table.php RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/classes/class-wcal-recover-orders-table.php RENAMED
@@ -230,7 +230,7 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
230
  $ac_results = $wpdb->get_results( $wpdb->prepare( $query_ac, $start_date, $end_date ) );
231
 
232
  $query_ac_carts = "SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history_lite
233
- WHERE abandoned_cart_time >= %d AND abandoned_cart_time <= %d AND abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND abandoned_cart_info NOT LIKE '$blank_cart' ";
234
  $ac_carts_results = $wpdb->get_results( $wpdb->prepare( $query_ac_carts, $start_date, $end_date ) );
235
 
236
  $recovered_item = $recovered_total = $count_carts = $total_value = $order_total = 0;
@@ -246,7 +246,7 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
246
  }
247
  $line_total = 0;
248
 
249
- if ( isset( $product_details ) && count( get_object_vars( $product_details ) ) > 0 && $product_details != false ) {
250
  foreach ( $product_details as $k => $v ) {
251
  if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
252
  $line_total = $line_total + $v->line_total + $v->line_subtotal_tax;
230
  $ac_results = $wpdb->get_results( $wpdb->prepare( $query_ac, $start_date, $end_date ) );
231
 
232
  $query_ac_carts = "SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history_lite
233
+ WHERE abandoned_cart_time >= %d AND abandoned_cart_time <= %d AND abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND abandoned_cart_info NOT LIKE '$blank_cart' AND (cart_ignored <> '1') OR (cart_ignored = '1' AND recovered_cart > 0)";
234
  $ac_carts_results = $wpdb->get_results( $wpdb->prepare( $query_ac_carts, $start_date, $end_date ) );
235
 
236
  $recovered_item = $recovered_total = $count_carts = $total_value = $order_total = 0;
246
  }
247
  $line_total = 0;
248
 
249
+ if ( false != $product_details && is_object( $product_details ) && count( get_object_vars( $product_details ) ) > 0 ) {
250
  foreach ( $product_details as $k => $v ) {
251
  if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
252
  $line_total = $line_total + $v->line_total + $v->line_subtotal_tax;
{woocommerce-abandoned-cart/includes → includes}/classes/class-wcal-templates-table.php RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/README.md RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/WooCommerce-Check/Instructions RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/WooCommerce-Check/ts-woo-active.php RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/deactivate-survey-popup/Instructions RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/deactivate-survey-popup/class-ts-deactivation.php RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/deactivate-survey-popup/template/ts-deactivate-modal.php RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/faq-support/Instructions RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/faq-support/templates/faq-page/faq-page.php RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/faq-support/ts-faq-support.php RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/pro-notices-in-lite/Instructions RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/pro-notices-in-lite/ts-pro-notices.php RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/tracking-data/Instructions RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/tracking-data/assets/images/site-logo-new.jpg RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/tracking-data/assets/js/dismiss-notice.js RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/tracking-data/class-ts-tracker.php RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/tracking-data/ts-tracking.php RENAMED
@@ -185,7 +185,7 @@ class Wcal_TS_tracking {
185
  */
186
  public static function ts_schedule_cron_job () {
187
  if ( ! wp_next_scheduled( self::$plugin_prefix . '_ts_tracker_send_event' ) ) {
188
- wp_schedule_event( time(), 'once_in_week', self::$plugin_prefix . '_ts_tracker_send_event' );
189
  }
190
  }
191
 
185
  */
186
  public static function ts_schedule_cron_job () {
187
  if ( ! wp_next_scheduled( self::$plugin_prefix . '_ts_tracker_send_event' ) ) {
188
+ wp_schedule_event( time() + 604800, 'once_in_week', self::$plugin_prefix . '_ts_tracker_send_event' );
189
  }
190
  }
191
 
{woocommerce-abandoned-cart/includes → includes}/component/welcome-page/Instructions RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/welcome-page/assets/images/abandon-cart-cut-off-time.png RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/welcome-page/assets/images/abandoned-cart-lite-email-templates.png RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/welcome-page/assets/images/email-templates-send-time.png RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/welcome-page/assets/images/icon-256x256.png RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/welcome-page/assets/images/site-logo-new.jpg RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/welcome-page/templates/social-media-elements.php RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/component/welcome-page/templates/welcome/welcome-page.php RENAMED
@@ -76,7 +76,7 @@
76
  <h3><?php esc_html_e( 'Set different cut-off times for visitors & logged-in users', 'woocommerce-abandoned-cart' ); ?></h3>
77
 
78
  <p><?php esc_html_e( 'The provision for setting two separate cut-off times for different roles is mainly because sometimes if the store admin wants the visitor carts to be captured earlier than the registered user carts, then these different settings can play an important role.', 'woocommerce-abandoned-cart' ); ?></p>
79
- <a href="https://www.tychesoftwares.com/capturing-abandoned-carts-woocommerce-abandoned-cart-pro-plugin/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank" class="button-secondary">
80
  <?php esc_html_e( 'Learn More', 'woocommerce-abandoned-cart' ); ?>
81
  <span class="dashicons dashicons-external"></span>
82
  </a>
@@ -97,7 +97,7 @@
97
  <h3><?php esc_html_e( 'Send abandoned cart recovery email in minutes of cart being abandoned', 'woocommerce-abandoned-cart' ); ?></h3>
98
 
99
  <p><?php esc_html_e( 'The ability to send the abandoned cart recovery email within first few minutes of cart being abandoned is a big advantage. In the Lite plugin, the earliest an email can be sent is after 1 hour. Whereas in the Pro version, the first recovery email gets sent 15 minutes after the cart is abandoned. This increases the recovery chances manifold.', 'woocommerce-abandoned-cart' ); ?></p>
100
- <a href="https://www.tychesoftwares.com/understanding-the-default-email-templates-of-abandoned-cart-pro-for-woocommerce-plugin/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank" class="button-secondary">
101
  <?php esc_html_e( 'Learn More', 'woocommerce-abandoned-cart' ); ?>
102
  <span class="dashicons dashicons-external"></span>
103
  </a>
76
  <h3><?php esc_html_e( 'Set different cut-off times for visitors & logged-in users', 'woocommerce-abandoned-cart' ); ?></h3>
77
 
78
  <p><?php esc_html_e( 'The provision for setting two separate cut-off times for different roles is mainly because sometimes if the store admin wants the visitor carts to be captured earlier than the registered user carts, then these different settings can play an important role.', 'woocommerce-abandoned-cart' ); ?></p>
79
+ <a href="https://www.tychesoftwares.com/docs/docs/abandoned-cart-pro-for-woocommerce/capturing-abandoned-carts/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank" class="button-secondary">
80
  <?php esc_html_e( 'Learn More', 'woocommerce-abandoned-cart' ); ?>
81
  <span class="dashicons dashicons-external"></span>
82
  </a>
97
  <h3><?php esc_html_e( 'Send abandoned cart recovery email in minutes of cart being abandoned', 'woocommerce-abandoned-cart' ); ?></h3>
98
 
99
  <p><?php esc_html_e( 'The ability to send the abandoned cart recovery email within first few minutes of cart being abandoned is a big advantage. In the Lite plugin, the earliest an email can be sent is after 1 hour. Whereas in the Pro version, the first recovery email gets sent 15 minutes after the cart is abandoned. This increases the recovery chances manifold.', 'woocommerce-abandoned-cart' ); ?></p>
100
+ <a href="https://www.tychesoftwares.com/docs/docs/abandoned-cart-pro-for-woocommerce/default-email-templates/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank" class="button-secondary">
101
  <?php esc_html_e( 'Learn More', 'woocommerce-abandoned-cart' ); ?>
102
  <span class="dashicons dashicons-external"></span>
103
  </a>
{woocommerce-abandoned-cart/includes → includes}/component/welcome-page/ts-welcome.php RENAMED
File without changes
includes/templates/template_1.php ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $site_title = get_bloginfo( 'name' );
4
+ $site_url = get_option( 'siteurl' );
5
+ $admin_args = array( 'role' => 'administrator',
6
+ 'fields' => array( 'id' )
7
+ );
8
+
9
+ $admin_usr = get_users( $admin_args );
10
+ $uid = $admin_usr[0]->id;
11
+ $admin_phone = get_user_meta( $uid, 'billing_phone', true );
12
+ ?>
13
+
14
+ <p><style type="text/css">
15
+ * {
16
+ -webkit-font-smoothing: antialiased;
17
+ }
18
+ div, p, a, li, td {
19
+ -webkit-text-size-adjust: none;
20
+ }
21
+ #outlook a {
22
+ padding: 0;
23
+ }
24
+ html {
25
+ width: 100%;
26
+ }
27
+ body {
28
+ margin: 0;
29
+ padding: 0;
30
+ color: #808080;
31
+ width: 100% !important;
32
+ font-family: Arial, Helvetica, sans-serif;
33
+ -webkit-text-size-adjust: 100%!important;
34
+ -ms-text-size-adjust: 100%!important;
35
+ -webkit-font-smoothing: antialiased!important;
36
+ }
37
+ img {
38
+ outline: none;
39
+ border: none;
40
+ text-decoration: none;
41
+ -ms-interpolation-mode: bicubic;
42
+ }
43
+ a {
44
+ text-decoration: none;
45
+ }
46
+ a img {
47
+ border: none;
48
+ }
49
+ table {
50
+ color: #222222;
51
+ font-family: Arial, sans-serif;
52
+ }
53
+ table td {
54
+ border-collapse: collapse;
55
+ mso-line-height-rule: exactly;
56
+ mso-table-lspace: 0pt;
57
+ mso-table-rspace: 0pt;
58
+ }
59
+ table {
60
+ border-collapse: collapse;
61
+ mso-table-lspace: 0pt;
62
+ mso-table-rspace: 0pt;
63
+ }
64
+ .main-wrapper {
65
+ max-width: 600px;
66
+ }
67
+ .container {
68
+ width: 100%;
69
+ table-layout: fixed;
70
+ -webkit-text-size-adjust: 100%;
71
+ -ms-text-size-adjust: 100%;
72
+ }
73
+ @media screen and (max-device-width:600px),
74
+ screen and (max-width:600px) {
75
+ td[class=td_em_hide] {
76
+ display: none !important;
77
+ }
78
+ table[class=main-wrapper] {
79
+ width: 100%!important;
80
+ }
81
+ td[class=em_bg_center] {
82
+ background-position: center!important;
83
+ }
84
+ .main-wrapper {
85
+ width: 100% !important;
86
+ }
87
+ }
88
+ @media screen and (max-device-width:520px),
89
+ screen and (max-width:520px) {
90
+ td[class=td_w_sm] {
91
+ width: 20px!important;
92
+ }
93
+ td[class=td_sm_hide] {
94
+ display: none !important;
95
+ }
96
+ .sm-center-txt {
97
+ text-align: center;
98
+ }
99
+ table[class=main-wrapper] {
100
+ width: 100%!important;
101
+ }
102
+ table[class=sm_wrapper] {
103
+ width: 100%!important;
104
+ }
105
+ td[class=td-sm_wrapper] {
106
+ width: 100%!important;
107
+ }
108
+ td[class=sm-txt] {
109
+ font-size: 24px!important;
110
+ }
111
+ td[class=sm-txt1] {
112
+ font-size: 45px!important;
113
+ }
114
+ .main-wrapper {
115
+ width: 100% !important;
116
+ }
117
+ }
118
+ </style></p><p><style type="text/css">
119
+ @media only screen and (max-width:480px) {
120
+ @-ms-viewport {
121
+ width: 320px;
122
+ }
123
+ @viewport {
124
+ width: 320px;
125
+ }
126
+ }
127
+ </style></p><p><style type="text/css">
128
+ @import url(https://fonts.googleapis.com/css?family=Lato);
129
+ @import url(https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700);
130
+ @import url(https://fonts.googleapis.com/css?family=Cabin);
131
+ </style></p><table style="background-color: #f6f3f3; font-size: 15px; line-height: 20px; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt;" border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#f6f3f3"><tbody><tr><td align="center" valign="top" width="100%"><!-- [if mso | IE]>
132
+ <table role="presentation" border="0" cellpadding="0" cellspacing="0" width="600" align="center" style="width:600px;">
133
+ <tr>
134
+ <td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
135
+ <![endif]--><div style="margin: 0 auto; max-width: 600px;"><table class="main-wrapper" style="background-color: #ffffff; table-layout: fixed; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-family: Arial, Helvetica, sans-serif; color: #333333; margin: 0 auto; max-width: 600px;" role="presentation" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#ffffff"><tbody><tr><td style="padding-top: 10px;" bgcolor="#ffffff" width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"><tbody><tr><td class="td_w_sm" style="font-size: 0; line-height: 0;" width="30"> </td><td style="padding: 0;"><div style="font-size: 0pt; line-height: 0pt; height: 20px;"> </div><table border="0" width="100%" cellspacing="0" cellpadding="0"><tbody><tr><td class="sm-txt" style="font-size: 30px; line-height: 30px; text-align: center; color: #333032; text-transform: uppercase; font-family: Ubuntu, Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; padding: 0;" align="center" width="100%"><?php echo "$site_title"; ?> </td>
136
+
137
+ </tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr><tr><td class="sm-txt1" style="font-size: 50px; line-height: 50px; text-align: center; color: #000000; text-transform: uppercase; font-family: Ubuntu, Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; padding: 0;" align="center" width="100%">PSST...</td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="20"> </td></tr><tr><td style="font-size: 15px; line-height: 24px; text-align: center; color: #333032; text-transform: uppercase; letter-spacing: 2px; padding: 0;" align="center" width="100%">Looks like you left something fabulous <br />in your shopping bag</td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="25"> </td></tr><tr><td style="font-size: 0pt; line-height: 0pt; padding: 0;" align="center"><img style="display: block; width: 100%; max-width: 301px; margin: 0 auto;" src="http://staging.tychesoftwares.com/templates/default1.jpeg" alt="" /></td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="25"> </td></tr><tr><td style="font-size: 15px; line-height: 24px; text-align: center; color: #333032; text-transform: uppercase; letter-spacing: 2px; padding: 0;" align="center" width="100%">Shop now before time runs out, <br />These must have ITEMs won't be around for long... </td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="20"> </td></tr><tr><td style="text-align: center; padding: 0;" align="center">
138
+
139
+ {{products.cart}}
140
+
141
+
142
+ </td></tr><tr><td style="line-height: 1px; font-size: 1px;" bgcolor="#cfcfcf" height="2"> </td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr><tr><td style="font-size: 15px; line-height: 20px; text-align: center; color: #333032; font-weight: bold; padding: 0;" align="center" width="100%">For your convenience, we have saved your shopping cart.</td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr><tr><td align="center"><table border="0" cellspacing="0" cellpadding="0" align="center"><tbody><tr><td align="center"><table border="0" width="270" cellspacing="0" cellpadding="0" align="center"><tbody><tr><td style="border-collapse: collapse; word-break: break-word; word-wrap: break-word;" align="center"><a style="display: block; font-family: Arial, Helvetica, sans-serif; font-size: 16px; letter-spacing: 1px; color: #ffffff; line-height: 20px; text-decoration: none; text-align: center; background-color: #000; margin: 0 auto; width: 270px; box-sizing: border-box; padding: 8px 8px 8px 8px;" href="{{cart.link}}">CHECKOUT NOW</a></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr><tr><td style="font-size: 15px; line-height: 20px; text-align: center; color: #333032; padding: 0;" align="center" width="100%">For your assistance or if you would like to place an order directly with our customer service team, please call us at <?php echo "$admin_phone"; ?> </td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr><tr><td style="line-height: 1px; font-size: 1px;" bgcolor="#cfcfcf" height="2"> </td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr></tbody></table></td><td class="td_w_sm" style="font-size: 0; line-height: 0;" width="30"> </td></tr></tbody></table></td></tr><tr><td><!-- ======= footer start======= --><table border="0" width="100%" cellspacing="0" cellpadding="0"><tbody><tr><td class="td_w_sm" style="font-size: 0; line-height: 0;" width="30"> </td><td style="padding: 0;"><table border="0" width="100%" cellspacing="0" cellpadding="0"><tbody>
143
+
144
+ <td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="10"> </td></tr><tr><td style="font-size: 15px; line-height: 20px; text-align: center; color: #333032; padding: 0;" align="center" width="100%"><a href="{{cart.unsubscribe}}">Unsubscribe</a></td></tr></tbody></table><!-- ======= footer end======= --></td><td class="td_w_sm" style="font-size: 0; line-height: 0;" width="30"> </td></tr></tbody></table></td></tr></tbody></table></div><!-- [if mso | IE]> </td></tr></table> <![endif]--></td></tr></tbody></table>
includes/wcal-common.php ADDED
@@ -0,0 +1,776 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Abandoned Cart Lite for WooCommerce
4
+ *
5
+ * @author Tyche Softwares
6
+ * @package Abandoned-Cart-Lite-for-WooCommerce/Common-Functions
7
+ */
8
+
9
+ /**
10
+ * It will have all the common funtions for the plugin.
11
+ * @since 2.5.2
12
+ */
13
+ class wcal_common {
14
+
15
+ /**
16
+ * Get abandoned orders counts.
17
+ * @globals mixed $wpdb
18
+ * @return string | int $wcal_order_count
19
+ * @since 3.9
20
+ */
21
+ private static function wcal_ts_get_abandoned_order_counts() {
22
+ global $wpdb;
23
+ $wcal_order_count = 0;
24
+
25
+ $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
26
+ $cut_off_time = $ac_cutoff_time * 60;
27
+ $current_time = current_time( 'timestamp' );
28
+ $compare_time = $current_time - $cut_off_time;
29
+
30
+ $blank_cart_info = '{"cart":[]}';
31
+ $blank_cart_info_guest = '[]';
32
+
33
+ $wcal_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest'";
34
+
35
+ $wcal_order_count = $wpdb->get_var( $wcal_query );
36
+
37
+ return $wcal_order_count;
38
+ }
39
+
40
+
41
+ /**
42
+ * Get recovered orders counts.
43
+ * @globals mixed $wpdb
44
+ * @return string | int $wcal_recovered_order_count
45
+ * @since 3.9
46
+ */
47
+ private static function wcal_ts_get_recovered_order_counts(){
48
+
49
+ global $wpdb;
50
+ $wcal_recovered_order_count = 0;
51
+
52
+ $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
53
+ $cut_off_time = $ac_cutoff_time * 60;
54
+ $current_time = current_time( 'timestamp' );
55
+ $compare_time = $current_time - $cut_off_time;
56
+
57
+ $wcal_recovery_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time'";
58
+
59
+ $wcal_recovered_order_count = $wpdb->get_var( $wcal_recovery_query );
60
+
61
+ return $wcal_recovered_order_count;
62
+ }
63
+
64
+ /**
65
+ * Get Total abandoned orders amount.
66
+ * @globals mixed $wpdb
67
+ * @return string | int $wcal_abandoned_orders_amount
68
+ * @since 3.9
69
+ */
70
+ private static function wcal_ts_get_abandoned_order_total_amount(){
71
+ global $wpdb;
72
+ $wcal_abandoned_orders_amount = 0;
73
+
74
+ $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
75
+ $cut_off_time = $ac_cutoff_time * 60;
76
+ $current_time = current_time( 'timestamp' );
77
+ $compare_time = $current_time - $cut_off_time;
78
+
79
+ $blank_cart_info = '{"cart":[]}';
80
+ $blank_cart_info_guest = '[]';
81
+
82
+ $wcal_abandoned_query = "SELECT abandoned_cart_info FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest'";
83
+
84
+ $wcal_abandoned_query_result = $wpdb->get_results( $wcal_abandoned_query );
85
+
86
+ $wcal_abandoned_orders_amount = self::wcal_get_abandoned_amount( $wcal_abandoned_query_result );
87
+
88
+ return $wcal_abandoned_orders_amount;
89
+ }
90
+
91
+ /**
92
+ * Get Total abandoned orders amount.
93
+ * @globals mixed $wpdb
94
+ * @param array | object $wcal_abandoned_query_result
95
+ * @return string | int $wcal_abandoned_orders_amount
96
+ * @since 3.9
97
+ */
98
+ private static function wcal_get_abandoned_amount( $wcal_abandoned_query_result ){
99
+
100
+ $wcal_abandoned_orders_amount = 0;
101
+ foreach ( $wcal_abandoned_query_result as $wcal_abandoned_query_key => $wcal_abandoned_query_value ) {
102
+ # code...
103
+ $cart_info = json_decode( $wcal_abandoned_query_value->abandoned_cart_info );
104
+
105
+ $cart_details = array();
106
+ if( isset( $cart_info->cart ) ){
107
+ $cart_details = $cart_info->cart;
108
+ }
109
+
110
+ if( count( $cart_details ) > 0 ) {
111
+ foreach( $cart_details as $k => $v ) {
112
+ if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
113
+ $wcal_abandoned_orders_amount = $wcal_abandoned_orders_amount + $v->line_total + $v->line_subtotal_tax;
114
+ } else {
115
+ $wcal_abandoned_orders_amount = $wcal_abandoned_orders_amount + $v->line_total;
116
+ }
117
+ }
118
+ }
119
+ }
120
+ return $wcal_abandoned_orders_amount;
121
+ }
122
+
123
+ /**
124
+ * Get recovered orders total amount.
125
+ * @globals mixed $wpdb
126
+ * @return string | int $wcal_recovered_orders_amount
127
+ * @since 3.9
128
+ */
129
+ private static function wcal_ts_get_recovered_order_total_amount() {
130
+
131
+ global $wpdb;
132
+ $wcal_recovered_orders_amount = 0;
133
+
134
+ $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
135
+ $cut_off_time = $ac_cutoff_time * 60;
136
+ $current_time = current_time( 'timestamp' );
137
+ $compare_time = $current_time - $cut_off_time;
138
+
139
+ $wcal_recovery_query_amount = "SELECT recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time'";
140
+
141
+ $wcal_recovered_order_amount_result = $wpdb->get_results( $wcal_recovery_query_amount );
142
+
143
+ $wcal_recovered_orders_amount = self::wcal_get_recovered_amount ($wcal_recovered_order_amount_result );
144
+
145
+ return $wcal_recovered_orders_amount;
146
+ }
147
+
148
+ /**
149
+ * Get recovered orders total amount.
150
+ * @globals mixed $wpdb
151
+ * @param array | object $wcal_data
152
+ * @return string | int $wcal_recovered_orders_amount
153
+ * @since 3.9
154
+ */
155
+
156
+ private static function wcal_get_recovered_amount ( $wcal_data ){
157
+
158
+ $wcal_recovered_orders_amount = 0;
159
+
160
+ foreach ($wcal_data as $wcal_data_key => $wcal_data_value) {
161
+
162
+ $wcal_order_total = get_post_meta( $wcal_data_value->recovered_cart , '_order_total', true);
163
+ $wcal_recovered_orders_amount = $wcal_recovered_orders_amount + $wcal_order_total;
164
+ }
165
+ return $wcal_recovered_orders_amount;
166
+ }
167
+
168
+ /**
169
+ * Get sent email total count.
170
+ * @globals mixed $wpdb
171
+ * @return string | int $wcal_sent_emails_count
172
+ * @since 3.9
173
+ */
174
+ private static function wcal_ts_get_sent_emails_total_count(){
175
+
176
+ global $wpdb;
177
+ $wcal_sent_emails_count = 0;
178
+ $wcal_sent_emails_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_sent_history_lite`";
179
+ $wcal_sent_emails_count = $wpdb->get_var( $wcal_sent_emails_query );
180
+ return $wcal_sent_emails_count;
181
+ }
182
+
183
+ /**
184
+ * Get email templates total count.
185
+ * @globals mixed $wpdb
186
+ * @return array $wcal_templates_data
187
+ * @since 3.9
188
+ */
189
+ private static function wcal_ts_get_email_templates_data(){
190
+
191
+ global $wpdb;
192
+ $wcal_email_templates_count = 0;
193
+ $wcal_email_templates_query = "SELECT id, is_active, is_wc_template,frequency, day_or_hour FROM `" . $wpdb->prefix . "ac_email_templates_lite`";
194
+ $wcal_email_templates_results = $wpdb->get_results( $wcal_email_templates_query );
195
+
196
+ $wcal_email_templates_count = count( $wcal_email_templates_results );
197
+
198
+ $wcal_templates_data = array();
199
+ $wcal_templates_data ['total_templates'] = $wcal_email_templates_count;
200
+
201
+ foreach ($wcal_email_templates_results as $wcal_email_templates_results_key => $wcal_email_templates_results_value ) {
202
+
203
+ $wcal_template_time = $wcal_email_templates_results_value->frequency . ' ' .$wcal_email_templates_results_value->day_or_hour ;
204
+
205
+ $wcal_get_total_email_sent_for_template = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE template_id = ". $wcal_email_templates_results_value->id;
206
+ $wcal_get_total_email_sent_for_template_count = $wpdb->get_var( $wcal_get_total_email_sent_for_template );
207
+
208
+ $wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['is_activate'] = ( $wcal_email_templates_results_value->is_active == 1 ) ? 'Active' : 'Deactive';
209
+ $wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['is_wc_template'] = ( $wcal_email_templates_results_value->is_wc_template == 1 ) ? 'Yes' : 'No';
210
+ $wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['template_time'] = $wcal_template_time;
211
+ $wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['total_email_sent'] = $wcal_get_total_email_sent_for_template_count;
212
+ }
213
+
214
+ return $wcal_templates_data;
215
+ }
216
+
217
+ /**
218
+ * Get logged-in users total abandoned count.
219
+ * @globals mixed $wpdb
220
+ * @return string | int $wcal_logged_in_user_query_count
221
+ * @since 3.9
222
+ */
223
+ private static function wcal_ts_get_logged_in_users_abandoned_cart_total_count (){
224
+
225
+ global $wpdb;
226
+ $wcal_logged_in_user_query_count = 0;
227
+
228
+ $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
229
+ $cut_off_time = $ac_cutoff_time * 60;
230
+ $current_time = current_time( 'timestamp' );
231
+ $compare_time = $current_time - $cut_off_time;
232
+
233
+ $blank_cart_info = '{"cart":[]}';
234
+ $blank_cart_info_guest = '[]';
235
+
236
+ $wcal_logged_in_user_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id < 63000000 AND user_id != 0";
237
+
238
+ $wcal_logged_in_user_query_count = $wpdb->get_var( $wcal_logged_in_user_query );
239
+
240
+ return $wcal_logged_in_user_query_count;
241
+ }
242
+
243
+ /**
244
+ * Get Guest users total abandoned count.
245
+ * @globals mixed $wpdb
246
+ * @return string | int $wcal_guest_user_query_count
247
+ * @since 3.9
248
+ */
249
+ private static function wcal_ts_get_guest_users_abandoned_cart_total_count(){
250
+ global $wpdb;
251
+ $wcal_guest_user_query_count = 0;
252
+
253
+ $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
254
+ $cut_off_time = $ac_cutoff_time * 60;
255
+ $current_time = current_time( 'timestamp' );
256
+ $compare_time = $current_time - $cut_off_time;
257
+
258
+ $blank_cart_info = '{"cart":[]}';
259
+ $blank_cart_info_guest = '[]';
260
+
261
+ $wcal_guest_user_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id >= 63000000 AND user_id != 0";
262
+
263
+ $wcal_guest_user_query_count = $wpdb->get_var( $wcal_guest_user_query );
264
+
265
+ return $wcal_guest_user_query_count;
266
+ }
267
+
268
+ /**
269
+ * Get logged-in users total abandoned amount.
270
+ * @globals mixed $wpdb
271
+ * @return string | int $wcal_abandoned_orders_amount
272
+ * @since 3.9
273
+ */
274
+ private static function wcal_ts_get_logged_in_users_abandoned_cart_total_amount (){
275
+
276
+ global $wpdb;
277
+ $wcal_abandoned_orders_amount = 0;
278
+
279
+ $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
280
+ $cut_off_time = $ac_cutoff_time * 60;
281
+ $current_time = current_time( 'timestamp' );
282
+ $compare_time = $current_time - $cut_off_time;
283
+
284
+ $blank_cart_info = '{"cart":[]}';
285
+ $blank_cart_info_guest = '[]';
286
+
287
+ $wcal_abandoned_query = "SELECT abandoned_cart_info FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id < 63000000 AND user_id != 0 ";
288
+
289
+ $wcal_abandoned_query_result = $wpdb->get_results( $wcal_abandoned_query );
290
+
291
+ $wcal_abandoned_orders_amount = self::wcal_get_abandoned_amount( $wcal_abandoned_query_result );
292
+
293
+ return $wcal_abandoned_orders_amount;
294
+ }
295
+
296
+ /**
297
+ * Get Guest users total abandoned amount.
298
+ * @globals mixed $wpdb
299
+ * @return string | int $wcal_abandoned_orders_amount
300
+ * @since 3.9
301
+ */
302
+ private static function wcal_ts_get_guest_users_abandoned_cart_total_amount (){
303
+
304
+ global $wpdb;
305
+ $wcal_abandoned_orders_amount = 0;
306
+
307
+ $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
308
+ $cut_off_time = $ac_cutoff_time * 60;
309
+ $current_time = current_time( 'timestamp' );
310
+ $compare_time = $current_time - $cut_off_time;
311
+
312
+ $blank_cart_info = '{"cart":[]}';
313
+ $blank_cart_info_guest = '[]';
314
+
315
+ $wcal_abandoned_query = "SELECT abandoned_cart_info FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id >= 63000000 AND user_id != 0 ";
316
+
317
+ $wcal_abandoned_query_result = $wpdb->get_results( $wcal_abandoned_query );
318
+
319
+ $wcal_abandoned_orders_amount = self::wcal_get_abandoned_amount( $wcal_abandoned_query_result );
320
+
321
+ return $wcal_abandoned_orders_amount;
322
+ }
323
+
324
+ /**
325
+ * Get logged-in users total recovered amount.
326
+ * @globals mixed $wpdb
327
+ * @return string | int $wcal_recovered_orders_amount
328
+ * @since 3.9
329
+ */
330
+ private static function wcal_ts_get_logged_in_users_recovered_cart_total_amount(){
331
+
332
+ global $wpdb;
333
+ $wcal_recovered_orders_amount = 0;
334
+
335
+ $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
336
+ $cut_off_time = $ac_cutoff_time * 60;
337
+ $current_time = current_time( 'timestamp' );
338
+ $compare_time = $current_time - $cut_off_time;
339
+
340
+ $wcal_recovery_query_amount = "SELECT recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time' AND user_id < 63000000 AND user_id != 0 ";
341
+
342
+ $wcal_recovered_order_amount_result = $wpdb->get_results( $wcal_recovery_query_amount );
343
+
344
+ $wcal_recovered_orders_amount = self::wcal_get_recovered_amount ($wcal_recovered_order_amount_result );
345
+
346
+ return $wcal_recovered_orders_amount;
347
+
348
+ }
349
+
350
+
351
+ /**
352
+ * Get Guest users total recovered amount.
353
+ * @globals mixed $wpdb
354
+ * @return string | int $wcal_recovered_orders_amount
355
+ * @since 3.9
356
+ */
357
+ private static function wcal_ts_get_guest_users_recovered_cart_total_amount (){
358
+
359
+ global $wpdb;
360
+ $wcal_recovered_orders_amount = 0;
361
+
362
+ $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
363
+ $cut_off_time = $ac_cutoff_time * 60;
364
+ $current_time = current_time( 'timestamp' );
365
+ $compare_time = $current_time - $cut_off_time;
366
+
367
+ $wcal_recovery_query_amount = "SELECT recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time' AND user_id >= 63000000 AND user_id != 0 ";
368
+
369
+ $wcal_recovered_order_amount_result = $wpdb->get_results( $wcal_recovery_query_amount );
370
+
371
+ $wcal_recovered_orders_amount = self::wcal_get_recovered_amount ($wcal_recovered_order_amount_result );
372
+
373
+ return $wcal_recovered_orders_amount;
374
+
375
+ }
376
+ /**
377
+ * Get all options of the plugin.
378
+ * @return array
379
+ * @since 3.9
380
+ */
381
+ private static function wcal_ts_get_all_plugin_options_values() {
382
+
383
+ return array(
384
+ 'wcal_cart_cut_off_time' => get_option( 'ac_lite_cart_abandoned_time' ),
385
+ 'wcal_admin_recovery_email' => get_option( 'ac_lite_email_admin_on_recovery' ),
386
+ 'wcal_capture_visitors_cart' => get_option( 'ac_lite_track_guest_cart_from_cart_page' )
387
+ );
388
+ }
389
+
390
+
391
+ /**
392
+ * If admin allow to track the data the it will gather all information and return back.
393
+ * @hook ts_tracker_data
394
+ * @param array $data
395
+ * @return array $data
396
+ * @since 3.9
397
+ */
398
+ public static function ts_add_plugin_tracking_data ( $data ){
399
+
400
+ if ( isset( $_GET[ 'wcal_tracker_optin' ] ) && isset( $_GET[ 'wcal_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ 'wcal_tracker_nonce' ], 'wcal_tracker_optin' ) ) {
401
+
402
+ $plugin_data[ 'ts_meta_data_table_name'] = 'ts_wcal_tracking_meta_data';
403
+
404
+ $plugin_data[ 'ts_plugin_name' ] = 'Abandoned Cart Lite for WooCommerce';
405
+
406
+ // Store abandoned count info
407
+ $plugin_data[ 'abandoned_orders' ] = self::wcal_ts_get_abandoned_order_counts();
408
+
409
+ // Store recovred count info
410
+ $plugin_data[ 'recovered_orders' ] = self::wcal_ts_get_recovered_order_counts();
411
+
412
+ // store abandoned orders amount
413
+ $plugin_data[ 'abandoned_orders_amount' ] = self::wcal_ts_get_abandoned_order_total_amount();
414
+
415
+ // Store recovered count info
416
+ $plugin_data[ 'recovered_orders_amount' ] = self::wcal_ts_get_recovered_order_total_amount();
417
+
418
+ // Store abandoned cart emails sent count info
419
+ $plugin_data[ 'sent_emails' ] = self::wcal_ts_get_sent_emails_total_count();
420
+
421
+ // Store email template count info
422
+ $plugin_data[ 'email_templates_data' ] = self::wcal_ts_get_email_templates_data();
423
+
424
+ // Store only logged-in users abandoned cart count info
425
+ $plugin_data[ 'logged_in_abandoned_orders' ] = self::wcal_ts_get_logged_in_users_abandoned_cart_total_count();
426
+
427
+ // Store only logged-in users abandoned cart count info
428
+ $plugin_data[ 'guest_abandoned_orders' ] = self::wcal_ts_get_guest_users_abandoned_cart_total_count();
429
+
430
+ // Store only logged-in users abandoned cart amount info
431
+ $plugin_data[ 'logged_in_abandoned_orders_amount' ] = self::wcal_ts_get_logged_in_users_abandoned_cart_total_amount();
432
+
433
+ // store only guest users abandoned cart amount
434
+ $plugin_data[ 'guest_abandoned_orders_amount' ] = self::wcal_ts_get_guest_users_abandoned_cart_total_amount();
435
+
436
+ // Store only logged-in users recovered cart amount info
437
+ $plugin_data[ 'logged_in_recovered_orders_amount' ] = self::wcal_ts_get_logged_in_users_recovered_cart_total_amount();
438
+
439
+ // Store only guest users recovered cart amount
440
+ $plugin_data[ 'guest_recovered_orders_amount' ] = self::wcal_ts_get_guest_users_recovered_cart_total_amount();
441
+
442
+ // Get all plugin options info
443
+ $plugin_data[ 'settings' ] = self::wcal_ts_get_all_plugin_options_values();
444
+ $plugin_data[ 'plugin_version' ] = self::wcal_get_version();
445
+ $plugin_data[ 'tracking_usage' ] = get_option ('wcal_allow_tracking');
446
+
447
+ $data [ 'plugin_data' ] = $plugin_data;
448
+ }
449
+ return $data;
450
+ }
451
+
452
+ /**
453
+ * Get data when Admin dont want to share information.
454
+ * @param array $params
455
+ * @return array $params
456
+ * @since 3.9
457
+ */
458
+ public static function ts_get_data_for_opt_out( $params ){
459
+
460
+ $plugin_data[ 'ts_meta_data_table_name'] = 'ts_wcal_tracking_meta_data';
461
+ $plugin_data[ 'ts_plugin_name' ] = 'Abandoned Cart Lite for WooCommerce';
462
+
463
+ $params[ 'plugin_data' ] = $plugin_data;
464
+
465
+ return $params;
466
+ }
467
+
468
+ /**
469
+ * It will fetch the total count for the abandoned cart section.
470
+ * @param string $get_section_result Name of the section for which we need result
471
+ * @return string | int $return_abandoned_count
472
+ * @globals mixed $wpdb
473
+ * @since 2.5.2
474
+ */
475
+ public static function wcal_get_abandoned_order_count( $get_section_result ){
476
+ global $wpdb;
477
+ $return_abandoned_count = 0;
478
+ $blank_cart_info = '{"cart":[]}';
479
+ $blank_cart_info_guest = '[]';
480
+ $blank_cart = '""';
481
+ $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
482
+ $cut_off_time = intval( $ac_cutoff_time ) * 60;
483
+ $current_time = current_time( 'timestamp' );
484
+ $compare_time = $current_time - $cut_off_time;
485
+
486
+ switch ( $get_section_result ) {
487
+ case 'wcal_all_abandoned':
488
+ $query_ac = "SELECT COUNT(`id`) as cnt FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE ( user_type = 'REGISTERED' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 AND cart_ignored <> '1') 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_info NOT LIKE '$blank_cart' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 AND cart_ignored <> '1') ORDER BY recovered_cart desc ";
489
+ $return_abandoned_count = $wpdb->get_var( $query_ac );
490
+ break;
491
+
492
+ case 'wcal_all_registered':
493
+ $query_ac = "SELECT COUNT(`id`) FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE ( user_type = 'REGISTERED' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 AND cart_ignored <> '1') ORDER BY recovered_cart desc ";
494
+ $return_abandoned_count = $wpdb->get_var( $query_ac );
495
+ break;
496
+
497
+ case 'wcal_all_guest':
498
+ $query_ac = "SELECT COUNT(`id`) 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_info NOT LIKE '$blank_cart' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 AND user_id >= 63000000 AND cart_ignored <> '1') ORDER BY recovered_cart desc ";
499
+ $return_abandoned_count = $wpdb->get_var( $query_ac );
500
+ break;
501
+
502
+ case 'wcal_all_visitor':
503
+ $query_ac = "SELECT COUNT(`id`) 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_info NOT LIKE '$blank_cart' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 AND user_id = 0 AND cart_ignored <> '1') ORDER BY recovered_cart desc ";
504
+ $return_abandoned_count = $wpdb->get_var( $query_ac );
505
+ break;
506
+
507
+ default:
508
+ # code...
509
+ break;
510
+ }
511
+ return $return_abandoned_count;
512
+ }
513
+
514
+
515
+ /**
516
+ * This function returns the Abandoned Cart Lite plugin version number.
517
+ * @return string $plugin_version
518
+ * @since 2.5.2
519
+ */
520
+ public static function wcal_get_version() {
521
+ $plugin_version = '';
522
+ $wcap_plugin_dir = dirname ( dirname (__FILE__) );
523
+ $wcap_plugin_dir .= '/woocommerce-ac.php';
524
+
525
+ $plugin_data = get_file_data( $wcap_plugin_dir, array( 'Version' => 'Version' ) );
526
+ if ( ! empty( $plugin_data['Version'] ) ) {
527
+ $plugin_version = $plugin_data[ 'Version' ];
528
+ }
529
+ return $plugin_version;
530
+ }
531
+
532
+ /**
533
+ * This function returns the plugin url.
534
+ * @return string plugin url
535
+ * @since 2.5.2
536
+ */
537
+ public static function wcal_get_plugin_url() {
538
+ return plugins_url() . '/woocommerce-abandoned-cart/';
539
+ }
540
+
541
+ /**
542
+ * This function will alter Email Templates Table to include emojis
543
+ *
544
+ * @return bool true if success else false
545
+ *
546
+ * @since 4.8
547
+ */
548
+ public static function update_templates_table(){
549
+
550
+ global $wpdb;
551
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
552
+
553
+ $query = "ALTER TABLE " . $wpdb->prefix . "ac_email_templates_lite" . " CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
554
+
555
+ return $wpdb->query( $query );
556
+ }
557
+
558
+ /**
559
+ * This function will show a dismissible success message after DB update is completed
560
+ *
561
+ * @since 4.8
562
+ */
563
+ public static function show_update_success() {
564
+ ?>
565
+
566
+ <div class="notice notice-success is-dismissible">
567
+ <p><strong><?php _e( 'Database Updated Successfully', 'woocommerce-abandoned-cart');?></strong></p>
568
+ </div>
569
+
570
+ <?php
571
+ }
572
+
573
+ /**
574
+ * This function will show a dismissible success message after DB update is completed
575
+ *
576
+ * @since 4.8
577
+ */
578
+ public static function show_update_failure() {
579
+ ?>
580
+
581
+ <div class="notice notice-error is-dismissible">
582
+ <p><strong><?php _e( 'Database Update Failed. Please try again after sometime', 'woocommerce-abandoned-cart');?></strong></p>
583
+ </div>
584
+
585
+ <?php
586
+ }
587
+ /**
588
+ * Returns an array of customer billing information.
589
+ * Should be called only for registered users.
590
+ *
591
+ * @param integer $user_id - User ID
592
+ * @return array $billing_details - Contains Billing Address Details
593
+ * @global $woocommerce
594
+ * @since 4.9
595
+ */
596
+ public static function wcal_get_billing_details( $user_id ) {
597
+ global $woocommerce;
598
+
599
+ $billing_details = array();
600
+
601
+ $user_billing_company_temp = get_user_meta( $user_id, 'billing_company' );
602
+ $user_billing_company = "";
603
+ if ( isset( $user_billing_company_temp[0] ) ){
604
+ $user_billing_company = $user_billing_company_temp[0];
605
+ }
606
+ $billing_details[ 'billing_company' ] = $user_billing_company;
607
+
608
+ $user_billing_address_1_temp = get_user_meta( $user_id, 'billing_address_1' );
609
+ $user_billing_address_1 = "";
610
+ if ( isset( $user_billing_address_1_temp[0] ) ) {
611
+ $user_billing_address_1 = $user_billing_address_1_temp[0];
612
+ }
613
+ $billing_details[ 'billing_address_1' ] = $user_billing_address_1;
614
+
615
+ $user_billing_address_2_temp = get_user_meta( $user_id, 'billing_address_2' );
616
+ $user_billing_address_2 = "";
617
+ if ( isset( $user_billing_address_2_temp[0] ) ) {
618
+ $user_billing_address_2 = $user_billing_address_2_temp[0];
619
+ }
620
+ $billing_details[ 'billing_address_2' ] = $user_billing_address_2;
621
+
622
+ $user_billing_city_temp = get_user_meta( $user_id, 'billing_city' );
623
+ $user_billing_city = "";
624
+ if ( isset( $user_billing_city_temp[0] ) ) {
625
+ $user_billing_city = $user_billing_city_temp[0];
626
+ }
627
+ $billing_details[ 'billing_city' ] = $user_billing_city;
628
+
629
+ $user_billing_postcode_temp = get_user_meta( $user_id, 'billing_postcode' );
630
+ $user_billing_postcode = "";
631
+ if ( isset( $user_billing_postcode_temp[0] ) ) {
632
+ $user_billing_postcode = $user_billing_postcode_temp[0];
633
+ }
634
+ $billing_details[ 'billing_postcode' ] = $user_billing_postcode;
635
+
636
+ $user_billing_country_temp = get_user_meta( $user_id, 'billing_country' );
637
+ $user_billing_country = "";
638
+ if ( isset( $user_billing_country_temp[0] ) && '' != $user_billing_country_temp[0] ) {
639
+ $user_billing_country = $user_billing_country_temp[0];
640
+ if ( isset( $woocommerce->countries->countries[ $user_billing_country ] ) || '' != ( $woocommerce->countries->countries[ $user_billing_country ] ) ) {
641
+ $user_billing_country = WC()->countries->countries[ $user_billing_country ];
642
+ } else {
643
+ $user_billing_country = "";
644
+ }
645
+ }
646
+ $billing_details[ 'billing_country' ] = $user_billing_country;
647
+
648
+ $user_billing_state_temp = get_user_meta( $user_id, 'billing_state' );
649
+ $user_billing_state = "";
650
+ if ( isset( $user_billing_state_temp[0] ) ) {
651
+ $user_billing_state = $user_billing_state_temp[0];
652
+ if ( isset( $woocommerce->countries->states[ $user_billing_country_temp[0] ][ $user_billing_state ] ) ) {
653
+ $user_billing_state = WC()->countries->states[ $user_billing_country_temp[0] ][ $user_billing_state ];
654
+ } else {
655
+ $user_billing_state = "";
656
+ }
657
+ }
658
+ $billing_details[ 'billing_state' ] = $user_billing_state;
659
+
660
+ return $billing_details;
661
+ }
662
+
663
+
664
+ /**
665
+ * Returns the Item Name, Qty and Total for any given product
666
+ * in the WC Cart
667
+ *
668
+ * @param stdClass $v - Cart Information from WC()->cart;
669
+ * @return array $item_details - Item Data
670
+ * @global $woocommerce
671
+ * @since 4.9
672
+ */
673
+ public static function wcal_get_cart_details( $v ) {
674
+ global $woocommerce;
675
+
676
+ $cart_total = $item_subtotal = $item_total = $line_subtotal_tax_display = $after_item_subtotal = $after_item_subtotal_display = 0;
677
+
678
+ $line_subtotal_tax = '';
679
+ $quantity_total = 0;
680
+
681
+ $item_details = array();
682
+
683
+ $quantity_total = $v->quantity;
684
+ $product_id = $v->product_id;
685
+ $prod_name = get_post( $product_id );
686
+ $product_name = $prod_name->post_title;
687
+
688
+ if ( isset( $v->variation_id ) && '' != $v->variation_id ) {
689
+ $variation_id = $v->variation_id;
690
+ $variation = wc_get_product( $variation_id );
691
+
692
+ if( false != $variation ) {
693
+ $name = $variation->get_formatted_name() ;
694
+ $explode_all = explode ( "&ndash;", $name );
695
+ if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
696
+ $wcap_sku = '';
697
+ if ( $variation->get_sku() ) {
698
+ $wcap_sku = "SKU: " . $variation->get_sku() . "<br>";
699
+ }
700
+ $wcap_get_formatted_variation = wc_get_formatted_variation( $variation, true );
701
+
702
+ $add_product_name = $product_name . ' - ' . $wcap_sku . $wcap_get_formatted_variation;
703
+
704
+ $pro_name_variation = (array) $add_product_name;
705
+ }else{
706
+ $pro_name_variation = array_slice( $explode_all, 1, -1 );
707
+ }
708
+ $product_name_with_variable = '';
709
+ $explode_many_varaition = array();
710
+ foreach( $pro_name_variation as $pro_name_variation_key => $pro_name_variation_value ) {
711
+ $explode_many_varaition = explode ( ",", $pro_name_variation_value );
712
+ if( !empty( $explode_many_varaition ) ) {
713
+ foreach( $explode_many_varaition as $explode_many_varaition_key => $explode_many_varaition_value ) {
714
+ $product_name_with_variable = $product_name_with_variable . html_entity_decode ( $explode_many_varaition_value ) . "<br>";
715
+ }
716
+ } else {
717
+ $product_name_with_variable = $product_name_with_variable . html_entity_decode ( $explode_many_varaition_value ) . "<br>";
718
+ }
719
+ }
720
+ $product_name = $product_name_with_variable;
721
+ }
722
+ }
723
+ $item_subtotal = 0;
724
+ // Item subtotal is calculated as product total including taxes
725
+ if ( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
726
+ $item_subtotal = $item_subtotal + $v->line_total + $v->line_subtotal_tax;
727
+ } else {
728
+ $item_subtotal = $item_subtotal + $v->line_total;
729
+ }
730
+ // Line total
731
+ $item_total = $item_subtotal;
732
+ $item_subtotal = $item_subtotal / $quantity_total;
733
+ $item_total = wc_price( $item_total );
734
+ $item_subtotal = wc_price( $item_subtotal );
735
+
736
+ $item_details[ 'product_name' ] = $product_name;
737
+ $item_details[ 'item_total_formatted' ] = $item_subtotal;
738
+ $item_details[ 'item_total' ] = $item_total;
739
+ $item_details[ 'qty' ] = $quantity_total;
740
+
741
+ return $item_details;
742
+ }
743
+
744
+ /**
745
+ * Set Cart Session variables
746
+ *
747
+ * @param string $session_key Key of the session
748
+ * @param string $session_value Value of the session
749
+ * @since 7.11.0
750
+ */
751
+ public static function wcal_set_cart_session( $session_key, $session_value ) {
752
+ WC()->session->set( $session_key, $session_value );
753
+ }
754
+
755
+ /**
756
+ * Get Cart Session variables
757
+ *
758
+ * @param string $session_key Key of the session
759
+ * @return mixed Value of the session
760
+ * @since 7.11.0
761
+ */
762
+ public static function wcal_get_cart_session( $session_key ) {
763
+ return WC()->session->get( $session_key );
764
+ }
765
+
766
+ /**
767
+ * Delete Cart Session variables
768
+ *
769
+ * @param string $session_key Key of the session
770
+ * @since 7.11.0
771
+ */
772
+ public static function wcal_unset_cart_session( $session_key ) {
773
+ WC()->session->__unset( $session_key );
774
+ }
775
+ }
776
+ ?>
{woocommerce-abandoned-cart/includes → includes}/wcal_actions.php RENAMED
@@ -26,15 +26,15 @@ class wcal_delete_bulk_action_handler {
26
  WHERE id = '$abandoned_cart_id' ";
27
  $results_get_user_id = $wpdb->get_results( $get_user_id );
28
  $user_id_of_guest = $results_get_user_id[0]->user_id;
29
-
30
  $query_delete = "DELETE FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
31
  WHERE id = '$abandoned_cart_id' ";
32
  $results_delete = $wpdb->get_results( $query_delete );
33
 
34
  if ( $user_id_of_guest >= '63000000' ) {
35
- $guest_query_delete = "DELETE FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
36
- WHERE id = '" . $user_id_of_guest . "'";
37
- $results_guest = $wpdb->get_results( $guest_query_delete );
38
  //guest user
39
  }
40
  wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&wcal_deleted=YES' ) );
@@ -64,46 +64,51 @@ class wcal_delete_bulk_action_handler {
64
  */
65
  public static function wcal_delete_abandoned_carts_after_x_days() {
66
  global $wpdb;
67
- $query = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite" . "` WHERE recovered_cart = '0' ";
68
- $carts = $wpdb->get_results ( $query );
69
- foreach( $carts as $cart_key => $cart_value ) {
70
- $cart_update_time = $cart_value->abandoned_cart_time;
71
- wcal_delete_bulk_action_handler::wcal_delete_ac_carts( $cart_value, $cart_update_time );
 
 
 
 
 
 
 
 
72
  }
 
73
  }
74
  /**
75
  * It will delete the abandoned cart data from database.
76
  * It will also delete the email history for that abandoned cart.
77
  * If the user id guest user then it will delete the record from users table.
78
  * @param object $value Value of cart.
79
- * @param timestamp $cart_update_time Cart abandoned time
80
  * @globals mixed $wpdb
81
  * @since 5.0
82
  */
83
- public static function wcal_delete_ac_carts( $value, $cart_update_time ) {
84
  global $wpdb;
85
- $delete_ac_after_days = get_option( 'ac_lite_delete_abandoned_order_days' );
86
- if ( '' != $delete_ac_after_days ){
87
- $delete_ac_after_days_time = $delete_ac_after_days * 86400;
88
- $current_time = current_time( 'timestamp' );
89
- $check_time = $current_time - $cart_update_time;
90
-
91
- if ( $check_time > $delete_ac_after_days_time && $delete_ac_after_days_time != 0 && $delete_ac_after_days_time != "" ) {
92
- $abandoned_id = $value->id;
93
- $query_delete_sent_history = "DELETE FROM `" . $wpdb->prefix . "ac_sent_history_lite" . "` WHERE abandoned_order_id = '$abandoned_id' ";
94
- $delete_sent_history = $wpdb->get_results( $query_delete_sent_history );
95
 
96
- $user_id = $value->user_id;
97
- $query = "DELETE FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite" . "` WHERE user_id = '$user_id' AND abandoned_cart_time = '$cart_update_time'";
98
- $results2 = $wpdb->get_results ( $query );
99
-
100
- $query_delete_cart = "DELETE FROM `" . $wpdb->prefix."usermeta` WHERE user_id = '$user_id' AND meta_key = '_woocommerce_persistent_cart' ";
101
- $results_delete = $wpdb->get_results ( $query_delete_cart );
102
- if ( $user_id >= '63000000' ) {
103
- $guest_query = "DELETE FROM `" . $wpdb->prefix . "ac_guest_abandoned_cart_history_lite" . "` WHERE id = '" . $user_id . "'";
104
- $results_guest = $wpdb->get_results ( $guest_query );
105
- }
 
 
 
106
  }
107
  }
108
- }
109
- }
26
  WHERE id = '$abandoned_cart_id' ";
27
  $results_get_user_id = $wpdb->get_results( $get_user_id );
28
  $user_id_of_guest = $results_get_user_id[0]->user_id;
29
+
30
  $query_delete = "DELETE FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
31
  WHERE id = '$abandoned_cart_id' ";
32
  $results_delete = $wpdb->get_results( $query_delete );
33
 
34
  if ( $user_id_of_guest >= '63000000' ) {
35
+ $guest_query_delete = "DELETE FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
36
+ WHERE id = '" . $user_id_of_guest . "'";
37
+ $results_guest = $wpdb->get_results( $guest_query_delete );
38
  //guest user
39
  }
40
  wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&wcal_deleted=YES' ) );
64
  */
65
  public static function wcal_delete_abandoned_carts_after_x_days() {
66
  global $wpdb;
67
+
68
+ $delete_ac_after_days = get_option( 'ac_lite_delete_abandoned_order_days' );
69
+ if ( '' != $delete_ac_after_days && $delete_ac_after_days != 0 ){
70
+
71
+ $delete_ac_after_days_time = $delete_ac_after_days * 86400;
72
+ $current_time = current_time( 'timestamp' );
73
+ $check_time = $current_time - $delete_ac_after_days_time;
74
+
75
+ $query = "SELECT id, user_id, user_type FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite" . "` WHERE recovered_cart = '0' AND abandoned_cart_time < %s";
76
+ $carts = $wpdb->get_results ( $wpdb->prepare( $query, $check_time ) );
77
+ foreach( $carts as $cart_key => $cart_value ) {
78
+ wcal_delete_bulk_action_handler::wcal_delete_ac_carts( $cart_value );
79
+ }
80
  }
81
+
82
  }
83
  /**
84
  * It will delete the abandoned cart data from database.
85
  * It will also delete the email history for that abandoned cart.
86
  * If the user id guest user then it will delete the record from users table.
87
  * @param object $value Value of cart.
 
88
  * @globals mixed $wpdb
89
  * @since 5.0
90
  */
91
+ public static function wcal_delete_ac_carts( $value ) {
92
  global $wpdb;
93
+
94
+ $abandoned_id = $value->id;
95
+ $user_id = $value->user_id;
96
+ $user_type = $value->user_type;
 
 
 
 
 
 
97
 
98
+ if( $abandoned_id > 0 && '' != $user_type ) {
99
+ // delete the sent history for reminder emails for the cart
100
+ $query_delete_sent_history = $wpdb->delete( $wpdb->prefix . "ac_sent_history_lite", array( 'abandoned_order_id' => $abandoned_id ) );
101
+
102
+ // delete the user meta for the user
103
+ $query_delete_cart = $wpdb->delete( $wpdb->prefix . "usermeta", array( 'user_id' => $user_id, 'meta_key' => '_woocommerce_persistent_cart' ) );
104
+
105
+ // delete the cart history table record
106
+ $query = $wpdb->delete( $wpdb->prefix . "ac_abandoned_cart_history_lite", array( 'user_id' => $user_id, 'id' => $abandoned_id ) );
107
+
108
+ // delete the guest cart record if applicable
109
+ if( 'GUEST' == $user_type && $user_id >= 63000000 ) {
110
+ $guest_query = $wpdb->delete( $wpdb->prefix . "ac_guest_abandoned_cart_history_lite", array( 'id' => $user_id ) );
111
  }
112
  }
113
+ }
114
+ }
{woocommerce-abandoned-cart/includes → includes}/wcal_admin_notice.php RENAMED
@@ -22,7 +22,7 @@ class Wcal_Admin_Notice {
22
  */
23
  public static function wcal_show_db_update_notice(){
24
 
25
- if( isset( $_GET['ac_update'] ) && $_GET['ac_update'] == 'email_templates' ){
26
  return;
27
  }
28
 
@@ -39,4 +39,4 @@ class Wcal_Admin_Notice {
39
  }
40
  }
41
  }
42
- }
22
  */
23
  public static function wcal_show_db_update_notice(){
24
 
25
+ if( isset( $_GET['ac_update'] ) && 'email_templates' == $_GET['ac_update'] ) {
26
  return;
27
  }
28
 
39
  }
40
  }
41
  }
42
+ }
{woocommerce-abandoned-cart/includes → includes}/wcal_all_component.php RENAMED
@@ -8,21 +8,22 @@
8
  if ( ! defined( 'ABSPATH' ) ) {
9
  exit; // Exit if accessed directly.
10
  }
 
11
  if ( ! class_exists( 'Wcal_All_Component' ) ) {
12
- /**
13
- * It will Add all the Boilerplate component when we activate the plugin.
14
- *
15
- */
16
- class Wcal_All_Component {
17
-
18
- /**
19
- * It will Add all the Boilerplate component when we activate the plugin.
20
- */
21
- public function __construct() {
22
 
23
- $is_admin = is_admin();
24
 
25
- if ( true === $is_admin ) {
26
 
27
  require_once( "component/WooCommerce-Check/ts-woo-active.php" );
28
 
@@ -70,7 +71,7 @@ if ( ! class_exists( 'Wcal_All_Component' ) ) {
70
  new Wcal_TS_Faq_Support( $wcal_plugin_name, $wcal_plugin_prefix, $wcal_plugins_page, $wcal_locale, $wcal_plugin_folder_name, $wcal_plugin_slug, $ts_pro_faq );
71
 
72
  /*$ts_pro_notices = self::wcal_get_notice_text ();
73
- new Wcal_ts_pro_notices( $wcal_plugin_name, $wcal_lite_plugin_prefix, $wcal_plugin_prefix, $ts_pro_notices, $wcal_file_name, $wcal_pro_file_name );*/
74
 
75
  }
76
  }
@@ -83,36 +84,36 @@ if ( ! class_exists( 'Wcal_All_Component' ) ) {
83
  $ts_pro_notices = array();
84
 
85
  $wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=wpnotice&utm_medium=first&utm_campaign=AbandonedCartLitePlugin';
86
- $wcal_pro_diff = 'https://www.tychesoftwares.com/differences-between-pro-and-lite-versions-of-abandoned-cart-for-woocommerce-plugin/';
87
- $message_first = wp_kses_post ( __( 'Now that you are all set with the Lite version, you can upgrade to Pro version to take your abandoned cart recovery to the next level. You can capture customer’s email address when they click Add to Cart, get access to 11 unique, fully responsive email templates, send text messages for recovery & <strong><a target="_blank" href= "'.$wcal_pro_diff.'">much more</a></strong>. <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'">Purchase now</a></strong>.', 'woocommerce-abandoned-cart' ) );
88
 
89
  $wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=wpnotice&utm_medium=second&utm_campaign=AbandonedCartLitePlugin';
90
- $message_two = wp_kses_post ( __( 'Boost your sales by recovering up to 60% of the abandoned carts with our Abandoned Cart Pro for WooCommerce plugin. You can capture customer email addresses right when they click the Add To Cart button. <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'"> Grab your copy of Abandon Cart Pro plugin now!</a></strong>', 'woocommerce-abandoned-cart' ) );
91
 
92
  $wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=wpnotice&utm_medium=third&utm_campaign=AbandonedCartLitePlugin';
93
- $message_three = wp_kses_post ( __( 'Don\'t loose your sales to abandoned carts. Use our Abandon Cart Pro plugin & start recovering your lost sales in less then 60 seconds. <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'">Grab it now!</a></strong>.', 'woocommerce-abandoned-cart' ) );
94
 
95
  $wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=wpnotice&utm_medium=fourth&utm_campaign=AbandonedCartLitePlugin';
96
- $message_four = wp_kses_post ( __( 'Send Abandoned Cart reminders that actually convert. Take advantage of our fully responsive email templates designed specially with an intent to trigger conversion. <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'">Purchase now</a></strong>.', 'woocommerce-abandoned-cart' ) );
97
 
98
  $wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=wpnotice&utm_medium=fifth&utm_campaign=AbandonedCartLitePlugin';
99
- $message_five = wp_kses_post ( __( 'Increase your store sales by recovering your abandoned carts for just $119. No profit sharing, no monthly fees. Our Abandoned Cart Pro plugin comes with a 30 day money back guarantee as well. :) Use coupon code ACPRO20 & save $24!<br>
100
  <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'">Grab your copy now!</a></strong>', 'woocommerce-abandoned-cart' ) );
101
 
102
- $_link = 'https://www.tychesoftwares.com/store/premium-plugins/order-delivery-date-for-woocommerce-pro-21/?utm_source=wpnotice&utm_medium=sixth&utm_campaign=AbandonedCartLitePlugin';
103
- $message_six = wp_kses_post ( __( 'Reduce cart abandonment rate by 57% with our Order Delivery Date Pro WooCommerce plugin. You can Create Delivery Settings by Shipping Zones & Shipping Classes. <br>Use discount code "ORDPRO20" and grab 20% discount on the purchase of the plugin. The discount code is valid only for the first 20 customers. <strong><a target="_blank" href= "'.$_link.'">Purchase now</a></strong>', 'woocommerce-abandoned-cart' ) );
104
 
105
- $_link = 'https://www.tychesoftwares.com/store/premium-plugins/product-delivery-date-pro-for-woocommerce/?utm_source=wpnotice&utm_medium=seventh&utm_campaign=AbandonedCartLitePlugin';
106
- $message_seven = wp_kses_post ( __( 'Allow your customers to select the Delivery Date on Single Product Page using our Product Delivery Date pro for WooCommerce Plugin. <br>
107
  <strong><a target="_blank" href= "'.$_link.'">Shop now</a></strong> & be one of the 20 customers to get 20% discount on the plugin price. Use the code "PRDPRO20". Hurry!!', 'woocommerce-abandoned-cart' ) );
108
 
109
- $_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-booking-plugin/?utm_source=wpnotice&utm_medium=eight&utm_campaign=AbandonedCartLitePlugin';
110
- $message_eight = wp_kses_post ( __( ' Allow your customers to book an appointment or rent an apartment with our Booking and Appointment for WooCommerce plugin. You can also sell your product as a resource or integrate with a few Vendor plugins. <br>Shop now & Save 20% on the plugin with the code "BKAP20". Only for first 20 customers. <strong><a target="_blank" href= "'.$_link.'">Have it now!</a></strong>', 'woocommerce-abandoned-cart' ) );
111
 
112
- $_link = 'https://www.tychesoftwares.com/store/premium-plugins/deposits-for-woocommerce/?utm_source=wpnotice&utm_medium=eight&utm_campaign=AbandonedCartLitePlugin';
113
- $message_nine = wp_kses_post ( __( ' Allow your customers to pay deposits on products using our Deposits for WooCommerce plugin. <br>
114
  <strong><a target="_blank" href= "'.$_link.'">Purchase now</a></strong> & Grab 20% discount with the code "DFWP20". The discount code is valid only for the first 20 customers.', 'woocommerce-abandoned-cart' ) );
115
-
116
  $ts_pro_notices = array (
117
  1 => $message_first,
118
  2 => $message_two,
@@ -127,8 +128,8 @@ if ( ! class_exists( 'Wcal_All_Component' ) ) {
127
 
128
  return $ts_pro_notices;
129
  }
130
-
131
- /**
132
  * It will contain all the FAQ which need to be display on the FAQ page.
133
  * @return array $ts_faq All questions and answers.
134
  *
@@ -151,24 +152,24 @@ if ( ! class_exists( 'Wcal_All_Component' ) ) {
151
  When logged-in user add the product to the cart we capture the email address from the user’s profile.'
152
  ),
153
  3 => array (
154
- 'question' => 'I want to know if it is possible to exclude tax from product price for abandoned order.',
155
- 'answer' => 'Currently it is not possible to exclude tax from the product price from the abandoned order view if tax is applicable for the product.'
156
  ),
157
  4 => array (
158
- 'question' => 'Is it possible to delete thousands of or all abandoned cart records at a once?',
159
- 'answer' => 'No, it is not possible to delete thousands of abandoned cart records in bulk. Our plugin does have the Bulk action functionality. But you can delete upto 30 Abandoned Carts in bulk. You can run a SQL query in the Database to delete those carts. For detailed steps please contact us via Support.'
160
  ),
161
  5 => array (
162
- 'question' => 'Is there any way to not capture the visitors carts?',
163
- 'answer' => 'You can uncheck the “Start tracking from Cart Page” setting under the General Settings menu of the Settings tab.'
164
  ),
165
  6 => array (
166
- 'question' => 'How can I know that abandoned cart reminders are being sent to customers?',
167
- 'answer' => 'It is not possible in the Abandoned Cart LITE plugin to check the records of the Abandoned Cart Reminder email whether email notifications are being sent or not. However you can upgrade to PRO version of our plugin to enable this feature.'
168
  ),
169
  7 => array (
170
- 'question' => 'Is there an alternate way to send the abandon cart emails automatically at regular intervals? As the WP-Cron is not running on my site.',
171
- 'answer' => 'Yes, you can setup a manual cron in your server’s administration panel.
172
  <br/><br/>
173
  For example, if you are using cPanel, it has a section Named as "Cron Jobs" which allows you to create the cron job.
174
  <br/><br/>
@@ -177,21 +178,21 @@ if ( ! class_exists( 'Wcal_All_Component' ) ) {
177
  You can refer to this document for creating a <a href="https://documentation.cpanel.net/display/68Docs/Cron+Jobs">cron job</a> in cPanel.'
178
  ),
179
  8 => array (
180
- 'question' => 'Does the plugin consider the cart as abandoned for Pending and Failed order status?',
181
- 'answer' => 'Yes, our plugin considers such carts (Pending Payment and Failed orders) as abandoned. It will send the abandoned cart reminder email to the customers if they fail to proceed with the payment after Cart abandoned cut off time reached.'
182
  ),
183
  9 => array (
184
- 'question' => 'How can we translate the strings of {{products.cart}} merge tag in the email?',
185
- 'answer' => 'To translate the strings, you need to generate ".po" and ".mo" files in your respective language. These files then need to be added to the following path: "woocommerce-abandoned-cart/i18n/languages"'
186
  ),
187
  10 => array (
188
- 'question' => 'There was a problem creating an email template on Multisite.',
189
- 'answer' => 'On Multisite, if you have activated the plugin from Network site then please deactivate it and activate the Abandoned Cart Lite plugin from an Individual site. So, one default email template will be created on the activation of the plugin and you can create new email template.'
190
  )
191
  );
192
 
193
  return $ts_faq;
194
  }
195
- }
196
- $Wcal_All_Component = new Wcal_All_Component();
197
  }
8
  if ( ! defined( 'ABSPATH' ) ) {
9
  exit; // Exit if accessed directly.
10
  }
11
+
12
  if ( ! class_exists( 'Wcal_All_Component' ) ) {
13
+ /**
14
+ * It will Add all the Boilerplate component when we activate the plugin.
15
+ *
16
+ */
17
+ class Wcal_All_Component {
18
+
19
+ /**
20
+ * It will Add all the Boilerplate component when we activate the plugin.
21
+ */
22
+ public function __construct() {
23
 
24
+ $is_admin = is_admin();
25
 
26
+ if ( true === $is_admin ) {
27
 
28
  require_once( "component/WooCommerce-Check/ts-woo-active.php" );
29
 
71
  new Wcal_TS_Faq_Support( $wcal_plugin_name, $wcal_plugin_prefix, $wcal_plugins_page, $wcal_locale, $wcal_plugin_folder_name, $wcal_plugin_slug, $ts_pro_faq );
72
 
73
  /*$ts_pro_notices = self::wcal_get_notice_text ();
74
+ new Wcal_ts_pro_notices( $wcal_plugin_name, $wcal_lite_plugin_prefix, $wcal_plugin_prefix, $ts_pro_notices, $wcal_file_name, $wcal_pro_file_name );*/
75
 
76
  }
77
  }
84
  $ts_pro_notices = array();
85
 
86
  $wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=wpnotice&utm_medium=first&utm_campaign=AbandonedCartLitePlugin';
87
+ $wcal_pro_diff = 'https://www.tychesoftwares.com/differences-between-pro-and-lite-versions-of-abandoned-cart-for-woocommerce-plugin/';
88
+ $message_first = wp_kses_post ( __( 'Now that you are all set with the Lite version, you can upgrade to Pro version to take your abandoned cart recovery to the next level. You can capture customer’s email address when they click Add to Cart, get access to 11 unique, fully responsive email templates, send text messages for recovery & <strong><a target="_blank" href= "'.$wcal_pro_diff.'">much more</a></strong>. <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'">Purchase now</a></strong>.', 'woocommerce-abandoned-cart' ) );
89
 
90
  $wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=wpnotice&utm_medium=second&utm_campaign=AbandonedCartLitePlugin';
91
+ $message_two = wp_kses_post ( __( 'Boost your sales by recovering up to 60% of the abandoned carts with our Abandoned Cart Pro for WooCommerce plugin. You can capture customer email addresses right when they click the Add To Cart button. <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'"> Grab your copy of Abandon Cart Pro plugin now!</a></strong>', 'woocommerce-abandoned-cart' ) );
92
 
93
  $wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=wpnotice&utm_medium=third&utm_campaign=AbandonedCartLitePlugin';
94
+ $message_three = wp_kses_post ( __( 'Don\'t loose your sales to abandoned carts. Use our Abandon Cart Pro plugin & start recovering your lost sales in less then 60 seconds. <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'">Grab it now!</a></strong>.', 'woocommerce-abandoned-cart' ) );
95
 
96
  $wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=wpnotice&utm_medium=fourth&utm_campaign=AbandonedCartLitePlugin';
97
+ $message_four = wp_kses_post ( __( 'Send Abandoned Cart reminders that actually convert. Take advantage of our fully responsive email templates designed specially with an intent to trigger conversion. <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'">Purchase now</a></strong>.', 'woocommerce-abandoned-cart' ) );
98
 
99
  $wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=wpnotice&utm_medium=fifth&utm_campaign=AbandonedCartLitePlugin';
100
+ $message_five = wp_kses_post ( __( 'Increase your store sales by recovering your abandoned carts for just $119. No profit sharing, no monthly fees. Our Abandoned Cart Pro plugin comes with a 30 day money back guarantee as well. :) Use coupon code ACPRO20 & save $24!<br>
101
  <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'">Grab your copy now!</a></strong>', 'woocommerce-abandoned-cart' ) );
102
 
103
+ $_link = 'https://www.tychesoftwares.com/store/premium-plugins/order-delivery-date-for-woocommerce-pro-21/?utm_source=wpnotice&utm_medium=sixth&utm_campaign=AbandonedCartLitePlugin';
104
+ $message_six = wp_kses_post ( __( 'Reduce cart abandonment rate by 57% with our Order Delivery Date Pro WooCommerce plugin. You can Create Delivery Settings by Shipping Zones & Shipping Classes. <br>Use discount code "ORDPRO20" and grab 20% discount on the purchase of the plugin. The discount code is valid only for the first 20 customers. <strong><a target="_blank" href= "'.$_link.'">Purchase now</a></strong>', 'woocommerce-abandoned-cart' ) );
105
 
106
+ $_link = 'https://www.tychesoftwares.com/store/premium-plugins/product-delivery-date-pro-for-woocommerce/?utm_source=wpnotice&utm_medium=seventh&utm_campaign=AbandonedCartLitePlugin';
107
+ $message_seven = wp_kses_post ( __( 'Allow your customers to select the Delivery Date on Single Product Page using our Product Delivery Date pro for WooCommerce Plugin. <br>
108
  <strong><a target="_blank" href= "'.$_link.'">Shop now</a></strong> & be one of the 20 customers to get 20% discount on the plugin price. Use the code "PRDPRO20". Hurry!!', 'woocommerce-abandoned-cart' ) );
109
 
110
+ $_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-booking-plugin/?utm_source=wpnotice&utm_medium=eight&utm_campaign=AbandonedCartLitePlugin';
111
+ $message_eight = wp_kses_post ( __( ' Allow your customers to book an appointment or rent an apartment with our Booking and Appointment for WooCommerce plugin. You can also sell your product as a resource or integrate with a few Vendor plugins. <br>Shop now & Save 20% on the plugin with the code "BKAP20". Only for first 20 customers. <strong><a target="_blank" href= "'.$_link.'">Have it now!</a></strong>', 'woocommerce-abandoned-cart' ) );
112
 
113
+ $_link = 'https://www.tychesoftwares.com/store/premium-plugins/deposits-for-woocommerce/?utm_source=wpnotice&utm_medium=eight&utm_campaign=AbandonedCartLitePlugin';
114
+ $message_nine = wp_kses_post ( __( ' Allow your customers to pay deposits on products using our Deposits for WooCommerce plugin. <br>
115
  <strong><a target="_blank" href= "'.$_link.'">Purchase now</a></strong> & Grab 20% discount with the code "DFWP20". The discount code is valid only for the first 20 customers.', 'woocommerce-abandoned-cart' ) );
116
+
117
  $ts_pro_notices = array (
118
  1 => $message_first,
119
  2 => $message_two,
128
 
129
  return $ts_pro_notices;
130
  }
131
+
132
+ /**
133
  * It will contain all the FAQ which need to be display on the FAQ page.
134
  * @return array $ts_faq All questions and answers.
135
  *
152
  When logged-in user add the product to the cart we capture the email address from the user’s profile.'
153
  ),
154
  3 => array (
155
+ 'question' => 'I want to know if it is possible to exclude tax from product price for abandoned order.',
156
+ 'answer' => 'Currently it is not possible to exclude tax from the product price from the abandoned order view if tax is applicable for the product.'
157
  ),
158
  4 => array (
159
+ 'question' => 'Is it possible to delete thousands of or all abandoned cart records at a once?',
160
+ 'answer' => 'No, it is not possible to delete thousands of abandoned cart records in bulk. Our plugin does have the Bulk action functionality. But you can delete upto 30 Abandoned Carts in bulk. You can run a SQL query in the Database to delete those carts. For detailed steps please contact us via Support.'
161
  ),
162
  5 => array (
163
+ 'question' => 'Is there any way to not capture the visitors carts?',
164
+ 'answer' => 'You can uncheck the “Start tracking from Cart Page” setting under the General Settings menu of the Settings tab.'
165
  ),
166
  6 => array (
167
+ 'question' => 'How can I know that abandoned cart reminders are being sent to customers?',
168
+ 'answer' => 'It is not possible in the Abandoned Cart LITE plugin to check the records of the Abandoned Cart Reminder email whether email notifications are being sent or not. However you can upgrade to PRO version of our plugin to enable this feature.'
169
  ),
170
  7 => array (
171
+ 'question' => 'Is there an alternate way to send the abandon cart emails automatically at regular intervals? As the WP-Cron is not running on my site.',
172
+ 'answer' => 'Yes, you can setup a manual cron in your server’s administration panel.
173
  <br/><br/>
174
  For example, if you are using cPanel, it has a section Named as "Cron Jobs" which allows you to create the cron job.
175
  <br/><br/>
178
  You can refer to this document for creating a <a href="https://documentation.cpanel.net/display/68Docs/Cron+Jobs">cron job</a> in cPanel.'
179
  ),
180
  8 => array (
181
+ 'question' => 'Does the plugin consider the cart as abandoned for Pending and Failed order status?',
182
+ 'answer' => 'Yes, our plugin considers such carts (Pending Payment and Failed orders) as abandoned. It will send the abandoned cart reminder email to the customers if they fail to proceed with the payment after Cart abandoned cut off time reached.'
183
  ),
184
  9 => array (
185
+ 'question' => 'How can we translate the strings of {{products.cart}} merge tag in the email?',
186
+ 'answer' => 'To translate the strings, you need to generate ".po" and ".mo" files in your respective language. These files then need to be added to the following path: "woocommerce-abandoned-cart/i18n/languages"'
187
  ),
188
  10 => array (
189
+ 'question' => 'There was a problem creating an email template on Multisite.',
190
+ 'answer' => 'On Multisite, if you have activated the plugin from Network site then please deactivate it and activate the Abandoned Cart Lite plugin from an Individual site. So, one default email template will be created on the activation of the plugin and you can create new email template.'
191
  )
192
  );
193
 
194
  return $ts_faq;
195
  }
196
+ }
197
+ $Wcal_All_Component = new Wcal_All_Component();
198
  }
{woocommerce-abandoned-cart/includes → includes}/wcal_class-guest.php RENAMED
@@ -83,83 +83,79 @@ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
83
  * @globals mixed $woocommerce
84
  * @since 2.2
85
  */
86
- function save_data() {
87
- if ( ! is_user_logged_in() ) {
88
- if( session_id() === '' ) {
89
- //session has not started
90
- session_start();
91
- }
92
  global $wpdb, $woocommerce;
93
  if ( isset($_POST['billing_first_name']) && $_POST['billing_first_name'] != '' ){
94
- $_SESSION['billing_first_name'] = $_POST['billing_first_name'];
95
- }
96
  if ( isset($_POST['billing_last_name']) && $_POST['billing_last_name'] != '' ) {
97
- $_SESSION['billing_last_name'] = $_POST['billing_last_name'];
98
  }
99
  if ( isset($_POST['billing_company']) && $_POST['billing_company'] != '' ) {
100
- $_SESSION['billing_company'] = $_POST['billing_company'];
101
  }
102
  if ( isset($_POST['billing_address_1']) && $_POST['billing_address_1'] != '' ) {
103
- $_SESSION['billing_address_1'] = $_POST['billing_address_1'];
104
  }
105
  if ( isset($_POST['billing_address_2']) && $_POST['billing_address_2'] != '' ) {
106
- $_SESSION['billing_address_2'] = $_POST['billing_address_2'];
107
  }
108
  if ( isset($_POST['billing_city']) && $_POST['billing_city'] != '' ) {
109
- $_SESSION['billing_city'] = $_POST['billing_city'];
110
  }
111
  if ( isset($_POST['billing_state']) && $_POST['billing_state'] != '' ) {
112
- $_SESSION['billing_state'] = $_POST['billing_state'];
113
  }
114
  if ( isset($_POST['billing_postcode']) && $_POST['billing_postcode'] != '' ) {
115
- $_SESSION['billing_postcode'] = $_POST['billing_postcode'];
116
  }
117
  if ( isset($_POST['billing_country']) && $_POST['billing_country'] != '' ) {
118
- $_SESSION['billing_country'] = $_POST['billing_country'];
119
  }
120
  if ( isset($_POST['billing_email']) && $_POST['billing_email'] != '' ) {
121
- $_SESSION['billing_email'] = $_POST['billing_email'];
122
  }
123
  if ( isset($_POST['billing_phone']) && $_POST['billing_phone'] != '' ) {
124
- $_SESSION['billing_phone'] = $_POST['billing_phone'];
125
  }
126
  if ( isset($_POST['order_notes']) && $_POST['order_notes'] != '' ) {
127
- $_SESSION['order_notes'] = $_POST['order_notes'];
128
  }
129
  if( isset( $_POST['ship_to_billing'] ) && $_POST['ship_to_billing'] != '' ) {
130
- $_SESSION['ship_to_billing'] = $_POST['ship_to_billing'];
131
  }
132
  if ( isset($_POST['shipping_first_name']) && $_POST['shipping_first_name'] != '' ) {
133
- $_SESSION['shipping_first_name'] = $_POST['shipping_first_name'];
134
  }
135
  if ( isset($_POST['shipping_last_name']) && $_POST['shipping_last_name'] != '' ) {
136
- $_SESSION['shipping_last_name'] = $_POST['shipping_last_name'];
137
  }
138
  if ( isset($_POST['shipping_company']) && $_POST['shipping_company'] != '' ) {
139
- $_SESSION['shipping_company'] = $_POST['shipping_company'];
140
  }
141
  if ( isset($_POST['shipping_address_1']) && $_POST['shipping_address_1'] != '' ) {
142
- $_SESSION['shipping_address_1'] = $_POST['shipping_address_1'];
143
  }
144
  if ( isset($_POST['shipping_address_2']) && $_POST['shipping_address_2'] != '' ) {
145
- $_SESSION['shipping_address_2'] = $_POST['shipping_address_2'];
146
  }
147
  if ( isset($_POST['shipping_city']) && $_POST['shipping_city'] != '' ) {
148
- $_SESSION['shipping_city'] = $_POST['shipping_city'];
149
  }
150
  if ( isset($_POST['shipping_state']) && $_POST['shipping_state'] != '' ) {
151
- $_SESSION['shipping_state'] = $_POST['shipping_state'];
152
  }
153
  if ( isset($_POST['shipping_postcode']) && $_POST['shipping_postcode'] != '' ) {
154
- $_SESSION['shipping_postcode'] = $_POST['shipping_postcode'];
155
  }
156
  if ( isset($_POST['shipping_country']) && $_POST['shipping_country'] != '' ) {
157
- $_SESSION['shipping_country'] = $_POST['shipping_country'];
158
  }
159
  // If a record is present in the guest cart history table for the same email id, then delete the previous records
160
  $query_guest = "SELECT id FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite`
161
  WHERE email_id = %s";
162
- $results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $_SESSION['billing_email'] ) );
163
 
164
  if ( $results_guest ) {
165
  foreach ( $results_guest as $key => $value ) {
@@ -176,111 +172,105 @@ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
176
  }
177
  }
178
  // Insert record in guest table
179
- if ( isset( $_SESSION['billing_first_name'] ) ) {
180
- $billing_first_name = $_SESSION['billing_first_name'];
181
- } else {
182
- $billing_first_name = '';
183
- }
184
- if ( isset( $_SESSION['billing_last_name'] ) ) {
185
- $billing_last_name = $_SESSION['billing_last_name'];
186
- } else {
187
- $billing_last_name = '';
188
- }
189
  $shipping_zipcode = $billing_zipcode = '';
190
-
191
- if ( isset( $_SESSION['shipping_postcode'] ) && $_SESSION['shipping_postcode'] != "" ) {
192
- $shipping_zipcode = $_SESSION['shipping_postcode'];
193
- } elseif( isset( $_SESSION['billing_postcode'] ) && $_SESSION['billing_postcode'] != "" ) {
194
- $shipping_zipcode = $billing_zipcode = $_SESSION['billing_postcode'];
195
  }
196
  $shipping_charges = $woocommerce->cart->shipping_total;
197
  $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 )
198
- VALUES ( '".$billing_first_name."', '".$billing_last_name."', '".$_SESSION['billing_email']."', '".$billing_zipcode."', '".$shipping_zipcode."', '".$shipping_charges."' )";
199
  $wpdb->query( $insert_guest );
200
 
201
  //Insert record in abandoned cart table for the guest user
202
  $user_id = $wpdb->insert_id;
203
- $_SESSION['user_id'] = $user_id;
204
  $current_time = current_time( 'timestamp' );
205
  $cut_off_time = get_option( 'ac_cart_abandoned_time' );
206
  $cart_cut_off_time = $cut_off_time * 60;
207
  $compare_time = $current_time - $cart_cut_off_time;
208
 
209
- $query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
210
- WHERE user_id = %d AND cart_ignored = '0' AND recovered_cart = '0' AND user_type = 'GUEST'";
211
  $results = $wpdb->get_results( $wpdb->prepare( $query, $user_id ) );
212
 
213
  $cart = array();
214
 
215
- if ( function_exists('WC') ) {
216
  $cart['cart'] = WC()->session->cart;
217
  } else {
218
  $cart['cart'] = $woocommerce->session->cart;
219
  }
220
 
221
- if ( count( $results ) == 0 ) {
222
- $get_cookie = WC()->session->get_session_cookie();
223
- $cart_info = addslashes( json_encode( $cart ) );
224
 
225
- $query = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
226
- WHERE session_id LIKE %s AND cart_ignored = '0' AND recovered_cart = '0' ";
227
- $results = $wpdb->get_results( $wpdb->prepare( $query, $get_cookie[0] ) );
228
 
229
- if ( count( $results ) == 0 ) {
230
  $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, session_id )
231
  VALUES ( '".$user_id."', '".$cart_info."', '".$current_time."', '0', '0', 'GUEST', '".$get_cookie[0] ."' )";
232
  $wpdb->query( $insert_query );
233
 
234
- $abandoned_cart_id = $wpdb->insert_id;
235
- $_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
236
 
237
  // $insert_persistent_cart = "INSERT INTO `".$wpdb->prefix."usermeta`( user_id, meta_key, meta_value )
238
  // VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
239
  // $wpdb->query( $insert_persistent_cart );
240
- if( is_multisite() ) {
241
- // get main site's table prefix
242
- $main_prefix = $wpdb->get_blog_prefix(1);
243
- $insert_persistent_cart = "INSERT INTO `" . $main_prefix . "usermeta`( user_id, meta_key, meta_value )
244
- VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
245
- $wpdb->query( $insert_persistent_cart );
246
 
247
- } else {
248
- $insert_persistent_cart = "INSERT INTO `" . $wpdb->prefix . "usermeta`( user_id, meta_key, meta_value )
249
- VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
250
- $wpdb->query( $insert_persistent_cart );
251
  }
252
  } else {
253
- $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' ";
254
  $wpdb->query( $query_update );
255
- $query_update_get = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
256
- WHERE user_id ='" . $user_id . "' AND cart_ignored='0' AND session_id ='" . $get_cookie[0] . "' ";
257
  $get_abandoned_record = $wpdb->get_results( $query_update_get );
258
 
259
  if ( count( $get_abandoned_record ) > 0 ) {
260
- $abandoned_cart_id = $get_abandoned_record[0]->id;
261
- $_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
262
  }
263
 
264
  $insert_persistent_cart = "INSERT INTO `".$wpdb->prefix."usermeta`( user_id, meta_key, meta_value )
265
  VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
266
  $wpdb->query( $insert_persistent_cart );
267
- if( is_multisite() ) {
268
  // get main site's table prefix
269
- $main_prefix = $wpdb->get_blog_prefix(1);
270
  $insert_persistent_cart = "INSERT INTO `" . $main_prefix . "usermeta`( user_id, meta_key, meta_value )
271
- VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
272
  $wpdb->query( $insert_persistent_cart );
273
 
274
  } else {
275
  $insert_persistent_cart = "INSERT INTO `" . $wpdb->prefix . "usermeta`( user_id, meta_key, meta_value )
276
  VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
277
  $wpdb->query( $insert_persistent_cart );
 
278
  }
279
- }
280
  }
281
  }
282
  }
283
-
284
  /**
285
  * It will populate the data on the chekout field if user comes from the abandoned cart reminder emails.
286
  * @hook woocommerce_checkout_fields
@@ -289,17 +279,17 @@ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
289
  * @since 2.2
290
  */
291
  function guest_checkout_fields( $fields ) {
292
- if ( isset( $_SESSION['guest_first_name'] ) && $_SESSION['guest_first_name'] != "" ) {
293
- $_POST['billing_first_name'] = $_SESSION['guest_first_name'];
 
 
 
294
  }
295
- if ( isset( $_SESSION['guest_last_name'] ) && $_SESSION['guest_last_name'] != "" ) {
296
- $_POST['billing_last_name'] = $_SESSION['guest_last_name'];
297
  }
298
- if ( isset( $_SESSION['guest_email']) && $_SESSION['guest_email'] != "" ) {
299
- $_POST['billing_email'] = $_SESSION['guest_email'];
300
- }
301
- if ( isset( $_SESSION['guest_phone']) && $_SESSION['guest_phone'] != "" ) {
302
- $_POST['billing_phone'] = $_SESSION['guest_phone'];
303
  }
304
  return $fields;
305
  }
83
  * @globals mixed $woocommerce
84
  * @since 2.2
85
  */
86
+ function save_data() {
87
+ if ( ! is_user_logged_in() ) {
 
 
 
 
88
  global $wpdb, $woocommerce;
89
  if ( isset($_POST['billing_first_name']) && $_POST['billing_first_name'] != '' ){
90
+ wcal_common::wcal_set_cart_session( 'billing_first_name', $_POST['billing_first_name'] );
91
+ }
92
  if ( isset($_POST['billing_last_name']) && $_POST['billing_last_name'] != '' ) {
93
+ wcal_common::wcal_set_cart_session( 'billing_last_name', $_POST['billing_last_name'] );
94
  }
95
  if ( isset($_POST['billing_company']) && $_POST['billing_company'] != '' ) {
96
+ wcal_common::wcal_set_cart_session( 'billing_company', $_POST['billing_company'] );
97
  }
98
  if ( isset($_POST['billing_address_1']) && $_POST['billing_address_1'] != '' ) {
99
+ wcal_common::wcal_set_cart_session( 'billing_address_1', $_POST['billing_address_1'] );
100
  }
101
  if ( isset($_POST['billing_address_2']) && $_POST['billing_address_2'] != '' ) {
102
+ wcal_common::wcal_set_cart_session( 'billing_address_2', $_POST['billing_address_2'] );
103
  }
104
  if ( isset($_POST['billing_city']) && $_POST['billing_city'] != '' ) {
105
+ wcal_common::wcal_set_cart_session( 'billing_city', $_POST['billing_city'] );
106
  }
107
  if ( isset($_POST['billing_state']) && $_POST['billing_state'] != '' ) {
108
+ wcal_common::wcal_set_cart_session( 'billing_state', $_POST['billing_state'] );
109
  }
110
  if ( isset($_POST['billing_postcode']) && $_POST['billing_postcode'] != '' ) {
111
+ wcal_common::wcal_set_cart_session( 'billing_postcode', $_POST['billing_postcode'] );
112
  }
113
  if ( isset($_POST['billing_country']) && $_POST['billing_country'] != '' ) {
114
+ wcal_common::wcal_set_cart_session( 'billing_country', $_POST['billing_country'] );
115
  }
116
  if ( isset($_POST['billing_email']) && $_POST['billing_email'] != '' ) {
117
+ wcal_common::wcal_set_cart_session( 'billing_email', $_POST['billing_email'] );
118
  }
119
  if ( isset($_POST['billing_phone']) && $_POST['billing_phone'] != '' ) {
120
+ wcal_common::wcal_set_cart_session( 'billing_phone', $_POST['billing_phone'] );
121
  }
122
  if ( isset($_POST['order_notes']) && $_POST['order_notes'] != '' ) {
123
+ wcal_common::wcal_set_cart_session( 'order_notes', $_POST['order_notes'] );
124
  }
125
  if( isset( $_POST['ship_to_billing'] ) && $_POST['ship_to_billing'] != '' ) {
126
+ wcal_common::wcal_set_cart_session( 'ship_to_billing', $_POST['ship_to_billing'] );
127
  }
128
  if ( isset($_POST['shipping_first_name']) && $_POST['shipping_first_name'] != '' ) {
129
+ wcal_common::wcal_set_cart_session( 'shipping_first_name', $_POST['shipping_first_name'] );
130
  }
131
  if ( isset($_POST['shipping_last_name']) && $_POST['shipping_last_name'] != '' ) {
132
+ wcal_common::wcal_set_cart_session( 'shipping_last_name', $_POST['shipping_last_name'] );
133
  }
134
  if ( isset($_POST['shipping_company']) && $_POST['shipping_company'] != '' ) {
135
+ wcal_common::wcal_set_cart_session( 'shipping_company', $_POST['shipping_company'] );
136
  }
137
  if ( isset($_POST['shipping_address_1']) && $_POST['shipping_address_1'] != '' ) {
138
+ wcal_common::wcal_set_cart_session( 'shipping_address_1', $_POST['shipping_address_1'] );
139
  }
140
  if ( isset($_POST['shipping_address_2']) && $_POST['shipping_address_2'] != '' ) {
141
+ wcal_common::wcal_set_cart_session( 'shipping_address_2', $_POST['shipping_address_2'] );
142
  }
143
  if ( isset($_POST['shipping_city']) && $_POST['shipping_city'] != '' ) {
144
+ wcal_common::wcal_set_cart_session( 'shipping_city', $_POST['shipping_city'] );
145
  }
146
  if ( isset($_POST['shipping_state']) && $_POST['shipping_state'] != '' ) {
147
+ wcal_common::wcal_set_cart_session( 'shipping_state', $_POST['shipping_state'] );
148
  }
149
  if ( isset($_POST['shipping_postcode']) && $_POST['shipping_postcode'] != '' ) {
150
+ wcal_common::wcal_set_cart_session( 'shipping_postcode', $_POST['shipping_postcode'] );
151
  }
152
  if ( isset($_POST['shipping_country']) && $_POST['shipping_country'] != '' ) {
153
+ wcal_common::wcal_set_cart_session( 'shipping_country', $_POST['shipping_country'] );
154
  }
155
  // If a record is present in the guest cart history table for the same email id, then delete the previous records
156
  $query_guest = "SELECT id FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite`
157
  WHERE email_id = %s";
158
+ $results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, wcal_common::wcal_get_cart_session( 'billing_email' ) ) );
159
 
160
  if ( $results_guest ) {
161
  foreach ( $results_guest as $key => $value ) {
172
  }
173
  }
174
  // Insert record in guest table
175
+ $billing_first_name = wcal_common::wcal_get_cart_session( 'billing_first_name' );
176
+
177
+ $billing_last_name = wcal_common::wcal_get_cart_session( 'billing_last_name' );
178
+
 
 
 
 
 
 
179
  $shipping_zipcode = $billing_zipcode = '';
180
+
181
+ if ( wcal_common::wcal_get_cart_session( 'shipping_postcode' ) != "" ) {
182
+ $shipping_zipcode = wcal_common::wcal_get_cart_session( 'shipping_postcode' );
183
+ } elseif( wcal_common::wcal_get_cart_session( 'billing_postcode' ) != "" ) {
184
+ $shipping_zipcode = $billing_zipcode = wcal_common::wcal_get_cart_session( 'billing_postcode' );
185
  }
186
  $shipping_charges = $woocommerce->cart->shipping_total;
187
  $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 )
188
+ VALUES ( '".$billing_first_name."', '".$billing_last_name."', '".wcal_common::wcal_get_cart_session( 'billing_email' )."', '".$billing_zipcode."', '".$shipping_zipcode."', '".$shipping_charges."' )";
189
  $wpdb->query( $insert_guest );
190
 
191
  //Insert record in abandoned cart table for the guest user
192
  $user_id = $wpdb->insert_id;
193
+ wcal_common::wcal_set_cart_session( 'user_id', $user_id );
194
  $current_time = current_time( 'timestamp' );
195
  $cut_off_time = get_option( 'ac_cart_abandoned_time' );
196
  $cart_cut_off_time = $cut_off_time * 60;
197
  $compare_time = $current_time - $cart_cut_off_time;
198
 
199
+ $query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
200
+ WHERE user_id = %d AND cart_ignored = '0' AND recovered_cart = '0' AND user_type = 'GUEST'";
201
  $results = $wpdb->get_results( $wpdb->prepare( $query, $user_id ) );
202
 
203
  $cart = array();
204
 
205
+ if ( function_exists( 'WC' ) ) {
206
  $cart['cart'] = WC()->session->cart;
207
  } else {
208
  $cart['cart'] = $woocommerce->session->cart;
209
  }
210
 
211
+ if ( 0 == count( $results ) ) {
212
+ $get_cookie = WC()->session->get_session_cookie();
213
+ $cart_info = addslashes( json_encode( $cart ) );
214
 
215
+ $query = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
216
+ WHERE session_id LIKE %s AND cart_ignored = '0' AND recovered_cart = '0' ";
217
+ $results = $wpdb->get_results( $wpdb->prepare( $query, $get_cookie[0] ) );
218
 
219
+ if ( 0 == count( $results ) ) {
220
  $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, session_id )
221
  VALUES ( '".$user_id."', '".$cart_info."', '".$current_time."', '0', '0', 'GUEST', '".$get_cookie[0] ."' )";
222
  $wpdb->query( $insert_query );
223
 
224
+ $abandoned_cart_id = $wpdb->insert_id;
225
+ wcal_common::wcal_set_cart_session( 'abandoned_cart_id_lite', $abandoned_cart_id );
226
 
227
  // $insert_persistent_cart = "INSERT INTO `".$wpdb->prefix."usermeta`( user_id, meta_key, meta_value )
228
  // VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
229
  // $wpdb->query( $insert_persistent_cart );
230
+ if ( is_multisite() ) {
231
+ // get main site's table prefix
232
+ $main_prefix = $wpdb->get_blog_prefix(1);
233
+ $insert_persistent_cart = "INSERT INTO `" . $main_prefix . "usermeta`( user_id, meta_key, meta_value )
234
+ VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
235
+ $wpdb->query( $insert_persistent_cart );
236
 
237
+ } else {
238
+ $insert_persistent_cart = "INSERT INTO `" . $wpdb->prefix . "usermeta`( user_id, meta_key, meta_value )
239
+ VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
240
+ $wpdb->query( $insert_persistent_cart );
241
  }
242
  } else {
243
+ $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' ";
244
  $wpdb->query( $query_update );
245
+ $query_update_get = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
246
+ WHERE user_id ='" . $user_id . "' AND cart_ignored='0' AND session_id ='" . $get_cookie[0] . "' ";
247
  $get_abandoned_record = $wpdb->get_results( $query_update_get );
248
 
249
  if ( count( $get_abandoned_record ) > 0 ) {
250
+ $abandoned_cart_id = $get_abandoned_record[0]->id;
251
+ wcal_common::wcal_set_cart_session( 'abandoned_cart_id_lite', $abandoned_cart_id );
252
  }
253
 
254
  $insert_persistent_cart = "INSERT INTO `".$wpdb->prefix."usermeta`( user_id, meta_key, meta_value )
255
  VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
256
  $wpdb->query( $insert_persistent_cart );
257
+ if ( is_multisite() ) {
258
  // get main site's table prefix
259
+ $main_prefix = $wpdb->get_blog_prefix(1);
260
  $insert_persistent_cart = "INSERT INTO `" . $main_prefix . "usermeta`( user_id, meta_key, meta_value )
261
+ VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
262
  $wpdb->query( $insert_persistent_cart );
263
 
264
  } else {
265
  $insert_persistent_cart = "INSERT INTO `" . $wpdb->prefix . "usermeta`( user_id, meta_key, meta_value )
266
  VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
267
  $wpdb->query( $insert_persistent_cart );
268
+ }
269
  }
 
270
  }
271
  }
272
  }
273
+
274
  /**
275
  * It will populate the data on the chekout field if user comes from the abandoned cart reminder emails.
276
  * @hook woocommerce_checkout_fields
279
  * @since 2.2
280
  */
281
  function guest_checkout_fields( $fields ) {
282
+ if ( wcal_common::wcal_get_cart_session( 'guest_first_name' ) != "" ) {
283
+ $_POST['billing_first_name'] = wcal_common::wcal_get_cart_session( 'guest_first_name' );
284
+ }
285
+ if ( wcal_common::wcal_get_cart_session( 'guest_last_name' ) != "" ) {
286
+ $_POST['billing_last_name'] = wcal_common::wcal_get_cart_session( 'guest_last_name' );
287
  }
288
+ if ( wcal_common::wcal_get_cart_session( 'guest_email' ) != "" ) {
289
+ $_POST['billing_email'] = wcal_common::wcal_get_cart_session( 'guest_email' );
290
  }
291
+ if ( wcal_common::wcal_get_cart_session( 'guest_phone' ) != "" ) {
292
+ $_POST['billing_phone'] = wcal_common::wcal_get_cart_session( 'guest_phone' );
 
 
 
293
  }
294
  return $fields;
295
  }
{woocommerce-abandoned-cart/includes → includes}/wcal_data_tracking_message.php RENAMED
@@ -5,10 +5,10 @@
5
  * @package Abandoned-Cart-Lite-for-WooCommerce/Tracking
6
  * @since 4.9
7
  */
8
- if (!defined('ABSPATH')) {
9
  exit; // Exit if accessed directly.
10
  }
11
- if ( !class_exists('Wcal_Tracking_msg' ) ) {
12
 
13
  /**
14
  * It will add messages as needed informing users of data being tracked.
@@ -38,11 +38,11 @@ if ( !class_exists('Wcal_Tracking_msg' ) ) {
38
  */
39
  static function wcal_add_gdpr_msg( $fields ) {
40
 
41
- if( ! is_user_logged_in() ) {
42
  // check if any message is present in the settings
43
  $guest_msg = get_option( 'wcal_guest_cart_capture_msg' );
44
 
45
- if( isset( $guest_msg ) && '' != $guest_msg ) {
46
  $existing_label = $fields[ 'billing' ][ 'billing_email' ][ 'label' ];
47
  $fields[ 'billing' ][ 'billing_email' ][ 'label' ] = $existing_label . "<br><small>$guest_msg</small>";
48
  }
@@ -59,11 +59,11 @@ if ( !class_exists('Wcal_Tracking_msg' ) ) {
59
  * @since 4.9
60
  */
61
  static function wcal_add_logged_msg() {
62
- if( is_user_logged_in() ) {
63
 
64
  $registered_msg = get_option( 'wcal_logged_cart_capture_msg' );
65
 
66
- if( isset( $registered_msg ) && '' != $registered_msg ) {
67
  echo "<p><small>" . __( $registered_msg, 'woocommerce-abandoned-cart' ) . "</small></p>";
68
  }
69
  }
5
  * @package Abandoned-Cart-Lite-for-WooCommerce/Tracking
6
  * @since 4.9
7
  */
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
  exit; // Exit if accessed directly.
10
  }
11
+ if ( ! class_exists( 'Wcal_Tracking_msg' ) ) {
12
 
13
  /**
14
  * It will add messages as needed informing users of data being tracked.
38
  */
39
  static function wcal_add_gdpr_msg( $fields ) {
40
 
41
+ if ( ! is_user_logged_in() ) {
42
  // check if any message is present in the settings
43
  $guest_msg = get_option( 'wcal_guest_cart_capture_msg' );
44
 
45
+ if ( isset( $guest_msg ) && '' != $guest_msg ) {
46
  $existing_label = $fields[ 'billing' ][ 'billing_email' ][ 'label' ];
47
  $fields[ 'billing' ][ 'billing_email' ][ 'label' ] = $existing_label . "<br><small>$guest_msg</small>";
48
  }
59
  * @since 4.9
60
  */
61
  static function wcal_add_logged_msg() {
62
+ if ( is_user_logged_in() ) {
63
 
64
  $registered_msg = get_option( 'wcal_logged_cart_capture_msg' );
65
 
66
+ if ( isset( $registered_msg ) && '' != $registered_msg ) {
67
  echo "<p><small>" . __( $registered_msg, 'woocommerce-abandoned-cart' ) . "</small></p>";
68
  }
69
  }
includes/wcal_default-settings.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abandoned Cart Lite for WooCommerce
5
+ *
6
+ * It will add the default template for the plugin.
7
+ *
8
+ * @author Tyche Softwares
9
+ * @package Abandoned-Cart-Lite-for-WooCommerce/Admin/Default-Template
10
+ * @since 2.5
11
+ */
12
+
13
+ class wcal_default_template_settings {
14
+
15
+ /**
16
+ * This function will load default template while activating the plugin.
17
+ * @globals mixed $wpdb
18
+ * @since 2.5
19
+ */
20
+ function wcal_create_default_templates() {
21
+ global $wpdb;
22
+ $template_name_array = 'Initial';
23
+ $site_title = get_bloginfo( 'name' );
24
+ $site_url = get_option( 'siteurl' );
25
+ $template_subject_array = "Hey {{customer.firstname}}!! You left something in your cart";
26
+ $active_post_array = 0;
27
+ $email_frequency_array = 1;
28
+ $day_or_hour_array = 'Hours';
29
+ if ( !defined( 'WCAL_PLUGIN_PATH' ) ) {
30
+ define('WCAL_PLUGIN_PATH' ,untrailingslashit(plugin_dir_path(__FILE__)) );
31
+ }
32
+ ob_start();
33
+ include( WCAL_PLUGIN_PATH . '/templates/template_1.php' );
34
+ $content = ob_get_clean();
35
+ $body_content_array = addslashes( $content );
36
+ $is_wc_template = 1;
37
+ $default_template = 1;
38
+ $header_text = addslashes( 'You left Something in Your Cart!' );
39
+
40
+ $query = "INSERT INTO `" . $wpdb->prefix . "ac_email_templates_lite`
41
+ ( subject, body, is_active, frequency, day_or_hour, template_name, is_wc_template, default_template, wc_email_header )
42
+ VALUES ( '" . $template_subject_array . "',
43
+ '" . $body_content_array . "',
44
+ '" . $active_post_array . "',
45
+ '" . $email_frequency_array . "',
46
+ '" . $day_or_hour_array . "',
47
+ '" . $template_name_array . "',
48
+ '" . $is_wc_template . "',
49
+ '" . $default_template . "',
50
+ '" . $header_text . "' )";
51
+ $wpdb->query( $query );
52
+ }
53
+ }
{woocommerce-abandoned-cart/includes → includes}/wcal_ts_tracking.php RENAMED
File without changes
{woocommerce-abandoned-cart/includes → includes}/welcome.php RENAMED
File without changes
woocommerce-abandoned-cart/readme.txt → readme.txt RENAMED
@@ -4,9 +4,9 @@ Contributors: ashokrane, pinal.shah, bhavik.kiri, chetnapatel, tychesoftwares
4
  Tags: abandon cart, cart recovery, increase woocommerce conversion rate , recover woocommerce cart, increase sales with woocommerce
5
  Author URI: https://www.tychesoftwares.com/
6
  Requires at least: 1.3
7
- Tested up to: 4.9.7
8
  Stable tag: trunk
9
- License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  Donate link: https://www.paypal.me/TycheSoftwares
12
 
@@ -193,6 +193,36 @@ You can refer **[here](https://www.tychesoftwares.com/differences-between-pro-an
193
 
194
  == Changelog ==
195
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  = 5.0.2 (13.10.2018) =
197
 
198
  * Removed the Welcome page of the plugin and also removed the promotional notices which were being displayed on admin end of the WordPress website.
4
  Tags: abandon cart, cart recovery, increase woocommerce conversion rate , recover woocommerce cart, increase sales with woocommerce
5
  Author URI: https://www.tychesoftwares.com/
6
  Requires at least: 1.3
7
+ Tested up to: 4.9.8
8
  Stable tag: trunk
9
+ License: GPLv2 or late
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
  Donate link: https://www.paypal.me/TycheSoftwares
12
 
193
 
194
  == Changelog ==
195
 
196
+ = 5.1.1 (01.11.2018) =
197
+
198
+ * Bug Fixed - Changed the file name in the plugin.
199
+
200
+ = 5.1.0 (01.11.2018) =
201
+
202
+ * This version has 5 Enhancements and 5 bugs fixes along with 1 Tweak.
203
+
204
+ * Enhancement - Removed the reliability on PHP sessions. The plugin no longer uses PHP sessions from this release.
205
+
206
+ * Enhancement - Modified the plugin to no longer display carts with the status 'Abandoned but new Cart created'. Since, these carts are not sent any reminder emails, it made most sense to stop displaying them as well.
207
+
208
+ * Enhancement - Added new default email template that use the responsive email designs added in the plugin version.
209
+
210
+ * Enhancement - We have removed a few unwanted queries & optimised the code which was executed every 2-3 minutes. This will improve the site performance.
211
+
212
+ * Enhancement - We have added Product page URL on the Product Name under Abandoned Orders View page.
213
+
214
+ * Tweak - Changed the subject lines and Header text for the default email templates.
215
+
216
+ * Bug Fix - When the site language is Hebrew, the site admin is unable to activate email templates. The same has now been fixed.
217
+
218
+ * Bug Fix - Email Templates were not getting saved as "utf8mb4_unicode_ci" collation was not allowing to create table of the email template in the database due to some site restriction. This issue has been fixed.
219
+
220
+ * Bug Fix - The plugin now runs the process to send reminder emails in the background. This will help fix the issue where the site performance is affected due to the plugin.
221
+
222
+ * Bug Fix - In case, if wp-content folder is separated from WP core folders then the plugin could not find "wp-load.php" correctly and abandoned cart reminder emails were not being sent. This issue is fixed now.
223
+
224
+ * Bug Fix - Some error messages are fixed in this plugin version.
225
+
226
  = 5.0.2 (13.10.2018) =
227
 
228
  * Removed the Welcome page of the plugin and also removed the promotional notices which were being displayed on admin end of the WordPress website.
woocommerce-abandoned-cart/screenshot-1.png → screenshot-1.png RENAMED
File without changes
woocommerce-abandoned-cart/screenshot-2.png → screenshot-2.png RENAMED
File without changes
woocommerce-abandoned-cart/screenshot-3.png → screenshot-3.png RENAMED
File without changes
woocommerce-abandoned-cart/screenshot-4.png → screenshot-4.png RENAMED
File without changes
woocommerce-abandoned-cart/screenshot-5.png → screenshot-5.png RENAMED
File without changes
views/wcal-email-template-preview.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /**
10
+ * Abandoned Cart Lite for WooCommerce
11
+ *
12
+ * It will handle the common action for the plugin.
13
+ *
14
+ * @author Tyche Softwares
15
+ * @package Abandoned-Cart-Lite-for-WooCommerce/Admin/Template-view
16
+ * @since 2.5.2
17
+ */
18
+
19
+
20
+ $site_title = get_bloginfo( 'name' );
21
+ $site_url = get_option( 'siteurl' );
22
+ $admin_args = array( 'role' => 'administrator',
23
+ 'fields' => array( 'id' )
24
+ );
25
+
26
+ $admin_usr = get_users( $admin_args );
27
+ $uid = $admin_usr[0]->id;
28
+ $admin_phone = get_user_meta( $uid, 'billing_phone', true );
29
+ $wcal_price = wc_price( '150' );
30
+ $wcal_total_price = wc_price( '300' );
31
+ ?>
32
+ <p><style type="text/css">
33
+ * {
34
+ -webkit-font-smoothing: antialiased;
35
+ }
36
+ div, p, a, li, td {
37
+ -webkit-text-size-adjust: none;
38
+ }
39
+ #outlook a {
40
+ padding: 0;
41
+ }
42
+ html {
43
+ width: 100%;
44
+ }
45
+ body {
46
+ margin: 0;
47
+ padding: 0;
48
+ color: #808080;
49
+ width: 100% !important;
50
+ font-family: Arial, Helvetica, sans-serif;
51
+ -webkit-text-size-adjust: 100%!important;
52
+ -ms-text-size-adjust: 100%!important;
53
+ -webkit-font-smoothing: antialiased!important;
54
+ }
55
+ img {
56
+ outline: none;
57
+ border: none;
58
+ text-decoration: none;
59
+ -ms-interpolation-mode: bicubic;
60
+ }
61
+ a {
62
+ text-decoration: none;
63
+ }
64
+ a img {
65
+ border: none;
66
+ }
67
+ table {
68
+ color: #222222;
69
+ font-family: Arial, sans-serif;
70
+ }
71
+ table td {
72
+ border-collapse: collapse;
73
+ mso-line-height-rule: exactly;
74
+ mso-table-lspace: 0pt;
75
+ mso-table-rspace: 0pt;
76
+ }
77
+ table {
78
+ border-collapse: collapse;
79
+ mso-table-lspace: 0pt;
80
+ mso-table-rspace: 0pt;
81
+ }
82
+ .main-wrapper {
83
+ max-width: 600px;
84
+ }
85
+ .container {
86
+ width: 100%;
87
+ table-layout: fixed;
88
+ -webkit-text-size-adjust: 100%;
89
+ -ms-text-size-adjust: 100%;
90
+ }
91
+ @media screen and (max-device-width:600px),
92
+ screen and (max-width:600px) {
93
+ td[class=td_em_hide] {
94
+ display: none !important;
95
+ }
96
+ table[class=main-wrapper] {
97
+ width: 100%!important;
98
+ }
99
+ td[class=em_bg_center] {
100
+ background-position: center!important;
101
+ }
102
+ .main-wrapper {
103
+ width: 100% !important;
104
+ }
105
+ }
106
+ @media screen and (max-device-width:520px),
107
+ screen and (max-width:520px) {
108
+ td[class=td_w_sm] {
109
+ width: 20px!important;
110
+ }
111
+ td[class=td_sm_hide] {
112
+ display: none !important;
113
+ }
114
+ .sm-center-txt {
115
+ text-align: center;
116
+ }
117
+ table[class=main-wrapper] {
118
+ width: 100%!important;
119
+ }
120
+ table[class=sm_wrapper] {
121
+ width: 100%!important;
122
+ }
123
+ td[class=td-sm_wrapper] {
124
+ width: 100%!important;
125
+ }
126
+ td[class=sm-txt] {
127
+ font-size: 24px!important;
128
+ }
129
+ td[class=sm-txt1] {
130
+ font-size: 45px!important;
131
+ }
132
+ .main-wrapper {
133
+ width: 100% !important;
134
+ }
135
+ }
136
+ </style></p><p><style type="text/css">
137
+ @media only screen and (max-width:480px) {
138
+ @-ms-viewport {
139
+ width: 320px;
140
+ }
141
+ @viewport {
142
+ width: 320px;
143
+ }
144
+ }
145
+ </style></p><p><style type="text/css">
146
+ @import url(https://fonts.googleapis.com/css?family=Lato);
147
+ @import url(https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700);
148
+ @import url(https://fonts.googleapis.com/css?family=Cabin);
149
+ </style></p><table style="background-color: #f6f3f3; font-size: 15px; line-height: 20px; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt;" border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#f6f3f3"><tbody><tr><td align="center" valign="top" width="100%"><!-- [if mso | IE]>
150
+ <table role="presentation" border="0" cellpadding="0" cellspacing="0" width="600" align="center" style="width:600px;">
151
+ <tr>
152
+ <td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
153
+ <![endif]--><div style="margin: 0 auto; max-width: 600px;"><table class="main-wrapper" style="background-color: #ffffff; table-layout: fixed; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-family: Arial, Helvetica, sans-serif; color: #333333; margin: 0 auto; max-width: 600px;" role="presentation" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#ffffff"><tbody><tr><td style="padding-top: 10px;" bgcolor="#ffffff" width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"><tbody><tr><td class="td_w_sm" style="font-size: 0; line-height: 0;" width="30"> </td><td style="padding: 0;"><div style="font-size: 0pt; line-height: 0pt; height: 20px;"> </div><table border="0" width="100%" cellspacing="0" cellpadding="0"><tbody><tr><td class="sm-txt" style="font-size: 30px; line-height: 30px; text-align: center; color: #333032; text-transform: uppercase; font-family: Ubuntu, Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; padding: 0;" align="center" width="100%"><?php echo "$site_title"; ?> </td>
154
+
155
+ </tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr><tr><td class="sm-txt1" style="font-size: 50px; line-height: 50px; text-align: center; color: #000000; text-transform: uppercase; font-family: Ubuntu, Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; padding: 0;" align="center" width="100%">PSST...</td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="20"> </td></tr><tr><td style="font-size: 15px; line-height: 24px; text-align: center; color: #333032; text-transform: uppercase; letter-spacing: 2px; padding: 0;" align="center" width="100%">Looks like you left something fabulous <br />in your shopping bag</td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="25"> </td></tr><tr><td style="font-size: 0pt; line-height: 0pt; padding: 0;" align="center"><img style="display: block; width: 100%; max-width: 301px; margin: 0 auto;" src="http://staging.tychesoftwares.com/templates/default1.jpeg" alt="" /></td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="25"> </td></tr><tr><td style="font-size: 15px; line-height: 24px; text-align: center; color: #333032; text-transform: uppercase; letter-spacing: 2px; padding: 0;" align="center" width="100%">Shop now before time runs out, <br />These must have ITEMs won't be around for long... </td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="20"> </td></tr><tr><td style="text-align: center; padding: 0;" align="center">
156
+
157
+ <table border="0" width="100%" cellspacing="0" cellpadding="0"><b>Your Shopping Cart</b>
158
+ <tbody>
159
+ <tr>
160
+
161
+
162
+ <td style="background-color: #666666; color: #ffffff; text-align: center; font-size: 13px; text-transform: uppercase; padding: 5px;" align="center" bgcolor="#666666"></td>
163
+
164
+ <td style="background-color: #666666; color: #ffffff; text-align: center; font-size: 13px; text-transform: uppercase; padding: 5px;" align="center" bgcolor="#666666">Product</td>
165
+
166
+ <td style="background-color: #666666; color: #ffffff; text-align: center; font-size: 13px; text-transform: uppercase; padding: 5px;" align="center" bgcolor="#666666">Price</td>
167
+
168
+ <td style="background-color: #666666; color: #ffffff; text-align: center; font-size: 13px; text-transform: uppercase; padding: 5px;" align="center" bgcolor="#666666">Quantity</td>
169
+
170
+ <td style="background-color: #666666; color: #ffffff; text-align: center; font-size: 13px; text-transform: uppercase; padding: 5px;" align="center" bgcolor="#666666">Total</td>
171
+
172
+ </tr>
173
+ <tr style="background-color:#f4f5f4;">
174
+ <td><img src = "<?php echo plugins_url();?>/woocommerce-abandoned-cart/assets/images/spectre.jpg" height="40px" width="40px"></td><td>Spectre</td><td> <?php echo "$wcal_price"; ?></td><td>2</td><td><?php echo "$wcal_total_price"; ?> </td>
175
+ </tr>
176
+ <tr>
177
+ <td>&nbsp;</td>
178
+ <td>&nbsp;</td>
179
+ <td>&nbsp;</td>
180
+ <th>Cart Total:</th>
181
+ <td><?php echo "$wcal_total_price"; ?></td>
182
+ </tr>
183
+
184
+ </tbody></table>
185
+
186
+ </td></tr><tr><td style="line-height: 1px; font-size: 1px;" bgcolor="#cfcfcf" height="2"> </td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr><tr><td style="font-size: 15px; line-height: 20px; text-align: center; color: #333032; font-weight: bold; padding: 0;" align="center" width="100%">For your convenience, we have saved your shopping cart.</td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr><tr><td align="center"><table border="0" cellspacing="0" cellpadding="0" align="center"><tbody><tr><td align="center"><table border="0" width="270" cellspacing="0" cellpadding="0" align="center"><tbody><tr><td style="border-collapse: collapse; word-break: break-word; word-wrap: break-word;" align="center"><a style="display: block; font-family: Arial, Helvetica, sans-serif; font-size: 16px; letter-spacing: 1px; color: #ffffff; line-height: 20px; text-decoration: none; text-align: center; background-color: #000; margin: 0 auto; width: 270px; box-sizing: border-box; padding: 8px 8px 8px 8px;" href="{{cart.link}}">CHECKOUT NOW</a></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr><tr><td style="font-size: 15px; line-height: 20px; text-align: center; color: #333032; padding: 0;" align="center" width="100%">For your assistance or if you would like to place an order directly with our customer service team, please call us at <?php echo "$admin_phone"; ?> </td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr><tr><td style="line-height: 1px; font-size: 1px;" bgcolor="#cfcfcf" height="2"> </td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr></tbody></table></td><td class="td_w_sm" style="font-size: 0; line-height: 0;" width="30"> </td></tr></tbody></table></td></tr><tr><td><!-- ======= footer start======= --><table border="0" width="100%" cellspacing="0" cellpadding="0"><tbody><tr><td class="td_w_sm" style="font-size: 0; line-height: 0;" width="30"> </td><td style="padding: 0;"><table border="0" width="100%" cellspacing="0" cellpadding="0"><tbody>
187
+
188
+ <td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="10"> </td></tr><tr><td style="font-size: 15px; line-height: 20px; text-align: center; color: #333032; padding: 0;" align="center" width="100%"><a href="{{cart.unsubscribe}}">Unsubscribe</a></td></tr></tbody></table><!-- ======= footer end======= --></td><td class="td_w_sm" style="font-size: 0; line-height: 0;" width="30"> </td></tr></tbody></table></td></tr></tbody></table></div><!-- [if mso | IE]> </td></tr></table> <![endif]--></td></tr></tbody></table>
views/wcal-wc-email-template-preview.php ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Abandoned Cart Lite for WooCommerce
10
+ *
11
+ * It will handle the common action for the plugin.
12
+ *
13
+ * @author Tyche Softwares
14
+ * @package Abandoned-Cart-Lite-for-WooCommerce/Admin/Template-view
15
+ * @since 2.5.2
16
+ */
17
+
18
+
19
+ $site_title = get_bloginfo( 'name' );
20
+ $site_url = get_option( 'siteurl' );
21
+ $admin_args = array( 'role' => 'administrator',
22
+ 'fields' => array( 'id' )
23
+ );
24
+
25
+ $admin_usr = get_users( $admin_args );
26
+ $uid = $admin_usr[0]->id;
27
+ $admin_phone = get_user_meta( $uid, 'billing_phone', true );
28
+ $wcal_price = wc_price( '150' );
29
+ $wcal_total_price = wc_price( '300' );
30
+ ?>
31
+ <p><style type="text/css">
32
+ * {
33
+ -webkit-font-smoothing: antialiased;
34
+ }
35
+ div, p, a, li, td {
36
+ -webkit-text-size-adjust: none;
37
+ }
38
+ #outlook a {
39
+ padding: 0;
40
+ }
41
+ html {
42
+ width: 100%;
43
+ }
44
+ body {
45
+ margin: 0;
46
+ padding: 0;
47
+ color: #808080;
48
+ width: 100% !important;
49
+ font-family: Arial, Helvetica, sans-serif;
50
+ -webkit-text-size-adjust: 100%!important;
51
+ -ms-text-size-adjust: 100%!important;
52
+ -webkit-font-smoothing: antialiased!important;
53
+ }
54
+ img {
55
+ outline: none;
56
+ border: none;
57
+ text-decoration: none;
58
+ -ms-interpolation-mode: bicubic;
59
+ }
60
+ a {
61
+ text-decoration: none;
62
+ }
63
+ a img {
64
+ border: none;
65
+ }
66
+ table {
67
+ color: #222222;
68
+ font-family: Arial, sans-serif;
69
+ }
70
+ table td {
71
+ border-collapse: collapse;
72
+ mso-line-height-rule: exactly;
73
+ mso-table-lspace: 0pt;
74
+ mso-table-rspace: 0pt;
75
+ }
76
+ table {
77
+ border-collapse: collapse;
78
+ mso-table-lspace: 0pt;
79
+ mso-table-rspace: 0pt;
80
+ }
81
+ .main-wrapper {
82
+ max-width: 600px;
83
+ }
84
+ .container {
85
+ width: 100%;
86
+ table-layout: fixed;
87
+ -webkit-text-size-adjust: 100%;
88
+ -ms-text-size-adjust: 100%;
89
+ }
90
+ @media screen and (max-device-width:600px),
91
+ screen and (max-width:600px) {
92
+ td[class=td_em_hide] {
93
+ display: none !important;
94
+ }
95
+ table[class=main-wrapper] {
96
+ width: 100%!important;
97
+ }
98
+ td[class=em_bg_center] {
99
+ background-position: center!important;
100
+ }
101
+ .main-wrapper {
102
+ width: 100% !important;
103
+ }
104
+ }
105
+ @media screen and (max-device-width:520px),
106
+ screen and (max-width:520px) {
107
+ td[class=td_w_sm] {
108
+ width: 20px!important;
109
+ }
110
+ td[class=td_sm_hide] {
111
+ display: none !important;
112
+ }
113
+ .sm-center-txt {
114
+ text-align: center;
115
+ }
116
+ table[class=main-wrapper] {
117
+ width: 100%!important;
118
+ }
119
+ table[class=sm_wrapper] {
120
+ width: 100%!important;
121
+ }
122
+ td[class=td-sm_wrapper] {
123
+ width: 100%!important;
124
+ }
125
+ td[class=sm-txt] {
126
+ font-size: 24px!important;
127
+ }
128
+ td[class=sm-txt1] {
129
+ font-size: 45px!important;
130
+ }
131
+ .main-wrapper {
132
+ width: 100% !important;
133
+ }
134
+ }
135
+ </style></p><p><style type="text/css">
136
+ @media only screen and (max-width:480px) {
137
+ @-ms-viewport {
138
+ width: 320px;
139
+ }
140
+ @viewport {
141
+ width: 320px;
142
+ }
143
+ }
144
+ </style></p><p><style type="text/css">
145
+ @import url(https://fonts.googleapis.com/css?family=Lato);
146
+ @import url(https://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700);
147
+ @import url(https://fonts.googleapis.com/css?family=Cabin);
148
+ </style></p><table style="background-color: #f6f3f3; font-size: 15px; line-height: 20px; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt;" border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#f6f3f3"><tbody><tr><td align="center" valign="top" width="100%"><!-- [if mso | IE]>
149
+ <table role="presentation" border="0" cellpadding="0" cellspacing="0" width="600" align="center" style="width:600px;">
150
+ <tr>
151
+ <td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;">
152
+ <![endif]--><div style="margin: 0 auto; max-width: 600px;"><table class="main-wrapper" style="background-color: #ffffff; table-layout: fixed; border-spacing: 0; border-collapse: collapse; mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-family: Arial, Helvetica, sans-serif; color: #333333; margin: 0 auto; max-width: 600px;" role="presentation" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#ffffff"><tbody><tr><td style="padding-top: 10px;" bgcolor="#ffffff" width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0"><tbody><tr><td class="td_w_sm" style="font-size: 0; line-height: 0;" width="30"> </td><td style="padding: 0;"><div style="font-size: 0pt; line-height: 0pt; height: 20px;"> </div><table border="0" width="100%" cellspacing="0" cellpadding="0"><tbody><tr><td class="sm-txt" style="font-size: 30px; line-height: 30px; text-align: center; color: #333032; text-transform: uppercase; font-family: Ubuntu, Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; padding: 0;" align="center" width="100%"><?php echo "$site_title"; ?> </td>
153
+
154
+ </tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr><tr><td class="sm-txt1" style="font-size: 50px; line-height: 50px; text-align: center; color: #000000; text-transform: uppercase; font-family: Ubuntu, Helvetica, Arial, sans-serif, Helvetica, Arial, sans-serif; padding: 0;" align="center" width="100%">PSST...</td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="20"> </td></tr><tr><td style="font-size: 15px; line-height: 24px; text-align: center; color: #333032; text-transform: uppercase; letter-spacing: 2px; padding: 0;" align="center" width="100%">Looks like you left something fabulous <br />in your shopping bag</td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="25"> </td></tr><tr><td style="font-size: 0pt; line-height: 0pt; padding: 0;" align="center"><img style="display: block; width: 100%; max-width: 301px; margin: 0 auto;" src="http://staging.tychesoftwares.com/templates/default1.jpeg" alt="" /></td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="25"> </td></tr><tr><td style="font-size: 15px; line-height: 24px; text-align: center; color: #333032; text-transform: uppercase; letter-spacing: 2px; padding: 0;" align="center" width="100%">Shop now before time runs out, <br />These must have ITEMs won't be around for long... </td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="20"> </td></tr><tr><td style="text-align: center; padding: 0;" align="center">
155
+
156
+ <table border="0" width="100%" cellspacing="0" cellpadding="0"><b>Your Shopping Cart</b>
157
+ <tbody>
158
+ <tr>
159
+
160
+
161
+ <td style="background-color: #666666; color: #ffffff; text-align: center; font-size: 13px; text-transform: uppercase; padding: 5px;" align="center" bgcolor="#666666"></td>
162
+
163
+ <td style="background-color: #666666; color: #ffffff; text-align: center; font-size: 13px; text-transform: uppercase; padding: 5px;" align="center" bgcolor="#666666">Product</td>
164
+
165
+ <td style="background-color: #666666; color: #ffffff; text-align: center; font-size: 13px; text-transform: uppercase; padding: 5px;" align="center" bgcolor="#666666">Price</td>
166
+
167
+ <td style="background-color: #666666; color: #ffffff; text-align: center; font-size: 13px; text-transform: uppercase; padding: 5px;" align="center" bgcolor="#666666">Quantity</td>
168
+
169
+ <td style="background-color: #666666; color: #ffffff; text-align: center; font-size: 13px; text-transform: uppercase; padding: 5px;" align="center" bgcolor="#666666">Total</td>
170
+
171
+ </tr>
172
+ <tr style="background-color:#f4f5f4;">
173
+ <td><img src = "<?php echo plugins_url();?>/woocommerce-abandoned-cart/assets/images/spectre.jpg" height="40px" width="40px"></td><td>Spectre</td><td> <?php echo "$wcal_price"; ?></td><td>2</td><td><?php echo "$wcal_total_price"; ?> </td>
174
+ </tr>
175
+ <tr>
176
+ <td>&nbsp;</td>
177
+ <td>&nbsp;</td>
178
+ <td>&nbsp;</td>
179
+ <th>Cart Total:</th>
180
+ <td><?php echo "$wcal_total_price"; ?></td>
181
+ </tr>
182
+
183
+ </tbody></table>
184
+
185
+ </td></tr><tr><td style="line-height: 1px; font-size: 1px;" bgcolor="#cfcfcf" height="2"> </td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr><tr><td style="font-size: 15px; line-height: 20px; text-align: center; color: #333032; font-weight: bold; padding: 0;" align="center" width="100%">For your convenience, we have saved your shopping cart.</td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr><tr><td align="center"><table border="0" cellspacing="0" cellpadding="0" align="center"><tbody><tr><td align="center"><table border="0" width="270" cellspacing="0" cellpadding="0" align="center"><tbody><tr><td style="border-collapse: collapse; word-break: break-word; word-wrap: break-word;" align="center"><a style="display: block; font-family: Arial, Helvetica, sans-serif; font-size: 16px; letter-spacing: 1px; color: #ffffff; line-height: 20px; text-decoration: none; text-align: center; background-color: #000; margin: 0 auto; width: 270px; box-sizing: border-box; padding: 8px 8px 8px 8px;" href="{{cart.link}}">CHECKOUT NOW</a></td></tr></tbody></table></td></tr></tbody></table></td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr><tr><td style="font-size: 15px; line-height: 20px; text-align: center; color: #333032; padding: 0;" align="center" width="100%">For your assistance or if you would like to place an order directly with our customer service team, please call us at <?php echo "$admin_phone"; ?> </td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr><tr><td style="line-height: 1px; font-size: 1px;" bgcolor="#cfcfcf" height="2"> </td></tr><tr><td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="30"> </td></tr></tbody></table></td><td class="td_w_sm" style="font-size: 0; line-height: 0;" width="30"> </td></tr></tbody></table></td></tr><tr><td><!-- ======= footer start======= --><table border="0" width="100%" cellspacing="0" cellpadding="0"><tbody><tr><td class="td_w_sm" style="font-size: 0; line-height: 0;" width="30"> </td><td style="padding: 0;"><table border="0" width="100%" cellspacing="0" cellpadding="0"><tbody>
186
+
187
+ <td style="font-size: 0pt; line-height: 0pt; text-align: left; padding: 0;" height="10"> </td></tr><tr><td style="font-size: 15px; line-height: 20px; text-align: center; color: #333032; padding: 0;" align="center" width="100%"><a href="{{cart.unsubscribe}}">Unsubscribe</a></td></tr></tbody></table><!-- ======= footer end======= --></td><td class="td_w_sm" style="font-size: 0; line-height: 0;" width="30"> </td></tr></tbody></table></td></tr></tbody></table></div><!-- [if mso | IE]> </td></tr></table> <![endif]--></td></tr></tbody></table>
woocommerce-abandoned-cart/includes/wcal-common.php DELETED
@@ -1,741 +0,0 @@
1
- <?php
2
- /**
3
- * Abandoned Cart Lite for WooCommerce
4
- *
5
- * @author Tyche Softwares
6
- * @package Abandoned-Cart-Lite-for-WooCommerce/Common-Functions
7
- */
8
-
9
- /**
10
- * It will have all the common funtions for the plugin.
11
- * @since 2.5.2
12
- */
13
- class wcal_common {
14
-
15
- /**
16
- * Get abandoned orders counts.
17
- * @globals mixed $wpdb
18
- * @return string | int $wcal_order_count
19
- * @since 3.9
20
- */
21
- private static function wcal_ts_get_abandoned_order_counts() {
22
- global $wpdb;
23
- $wcal_order_count = 0;
24
-
25
- $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
26
- $cut_off_time = $ac_cutoff_time * 60;
27
- $current_time = current_time( 'timestamp' );
28
- $compare_time = $current_time - $cut_off_time;
29
-
30
- $blank_cart_info = '{"cart":[]}';
31
- $blank_cart_info_guest = '[]';
32
-
33
- $wcal_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest'";
34
-
35
- $wcal_order_count = $wpdb->get_var( $wcal_query );
36
-
37
- return $wcal_order_count;
38
- }
39
-
40
-
41
- /**
42
- * Get recovered orders counts.
43
- * @globals mixed $wpdb
44
- * @return string | int $wcal_recovered_order_count
45
- * @since 3.9
46
- */
47
- private static function wcal_ts_get_recovered_order_counts(){
48
-
49
- global $wpdb;
50
- $wcal_recovered_order_count = 0;
51
-
52
- $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
53
- $cut_off_time = $ac_cutoff_time * 60;
54
- $current_time = current_time( 'timestamp' );
55
- $compare_time = $current_time - $cut_off_time;
56
-
57
- $wcal_recovery_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time'";
58
-
59
- $wcal_recovered_order_count = $wpdb->get_var( $wcal_recovery_query );
60
-
61
- return $wcal_recovered_order_count;
62
- }
63
-
64
- /**
65
- * Get Total abandoned orders amount.
66
- * @globals mixed $wpdb
67
- * @return string | int $wcal_abandoned_orders_amount
68
- * @since 3.9
69
- */
70
- private static function wcal_ts_get_abandoned_order_total_amount(){
71
- global $wpdb;
72
- $wcal_abandoned_orders_amount = 0;
73
-
74
- $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
75
- $cut_off_time = $ac_cutoff_time * 60;
76
- $current_time = current_time( 'timestamp' );
77
- $compare_time = $current_time - $cut_off_time;
78
-
79
- $blank_cart_info = '{"cart":[]}';
80
- $blank_cart_info_guest = '[]';
81
-
82
- $wcal_abandoned_query = "SELECT abandoned_cart_info FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest'";
83
-
84
- $wcal_abandoned_query_result = $wpdb->get_results( $wcal_abandoned_query );
85
-
86
- $wcal_abandoned_orders_amount = self::wcal_get_abandoned_amount( $wcal_abandoned_query_result );
87
-
88
- return $wcal_abandoned_orders_amount;
89
- }
90
-
91
- /**
92
- * Get Total abandoned orders amount.
93
- * @globals mixed $wpdb
94
- * @param array | object $wcal_abandoned_query_result
95
- * @return string | int $wcal_abandoned_orders_amount
96
- * @since 3.9
97
- */
98
- private static function wcal_get_abandoned_amount( $wcal_abandoned_query_result ){
99
-
100
- $wcal_abandoned_orders_amount = 0;
101
- foreach ( $wcal_abandoned_query_result as $wcal_abandoned_query_key => $wcal_abandoned_query_value ) {
102
- # code...
103
- $cart_info = json_decode( $wcal_abandoned_query_value->abandoned_cart_info );
104
-
105
- $cart_details = array();
106
- if( isset( $cart_info->cart ) ){
107
- $cart_details = $cart_info->cart;
108
- }
109
-
110
- if( count( $cart_details ) > 0 ) {
111
- foreach( $cart_details as $k => $v ) {
112
- if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
113
- $wcal_abandoned_orders_amount = $wcal_abandoned_orders_amount + $v->line_total + $v->line_subtotal_tax;
114
- } else {
115
- $wcal_abandoned_orders_amount = $wcal_abandoned_orders_amount + $v->line_total;
116
- }
117
- }
118
- }
119
- }
120
- return $wcal_abandoned_orders_amount;
121
- }
122
-
123
- /**
124
- * Get recovered orders total amount.
125
- * @globals mixed $wpdb
126
- * @return string | int $wcal_recovered_orders_amount
127
- * @since 3.9
128
- */
129
- private static function wcal_ts_get_recovered_order_total_amount() {
130
-
131
- global $wpdb;
132
- $wcal_recovered_orders_amount = 0;
133
-
134
- $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
135
- $cut_off_time = $ac_cutoff_time * 60;
136
- $current_time = current_time( 'timestamp' );
137
- $compare_time = $current_time - $cut_off_time;
138
-
139
- $wcal_recovery_query_amount = "SELECT recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time'";
140
-
141
- $wcal_recovered_order_amount_result = $wpdb->get_results( $wcal_recovery_query_amount );
142
-
143
- $wcal_recovered_orders_amount = self::wcal_get_recovered_amount ($wcal_recovered_order_amount_result );
144
-
145
- return $wcal_recovered_orders_amount;
146
- }
147
-
148
- /**
149
- * Get recovered orders total amount.
150
- * @globals mixed $wpdb
151
- * @param array | object $wcal_data
152
- * @return string | int $wcal_recovered_orders_amount
153
- * @since 3.9
154
- */
155
-
156
- private static function wcal_get_recovered_amount ( $wcal_data ){
157
-
158
- $wcal_recovered_orders_amount = 0;
159
-
160
- foreach ($wcal_data as $wcal_data_key => $wcal_data_value) {
161
-
162
- $wcal_order_total = get_post_meta( $wcal_data_value->recovered_cart , '_order_total', true);
163
- $wcal_recovered_orders_amount = $wcal_recovered_orders_amount + $wcal_order_total;
164
- }
165
- return $wcal_recovered_orders_amount;
166
- }
167
-
168
- /**
169
- * Get sent email total count.
170
- * @globals mixed $wpdb
171
- * @return string | int $wcal_sent_emails_count
172
- * @since 3.9
173
- */
174
- private static function wcal_ts_get_sent_emails_total_count(){
175
-
176
- global $wpdb;
177
- $wcal_sent_emails_count = 0;
178
- $wcal_sent_emails_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_sent_history_lite`";
179
- $wcal_sent_emails_count = $wpdb->get_var( $wcal_sent_emails_query );
180
- return $wcal_sent_emails_count;
181
- }
182
-
183
- /**
184
- * Get email templates total count.
185
- * @globals mixed $wpdb
186
- * @return array $wcal_templates_data
187
- * @since 3.9
188
- */
189
- private static function wcal_ts_get_email_templates_data(){
190
-
191
- global $wpdb;
192
- $wcal_email_templates_count = 0;
193
- $wcal_email_templates_query = "SELECT id, is_active, is_wc_template,frequency, day_or_hour FROM `" . $wpdb->prefix . "ac_email_templates_lite`";
194
- $wcal_email_templates_results = $wpdb->get_results( $wcal_email_templates_query );
195
-
196
- $wcal_email_templates_count = count( $wcal_email_templates_results );
197
-
198
- $wcal_templates_data = array();
199
- $wcal_templates_data ['total_templates'] = $wcal_email_templates_count;
200
-
201
- foreach ($wcal_email_templates_results as $wcal_email_templates_results_key => $wcal_email_templates_results_value ) {
202
-
203
- $wcal_template_time = $wcal_email_templates_results_value->frequency . ' ' .$wcal_email_templates_results_value->day_or_hour ;
204
-
205
- $wcal_get_total_email_sent_for_template = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE template_id = ". $wcal_email_templates_results_value->id;
206
- $wcal_get_total_email_sent_for_template_count = $wpdb->get_var( $wcal_get_total_email_sent_for_template );
207
-
208
- $wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['is_activate'] = ( $wcal_email_templates_results_value->is_active == 1 ) ? 'Active' : 'Deactive';
209
- $wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['is_wc_template'] = ( $wcal_email_templates_results_value->is_wc_template == 1 ) ? 'Yes' : 'No';
210
- $wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['template_time'] = $wcal_template_time;
211
- $wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['total_email_sent'] = $wcal_get_total_email_sent_for_template_count;
212
- }
213
-
214
- return $wcal_templates_data;
215
- }
216
-
217
- /**
218
- * Get logged-in users total abandoned count.
219
- * @globals mixed $wpdb
220
- * @return string | int $wcal_logged_in_user_query_count
221
- * @since 3.9
222
- */
223
- private static function wcal_ts_get_logged_in_users_abandoned_cart_total_count (){
224
-
225
- global $wpdb;
226
- $wcal_logged_in_user_query_count = 0;
227
-
228
- $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
229
- $cut_off_time = $ac_cutoff_time * 60;
230
- $current_time = current_time( 'timestamp' );
231
- $compare_time = $current_time - $cut_off_time;
232
-
233
- $blank_cart_info = '{"cart":[]}';
234
- $blank_cart_info_guest = '[]';
235
-
236
- $wcal_logged_in_user_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id < 63000000 AND user_id != 0";
237
-
238
- $wcal_logged_in_user_query_count = $wpdb->get_var( $wcal_logged_in_user_query );
239
-
240
- return $wcal_logged_in_user_query_count;
241
- }
242
-
243
- /**
244
- * Get Guest users total abandoned count.
245
- * @globals mixed $wpdb
246
- * @return string | int $wcal_guest_user_query_count
247
- * @since 3.9
248
- */
249
- private static function wcal_ts_get_guest_users_abandoned_cart_total_count(){
250
- global $wpdb;
251
- $wcal_guest_user_query_count = 0;
252
-
253
- $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
254
- $cut_off_time = $ac_cutoff_time * 60;
255
- $current_time = current_time( 'timestamp' );
256
- $compare_time = $current_time - $cut_off_time;
257
-
258
- $blank_cart_info = '{"cart":[]}';
259
- $blank_cart_info_guest = '[]';
260
-
261
- $wcal_guest_user_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id >= 63000000 AND user_id != 0";
262
-
263
- $wcal_guest_user_query_count = $wpdb->get_var( $wcal_guest_user_query );
264
-
265
- return $wcal_guest_user_query_count;
266
- }
267
-
268
- /**
269
- * Get logged-in users total abandoned amount.
270
- * @globals mixed $wpdb
271
- * @return string | int $wcal_abandoned_orders_amount
272
- * @since 3.9
273
- */
274
- private static function wcal_ts_get_logged_in_users_abandoned_cart_total_amount (){
275
-
276
- global $wpdb;
277
- $wcal_abandoned_orders_amount = 0;
278
-
279
- $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
280
- $cut_off_time = $ac_cutoff_time * 60;
281
- $current_time = current_time( 'timestamp' );
282
- $compare_time = $current_time - $cut_off_time;
283
-
284
- $blank_cart_info = '{"cart":[]}';
285
- $blank_cart_info_guest = '[]';
286
-
287
- $wcal_abandoned_query = "SELECT abandoned_cart_info FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id < 63000000 AND user_id != 0 ";
288
-
289
- $wcal_abandoned_query_result = $wpdb->get_results( $wcal_abandoned_query );
290
-
291
- $wcal_abandoned_orders_amount = self::wcal_get_abandoned_amount( $wcal_abandoned_query_result );
292
-
293
- return $wcal_abandoned_orders_amount;
294
- }
295
-
296
- /**
297
- * Get Guest users total abandoned amount.
298
- * @globals mixed $wpdb
299
- * @return string | int $wcal_abandoned_orders_amount
300
- * @since 3.9
301
- */
302
- private static function wcal_ts_get_guest_users_abandoned_cart_total_amount (){
303
-
304
- global $wpdb;
305
- $wcal_abandoned_orders_amount = 0;
306
-
307
- $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
308
- $cut_off_time = $ac_cutoff_time * 60;
309
- $current_time = current_time( 'timestamp' );
310
- $compare_time = $current_time - $cut_off_time;
311
-
312
- $blank_cart_info = '{"cart":[]}';
313
- $blank_cart_info_guest = '[]';
314
-
315
- $wcal_abandoned_query = "SELECT abandoned_cart_info FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id >= 63000000 AND user_id != 0 ";
316
-
317
- $wcal_abandoned_query_result = $wpdb->get_results( $wcal_abandoned_query );
318
-
319
- $wcal_abandoned_orders_amount = self::wcal_get_abandoned_amount( $wcal_abandoned_query_result );
320
-
321
- return $wcal_abandoned_orders_amount;
322
- }
323
-
324
- /**
325
- * Get logged-in users total recovered amount.
326
- * @globals mixed $wpdb
327
- * @return string | int $wcal_recovered_orders_amount
328
- * @since 3.9
329
- */
330
- private static function wcal_ts_get_logged_in_users_recovered_cart_total_amount(){
331
-
332
- global $wpdb;
333
- $wcal_recovered_orders_amount = 0;
334
-
335
- $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
336
- $cut_off_time = $ac_cutoff_time * 60;
337
- $current_time = current_time( 'timestamp' );
338
- $compare_time = $current_time - $cut_off_time;
339
-
340
- $wcal_recovery_query_amount = "SELECT recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time' AND user_id < 63000000 AND user_id != 0 ";
341
-
342
- $wcal_recovered_order_amount_result = $wpdb->get_results( $wcal_recovery_query_amount );
343
-
344
- $wcal_recovered_orders_amount = self::wcal_get_recovered_amount ($wcal_recovered_order_amount_result );
345
-
346
- return $wcal_recovered_orders_amount;
347
-
348
- }
349
-
350
-
351
- /**
352
- * Get Guest users total recovered amount.
353
- * @globals mixed $wpdb
354
- * @return string | int $wcal_recovered_orders_amount
355
- * @since 3.9
356
- */
357
- private static function wcal_ts_get_guest_users_recovered_cart_total_amount (){
358
-
359
- global $wpdb;
360
- $wcal_recovered_orders_amount = 0;
361
-
362
- $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
363
- $cut_off_time = $ac_cutoff_time * 60;
364
- $current_time = current_time( 'timestamp' );
365
- $compare_time = $current_time - $cut_off_time;
366
-
367
- $wcal_recovery_query_amount = "SELECT recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time' AND user_id >= 63000000 AND user_id != 0 ";
368
-
369
- $wcal_recovered_order_amount_result = $wpdb->get_results( $wcal_recovery_query_amount );
370
-
371
- $wcal_recovered_orders_amount = self::wcal_get_recovered_amount ($wcal_recovered_order_amount_result );
372
-
373
- return $wcal_recovered_orders_amount;
374
-
375
- }
376
- /**
377
- * Get all options of the plugin.
378
- * @return array
379
- * @since 3.9
380
- */
381
- private static function wcal_ts_get_all_plugin_options_values() {
382
-
383
- return array(
384
- 'wcal_cart_cut_off_time' => get_option( 'ac_lite_cart_abandoned_time' ),
385
- 'wcal_admin_recovery_email' => get_option( 'ac_lite_email_admin_on_recovery' ),
386
- 'wcal_capture_visitors_cart' => get_option( 'ac_lite_track_guest_cart_from_cart_page' )
387
- );
388
- }
389
-
390
-
391
- /**
392
- * If admin allow to track the data the it will gather all information and return back.
393
- * @hook ts_tracker_data
394
- * @param array $data
395
- * @return array $data
396
- * @since 3.9
397
- */
398
- public static function ts_add_plugin_tracking_data ( $data ){
399
-
400
- if ( isset( $_GET[ 'wcal_tracker_optin' ] ) && isset( $_GET[ 'wcal_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ 'wcal_tracker_nonce' ], 'wcal_tracker_optin' ) ) {
401
-
402
- $plugin_data[ 'ts_meta_data_table_name'] = 'ts_wcal_tracking_meta_data';
403
-
404
- $plugin_data[ 'ts_plugin_name' ] = 'Abandoned Cart Lite for WooCommerce';
405
-
406
- // Store abandoned count info
407
- $plugin_data[ 'abandoned_orders' ] = self::wcal_ts_get_abandoned_order_counts();
408
-
409
- // Store recovred count info
410
- $plugin_data[ 'recovered_orders' ] = self::wcal_ts_get_recovered_order_counts();
411
-
412
- // store abandoned orders amount
413
- $plugin_data[ 'abandoned_orders_amount' ] = self::wcal_ts_get_abandoned_order_total_amount();
414
-
415
- // Store recovered count info
416
- $plugin_data[ 'recovered_orders_amount' ] = self::wcal_ts_get_recovered_order_total_amount();
417
-
418
- // Store abandoned cart emails sent count info
419
- $plugin_data[ 'sent_emails' ] = self::wcal_ts_get_sent_emails_total_count();
420
-
421
- // Store email template count info
422
- $plugin_data[ 'email_templates_data' ] = self::wcal_ts_get_email_templates_data();
423
-
424
- // Store only logged-in users abandoned cart count info
425
- $plugin_data[ 'logged_in_abandoned_orders' ] = self::wcal_ts_get_logged_in_users_abandoned_cart_total_count();
426
-
427
- // Store only logged-in users abandoned cart count info
428
- $plugin_data[ 'guest_abandoned_orders' ] = self::wcal_ts_get_guest_users_abandoned_cart_total_count();
429
-
430
- // Store only logged-in users abandoned cart amount info
431
- $plugin_data[ 'logged_in_abandoned_orders_amount' ] = self::wcal_ts_get_logged_in_users_abandoned_cart_total_amount();
432
-
433
- // store only guest users abandoned cart amount
434
- $plugin_data[ 'guest_abandoned_orders_amount' ] = self::wcal_ts_get_guest_users_abandoned_cart_total_amount();
435
-
436
- // Store only logged-in users recovered cart amount info
437
- $plugin_data[ 'logged_in_recovered_orders_amount' ] = self::wcal_ts_get_logged_in_users_recovered_cart_total_amount();
438
-
439
- // Store only guest users recovered cart amount
440
- $plugin_data[ 'guest_recovered_orders_amount' ] = self::wcal_ts_get_guest_users_recovered_cart_total_amount();
441
-
442
- // Get all plugin options info
443
- $plugin_data[ 'settings' ] = self::wcal_ts_get_all_plugin_options_values();
444
- $plugin_data[ 'plugin_version' ] = self::wcal_get_version();
445
- $plugin_data[ 'tracking_usage' ] = get_option ('wcal_allow_tracking');
446
-
447
- $data [ 'plugin_data' ] = $plugin_data;
448
- }
449
- return $data;
450
- }
451
-
452
- /**
453
- * Get data when Admin dont want to share information.
454
- * @param array $params
455
- * @return array $params
456
- * @since 3.9
457
- */
458
- public static function ts_get_data_for_opt_out( $params ){
459
-
460
- $plugin_data[ 'ts_meta_data_table_name'] = 'ts_wcal_tracking_meta_data';
461
- $plugin_data[ 'ts_plugin_name' ] = 'Abandoned Cart Lite for WooCommerce';
462
-
463
- $params[ 'plugin_data' ] = $plugin_data;
464
-
465
- return $params;
466
- }
467
-
468
- /**
469
- * It will fetch the total count for the abandoned cart section.
470
- * @param string $get_section_result Name of the section for which we need result
471
- * @return string | int $return_abandoned_count
472
- * @globals mixed $wpdb
473
- * @since 2.5.2
474
- */
475
- public static function wcal_get_abandoned_order_count( $get_section_result ){
476
- global $wpdb;
477
- $return_abandoned_count = 0;
478
- $blank_cart_info = '{"cart":[]}';
479
- $blank_cart_info_guest = '[]';
480
- $blank_cart = '""';
481
- $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
482
- $cut_off_time = intval( $ac_cutoff_time ) * 60;
483
- $current_time = current_time( 'timestamp' );
484
- $compare_time = $current_time - $cut_off_time;
485
-
486
- switch ( $get_section_result ) {
487
- case 'wcal_all_abandoned':
488
- $query_ac = "SELECT COUNT(`id`) as cnt FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE ( user_type = 'REGISTERED' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart' 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_info NOT LIKE '$blank_cart' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 ) ORDER BY recovered_cart desc ";
489
- $return_abandoned_count = $wpdb->get_var( $query_ac );
490
- break;
491
-
492
- case 'wcal_all_registered':
493
- $query_ac = "SELECT COUNT(`id`) FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE ( user_type = 'REGISTERED' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 ) ORDER BY recovered_cart desc ";
494
- $return_abandoned_count = $wpdb->get_var( $query_ac );
495
- break;
496
-
497
- case 'wcal_all_guest':
498
- $query_ac = "SELECT COUNT(`id`) 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_info NOT LIKE '$blank_cart' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 AND user_id >= 63000000 ) ORDER BY recovered_cart desc ";
499
- $return_abandoned_count = $wpdb->get_var( $query_ac );
500
- break;
501
-
502
- case 'wcal_all_visitor':
503
- $query_ac = "SELECT COUNT(`id`) 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_info NOT LIKE '$blank_cart' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 AND user_id = 0 ) ORDER BY recovered_cart desc ";
504
- $return_abandoned_count = $wpdb->get_var( $query_ac );
505
- break;
506
-
507
- default:
508
- # code...
509
- break;
510
- }
511
- return $return_abandoned_count;
512
- }
513
-
514
-
515
- /**
516
- * This function returns the Abandoned Cart Lite plugin version number.
517
- * @return string $plugin_version
518
- * @since 2.5.2
519
- */
520
- public static function wcal_get_version() {
521
- $plugin_version = '';
522
- $wcap_plugin_dir = dirname ( dirname (__FILE__) );
523
- $wcap_plugin_dir .= '/woocommerce-ac.php';
524
-
525
- $plugin_data = get_file_data( $wcap_plugin_dir, array( 'Version' => 'Version' ) );
526
- if ( ! empty( $plugin_data['Version'] ) ) {
527
- $plugin_version = $plugin_data[ 'Version' ];
528
- }
529
- return $plugin_version;
530
- }
531
-
532
- /**
533
- * This function returns the plugin url.
534
- * @return string plugin url
535
- * @since 2.5.2
536
- */
537
- public static function wcal_get_plugin_url() {
538
- return plugins_url() . '/woocommerce-abandoned-cart/';
539
- }
540
-
541
- /**
542
- * This function will alter Email Templates Table to include emojis
543
- *
544
- * @return bool true if success else false
545
- *
546
- * @since 4.8
547
- */
548
- public static function update_templates_table(){
549
-
550
- global $wpdb;
551
- require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
552
-
553
- $query = "ALTER TABLE " . $wpdb->prefix . "ac_email_templates_lite" . " CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
554
-
555
- return $wpdb->query( $query );
556
- }
557
-
558
- /**
559
- * This function will show a dismissible success message after DB update is completed
560
- *
561
- * @since 4.8
562
- */
563
- public static function show_update_success() {
564
- ?>
565
-
566
- <div class="notice notice-success is-dismissible">
567
- <p><strong><?php _e( 'Database Updated Successfully', 'woocommerce-abandoned-cart');?></strong></p>
568
- </div>
569
-
570
- <?php
571
- }
572
-
573
- /**
574
- * This function will show a dismissible success message after DB update is completed
575
- *
576
- * @since 4.8
577
- */
578
- public static function show_update_failure() {
579
- ?>
580
-
581
- <div class="notice notice-error is-dismissible">
582
- <p><strong><?php _e( 'Database Update Failed. Please try again after sometime', 'woocommerce-abandoned-cart');?></strong></p>
583
- </div>
584
-
585
- <?php
586
- }
587
- /**
588
- * Returns an array of customer billing information.
589
- * Should be called only for registered users.
590
- *
591
- * @param integer $user_id - User ID
592
- * @return array $billing_details - Contains Billing Address Details
593
- * @global $woocommerce
594
- * @since 4.9
595
- */
596
- public static function wcal_get_billing_details( $user_id ) {
597
- global $woocommerce;
598
-
599
- $billing_details = array();
600
-
601
- $user_billing_company_temp = get_user_meta( $user_id, 'billing_company' );
602
- $user_billing_company = "";
603
- if ( isset( $user_billing_company_temp[0] ) ){
604
- $user_billing_company = $user_billing_company_temp[0];
605
- }
606
- $billing_details[ 'billing_company' ] = $user_billing_company;
607
-
608
- $user_billing_address_1_temp = get_user_meta( $user_id, 'billing_address_1' );
609
- $user_billing_address_1 = "";
610
- if ( isset( $user_billing_address_1_temp[0] ) ) {
611
- $user_billing_address_1 = $user_billing_address_1_temp[0];
612
- }
613
- $billing_details[ 'billing_address_1' ] = $user_billing_address_1;
614
-
615
- $user_billing_address_2_temp = get_user_meta( $user_id, 'billing_address_2' );
616
- $user_billing_address_2 = "";
617
- if ( isset( $user_billing_address_2_temp[0] ) ) {
618
- $user_billing_address_2 = $user_billing_address_2_temp[0];
619
- }
620
- $billing_details[ 'billing_address_2' ] = $user_billing_address_2;
621
-
622
- $user_billing_city_temp = get_user_meta( $user_id, 'billing_city' );
623
- $user_billing_city = "";
624
- if ( isset( $user_billing_city_temp[0] ) ) {
625
- $user_billing_city = $user_billing_city_temp[0];
626
- }
627
- $billing_details[ 'billing_city' ] = $user_billing_city;
628
-
629
- $user_billing_postcode_temp = get_user_meta( $user_id, 'billing_postcode' );
630
- $user_billing_postcode = "";
631
- if ( isset( $user_billing_postcode_temp[0] ) ) {
632
- $user_billing_postcode = $user_billing_postcode_temp[0];
633
- }
634
- $billing_details[ 'billing_postcode' ] = $user_billing_postcode;
635
-
636
- $user_billing_country_temp = get_user_meta( $user_id, 'billing_country' );
637
- $user_billing_country = "";
638
- if ( isset( $user_billing_country_temp[0] ) && '' != $user_billing_country_temp[0] ) {
639
- $user_billing_country = $user_billing_country_temp[0];
640
- if ( isset( $woocommerce->countries->countries[ $user_billing_country ] ) || '' != ( $woocommerce->countries->countries[ $user_billing_country ] ) ) {
641
- $user_billing_country = WC()->countries->countries[ $user_billing_country ];
642
- }else {
643
- $user_billing_country = "";
644
- }
645
- }
646
- $billing_details[ 'billing_country' ] = $user_billing_country;
647
-
648
- $user_billing_state_temp = get_user_meta( $user_id, 'billing_state' );
649
- $user_billing_state = "";
650
- if ( isset( $user_billing_state_temp[0] ) ) {
651
- $user_billing_state = $user_billing_state_temp[0];
652
- if ( isset( $woocommerce->countries->states[ $user_billing_country_temp[0] ][ $user_billing_state ] ) ) {
653
- $user_billing_state = WC()->countries->states[ $user_billing_country_temp[0] ][ $user_billing_state ];
654
- }else {
655
- $user_billing_state = "";
656
- }
657
- }
658
- $billing_details[ 'billing_state' ] = $user_billing_state;
659
-
660
- return $billing_details;
661
- }
662
-
663
-
664
- /**
665
- * Returns the Item Name, Qty and Total for any given product
666
- * in the WC Cart
667
- *
668
- * @param stdClass $v - Cart Information from WC()->cart;
669
- * @return array $item_details - Item Data
670
- * @global $woocommerce
671
- * @since 4.9
672
- */
673
- public static function wcal_get_cart_details( $v ) {
674
- global $woocommerce;
675
-
676
- $cart_total = $item_subtotal = $item_total = $line_subtotal_tax_display = $after_item_subtotal = $after_item_subtotal_display = 0;
677
-
678
- $line_subtotal_tax = '';
679
- $quantity_total = 0;
680
-
681
- $item_details = array();
682
-
683
- $quantity_total = $v->quantity;
684
- $product_id = $v->product_id;
685
- $prod_name = get_post( $product_id );
686
- $product_name = $prod_name->post_title;
687
-
688
- if ( isset( $v->variation_id ) && '' != $v->variation_id ){
689
- $variation_id = $v->variation_id;
690
- $variation = wc_get_product( $variation_id );
691
- $name = $variation->get_formatted_name() ;
692
- $explode_all = explode ( "&ndash;", $name );
693
- if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
694
- $wcap_sku = '';
695
- if ( $variation->get_sku() ) {
696
- $wcap_sku = "SKU: " . $variation->get_sku() . "<br>";
697
- }
698
- $wcap_get_formatted_variation = wc_get_formatted_variation( $variation, true );
699
-
700
- $add_product_name = $product_name . ' - ' . $wcap_sku . $wcap_get_formatted_variation;
701
-
702
- $pro_name_variation = (array) $add_product_name;
703
- }else{
704
- $pro_name_variation = array_slice( $explode_all, 1, -1 );
705
- }
706
- $product_name_with_variable = '';
707
- $explode_many_varaition = array();
708
- foreach( $pro_name_variation as $pro_name_variation_key => $pro_name_variation_value ) {
709
- $explode_many_varaition = explode ( ",", $pro_name_variation_value );
710
- if( !empty( $explode_many_varaition ) ) {
711
- foreach( $explode_many_varaition as $explode_many_varaition_key => $explode_many_varaition_value ) {
712
- $product_name_with_variable = $product_name_with_variable . html_entity_decode ( $explode_many_varaition_value ) . "<br>";
713
- }
714
- } else {
715
- $product_name_with_variable = $product_name_with_variable . html_entity_decode ( $explode_many_varaition_value ) . "<br>";
716
- }
717
- }
718
- $product_name = $product_name_with_variable;
719
- }
720
- $item_subtotal = 0;
721
- // Item subtotal is calculated as product total including taxes
722
- if ( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
723
- $item_subtotal = $item_subtotal + $v->line_total + $v->line_subtotal_tax;
724
- } else {
725
- $item_subtotal = $item_subtotal + $v->line_total;
726
- }
727
- // Line total
728
- $item_total = $item_subtotal;
729
- $item_subtotal = $item_subtotal / $quantity_total;
730
- $item_total = wc_price( $item_total );
731
- $item_subtotal = wc_price( $item_subtotal );
732
-
733
- $item_details[ 'product_name' ] = $product_name;
734
- $item_details[ 'item_total_formatted' ] = $item_subtotal;
735
- $item_details[ 'item_total' ] = $item_total;
736
- $item_details[ 'qty' ] = $quantity_total;
737
-
738
- return $item_details;
739
- }
740
- }
741
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
woocommerce-abandoned-cart/includes/wcal_default-settings.php DELETED
@@ -1,61 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Abandoned Cart Lite for WooCommerce
5
- *
6
- * It will add the default template for the plugin.
7
- *
8
- * @author Tyche Softwares
9
- * @package Abandoned-Cart-Lite-for-WooCommerce/Admin/Default-Template
10
- * @since 2.5
11
- */
12
-
13
- class wcal_default_template_settings {
14
-
15
- /**
16
- * This function will load default template while activating the plugin.
17
- * @globals mixed $wpdb
18
- * @since 2.5
19
- */
20
- function wcal_create_default_templates() {
21
- global $wpdb;
22
- $template_name_array = 'Initial';
23
- $site_title = get_bloginfo( 'name' );
24
- $site_url = get_option( 'siteurl' );
25
- $template_subject_array = $site_title . ": Did you have checkout trouble?";
26
- $active_post_array = 0;
27
- $email_frequency_array = 1;
28
- $day_or_hour_array = 'Hours';
29
- $body_content_array = addslashes( "<html>
30
- <body>
31
- <p> Hello {{customer.fullname}}, </p>
32
- <p> &nbsp; </p>
33
- <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>
34
- <p> &nbsp; </p>
35
- <p> {{products.cart}} </p>
36
- <p> &nbsp; </p>
37
- <p> If you had any purchase troubles, could you please Contact to share them? </p>
38
- <p> &nbsp; </p>
39
- <p> Otherwise, how about giving us another chance? Shop <a href= $site_url >$site_title</a>. </p>
40
- <hr></hr>
41
- <p> You may <a href='{{cart.unsubscribe}}'>unsubscribe</a> to stop receiving these emails. </p>
42
- <p> &nbsp; </p>
43
- <p> <a href=$site_url>$site_title</a> appreciates your business. </p>
44
- </body>
45
- </html>" );
46
- $is_wc_template = 1 ;
47
- $default_template = 1;
48
-
49
- $query = "INSERT INTO `" . $wpdb->prefix . "ac_email_templates_lite`
50
- ( subject, body, is_active, frequency, day_or_hour, template_name, is_wc_template, default_template )
51
- VALUES ( '" . $template_subject_array . "',
52
- '" . $body_content_array . "',
53
- '" . $active_post_array . "',
54
- '" . $email_frequency_array . "',
55
- '" . $day_or_hour_array . "',
56
- '" . $template_name_array . "',
57
- '" . $is_wc_template . "',
58
- '" . $default_template . "' )";
59
- $wpdb->query( $query );
60
- }
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
woocommerce-abandoned-cart/views/wcal-email-template-preview.php DELETED
@@ -1,67 +0,0 @@
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
- /**
10
- * Abandoned Cart Lite for WooCommerce
11
- *
12
- * It will handle the common action for the plugin.
13
- *
14
- * @author Tyche Softwares
15
- * @package Abandoned-Cart-Lite-for-WooCommerce/Admin/Template-view
16
- * @since 2.5.2
17
- */
18
-
19
- $current_time_stamp = current_time( 'timestamp' );
20
- $date_format = date_i18n( get_option( 'date_format' ), $current_time_stamp );
21
- $time_format = date_i18n( get_option( 'time_format' ), $current_time_stamp );
22
- $test_date = $date_format . ' ' . $time_format;
23
- $wcal_price = wc_price( '150' );
24
- $wcal_total_price = wc_price( '300' );
25
- ?>
26
- <html>
27
- <head>
28
- <title>My document title</title>
29
- </head>
30
- <body>
31
- <p align="center"> Hello John Carter, </p>
32
- <p> &nbsp; </p>
33
- <p align="center"> We're following up with you, because we noticed that on <?php echo "$test_date"; ?> you attempted to purchase the following products on <?php echo get_option( 'blogname' );?>. </p>
34
- <p> &nbsp; </p>
35
- <p>
36
- <table border="0" cellspacing="5" align="center"><caption><b>Cart Details</b></caption>
37
- <tbody>
38
- <tr>
39
- <th></th>
40
- <th>Product</th>
41
- <th>Price</th>
42
- <th>Quantity</th>
43
- <th>Total</th>
44
- </tr>
45
- <tr style="background-color:#f4f5f4;">
46
- <td><img src = "<?php echo plugins_url();?>/woocommerce-abandoned-cart/assets/images/spectre.jpg" height="40px" width="40px"></td><td>Spectre</td><td> <?php echo "$wcal_price"; ?></td><td>2</td><td><?php echo "$wcal_total_price"; ?> </td>
47
- </tr>
48
- <tr>
49
- <td>&nbsp;</td>
50
- <td>&nbsp;</td>
51
- <td>&nbsp;</td>
52
- <th>Cart Total:</th>
53
- <td><?php echo "$wcal_total_price"; ?></td>
54
- </tr>
55
- </tbody>
56
- </table>
57
- </p>
58
- <p> &nbsp; </p>
59
- <p align="center"> If you had any purchase troubles, could you please Contact to share them? </p>
60
- <p> &nbsp; </p>
61
- <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>
62
- <hr></hr>
63
- <p align="center"> You may <a href="<?php echo get_option( 'siteurl' );?>">unsubscribe</a> to stop receiving these emails. </p>
64
- <p> &nbsp; </p>
65
- <p align="center"> <a href="<?php echo get_option( 'siteurl' );?>"><?php echo get_option( 'blogname' );?></a> appreciates your business. </p>
66
- </body>
67
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
woocommerce-abandoned-cart/views/wcal-wc-email-template-preview.php DELETED
@@ -1,61 +0,0 @@
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
- * Abandoned Cart Lite for WooCommerce
10
- *
11
- * It will handle the common action for the plugin.
12
- *
13
- * @author Tyche Softwares
14
- * @package Abandoned-Cart-Lite-for-WooCommerce/Admin/Template-view
15
- * @since 2.5.2
16
- */
17
-
18
- $current_time_stamp = current_time( 'timestamp' );
19
- $date_format = date_i18n( get_option( 'date_format' ), $current_time_stamp );
20
- $time_format = date_i18n( get_option( 'time_format' ), $current_time_stamp );
21
- $test_date = $date_format . ' ' . $time_format;
22
- $wcal_price = wc_price( '150' );
23
- $wcal_total_price = wc_price( '300' );
24
- ?>
25
- <body>
26
- <p> Hello John Carter, </p>
27
- <p> &nbsp; </p>
28
- <p> We're following up with you, because we noticed that on <?php echo "$test_date"; ?> you attempted to purchase the following products on <?php echo get_option( 'blogname' );?>. </p>
29
- <p> &nbsp; </p>
30
- <p>
31
- <table border="0" cellspacing="5" align="center"><caption><b>Cart Details</b></caption>
32
- <tbody>
33
- <tr>
34
- <th></th>
35
- <th>Product</th>
36
- <th>Price</th>
37
- <th>Quantity</th>
38
- <th>Total</th>
39
- </tr>
40
- <tr style="background-color:#f4f5f4;">
41
- <td><img src = "<?php echo plugins_url();?>/woocommerce-abandoned-cart/assets/images/spectre.jpg" height="40px" width="40px"></td><td>Spectre</td><td> <?php echo "$wcal_price"; ?> </td><td>2</td><td><?php echo "$wcal_total_price"; ?> </td>
42
- </tr>
43
- <tr>
44
- <td>&nbsp;</td>
45
- <td>&nbsp;</td>
46
- <td>&nbsp;</td>
47
- <th>Cart Total:</th>
48
- <td><?php echo "$wcal_total_price"; ?></td>
49
- </tr>
50
- </tbody>
51
- </table>
52
- </p>
53
- <p> &nbsp; </p>
54
- <p> If you had any purchase troubles, could you please Contact to share them? </p>
55
- <p> &nbsp; </p>
56
- <p> Otherwise, how about giving us another chance? Shop <a href="<?php echo get_option( 'siteurl' );?>"><?php echo get_option( 'blogname' );?></a>. </p>
57
- <hr></hr>
58
- <p> You may <a href="<?php echo get_option( 'siteurl' );?>">unsubscribe</a> to stop receiving these emails. </p>
59
- <p> &nbsp; </p>
60
- <p> <a href="<?php echo get_option( 'siteurl' );?>"><?php echo get_option( 'blogname' );?></a> appreciates your business. </p>
61
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
woocommerce-abandoned-cart/woocommerce-ac.php → woocommerce-ac.php RENAMED
@@ -5,14 +5,14 @@
5
  * Description: This plugin captures abandoned carts by logged-in users & emails them about it.
6
  * <strong><a href="http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro">Click here to get the
7
  * PRO Version.</a></strong>
8
- * Version: 5.0.2
9
  * Author: Tyche Softwares
10
  * Author URI: http://www.tychesoftwares.com/
11
  * Text Domain: woocommerce-abandoned-cart
12
  * Domain Path: /i18n/languages/
13
  * Requires PHP: 5.6
14
  * WC requires at least: 3.0.0
15
- * WC tested up to: 3.4.4
16
  *
17
  * @package Abandoned-Cart-Lite-for-WooCommerce
18
  */
@@ -32,11 +32,6 @@ require_once( 'includes/wcal_data_tracking_message.php' );
32
  require_once( 'includes/admin/wcal_privacy_erase.php' );
33
  require_once( 'includes/admin/wcal_privacy_export.php' );
34
 
35
- if ( is_admin() ) {
36
- require_once( 'includes/wcal_all_component.php' );
37
-
38
- }
39
-
40
  // Add a new interval of 15 minutes
41
  add_filter( 'cron_schedules', 'wcal_add_cron_schedule' );
42
 
@@ -66,6 +61,14 @@ if ( ! wp_next_scheduled( 'woocommerce_ac_send_email_action' ) ) {
66
  wp_schedule_event( time(), '15_minutes_lite', 'woocommerce_ac_send_email_action' );
67
  }
68
 
 
 
 
 
 
 
 
 
69
  /**
70
  * Hook into that action that'll fire every 15 minutes
71
  */
@@ -179,11 +182,14 @@ function woocommerce_ac_delete_lite() {
179
  delete_option( 'wcal_logged_cart_capture_msg' );
180
 
181
  delete_option( 'ac_lite_delete_abandoned_order_days' );
 
 
 
182
  }
183
  /**
184
  * woocommerce_abandon_cart_lite class
185
  **/
186
- if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
187
 
188
 
189
  /**
@@ -240,6 +246,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
240
 
241
  // Initialize settings
242
  register_activation_hook ( __FILE__, array( &$this, 'wcal_activate' ) );
 
 
 
 
243
 
244
  // WordPress Administration Menu
245
  add_action ( 'admin_menu', array( &$this, 'wcal_admin_menu' ) );
@@ -260,6 +270,8 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
260
 
261
  // Language Translation
262
  add_action ( 'init', array( &$this, 'wcal_update_po_file' ) );
 
 
263
 
264
  // track links
265
  add_filter( 'template_include', array( &$this, 'wcal_email_track_links' ), 99, 1 );
@@ -271,7 +283,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
271
  add_action ( 'admin_enqueue_scripts', array( &$this, 'wcal_enqueue_scripts_css' ) );
272
  //delete abandoned order after X number of days
273
  if ( class_exists( 'wcal_delete_bulk_action_handler' ) ) {
274
- add_action( 'admin_init', array( 'wcal_delete_bulk_action_handler', 'wcal_delete_abandoned_carts_after_x_days' ) );
275
  }
276
 
277
  if ( is_admin() ) {
@@ -302,7 +314,18 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
302
 
303
  add_action( 'admin_notices', array( 'Wcal_Admin_Notice', 'wcal_show_db_update_notice' ) );
304
  }
305
-
 
 
 
 
 
 
 
 
 
 
 
306
  /**
307
  * It will add the Questions while admin deactivate the plugin.
308
  * @hook ts_deativate_plugin_questions
@@ -352,11 +375,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
352
  * @since 3.4
353
  */
354
  public static function wcal_order_placed( $order_id ) {
355
- if( session_id() === '' ) {
356
- //session has not started
357
- session_start();
358
- }
359
-
360
  /**
361
  * When user comes from the abandoned cart reminder email this conditon will be executed.
362
  * It will check the guest uers data in further 3 conditions.
@@ -366,15 +385,16 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
366
  * 3. When user places the orde as guest user.
367
  * It will consider the old cart of the customer as the recovered order and delete the unwanted new records.
368
  */
369
- if ( isset( $_SESSION['email_sent_id'] ) && $_SESSION['email_sent_id'] !='' ) {
 
 
 
370
  global $woocommerce, $wpdb;
371
 
372
  $wcal_history_table_name = $wpdb->prefix . 'ac_abandoned_cart_history_lite';
373
  $wcal_guest_table_name = $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite';
374
  $wcal_sent_email_table_name = $wpdb->prefix . 'ac_sent_history_lite';
375
 
376
- $email_sent_id = $_SESSION['email_sent_id'];
377
-
378
  $get_ac_id_query = "SELECT abandoned_order_id FROM ". $wcal_sent_email_table_name ." WHERE id = %d";
379
  $get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query, $email_sent_id ) );
380
 
@@ -386,17 +406,11 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
386
  $wcal_account_password_check = 'no';
387
 
388
  /*if user becomes the registered user */
389
- if ( isset( $_POST['account_password'] ) && $_POST['account_password'] != '' ) {
390
 
391
- $abandoned_cart_id_new_user = '';
392
- if ( isset( $_SESSION['abandoned_cart_id_lite'] ) && '' != $_SESSION['abandoned_cart_id_lite'] ) {
393
- $abandoned_cart_id_new_user = $_SESSION['abandoned_cart_id_lite'];
394
- }
395
 
396
- $wcal_user_id_of_guest = '';
397
- if ( isset( $_SESSION['user_id'] ) && '' != $_SESSION['user_id'] ) {
398
- $wcal_user_id_of_guest = $_SESSION['user_id'];
399
- }
400
 
401
  /* delete the guest record. As it become the logged in user */
402
 
@@ -406,7 +420,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
406
  $get_ac_id_guest_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_guest_query, $wcal_user_id_of_guest ) );
407
  }
408
 
409
- if ( count ($get_ac_id_guest_results) > 1 ) {
410
  $abandoned_order_id_of_guest = $get_ac_id_guest_results[0]->id;
411
  $wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_order_id_of_guest ) );
412
  }
@@ -424,13 +438,11 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
424
  $_POST['createaccount'] != '' &&
425
  'no' == $wcal_account_password_check ) {
426
 
427
- $abandoned_cart_id_new_user = '';
428
- if ( isset ( $_SESSION['abandoned_cart_id_lite'] ) && '' != $_SESSION['abandoned_cart_id_lite'] ) {
429
- $abandoned_cart_id_new_user = $_SESSION['abandoned_cart_id_lite'];
430
- }
431
  $wcal_user_id_of_guest = '';
432
  if ( isset( $_SESSION['user_id'] ) && '' != $_SESSION['user_id'] ) {
433
- $wcal_user_id_of_guest = $_SESSION['user_id'];
434
  }
435
  /* Delete the guest record. As it become the logged in user */
436
  $get_ac_id_guest_results = array();
@@ -438,7 +450,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
438
  $get_ac_id_guest_query = "SELECT id FROM `" . $wcal_history_table_name ."` WHERE user_id = %d ORDER BY id DESC";
439
  $get_ac_id_guest_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_guest_query, $wcal_user_id_of_guest ) );
440
  }
441
- if ( count ($get_ac_id_guest_results) > 1 ){
442
  $abandoned_order_id_of_guest = $get_ac_id_guest_results[0]->id;
443
  $wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_order_id_of_guest ) );
444
  }
@@ -459,7 +471,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
459
  $get_ac_id_guest_query = "SELECT id FROM `" . $wcal_history_table_name ."` WHERE user_id = %d ORDER BY id DESC";
460
  $get_ac_id_guest_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_guest_query, $wcal_user_id_of_guest ) );
461
 
462
- if ( count ($get_ac_id_guest_results) > 1 ) {
463
  $abandoned_order_id_of_guest = $get_ac_id_guest_results[0]->id;
464
  $wpdb->delete( $wcal_history_table_name, array( 'id' => $abandoned_order_id_of_guest ) );
465
  }
@@ -471,7 +483,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
471
  add_post_meta( $order_id , 'wcal_recover_order_placed', $abandoned_order_id );
472
  }
473
 
474
- }else if ( isset( $_SESSION['abandoned_cart_id_lite'] ) && $_SESSION['abandoned_cart_id_lite'] != '' ) {
475
 
476
  /**
477
  * In this codition we are cheking that if the order is placed before the cart cut off time then we
@@ -480,26 +492,23 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
480
  * the abandoned cart id. So we will refer this abandoned cart id when order staus is changed
481
  * while placing the order.
482
  */
483
- if( session_id() === '' ){
484
- //session has not started
485
- session_start();
486
- }
487
-
488
  global $woocommerce, $wpdb;
489
 
490
  $wcal_history_table_name = $wpdb->prefix . 'ac_abandoned_cart_history_lite';
491
  $wcal_guest_table_name = $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite';
492
  $wcal_sent_email_table_name = $wpdb->prefix . 'ac_sent_history_lite';
493
 
494
- $current_time = current_time( 'timestamp' );
495
  $wcal_cart_abandoned_time = '';
496
- if ( isset( $_SESSION['abandoned_cart_id_lite'] ) && '' != $_SESSION['abandoned_cart_id_lite'] ) {
497
- $wcal_abandoned_cart_id = $_SESSION['abandoned_cart_id_lite'];
 
 
498
 
499
  $get_abandoned_cart_query = "SELECT abandoned_cart_time FROM `" . $wcal_history_table_name . "` WHERE id = %d ";
500
  $get_abandoned_cart_results = $wpdb->get_results( $wpdb->prepare( $get_abandoned_cart_query, $wcal_abandoned_cart_id ) );
501
 
502
- if ( count( $get_abandoned_cart_results ) > 0 ){
503
  $wcal_cart_abandoned_time = $get_abandoned_cart_results[0]->abandoned_cart_time;
504
  }
505
 
@@ -507,10 +516,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
507
  $cut_off_time = $ac_cutoff_time * 60;
508
  $compare_time = $current_time - $cut_off_time;
509
 
510
- if ( $compare_time > $wcal_cart_abandoned_time ) {
511
  /* cart is declared as adandoned */
512
  add_post_meta( $order_id , 'wcal_recover_order_placed', $wcal_abandoned_cart_id );
513
- }else {
514
  /**
515
  * Cart order is placed within the cutoff time.
516
  * We will delete that abandoned cart.
@@ -518,10 +527,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
518
 
519
  /* If user becomes the registred user */
520
 
521
- if ( isset( $_POST['account_password'] ) && $_POST['account_password'] != '' ) {
522
 
523
- $abandoned_cart_id_new_user = $_SESSION['abandoned_cart_id_lite'];
524
- $wcal_user_id_of_guest = $_SESSION['user_id'];
525
 
526
  /* Delete the guest record. As it become the logged in user */
527
 
@@ -530,7 +539,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
530
 
531
  /* It is the new registered users cart id */
532
  $wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_cart_id_new_user ) );
533
- }else {
534
 
535
  /**
536
  * It will delete the order from history table if the order is placed before any email sent to
@@ -539,9 +548,8 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
539
  $wpdb->delete( $wcal_history_table_name , array( 'id' => $wcal_abandoned_cart_id ) );
540
 
541
  /* This user id is set for the guest uesrs. */
542
- if ( isset( $_SESSION['user_id'] ) && $_SESSION['user_id'] != '' ) {
543
-
544
- $wcal_user_id_of_guest = $_SESSION['user_id'];
545
  $wpdb->delete( $wcal_guest_table_name, array( 'id' => $wcal_user_id_of_guest ) );
546
  }
547
  }
@@ -606,12 +614,12 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
606
  if ( count( $get_abandoned_cart_user_id_results ) > 0 ) {
607
  $wcap_user_id = $get_abandoned_cart_user_id_results[0]->user_id;
608
 
609
- if ( $wcap_user_id >= 63000000 ){
610
- $wpdb->delete( $wcal_guest_ac_table_name , array( 'id' => $wcap_user_id ) );
611
  }
612
 
613
- $wpdb->delete( $wcal_ac_table_name , array( 'id' => $get_abandoned_id_of_order ) );
614
- delete_post_meta( $order_id, 'wcap_recover_order_placed', $get_abandoned_id_of_order );
615
  }
616
  }
617
  }
@@ -626,13 +634,13 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
626
  */
627
  public function wcal_preview_emails() {
628
  global $woocommerce;
629
- if( isset( $_GET['wcal_preview_woocommerce_mail'] ) ) {
630
- if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-abandoned-cart' ) ) {
631
  die( 'Security check' );
632
  }
633
  $message = '';
634
  // create a new email
635
- if( $woocommerce->version < '2.3' ) {
636
  global $email_heading;
637
  ob_start();
638
 
@@ -666,7 +674,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
666
  // get the preview email content
667
  ob_start();
668
  include( 'views/wcal-email-template-preview.php' );
669
- $message = ob_get_clean();
670
  // print the preview email
671
  echo $message;
672
  exit;
@@ -703,21 +711,21 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
703
  function wcal_activate() {
704
  global $wpdb;
705
  $wcap_collate = '';
706
- if( $wpdb->has_cap( 'collation' ) ) {
707
  $wcap_collate = $wpdb->get_charset_collate();
708
  }
709
  $table_name = $wpdb->prefix . "ac_email_templates_lite";
710
  $sql = "CREATE TABLE IF NOT EXISTS $table_name (
711
  `id` int(11) NOT NULL AUTO_INCREMENT,
712
- `subject` text COLLATE utf8mb4_unicode_ci NOT NULL,
713
- `body` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL,
714
- `is_active` enum('0','1') COLLATE utf8mb4_unicode_ci NOT NULL,
715
  `frequency` int(11) NOT NULL,
716
- `day_or_hour` enum('Days','Hours') COLLATE utf8mb4_unicode_ci NOT NULL,
717
- `template_name` text COLLATE utf8mb4_unicode_ci NOT NULL,
718
- `is_wc_template` enum('0','1') COLLATE utf8_unicode_ci NOT NULL,
719
- `default_template` int(11) COLLATE utf8_unicode_ci NOT NULL,
720
- `wc_email_header` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
721
  PRIMARY KEY (`id`)
722
  ) $wcap_collate AUTO_INCREMENT=1 ";
723
 
@@ -770,11 +778,11 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
770
  // Default templates: function call to create default templates.
771
  $check_table_empty = $wpdb->get_var( "SELECT COUNT(*) FROM `" . $wpdb->prefix . "ac_email_templates_lite`" );
772
 
773
- if( !get_option( 'woocommerce_ac_default_templates_installed' ) ) {
774
- if( 0 == $check_table_empty ) {
775
  $default_template = new wcal_default_template_settings;
776
  $default_template->wcal_create_default_templates();
777
- update_option( 'woocommerce_ac_default_templates_installed', "yes" );
778
  }
779
  }
780
 
@@ -782,7 +790,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
782
  $query_guest_table = "SHOW TABLES LIKE '$guest_table' ";
783
  $result_guest_table = $wpdb->get_results( $query_guest_table );
784
 
785
- if ( count( $result_guest_table ) == 0 ) {
786
  $ac_guest_history_table_name = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
787
  $ac_guest_history_query = "CREATE TABLE IF NOT EXISTS $ac_guest_history_table_name (
788
  `id` int(15) NOT NULL AUTO_INCREMENT,
@@ -817,18 +825,18 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
817
  * This is add for thos user who Install the plguin first time.
818
  * So for them this option will be cheked.
819
  */
820
- if( !get_option( 'ac_lite_track_guest_cart_from_cart_page' ) ) {
821
  add_option( 'ac_lite_track_guest_cart_from_cart_page', 'on' );
822
  }
823
- if( !get_option( 'wcal_from_name' ) ) {
824
  add_option( 'wcal_from_name', 'Admin' );
825
  }
826
  $wcal_get_admin_email = get_option( 'admin_email' );
827
- if( !get_option( 'wcal_from_email' ) ) {
828
  add_option( 'wcal_from_email', $wcal_get_admin_email );
829
  }
830
 
831
- if( !get_option( 'wcal_reply_email' ) ) {
832
  add_option( 'wcal_reply_email', $wcal_get_admin_email );
833
  }
834
 
@@ -844,10 +852,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
844
 
845
  // First, we register a section. This is necessary since all future options must belong to a
846
  add_settings_section(
847
- 'ac_lite_general_settings_section', // ID used to identify this section and with which to register options
848
- __( 'Settings', 'woocommerce-abandoned-cart' ), // Title to be displayed on the administration page
849
- array($this, 'ac_lite_general_options_callback' ), // Callback used to render the description of the section
850
- 'woocommerce_ac_page' // Page on which to add this section of options
851
  );
852
 
853
  add_settings_field(
@@ -912,10 +920,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
912
  */
913
 
914
  add_settings_section(
915
- 'ac_email_settings_section', // ID used to identify this section and with which to register options
916
- __( 'Settings for abandoned cart recovery emails', 'woocommerce-abandoned-cart' ), // Title to be displayed on the administration page
917
- array($this, 'wcal_email_callback' ),// Callback used to render the description of the section
918
- 'woocommerce_ac_email_page' // Page on which to add this section of options
919
  );
920
 
921
  add_settings_field(
@@ -1029,7 +1037,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1029
  */
1030
  function ac_lite_cart_time_validation( $input ) {
1031
  $output = '';
1032
- if ( $input != '' && ( is_numeric( $input) && $input > 0 ) ) {
1033
  $output = stripslashes( $input) ;
1034
  } else {
1035
  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-abandoned-cart' ) );
@@ -1045,7 +1053,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1045
  */
1046
  public static function wcal_delete_days_validation( $input ) {
1047
  $output = '';
1048
- if ( $input == '' || ( is_numeric( $input ) && $input > 0 ) ) {
1049
  $output = stripslashes( $input );
1050
  } else {
1051
  add_settings_error( 'ac_lite_delete_abandoned_order_days', 'error found', __( 'Automatically Delete Abandoned Orders after X days has to be greater than 0.', 'woocommerce-abandoned-cart' ) );
@@ -1082,7 +1090,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1082
  $email_admin_on_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
1083
 
1084
  // This condition added to avoid the notie displyed while Check box is unchecked.
1085
- if( isset( $email_admin_on_recovery ) && $email_admin_on_recovery == '' ) {
1086
  $email_admin_on_recovery = 'off';
1087
  }
1088
  // Next, we update the name attribute to access this element's ID in the context of the display options array
@@ -1090,8 +1098,8 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1090
  $html='';
1091
  printf(
1092
  '<input type="checkbox" id="ac_lite_email_admin_on_recovery" name="ac_lite_email_admin_on_recovery" value="on"
1093
- ' . checked('on', $email_admin_on_recovery, false).' />'
1094
- );
1095
 
1096
  // Here, we'll take the first argument of the array and add it to a label next to the checkbox
1097
  $html .= '<label for="ac_lite_email_admin_on_recovery"> ' . $args[0] . '</label>';
@@ -1107,7 +1115,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1107
  $disable_guest_cart_from_cart_page = get_option( 'ac_lite_track_guest_cart_from_cart_page' );
1108
 
1109
  // This condition added to avoid the notice displyed while Check box is unchecked.
1110
- if ( isset( $disable_guest_cart_from_cart_page ) && $disable_guest_cart_from_cart_page == '' ) {
1111
  $disable_guest_cart_from_cart_page = 'off';
1112
  }
1113
  // Next, we update the name attribute to access this element's ID in the context of the display options array
@@ -1142,7 +1150,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1142
  * @param array $args Argument for adding field details
1143
  * @since 7.8
1144
  */
1145
- public static function wcal_logged_cart_capture_msg_callback( $args) {
1146
 
1147
  $logged_msg = get_option( 'wcal_logged_cart_capture_msg' );
1148
 
@@ -1173,10 +1181,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1173
  printf(
1174
  '<input type="text" id="wcal_from_name" name="wcal_from_name" value="%s" />',
1175
  isset( $wcal_from_name ) ? esc_attr( $wcal_from_name ) : ''
1176
- );
1177
- // Here, we'll take the first argument of the array and add it to a label next to the checkbox
1178
- $html = '<label for="wcal_from_name_label"> ' . $args[0] . '</label>';
1179
- echo $html;
1180
  }
1181
 
1182
  /**
@@ -1192,10 +1200,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1192
  printf(
1193
  '<input type="text" id="wcal_from_email" name="wcal_from_email" value="%s" />',
1194
  isset( $wcal_from_email ) ? esc_attr( $wcal_from_email ) : ''
1195
- );
1196
- // Here, we'll take the first argument of the array and add it to a label next to the checkbox
1197
- $html = '<label for="wcal_from_email_label"> ' . $args[0] . '</label>';
1198
- echo $html;
1199
  }
1200
 
1201
  /**
@@ -1211,10 +1219,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1211
  printf(
1212
  '<input type="text" id="wcal_reply_email" name="wcal_reply_email" value="%s" />',
1213
  isset( $wcal_reply_email ) ? esc_attr( $wcal_reply_email ) : ''
1214
- );
1215
- // Here, we'll take the first argument of the array and add it to a label next to the checkbox
1216
- $html = '<label for="wcal_reply_email_label"> ' . $args[0] . '</label>';
1217
- echo $html;
1218
  }
1219
 
1220
  /**
@@ -1229,7 +1237,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1229
  $wcal_previous_version = get_option( 'wcal_previous_version' );
1230
 
1231
  if ( $wcal_previous_version != wcal_common::wcal_get_version() ) {
1232
- update_option( 'wcal_previous_version', '5.0.2' );
1233
  }
1234
 
1235
  /**
@@ -1243,12 +1251,19 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1243
  update_option ( 'wcal_guest_user_id_altered', 'yes' );
1244
  }
1245
  }
1246
- if( get_option( 'ac_lite_alter_table_queries' ) != 'yes' ) {
 
 
 
 
 
 
 
1247
  $ac_history_table_name = $wpdb->prefix."ac_abandoned_cart_history_lite";
1248
  $check_table_query = "SHOW COLUMNS FROM $ac_history_table_name LIKE 'user_type'";
1249
  $results = $wpdb->get_results( $check_table_query );
1250
 
1251
- if ( count( $results ) == 0 ) {
1252
  $alter_table_query = "ALTER TABLE $ac_history_table_name ADD `user_type` text AFTER `recovered_cart`";
1253
  $wpdb->get_results( $alter_table_query );
1254
  }
@@ -1257,7 +1272,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1257
  $check_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'is_wc_template' ";
1258
  $results = $wpdb->get_results( $check_template_table_query );
1259
 
1260
- if ( count( $results ) == 0 ) {
1261
  $alter_template_table_query = "ALTER TABLE $table_name
1262
  ADD COLUMN `is_wc_template` enum('0','1') COLLATE utf8_unicode_ci NOT NULL AFTER `template_name`,
1263
  ADD COLUMN `default_template` int(11) NOT NULL AFTER `is_wc_template`";
@@ -1268,9 +1283,9 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1268
  $check_email_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'wc_email_header' ";
1269
  $results_email = $wpdb->get_results( $check_email_template_table_query );
1270
 
1271
- if ( count( $results_email ) == 0 ) {
1272
  $alter_email_template_table_query = "ALTER TABLE $table_name
1273
- ADD COLUMN `wc_email_header` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL AFTER `default_template`";
1274
  $wpdb->get_results( $alter_email_template_table_query );
1275
  }
1276
 
@@ -1294,7 +1309,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1294
  if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_email_templates_lite';" ) ) {
1295
  if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'from_email';" ) ) {
1296
  $get_email_template_query = "SELECT `from_email` FROM {$wpdb->prefix}ac_email_templates_lite WHERE `is_active` = '1' ORDER BY `id` ASC LIMIT 1";
1297
- $get_email_template_result = $wpdb->get_results ($get_email_template_query);
1298
  $wcal_from_email = '';
1299
  if ( isset( $get_email_template_result ) && count ( $get_email_template_result ) > 0 ){
1300
  $wcal_from_email = $get_email_template_result[0]->from_email;
@@ -1307,7 +1322,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1307
 
1308
  if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'from_name';" ) ) {
1309
  $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";
1310
- $get_email_template_from_name_result = $wpdb->get_results ($get_email_template_from_name_query);
1311
  $wcal_from_name = '';
1312
  if ( isset( $get_email_template_from_name_result ) && count ( $get_email_template_from_name_result ) > 0 ){
1313
  $wcal_from_name = $get_email_template_from_name_result[0]->from_name;
@@ -1320,7 +1335,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1320
 
1321
  if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'reply_email';" ) ) {
1322
  $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";
1323
- $get_email_template_reply_email_result = $wpdb->get_results ($get_email_template_reply_email_query);
1324
  $wcal_reply_email = '';
1325
  if ( isset( $get_email_template_reply_email_result ) && count ( $get_email_template_reply_email_result ) > 0 ){
1326
  $wcal_reply_email = $get_email_template_reply_email_result[0]->reply_email;
@@ -1332,7 +1347,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1332
  }
1333
  }
1334
 
1335
- if ( !get_option( 'wcal_security_key' ) ){
1336
  update_option( 'wcal_security_key', 'qJB0rGtIn5UB1xG03efyCp' );
1337
  }
1338
 
@@ -1341,36 +1356,46 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1341
 
1342
  //get the option, if it is not set to individual then convert to individual records and delete the base record
1343
  $ac_settings = get_option( 'ac_lite_settings_status' );
1344
- if ( $ac_settings != 'INDIVIDUAL' ) {
1345
  //fetch the existing settings and save them as inidividual to be used for the settings API
1346
  $woocommerce_ac_settings = json_decode( get_option( 'woocommerce_ac_settings' ) );
1347
 
1348
- if( isset( $woocommerce_ac_settings[0]->cart_time ) ) {
1349
  add_option( 'ac_lite_cart_abandoned_time', $woocommerce_ac_settings[0]->cart_time );
1350
  } else {
1351
  add_option( 'ac_lite_cart_abandoned_time', '10' );
1352
  }
1353
 
1354
- if( isset( $woocommerce_ac_settings[0]->delete_order_days ) ) {
1355
  add_option( 'ac_lite_delete_abandoned_order_days', $woocommerce_ac_settings[0]->delete_order_days );
1356
  } else {
1357
  add_option( 'ac_lite_delete_abandoned_order_days', "" );
1358
  }
1359
 
1360
- if( isset( $woocommerce_ac_settings[0]->email_admin ) ) {
1361
  add_option( 'ac_lite_email_admin_on_recovery', $woocommerce_ac_settings[0]->email_admin );
1362
  } else {
1363
  add_option( 'ac_lite_email_admin_on_recovery', "" );
1364
- }
1365
- if( isset( $woocommerce_ac_settings[0]->disable_guest_cart_from_cart_page ) ) {
 
1366
  add_option( 'ac_lite_track_guest_cart_from_cart_page', $woocommerce_ac_settings[0]->disable_guest_cart_from_cart_page );
1367
  } else {
1368
  add_option( 'ac_lite_track_guest_cart_from_cart_page', "" );
1369
- }
 
1370
  update_option( 'ac_lite_settings_status', 'INDIVIDUAL' );
1371
  //Delete the main settings record
1372
  delete_option( 'woocommerce_ac_settings' );
1373
  }
 
 
 
 
 
 
 
 
1374
  }
1375
 
1376
  /**
@@ -1389,13 +1414,13 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1389
  $user_id = get_current_user_id();
1390
  $ac_email_admin_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
1391
  $order = new WC_Order( $order_id );
1392
- if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
1393
- $user_id = $order->get_user_id();
1394
  } else {
1395
- $user_id = $order->user_id;
1396
  }
1397
 
1398
- if( $ac_email_admin_recovery == 'on' ) {
1399
  $recovered_email_sent = get_post_meta( $order_id, 'wcap_recovered_email_sent', true );
1400
  $created_via = get_post_meta( $order_id, '_created_via', true );
1401
  $wcal_check_order_is_recovered = woocommerce_abandon_cart_lite::wcal_check_order_is_recovered( $order_id );
@@ -1445,13 +1470,13 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1445
 
1446
  $user_id = get_current_user_id();
1447
  $ac_email_admin_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
1448
- if( $ac_email_admin_recovery == 'on' ) {
1449
- $order = new WC_Order( $order_id );
1450
 
1451
- if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
1452
- $user_id = $order->get_user_id();
1453
- }else{
1454
- $user_id = $order->user_id;
1455
  }
1456
  $recovered_email_sent = get_post_meta( $order_id, 'wcap_recovered_email_sent', true );
1457
  $created_via = get_post_meta( $order_id, '_created_via', true );
@@ -1467,11 +1492,11 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1467
  ob_start();
1468
  // Get mail template
1469
  wc_get_template( 'emails/admin-new-order.php', array(
1470
- 'order' => $order,
1471
- 'email_heading' => $email_heading,
1472
- 'sent_to_admin' => false,
1473
- 'plain_text' => false,
1474
- 'email' => true
1475
  ) );
1476
  // Get contents
1477
  $email_body = ob_get_clean();
@@ -1494,7 +1519,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1494
  global $wpdb;
1495
  $wcal_recover_order_query = "SELECT `recovered_cart` FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE `recovered_cart` = %d";
1496
  $wcal_recover_order_query_result = $wpdb->get_results( $wpdb->prepare( $wcal_recover_order_query, $wcal_order_id ) );
1497
- if( count( $wcal_recover_order_query_result ) > 0 ) {
1498
  return true;
1499
  }
1500
  return false;
@@ -1517,24 +1542,20 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1517
  * @since 1.0
1518
  */
1519
  function wcal_store_cart_timestamp() {
1520
-
1521
- if( session_id() === '' ){
1522
- //session has not started
1523
- session_start();
1524
- }
1525
  global $wpdb,$woocommerce;
1526
- $current_time = current_time( 'timestamp' );
1527
- $cut_off_time = get_option( 'ac_lite_cart_abandoned_time' );
1528
  $track_guest_cart_from_cart_page = get_option( 'ac_lite_track_guest_cart_from_cart_page' );
1529
- $cart_ignored = 0;
1530
- $recovered_cart = 0;
1531
 
1532
  $track_guest_user_cart_from_cart = "";
1533
  if ( isset( $track_guest_cart_from_cart_page ) ) {
1534
  $track_guest_user_cart_from_cart = $track_guest_cart_from_cart_page;
1535
  }
1536
 
1537
- if( isset( $cut_off_time ) ) {
1538
  $cart_cut_off_time = intval( $cut_off_time ) * 60;
1539
  } else {
1540
  $cart_cut_off_time = 60 * 60;
@@ -1547,26 +1568,29 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1547
  WHERE user_id = %d
1548
  AND cart_ignored = %s
1549
  AND recovered_cart = %d ";
1550
- $results = $wpdb->get_results($wpdb->prepare( $query, $user_id, $cart_ignored, $recovered_cart ) );
1551
-
1552
- if ( count($results) == 0 ) {
1553
  $wcal_woocommerce_persistent_cart =version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
1554
-
1555
- $cart_info = json_encode( get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true ) );
1556
- $user_type = "REGISTERED";
1557
- $insert_query = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1558
- ( user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type )
1559
- VALUES ( %d, %s, %d, %s, %s )";
1560
- $wpdb->query( $wpdb->prepare( $insert_query, $user_id, $cart_info,$current_time, $cart_ignored, $user_type ) );
1561
-
1562
- $abandoned_cart_id = $wpdb->insert_id;
1563
- $_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
 
 
 
 
1564
  } elseif ( isset( $results[0]->abandoned_cart_time ) && $compare_time > $results[0]->abandoned_cart_time ) {
1565
-
1566
  $wcal_woocommerce_persistent_cart = version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
1567
- $updated_cart_info = json_encode( get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true ) );
1568
-
1569
- if ( ! $this->wcal_compare_carts( $user_id, $results[0]->abandoned_cart_info ) ) {
1570
  $updated_cart_ignored = 1;
1571
  $query_ignored = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1572
  SET cart_ignored = %s
@@ -1582,14 +1606,14 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1582
  update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "yes" ) );
1583
 
1584
  $abandoned_cart_id = $wpdb->insert_id;
1585
- $_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
1586
  } else {
1587
  update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "no" ) );
1588
  }
1589
- } else {
1590
- $wcal_woocommerce_persistent_cart =version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
1591
- $updated_cart_info = json_encode( get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true ) );
1592
-
1593
  $query_update = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1594
  SET abandoned_cart_info = %s,
1595
  abandoned_cart_time = %d
@@ -1597,38 +1621,35 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1597
  AND cart_ignored = %s ";
1598
  $wpdb->query( $wpdb->prepare( $query_update, $updated_cart_info, $current_time, $user_id, $cart_ignored ) );
1599
 
1600
- $query_update = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE user_id ='" . $user_id . "' AND cart_ignored='0' ";
1601
  $get_abandoned_record = $wpdb->get_results( $query_update );
1602
  if ( count( $get_abandoned_record ) > 0 ) {
1603
  $abandoned_cart_id = $get_abandoned_record[0]->id;
1604
- $_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
1605
  }
1606
  }
1607
  } else {
1608
- //start here guest user
1609
- if ( isset( $_SESSION['user_id'] ) ) {
1610
- $user_id = $_SESSION['user_id'];
1611
- } else {
1612
- $user_id = "";
1613
- }
1614
-
1615
  $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'";
1616
  $results = $wpdb->get_results( $wpdb->prepare( $query, $user_id ) );
1617
  $cart = array();
 
1618
  $get_cookie = WC()->session->get_session_cookie();
1619
  if ( function_exists('WC') ) {
1620
  $cart['cart'] = WC()->session->cart;
1621
  } else {
1622
  $cart['cart'] = $woocommerce->session->cart;
1623
  }
1624
-
1625
- $updated_cart_info = json_encode($cart);
1626
- $updated_cart_info = addslashes ( $updated_cart_info );
1627
-
1628
- if ( count($results) > 0 ) {
1629
- if ( $compare_time > $results[0]->abandoned_cart_time ) {
1630
  if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
1631
-
1632
  $query_ignored = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1633
  SET cart_ignored = '1'
1634
  WHERE user_id ='".$user_id."'";
@@ -1653,21 +1674,21 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1653
  * Here we capture the guest cart from the cart page.
1654
  * @since 3.5
1655
  */
1656
- if ( $track_guest_user_cart_from_cart == "on" && $get_cookie[0] != '' ) {
1657
  $query = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE session_id LIKE %s AND cart_ignored = '0' AND recovered_cart = '0' ";
1658
  $results = $wpdb->get_results( $wpdb->prepare( $query, $get_cookie[0] ) );
1659
- if ( count( $results ) == 0 ) {
1660
- $cart_info = $updated_cart_info;
1661
- $blank_cart_info = '[]';
1662
- if ( $blank_cart_info != $cart_info ) {
1663
  $insert_query = "INSERT INTO `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
1664
  ( abandoned_cart_info , abandoned_cart_time , cart_ignored , recovered_cart, user_type, session_id )
1665
  VALUES ( '" . $cart_info."' , '" . $current_time . "' , '0' , '0' , 'GUEST', '". $get_cookie[0] ."' )";
1666
  $wpdb->query( $insert_query );
1667
  }
1668
  } elseif ( $compare_time > $results[0]->abandoned_cart_time ) {
1669
- $blank_cart_info = '[]';
1670
- if ( $blank_cart_info != $updated_cart_info ) {
1671
  if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
1672
  $query_ignored = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET cart_ignored = '1' WHERE session_id ='" . $get_cookie[0] . "'";
1673
  $wpdb->query( $query_ignored );
@@ -1678,8 +1699,8 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1678
  }
1679
  }
1680
  } else {
1681
- $blank_cart_info = '[]';
1682
- if ( $blank_cart_info != $updated_cart_info ) {
1683
  if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
1684
  $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' ";
1685
  $wpdb->query( $query_update );
@@ -1709,26 +1730,26 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1709
  $validate_email_id_decode = 0;
1710
  $cryptKey = get_option( 'wcal_security_key' );
1711
  $validate_email_id_decode = Wcal_Aes_Ctr::decrypt( $validate_email_id_string, $cryptKey, 256 );
1712
- if( isset( $_GET['track_email_id'] ) ) {
1713
  $encoded_email_address = rawurldecode( $_GET['track_email_id'] );
1714
  $validate_email_address_string = str_replace( " " , "+", $encoded_email_address );
1715
- }
1716
  $query_id = "SELECT * FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE id = %d ";
1717
  $results_sent = $wpdb->get_results ( $wpdb->prepare( $query_id, $validate_email_id_decode ) );
1718
  $email_address = '';
1719
- if( isset( $results_sent[0] ) ) {
1720
  $email_address = $results_sent[0]->sent_email_id;
1721
  }
1722
- if( $validate_email_address_string == hash( 'sha256', $email_address ) && '' != $email_address ) {
1723
  $email_sent_id = $validate_email_id_decode;
1724
  $get_ac_id_query = "SELECT abandoned_order_id FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE id = %d";
1725
  $get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query , $email_sent_id ) );
1726
  $user_id = 0;
1727
- if( isset( $get_ac_id_results[0] ) ) {
1728
  $get_user_id_query = "SELECT user_id FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE id = %d";
1729
  $get_user_results = $wpdb->get_results( $wpdb->prepare( $get_user_id_query , $get_ac_id_results[0]->abandoned_order_id ) );
1730
  }
1731
- if( isset( $get_user_results[0] ) ) {
1732
  $user_id = $get_user_results[0]->user_id;
1733
  }
1734
 
@@ -1767,7 +1788,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1767
  $track_link = $_GET['wcal_action'];
1768
  }
1769
  if ( $track_link == 'track_links' ) {
1770
- if( session_id() === '' ) {
1771
  //session has not started
1772
  session_start();
1773
  }
@@ -1779,7 +1800,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1779
  $link_decode = Wcal_Aes_Ctr::decrypt( $validate_encoded_string, $cryptKey, 256 );
1780
  $sent_email_id_pos = strpos( $link_decode, '&' );
1781
  $email_sent_id = substr( $link_decode , 0, $sent_email_id_pos );
1782
- $_SESSION['email_sent_id'] = $email_sent_id;
 
 
 
1783
  $url_pos = strpos( $link_decode, '=' );
1784
  $url_pos = $url_pos + 1;
1785
  $url = substr( $link_decode, $url_pos );
@@ -1790,11 +1814,11 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1790
  $get_user_id_query = "SELECT user_id FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE id = %d";
1791
  $get_user_results = $wpdb->get_results( $wpdb->prepare( $get_user_id_query, $get_ac_id_results[0]->abandoned_order_id ) );
1792
  }
1793
- $user_id = 0;
1794
  if ( isset( $get_user_results ) && count( $get_user_results ) > 0 ) {
1795
  $user_id = $get_user_results[0]->user_id;
1796
  }
1797
- if ( $user_id == 0 ) {
1798
  echo "Link expired";
1799
  exit;
1800
  }
@@ -1805,12 +1829,12 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1805
  $query_cart = "SELECT recovered_cart FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id = %d";
1806
  $results = $wpdb->get_results( $wpdb->prepare( $query_cart, $user_id ) );
1807
  if ( $results_guest && $results[0]->recovered_cart == '0' ) {
1808
- $_SESSION['guest_first_name'] = $results_guest[0]->billing_first_name;
1809
- $_SESSION['guest_last_name'] = $results_guest[0]->billing_last_name;
1810
- $_SESSION['guest_email'] = $results_guest[0]->email_id;
1811
- $_SESSION['user_id'] = $user_id;
1812
  } else {
1813
- if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
1814
  wp_redirect( get_permalink( wc_get_page_id( 'shop' ) ) );
1815
  } else {
1816
  wp_redirect( get_permalink( woocommerce_get_page_id( 'shop' ) ) );
@@ -1844,9 +1868,9 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1844
  * @since 1.0
1845
  */
1846
  function wcal_load_guest_persistent_cart() {
1847
- if ( isset( $_SESSION['user_id'] ) && '' != $_SESSION['user_id'] ) {
1848
  global $woocommerce;
1849
- $saved_cart = json_decode( get_user_meta( $_SESSION['user_id'], '_woocommerce_persistent_cart',true ), true );
1850
  $c = array();
1851
  $cart_contents_total = $cart_contents_weight = $cart_contents_count = $cart_contents_tax = $total = $subtotal = $subtotal_ex_tax = $tax_total = 0;
1852
  if ( count( $saved_cart ) > 0 ) {
@@ -1857,7 +1881,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1857
  $c['variation'] = $b['variation'];
1858
  $c['quantity'] = $b['quantity'];
1859
  $product_id = $b['product_id'];
1860
- $c['data'] = wc_get_product($product_id);
1861
  $c['line_total'] = $b['line_total'];
1862
  $c['line_tax'] = $cart_contents_tax;
1863
  $c['line_subtotal'] = $b['line_subtotal'];
@@ -1874,7 +1898,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1874
  }
1875
  }
1876
 
1877
- if( $saved_cart ) {
1878
  if ( empty( $woocommerce->session->cart ) || ! is_array( $woocommerce->session->cart ) || sizeof( $woocommerce->session->cart ) == 0 ) {
1879
  $woocommerce->session->cart = $saved_cart['cart'];
1880
  $woocommerce->session->cart_contents_total = $cart_contents_total;
@@ -1972,7 +1996,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1972
  $current_woo_cart = get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true );
1973
  $abandoned_cart_arr = json_decode( $last_abandoned_cart, true );
1974
  $temp_variable = "";
1975
- if( isset( $current_woo_cart['cart'] ) && isset( $abandoned_cart_arr['cart'] ) ) {
1976
  if ( count( $current_woo_cart['cart'] ) >= count( $abandoned_cart_arr['cart'] ) ) {
1977
  //do nothing
1978
  } else {
@@ -2027,25 +2051,25 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2027
  */
2028
  function wcal_action_after_delivery_session( $order ) {
2029
 
2030
- if( session_id() === '' ){
2031
  //session has not started
2032
  session_start();
2033
  }
2034
  global $wpdb, $woocommerce;
2035
- if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
2036
- $order_id = $order->get_id();
2037
- }else{
2038
- $order_id = $order->id;
2039
  }
2040
  $get_abandoned_id_of_order = '';
2041
  $get_sent_email_id_of_order = '';
2042
  $get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
2043
- if( isset( $get_abandoned_id_of_order ) && $get_abandoned_id_of_order != '' ){
2044
  $get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
2045
  $get_sent_email_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed_sent_id', true );
2046
 
2047
  $query_order = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET recovered_cart= '" . $order_id . "', cart_ignored = '1'
2048
- WHERE id = '".$get_abandoned_id_of_order."' ";
2049
  $wpdb->query( $query_order );
2050
 
2051
  $order->add_order_note( __( 'This order was abandoned & subsequently recovered.', 'woocommerce-abandoned-cart' ) );
@@ -2054,14 +2078,17 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2054
  delete_post_meta( $order_id , 'wcal_recover_order_placed_sent_id', $get_sent_email_id_of_order );
2055
  }
2056
  $user_id = get_current_user_id();
2057
- $sent_email = '';
2058
- if( isset( $_SESSION['email_sent_id'] ) ){
2059
- $sent_email = $_SESSION['email_sent_id'];
2060
- }
2061
  if( $user_id == "" ) {
2062
- $user_id = $_SESSION['user_id'];
 
2063
  // Set the session variables to blanks
2064
- $_SESSION['guest_first_name'] = $_SESSION['guest_last_name'] = $_SESSION['guest_email'] = $_SESSION['user_id'] = "";
 
 
 
2065
  }
2066
  delete_user_meta( $user_id, '_woocommerce_ac_persistent_cart_time' );
2067
  delete_user_meta( $user_id, '_woocommerce_ac_persistent_cart_temp_time' );
@@ -2079,10 +2106,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2079
  if ( get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true ) == md5( "yes" ) ||
2080
  get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true ) == md5( "no" ) ) {
2081
 
2082
- if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
2083
- $order_id = $order->get_id();
2084
- }else{
2085
- $order_id = $order->id;
2086
  }
2087
  $updated_cart_ignored = 1;
2088
  $query_order = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
@@ -2092,34 +2119,33 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2092
  $wpdb->query( $wpdb->prepare( $query_order, $order_id, $updated_cart_ignored, $results[0]->id ) );
2093
  delete_user_meta( $user_id, '_woocommerce_ac_modified_cart' );
2094
  delete_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
2095
- } else {
2096
  $delete_query = "DELETE FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
2097
  WHERE id= %d ";
2098
  $wpdb->query( $wpdb->prepare( $delete_query, $results[0]->id ) );
2099
  }
2100
  } else {
2101
- if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
2102
-
2103
- $email_id = $order->get_billing_email();
2104
- }else{
2105
- $email_id = $order->billing_email;
2106
  }
2107
  $query = "SELECT * FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE email_id = %s";
2108
  $results_id = $wpdb->get_results( $wpdb->prepare( $query, $email_id ) );
2109
 
2110
  if ( $results_id ) {
2111
- $record_status = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
2112
- WHERE user_id = %d AND recovered_cart = '0'";
2113
  $results_status = $wpdb->get_results( $wpdb->prepare( $record_status, $results_id[0]->id ) );
2114
 
2115
  if ( $results_status ) {
2116
  if ( get_user_meta( $results_id[0]->id, '_woocommerce_ac_modified_cart', true ) == md5("yes") ||
2117
  get_user_meta( $results_id[0]->id, '_woocommerce_ac_modified_cart', true ) == md5("no") ) {
2118
 
2119
- if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
2120
- $order_id = $order->get_id();
2121
- }else{
2122
- $order_id = $order->id;
2123
  }
2124
  $query_order = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
2125
  SET recovered_cart= '".$order_id."', cart_ignored = '1'
@@ -2134,7 +2160,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2134
  $delete_query = "DELETE FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id='".$results_id[0]->id."' ";
2135
  $wpdb->query( $delete_query );
2136
  }
2137
- }
2138
  }
2139
  }
2140
  }
@@ -2148,23 +2174,17 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2148
 
2149
  // only hook up these filters if we're in the admin panel and the current user has permission
2150
  // to edit posts and pages
2151
- if ( !isset( $_GET['page'] ) || $_GET['page'] != "woocommerce_ac_page" ) {
2152
  return;
2153
  }
2154
- if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) ) {
2155
  return;
2156
  }
2157
- if ( get_user_option( 'rich_editing' ) == 'true' ) {
2158
  remove_filter( 'the_excerpt', 'wpautop' );
2159
  add_filter( 'tiny_mce_before_init', array( &$this, 'wcal_format_tiny_MCE' ) );
2160
- add_filter( 'mce_buttons', array( &$this, 'wcal_filter_mce_button' ) );
2161
- add_filter( 'mce_external_plugins', array( &$this, 'wcal_filter_mce_plugin' ) );
2162
- }
2163
- if ( isset( $_GET['page'] ) && 'woocommerce_ac_page' == $_GET['page'] ) {
2164
- if( session_id() === '' ){
2165
- //session has not started
2166
- session_start();
2167
- }
2168
  }
2169
  }
2170
 
@@ -2209,32 +2229,32 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2209
  $active_settings = "";
2210
  $active_stats = "";
2211
  }
2212
- if ( ( $action == 'listcart' || $action == 'orderdetails' ) || $action == '' ) {
2213
  $active_listcart = "nav-tab-active";
2214
  }
2215
- if ( $action == 'emailtemplates' ) {
2216
  $active_emailtemplates = "nav-tab-active";
2217
  }
2218
- if ( $action == 'emailsettings' ) {
2219
  $active_settings = "nav-tab-active";
2220
  }
2221
- if ( $action == 'stats' ) {
2222
  $active_stats = "nav-tab-active";
2223
  }
2224
- if ( $action == 'report' ) {
2225
  $active_report = "nav-tab-active";
2226
  }
2227
  ?>
2228
  <div style="background-image: url('<?php echo plugins_url(); ?>/woocommerce-abandoned-cart/assets/images/ac_tab_icon.png') !important;" class="icon32"><br>
2229
  </div>
2230
  <h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
2231
- <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-abandoned-cart' );?> </a>
2232
- <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-abandoned-cart' );?> </a>
2233
- <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-abandoned-cart' );?> </a>
2234
- <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-abandoned-cart' );?> </a>
2235
- <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-abandoned-cart' );?> </a>
2236
 
2237
- <?php do_action ( 'wcal_add_settings_tab' ); ?>
2238
  </h2>
2239
  <?php
2240
  }
@@ -2246,20 +2266,21 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2246
  * @since 1.0
2247
  */
2248
  function wcal_enqueue_scripts_js( $hook ) {
2249
-
2250
- if ( $hook != 'woocommerce_page_woocommerce_ac_page' ) {
 
 
2251
  return;
2252
  } else {
2253
  wp_enqueue_script( 'jquery' );
2254
- wp_enqueue_script(
2255
- 'jquery-ui-min',
2256
- '//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js',
2257
- '',
2258
- '',
2259
- false
2260
  );
2261
  wp_enqueue_script( 'jquery-ui-datepicker' );
2262
-
2263
  wp_enqueue_script(
2264
  'jquery-tip',
2265
  plugins_url( '/assets/js/jquery.tipTip.minified.js', __FILE__ ),
@@ -2267,6 +2288,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2267
  '',
2268
  false
2269
  );
 
2270
  wp_register_script( 'woocommerce_admin', plugins_url() . '/woocommerce/assets/js/admin/woocommerce_admin.js', array( 'jquery', 'jquery-ui-widget', 'jquery-ui-core' ) );
2271
  wp_enqueue_script( 'woocommerce_admin' );
2272
  ?>
@@ -2322,17 +2344,25 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2322
  * @since 1.0
2323
  */
2324
  function wcal_enqueue_scripts_css( $hook ) {
2325
- if ( $hook != 'woocommerce_page_woocommerce_ac_page' ) {
 
 
 
 
 
2326
  return;
2327
- } else {
2328
- wp_enqueue_style( 'jquery-ui', "//ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" , '', '', false );
 
2329
  wp_enqueue_style( 'woocommerce_admin_styles', plugins_url() . '/woocommerce/assets/css/admin.css' );
2330
- wp_enqueue_style( 'jquery-ui-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
 
2331
  wp_enqueue_style( 'abandoned-orders-list', plugins_url() . '/woocommerce-abandoned-cart/assets/css/view.abandoned.orders.style.css' );
2332
  wp_enqueue_style( 'wcal_email_template', plugins_url() . '/woocommerce-abandoned-cart/assets/css/wcal_template_activate.css' );
2333
 
2334
  }
2335
  }
 
2336
 
2337
  /**
2338
  * When we have added the wp list table for the listing then while deleting the record with the bulk action it was showing
@@ -2357,7 +2387,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2357
  if ( is_user_logged_in() ) {
2358
  global $wpdb;
2359
  // Check the user capabilities
2360
- if ( !current_user_can( 'manage_woocommerce' ) ) {
2361
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'woocommerce-abandoned-cart' ) );
2362
  }
2363
  ?>
@@ -2365,60 +2395,60 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2365
  <h2><?php _e( 'WooCommerce - Abandon Cart Lite', 'woocommerce-abandoned-cart' ); ?></h2>
2366
  <?php
2367
 
2368
- if ( isset( $_GET['ac_update'] ) && $_GET['ac_update'] === 'email_templates' ) {
2369
  $status = wcal_common::update_templates_table();
2370
 
2371
  if ( $status !== false ) {
2372
  wcal_common::show_update_success();
2373
- }else {
2374
  wcal_common::show_update_failure();
2375
  }
2376
  }
 
 
 
 
 
 
 
 
 
 
 
 
2377
 
2378
- if ( isset( $_GET['action'] ) ) {
2379
- $action = $_GET['action'];
2380
- } else {
2381
- $action = "";
2382
- }
2383
- if ( isset( $_GET['mode'] ) ) {
2384
- $mode = $_GET['mode'];
2385
- } else {
2386
- $mode = "";
2387
- }
2388
- $this->wcal_display_tabs();
2389
-
2390
- do_action ( 'wcal_add_tab_content' );
2391
-
2392
- /**
2393
- * When we delete the item from the below drop down it is registred in action 2
2394
- */
2395
- if ( isset( $_GET['action2'] ) ) {
2396
- $action_two = $_GET['action2'];
2397
- } else {
2398
- $action_two = "";
2399
- }
2400
- // Detect when a bulk action is being triggered on abandoned orders page.
2401
- if( 'wcal_delete' === $action || 'wcal_delete' === $action_two ) {
2402
- $ids = isset( $_GET['abandoned_order_id'] ) ? $_GET['abandoned_order_id'] : false;
2403
- if ( ! is_array( $ids ) ) {
2404
- $ids = array( $ids );
2405
- }
2406
- foreach ( $ids as $id ) {
2407
- $class = new wcal_delete_bulk_action_handler();
2408
- $class->wcal_delete_bulk_action_handler_function( $id );
2409
- }
2410
- }
2411
- //Detect when a bulk action is being triggered on temnplates page.
2412
- if( 'wcal_delete_template' === $action || 'wcal_delete_template' === $action_two ) {
2413
- $ids = isset( $_GET['template_id'] ) ? $_GET['template_id'] : false;
2414
- if ( ! is_array( $ids ) ) {
2415
- $ids = array( $ids );
2416
- }
2417
- foreach ( $ids as $id ) {
2418
- $class = new wcal_delete_bulk_action_handler();
2419
- $class->wcal_delete_template_bulk_action_handler_function( $id );
2420
- }
2421
- }
2422
 
2423
  if ( isset( $_GET['wcal_deleted'] ) && 'YES' == $_GET['wcal_deleted'] ) { ?>
2424
  <div id="message" class="updated fade">
@@ -2430,7 +2460,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2430
  <p><strong><?php _e( 'The Template has been successfully deleted.', 'woocommerce-abandoned-cart' ); ?></strong></p>
2431
  </div>
2432
  <?php }
2433
- if ( $action == 'emailsettings' ) {
2434
  // Save the field values
2435
  ?>
2436
  <p><?php _e( 'Change settings for sending email notifications to Customers, to Admin etc.', 'woocommerce-abandoned-cart' ); ?></p>
@@ -2442,13 +2472,12 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2442
  } else {
2443
  $section = '';
2444
  }
2445
- if ( $section == 'wcal_general_settings' || $section == '' ) {
2446
  $wcal_general_settings_class = "current";
2447
  }
2448
- if( $section == 'wcal_email_settings' ) {
2449
  $wcal_email_setting = "current";
2450
  }
2451
-
2452
  ?>
2453
  <ul class="subsubsub" id="wcal_general_settings_list">
2454
  <li>
@@ -2461,7 +2490,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2461
  </ul>
2462
  <br class="clear">
2463
  <?php
2464
- if ( $section == 'wcal_general_settings' || $section == '' ) {
2465
  ?>
2466
  <form method="post" action="options.php">
2467
  <?php settings_fields( 'woocommerce_ac_settings' ); ?>
@@ -2470,7 +2499,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2470
  <?php submit_button(); ?>
2471
  </form>
2472
  <?php
2473
- } else if ( $section == 'wcal_email_settings' ) {
2474
  ?>
2475
  <form method="post" action="options.php">
2476
  <?php settings_fields ( 'woocommerce_ac_email_settings' ); ?>
@@ -2507,21 +2536,21 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2507
  } else {
2508
  $section = '';
2509
  }
2510
- if ( $section == 'wcal_all_abandoned' || $section == '' ) {
2511
  $wcal_all_abandoned_carts = "current";
2512
  }
2513
 
2514
- if( $section == 'wcal_all_registered' ) {
2515
- $wcal_all_registered = "current";
2516
  $wcal_all_abandoned_carts = "";
2517
  }
2518
- if( $section == 'wcal_all_guest' ) {
2519
- $wcal_all_guest = "current";
2520
  $wcal_all_abandoned_carts = "";
2521
  }
2522
 
2523
- if( $section == 'wcal_all_visitor' ) {
2524
- $wcal_all_visitor = "current";
2525
  $wcal_all_abandoned_carts = "";
2526
  }
2527
  ?>
@@ -2530,19 +2559,19 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2530
  <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-abandoned-cart' ) ;?> <span class = "count" > <?php echo "( $get_all_abandoned_count )" ?> </span></a>
2531
  </li>
2532
 
2533
- <?php if ($get_registered_user_ac_count > 0 ) { ?>
2534
  <li>
2535
  | <a href="admin.php?page=woocommerce_ac_page&action=listcart&wcal_section=wcal_all_registered" class="<?php echo $wcal_all_registered; ?>"><?php printf( __( 'Registered %s', 'woocommerce-abandoned-cart' ), $wcal_user_reg_text ); ?> <span class = "count" > <?php echo "( $get_registered_user_ac_count )" ?> </span></a>
2536
  </li>
2537
  <?php } ?>
2538
 
2539
- <?php if ($get_guest_user_ac_count > 0 ) { ?>
2540
  <li>
2541
  | <a href="admin.php?page=woocommerce_ac_page&action=listcart&wcal_section=wcal_all_guest" class="<?php echo $wcal_all_guest; ?>"><?php printf( __( 'Guest %s', 'woocommerce-abandoned-cart' ), $wcal_user_gus_text ); ?> <span class = "count" > <?php echo "( $get_guest_user_ac_count )" ?> </span></a>
2542
  </li>
2543
  <?php } ?>
2544
 
2545
- <?php if ($get_visitor_user_ac_count > 0 ) { ?>
2546
  <li>
2547
  | <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-abandoned-cart' ); ?> <span class = "count" > <?php echo "( $get_visitor_user_ac_count )" ?> </span></a>
2548
  </li>
@@ -2563,18 +2592,18 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2563
  </form>
2564
  </div>
2565
  <?php
2566
- } elseif ( ( $action == 'emailtemplates' && ( $mode != 'edittemplate' && $mode != 'addnewtemplate' ) || '' == $action || '-1' == $action || '-1' == $action_two ) ) {
2567
- ?>
2568
  <p> <?php _e( 'Add email templates at different intervals to maximize the possibility of recovering your abandoned carts.', 'woocommerce-abandoned-cart' );?> </p>
2569
  <?php
2570
  // Save the field values
2571
  $insert_template_successfuly = $update_template_successfuly = '';
2572
- if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' ) {
2573
- $woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
2574
  $woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
2575
  $woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
2576
- $woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
2577
-
2578
  $email_frequency = trim( $_POST['email_frequency'] );
2579
  $day_or_hour = trim( $_POST['day_or_hour'] );
2580
  $is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
@@ -2585,18 +2614,18 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2585
  VALUES ( %s, %s, %d, %s, %s, %s, %d, %s )";
2586
 
2587
  $insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query,
2588
- $woocommerce_ac_email_subject,
2589
- $woocommerce_ac_email_body,
2590
- $email_frequency,
2591
- $day_or_hour,
2592
- $woocommerce_ac_template_name,
2593
- $is_wc_template,
2594
- $default_value,
2595
- $woocommerce_ac_email_header )
2596
  );
2597
  }
2598
 
2599
- if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' ) {
2600
 
2601
  $updated_is_active = '0';
2602
 
@@ -2604,10 +2633,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2604
  $day_or_hour = trim( $_POST['day_or_hour'] );
2605
  $is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
2606
 
2607
- $woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
2608
  $woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
2609
  $woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
2610
- $woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
2611
  $id = trim( $_POST['id'] );
2612
 
2613
  $check_query = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite`
@@ -2647,23 +2676,23 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2647
 
2648
  }
2649
 
2650
- if ( $action == 'emailtemplates' && $mode == 'removetemplate' ) {
2651
  $id_remove = $_GET['id'];
2652
  $query_remove = "DELETE FROM `".$wpdb->prefix."ac_email_templates_lite` WHERE id= %d ";
2653
  $wpdb->query( $wpdb->prepare( $query_remove, $id_remove ) );
2654
  }
2655
 
2656
- if ( $action == 'emailtemplates' && $mode == 'activate_template' ) {
2657
  $template_id = $_GET['id'];
2658
  $current_template_status = $_GET['active_state'];
2659
 
2660
- if( "1" == $current_template_status ) {
2661
  $active = "0";
2662
  } else {
2663
  $active = "1";
2664
 
2665
- $query_update = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite` WHERE id ='" . $template_id . "'";
2666
- $get_selected_template_result = $wpdb->get_results( $query_update );
2667
  $email_frequncy = $get_selected_template_result[0]->frequency;
2668
  $email_day_or_hour = $get_selected_template_result[0]->day_or_hour;
2669
 
@@ -2678,8 +2707,8 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2678
 
2679
  wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&action=emailtemplates' ) );
2680
  }
2681
-
2682
- if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' && ( isset( $insert_template_successfuly ) && $insert_template_successfuly != '' ) ) { ?>
2683
  <div id="message" class="updated fade">
2684
  <p>
2685
  <strong>
@@ -2687,7 +2716,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2687
  </strong>
2688
  </p>
2689
  </div>
2690
- <?php } else if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' && ( isset( $insert_template_successfuly ) && $insert_template_successfuly == '' ) ) {
2691
  ?>
2692
  <div id="message" class="error fade">
2693
  <p>
@@ -2699,7 +2728,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2699
  <?php
2700
  }
2701
 
2702
- if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' && isset($update_template_successfuly) && $update_template_successfuly !== false ) { ?>
2703
  <div id="message" class="updated fade">
2704
  <p>
2705
  <strong>
@@ -2707,7 +2736,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2707
  </strong>
2708
  </p>
2709
  </div>
2710
- <?php } else if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' && isset($update_template_successfuly) && $update_template_successfuly === false ){
2711
  ?>
2712
  <div id="message" class="error fade">
2713
  <p>
@@ -2740,7 +2769,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2740
  </div>
2741
  </div>
2742
  <?php
2743
- } elseif ($action == 'stats' || $action == '') {
2744
  ?>
2745
  <p>
2746
  <script language='javascript'>
@@ -2791,12 +2820,12 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2791
  } else {
2792
  $duration_range = "";
2793
  }
2794
- if ( $duration_range == "" ) {
2795
  if ( isset( $_GET['duration_select'] ) ){
2796
  $duration_range = $_GET['duration_select'];
2797
- }
2798
  }
2799
- if ($duration_range == "") $duration_range = "last_seven";
2800
 
2801
  _e( 'The Report below shows how many Abandoned Carts we were able to recover for you by sending automatic emails to encourage shoppers.', 'woocommerce-abandoned-cart');
2802
  ?>
@@ -2807,7 +2836,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2807
  <?php
2808
  foreach ( $this->duration_range_select as $key => $value ) {
2809
  $sel = "";
2810
- if ($key == $duration_range) {
2811
  $sel = " selected ";
2812
  }
2813
  echo"<option value='$key' $sel> $value </option>";
@@ -2892,7 +2921,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2892
  </form>
2893
  </div>
2894
  <?php
2895
- } elseif ( $action == 'orderdetails' ) {
2896
  global $woocommerce;
2897
  $ac_order_id = $_GET['id'];
2898
  ?>
@@ -2918,8 +2947,8 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2918
  if ( $results[0]->user_type == "GUEST" && "0" != $results[0]->user_id ) {
2919
  $query_guest = "SELECT * FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d";
2920
  $results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $results[0]->user_id ) );
2921
- $user_email = $user_first_name = $user_last_name = $user_billing_postcode = $user_shipping_postcode = '';
2922
- $shipping_charges = '';
2923
  if ( count( $results_guest ) > 0 ) {
2924
  $user_email = $results_guest[0]->email_id;
2925
  $user_first_name = $results_guest[0]->billing_first_name;
@@ -2946,21 +2975,21 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2946
  $user_login = $results[0]->user_login;
2947
  }
2948
  $user_email = get_user_meta( $results[0]->user_id, 'billing_email', true );
2949
- if( "" == $user_email ) {
2950
  $user_data = get_userdata( $results[0]->user_id );
2951
  if ( isset( $user_data->user_email ) ) {
2952
- $user_email = $user_data->user_email;
2953
  } else {
2954
  $user_email = '';
2955
  }
2956
  }
2957
 
2958
- $user_first_name = "";
2959
- $user_first_name_temp = get_user_meta( $user_id, 'billing_first_name', true );
2960
- if( isset( $user_first_name_temp ) && "" == $user_first_name_temp ) {
2961
- $user_data = get_userdata( $user_id );
2962
  if ( isset( $user_data->first_name ) ) {
2963
- $user_first_name = $user_data->first_name;
2964
  } else {
2965
  $user_first_name = '';
2966
  }
@@ -2969,7 +2998,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2969
  }
2970
  $user_last_name = "";
2971
  $user_last_name_temp = get_user_meta( $user_id, 'billing_last_name', true );
2972
- if( isset( $user_last_name_temp ) && "" == $user_last_name_temp ) {
2973
  $user_data = get_userdata( $user_id );
2974
  if ( isset( $user_data->last_name ) ) {
2975
  $user_last_name = $user_data->last_name;
@@ -2977,20 +3006,20 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2977
  $user_last_name = '';
2978
  }
2979
  } else {
2980
- $user_last_name = $user_last_name_temp;
2981
  }
2982
  $user_billing_first_name = get_user_meta( $results[0]->user_id, 'billing_first_name' );
2983
  $user_billing_last_name = get_user_meta( $results[0]->user_id, 'billing_last_name' );
2984
 
2985
- $user_billing_details = wcal_common::wcal_get_billing_details( $results[0]->user_id );
2986
 
2987
- $user_billing_company = $user_billing_details[ 'billing_company' ];
2988
- $user_billing_address_1 = $user_billing_details[ 'billing_address_1' ];
2989
- $user_billing_address_2 = $user_billing_details[ 'billing_address_2' ];
2990
- $user_billing_city = $user_billing_details[ 'billing_city' ];
2991
- $user_billing_postcode = $user_billing_details[ 'billing_postcode' ] ;
2992
- $user_billing_country = $user_billing_details[ 'billing_country' ];
2993
- $user_billing_state = $user_billing_details[ 'billing_state' ];
2994
 
2995
  $user_billing_phone_temp = get_user_meta( $results[0]->user_id, 'billing_phone' );
2996
  if ( isset( $user_billing_phone_temp[0] ) ) {
@@ -3045,7 +3074,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3045
  if ( isset( $user_shipping_state_temp[0] ) ) {
3046
  $user_shipping_state = $user_shipping_state_temp[0];
3047
  if ( isset( $woocommerce->countries->states[ $user_shipping_country_temp[0] ][ $user_shipping_state ] ) ) {
3048
- # code...
3049
  $user_shipping_state = $woocommerce->countries->states[ $user_shipping_country_temp[0] ][ $user_shipping_state ];
3050
  }
3051
  }
@@ -3062,22 +3091,22 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3062
  $item_details = wcal_common::wcal_get_cart_details( $v );
3063
 
3064
  $product_id = $v->product_id;
3065
- $product = wc_get_product( $product_id );
3066
- $prod_image = $product->get_image(array(200, 200));
3067
-
3068
- $product_name = $item_details[ 'product_name' ];
3069
- $item_subtotal = $item_details[ 'item_total_formatted' ];
3070
- $item_total = $item_details[ 'item_total' ];
3071
  $quantity_total = $item_details[ 'qty' ];
3072
 
3073
  $qty_item_text = 'item';
3074
  if ( $quantity_total > 1 ) {
3075
  $qty_item_text = 'items';
3076
  }
3077
- ?>
3078
  <tr>
3079
  <td> <?php echo $prod_image; ?></td>
3080
- <td> <?php echo $product_name; ?></td>
3081
  <td> <?php echo $quantity_total; ?></td>
3082
  <td> <?php echo $item_subtotal; ?></td>
3083
  <td> <?php echo $item_total; ?></td>
@@ -3139,7 +3168,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3139
  $user_shipping_country."</br>";
3140
  ?>
3141
  <br><br>
3142
- <strong> Shipping Charges: </strong>
3143
  <?php if ( $shipping_charges != 0 ) echo $currency_symbol . $shipping_charges;?>
3144
  </p>
3145
  <?php }?>
@@ -3164,17 +3193,16 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3164
  echo( "</table>" );
3165
 
3166
  if ( isset( $_GET['action'] ) ) {
3167
- $action = $_GET['action'];
3168
  }
3169
- if ( isset( $_GET['mode'] ) ){
3170
- $mode = $_GET['mode'];
3171
  }
3172
- if ( $action == 'emailtemplates' && ( $mode == 'addnewtemplate' || $mode == 'edittemplate' ) ) {
3173
- if ( $mode=='edittemplate' ) {
3174
  $results = array();
3175
  if ( isset( $_GET['id'] ) ) {
3176
  $edit_id = $_GET['id'];
3177
-
3178
  $query = "SELECT wpet . * FROM `".$wpdb->prefix."ac_email_templates_lite` AS wpet WHERE id = %d ";
3179
  $results = $wpdb->get_results( $wpdb->prepare( $query, $edit_id ) );
3180
  }
@@ -3194,7 +3222,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3194
  <?php
3195
  $button_mode = "save";
3196
  $display_message = "Add Email Template";
3197
- if ( $mode == 'edittemplate' ) {
3198
  $button_mode = "update";
3199
  $display_message = "Edit Email Template";
3200
  }
@@ -3211,7 +3239,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3211
  <td>
3212
  <?php
3213
  $template_name = "";
3214
- if( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->template_name ) ) {
3215
  $template_name = $results[0]->template_name;
3216
  }
3217
  print'<input type="text" name="woocommerce_ac_template_name" id="woocommerce_ac_template_name" class="regular-text" value="'.$template_name.'">';?>
@@ -3226,7 +3254,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3226
  <td>
3227
  <?php
3228
  $subject_edit = "";
3229
- if ( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->subject ) ) {
3230
  $subject_edit= stripslashes ( $results[0]->subject );
3231
  }
3232
  print'<input type="text" name="woocommerce_ac_email_subject" id="woocommerce_ac_email_subject" class="regular-text" value="'.$subject_edit.'">';?>
@@ -3241,20 +3269,20 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3241
  <td>
3242
  <?php
3243
  $initial_data = "";
3244
- if ( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->body ) ) {
3245
  $initial_data = stripslashes( $results[0]->body );
3246
  }
3247
 
3248
  $initial_data = str_replace ( "My document title", "", $initial_data );
3249
  wp_editor(
3250
  $initial_data,
3251
- 'woocommerce_ac_email_body',
3252
- array(
3253
  'media_buttons' => true,
3254
  'textarea_rows' => 15,
3255
- 'tabindex' => 4,
3256
- 'tinymce' => array(
3257
- 'theme_advanced_buttons1' => 'bold,italic,underline,|,bullist,numlist,blockquote,|,link,unlink,|,spellchecker,fullscreen,|,formatselect,styleselect'
3258
  ),
3259
  )
3260
  );
@@ -3279,7 +3307,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3279
  </tr>
3280
  <script type="text/javascript">
3281
  function wcal_show_help_tips() {
3282
- if( jQuery( '#help_message' ) . css( 'display' ) == 'none') {
3283
  document.getElementById( "help_message" ).style.display = "block";
3284
  }
3285
  else {
@@ -3295,10 +3323,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3295
  <td>
3296
  <?php
3297
  $is_wc_template = "";
3298
- if ( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->is_wc_template ) ) {
3299
  $use_wc_template = $results[0]->is_wc_template;
3300
 
3301
- if ( $use_wc_template == '1' ) {
3302
  $is_wc_template = "checked";
3303
  } else {
3304
  $is_wc_template = "";
@@ -3319,10 +3347,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3319
  <?php
3320
 
3321
  $wcal_wc_email_header = "";
3322
- if ( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->wc_email_header ) ) {
3323
  $wcal_wc_email_header = $results[0]->wc_email_header;
3324
  }
3325
- if ( $wcal_wc_email_header == "" ) {
3326
  $wcal_wc_email_header = "Abandoned cart reminder";
3327
  }
3328
  print'<input type="text" name="wcal_wc_email_header" id="wcal_wc_email_header" class="regular-text" value="' . $wcal_wc_email_header . '">'; ?>
@@ -3338,7 +3366,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3338
  <select name="email_frequency" id="email_frequency">
3339
  <?php
3340
  $frequency_edit = "";
3341
- if( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->frequency ) ) {
3342
  $frequency_edit = $results[0]->frequency;
3343
  }
3344
  for ( $i = 1; $i < 4; $i++ ) {
@@ -3354,14 +3382,14 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3354
  <select name="day_or_hour" id="day_or_hour">
3355
  <?php
3356
  $days_or_hours_edit = "";
3357
- if ( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->day_or_hour ) )
3358
  {
3359
  $days_or_hours_edit = $results[0]->day_or_hour;
3360
  }
3361
  $days_or_hours = array(
3362
  'Days' => 'Day(s)',
3363
- 'Hours' => 'Hour(s)'
3364
- );
3365
  foreach( $days_or_hours as $k => $v )
3366
  {
3367
  printf( "<option %s value='%s'>%s</option>\n",
@@ -3396,10 +3424,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3396
  <p class="submit">
3397
  <?php
3398
  $button_value = "Save Changes";
3399
- if ( $mode == 'edittemplate' )
3400
- {
3401
  $button_value = "Update Changes";
3402
- }?>
 
3403
  <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e( $button_value, 'woocommerce-abandoned-cart' ); ?>" />
3404
  </p>
3405
  </form>
@@ -3440,11 +3468,11 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3440
  $temp = array();
3441
  foreach ( $unsort_array as $key => $value )
3442
  $temp[ $key ] = $value; //concatenate something unique to make sure two equal weights don't overwrite each other
3443
- asort( $temp, SORT_NUMERIC ); // or ksort($temp, SORT_NATURAL); see paragraph above to understand why
3444
 
3445
- if( $order == 'desc' ) {
3446
  $array = array_reverse( $temp, true );
3447
- } else if( $order == 'asc' ) {
3448
  $array = $temp;
3449
  }
3450
  unset( $temp );
@@ -3481,8 +3509,8 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3481
  is_wc_template : is_wc_template,
3482
  wc_template_header : wc_template_header,
3483
  action : 'wcal_preview_email_sent'
3484
- };
3485
-
3486
  // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
3487
  $.post( ajaxurl, data, function( response ) {
3488
  if ( 'not sent' == response ) {
@@ -3513,24 +3541,24 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3513
  $template_id = $_POST['wcal_template_id'];
3514
  $current_template_status = $_POST['current_state'];
3515
 
3516
- if( "on" == $current_template_status ) {
3517
  $query_update = "SELECT * FROM `" . $wpdb->prefix . "ac_email_templates_lite` WHERE id ='" . $template_id . "'";
3518
  $get_selected_template_result = $wpdb->get_results( $query_update );
3519
- $email_frequncy = $get_selected_template_result[0]->frequency;
3520
- $email_day_or_hour = $get_selected_template_result[0]->day_or_hour;
3521
- $query_update = "UPDATE `" . $wpdb->prefix . "ac_email_templates_lite` SET is_active='0' WHERE frequency='" . $email_frequncy . "' AND day_or_hour='" . $email_day_or_hour . "' ";
3522
- $wcal_updated = $wpdb->query( $query_update );
3523
 
3524
  if ( 1 == $wcal_updated ){
3525
  $query_update_get_id = "SELECT id FROM `" . $wpdb->prefix . "ac_email_templates_lite` WHERE id != $template_id AND frequency='" . $email_frequncy . "' AND day_or_hour='" . $email_day_or_hour . "' ";
3526
  $wcal_updated_get_id = $wpdb->get_results( $query_update_get_id );
3527
  $wcal_all_ids = '';
3528
- foreach ($wcal_updated_get_id as $wcal_updated_get_id_key => $wcal_updated_get_id_value ) {
3529
  # code...
3530
  if ( '' == $wcal_all_ids ){
3531
  $wcal_all_ids = $wcal_updated_get_id_value->id;
3532
- }else{
3533
- $wcal_all_ids = $wcal_all_ids . ',' .$wcal_updated_get_id_value->id;
3534
  }
3535
  }
3536
  echo 'wcal-template-updated:'. $wcal_all_ids ;
@@ -3559,10 +3587,13 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3559
  $reply_name_preview = get_option ( 'wcal_from_email' );
3560
  $from_email_preview = get_option ( 'wcal_reply_email' );
3561
  $subject_email_preview = stripslashes ( $_POST['subject_email_preview'] );
3562
- $subject_email_preview = convert_smilies ( $subject_email_preview );
 
3563
  $body_email_preview = convert_smilies ( $_POST['body_email_preview'] );
3564
  $is_wc_template = $_POST['is_wc_template'];
3565
- $wc_template_header = stripslashes( $_POST['wc_template_header'] );
 
 
3566
  $body_email_preview = str_replace( '{{customer.firstname}}', 'John', $body_email_preview );
3567
  $body_email_preview = str_replace( '{{customer.lastname}}', 'Doe', $body_email_preview );
3568
  $body_email_preview = str_replace( '{{customer.fullname}}', 'John'." ".'Doe', $body_email_preview );
@@ -3653,10 +3684,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3653
  } else {
3654
  $to_email_preview = "";
3655
  }
3656
- $user_email_from = get_option( 'admin_email' );
3657
  $body_email_final_preview = stripslashes( $body_email_preview );
3658
 
3659
- if ( isset( $is_wc_template ) && "true" == $is_wc_template ) {
3660
  ob_start();
3661
  // Get email heading
3662
  wc_get_template( 'emails/email-header.php', array( 'email_heading' => $wc_template_header ) );
@@ -3666,10 +3697,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3666
  wc_get_template( 'emails/email-footer.php' );
3667
  $email_body_template_footer = ob_get_clean();
3668
 
3669
- $final_email_body = $email_body_template_header . $body_email_final_preview . $email_body_template_footer;
3670
 
3671
- $site_title = get_bloginfo( 'name' );
3672
- $email_body_template_footer = str_replace( '{site_title}', $site_title, $email_body_template_footer );
3673
 
3674
  wc_mail( $to_email_preview, $subject_email_preview, $final_email_body , $headers );
3675
  }
5
  * Description: This plugin captures abandoned carts by logged-in users & emails them about it.
6
  * <strong><a href="http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro">Click here to get the
7
  * PRO Version.</a></strong>
8
+ * Version: 5.1.1
9
  * Author: Tyche Softwares
10
  * Author URI: http://www.tychesoftwares.com/
11
  * Text Domain: woocommerce-abandoned-cart
12
  * Domain Path: /i18n/languages/
13
  * Requires PHP: 5.6
14
  * WC requires at least: 3.0.0
15
+ * WC tested up to: 3.5
16
  *
17
  * @package Abandoned-Cart-Lite-for-WooCommerce
18
  */
32
  require_once( 'includes/admin/wcal_privacy_erase.php' );
33
  require_once( 'includes/admin/wcal_privacy_export.php' );
34
 
 
 
 
 
 
35
  // Add a new interval of 15 minutes
36
  add_filter( 'cron_schedules', 'wcal_add_cron_schedule' );
37
 
61
  wp_schedule_event( time(), '15_minutes_lite', 'woocommerce_ac_send_email_action' );
62
  }
63
 
64
+ /**
65
+ * Schedule an action to delete old carts once a day
66
+ * @since 5.1
67
+ * @package Abandoned-Cart-Lite-for-WooCommerce/Cron
68
+ */
69
+ if( ! wp_next_scheduled( 'wcal_clear_carts' ) ) {
70
+ wp_schedule_event( time(), 'daily', 'wcal_clear_carts' );
71
+ }
72
  /**
73
  * Hook into that action that'll fire every 15 minutes
74
  */
182
  delete_option( 'wcal_logged_cart_capture_msg' );
183
 
184
  delete_option( 'ac_lite_delete_abandoned_order_days' );
185
+ delete_option( 'wcal_new_default_templates' );
186
+
187
+ delete_option( 'ac_lite_delete_redundant_queries' );
188
  }
189
  /**
190
  * woocommerce_abandon_cart_lite class
191
  **/
192
+ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
193
 
194
 
195
  /**
246
 
247
  // Initialize settings
248
  register_activation_hook ( __FILE__, array( &$this, 'wcal_activate' ) );
249
+
250
+ // Background Processing for Cron
251
+ require_once( 'cron/wcal_send_email.php' );
252
+ require_once( 'includes/background-processes/wcal_process_base.php' );
253
 
254
  // WordPress Administration Menu
255
  add_action ( 'admin_menu', array( &$this, 'wcal_admin_menu' ) );
270
 
271
  // Language Translation
272
  add_action ( 'init', array( &$this, 'wcal_update_po_file' ) );
273
+
274
+ add_action ( 'init', array ( &$this, 'wcal_add_component_file') );
275
 
276
  // track links
277
  add_filter( 'template_include', array( &$this, 'wcal_email_track_links' ), 99, 1 );
283
  add_action ( 'admin_enqueue_scripts', array( &$this, 'wcal_enqueue_scripts_css' ) );
284
  //delete abandoned order after X number of days
285
  if ( class_exists( 'wcal_delete_bulk_action_handler' ) ) {
286
+ add_action( 'wcal_clear_carts', array( 'wcal_delete_bulk_action_handler', 'wcal_delete_abandoned_carts_after_x_days' ) );
287
  }
288
 
289
  if ( is_admin() ) {
314
 
315
  add_action( 'admin_notices', array( 'Wcal_Admin_Notice', 'wcal_show_db_update_notice' ) );
316
  }
317
+
318
+ /**
319
+ * It will load the boilerplate components file. In this file we have included all boilerplate files.
320
+ * We need to inlcude this file after the init hook.
321
+ * @hook init
322
+ */
323
+ public static function wcal_add_component_file () {
324
+ if ( is_admin() ) {
325
+ require_once( 'includes/wcal_all_component.php' );
326
+
327
+ }
328
+ }
329
  /**
330
  * It will add the Questions while admin deactivate the plugin.
331
  * @hook ts_deativate_plugin_questions
375
  * @since 3.4
376
  */
377
  public static function wcal_order_placed( $order_id ) {
378
+
 
 
 
 
379
  /**
380
  * When user comes from the abandoned cart reminder email this conditon will be executed.
381
  * It will check the guest uers data in further 3 conditions.
385
  * 3. When user places the orde as guest user.
386
  * It will consider the old cart of the customer as the recovered order and delete the unwanted new records.
387
  */
388
+ $email_sent_id = wcal_common::wcal_get_cart_session( 'email_sent_id' );
389
+
390
+ if ( $email_sent_id !='' ) {
391
+
392
  global $woocommerce, $wpdb;
393
 
394
  $wcal_history_table_name = $wpdb->prefix . 'ac_abandoned_cart_history_lite';
395
  $wcal_guest_table_name = $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite';
396
  $wcal_sent_email_table_name = $wpdb->prefix . 'ac_sent_history_lite';
397
 
 
 
398
  $get_ac_id_query = "SELECT abandoned_order_id FROM ". $wcal_sent_email_table_name ." WHERE id = %d";
399
  $get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query, $email_sent_id ) );
400
 
406
  $wcal_account_password_check = 'no';
407
 
408
  /*if user becomes the registered user */
409
+ if ( isset( $_POST['account_password'] ) && '' != $_POST['account_password'] ) {
410
 
411
+ $abandoned_cart_id_new_user = wcal_common::wcal_get_cart_session( 'abandoned_cart_id_lite' );
 
 
 
412
 
413
+ $wcal_user_id_of_guest = wcal_common::wcal_get_cart_session( 'user_id' );
 
 
 
414
 
415
  /* delete the guest record. As it become the logged in user */
416
 
420
  $get_ac_id_guest_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_guest_query, $wcal_user_id_of_guest ) );
421
  }
422
 
423
+ if ( count ( $get_ac_id_guest_results ) > 1 ) {
424
  $abandoned_order_id_of_guest = $get_ac_id_guest_results[0]->id;
425
  $wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_order_id_of_guest ) );
426
  }
438
  $_POST['createaccount'] != '' &&
439
  'no' == $wcal_account_password_check ) {
440
 
441
+ $abandoned_cart_id_new_user = wcal_common::wcal_get_cart_session( 'abandoned_cart_id_lite' );
442
+
 
 
443
  $wcal_user_id_of_guest = '';
444
  if ( isset( $_SESSION['user_id'] ) && '' != $_SESSION['user_id'] ) {
445
+ $wcal_user_id_of_guest = $_SESSION['user_id'];
446
  }
447
  /* Delete the guest record. As it become the logged in user */
448
  $get_ac_id_guest_results = array();
450
  $get_ac_id_guest_query = "SELECT id FROM `" . $wcal_history_table_name ."` WHERE user_id = %d ORDER BY id DESC";
451
  $get_ac_id_guest_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_guest_query, $wcal_user_id_of_guest ) );
452
  }
453
+ if ( count ( $get_ac_id_guest_results ) > 1 ) {
454
  $abandoned_order_id_of_guest = $get_ac_id_guest_results[0]->id;
455
  $wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_order_id_of_guest ) );
456
  }
471
  $get_ac_id_guest_query = "SELECT id FROM `" . $wcal_history_table_name ."` WHERE user_id = %d ORDER BY id DESC";
472
  $get_ac_id_guest_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_guest_query, $wcal_user_id_of_guest ) );
473
 
474
+ if ( count ( $get_ac_id_guest_results ) > 1 ) {
475
  $abandoned_order_id_of_guest = $get_ac_id_guest_results[0]->id;
476
  $wpdb->delete( $wcal_history_table_name, array( 'id' => $abandoned_order_id_of_guest ) );
477
  }
483
  add_post_meta( $order_id , 'wcal_recover_order_placed', $abandoned_order_id );
484
  }
485
 
486
+ }else if ( wcal_common::wcal_get_cart_session( 'abandoned_cart_id_lite' ) != '' ) {
487
 
488
  /**
489
  * In this codition we are cheking that if the order is placed before the cart cut off time then we
492
  * the abandoned cart id. So we will refer this abandoned cart id when order staus is changed
493
  * while placing the order.
494
  */
 
 
 
 
 
495
  global $woocommerce, $wpdb;
496
 
497
  $wcal_history_table_name = $wpdb->prefix . 'ac_abandoned_cart_history_lite';
498
  $wcal_guest_table_name = $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite';
499
  $wcal_sent_email_table_name = $wpdb->prefix . 'ac_sent_history_lite';
500
 
501
+ $current_time = current_time( 'timestamp' );
502
  $wcal_cart_abandoned_time = '';
503
+
504
+ $wcal_abandoned_cart_id = wcal_common::wcal_get_cart_session( 'abandoned_cart_id_lite' );
505
+
506
+ if ( $wcal_abandoned_cart_id != '' ) {
507
 
508
  $get_abandoned_cart_query = "SELECT abandoned_cart_time FROM `" . $wcal_history_table_name . "` WHERE id = %d ";
509
  $get_abandoned_cart_results = $wpdb->get_results( $wpdb->prepare( $get_abandoned_cart_query, $wcal_abandoned_cart_id ) );
510
 
511
+ if ( count( $get_abandoned_cart_results ) > 0 ) {
512
  $wcal_cart_abandoned_time = $get_abandoned_cart_results[0]->abandoned_cart_time;
513
  }
514
 
516
  $cut_off_time = $ac_cutoff_time * 60;
517
  $compare_time = $current_time - $cut_off_time;
518
 
519
+ if ( $compare_time > $wcal_cart_abandoned_time ) {
520
  /* cart is declared as adandoned */
521
  add_post_meta( $order_id , 'wcal_recover_order_placed', $wcal_abandoned_cart_id );
522
+ } else {
523
  /**
524
  * Cart order is placed within the cutoff time.
525
  * We will delete that abandoned cart.
527
 
528
  /* If user becomes the registred user */
529
 
530
+ if ( isset( $_POST['account_password'] ) && '' != $_POST['account_password'] ) {
531
 
532
+ $abandoned_cart_id_new_user = wcal_common::wcal_get_cart_session( 'abandoned_cart_id_lite' );
533
+ $wcal_user_id_of_guest = wcal_common::wcal_get_cart_session( 'user_id' );
534
 
535
  /* Delete the guest record. As it become the logged in user */
536
 
539
 
540
  /* It is the new registered users cart id */
541
  $wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_cart_id_new_user ) );
542
+ } else {
543
 
544
  /**
545
  * It will delete the order from history table if the order is placed before any email sent to
548
  $wpdb->delete( $wcal_history_table_name , array( 'id' => $wcal_abandoned_cart_id ) );
549
 
550
  /* This user id is set for the guest uesrs. */
551
+ if ( wcal_common::wcal_get_cart_session( 'user_id' ) != '' ) {
552
+ $wcal_user_id_of_guest = wcal_common::wcal_get_cart_session( 'user_id' );
 
553
  $wpdb->delete( $wcal_guest_table_name, array( 'id' => $wcal_user_id_of_guest ) );
554
  }
555
  }
614
  if ( count( $get_abandoned_cart_user_id_results ) > 0 ) {
615
  $wcap_user_id = $get_abandoned_cart_user_id_results[0]->user_id;
616
 
617
+ if ( $wcap_user_id >= 63000000 ) {
618
+ $wpdb->delete( $wcal_guest_ac_table_name, array( 'id' => $wcap_user_id ) );
619
  }
620
 
621
+ $wpdb->delete( $wcal_ac_table_name, array( 'id' => $get_abandoned_id_of_order ) );
622
+ delete_post_meta( $order_id, 'wcap_recover_order_placed', $get_abandoned_id_of_order );
623
  }
624
  }
625
  }
634
  */
635
  public function wcal_preview_emails() {
636
  global $woocommerce;
637
+ if ( isset( $_GET['wcal_preview_woocommerce_mail'] ) ) {
638
+ if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-abandoned-cart' ) ) {
639
  die( 'Security check' );
640
  }
641
  $message = '';
642
  // create a new email
643
+ if ( $woocommerce->version < '2.3' ) {
644
  global $email_heading;
645
  ob_start();
646
 
674
  // get the preview email content
675
  ob_start();
676
  include( 'views/wcal-email-template-preview.php' );
677
+ $message = ob_get_clean();
678
  // print the preview email
679
  echo $message;
680
  exit;
711
  function wcal_activate() {
712
  global $wpdb;
713
  $wcap_collate = '';
714
+ if ( $wpdb->has_cap( 'collation' ) ) {
715
  $wcap_collate = $wpdb->get_charset_collate();
716
  }
717
  $table_name = $wpdb->prefix . "ac_email_templates_lite";
718
  $sql = "CREATE TABLE IF NOT EXISTS $table_name (
719
  `id` int(11) NOT NULL AUTO_INCREMENT,
720
+ `subject` text NOT NULL,
721
+ `body` mediumtext NOT NULL,
722
+ `is_active` enum('0','1') NOT NULL,
723
  `frequency` int(11) NOT NULL,
724
+ `day_or_hour` enum('Days','Hours') NOT NULL,
725
+ `template_name` text NOT NULL,
726
+ `is_wc_template` enum('0','1') NOT NULL,
727
+ `default_template` int(11) NOT NULL,
728
+ `wc_email_header` varchar(50) NOT NULL,
729
  PRIMARY KEY (`id`)
730
  ) $wcap_collate AUTO_INCREMENT=1 ";
731
 
778
  // Default templates: function call to create default templates.
779
  $check_table_empty = $wpdb->get_var( "SELECT COUNT(*) FROM `" . $wpdb->prefix . "ac_email_templates_lite`" );
780
 
781
+ if ( ! get_option( 'wcal_new_default_templates' ) ) {
782
+ if ( 0 == $check_table_empty ) {
783
  $default_template = new wcal_default_template_settings;
784
  $default_template->wcal_create_default_templates();
785
+ update_option( 'wcal_new_default_templates', "yes" );
786
  }
787
  }
788
 
790
  $query_guest_table = "SHOW TABLES LIKE '$guest_table' ";
791
  $result_guest_table = $wpdb->get_results( $query_guest_table );
792
 
793
+ if ( 0 == count( $result_guest_table ) ) {
794
  $ac_guest_history_table_name = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
795
  $ac_guest_history_query = "CREATE TABLE IF NOT EXISTS $ac_guest_history_table_name (
796
  `id` int(15) NOT NULL AUTO_INCREMENT,
825
  * This is add for thos user who Install the plguin first time.
826
  * So for them this option will be cheked.
827
  */
828
+ if ( ! get_option( 'ac_lite_track_guest_cart_from_cart_page' ) ) {
829
  add_option( 'ac_lite_track_guest_cart_from_cart_page', 'on' );
830
  }
831
+ if ( ! get_option( 'wcal_from_name' ) ) {
832
  add_option( 'wcal_from_name', 'Admin' );
833
  }
834
  $wcal_get_admin_email = get_option( 'admin_email' );
835
+ if ( ! get_option( 'wcal_from_email' ) ) {
836
  add_option( 'wcal_from_email', $wcal_get_admin_email );
837
  }
838
 
839
+ if ( ! get_option( 'wcal_reply_email' ) ) {
840
  add_option( 'wcal_reply_email', $wcal_get_admin_email );
841
  }
842
 
852
 
853
  // First, we register a section. This is necessary since all future options must belong to a
854
  add_settings_section(
855
+ 'ac_lite_general_settings_section', // ID used to identify this section and with which to register options
856
+ __( 'Settings', 'woocommerce-abandoned-cart' ), // Title to be displayed on the administration page
857
+ array( $this, 'ac_lite_general_options_callback' ), // Callback used to render the description of the section
858
+ 'woocommerce_ac_page' // Page on which to add this section of options
859
  );
860
 
861
  add_settings_field(
920
  */
921
 
922
  add_settings_section(
923
+ 'ac_email_settings_section', // ID used to identify this section and with which to register options
924
+ __( 'Settings for abandoned cart recovery emails', 'woocommerce-abandoned-cart' ), // Title to be displayed on the administration page
925
+ array( $this, 'wcal_email_callback' ), // Callback used to render the description of the section
926
+ 'woocommerce_ac_email_page' // Page on which to add this section of options
927
  );
928
 
929
  add_settings_field(
1037
  */
1038
  function ac_lite_cart_time_validation( $input ) {
1039
  $output = '';
1040
+ if ( '' != $input && ( is_numeric( $input) && $input > 0 ) ) {
1041
  $output = stripslashes( $input) ;
1042
  } else {
1043
  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-abandoned-cart' ) );
1053
  */
1054
  public static function wcal_delete_days_validation( $input ) {
1055
  $output = '';
1056
+ if ( '' == $input || ( is_numeric( $input ) && $input > 0 ) ) {
1057
  $output = stripslashes( $input );
1058
  } else {
1059
  add_settings_error( 'ac_lite_delete_abandoned_order_days', 'error found', __( 'Automatically Delete Abandoned Orders after X days has to be greater than 0.', 'woocommerce-abandoned-cart' ) );
1090
  $email_admin_on_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
1091
 
1092
  // This condition added to avoid the notie displyed while Check box is unchecked.
1093
+ if ( isset( $email_admin_on_recovery ) && '' == $email_admin_on_recovery ) {
1094
  $email_admin_on_recovery = 'off';
1095
  }
1096
  // Next, we update the name attribute to access this element's ID in the context of the display options array
1098
  $html='';
1099
  printf(
1100
  '<input type="checkbox" id="ac_lite_email_admin_on_recovery" name="ac_lite_email_admin_on_recovery" value="on"
1101
+ ' . checked('on', $email_admin_on_recovery, false).' />'
1102
+ );
1103
 
1104
  // Here, we'll take the first argument of the array and add it to a label next to the checkbox
1105
  $html .= '<label for="ac_lite_email_admin_on_recovery"> ' . $args[0] . '</label>';
1115
  $disable_guest_cart_from_cart_page = get_option( 'ac_lite_track_guest_cart_from_cart_page' );
1116
 
1117
  // This condition added to avoid the notice displyed while Check box is unchecked.
1118
+ if ( isset( $disable_guest_cart_from_cart_page ) && '' == $disable_guest_cart_from_cart_page ) {
1119
  $disable_guest_cart_from_cart_page = 'off';
1120
  }
1121
  // Next, we update the name attribute to access this element's ID in the context of the display options array
1150
  * @param array $args Argument for adding field details
1151
  * @since 7.8
1152
  */
1153
+ public static function wcal_logged_cart_capture_msg_callback( $args ) {
1154
 
1155
  $logged_msg = get_option( 'wcal_logged_cart_capture_msg' );
1156
 
1181
  printf(
1182
  '<input type="text" id="wcal_from_name" name="wcal_from_name" value="%s" />',
1183
  isset( $wcal_from_name ) ? esc_attr( $wcal_from_name ) : ''
1184
+ );
1185
+ // Here, we'll take the first argument of the array and add it to a label next to the checkbox
1186
+ $html = '<label for="wcal_from_name_label"> ' . $args[0] . '</label>';
1187
+ echo $html;
1188
  }
1189
 
1190
  /**
1200
  printf(
1201
  '<input type="text" id="wcal_from_email" name="wcal_from_email" value="%s" />',
1202
  isset( $wcal_from_email ) ? esc_attr( $wcal_from_email ) : ''
1203
+ );
1204
+ // Here, we'll take the first argument of the array and add it to a label next to the checkbox
1205
+ $html = '<label for="wcal_from_email_label"> ' . $args[0] . '</label>';
1206
+ echo $html;
1207
  }
1208
 
1209
  /**
1219
  printf(
1220
  '<input type="text" id="wcal_reply_email" name="wcal_reply_email" value="%s" />',
1221
  isset( $wcal_reply_email ) ? esc_attr( $wcal_reply_email ) : ''
1222
+ );
1223
+ // Here, we'll take the first argument of the array and add it to a label next to the checkbox
1224
+ $html = '<label for="wcal_reply_email_label"> ' . $args[0] . '</label>';
1225
+ echo $html;
1226
  }
1227
 
1228
  /**
1237
  $wcal_previous_version = get_option( 'wcal_previous_version' );
1238
 
1239
  if ( $wcal_previous_version != wcal_common::wcal_get_version() ) {
1240
+ update_option( 'wcal_previous_version', '5.1.1' );
1241
  }
1242
 
1243
  /**
1251
  update_option ( 'wcal_guest_user_id_altered', 'yes' );
1252
  }
1253
  }
1254
+
1255
+ if( !get_option( 'wcal_new_default_templates' ) ) {
1256
+ $default_template = new wcal_default_template_settings;
1257
+ $default_template->wcal_create_default_templates();
1258
+ add_option( 'wcal_new_default_templates', "yes" );
1259
+
1260
+ }
1261
+ if ( 'yes' != get_option( 'ac_lite_alter_table_queries' ) ) {
1262
  $ac_history_table_name = $wpdb->prefix."ac_abandoned_cart_history_lite";
1263
  $check_table_query = "SHOW COLUMNS FROM $ac_history_table_name LIKE 'user_type'";
1264
  $results = $wpdb->get_results( $check_table_query );
1265
 
1266
+ if ( 0 == count( $results ) ) {
1267
  $alter_table_query = "ALTER TABLE $ac_history_table_name ADD `user_type` text AFTER `recovered_cart`";
1268
  $wpdb->get_results( $alter_table_query );
1269
  }
1272
  $check_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'is_wc_template' ";
1273
  $results = $wpdb->get_results( $check_template_table_query );
1274
 
1275
+ if ( 0 == count( $results ) ) {
1276
  $alter_template_table_query = "ALTER TABLE $table_name
1277
  ADD COLUMN `is_wc_template` enum('0','1') COLLATE utf8_unicode_ci NOT NULL AFTER `template_name`,
1278
  ADD COLUMN `default_template` int(11) NOT NULL AFTER `is_wc_template`";
1283
  $check_email_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'wc_email_header' ";
1284
  $results_email = $wpdb->get_results( $check_email_template_table_query );
1285
 
1286
+ if ( 0 == count( $results_email ) ) {
1287
  $alter_email_template_table_query = "ALTER TABLE $table_name
1288
+ ADD COLUMN `wc_email_header` varchar(50) NOT NULL AFTER `default_template`";
1289
  $wpdb->get_results( $alter_email_template_table_query );
1290
  }
1291
 
1309
  if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_email_templates_lite';" ) ) {
1310
  if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'from_email';" ) ) {
1311
  $get_email_template_query = "SELECT `from_email` FROM {$wpdb->prefix}ac_email_templates_lite WHERE `is_active` = '1' ORDER BY `id` ASC LIMIT 1";
1312
+ $get_email_template_result = $wpdb->get_results ( $get_email_template_query );
1313
  $wcal_from_email = '';
1314
  if ( isset( $get_email_template_result ) && count ( $get_email_template_result ) > 0 ){
1315
  $wcal_from_email = $get_email_template_result[0]->from_email;
1322
 
1323
  if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'from_name';" ) ) {
1324
  $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";
1325
+ $get_email_template_from_name_result = $wpdb->get_results ( $get_email_template_from_name_query );
1326
  $wcal_from_name = '';
1327
  if ( isset( $get_email_template_from_name_result ) && count ( $get_email_template_from_name_result ) > 0 ){
1328
  $wcal_from_name = $get_email_template_from_name_result[0]->from_name;
1335
 
1336
  if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'reply_email';" ) ) {
1337
  $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";
1338
+ $get_email_template_reply_email_result = $wpdb->get_results ( $get_email_template_reply_email_query);
1339
  $wcal_reply_email = '';
1340
  if ( isset( $get_email_template_reply_email_result ) && count ( $get_email_template_reply_email_result ) > 0 ){
1341
  $wcal_reply_email = $get_email_template_reply_email_result[0]->reply_email;
1347
  }
1348
  }
1349
 
1350
+ if ( ! get_option( 'wcal_security_key' ) ) {
1351
  update_option( 'wcal_security_key', 'qJB0rGtIn5UB1xG03efyCp' );
1352
  }
1353
 
1356
 
1357
  //get the option, if it is not set to individual then convert to individual records and delete the base record
1358
  $ac_settings = get_option( 'ac_lite_settings_status' );
1359
+ if ( 'INDIVIDUAL' != $ac_settings ) {
1360
  //fetch the existing settings and save them as inidividual to be used for the settings API
1361
  $woocommerce_ac_settings = json_decode( get_option( 'woocommerce_ac_settings' ) );
1362
 
1363
+ if ( isset( $woocommerce_ac_settings[0]->cart_time ) ) {
1364
  add_option( 'ac_lite_cart_abandoned_time', $woocommerce_ac_settings[0]->cart_time );
1365
  } else {
1366
  add_option( 'ac_lite_cart_abandoned_time', '10' );
1367
  }
1368
 
1369
+ if ( isset( $woocommerce_ac_settings[0]->delete_order_days ) ) {
1370
  add_option( 'ac_lite_delete_abandoned_order_days', $woocommerce_ac_settings[0]->delete_order_days );
1371
  } else {
1372
  add_option( 'ac_lite_delete_abandoned_order_days', "" );
1373
  }
1374
 
1375
+ if ( isset( $woocommerce_ac_settings[0]->email_admin ) ) {
1376
  add_option( 'ac_lite_email_admin_on_recovery', $woocommerce_ac_settings[0]->email_admin );
1377
  } else {
1378
  add_option( 'ac_lite_email_admin_on_recovery', "" );
1379
+ }
1380
+
1381
+ if ( isset( $woocommerce_ac_settings[0]->disable_guest_cart_from_cart_page ) ) {
1382
  add_option( 'ac_lite_track_guest_cart_from_cart_page', $woocommerce_ac_settings[0]->disable_guest_cart_from_cart_page );
1383
  } else {
1384
  add_option( 'ac_lite_track_guest_cart_from_cart_page', "" );
1385
+ }
1386
+
1387
  update_option( 'ac_lite_settings_status', 'INDIVIDUAL' );
1388
  //Delete the main settings record
1389
  delete_option( 'woocommerce_ac_settings' );
1390
  }
1391
+
1392
+ if ( 'yes' != get_option( 'ac_lite_delete_redundant_queries' ) ) {
1393
+ $ac_history_table_name = $wpdb->prefix."ac_abandoned_cart_history_lite";
1394
+
1395
+ $wpdb->delete( $ac_history_table_name, array( 'abandoned_cart_info' => '{"cart":[]}' ) );
1396
+
1397
+ update_option( 'ac_lite_delete_redundant_queries', 'yes' );
1398
+ }
1399
  }
1400
 
1401
  /**
1414
  $user_id = get_current_user_id();
1415
  $ac_email_admin_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
1416
  $order = new WC_Order( $order_id );
1417
+ if ( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
1418
+ $user_id = $order->get_user_id();
1419
  } else {
1420
+ $user_id = $order->user_id;
1421
  }
1422
 
1423
+ if ( 'on' == $ac_email_admin_recovery ) {
1424
  $recovered_email_sent = get_post_meta( $order_id, 'wcap_recovered_email_sent', true );
1425
  $created_via = get_post_meta( $order_id, '_created_via', true );
1426
  $wcal_check_order_is_recovered = woocommerce_abandon_cart_lite::wcal_check_order_is_recovered( $order_id );
1470
 
1471
  $user_id = get_current_user_id();
1472
  $ac_email_admin_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
1473
+ if ( 'on' == $ac_email_admin_recovery ) {
1474
+ $order = new WC_Order( $order_id );
1475
 
1476
+ if ( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
1477
+ $user_id = $order->get_user_id();
1478
+ } else {
1479
+ $user_id = $order->user_id;
1480
  }
1481
  $recovered_email_sent = get_post_meta( $order_id, 'wcap_recovered_email_sent', true );
1482
  $created_via = get_post_meta( $order_id, '_created_via', true );
1492
  ob_start();
1493
  // Get mail template
1494
  wc_get_template( 'emails/admin-new-order.php', array(
1495
+ 'order' => $order,
1496
+ 'email_heading' => $email_heading,
1497
+ 'sent_to_admin' => false,
1498
+ 'plain_text' => false,
1499
+ 'email' => true
1500
  ) );
1501
  // Get contents
1502
  $email_body = ob_get_clean();
1519
  global $wpdb;
1520
  $wcal_recover_order_query = "SELECT `recovered_cart` FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE `recovered_cart` = %d";
1521
  $wcal_recover_order_query_result = $wpdb->get_results( $wpdb->prepare( $wcal_recover_order_query, $wcal_order_id ) );
1522
+ if ( count( $wcal_recover_order_query_result ) > 0 ) {
1523
  return true;
1524
  }
1525
  return false;
1542
  * @since 1.0
1543
  */
1544
  function wcal_store_cart_timestamp() {
1545
+
 
 
 
 
1546
  global $wpdb,$woocommerce;
1547
+ $current_time = current_time( 'timestamp' );
1548
+ $cut_off_time = get_option( 'ac_lite_cart_abandoned_time' );
1549
  $track_guest_cart_from_cart_page = get_option( 'ac_lite_track_guest_cart_from_cart_page' );
1550
+ $cart_ignored = 0;
1551
+ $recovered_cart = 0;
1552
 
1553
  $track_guest_user_cart_from_cart = "";
1554
  if ( isset( $track_guest_cart_from_cart_page ) ) {
1555
  $track_guest_user_cart_from_cart = $track_guest_cart_from_cart_page;
1556
  }
1557
 
1558
+ if ( isset( $cut_off_time ) ) {
1559
  $cart_cut_off_time = intval( $cut_off_time ) * 60;
1560
  } else {
1561
  $cart_cut_off_time = 60 * 60;
1568
  WHERE user_id = %d
1569
  AND cart_ignored = %s
1570
  AND recovered_cart = %d ";
1571
+ $results = $wpdb->get_results( $wpdb->prepare( $query, $user_id, $cart_ignored, $recovered_cart ) );
1572
+
1573
+ if ( 0 == count( $results ) ) {
1574
  $wcal_woocommerce_persistent_cart =version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
1575
+
1576
+ $cart_info_meta = json_encode( get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true ) );
1577
+
1578
+ if( '' !== $cart_info_meta && '{"cart":[]}' != $cart_info_meta ) {
1579
+ $cart_info = $cart_info_meta;
1580
+ $user_type = "REGISTERED";
1581
+ $insert_query = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1582
+ ( user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type )
1583
+ VALUES ( %d, %s, %d, %s, %s )";
1584
+ $wpdb->query( $wpdb->prepare( $insert_query, $user_id, $cart_info,$current_time, $cart_ignored, $user_type ) );
1585
+
1586
+ $abandoned_cart_id = $wpdb->insert_id;
1587
+ wcal_common::wcal_set_cart_session( 'abandoned_cart_id_lite', $abandoned_cart_id );
1588
+ }
1589
  } elseif ( isset( $results[0]->abandoned_cart_time ) && $compare_time > $results[0]->abandoned_cart_time ) {
 
1590
  $wcal_woocommerce_persistent_cart = version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
1591
+ $updated_cart_info = json_encode( get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true ) );
1592
+
1593
+ if ( ! $this->wcal_compare_carts( $user_id, $results[0]->abandoned_cart_info ) ) {
1594
  $updated_cart_ignored = 1;
1595
  $query_ignored = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1596
  SET cart_ignored = %s
1606
  update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "yes" ) );
1607
 
1608
  $abandoned_cart_id = $wpdb->insert_id;
1609
+ wcal_common::wcal_set_cart_session( 'abandoned_cart_id_lite', $abandoned_cart_id );
1610
  } else {
1611
  update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "no" ) );
1612
  }
1613
+ } else {
1614
+ $wcal_woocommerce_persistent_cart = version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
1615
+ $updated_cart_info = json_encode( get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true ) );
1616
+
1617
  $query_update = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1618
  SET abandoned_cart_info = %s,
1619
  abandoned_cart_time = %d
1621
  AND cart_ignored = %s ";
1622
  $wpdb->query( $wpdb->prepare( $query_update, $updated_cart_info, $current_time, $user_id, $cart_ignored ) );
1623
 
1624
+ $query_update = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE user_id ='" . $user_id . "' AND cart_ignored='0' ";
1625
  $get_abandoned_record = $wpdb->get_results( $query_update );
1626
  if ( count( $get_abandoned_record ) > 0 ) {
1627
  $abandoned_cart_id = $get_abandoned_record[0]->id;
1628
+ wcal_common::wcal_set_cart_session( 'abandoned_cart_id_lite', $abandoned_cart_id );
1629
  }
1630
  }
1631
  } else {
1632
+ //start here guest user
1633
+ $user_id = wcal_common::wcal_get_cart_session( 'user_id' );
1634
+
 
 
 
 
1635
  $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'";
1636
  $results = $wpdb->get_results( $wpdb->prepare( $query, $user_id ) );
1637
  $cart = array();
1638
+
1639
  $get_cookie = WC()->session->get_session_cookie();
1640
  if ( function_exists('WC') ) {
1641
  $cart['cart'] = WC()->session->cart;
1642
  } else {
1643
  $cart['cart'] = $woocommerce->session->cart;
1644
  }
1645
+
1646
+ $updated_cart_info = json_encode( $cart );
1647
+ //$updated_cart_info = addslashes ( $updated_cart_info );
1648
+
1649
+ if ( count( $results ) > 0 && '{"cart":[]}' != $updated_cart_info ) {
1650
+ if ( $compare_time > $results[0]->abandoned_cart_time ) {
1651
  if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
1652
+
1653
  $query_ignored = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
1654
  SET cart_ignored = '1'
1655
  WHERE user_id ='".$user_id."'";
1674
  * Here we capture the guest cart from the cart page.
1675
  * @since 3.5
1676
  */
1677
+ if ( 'on' == $track_guest_user_cart_from_cart && '' != $get_cookie[0] ) {
1678
  $query = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE session_id LIKE %s AND cart_ignored = '0' AND recovered_cart = '0' ";
1679
  $results = $wpdb->get_results( $wpdb->prepare( $query, $get_cookie[0] ) );
1680
+ if ( 0 == count( $results ) ) {
1681
+ $cart_info = $updated_cart_info;
1682
+ $blank_cart_info = '[]';
1683
+ if ( $blank_cart_info != $cart_info && '{"cart":[]}' != $cart_info ) {
1684
  $insert_query = "INSERT INTO `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
1685
  ( abandoned_cart_info , abandoned_cart_time , cart_ignored , recovered_cart, user_type, session_id )
1686
  VALUES ( '" . $cart_info."' , '" . $current_time . "' , '0' , '0' , 'GUEST', '". $get_cookie[0] ."' )";
1687
  $wpdb->query( $insert_query );
1688
  }
1689
  } elseif ( $compare_time > $results[0]->abandoned_cart_time ) {
1690
+ $blank_cart_info = '[]';
1691
+ if ( $blank_cart_info != $updated_cart_info && '{"cart":[]}' != $updated_cart_info ) {
1692
  if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
1693
  $query_ignored = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET cart_ignored = '1' WHERE session_id ='" . $get_cookie[0] . "'";
1694
  $wpdb->query( $query_ignored );
1699
  }
1700
  }
1701
  } else {
1702
+ $blank_cart_info = '[]';
1703
+ if ( $blank_cart_info != $updated_cart_info && '{"cart":[]}' != $updated_cart_info ) {
1704
  if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
1705
  $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' ";
1706
  $wpdb->query( $query_update );
1730
  $validate_email_id_decode = 0;
1731
  $cryptKey = get_option( 'wcal_security_key' );
1732
  $validate_email_id_decode = Wcal_Aes_Ctr::decrypt( $validate_email_id_string, $cryptKey, 256 );
1733
+ if ( isset( $_GET['track_email_id'] ) ) {
1734
  $encoded_email_address = rawurldecode( $_GET['track_email_id'] );
1735
  $validate_email_address_string = str_replace( " " , "+", $encoded_email_address );
1736
+ }
1737
  $query_id = "SELECT * FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE id = %d ";
1738
  $results_sent = $wpdb->get_results ( $wpdb->prepare( $query_id, $validate_email_id_decode ) );
1739
  $email_address = '';
1740
+ if ( isset( $results_sent[0] ) ) {
1741
  $email_address = $results_sent[0]->sent_email_id;
1742
  }
1743
+ if ( $validate_email_address_string == hash( 'sha256', $email_address ) && '' != $email_address ) {
1744
  $email_sent_id = $validate_email_id_decode;
1745
  $get_ac_id_query = "SELECT abandoned_order_id FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE id = %d";
1746
  $get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query , $email_sent_id ) );
1747
  $user_id = 0;
1748
+ if ( isset( $get_ac_id_results[0] ) ) {
1749
  $get_user_id_query = "SELECT user_id FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE id = %d";
1750
  $get_user_results = $wpdb->get_results( $wpdb->prepare( $get_user_id_query , $get_ac_id_results[0]->abandoned_order_id ) );
1751
  }
1752
+ if ( isset( $get_user_results[0] ) ) {
1753
  $user_id = $get_user_results[0]->user_id;
1754
  }
1755
 
1788
  $track_link = $_GET['wcal_action'];
1789
  }
1790
  if ( $track_link == 'track_links' ) {
1791
+ if ( '' === session_id() ) {
1792
  //session has not started
1793
  session_start();
1794
  }
1800
  $link_decode = Wcal_Aes_Ctr::decrypt( $validate_encoded_string, $cryptKey, 256 );
1801
  $sent_email_id_pos = strpos( $link_decode, '&' );
1802
  $email_sent_id = substr( $link_decode , 0, $sent_email_id_pos );
1803
+
1804
+ wcal_common::wcal_set_cart_session( 'email_sent_id', $email_sent_id );
1805
+ set_transient( 'wcal_email_sent_id', $email_sent_id, 5 );
1806
+
1807
  $url_pos = strpos( $link_decode, '=' );
1808
  $url_pos = $url_pos + 1;
1809
  $url = substr( $link_decode, $url_pos );
1814
  $get_user_id_query = "SELECT user_id FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE id = %d";
1815
  $get_user_results = $wpdb->get_results( $wpdb->prepare( $get_user_id_query, $get_ac_id_results[0]->abandoned_order_id ) );
1816
  }
1817
+ $user_id = 0;
1818
  if ( isset( $get_user_results ) && count( $get_user_results ) > 0 ) {
1819
  $user_id = $get_user_results[0]->user_id;
1820
  }
1821
+ if ( 0 == $user_id ) {
1822
  echo "Link expired";
1823
  exit;
1824
  }
1829
  $query_cart = "SELECT recovered_cart FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id = %d";
1830
  $results = $wpdb->get_results( $wpdb->prepare( $query_cart, $user_id ) );
1831
  if ( $results_guest && $results[0]->recovered_cart == '0' ) {
1832
+ wcal_common::wcal_set_cart_session( 'guest_first_name', $results_guest[0]->billing_first_name );
1833
+ wcal_common::wcal_set_cart_session( 'guest_last_name', $results_guest[0]->billing_last_name );
1834
+ wcal_common::wcal_set_cart_session( 'guest_email', $results_guest[0]->email_id );
1835
+ wcal_common::wcal_set_cart_session( 'user_id', $user_id );
1836
  } else {
1837
+ if ( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
1838
  wp_redirect( get_permalink( wc_get_page_id( 'shop' ) ) );
1839
  } else {
1840
  wp_redirect( get_permalink( woocommerce_get_page_id( 'shop' ) ) );
1868
  * @since 1.0
1869
  */
1870
  function wcal_load_guest_persistent_cart() {
1871
+ if ( wcal_common::wcal_get_cart_session( 'user_id' ) != '' ) {
1872
  global $woocommerce;
1873
+ $saved_cart = json_decode( get_user_meta( wcal_common::wcal_get_cart_session( 'user_id' ), '_woocommerce_persistent_cart',true ), true );
1874
  $c = array();
1875
  $cart_contents_total = $cart_contents_weight = $cart_contents_count = $cart_contents_tax = $total = $subtotal = $subtotal_ex_tax = $tax_total = 0;
1876
  if ( count( $saved_cart ) > 0 ) {
1881
  $c['variation'] = $b['variation'];
1882
  $c['quantity'] = $b['quantity'];
1883
  $product_id = $b['product_id'];
1884
+ $c['data'] = wc_get_product( $product_id );
1885
  $c['line_total'] = $b['line_total'];
1886
  $c['line_tax'] = $cart_contents_tax;
1887
  $c['line_subtotal'] = $b['line_subtotal'];
1898
  }
1899
  }
1900
 
1901
+ if ( $saved_cart ) {
1902
  if ( empty( $woocommerce->session->cart ) || ! is_array( $woocommerce->session->cart ) || sizeof( $woocommerce->session->cart ) == 0 ) {
1903
  $woocommerce->session->cart = $saved_cart['cart'];
1904
  $woocommerce->session->cart_contents_total = $cart_contents_total;
1996
  $current_woo_cart = get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true );
1997
  $abandoned_cart_arr = json_decode( $last_abandoned_cart, true );
1998
  $temp_variable = "";
1999
+ if ( isset( $current_woo_cart['cart'] ) && isset( $abandoned_cart_arr['cart'] ) ) {
2000
  if ( count( $current_woo_cart['cart'] ) >= count( $abandoned_cart_arr['cart'] ) ) {
2001
  //do nothing
2002
  } else {
2051
  */
2052
  function wcal_action_after_delivery_session( $order ) {
2053
 
2054
+ if ( '' === session_id() ) {
2055
  //session has not started
2056
  session_start();
2057
  }
2058
  global $wpdb, $woocommerce;
2059
+ if ( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
2060
+ $order_id = $order->get_id();
2061
+ } else {
2062
+ $order_id = $order->id;
2063
  }
2064
  $get_abandoned_id_of_order = '';
2065
  $get_sent_email_id_of_order = '';
2066
  $get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
2067
+ if ( isset( $get_abandoned_id_of_order ) && '' != $get_abandoned_id_of_order ) {
2068
  $get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
2069
  $get_sent_email_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed_sent_id', true );
2070
 
2071
  $query_order = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET recovered_cart= '" . $order_id . "', cart_ignored = '1'
2072
+ WHERE id = '".$get_abandoned_id_of_order."' ";
2073
  $wpdb->query( $query_order );
2074
 
2075
  $order->add_order_note( __( 'This order was abandoned & subsequently recovered.', 'woocommerce-abandoned-cart' ) );
2078
  delete_post_meta( $order_id , 'wcal_recover_order_placed_sent_id', $get_sent_email_id_of_order );
2079
  }
2080
  $user_id = get_current_user_id();
2081
+
2082
+ $sent_email = wcal_common::wcal_get_cart_session( 'email_sent_id' );
2083
+
 
2084
  if( $user_id == "" ) {
2085
+ $user_id = wcal_common::wcal_get_cart_session( 'user_id' );
2086
+
2087
  // Set the session variables to blanks
2088
+ wcal_common::wcal_unset_cart_session( 'guest_first_name' );
2089
+ wcal_common::wcal_unset_cart_session( 'guest_last_name' );
2090
+ wcal_common::wcal_unset_cart_session( 'guest_email' );
2091
+ wcal_common::wcal_unset_cart_session( 'user_id' );
2092
  }
2093
  delete_user_meta( $user_id, '_woocommerce_ac_persistent_cart_time' );
2094
  delete_user_meta( $user_id, '_woocommerce_ac_persistent_cart_temp_time' );
2106
  if ( get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true ) == md5( "yes" ) ||
2107
  get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true ) == md5( "no" ) ) {
2108
 
2109
+ if ( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
2110
+ $order_id = $order->get_id();
2111
+ } else {
2112
+ $order_id = $order->id;
2113
  }
2114
  $updated_cart_ignored = 1;
2115
  $query_order = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
2119
  $wpdb->query( $wpdb->prepare( $query_order, $order_id, $updated_cart_ignored, $results[0]->id ) );
2120
  delete_user_meta( $user_id, '_woocommerce_ac_modified_cart' );
2121
  delete_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
2122
+ } else {
2123
  $delete_query = "DELETE FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
2124
  WHERE id= %d ";
2125
  $wpdb->query( $wpdb->prepare( $delete_query, $results[0]->id ) );
2126
  }
2127
  } else {
2128
+ if ( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
2129
+ $email_id = $order->get_billing_email();
2130
+ } else {
2131
+ $email_id = $order->billing_email;
 
2132
  }
2133
  $query = "SELECT * FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE email_id = %s";
2134
  $results_id = $wpdb->get_results( $wpdb->prepare( $query, $email_id ) );
2135
 
2136
  if ( $results_id ) {
2137
+ $record_status = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
2138
+ WHERE user_id = %d AND recovered_cart = '0'";
2139
  $results_status = $wpdb->get_results( $wpdb->prepare( $record_status, $results_id[0]->id ) );
2140
 
2141
  if ( $results_status ) {
2142
  if ( get_user_meta( $results_id[0]->id, '_woocommerce_ac_modified_cart', true ) == md5("yes") ||
2143
  get_user_meta( $results_id[0]->id, '_woocommerce_ac_modified_cart', true ) == md5("no") ) {
2144
 
2145
+ if ( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
2146
+ $order_id = $order->get_id();
2147
+ } else {
2148
+ $order_id = $order->id;
2149
  }
2150
  $query_order = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
2151
  SET recovered_cart= '".$order_id."', cart_ignored = '1'
2160
  $delete_query = "DELETE FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id='".$results_id[0]->id."' ";
2161
  $wpdb->query( $delete_query );
2162
  }
2163
+ }
2164
  }
2165
  }
2166
  }
2174
 
2175
  // only hook up these filters if we're in the admin panel and the current user has permission
2176
  // to edit posts and pages
2177
+ if ( ! isset( $_GET['page'] ) || $_GET['page'] != "woocommerce_ac_page" ) {
2178
  return;
2179
  }
2180
+ if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
2181
  return;
2182
  }
2183
+ if ( 'true' == get_user_option( 'rich_editing' ) ) {
2184
  remove_filter( 'the_excerpt', 'wpautop' );
2185
  add_filter( 'tiny_mce_before_init', array( &$this, 'wcal_format_tiny_MCE' ) );
2186
+ add_filter( 'mce_buttons', array( &$this, 'wcal_filter_mce_button' ) );
2187
+ add_filter( 'mce_external_plugins', array( &$this, 'wcal_filter_mce_plugin' ) );
 
 
 
 
 
 
2188
  }
2189
  }
2190
 
2229
  $active_settings = "";
2230
  $active_stats = "";
2231
  }
2232
+ if ( ( 'listcart' == $action || 'orderdetails' == $action ) || '' == $action ) {
2233
  $active_listcart = "nav-tab-active";
2234
  }
2235
+ if ( 'emailtemplates' == $action ) {
2236
  $active_emailtemplates = "nav-tab-active";
2237
  }
2238
+ if ( 'emailsettings' == $action ) {
2239
  $active_settings = "nav-tab-active";
2240
  }
2241
+ if ( 'stats' == $action ) {
2242
  $active_stats = "nav-tab-active";
2243
  }
2244
+ if ( 'report' == $action ) {
2245
  $active_report = "nav-tab-active";
2246
  }
2247
  ?>
2248
  <div style="background-image: url('<?php echo plugins_url(); ?>/woocommerce-abandoned-cart/assets/images/ac_tab_icon.png') !important;" class="icon32"><br>
2249
  </div>
2250
  <h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
2251
+ <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-abandoned-cart' );?> </a>
2252
+ <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-abandoned-cart' );?> </a>
2253
+ <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-abandoned-cart' );?> </a>
2254
+ <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-abandoned-cart' );?> </a>
2255
+ <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-abandoned-cart' );?> </a>
2256
 
2257
+ <?php do_action( 'wcal_add_settings_tab' ); ?>
2258
  </h2>
2259
  <?php
2260
  }
2266
  * @since 1.0
2267
  */
2268
  function wcal_enqueue_scripts_js( $hook ) {
2269
+ global $pagenow, $woocommerce;
2270
+ $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
2271
+
2272
+ if ( $page === '' || $page !== 'woocommerce_ac_page' ) {
2273
  return;
2274
  } else {
2275
  wp_enqueue_script( 'jquery' );
2276
+ wp_enqueue_script(
2277
+ 'jquery-ui-min',
2278
+ plugins_url( '/assets/js/jquery-ui.min.js', __FILE__ ),
2279
+ '',
2280
+ '',
2281
+ false
2282
  );
2283
  wp_enqueue_script( 'jquery-ui-datepicker' );
 
2284
  wp_enqueue_script(
2285
  'jquery-tip',
2286
  plugins_url( '/assets/js/jquery.tipTip.minified.js', __FILE__ ),
2288
  '',
2289
  false
2290
  );
2291
+
2292
  wp_register_script( 'woocommerce_admin', plugins_url() . '/woocommerce/assets/js/admin/woocommerce_admin.js', array( 'jquery', 'jquery-ui-widget', 'jquery-ui-core' ) );
2293
  wp_enqueue_script( 'woocommerce_admin' );
2294
  ?>
2344
  * @since 1.0
2345
  */
2346
  function wcal_enqueue_scripts_css( $hook ) {
2347
+
2348
+ global $pagenow;
2349
+
2350
+ $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
2351
+
2352
+ if ( $page != 'woocommerce_ac_page' ) {
2353
  return;
2354
+ } elseif ( $page === 'woocommerce_ac_page' ) {
2355
+
2356
+ wp_enqueue_style( 'jquery-ui', plugins_url() . '/woocommerce-abandoned-cart/assets/css/jquery-ui.css', '', '', false );
2357
  wp_enqueue_style( 'woocommerce_admin_styles', plugins_url() . '/woocommerce/assets/css/admin.css' );
2358
+
2359
+ wp_enqueue_style( 'jquery-ui-style', plugins_url() . '/woocommerce-abandoned-cart/assets/css/jquery-ui-smoothness.css' );
2360
  wp_enqueue_style( 'abandoned-orders-list', plugins_url() . '/woocommerce-abandoned-cart/assets/css/view.abandoned.orders.style.css' );
2361
  wp_enqueue_style( 'wcal_email_template', plugins_url() . '/woocommerce-abandoned-cart/assets/css/wcal_template_activate.css' );
2362
 
2363
  }
2364
  }
2365
+
2366
 
2367
  /**
2368
  * When we have added the wp list table for the listing then while deleting the record with the bulk action it was showing
2387
  if ( is_user_logged_in() ) {
2388
  global $wpdb;
2389
  // Check the user capabilities
2390
+ if ( ! current_user_can( 'manage_woocommerce' ) ) {
2391
  wp_die( __( 'You do not have sufficient permissions to access this page.', 'woocommerce-abandoned-cart' ) );
2392
  }
2393
  ?>
2395
  <h2><?php _e( 'WooCommerce - Abandon Cart Lite', 'woocommerce-abandoned-cart' ); ?></h2>
2396
  <?php
2397
 
2398
+ if ( isset( $_GET['ac_update'] ) && 'email_templates' === $_GET['ac_update'] ) {
2399
  $status = wcal_common::update_templates_table();
2400
 
2401
  if ( $status !== false ) {
2402
  wcal_common::show_update_success();
2403
+ } else {
2404
  wcal_common::show_update_failure();
2405
  }
2406
  }
2407
+
2408
+ if ( isset( $_GET['action'] ) ) {
2409
+ $action = $_GET['action'];
2410
+ } else {
2411
+ $action = "";
2412
+ }
2413
+ if ( isset( $_GET['mode'] ) ) {
2414
+ $mode = $_GET['mode'];
2415
+ } else {
2416
+ $mode = "";
2417
+ }
2418
+ $this->wcal_display_tabs();
2419
 
2420
+ do_action ( 'wcal_add_tab_content' );
2421
+
2422
+ /**
2423
+ * When we delete the item from the below drop down it is registred in action 2
2424
+ */
2425
+ if ( isset( $_GET['action2'] ) ) {
2426
+ $action_two = $_GET['action2'];
2427
+ } else {
2428
+ $action_two = "";
2429
+ }
2430
+ // Detect when a bulk action is being triggered on abandoned orders page.
2431
+ if ( 'wcal_delete' === $action || 'wcal_delete' === $action_two ) {
2432
+ $ids = isset( $_GET['abandoned_order_id'] ) ? $_GET['abandoned_order_id'] : false;
2433
+ if ( ! is_array( $ids ) ) {
2434
+ $ids = array( $ids );
2435
+ }
2436
+ foreach ( $ids as $id ) {
2437
+ $class = new wcal_delete_bulk_action_handler();
2438
+ $class->wcal_delete_bulk_action_handler_function( $id );
2439
+ }
2440
+ }
2441
+ //Detect when a bulk action is being triggered on temnplates page.
2442
+ if ( 'wcal_delete_template' === $action || 'wcal_delete_template' === $action_two ) {
2443
+ $ids = isset( $_GET['template_id'] ) ? $_GET['template_id'] : false;
2444
+ if ( ! is_array( $ids ) ) {
2445
+ $ids = array( $ids );
2446
+ }
2447
+ foreach ( $ids as $id ) {
2448
+ $class = new wcal_delete_bulk_action_handler();
2449
+ $class->wcal_delete_template_bulk_action_handler_function( $id );
2450
+ }
2451
+ }
 
 
 
 
 
 
 
 
 
 
 
 
2452
 
2453
  if ( isset( $_GET['wcal_deleted'] ) && 'YES' == $_GET['wcal_deleted'] ) { ?>
2454
  <div id="message" class="updated fade">
2460
  <p><strong><?php _e( 'The Template has been successfully deleted.', 'woocommerce-abandoned-cart' ); ?></strong></p>
2461
  </div>
2462
  <?php }
2463
+ if ( 'emailsettings' == $action ) {
2464
  // Save the field values
2465
  ?>
2466
  <p><?php _e( 'Change settings for sending email notifications to Customers, to Admin etc.', 'woocommerce-abandoned-cart' ); ?></p>
2472
  } else {
2473
  $section = '';
2474
  }
2475
+ if ( 'wcal_general_settings' == $section || '' == $section ) {
2476
  $wcal_general_settings_class = "current";
2477
  }
2478
+ if ( 'wcal_email_settings' == $section ) {
2479
  $wcal_email_setting = "current";
2480
  }
 
2481
  ?>
2482
  <ul class="subsubsub" id="wcal_general_settings_list">
2483
  <li>
2490
  </ul>
2491
  <br class="clear">
2492
  <?php
2493
+ if ( 'wcal_general_settings' == $section || '' == $section ) {
2494
  ?>
2495
  <form method="post" action="options.php">
2496
  <?php settings_fields( 'woocommerce_ac_settings' ); ?>
2499
  <?php submit_button(); ?>
2500
  </form>
2501
  <?php
2502
+ } else if ( 'wcal_email_settings' == $section ) {
2503
  ?>
2504
  <form method="post" action="options.php">
2505
  <?php settings_fields ( 'woocommerce_ac_email_settings' ); ?>
2536
  } else {
2537
  $section = '';
2538
  }
2539
+ if ( 'wcal_all_abandoned' == $section || '' == $section ) {
2540
  $wcal_all_abandoned_carts = "current";
2541
  }
2542
 
2543
+ if ( 'wcal_all_registered' == $section ) {
2544
+ $wcal_all_registered = "current";
2545
  $wcal_all_abandoned_carts = "";
2546
  }
2547
+ if ( 'wcal_all_guest' == $section ) {
2548
+ $wcal_all_guest = "current";
2549
  $wcal_all_abandoned_carts = "";
2550
  }
2551
 
2552
+ if ( 'wcal_all_visitor' == $section ) {
2553
+ $wcal_all_visitor = "current";
2554
  $wcal_all_abandoned_carts = "";
2555
  }
2556
  ?>
2559
  <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-abandoned-cart' ) ;?> <span class = "count" > <?php echo "( $get_all_abandoned_count )" ?> </span></a>
2560
  </li>
2561
 
2562
+ <?php if ( $get_registered_user_ac_count > 0 ) { ?>
2563
  <li>
2564
  | <a href="admin.php?page=woocommerce_ac_page&action=listcart&wcal_section=wcal_all_registered" class="<?php echo $wcal_all_registered; ?>"><?php printf( __( 'Registered %s', 'woocommerce-abandoned-cart' ), $wcal_user_reg_text ); ?> <span class = "count" > <?php echo "( $get_registered_user_ac_count )" ?> </span></a>
2565
  </li>
2566
  <?php } ?>
2567
 
2568
+ <?php if ( $get_guest_user_ac_count > 0 ) { ?>
2569
  <li>
2570
  | <a href="admin.php?page=woocommerce_ac_page&action=listcart&wcal_section=wcal_all_guest" class="<?php echo $wcal_all_guest; ?>"><?php printf( __( 'Guest %s', 'woocommerce-abandoned-cart' ), $wcal_user_gus_text ); ?> <span class = "count" > <?php echo "( $get_guest_user_ac_count )" ?> </span></a>
2571
  </li>
2572
  <?php } ?>
2573
 
2574
+ <?php if ( $get_visitor_user_ac_count > 0 ) { ?>
2575
  <li>
2576
  | <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-abandoned-cart' ); ?> <span class = "count" > <?php echo "( $get_visitor_user_ac_count )" ?> </span></a>
2577
  </li>
2592
  </form>
2593
  </div>
2594
  <?php
2595
+ } elseif ( ( 'emailtemplates' == $action && ( 'edittemplate' != $mode && 'addnewtemplate' != $mode ) || '' == $action || '-1' == $action || '-1' == $action_two ) ) {
2596
+ ?>
2597
  <p> <?php _e( 'Add email templates at different intervals to maximize the possibility of recovering your abandoned carts.', 'woocommerce-abandoned-cart' );?> </p>
2598
  <?php
2599
  // Save the field values
2600
  $insert_template_successfuly = $update_template_successfuly = '';
2601
+ if ( isset( $_POST['ac_settings_frm'] ) && 'save' == $_POST['ac_settings_frm'] ) {
2602
+ $woocommerce_ac_email_subject = trim( htmlspecialchars( $_POST['woocommerce_ac_email_subject'] ), ENT_QUOTES );
2603
  $woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
2604
  $woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
2605
+ $woocommerce_ac_email_header = stripslashes( trim( htmlspecialchars( $_POST['wcal_wc_email_header'] ), ENT_QUOTES ) );
2606
+
2607
  $email_frequency = trim( $_POST['email_frequency'] );
2608
  $day_or_hour = trim( $_POST['day_or_hour'] );
2609
  $is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
2614
  VALUES ( %s, %s, %d, %s, %s, %s, %d, %s )";
2615
 
2616
  $insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query,
2617
+ $woocommerce_ac_email_subject,
2618
+ $woocommerce_ac_email_body,
2619
+ $email_frequency,
2620
+ $day_or_hour,
2621
+ $woocommerce_ac_template_name,
2622
+ $is_wc_template,
2623
+ $default_value,
2624
+ $woocommerce_ac_email_header )
2625
  );
2626
  }
2627
 
2628
+ if ( isset( $_POST['ac_settings_frm'] ) && 'update' == $_POST['ac_settings_frm'] ) {
2629
 
2630
  $updated_is_active = '0';
2631
 
2633
  $day_or_hour = trim( $_POST['day_or_hour'] );
2634
  $is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
2635
 
2636
+ $woocommerce_ac_email_subject = trim( htmlspecialchars( $_POST['woocommerce_ac_email_subject'] ), ENT_QUOTES );
2637
  $woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
2638
  $woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
2639
+ $woocommerce_ac_email_header = stripslashes( trim( htmlspecialchars( $_POST['wcal_wc_email_header'] ), ENT_QUOTES ) );
2640
  $id = trim( $_POST['id'] );
2641
 
2642
  $check_query = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite`
2676
 
2677
  }
2678
 
2679
+ if ( 'emailtemplates' == $action && 'removetemplate' == $mode ) {
2680
  $id_remove = $_GET['id'];
2681
  $query_remove = "DELETE FROM `".$wpdb->prefix."ac_email_templates_lite` WHERE id= %d ";
2682
  $wpdb->query( $wpdb->prepare( $query_remove, $id_remove ) );
2683
  }
2684
 
2685
+ if ( 'emailtemplates' == $action && 'activate_template' == $mode ) {
2686
  $template_id = $_GET['id'];
2687
  $current_template_status = $_GET['active_state'];
2688
 
2689
+ if ( "1" == $current_template_status ) {
2690
  $active = "0";
2691
  } else {
2692
  $active = "1";
2693
 
2694
+ $query_update = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite` WHERE id ='" . $template_id . "'";
2695
+ $get_selected_template_result = $wpdb->get_results( $query_update );
2696
  $email_frequncy = $get_selected_template_result[0]->frequency;
2697
  $email_day_or_hour = $get_selected_template_result[0]->day_or_hour;
2698
 
2707
 
2708
  wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&action=emailtemplates' ) );
2709
  }
2710
+
2711
+ if ( isset( $_POST['ac_settings_frm'] ) && 'save' == $_POST['ac_settings_frm'] && ( isset( $insert_template_successfuly ) && $insert_template_successfuly != '' ) ) { ?>
2712
  <div id="message" class="updated fade">
2713
  <p>
2714
  <strong>
2716
  </strong>
2717
  </p>
2718
  </div>
2719
+ <?php } else if ( isset( $_POST['ac_settings_frm'] ) && 'save' == $_POST['ac_settings_frm'] && ( isset( $insert_template_successfuly ) && '' == $insert_template_successfuly ) ) {
2720
  ?>
2721
  <div id="message" class="error fade">
2722
  <p>
2728
  <?php
2729
  }
2730
 
2731
+ if ( isset( $_POST['ac_settings_frm'] ) && 'update' == $_POST['ac_settings_frm'] && isset( $update_template_successfuly ) && $update_template_successfuly !== false ) { ?>
2732
  <div id="message" class="updated fade">
2733
  <p>
2734
  <strong>
2736
  </strong>
2737
  </p>
2738
  </div>
2739
+ <?php } else if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' && isset( $update_template_successfuly) && $update_template_successfuly === false ){
2740
  ?>
2741
  <div id="message" class="error fade">
2742
  <p>
2769
  </div>
2770
  </div>
2771
  <?php
2772
+ } elseif ( 'stats' == $action || '' == $action ) {
2773
  ?>
2774
  <p>
2775
  <script language='javascript'>
2820
  } else {
2821
  $duration_range = "";
2822
  }
2823
+ if ( '' == $duration_range ) {
2824
  if ( isset( $_GET['duration_select'] ) ){
2825
  $duration_range = $_GET['duration_select'];
2826
+ }
2827
  }
2828
+ if ( '' == $duration_range ) $duration_range = "last_seven";
2829
 
2830
  _e( 'The Report below shows how many Abandoned Carts we were able to recover for you by sending automatic emails to encourage shoppers.', 'woocommerce-abandoned-cart');
2831
  ?>
2836
  <?php
2837
  foreach ( $this->duration_range_select as $key => $value ) {
2838
  $sel = "";
2839
+ if ( $key == $duration_range ) {
2840
  $sel = " selected ";
2841
  }
2842
  echo"<option value='$key' $sel> $value </option>";
2921
  </form>
2922
  </div>
2923
  <?php
2924
+ } elseif ( 'orderdetails' == $action ) {
2925
  global $woocommerce;
2926
  $ac_order_id = $_GET['id'];
2927
  ?>
2947
  if ( $results[0]->user_type == "GUEST" && "0" != $results[0]->user_id ) {
2948
  $query_guest = "SELECT * FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d";
2949
  $results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $results[0]->user_id ) );
2950
+ $user_email = $user_first_name = $user_last_name = $user_billing_postcode = $user_shipping_postcode = '';
2951
+ $shipping_charges = '';
2952
  if ( count( $results_guest ) > 0 ) {
2953
  $user_email = $results_guest[0]->email_id;
2954
  $user_first_name = $results_guest[0]->billing_first_name;
2975
  $user_login = $results[0]->user_login;
2976
  }
2977
  $user_email = get_user_meta( $results[0]->user_id, 'billing_email', true );
2978
+ if ( '' == $user_email ) {
2979
  $user_data = get_userdata( $results[0]->user_id );
2980
  if ( isset( $user_data->user_email ) ) {
2981
+ $user_email = $user_data->user_email;
2982
  } else {
2983
  $user_email = '';
2984
  }
2985
  }
2986
 
2987
+ $user_first_name = "";
2988
+ $user_first_name_temp = get_user_meta( $user_id, 'billing_first_name', true );
2989
+ if ( isset( $user_first_name_temp ) && '' == $user_first_name_temp ) {
2990
+ $user_data = get_userdata( $user_id );
2991
  if ( isset( $user_data->first_name ) ) {
2992
+ $user_first_name = $user_data->first_name;
2993
  } else {
2994
  $user_first_name = '';
2995
  }
2998
  }
2999
  $user_last_name = "";
3000
  $user_last_name_temp = get_user_meta( $user_id, 'billing_last_name', true );
3001
+ if ( isset( $user_last_name_temp ) && "" == $user_last_name_temp ) {
3002
  $user_data = get_userdata( $user_id );
3003
  if ( isset( $user_data->last_name ) ) {
3004
  $user_last_name = $user_data->last_name;
3006
  $user_last_name = '';
3007
  }
3008
  } else {
3009
+ $user_last_name = $user_last_name_temp;
3010
  }
3011
  $user_billing_first_name = get_user_meta( $results[0]->user_id, 'billing_first_name' );
3012
  $user_billing_last_name = get_user_meta( $results[0]->user_id, 'billing_last_name' );
3013
 
3014
+ $user_billing_details = wcal_common::wcal_get_billing_details( $results[0]->user_id );
3015
 
3016
+ $user_billing_company = $user_billing_details[ 'billing_company' ];
3017
+ $user_billing_address_1 = $user_billing_details[ 'billing_address_1' ];
3018
+ $user_billing_address_2 = $user_billing_details[ 'billing_address_2' ];
3019
+ $user_billing_city = $user_billing_details[ 'billing_city' ];
3020
+ $user_billing_postcode = $user_billing_details[ 'billing_postcode' ] ;
3021
+ $user_billing_country = $user_billing_details[ 'billing_country' ];
3022
+ $user_billing_state = $user_billing_details[ 'billing_state' ];
3023
 
3024
  $user_billing_phone_temp = get_user_meta( $results[0]->user_id, 'billing_phone' );
3025
  if ( isset( $user_billing_phone_temp[0] ) ) {
3074
  if ( isset( $user_shipping_state_temp[0] ) ) {
3075
  $user_shipping_state = $user_shipping_state_temp[0];
3076
  if ( isset( $woocommerce->countries->states[ $user_shipping_country_temp[0] ][ $user_shipping_state ] ) ) {
3077
+ # code...
3078
  $user_shipping_state = $woocommerce->countries->states[ $user_shipping_country_temp[0] ][ $user_shipping_state ];
3079
  }
3080
  }
3091
  $item_details = wcal_common::wcal_get_cart_details( $v );
3092
 
3093
  $product_id = $v->product_id;
3094
+ $product = wc_get_product( $product_id );
3095
+ $prod_image = $product->get_image(array(200, 200));
3096
+ $product_page_url = get_permalink( $product_id );
3097
+ $product_name = $item_details[ 'product_name' ];
3098
+ $item_subtotal = $item_details[ 'item_total_formatted' ];
3099
+ $item_total = $item_details[ 'item_total' ];
3100
  $quantity_total = $item_details[ 'qty' ];
3101
 
3102
  $qty_item_text = 'item';
3103
  if ( $quantity_total > 1 ) {
3104
  $qty_item_text = 'items';
3105
  }
3106
+ ?>
3107
  <tr>
3108
  <td> <?php echo $prod_image; ?></td>
3109
+ <td> <?php echo '<a href="' . $product_page_url . '"> ' . $product_name . ' </a>'; ?> </td>
3110
  <td> <?php echo $quantity_total; ?></td>
3111
  <td> <?php echo $item_subtotal; ?></td>
3112
  <td> <?php echo $item_total; ?></td>
3168
  $user_shipping_country."</br>";
3169
  ?>
3170
  <br><br>
3171
+ <strong><?php _e( 'Shipping Charges', 'woocommerce-abandoned-lite' ); ?>: </strong>
3172
  <?php if ( $shipping_charges != 0 ) echo $currency_symbol . $shipping_charges;?>
3173
  </p>
3174
  <?php }?>
3193
  echo( "</table>" );
3194
 
3195
  if ( isset( $_GET['action'] ) ) {
3196
+ $action = $_GET['action'];
3197
  }
3198
+ if ( isset( $_GET['mode'] ) ) {
3199
+ $mode = $_GET['mode'];
3200
  }
3201
+ if ( 'emailtemplates' == $action && ( 'addnewtemplate' == $mode || 'edittemplate' == $mode ) ) {
3202
+ if ( 'edittemplate' == $mode ) {
3203
  $results = array();
3204
  if ( isset( $_GET['id'] ) ) {
3205
  $edit_id = $_GET['id'];
 
3206
  $query = "SELECT wpet . * FROM `".$wpdb->prefix."ac_email_templates_lite` AS wpet WHERE id = %d ";
3207
  $results = $wpdb->get_results( $wpdb->prepare( $query, $edit_id ) );
3208
  }
3222
  <?php
3223
  $button_mode = "save";
3224
  $display_message = "Add Email Template";
3225
+ if ( 'edittemplate' == $mode ) {
3226
  $button_mode = "update";
3227
  $display_message = "Edit Email Template";
3228
  }
3239
  <td>
3240
  <?php
3241
  $template_name = "";
3242
+ if ( 'edittemplate' == $mode && count( $results ) > 0 && isset( $results[0]->template_name ) ) {
3243
  $template_name = $results[0]->template_name;
3244
  }
3245
  print'<input type="text" name="woocommerce_ac_template_name" id="woocommerce_ac_template_name" class="regular-text" value="'.$template_name.'">';?>
3254
  <td>
3255
  <?php
3256
  $subject_edit = "";
3257
+ if ( 'edittemplate' == $mode && count( $results ) > 0 && isset( $results[0]->subject ) ) {
3258
  $subject_edit= stripslashes ( $results[0]->subject );
3259
  }
3260
  print'<input type="text" name="woocommerce_ac_email_subject" id="woocommerce_ac_email_subject" class="regular-text" value="'.$subject_edit.'">';?>
3269
  <td>
3270
  <?php
3271
  $initial_data = "";
3272
+ if ( 'edittemplate' == $mode && count( $results ) > 0 && isset( $results[0]->body ) ) {
3273
  $initial_data = stripslashes( $results[0]->body );
3274
  }
3275
 
3276
  $initial_data = str_replace ( "My document title", "", $initial_data );
3277
  wp_editor(
3278
  $initial_data,
3279
+ 'woocommerce_ac_email_body',
3280
+ array(
3281
  'media_buttons' => true,
3282
  'textarea_rows' => 15,
3283
+ 'tabindex' => 4,
3284
+ 'tinymce' => array(
3285
+ 'theme_advanced_buttons1' => 'bold,italic,underline,|,bullist,numlist,blockquote,|,link,unlink,|,spellchecker,fullscreen,|,formatselect,styleselect'
3286
  ),
3287
  )
3288
  );
3307
  </tr>
3308
  <script type="text/javascript">
3309
  function wcal_show_help_tips() {
3310
+ if ( jQuery( '#help_message' ) . css( 'display' ) == 'none') {
3311
  document.getElementById( "help_message" ).style.display = "block";
3312
  }
3313
  else {
3323
  <td>
3324
  <?php
3325
  $is_wc_template = "";
3326
+ if ( 'edittemplate' == $mode && count( $results ) > 0 && isset( $results[0]->is_wc_template ) ) {
3327
  $use_wc_template = $results[0]->is_wc_template;
3328
 
3329
+ if ( '1' == $use_wc_template ) {
3330
  $is_wc_template = "checked";
3331
  } else {
3332
  $is_wc_template = "";
3347
  <?php
3348
 
3349
  $wcal_wc_email_header = "";
3350
+ if ( 'edittemplate' == $mode && count( $results ) > 0 && isset( $results[0]->wc_email_header ) ) {
3351
  $wcal_wc_email_header = $results[0]->wc_email_header;
3352
  }
3353
+ if ( '' == $wcal_wc_email_header ) {
3354
  $wcal_wc_email_header = "Abandoned cart reminder";
3355
  }
3356
  print'<input type="text" name="wcal_wc_email_header" id="wcal_wc_email_header" class="regular-text" value="' . $wcal_wc_email_header . '">'; ?>
3366
  <select name="email_frequency" id="email_frequency">
3367
  <?php
3368
  $frequency_edit = "";
3369
+ if ( 'edittemplate' == $mode && count( $results ) > 0 && isset( $results[0]->frequency ) ) {
3370
  $frequency_edit = $results[0]->frequency;
3371
  }
3372
  for ( $i = 1; $i < 4; $i++ ) {
3382
  <select name="day_or_hour" id="day_or_hour">
3383
  <?php
3384
  $days_or_hours_edit = "";
3385
+ if ( 'edittemplate' == $mode && count( $results ) > 0 && isset( $results[0]->day_or_hour ) )
3386
  {
3387
  $days_or_hours_edit = $results[0]->day_or_hour;
3388
  }
3389
  $days_or_hours = array(
3390
  'Days' => 'Day(s)',
3391
+ 'Hours' => 'Hour(s)'
3392
+ );
3393
  foreach( $days_or_hours as $k => $v )
3394
  {
3395
  printf( "<option %s value='%s'>%s</option>\n",
3424
  <p class="submit">
3425
  <?php
3426
  $button_value = "Save Changes";
3427
+ if ( 'edittemplate' == $mode ) {
 
3428
  $button_value = "Update Changes";
3429
+ }
3430
+ ?>
3431
  <input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e( $button_value, 'woocommerce-abandoned-cart' ); ?>" />
3432
  </p>
3433
  </form>
3468
  $temp = array();
3469
  foreach ( $unsort_array as $key => $value )
3470
  $temp[ $key ] = $value; //concatenate something unique to make sure two equal weights don't overwrite each other
3471
+ asort( $temp, SORT_NUMERIC ); // or ksort( $temp, SORT_NATURAL ); see paragraph above to understand why
3472
 
3473
+ if ( 'desc' == $order ) {
3474
  $array = array_reverse( $temp, true );
3475
+ } else if ( $order == 'asc' ) {
3476
  $array = $temp;
3477
  }
3478
  unset( $temp );
3509
  is_wc_template : is_wc_template,
3510
  wc_template_header : wc_template_header,
3511
  action : 'wcal_preview_email_sent'
3512
+ };
3513
+
3514
  // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
3515
  $.post( ajaxurl, data, function( response ) {
3516
  if ( 'not sent' == response ) {
3541
  $template_id = $_POST['wcal_template_id'];
3542
  $current_template_status = $_POST['current_state'];
3543
 
3544
+ if ( "on" == $current_template_status ) {
3545
  $query_update = "SELECT * FROM `" . $wpdb->prefix . "ac_email_templates_lite` WHERE id ='" . $template_id . "'";
3546
  $get_selected_template_result = $wpdb->get_results( $query_update );
3547
+ $email_frequncy = $get_selected_template_result[0]->frequency;
3548
+ $email_day_or_hour = $get_selected_template_result[0]->day_or_hour;
3549
+ $query_update = "UPDATE `" . $wpdb->prefix . "ac_email_templates_lite` SET is_active='0' WHERE frequency='" . $email_frequncy . "' AND day_or_hour='" . $email_day_or_hour . "' ";
3550
+ $wcal_updated = $wpdb->query( $query_update );
3551
 
3552
  if ( 1 == $wcal_updated ){
3553
  $query_update_get_id = "SELECT id FROM `" . $wpdb->prefix . "ac_email_templates_lite` WHERE id != $template_id AND frequency='" . $email_frequncy . "' AND day_or_hour='" . $email_day_or_hour . "' ";
3554
  $wcal_updated_get_id = $wpdb->get_results( $query_update_get_id );
3555
  $wcal_all_ids = '';
3556
+ foreach ( $wcal_updated_get_id as $wcal_updated_get_id_key => $wcal_updated_get_id_value ) {
3557
  # code...
3558
  if ( '' == $wcal_all_ids ){
3559
  $wcal_all_ids = $wcal_updated_get_id_value->id;
3560
+ } else {
3561
+ $wcal_all_ids = $wcal_all_ids . ',' . $wcal_updated_get_id_value->id;
3562
  }
3563
  }
3564
  echo 'wcal-template-updated:'. $wcal_all_ids ;
3587
  $reply_name_preview = get_option ( 'wcal_from_email' );
3588
  $from_email_preview = get_option ( 'wcal_reply_email' );
3589
  $subject_email_preview = stripslashes ( $_POST['subject_email_preview'] );
3590
+ $subject_email_preview = convert_smilies ( $subject_email_preview );
3591
+ $subject_email_preview = str_replace( '{{customer.firstname}}', 'John', $subject_email_preview );
3592
  $body_email_preview = convert_smilies ( $_POST['body_email_preview'] );
3593
  $is_wc_template = $_POST['is_wc_template'];
3594
+ $wc_template_header = stripslashes( $_POST['wc_template_header'] );
3595
+
3596
+ $body_email_preview = str_replace( '{{customer.firstname}}', 'John', $body_email_preview );
3597
  $body_email_preview = str_replace( '{{customer.firstname}}', 'John', $body_email_preview );
3598
  $body_email_preview = str_replace( '{{customer.lastname}}', 'Doe', $body_email_preview );
3599
  $body_email_preview = str_replace( '{{customer.fullname}}', 'John'." ".'Doe', $body_email_preview );
3684
  } else {
3685
  $to_email_preview = "";
3686
  }
3687
+ $user_email_from = get_option( 'admin_email' );
3688
  $body_email_final_preview = stripslashes( $body_email_preview );
3689
 
3690
+ if ( isset( $is_wc_template ) && 'true' == $is_wc_template ) {
3691
  ob_start();
3692
  // Get email heading
3693
  wc_get_template( 'emails/email-header.php', array( 'email_heading' => $wc_template_header ) );
3697
  wc_get_template( 'emails/email-footer.php' );
3698
  $email_body_template_footer = ob_get_clean();
3699
 
3700
+ $final_email_body = $email_body_template_header . $body_email_final_preview . $email_body_template_footer;
3701
 
3702
+ $site_title = get_bloginfo( 'name' );
3703
+ $email_body_template_footer = str_replace( '{site_title}', $site_title, $email_body_template_footer );
3704
 
3705
  wc_mail( $to_email_preview, $subject_email_preview, $final_email_body , $headers );
3706
  }