Version Description
(13.10-2017) =
This version has 3 bugs fixes along with 1 Enhancement.
Bug Fixed - If the guest user's id is wrong then the abandoned cart email will not be sent to the customers.
Bug Fixed - If the variable products have a special character was not displaying the correct attributes. This has been fixed.
Bug Fixed - Some error notices of debug log file are fixed.
Enhancement - Now, admin can activate the email templates using toggle button from the Email Templates page.
Download this release
Release Info
| Developer | bhavik.kiri |
| Plugin | |
| Version | 4.4 |
| Comparing to | |
| See all releases | |
Code changes from version 4.3 to 4.4
- assets/css/wcal_template_activate.css +47 -0
- assets/js/wcal_template_activate.js +40 -0
- cron/wcal_send_email.php +223 -193
- includes/classes/class-wcal-abandoned-orders-table.php +1 -1
- includes/classes/class-wcal-templates-table.php +7 -3
- includes/wcal-common.php +1 -1
- includes/wcal_actions.php +0 -1
- includes/wcal_admin_notice.php +4 -4
- includes/wcal_class-guest.php +6 -6
- readme.txt +25 -1
- views/wcal-email-template-preview.php +8 -6
- views/wcal-wc-email-template-preview.php +8 -6
- woocommerce-ac.php +472 -532
assets/css/wcal_template_activate.css
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* To display the toggle button on the template page*/
|
| 2 |
+
|
| 3 |
+
.wcal-switch {
|
| 4 |
+
cursor: pointer;
|
| 5 |
+
text-indent: -999em;
|
| 6 |
+
display: block;
|
| 7 |
+
width: 38px;
|
| 8 |
+
height: 22px;
|
| 9 |
+
border-radius: 30px;
|
| 10 |
+
border: none;
|
| 11 |
+
position: relative;
|
| 12 |
+
box-sizing: border-box;
|
| 13 |
+
-webkit-transition: all .3s ease;
|
| 14 |
+
transition: all .3s ease;
|
| 15 |
+
box-shadow: inset 0 0 0 0 transparent;
|
| 16 |
+
}
|
| 17 |
+
.wcal-switch:focus {
|
| 18 |
+
outline: none;
|
| 19 |
+
}
|
| 20 |
+
.wcal-switch:before {
|
| 21 |
+
border-radius: 50%;
|
| 22 |
+
background: #ffffff;
|
| 23 |
+
content: '';
|
| 24 |
+
position: absolute;
|
| 25 |
+
display: block;
|
| 26 |
+
width: 18px;
|
| 27 |
+
height: 18px;
|
| 28 |
+
top: 2px;
|
| 29 |
+
left: 2px;
|
| 30 |
+
-webkit-transition: all .15s ease;
|
| 31 |
+
transition: all .15s ease;
|
| 32 |
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
|
| 33 |
+
}
|
| 34 |
+
.wcal-switch[wcal-template-switch="on"] {
|
| 35 |
+
box-shadow: inset 0 0 0 11px #008000;
|
| 36 |
+
}
|
| 37 |
+
.wcal-switch[wcal-template-switch="on"]:before {
|
| 38 |
+
-webkit-transform: translateX(16px);
|
| 39 |
+
transform: translateX(16px);
|
| 40 |
+
}
|
| 41 |
+
.wcal-switch[wcal-template-switch="off"] {
|
| 42 |
+
background: #ccc;
|
| 43 |
+
}
|
| 44 |
+
.wcal-switch.wcap-loading {
|
| 45 |
+
cursor: default;
|
| 46 |
+
opacity: 0.5;
|
| 47 |
+
}
|
assets/js/wcal_template_activate.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
jQuery(function( $ ) {
|
| 2 |
+
|
| 3 |
+
$('.wcal-switch.wcal-toggle-template-status').click(function(){
|
| 4 |
+
|
| 5 |
+
var $switch, state, new_state;
|
| 6 |
+
|
| 7 |
+
$switch = $(this);
|
| 8 |
+
|
| 9 |
+
if ( $switch.is('.wcal-loading') )
|
| 10 |
+
return;
|
| 11 |
+
|
| 12 |
+
state = $switch.attr( 'wcal-template-switch' );
|
| 13 |
+
new_state = state === 'on' ? 'off' : 'on';
|
| 14 |
+
|
| 15 |
+
$switch.addClass('wcal-loading');
|
| 16 |
+
$switch.attr( 'wcal-template-switch', new_state );
|
| 17 |
+
|
| 18 |
+
$.post( ajaxurl, {
|
| 19 |
+
action : 'wcal_toggle_template_status',
|
| 20 |
+
wcal_template_id: $switch.attr( 'wcal-template-id' ),
|
| 21 |
+
current_state : new_state
|
| 22 |
+
}, function( wcal_template_response ) {
|
| 23 |
+
if ( wcal_template_response.indexOf('wcal-template-updated') > -1){
|
| 24 |
+
var wcal_template_response_array = wcal_template_response.split ( ':' );
|
| 25 |
+
|
| 26 |
+
var wcal_deactivate_ids = wcal_template_response_array[1];
|
| 27 |
+
var wcal_split_all_ids = wcal_deactivate_ids.split ( ',' );
|
| 28 |
+
|
| 29 |
+
for (i = 0; i < wcal_split_all_ids.length; i++) {
|
| 30 |
+
var selelcted_id = wcal_split_all_ids[i];
|
| 31 |
+
|
| 32 |
+
var $list = document.querySelector('[wcal-template-id="'+ selelcted_id+'"]');
|
| 33 |
+
$($list).attr('wcal-template-switch','off');
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
}
|
| 37 |
+
$switch.removeClass('wcal-loading');
|
| 38 |
+
});
|
| 39 |
+
});
|
| 40 |
+
});
|
cron/wcal_send_email.php
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
<?php
|
| 2 |
-
|
| 3 |
static $wp_load; // Since this will be called twice, hold onto it.
|
| 4 |
if ( ! isset( $wp_load ) ) {
|
| 5 |
$wp_load = false;
|
|
@@ -69,40 +68,48 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
|
|
| 69 |
$wc_template_header = stripslashes( $wc_template_header_text );
|
| 70 |
if ( '' != $email_body_template ) {
|
| 71 |
foreach ( $carts as $key => $value ) {
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
}
|
| 82 |
-
$
|
| 83 |
-
|
| 84 |
-
$user_biiling_email = get_user_meta( $user_id, $key, $single );
|
| 85 |
-
if ( isset( $user_biiling_email ) && $user_biiling_email != '' ) {
|
| 86 |
-
$value->user_email = $user_biiling_email;
|
| 87 |
}
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
if( count( $cart_info_db_field->cart ) > 0 && isset( $value->user_id ) && $value->user_id != '0') {
|
| 97 |
-
$cart_update_time = $value->abandoned_cart_time;
|
| 98 |
-
$new_user = $this->wcal_check_sent_history( $value->user_id, $cart_update_time, $template_id, $value->id );
|
| 99 |
-
if ( $new_user == true ) {
|
| 100 |
|
| 101 |
/**
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
|
|
|
|
|
|
| 106 |
|
| 107 |
$wcal_check_cart_needed_for_multiple_template = $this->wcal_remove_cart_for_mutiple_templates( $value->id, $time_to_send_template_after, $template_id );
|
| 108 |
|
|
@@ -164,7 +171,11 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
|
|
| 164 |
$user_first_name_temp = get_user_meta( $value->user_id, 'billing_first_name', true );
|
| 165 |
if( isset( $user_first_name_temp ) && "" == $user_first_name_temp ) {
|
| 166 |
$user_data = get_userdata( $user_id );
|
| 167 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
} else {
|
| 169 |
$user_first_name = $user_first_name_temp;
|
| 170 |
}
|
|
@@ -174,7 +185,11 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
|
|
| 174 |
$user_last_name_temp = get_user_meta( $value->user_id, 'billing_last_name', true );
|
| 175 |
if( isset( $user_last_name_temp ) && "" == $user_last_name_temp ) {
|
| 176 |
$user_data = get_userdata( $user_id );
|
| 177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
} else {
|
| 179 |
$user_last_name = $user_last_name_temp;
|
| 180 |
}
|
|
@@ -183,8 +198,8 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
|
|
| 183 |
}
|
| 184 |
$order_date = "";
|
| 185 |
if( $cart_update_time != "" && $cart_update_time != 0 ) {
|
| 186 |
-
|
| 187 |
-
|
| 188 |
$order_date = $date_format . ' ' . $time_format;
|
| 189 |
}
|
| 190 |
$email_body = str_replace( "{{cart.abandoned_date}}", $order_date, $email_body );
|
|
@@ -197,165 +212,164 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
|
|
| 197 |
WHERE template_id = %s AND abandoned_order_id = %s
|
| 198 |
ORDER BY id DESC
|
| 199 |
LIMIT 1 ";
|
| 200 |
-
$results_sent = $wpdb->get_results( $wpdb->prepare( $query_id, $template_id, $value->id ) );
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
if( $woocommerce->version < '2.3' ) {
|
| 204 |
-
$cart_page_link = $woocommerce->cart->get_cart_url();
|
| 205 |
} else {
|
| 206 |
-
$
|
| 207 |
-
$cart_page_link = $cart_page_id ? get_permalink( $cart_page_id ) : '';
|
| 208 |
}
|
|
|
|
|
|
|
| 209 |
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
$cart_link_track = get_option('siteurl').'/?wcal_action=track_links&validate=' . $validate_cart;
|
| 213 |
-
$email_body = str_replace( "{{cart.link}}", $cart_link_track, $email_body );
|
| 214 |
-
|
| 215 |
-
$validate_unsubscribe = $this->wcal_encrypt_validate( $email_sent_id );
|
| 216 |
-
$email_sent_id_address = $results_sent[0]->sent_email_id;
|
| 217 |
-
$encrypt_email_sent_id_address = hash( 'sha256', $email_sent_id_address );
|
| 218 |
-
$plugins_url = get_option( 'siteurl' ) . "/?wcal_track_unsubscribe=wcal_unsubscribe&validate=" . $validate_unsubscribe . "&track_email_id=" . $encrypt_email_sent_id_address;
|
| 219 |
-
$unsubscribe_link_track = $plugins_url;
|
| 220 |
-
$email_body = str_replace( "{{cart.unsubscribe}}" , $unsubscribe_link_track , $email_body );
|
| 221 |
-
$var = '';
|
| 222 |
-
if( preg_match( "{{products.cart}}", $email_body, $matched ) ) {
|
| 223 |
-
if ( class_exists( 'WP_Better_Emails' ) ) {
|
| 224 |
-
$var = '<table width = 100%>
|
| 225 |
-
<tr> <td colspan="5"> <h3>'.__( "Your Shopping Cart", "woocommerce-ac" ).'</h3> </td></tr>
|
| 226 |
-
<tr>
|
| 227 |
-
<th>'.__( "Item", "woocommerce-ac" ).'</th>
|
| 228 |
-
<th>'.__( "Name", "woocommerce-ac" ).'</th>
|
| 229 |
-
<th>'.__( "Quantity", "woocommerce-ac" ).'</th>
|
| 230 |
-
<th>'.__( "Price", "woocommerce-ac" ).'</th>
|
| 231 |
-
<th>'.__( "Line Subtotal", "woocommerce-ac" ).'</th>
|
| 232 |
-
</tr>';
|
| 233 |
} else {
|
| 234 |
-
$
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
$
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
if(
|
| 254 |
-
$
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
} else {
|
| 260 |
-
$
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
$
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
}
|
| 292 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
}
|
| 294 |
-
$
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
$product_name_with_variable = $product_name_with_variable . "<br>". html_entity_decode ( $explode_many_varaition_value );
|
| 306 |
}
|
| 307 |
-
|
| 308 |
-
$product_name_with_variable = $product_name_with_variable . "<br>". html_entity_decode ( $explode_many_varaition_value );
|
| 309 |
}
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
</tr>';
|
| 320 |
-
|
| 321 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
}
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
<td> </td>
|
| 326 |
-
<td> </td>
|
| 327 |
-
<td> </td>
|
| 328 |
-
<td>'.__( "Cart Total:", "woocommerce-ac" ).'</td>
|
| 329 |
-
<td> '.$cart_total.'</td>
|
| 330 |
-
</tr>';
|
| 331 |
-
$var .= '</table>
|
| 332 |
-
';
|
| 333 |
-
$email_body = str_replace( "{{products.cart}}", $var, $email_body );
|
| 334 |
-
$email_subject = str_replace( "{{product.name}}", __( $sub_line_prod_name, "woocommerce-ac" ), $email_subject );
|
| 335 |
-
}
|
| 336 |
-
|
| 337 |
-
$user_email = $value->user_email;
|
| 338 |
-
$email_body_final = stripslashes( $email_body );
|
| 339 |
-
$email_body_final = convert_smilies( $email_body_final );
|
| 340 |
-
if ( isset( $is_wc_template ) && "1" == $is_wc_template ){
|
| 341 |
-
ob_start();
|
| 342 |
-
|
| 343 |
-
wc_get_template( 'emails/email-header.php', array( 'email_heading' => $wc_template_header ) );
|
| 344 |
-
$email_body_template_header = ob_get_clean();
|
| 345 |
-
|
| 346 |
-
ob_start();
|
| 347 |
-
|
| 348 |
-
wc_get_template( 'emails/email-footer.php' );
|
| 349 |
-
$email_body_template_footer = ob_get_clean();
|
| 350 |
-
|
| 351 |
-
$final_email_body = $email_body_template_header . $email_body_final . $email_body_template_footer;
|
| 352 |
-
|
| 353 |
-
wc_mail( $user_email, $email_subject, $final_email_body, $headers );
|
| 354 |
-
|
| 355 |
-
} else {
|
| 356 |
-
wp_mail( $user_email, $email_subject, __( $email_body_final, 'woocommerce-ac' ), $headers );
|
| 357 |
-
}
|
| 358 |
-
}
|
| 359 |
}
|
| 360 |
}
|
| 361 |
}
|
|
@@ -363,9 +377,28 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
|
|
| 363 |
}
|
| 364 |
}
|
| 365 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 366 |
function wcal_check_cart_total ( $cart ){
|
| 367 |
foreach( $cart as $k => $v ) {
|
| 368 |
-
//wc_mail("chetna@tychesoftwares.com", "line total", print_r($cart,true));
|
| 369 |
if( $v->line_total != 0 && $v->line_total > 0 ) {
|
| 370 |
return true;
|
| 371 |
}
|
|
@@ -479,22 +512,22 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
|
|
| 479 |
|
| 480 |
$results_query_email = $wpdb->get_results( $wpdb->prepare( $query_email_id, $user_billing_email ) );
|
| 481 |
|
| 482 |
-
if ( count ( $results_query_email ) > 0 ){
|
| 483 |
$current_time = current_time( 'timestamp' );
|
| 484 |
$todays_date = date( 'Y-m-d', $current_time );
|
| 485 |
-
$order_date_time
|
| 486 |
-
$order_date
|
| 487 |
|
| 488 |
if ( $order_date == $todays_date ){
|
| 489 |
|
| 490 |
$wcal_check_email_sent_to_cart = woocommerce_abandon_cart_cron::wcal_get_cart_sent_data ( $cart_id );
|
| 491 |
|
| 492 |
-
if ( 0 != $wcal_check_email_sent_to_cart ){
|
| 493 |
|
| 494 |
$wcal_query = "SELECT `post_id` FROM `" . $wpdb->prefix . "postmeta` WHERE meta_value = %s";
|
| 495 |
$wcal_results = $wpdb->get_results ( $wpdb->prepare( $wcal_query , $cart_id ) );
|
| 496 |
|
| 497 |
-
if ( count( $wcal_results ) > 0 ){
|
| 498 |
|
| 499 |
$order_id = $wcal_results[0]->post_id;
|
| 500 |
|
|
@@ -503,14 +536,12 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
|
|
| 503 |
$query_order = "UPDATE `" . $wpdb->prefix."ac_abandoned_cart_history_lite` SET recovered_cart= '" . $order_id . "', cart_ignored = '1' WHERE id = '".$cart_id."' ";
|
| 504 |
$wpdb->query( $query_order );
|
| 505 |
|
| 506 |
-
|
| 507 |
-
|
| 508 |
$order->add_order_note( __( 'This order was abandoned & subsequently recovered.', 'woocommerce-ac' ) );
|
| 509 |
|
| 510 |
delete_post_meta( $order_id, 'wcap_recover_order_placed', $cart_id );
|
| 511 |
delete_post_meta( $order_id , 'wcap_recover_order_placed_sent_id', $wcal_check_email_sent_to_cart );
|
| 512 |
}
|
| 513 |
-
}else{
|
| 514 |
|
| 515 |
$query_ignored = "UPDATE `" . $wpdb->prefix."ac_abandoned_cart_history_lite` SET cart_ignored = '1' WHERE id ='" . $cart_id . "'";
|
| 516 |
$wpdb->query( $query_ignored );
|
|
@@ -540,7 +571,6 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
|
|
| 540 |
return 0;
|
| 541 |
}
|
| 542 |
|
| 543 |
-
|
| 544 |
public static function wcal_remove_cart_for_mutiple_templates( $wcal_cart_id, $time_to_send_template_after, $template_id ) {
|
| 545 |
global $wpdb;
|
| 546 |
|
| 1 |
<?php
|
|
|
|
| 2 |
static $wp_load; // Since this will be called twice, hold onto it.
|
| 3 |
if ( ! isset( $wp_load ) ) {
|
| 4 |
$wp_load = false;
|
| 68 |
$wc_template_header = stripslashes( $wc_template_header_text );
|
| 69 |
if ( '' != $email_body_template ) {
|
| 70 |
foreach ( $carts as $key => $value ) {
|
| 71 |
+
|
| 72 |
+
$wcal_is_guest_id_correct = $this->wcal_get_is_guest_valid ( $value->user_id, $value->user_type ) ;
|
| 73 |
+
if ( true === $wcal_is_guest_id_correct ) {
|
| 74 |
+
|
| 75 |
+
if ( $value->user_type == "GUEST" && $value->user_id != '0' ) {
|
| 76 |
+
$value->user_login = "";
|
| 77 |
+
$query_guest = "SELECT billing_first_name, billing_last_name, email_id FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite`
|
| 78 |
+
WHERE id = %d";
|
| 79 |
+
$results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $value->user_id ) );
|
| 80 |
+
if ( count( $results_guest ) > 0 && isset( $results_guest[0]->email_id ) ) {
|
| 81 |
+
$value->user_email = $results_guest[0]->email_id;
|
| 82 |
+
}
|
| 83 |
+
} else {
|
| 84 |
+
if( isset( $value->user_id ) ) {
|
| 85 |
+
$user_id = $value->user_id;
|
| 86 |
+
}
|
| 87 |
+
$key = 'billing_email';
|
| 88 |
+
$single = true;
|
| 89 |
+
$user_biiling_email = get_user_meta( $user_id, $key, $single );
|
| 90 |
+
if ( isset( $user_biiling_email ) && $user_biiling_email != '' ) {
|
| 91 |
+
$value->user_email = $user_biiling_email;
|
| 92 |
+
}
|
| 93 |
}
|
| 94 |
+
if( isset( $value->abandoned_cart_info ) ) {
|
| 95 |
+
$cart_info_db_field = json_decode( $value->abandoned_cart_info );
|
|
|
|
|
|
|
|
|
|
| 96 |
}
|
| 97 |
+
$cart = array();
|
| 98 |
+
if( !empty( $cart_info_db_field ) ) {
|
| 99 |
+
$cart = $cart_info_db_field->cart;
|
| 100 |
+
}
|
| 101 |
+
if( count( $cart_info_db_field->cart ) > 0 && isset( $value->user_id ) && $value->user_id != '0') {
|
| 102 |
+
$cart_update_time = $value->abandoned_cart_time;
|
| 103 |
+
$new_user = $this->wcal_check_sent_history( $value->user_id, $cart_update_time, $template_id, $value->id );
|
| 104 |
+
if ( $new_user == true ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
/**
|
| 107 |
+
* When there are 3 templates and for cart id 1 all template time has been reached. BUt all templates
|
| 108 |
+
* are deactivated.
|
| 109 |
+
* If we activate all 3 template then at a 1 time all 3 email templates send to the users.
|
| 110 |
+
* So below function check that after first email is sent time and then from that time it will send the
|
| 111 |
+
* 2nd template time. ( It will not consider the cart abadoned time in this case. )
|
| 112 |
+
*/
|
| 113 |
|
| 114 |
$wcal_check_cart_needed_for_multiple_template = $this->wcal_remove_cart_for_mutiple_templates( $value->id, $time_to_send_template_after, $template_id );
|
| 115 |
|
| 171 |
$user_first_name_temp = get_user_meta( $value->user_id, 'billing_first_name', true );
|
| 172 |
if( isset( $user_first_name_temp ) && "" == $user_first_name_temp ) {
|
| 173 |
$user_data = get_userdata( $user_id );
|
| 174 |
+
if ( isset( $user_data->first_name ) ) {
|
| 175 |
+
$user_first_name = $user_data->first_name;
|
| 176 |
+
} else {
|
| 177 |
+
$user_first_name = '';
|
| 178 |
+
}
|
| 179 |
} else {
|
| 180 |
$user_first_name = $user_first_name_temp;
|
| 181 |
}
|
| 185 |
$user_last_name_temp = get_user_meta( $value->user_id, 'billing_last_name', true );
|
| 186 |
if( isset( $user_last_name_temp ) && "" == $user_last_name_temp ) {
|
| 187 |
$user_data = get_userdata( $user_id );
|
| 188 |
+
if ( isset( $user_data->last_name) ) {
|
| 189 |
+
$user_last_name = $user_data->last_name;
|
| 190 |
+
} else {
|
| 191 |
+
$user_last_name = '';
|
| 192 |
+
}
|
| 193 |
} else {
|
| 194 |
$user_last_name = $user_last_name_temp;
|
| 195 |
}
|
| 198 |
}
|
| 199 |
$order_date = "";
|
| 200 |
if( $cart_update_time != "" && $cart_update_time != 0 ) {
|
| 201 |
+
$date_format = date_i18n( get_option( 'date_format' ), $cart_update_time );
|
| 202 |
+
$time_format = date_i18n( get_option( 'time_format' ), $cart_update_time );
|
| 203 |
$order_date = $date_format . ' ' . $time_format;
|
| 204 |
}
|
| 205 |
$email_body = str_replace( "{{cart.abandoned_date}}", $order_date, $email_body );
|
| 212 |
WHERE template_id = %s AND abandoned_order_id = %s
|
| 213 |
ORDER BY id DESC
|
| 214 |
LIMIT 1 ";
|
| 215 |
+
$results_sent = $wpdb->get_results( $wpdb->prepare( $query_id, $template_id, $value->id ) );
|
| 216 |
+
if ( count( $results_sent ) > 0 ) {
|
| 217 |
+
$email_sent_id = $results_sent[0]->id;
|
|
|
|
|
|
|
| 218 |
} else {
|
| 219 |
+
$email_sent_id = '';
|
|
|
|
| 220 |
}
|
| 221 |
+
|
| 222 |
+
if ( '' != $email_sent_id ) {
|
| 223 |
|
| 224 |
+
if( $woocommerce->version < '2.3' ) {
|
| 225 |
+
$cart_page_link = $woocommerce->cart->get_cart_url();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
} else {
|
| 227 |
+
$cart_page_id = wc_get_page_id( 'cart' );
|
| 228 |
+
$cart_page_link = $cart_page_id ? get_permalink( $cart_page_id ) : '';
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
$encoding_cart = $email_sent_id.'&url='.$cart_page_link;
|
| 232 |
+
$validate_cart = $this->wcal_encrypt_validate( $encoding_cart );
|
| 233 |
+
$cart_link_track = get_option('siteurl').'/?wcal_action=track_links&validate=' . $validate_cart;
|
| 234 |
+
$email_body = str_replace( "{{cart.link}}", $cart_link_track, $email_body );
|
| 235 |
+
|
| 236 |
+
$validate_unsubscribe = $this->wcal_encrypt_validate( $email_sent_id );
|
| 237 |
+
if ( count( $results_sent ) > 0 && isset( $results_sent[0]->sent_email_id ) ) {
|
| 238 |
+
$email_sent_id_address = $results_sent[0]->sent_email_id;
|
| 239 |
+
}
|
| 240 |
+
$encrypt_email_sent_id_address = hash( 'sha256', $email_sent_id_address );
|
| 241 |
+
$plugins_url = get_option( 'siteurl' ) . "/?wcal_track_unsubscribe=wcal_unsubscribe&validate=" . $validate_unsubscribe . "&track_email_id=" . $encrypt_email_sent_id_address;
|
| 242 |
+
$unsubscribe_link_track = $plugins_url;
|
| 243 |
+
$email_body = str_replace( "{{cart.unsubscribe}}" , $unsubscribe_link_track , $email_body );
|
| 244 |
+
$var = '';
|
| 245 |
+
if( preg_match( "{{products.cart}}", $email_body, $matched ) ) {
|
| 246 |
+
if ( class_exists( 'WP_Better_Emails' ) ) {
|
| 247 |
+
$var = '<table width = 100%>
|
| 248 |
+
<tr> <td colspan="5"> <h3>'.__( "Your Shopping Cart", "woocommerce-ac" ).'</h3> </td></tr>
|
| 249 |
+
<tr>
|
| 250 |
+
<th>'.__( "Item", "woocommerce-ac" ).'</th>
|
| 251 |
+
<th>'.__( "Name", "woocommerce-ac" ).'</th>
|
| 252 |
+
<th>'.__( "Quantity", "woocommerce-ac" ).'</th>
|
| 253 |
+
<th>'.__( "Price", "woocommerce-ac" ).'</th>
|
| 254 |
+
<th>'.__( "Line Subtotal", "woocommerce-ac" ).'</th>
|
| 255 |
+
</tr>';
|
| 256 |
} else {
|
| 257 |
+
$var = '<h3>'.__( "Your Shopping Cart", "woocommerce-ac" ).'</h3>
|
| 258 |
+
<table border="0" cellpadding="10" cellspacing="0" class="templateDataTable">
|
| 259 |
+
<tr>
|
| 260 |
+
<th>'.__( "Item", "woocommerce-ac" ).'</th>
|
| 261 |
+
<th>'.__( "Name", "woocommerce-ac" ).'</th>
|
| 262 |
+
<th>'.__( "Quantity", "woocommerce-ac" ).'</th>
|
| 263 |
+
<th>'.__( "Price", "woocommerce-ac" ).'</th>
|
| 264 |
+
<th>'.__( "Line Subtotal", "woocommerce-ac" ).'</th>
|
| 265 |
+
</tr>';
|
| 266 |
+
}
|
| 267 |
+
$cart_details = $cart_info_db_field->cart;
|
| 268 |
+
$cart_total = $item_subtotal = $item_total = 0;
|
| 269 |
+
$sub_line_prod_name = '';
|
| 270 |
+
foreach ( $cart_details as $k => $v ) {
|
| 271 |
+
$quantity_total = $v->quantity;
|
| 272 |
+
$product_id = $v->product_id;
|
| 273 |
+
$prod_name = get_post( $product_id );
|
| 274 |
+
$product_link_track = get_permalink( $product_id );
|
| 275 |
+
$product_name = $prod_name->post_title;
|
| 276 |
+
if( $sub_line_prod_name == '' ) {
|
| 277 |
+
$sub_line_prod_name = $product_name;
|
| 278 |
+
}
|
| 279 |
+
// Item subtotal is calculated as product total including taxes
|
| 280 |
+
if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
|
| 281 |
+
$item_subtotal = $item_subtotal + $v->line_total + $v->line_subtotal_tax;
|
| 282 |
+
} else {
|
| 283 |
+
$item_subtotal = $item_subtotal + $v->line_total;
|
| 284 |
+
}
|
| 285 |
+
// Line total
|
| 286 |
+
$item_total = $item_subtotal;
|
| 287 |
+
$item_subtotal = $item_subtotal / $quantity_total;
|
| 288 |
+
$item_total_display = wc_price( $item_total );
|
| 289 |
+
$item_subtotal = wc_price( $item_subtotal );
|
| 290 |
+
$product = wc_get_product( $product_id );
|
| 291 |
+
$prod_image = $product->get_image();
|
| 292 |
+
$image_url = wp_get_attachment_url( get_post_thumbnail_id( $product_id ) );
|
| 293 |
+
if ( isset( $v->variation_id ) && '' != $v->variation_id ) {
|
| 294 |
+
$variation_id = $v->variation_id;
|
| 295 |
+
$variation = wc_get_product( $variation_id );
|
| 296 |
+
$name = $variation->get_formatted_name() ;
|
| 297 |
+
$explode_all = explode ( "–", $name );
|
| 298 |
+
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
| 299 |
+
$wcap_sku = '';
|
| 300 |
+
if ( $variation->get_sku() ) {
|
| 301 |
+
$wcap_sku = "SKU: " . $variation->get_sku() . "<br>";
|
| 302 |
}
|
| 303 |
+
$wcap_get_formatted_variation = wc_get_formatted_variation( $variation, true );
|
| 304 |
+
|
| 305 |
+
$add_product_name = $product_name . ' - ' . $wcap_sku . $wcap_get_formatted_variation;
|
| 306 |
+
|
| 307 |
+
$pro_name_variation = (array) $add_product_name;
|
| 308 |
+
}else{
|
| 309 |
+
$pro_name_variation = array_slice( $explode_all, 1, -1 );
|
| 310 |
}
|
| 311 |
+
$product_name_with_variable = '';
|
| 312 |
+
$explode_many_varaition = array();
|
| 313 |
+
foreach( $pro_name_variation as $pro_name_variation_key => $pro_name_variation_value ) {
|
| 314 |
+
$explode_many_varaition = explode ( ",", $pro_name_variation_value );
|
| 315 |
+
if( !empty( $explode_many_varaition ) ) {
|
| 316 |
+
foreach( $explode_many_varaition as $explode_many_varaition_key => $explode_many_varaition_value ) {
|
| 317 |
+
$product_name_with_variable = $product_name_with_variable . html_entity_decode ( $explode_many_varaition_value ) . "<br>";
|
| 318 |
+
}
|
| 319 |
+
} else {
|
| 320 |
+
$product_name_with_variable = $product_name_with_variable . html_entity_decode ( $explode_many_varaition_value ) . "<br>";
|
| 321 |
+
}
|
|
|
|
| 322 |
}
|
| 323 |
+
$product_name = $product_name_with_variable;
|
|
|
|
| 324 |
}
|
| 325 |
+
$var .='<tr align="center">
|
| 326 |
+
<td> <a href="'.$cart_link_track.'"> <img src="' . $image_url . '" alt="" height="42" width="42" /> </a></td>
|
| 327 |
+
<td> <a href="'.$cart_link_track.'">'.__( $product_name, "woocommerce-ac" ).'</a></td>
|
| 328 |
+
<td> '.$quantity_total.'</td>
|
| 329 |
+
<td> '.$item_subtotal.'</td>
|
| 330 |
+
<td> '.$item_total_display.'</td>
|
| 331 |
+
</tr>';
|
| 332 |
+
$cart_total += $item_total;
|
| 333 |
+
$item_subtotal = $item_total = 0;
|
| 334 |
+
}
|
| 335 |
+
$cart_total = wc_price( $cart_total );
|
| 336 |
+
$var .= '<tr align="center">
|
| 337 |
+
<td> </td>
|
| 338 |
+
<td> </td>
|
| 339 |
+
<td> </td>
|
| 340 |
+
<td>'.__( "Cart Total:", "woocommerce-ac" ).'</td>
|
| 341 |
+
<td> '.$cart_total.'</td>
|
| 342 |
</tr>';
|
| 343 |
+
$var .= '</table>
|
| 344 |
+
';
|
| 345 |
+
$email_body = str_replace( "{{products.cart}}", $var, $email_body );
|
| 346 |
+
$email_subject = str_replace( "{{product.name}}", __( $sub_line_prod_name, "woocommerce-ac" ), $email_subject );
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
$user_email = $value->user_email;
|
| 350 |
+
$email_body_final = stripslashes( $email_body );
|
| 351 |
+
$email_body_final = convert_smilies( $email_body_final );
|
| 352 |
+
if ( isset( $is_wc_template ) && "1" == $is_wc_template ){
|
| 353 |
+
ob_start();
|
| 354 |
+
|
| 355 |
+
wc_get_template( 'emails/email-header.php', array( 'email_heading' => $wc_template_header ) );
|
| 356 |
+
$email_body_template_header = ob_get_clean();
|
| 357 |
+
|
| 358 |
+
ob_start();
|
| 359 |
+
|
| 360 |
+
wc_get_template( 'emails/email-footer.php' );
|
| 361 |
+
$email_body_template_footer = ob_get_clean();
|
| 362 |
+
|
| 363 |
+
$final_email_body = $email_body_template_header . $email_body_final . $email_body_template_footer;
|
| 364 |
+
|
| 365 |
+
wc_mail( $user_email, $email_subject, $final_email_body, $headers );
|
| 366 |
+
|
| 367 |
+
} else {
|
| 368 |
+
wp_mail( $user_email, $email_subject, __( $email_body_final, 'woocommerce-ac' ), $headers );
|
| 369 |
+
}
|
| 370 |
}
|
| 371 |
+
}
|
| 372 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 373 |
}
|
| 374 |
}
|
| 375 |
}
|
| 377 |
}
|
| 378 |
}
|
| 379 |
}
|
| 380 |
+
|
| 381 |
+
/**
|
| 382 |
+
* This function will check if the user type is Guest and the id is greater than 63000000
|
| 383 |
+
* Then conider that as a correct guest user, if is not then do not send the emails
|
| 384 |
+
*/
|
| 385 |
+
public static function wcal_get_is_guest_valid ( $wcal_user_id, $wcal_user_type ) {
|
| 386 |
+
|
| 387 |
+
if ( 'REGISTERED' == $wcal_user_type ){
|
| 388 |
+
return true;
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
if ( 'GUEST' == $wcal_user_type && $wcal_user_id >= 63000000 ) {
|
| 392 |
+
return true;
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
/**
|
| 396 |
+
* It indicates that the user type is guest but the id for them is wrong.
|
| 397 |
+
*/
|
| 398 |
+
return false;
|
| 399 |
+
}
|
| 400 |
function wcal_check_cart_total ( $cart ){
|
| 401 |
foreach( $cart as $k => $v ) {
|
|
|
|
| 402 |
if( $v->line_total != 0 && $v->line_total > 0 ) {
|
| 403 |
return true;
|
| 404 |
}
|
| 512 |
|
| 513 |
$results_query_email = $wpdb->get_results( $wpdb->prepare( $query_email_id, $user_billing_email ) );
|
| 514 |
|
| 515 |
+
if ( count ( $results_query_email ) > 0 ) {
|
| 516 |
$current_time = current_time( 'timestamp' );
|
| 517 |
$todays_date = date( 'Y-m-d', $current_time );
|
| 518 |
+
$order_date_time = $results_query_email[0]->post_date;
|
| 519 |
+
$order_date = substr( $order_date_time, 0, 10 );
|
| 520 |
|
| 521 |
if ( $order_date == $todays_date ){
|
| 522 |
|
| 523 |
$wcal_check_email_sent_to_cart = woocommerce_abandon_cart_cron::wcal_get_cart_sent_data ( $cart_id );
|
| 524 |
|
| 525 |
+
if ( 0 != $wcal_check_email_sent_to_cart ) {
|
| 526 |
|
| 527 |
$wcal_query = "SELECT `post_id` FROM `" . $wpdb->prefix . "postmeta` WHERE meta_value = %s";
|
| 528 |
$wcal_results = $wpdb->get_results ( $wpdb->prepare( $wcal_query , $cart_id ) );
|
| 529 |
|
| 530 |
+
if ( count( $wcal_results ) > 0 ) {
|
| 531 |
|
| 532 |
$order_id = $wcal_results[0]->post_id;
|
| 533 |
|
| 536 |
$query_order = "UPDATE `" . $wpdb->prefix."ac_abandoned_cart_history_lite` SET recovered_cart= '" . $order_id . "', cart_ignored = '1' WHERE id = '".$cart_id."' ";
|
| 537 |
$wpdb->query( $query_order );
|
| 538 |
|
|
|
|
|
|
|
| 539 |
$order->add_order_note( __( 'This order was abandoned & subsequently recovered.', 'woocommerce-ac' ) );
|
| 540 |
|
| 541 |
delete_post_meta( $order_id, 'wcap_recover_order_placed', $cart_id );
|
| 542 |
delete_post_meta( $order_id , 'wcap_recover_order_placed_sent_id', $wcal_check_email_sent_to_cart );
|
| 543 |
}
|
| 544 |
+
}else {
|
| 545 |
|
| 546 |
$query_ignored = "UPDATE `" . $wpdb->prefix."ac_abandoned_cart_history_lite` SET cart_ignored = '1' WHERE id ='" . $cart_id . "'";
|
| 547 |
$wpdb->query( $query_ignored );
|
| 571 |
return 0;
|
| 572 |
}
|
| 573 |
|
|
|
|
| 574 |
public static function wcal_remove_cart_for_mutiple_templates( $wcal_cart_id, $time_to_send_template_after, $template_id ) {
|
| 575 |
global $wpdb;
|
| 576 |
|
includes/classes/class-wcal-abandoned-orders-table.php
CHANGED
|
@@ -290,7 +290,7 @@ class WCAL_Abandoned_Orders_Table extends WP_List_Table {
|
|
| 290 |
}
|
| 291 |
|
| 292 |
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
| 293 |
-
$cut_off_time = $ac_cutoff_time * 60;
|
| 294 |
$current_time = current_time( 'timestamp' );
|
| 295 |
$compare_time = $current_time - $cart_update_time;
|
| 296 |
$cart_details = array();
|
| 290 |
}
|
| 291 |
|
| 292 |
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
| 293 |
+
$cut_off_time = intval( $ac_cutoff_time ) * 60;
|
| 294 |
$current_time = current_time( 'timestamp' );
|
| 295 |
$compare_time = $current_time - $cart_update_time;
|
| 296 |
$cart_details = array();
|
includes/classes/class-wcal-templates-table.php
CHANGED
|
@@ -235,12 +235,16 @@ class WCAL_Templates_Table extends WP_List_Table {
|
|
| 235 |
$is_active = $wcal_abandoned_orders->is_active;
|
| 236 |
$active = '';
|
| 237 |
if ( $is_active == '1' ) {
|
| 238 |
-
$active = "
|
| 239 |
} else {
|
| 240 |
-
$active = "
|
| 241 |
}
|
| 242 |
$active_text = __( $active, 'woocommerce-ac' );
|
| 243 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
}
|
| 245 |
break;
|
| 246 |
default:
|
| 235 |
$is_active = $wcal_abandoned_orders->is_active;
|
| 236 |
$active = '';
|
| 237 |
if ( $is_active == '1' ) {
|
| 238 |
+
$active = "on";
|
| 239 |
} else {
|
| 240 |
+
$active = "off";
|
| 241 |
}
|
| 242 |
$active_text = __( $active, 'woocommerce-ac' );
|
| 243 |
+
//$value = '<a href="#" onclick="wcal_activate_email_template('. $id.', '.$is_active.' )"> '.$active_text.'</a>';
|
| 244 |
+
$value = '<button type="button" class="wcal-switch wcal-toggle-template-status" '
|
| 245 |
+
. 'wcal-template-id="'. $id .'" '
|
| 246 |
+
. 'wcal-template-switch="'. ( $active ) . '">'
|
| 247 |
+
. $active_text . '</button>';
|
| 248 |
}
|
| 249 |
break;
|
| 250 |
default:
|
includes/wcal-common.php
CHANGED
|
@@ -7,7 +7,7 @@ class wcal_common {
|
|
| 7 |
$blank_cart_info = '{"cart":[]}';
|
| 8 |
$blank_cart_info_guest = '[]';
|
| 9 |
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
| 10 |
-
$cut_off_time = $ac_cutoff_time * 60;
|
| 11 |
$current_time = current_time( 'timestamp' );
|
| 12 |
$compare_time = $current_time - $cut_off_time;
|
| 13 |
|
| 7 |
$blank_cart_info = '{"cart":[]}';
|
| 8 |
$blank_cart_info_guest = '[]';
|
| 9 |
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
| 10 |
+
$cut_off_time = intval( $ac_cutoff_time ) * 60;
|
| 11 |
$current_time = current_time( 'timestamp' );
|
| 12 |
$compare_time = $current_time - $cut_off_time;
|
| 13 |
|
includes/wcal_actions.php
CHANGED
|
@@ -41,6 +41,5 @@ class wcal_delete_bulk_action_handler {
|
|
| 41 |
$wpdb->query( $query_remove );
|
| 42 |
|
| 43 |
wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&action=emailtemplates&wcal_template_deleted=YES' ) );
|
| 44 |
-
|
| 45 |
}
|
| 46 |
}
|
| 41 |
$wpdb->query( $query_remove );
|
| 42 |
|
| 43 |
wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&action=emailtemplates&wcal_template_deleted=YES' ) );
|
|
|
|
| 44 |
}
|
| 45 |
}
|
includes/wcal_admin_notice.php
CHANGED
|
@@ -6,7 +6,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
| 6 |
|
| 7 |
class Wcal_Admin_Notice {
|
| 8 |
|
| 9 |
-
public static function wcal_pro_notice (){
|
| 10 |
|
| 11 |
$wcal_activate_time = get_option ( 'wcal_activate_time' );
|
| 12 |
$wcal_sixty_days = strtotime( '+60 Days', $wcal_activate_time );
|
|
@@ -32,7 +32,7 @@ class Wcal_Admin_Notice {
|
|
| 32 |
printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, $message, $cancel_button );
|
| 33 |
}
|
| 34 |
|
| 35 |
-
if ( get_user_meta( get_current_user_id(), 'wcal_pro_first_notice_ignore' ) && ! get_user_meta( get_current_user_id(), 'wcal_pro_second_notice_ignore' )) {
|
| 36 |
|
| 37 |
$wcal_first_ignore_time = get_user_meta( get_current_user_id(), 'wcal_pro_first_notice_ignore_time' );
|
| 38 |
$wcal_fifteen_days = strtotime( '+15 Days', $wcal_first_ignore_time[0]);
|
|
@@ -77,7 +77,7 @@ class Wcal_Admin_Notice {
|
|
| 77 |
get_user_meta( get_current_user_id(), 'wcal_pro_second_notice_ignore' ) &&
|
| 78 |
! get_user_meta( get_current_user_id(), 'wcal_pro_fourth_notice_ignore' ) &&
|
| 79 |
( is_plugin_active( 'order-delivery-date/order_delivery_date.php' ) ||
|
| 80 |
-
is_plugin_active( 'order-delivery-date-for-woocommerce/order_delivery_date.php' ) ) ){
|
| 81 |
|
| 82 |
$wcal_third_ignore_time = get_user_meta( get_current_user_id(), 'wcal_pro_second_notice_ignore_time' );
|
| 83 |
$wcal_seven_days = strtotime( '+15 Days', $wcal_third_ignore_time[0] );
|
|
@@ -109,7 +109,7 @@ class Wcal_Admin_Notice {
|
|
| 109 |
$wcal_seven_days = strtotime( '+7 Days', $wcal_third_ignore_time[0] );
|
| 110 |
|
| 111 |
|
| 112 |
-
if ( $wcal_current_time >= $wcal_seven_days ){
|
| 113 |
$class = 'updated notice-info point-notice';
|
| 114 |
$style = 'position:relative';
|
| 115 |
|
| 6 |
|
| 7 |
class Wcal_Admin_Notice {
|
| 8 |
|
| 9 |
+
public static function wcal_pro_notice () {
|
| 10 |
|
| 11 |
$wcal_activate_time = get_option ( 'wcal_activate_time' );
|
| 12 |
$wcal_sixty_days = strtotime( '+60 Days', $wcal_activate_time );
|
| 32 |
printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, $message, $cancel_button );
|
| 33 |
}
|
| 34 |
|
| 35 |
+
if ( get_user_meta( get_current_user_id(), 'wcal_pro_first_notice_ignore' ) && ! get_user_meta( get_current_user_id(), 'wcal_pro_second_notice_ignore' ) ) {
|
| 36 |
|
| 37 |
$wcal_first_ignore_time = get_user_meta( get_current_user_id(), 'wcal_pro_first_notice_ignore_time' );
|
| 38 |
$wcal_fifteen_days = strtotime( '+15 Days', $wcal_first_ignore_time[0]);
|
| 77 |
get_user_meta( get_current_user_id(), 'wcal_pro_second_notice_ignore' ) &&
|
| 78 |
! get_user_meta( get_current_user_id(), 'wcal_pro_fourth_notice_ignore' ) &&
|
| 79 |
( is_plugin_active( 'order-delivery-date/order_delivery_date.php' ) ||
|
| 80 |
+
is_plugin_active( 'order-delivery-date-for-woocommerce/order_delivery_date.php' ) ) ) {
|
| 81 |
|
| 82 |
$wcal_third_ignore_time = get_user_meta( get_current_user_id(), 'wcal_pro_second_notice_ignore_time' );
|
| 83 |
$wcal_seven_days = strtotime( '+15 Days', $wcal_third_ignore_time[0] );
|
| 109 |
$wcal_seven_days = strtotime( '+7 Days', $wcal_third_ignore_time[0] );
|
| 110 |
|
| 111 |
|
| 112 |
+
if ( $wcal_current_time >= $wcal_seven_days ) {
|
| 113 |
$class = 'updated notice-info point-notice';
|
| 114 |
$style = 'position:relative';
|
| 115 |
|
includes/wcal_class-guest.php
CHANGED
|
@@ -18,9 +18,7 @@ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
|
|
| 18 |
function load_ac_ajax() {
|
| 19 |
if ( ! is_user_logged_in() ) {
|
| 20 |
add_action( 'wp_ajax_nopriv_save_data', 'save_data' );
|
| 21 |
-
}
|
| 22 |
-
add_action( 'wp_ajax_save_data', 'save_data' );
|
| 23 |
-
}
|
| 24 |
}
|
| 25 |
|
| 26 |
function user_side_js() {
|
|
@@ -143,7 +141,7 @@ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
|
|
| 143 |
WHERE user_id = %d AND recovered_cart = '0'" ;
|
| 144 |
$result = $wpdb->get_results( $wpdb->prepare( $query, $value->id ) );
|
| 145 |
|
| 146 |
-
if ( $result ) {
|
| 147 |
$delete_sent_email = "DELETE FROM `".$wpdb->prefix."ac_sent_history_lite`
|
| 148 |
WHERE abandoned_order_id = '".$result[0]->id."'";
|
| 149 |
$wpdb->query( $delete_sent_email );
|
|
@@ -225,8 +223,10 @@ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
|
|
| 225 |
WHERE user_id ='" . $user_id . "' AND cart_ignored='0' AND session_id ='" . $get_cookie[0] . "' ";
|
| 226 |
$get_abandoned_record = $wpdb->get_results( $query_update_get );
|
| 227 |
|
| 228 |
-
|
| 229 |
-
|
|
|
|
|
|
|
| 230 |
|
| 231 |
$insert_persistent_cart = "INSERT INTO `".$wpdb->prefix."usermeta`( user_id, meta_key, meta_value )
|
| 232 |
VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
|
| 18 |
function load_ac_ajax() {
|
| 19 |
if ( ! is_user_logged_in() ) {
|
| 20 |
add_action( 'wp_ajax_nopriv_save_data', 'save_data' );
|
| 21 |
+
}
|
|
|
|
|
|
|
| 22 |
}
|
| 23 |
|
| 24 |
function user_side_js() {
|
| 141 |
WHERE user_id = %d AND recovered_cart = '0'" ;
|
| 142 |
$result = $wpdb->get_results( $wpdb->prepare( $query, $value->id ) );
|
| 143 |
|
| 144 |
+
if ( count( $result ) ) {
|
| 145 |
$delete_sent_email = "DELETE FROM `".$wpdb->prefix."ac_sent_history_lite`
|
| 146 |
WHERE abandoned_order_id = '".$result[0]->id."'";
|
| 147 |
$wpdb->query( $delete_sent_email );
|
| 223 |
WHERE user_id ='" . $user_id . "' AND cart_ignored='0' AND session_id ='" . $get_cookie[0] . "' ";
|
| 224 |
$get_abandoned_record = $wpdb->get_results( $query_update_get );
|
| 225 |
|
| 226 |
+
if ( count( $get_abandoned_record ) > 0 ) {
|
| 227 |
+
$abandoned_cart_id = $get_abandoned_record[0]->id;
|
| 228 |
+
$_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
|
| 229 |
+
}
|
| 230 |
|
| 231 |
$insert_persistent_cart = "INSERT INTO `".$wpdb->prefix."usermeta`( user_id, meta_key, meta_value )
|
| 232 |
VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
|
readme.txt
CHANGED
|
@@ -4,7 +4,7 @@ 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.8.
|
| 8 |
Stable tag: trunk
|
| 9 |
License: GPLv2 or later
|
| 10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
|
@@ -188,6 +188,18 @@ You can refer **[here](https://www.tychesoftwares.com/differences-between-pro-an
|
|
| 188 |
|
| 189 |
== Changelog ==
|
| 190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
= 4.3 (29.08.2017) =
|
| 192 |
|
| 193 |
* This version has 1 bug fix along with 3 Enhancements.
|
|
@@ -479,6 +491,18 @@ For existing users, this setting will remain unchecked. For new users of the plu
|
|
| 479 |
|
| 480 |
== Upgrade Notice ==
|
| 481 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 482 |
= 4.3 (29.08.2017) =
|
| 483 |
|
| 484 |
* This version has 1 bug fix along with 3 Enhancements.
|
| 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.8.2
|
| 8 |
Stable tag: trunk
|
| 9 |
License: GPLv2 or later
|
| 10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 188 |
|
| 189 |
== Changelog ==
|
| 190 |
|
| 191 |
+
= 4.4 (13.10-2017) =
|
| 192 |
+
|
| 193 |
+
* This version has 3 bugs fixes along with 1 Enhancement.
|
| 194 |
+
|
| 195 |
+
* Bug Fixed - If the guest user's id is wrong then the abandoned cart email will not be sent to the customers.
|
| 196 |
+
|
| 197 |
+
* Bug Fixed - If the variable products have a special character was not displaying the correct attributes. This has been fixed.
|
| 198 |
+
|
| 199 |
+
* Bug Fixed - Some error notices of debug log file are fixed.
|
| 200 |
+
|
| 201 |
+
* Enhancement - Now, admin can activate the email templates using toggle button from the Email Templates page.
|
| 202 |
+
|
| 203 |
= 4.3 (29.08.2017) =
|
| 204 |
|
| 205 |
* This version has 1 bug fix along with 3 Enhancements.
|
| 491 |
|
| 492 |
== Upgrade Notice ==
|
| 493 |
|
| 494 |
+
= 4.4 (13.10-2017) =
|
| 495 |
+
|
| 496 |
+
* This version has 3 bugs fixes along with 1 Enhancement.
|
| 497 |
+
|
| 498 |
+
* Bug Fixed - If the guest user's id is wrong then the abandoned cart email will not be sent to the customers.
|
| 499 |
+
|
| 500 |
+
* Bug Fixed - If the variable products have a special character was not displaying the correct attributes. This has been fixed.
|
| 501 |
+
|
| 502 |
+
* Bug Fixed - Some error notices of debug log file are fixed.
|
| 503 |
+
|
| 504 |
+
* Enhancement - Now, admin can activate the email templates using toggle button from the Email Templates page.
|
| 505 |
+
|
| 506 |
= 4.3 (29.08.2017) =
|
| 507 |
|
| 508 |
* This version has 1 bug fix along with 3 Enhancements.
|
views/wcal-email-template-preview.php
CHANGED
|
@@ -5,10 +5,12 @@
|
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) {
|
| 6 |
exit; // Exit if accessed directly
|
| 7 |
}
|
| 8 |
-
$current_time_stamp
|
| 9 |
-
$date_format
|
| 10 |
-
$time_format
|
| 11 |
-
$test_date
|
|
|
|
|
|
|
| 12 |
?>
|
| 13 |
<html>
|
| 14 |
<head>
|
|
@@ -30,14 +32,14 @@ $test_date = $date_format . ' ' . $time_format;
|
|
| 30 |
<th>Total</th>
|
| 31 |
</tr>
|
| 32 |
<tr style="background-color:#f4f5f4;">
|
| 33 |
-
<td><img src = "<?php echo plugins_url();?>/woocommerce-abandoned-cart/assets/images/spectre.jpg" height="40px" width="40px"></td><td>Spectre</td><td
|
| 34 |
</tr>
|
| 35 |
<tr>
|
| 36 |
<td> </td>
|
| 37 |
<td> </td>
|
| 38 |
<td> </td>
|
| 39 |
<th>Cart Total:</th>
|
| 40 |
-
<td
|
| 41 |
</tr>
|
| 42 |
</tbody>
|
| 43 |
</table>
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) {
|
| 6 |
exit; // Exit if accessed directly
|
| 7 |
}
|
| 8 |
+
$current_time_stamp = current_time( 'timestamp' );
|
| 9 |
+
$date_format = date_i18n( get_option( 'date_format' ), $current_time_stamp );
|
| 10 |
+
$time_format = date_i18n( get_option( 'time_format' ), $current_time_stamp );
|
| 11 |
+
$test_date = $date_format . ' ' . $time_format;
|
| 12 |
+
$wcal_price = wc_price( '150' );
|
| 13 |
+
$wcal_total_price = wc_price( '300' );
|
| 14 |
?>
|
| 15 |
<html>
|
| 16 |
<head>
|
| 32 |
<th>Total</th>
|
| 33 |
</tr>
|
| 34 |
<tr style="background-color:#f4f5f4;">
|
| 35 |
+
<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>
|
| 36 |
</tr>
|
| 37 |
<tr>
|
| 38 |
<td> </td>
|
| 39 |
<td> </td>
|
| 40 |
<td> </td>
|
| 41 |
<th>Cart Total:</th>
|
| 42 |
+
<td><?php echo "$wcal_total_price"; ?></td>
|
| 43 |
</tr>
|
| 44 |
</tbody>
|
| 45 |
</table>
|
views/wcal-wc-email-template-preview.php
CHANGED
|
@@ -5,10 +5,12 @@
|
|
| 5 |
if( ! defined( 'ABSPATH' ) ) {
|
| 6 |
exit; // Exit if accessed directly
|
| 7 |
}
|
| 8 |
-
$current_time_stamp
|
| 9 |
-
$date_format
|
| 10 |
-
$time_format
|
| 11 |
-
$test_date
|
|
|
|
|
|
|
| 12 |
?>
|
| 13 |
<body>
|
| 14 |
<p> Hello John Carter, </p>
|
|
@@ -26,14 +28,14 @@ $test_date = $date_format . ' ' . $time_format;
|
|
| 26 |
<th>Total</th>
|
| 27 |
</tr>
|
| 28 |
<tr style="background-color:#f4f5f4;">
|
| 29 |
-
<td><img src = "<?php echo plugins_url();?>/woocommerce-abandoned-cart/assets/images/spectre.jpg" height="40px" width="40px"></td><td>Spectre</td><td
|
| 30 |
</tr>
|
| 31 |
<tr>
|
| 32 |
<td> </td>
|
| 33 |
<td> </td>
|
| 34 |
<td> </td>
|
| 35 |
<th>Cart Total:</th>
|
| 36 |
-
<td
|
| 37 |
</tr>
|
| 38 |
</tbody>
|
| 39 |
</table>
|
| 5 |
if( ! defined( 'ABSPATH' ) ) {
|
| 6 |
exit; // Exit if accessed directly
|
| 7 |
}
|
| 8 |
+
$current_time_stamp = current_time( 'timestamp' );
|
| 9 |
+
$date_format = date_i18n( get_option( 'date_format' ), $current_time_stamp );
|
| 10 |
+
$time_format = date_i18n( get_option( 'time_format' ), $current_time_stamp );
|
| 11 |
+
$test_date = $date_format . ' ' . $time_format;
|
| 12 |
+
$wcal_price = wc_price( '150' );
|
| 13 |
+
$wcal_total_price = wc_price( '300' );
|
| 14 |
?>
|
| 15 |
<body>
|
| 16 |
<p> Hello John Carter, </p>
|
| 28 |
<th>Total</th>
|
| 29 |
</tr>
|
| 30 |
<tr style="background-color:#f4f5f4;">
|
| 31 |
+
<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>
|
| 32 |
</tr>
|
| 33 |
<tr>
|
| 34 |
<td> </td>
|
| 35 |
<td> </td>
|
| 36 |
<td> </td>
|
| 37 |
<th>Cart Total:</th>
|
| 38 |
+
<td><?php echo "$wcal_total_price"; ?></td>
|
| 39 |
</tr>
|
| 40 |
</tbody>
|
| 41 |
</table>
|
woocommerce-ac.php
CHANGED
|
@@ -1,15 +1,16 @@
|
|
| 1 |
<?php
|
| 2 |
/*
|
| 3 |
-
Plugin Name: Abandoned Cart Lite for WooCommerce
|
| 4 |
-
Plugin URI: http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro
|
| 5 |
-
Description: This plugin captures abandoned carts by logged-in users & emails them about it. <strong><a href="http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro">Click here to get the PRO Version.</a></strong>
|
| 6 |
-
Version: 4.
|
| 7 |
-
Author: Tyche Softwares
|
| 8 |
-
Author URI: http://www.tychesoftwares.com/
|
| 9 |
-
Text Domain: woocommerce-ac
|
| 10 |
-
Domain Path: /i18n/languages/
|
| 11 |
-
|
| 12 |
-
WC
|
|
|
|
| 13 |
*/
|
| 14 |
|
| 15 |
// Deletion Settings
|
|
@@ -59,7 +60,7 @@ if ( ! wp_next_scheduled( 'wcal_ts_tracker_send_event' ) ) {
|
|
| 59 |
add_action( 'woocommerce_ac_send_email_action', 'wcal_send_email_cron' );
|
| 60 |
|
| 61 |
function wcal_send_email_cron() {
|
| 62 |
-
|
| 63 |
$plugin_dir_path = plugin_dir_path( __FILE__ );
|
| 64 |
require_once( $plugin_dir_path . 'cron/wcal_send_email.php' );
|
| 65 |
}
|
|
@@ -221,7 +222,8 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 221 |
if ( is_admin() ) {
|
| 222 |
// Load "admin-only" scripts here
|
| 223 |
add_action ( 'admin_head', array( &$this, 'wcal_action_send_preview' ) );
|
| 224 |
-
add_action ( 'wp_ajax_wcal_preview_email_sent', array( &$this, 'wcal_preview_email_sent' ) );
|
|
|
|
| 225 |
}
|
| 226 |
|
| 227 |
// Send Email on order recovery
|
|
@@ -231,21 +233,22 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 231 |
add_action( 'woocommerce_order_status_failed_to_processing_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
| 232 |
add_action( 'woocommerce_order_status_failed_to_completed_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
| 233 |
|
| 234 |
-
add_action('woocommerce_order_status_changed', array( &$this,
|
| 235 |
|
| 236 |
add_action( 'admin_init', array( $this, 'wcal_preview_emails' ) );
|
| 237 |
add_action( 'init', array( $this, 'wcal_app_output_buffer') );
|
| 238 |
add_action( 'admin_init', array( &$this, 'wcal_check_pro_activated' ) );
|
| 239 |
add_action( 'woocommerce_checkout_order_processed', array( &$this, 'wcal_order_placed' ), 10 , 1 );
|
| 240 |
-
add_filter( 'woocommerce_payment_complete_order_status', array( &$this
|
| 241 |
add_filter( 'admin_footer_text', array( $this, 'wcal_admin_footer_text' ), 1 );
|
| 242 |
|
| 243 |
-
add_action( 'admin_notices',
|
| 244 |
add_action( 'admin_init', array( 'Wcal_Admin_Notice', 'wcal_pro_notice_ignore' ) );
|
| 245 |
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
|
|
|
| 249 |
add_action( 'admin_init', array( &$this, 'wcal_wc_check_compatibility' ) );
|
| 250 |
}
|
| 251 |
|
|
@@ -322,28 +325,42 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 322 |
$get_ac_id_query = "SELECT abandoned_order_id FROM ". $wcal_sent_email_table_name ." WHERE id = %d";
|
| 323 |
$get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query, $email_sent_id ) );
|
| 324 |
|
| 325 |
-
$abandoned_order_id =
|
|
|
|
|
|
|
|
|
|
| 326 |
|
| 327 |
$wcal_account_password_check = 'no';
|
| 328 |
|
| 329 |
/*if user becomes the registered user */
|
| 330 |
if ( isset( $_POST['account_password'] ) && $_POST['account_password'] != '' ) {
|
| 331 |
|
| 332 |
-
$abandoned_cart_id_new_user =
|
| 333 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
|
| 335 |
/* delete the guest record. As it become the logged in user */
|
| 336 |
|
| 337 |
-
$
|
| 338 |
-
|
| 339 |
-
|
|
|
|
|
|
|
| 340 |
|
| 341 |
if ( count ($get_ac_id_guest_results) > 1 ) {
|
| 342 |
$abandoned_order_id_of_guest = $get_ac_id_guest_results[0]->id;
|
| 343 |
$wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_order_id_of_guest ) );
|
| 344 |
}
|
| 345 |
-
|
| 346 |
-
|
|
|
|
|
|
|
| 347 |
|
| 348 |
$wcal_account_password_check = 'yes';
|
| 349 |
}
|
|
@@ -354,65 +371,79 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 354 |
$_POST['createaccount'] != '' &&
|
| 355 |
'no' == $wcal_account_password_check ) {
|
| 356 |
|
| 357 |
-
$abandoned_cart_id_new_user =
|
| 358 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 359 |
|
| 360 |
/* delete the guest record. As it become the logged in user */
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
|
|
|
| 365 |
if ( count ($get_ac_id_guest_results) > 1 ){
|
| 366 |
$abandoned_order_id_of_guest = $get_ac_id_guest_results[0]->id;
|
| 367 |
$wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_order_id_of_guest ) );
|
| 368 |
}
|
| 369 |
|
| 370 |
/* it is the new registered users cart id */
|
| 371 |
-
|
|
|
|
|
|
|
| 372 |
|
| 373 |
$wcap_create_account = 'yes';
|
| 374 |
}
|
| 375 |
|
| 376 |
if ( 'no' == $wcal_account_password_check && 'no' == $wcap_create_account ) {
|
| 377 |
|
| 378 |
-
$wcal_user_id_of_guest
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
$abandoned_order_id_of_guest = $get_ac_id_guest_results[0]->id;
|
| 385 |
-
$wpdb->delete( $wcal_history_table_name, array( 'id' => $abandoned_order_id_of_guest ) );
|
| 386 |
}
|
| 387 |
}
|
| 388 |
|
| 389 |
add_post_meta( $order_id , 'wcal_recover_order_placed_sent_id', $email_sent_id );
|
| 390 |
-
|
|
|
|
|
|
|
| 391 |
|
| 392 |
}else if ( isset( $_SESSION['abandoned_cart_id_lite'] ) && $_SESSION['abandoned_cart_id_lite'] != '' ) {
|
| 393 |
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
|
| 406 |
-
|
| 407 |
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
|
| 412 |
-
|
| 413 |
-
|
|
|
|
| 414 |
$wcal_abandoned_cart_id = $_SESSION['abandoned_cart_id_lite'];
|
| 415 |
-
|
| 416 |
|
| 417 |
$get_abandoned_cart_query = "SELECT abandoned_cart_time FROM `" . $wcal_history_table_name . "` WHERE id = %d ";
|
| 418 |
$get_abandoned_cart_results = $wpdb->get_results( $wpdb->prepare( $get_abandoned_cart_query, $wcal_abandoned_cart_id ) );
|
|
@@ -427,41 +458,41 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 427 |
|
| 428 |
if ( $compare_time > $wcal_cart_abandoned_time ) {
|
| 429 |
/* cart is declared as adandoned */
|
| 430 |
-
|
| 431 |
add_post_meta( $order_id , 'wcal_recover_order_placed', $wcal_abandoned_cart_id );
|
| 432 |
}else {
|
| 433 |
-
|
| 434 |
-
|
| 435 |
|
| 436 |
-
|
| 437 |
|
| 438 |
-
|
| 439 |
|
| 440 |
-
|
| 441 |
-
|
| 442 |
|
| 443 |
-
|
| 444 |
|
| 445 |
-
|
| 446 |
-
|
| 447 |
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
|
| 458 |
-
|
| 459 |
-
|
| 460 |
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
|
|
|
| 465 |
}
|
| 466 |
}
|
| 467 |
}
|
|
@@ -536,7 +567,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 536 |
* activated with PRO version is activated.
|
| 537 |
*/
|
| 538 |
public static function wcal_check_pro_notice() {
|
| 539 |
-
$class
|
| 540 |
$message = __( 'The Lite & Pro version of Abandoned Cart plugin for WooCommerce (from Tyche Softwares) are active on your website. <br> In this case, the abandoned carts will be captured in both plugins & email reminders will also be sent from both plugins. <br> It is recommended that you deactivate the Lite version & keep the Pro version active.', 'woocommerce-ac' );
|
| 541 |
printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
|
| 542 |
}
|
|
@@ -564,7 +595,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 564 |
include( 'views/wcal-wc-email-template-preview.php' );
|
| 565 |
$mailer = WC()->mailer();
|
| 566 |
$message = ob_get_clean();
|
| 567 |
-
$email_heading = __( 'HTML Email Template', 'woocommerce' );
|
| 568 |
$message = $mailer->wrap_message( $email_heading, $message );
|
| 569 |
} else {
|
| 570 |
// load the mailer class
|
|
@@ -784,7 +815,6 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 784 |
array( 'When a contact receives your email and clicks reply, which email address should that reply be sent to?', 'woocommerce-ac' )
|
| 785 |
);
|
| 786 |
|
| 787 |
-
|
| 788 |
// Finally, we register the fields with WordPress
|
| 789 |
register_setting(
|
| 790 |
'woocommerce_ac_settings',
|
|
@@ -1097,8 +1127,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 1097 |
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_abandoned_cart_history_lite ADD `session_id` varchar(50) COLLATE utf8_unicode_ci NOT NULL AFTER `unsubscribe_link`;" );
|
| 1098 |
}
|
| 1099 |
}
|
| 1100 |
-
|
| 1101 |
-
*
|
|
|
|
|
|
|
| 1102 |
*/
|
| 1103 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_guest_abandoned_cart_history_lite';" ) && 'yes' != get_option( 'wcal_guest_user_id_altered' ) ) {
|
| 1104 |
$last_id = $wpdb->get_var( "SELECT max(id) FROM `{$wpdb->prefix}ac_guest_abandoned_cart_history_lite`;" );
|
|
@@ -1108,10 +1140,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 1108 |
}
|
| 1109 |
}
|
| 1110 |
|
| 1111 |
-
|
| 1112 |
-
* Since 4.7
|
| 1113 |
* We have moved email templates fields in the setings section. SO to remove that fields column fro the db we need it.
|
| 1114 |
-
* For existing user we need to fill this setting with the first template.
|
|
|
|
| 1115 |
*/
|
| 1116 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_email_templates_lite';" ) ) {
|
| 1117 |
if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'from_email';" ) ) {
|
|
@@ -1155,7 +1187,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 1155 |
}
|
| 1156 |
}
|
| 1157 |
|
| 1158 |
-
|
| 1159 |
* Send email to admin when cart is recovered only via PayPal.
|
| 1160 |
* @since 2.9 version
|
| 1161 |
*/
|
|
@@ -1176,7 +1208,6 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 1176 |
$check_abandoned_cart = get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true );
|
| 1177 |
$created_via = get_post_meta ( $order_id, '_created_via', true );
|
| 1178 |
|
| 1179 |
-
// mention here why are we comparing both "yes" and "no" values
|
| 1180 |
if ( 'checkout' == $created_via && 'yes' != $recovered_email_sent && ( $check_abandoned_cart == md5( "yes" ) || $check_abandoned_cart == md5( "no" ) ) ) { // indicates cart is abandoned
|
| 1181 |
$order = new WC_Order( $order_id );
|
| 1182 |
$email_heading = __( 'New Customer Order - Recovered', 'woocommerce-ac' );
|
|
@@ -1205,7 +1236,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 1205 |
}
|
| 1206 |
}
|
| 1207 |
|
| 1208 |
-
|
| 1209 |
* Send email to admin when cart is recovered via any other payment gateway other than PayPal.
|
| 1210 |
* @since 2.3 version
|
| 1211 |
*/
|
|
@@ -1277,7 +1308,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 1277 |
}
|
| 1278 |
|
| 1279 |
if( isset( $cut_off_time ) ) {
|
| 1280 |
-
$cart_cut_off_time = $cut_off_time * 60;
|
| 1281 |
} else {
|
| 1282 |
$cart_cut_off_time = 60 * 60;
|
| 1283 |
}
|
|
@@ -1304,7 +1335,8 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 1304 |
$abandoned_cart_id = $wpdb->insert_id;
|
| 1305 |
$_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
|
| 1306 |
} elseif ( isset( $results[0]->abandoned_cart_time ) && $compare_time > $results[0]->abandoned_cart_time ) {
|
| 1307 |
-
|
|
|
|
| 1308 |
$updated_cart_info = json_encode( get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true ) );
|
| 1309 |
|
| 1310 |
if ( ! $this->wcal_compare_carts( $user_id, $results[0]->abandoned_cart_info ) ) {
|
|
@@ -1322,7 +1354,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 1322 |
|
| 1323 |
update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "yes" ) );
|
| 1324 |
|
| 1325 |
-
$abandoned_cart_id
|
| 1326 |
$_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
|
| 1327 |
} else {
|
| 1328 |
update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "no" ) );
|
|
@@ -1340,9 +1372,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 1340 |
|
| 1341 |
$query_update = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE user_id ='" . $user_id . "' AND cart_ignored='0' ";
|
| 1342 |
$get_abandoned_record = $wpdb->get_results( $query_update );
|
| 1343 |
-
|
| 1344 |
-
|
| 1345 |
-
|
|
|
|
| 1346 |
}
|
| 1347 |
} else {
|
| 1348 |
//start here guest user
|
|
@@ -1389,9 +1422,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 1389 |
$wpdb->query( $query_update );
|
| 1390 |
}
|
| 1391 |
} else {
|
| 1392 |
-
|
| 1393 |
-
* @Since: 3.5
|
| 1394 |
* Here we capture the guest cart from the cart page.
|
|
|
|
|
|
|
| 1395 |
*/
|
| 1396 |
if ( $track_guest_user_cart_from_cart == "on" && $get_cookie[0] != '' ) {
|
| 1397 |
$query = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE session_id LIKE %s AND cart_ignored = '0' AND recovered_cart = '0' ";
|
|
@@ -1473,7 +1507,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 1473 |
if( isset( $results_sent[0] ) ) {
|
| 1474 |
$email_address = $results_sent[0]->sent_email_id;
|
| 1475 |
}
|
| 1476 |
-
if( $validate_email_address_string == hash( 'sha256', $email_address ) ) {
|
| 1477 |
$email_sent_id = $validate_email_id_decode;
|
| 1478 |
$get_ac_id_query = "SELECT abandoned_order_id FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE id = %d";
|
| 1479 |
$get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query , $email_sent_id ) );
|
|
@@ -1487,7 +1521,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 1487 |
}
|
| 1488 |
|
| 1489 |
$unsubscribe_query = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
| 1490 |
-
SET unsubscribe_link = '1'
|
| 1491 |
WHERE user_id= %d AND cart_ignored='0' ";
|
| 1492 |
$wpdb->query( $wpdb->prepare( $unsubscribe_query , $user_id ) );
|
| 1493 |
echo "Unsubscribed Successfully";
|
|
@@ -1544,8 +1578,11 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 1544 |
$url = substr( $link_decode, $url_pos );
|
| 1545 |
$get_ac_id_query = "SELECT abandoned_order_id FROM `".$wpdb->prefix."ac_sent_history_lite` WHERE id = %d";
|
| 1546 |
$get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query, $email_sent_id ) );
|
| 1547 |
-
$
|
| 1548 |
-
|
|
|
|
|
|
|
|
|
|
| 1549 |
$user_id = 0;
|
| 1550 |
if ( isset( $get_user_results ) && count( $get_user_results ) > 0 ) {
|
| 1551 |
$user_id = $get_user_results[0]->user_id;
|
|
@@ -1591,57 +1628,60 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 1591 |
|
| 1592 |
// load the information of the guest user
|
| 1593 |
function wcal_load_guest_persistent_cart() {
|
| 1594 |
-
|
| 1595 |
-
|
| 1596 |
-
|
| 1597 |
-
|
| 1598 |
-
|
| 1599 |
-
|
| 1600 |
-
|
| 1601 |
-
|
| 1602 |
-
|
| 1603 |
-
|
| 1604 |
-
|
| 1605 |
-
|
| 1606 |
-
|
| 1607 |
-
|
| 1608 |
-
|
| 1609 |
-
|
| 1610 |
-
|
| 1611 |
-
|
| 1612 |
-
|
| 1613 |
-
|
| 1614 |
-
|
| 1615 |
-
|
| 1616 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1617 |
}
|
| 1618 |
-
|
| 1619 |
-
$
|
| 1620 |
-
|
| 1621 |
-
|
| 1622 |
-
|
| 1623 |
-
|
| 1624 |
-
|
| 1625 |
-
|
| 1626 |
-
|
| 1627 |
-
|
| 1628 |
-
|
| 1629 |
-
|
| 1630 |
-
|
| 1631 |
-
|
| 1632 |
-
|
| 1633 |
-
|
| 1634 |
-
|
| 1635 |
-
|
| 1636 |
-
|
| 1637 |
-
|
| 1638 |
-
|
| 1639 |
-
|
| 1640 |
-
|
| 1641 |
-
|
| 1642 |
-
|
| 1643 |
-
$woocommerce->cart->subtotal_ex_tax = $subtotal_ex_tax;
|
| 1644 |
-
$woocommerce->cart->tax_total = $tax_total;
|
| 1645 |
}
|
| 1646 |
}
|
| 1647 |
}
|
|
@@ -1708,33 +1748,35 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 1708 |
$current_woo_cart = $abandoned_cart_arr;
|
| 1709 |
$abandoned_cart_arr = $temp_variable;
|
| 1710 |
}
|
| 1711 |
-
|
| 1712 |
-
|
| 1713 |
-
|
| 1714 |
-
$
|
| 1715 |
-
|
| 1716 |
-
|
| 1717 |
-
|
| 1718 |
-
|
| 1719 |
-
|
| 1720 |
-
|
| 1721 |
-
|
| 1722 |
-
|
| 1723 |
-
|
| 1724 |
-
|
| 1725 |
-
|
| 1726 |
-
|
| 1727 |
-
|
| 1728 |
-
|
| 1729 |
-
|
| 1730 |
-
|
| 1731 |
-
|
| 1732 |
-
|
| 1733 |
-
|
| 1734 |
-
|
| 1735 |
-
|
| 1736 |
-
|
| 1737 |
-
|
|
|
|
|
|
|
| 1738 |
}
|
| 1739 |
}
|
| 1740 |
}
|
|
@@ -1965,6 +2007,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 1965 |
$js_src = includes_url('js/tinymce/') . 'tinymce.min.js';
|
| 1966 |
wp_enqueue_script( 'tinyMce_ac',$js_src );
|
| 1967 |
wp_enqueue_script( 'ac_email_variables', plugins_url() . '/woocommerce-abandoned-cart/assets/js/abandoncart_plugin_button.js' );
|
|
|
|
| 1968 |
}
|
| 1969 |
}
|
| 1970 |
|
|
@@ -2001,6 +2044,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 2001 |
wp_enqueue_style( 'woocommerce_admin_styles', plugins_url() . '/woocommerce/assets/css/admin.css' );
|
| 2002 |
wp_enqueue_style( 'jquery-ui-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
|
| 2003 |
wp_enqueue_style( 'abandoned-orders-list', plugins_url() . '/woocommerce-abandoned-cart/assets/css/view.abandoned.orders.style.css' );
|
|
|
|
| 2004 |
|
| 2005 |
}
|
| 2006 |
}
|
|
@@ -2112,20 +2156,21 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 2112 |
<?php
|
| 2113 |
if ( $section == 'wcal_general_settings' || $section == '' ) {
|
| 2114 |
?>
|
| 2115 |
-
|
| 2116 |
-
|
| 2117 |
-
|
| 2118 |
-
|
| 2119 |
-
|
| 2120 |
-
|
| 2121 |
<?php
|
| 2122 |
} else if ( $section == 'wcal_email_settings' ) {
|
| 2123 |
-
|
|
|
|
| 2124 |
<?php settings_fields ( 'woocommerce_ac_email_settings' ); ?>
|
| 2125 |
<?php do_settings_sections( 'woocommerce_ac_email_page' ); ?>
|
| 2126 |
<?php settings_errors(); ?>
|
| 2127 |
<?php submit_button(); ?>
|
| 2128 |
-
|
| 2129 |
<?php
|
| 2130 |
}
|
| 2131 |
?>
|
|
@@ -2141,11 +2186,11 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 2141 |
$get_visitor_user_ac_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_visitor' );
|
| 2142 |
|
| 2143 |
$wcal_user_reg_text = 'User';
|
| 2144 |
-
if ( $get_registered_user_ac_count > 1){
|
| 2145 |
$wcal_user_reg_text = 'Users';
|
| 2146 |
}
|
| 2147 |
$wcal_user_gus_text = 'User';
|
| 2148 |
-
if ( $get_guest_user_ac_count > 1){
|
| 2149 |
$wcal_user_gus_text = 'Users';
|
| 2150 |
}
|
| 2151 |
$wcal_all_abandoned_carts = $section = $wcal_all_registered = $wcal_all_guest = $wcal_all_visitor = "" ;
|
|
@@ -2218,169 +2263,61 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 2218 |
// Save the field values
|
| 2219 |
$insert_template_successfuly = $update_template_successfuly = '';
|
| 2220 |
if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' ) {
|
| 2221 |
-
|
| 2222 |
-
|
| 2223 |
-
|
| 2224 |
-
|
| 2225 |
-
|
| 2226 |
-
|
| 2227 |
-
|
| 2228 |
-
|
| 2229 |
-
|
| 2230 |
-
|
| 2231 |
-
|
| 2232 |
-
|
| 2233 |
-
|
| 2234 |
-
|
| 2235 |
-
|
| 2236 |
-
|
| 2237 |
-
|
| 2238 |
-
|
| 2239 |
-
|
| 2240 |
-
|
| 2241 |
-
|
| 2242 |
-
|
| 2243 |
-
|
| 2244 |
-
|
| 2245 |
-
|
| 2246 |
-
$insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query,
|
| 2247 |
-
$woocommerce_ac_email_subject,
|
| 2248 |
-
$woocommerce_ac_email_body,
|
| 2249 |
-
$active_post,
|
| 2250 |
-
$email_frequency,
|
| 2251 |
-
$day_or_hour,
|
| 2252 |
-
$woocommerce_ac_template_name,
|
| 2253 |
-
$is_wc_template,
|
| 2254 |
-
$default_value,
|
| 2255 |
-
$woocommerce_ac_email_header)
|
| 2256 |
-
);
|
| 2257 |
-
} else {
|
| 2258 |
-
$update_is_active = 0;
|
| 2259 |
-
$query_update = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
|
| 2260 |
-
SET
|
| 2261 |
-
is_active = %s
|
| 2262 |
-
WHERE frequency = %d
|
| 2263 |
-
AND day_or_hour = %s ";
|
| 2264 |
-
$update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update, $update_is_active, $email_frequency, $day_or_hour ) );
|
| 2265 |
-
|
| 2266 |
-
$woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
|
| 2267 |
-
$woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
|
| 2268 |
-
$woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
|
| 2269 |
-
$woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
|
| 2270 |
-
$query_insert_new = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
|
| 2271 |
-
(subject, body, is_active, frequency, day_or_hour, template_name, is_wc_template, default_template, wc_email_header )
|
| 2272 |
-
VALUES ( %s, %s, %s, %d, %s, %s, %s, %d, %s )";
|
| 2273 |
-
|
| 2274 |
-
$insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query_insert_new,
|
| 2275 |
-
$woocommerce_ac_email_subject,
|
| 2276 |
-
$woocommerce_ac_email_body,
|
| 2277 |
-
$active_post,
|
| 2278 |
-
$email_frequency,
|
| 2279 |
-
$day_or_hour,
|
| 2280 |
-
$woocommerce_ac_template_name,
|
| 2281 |
-
$is_wc_template,
|
| 2282 |
-
$default_value,
|
| 2283 |
-
$woocommerce_ac_email_header )
|
| 2284 |
-
);
|
| 2285 |
-
}
|
| 2286 |
-
} else {
|
| 2287 |
-
$woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
|
| 2288 |
-
$woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
|
| 2289 |
-
$woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
|
| 2290 |
-
$woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
|
| 2291 |
-
$active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
| 2292 |
-
$email_frequency = trim( $_POST['email_frequency'] );
|
| 2293 |
-
$day_or_hour = trim( $_POST['day_or_hour'] );
|
| 2294 |
-
$is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
|
| 2295 |
-
$default_value = 0 ;
|
| 2296 |
-
|
| 2297 |
-
$query = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
|
| 2298 |
-
(subject, body, is_active, frequency, day_or_hour, template_name, is_wc_template, default_template, wc_email_header )
|
| 2299 |
-
VALUES ( %s, %s, %s, %d, %s, %s, %s, %d, %s )";
|
| 2300 |
-
|
| 2301 |
-
$insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query,
|
| 2302 |
-
$woocommerce_ac_email_subject,
|
| 2303 |
-
$woocommerce_ac_email_body,
|
| 2304 |
-
$active_post,
|
| 2305 |
-
$email_frequency,
|
| 2306 |
-
$day_or_hour,
|
| 2307 |
-
$woocommerce_ac_template_name,
|
| 2308 |
-
$is_wc_template,
|
| 2309 |
-
$default_value,
|
| 2310 |
-
$woocommerce_ac_email_header )
|
| 2311 |
-
);
|
| 2312 |
-
}
|
| 2313 |
}
|
| 2314 |
|
| 2315 |
if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' ) {
|
| 2316 |
-
|
| 2317 |
-
$
|
| 2318 |
|
| 2319 |
-
|
| 2320 |
-
|
| 2321 |
-
|
| 2322 |
-
|
| 2323 |
-
|
| 2324 |
-
|
| 2325 |
-
|
| 2326 |
-
|
| 2327 |
-
|
| 2328 |
-
|
| 2329 |
-
|
| 2330 |
-
|
| 2331 |
-
|
| 2332 |
-
|
| 2333 |
-
|
| 2334 |
-
|
| 2335 |
-
|
| 2336 |
-
$
|
| 2337 |
-
|
| 2338 |
-
|
| 2339 |
-
|
| 2340 |
-
|
| 2341 |
-
$query_update = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
|
| 2342 |
-
SET
|
| 2343 |
-
subject = %s,
|
| 2344 |
-
body = %s,
|
| 2345 |
-
is_active = %s,
|
| 2346 |
-
frequency = %d,
|
| 2347 |
-
day_or_hour = %s,
|
| 2348 |
-
template_name = %s,
|
| 2349 |
-
is_wc_template = %s,
|
| 2350 |
-
default_template = %d,
|
| 2351 |
-
wc_email_header = %s
|
| 2352 |
-
WHERE id = %d ";
|
| 2353 |
-
$update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update,
|
| 2354 |
-
$woocommerce_ac_email_subject,
|
| 2355 |
-
$woocommerce_ac_email_body,
|
| 2356 |
-
$active,
|
| 2357 |
-
$email_frequency,
|
| 2358 |
-
$day_or_hour,
|
| 2359 |
-
$woocommerce_ac_template_name,
|
| 2360 |
-
$is_wc_template,
|
| 2361 |
-
$default_value,
|
| 2362 |
-
$woocommerce_ac_email_header,
|
| 2363 |
-
$id )
|
| 2364 |
-
|
| 2365 |
-
);
|
| 2366 |
-
} else {
|
| 2367 |
-
$updated_is_active = 0;
|
| 2368 |
-
$query_update_new = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
|
| 2369 |
-
SET is_active = %s
|
| 2370 |
-
WHERE frequency = %d
|
| 2371 |
-
AND day_or_hour = %s ";
|
| 2372 |
-
$update_template_successfuly = $wpdb->query( $wpdb->prepare( $query_update_new, $updated_is_active, $email_frequency, $day_or_hour ) );
|
| 2373 |
-
$woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
|
| 2374 |
-
$woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
|
| 2375 |
-
$woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
|
| 2376 |
-
$woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
|
| 2377 |
-
$id = trim( $_POST['id'] );
|
| 2378 |
-
|
| 2379 |
-
$query_update_latest = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
|
| 2380 |
SET
|
| 2381 |
subject = %s,
|
| 2382 |
body = %s,
|
| 2383 |
-
is_active = %s,
|
| 2384 |
frequency = %d,
|
| 2385 |
day_or_hour = %s,
|
| 2386 |
template_name = %s,
|
|
@@ -2388,75 +2325,19 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 2388 |
default_template = %d,
|
| 2389 |
wc_email_header = %s
|
| 2390 |
WHERE id = %d ";
|
| 2391 |
-
$update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update_latest,
|
| 2392 |
-
$woocommerce_ac_email_subject,
|
| 2393 |
-
$woocommerce_ac_email_body,
|
| 2394 |
-
$active,
|
| 2395 |
-
$email_frequency,
|
| 2396 |
-
$day_or_hour,
|
| 2397 |
-
$woocommerce_ac_template_name,
|
| 2398 |
-
$is_wc_template,
|
| 2399 |
-
$default_value,
|
| 2400 |
-
$woocommerce_ac_email_header,
|
| 2401 |
-
$id )
|
| 2402 |
-
|
| 2403 |
-
);
|
| 2404 |
-
}
|
| 2405 |
-
} else {
|
| 2406 |
-
$updated_is_active = '0';
|
| 2407 |
-
$is_active = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
| 2408 |
-
$email_frequency = trim( $_POST['email_frequency'] );
|
| 2409 |
-
$day_or_hour = trim( $_POST['day_or_hour'] );
|
| 2410 |
-
$is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
|
| 2411 |
|
| 2412 |
-
|
| 2413 |
-
|
| 2414 |
-
|
| 2415 |
-
|
| 2416 |
-
|
| 2417 |
-
|
| 2418 |
-
|
| 2419 |
-
|
| 2420 |
-
|
| 2421 |
-
|
| 2422 |
-
|
| 2423 |
-
|
| 2424 |
-
WHERE is_active= %s
|
| 2425 |
-
AND frequency = %d
|
| 2426 |
-
AND day_or_hour= %s ";
|
| 2427 |
-
$check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $is_active, $email_frequency, $day_or_hour ) );
|
| 2428 |
-
$default_value = '';
|
| 2429 |
-
|
| 2430 |
-
foreach( $check_results as $result_key => $result_value ) {
|
| 2431 |
-
$default_value = ( empty( $result_value->default_template ) ) ? 0 : $result_value->default_template;
|
| 2432 |
-
}
|
| 2433 |
-
|
| 2434 |
-
$query_update_latest = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
|
| 2435 |
-
SET
|
| 2436 |
-
subject = %s,
|
| 2437 |
-
body = %s,
|
| 2438 |
-
is_active = %s,
|
| 2439 |
-
frequency = %d,
|
| 2440 |
-
day_or_hour = %s,
|
| 2441 |
-
template_name = %s,
|
| 2442 |
-
is_wc_template = %s,
|
| 2443 |
-
default_template = %d,
|
| 2444 |
-
wc_email_header = %s
|
| 2445 |
-
WHERE id = %d ";
|
| 2446 |
-
|
| 2447 |
-
$update_template_successfuly = $wpdb->query( $wpdb->prepare( $query_update_latest,
|
| 2448 |
-
$woocommerce_ac_email_subject,
|
| 2449 |
-
$woocommerce_ac_email_body,
|
| 2450 |
-
$is_active,
|
| 2451 |
-
$email_frequency,
|
| 2452 |
-
$day_or_hour,
|
| 2453 |
-
$woocommerce_ac_template_name,
|
| 2454 |
-
$is_wc_template,
|
| 2455 |
-
$default_value,
|
| 2456 |
-
$woocommerce_ac_email_header,
|
| 2457 |
-
$id )
|
| 2458 |
-
);
|
| 2459 |
-
}
|
| 2460 |
}
|
| 2461 |
|
| 2462 |
if ( $action == 'emailtemplates' && $mode == 'removetemplate' ) {
|
|
@@ -2492,24 +2373,49 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 2492 |
}
|
| 2493 |
|
| 2494 |
if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' && ( isset( $insert_template_successfuly ) && $insert_template_successfuly != '' ) ) { ?>
|
| 2495 |
-
<div id="message" class="updated fade"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2496 |
<?php } else if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' && ( isset( $insert_template_successfuly ) && $insert_template_successfuly == '' ) ) {
|
| 2497 |
?>
|
| 2498 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2499 |
<?php
|
| 2500 |
}
|
| 2501 |
|
| 2502 |
if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' && isset($update_template_successfuly) && $update_template_successfuly >= 0 ) { ?>
|
| 2503 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2504 |
<?php } else if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' && isset($update_template_successfuly) && $update_template_successfuly === false ){
|
| 2505 |
?>
|
| 2506 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2507 |
<?php
|
| 2508 |
}
|
| 2509 |
?>
|
| 2510 |
<div class="tablenav">
|
| 2511 |
<p style="float:left;">
|
| 2512 |
-
<a cursor: pointer; href="<?php echo "admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=addnewtemplate"; ?>" class="button-secondary"><?php _e( 'Add New Template', 'woocommerce-ac' );
|
|
|
|
| 2513 |
</p>
|
| 2514 |
|
| 2515 |
<?php
|
|
@@ -2531,46 +2437,31 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 2531 |
?>
|
| 2532 |
<p>
|
| 2533 |
<script language='javascript'>
|
| 2534 |
-
jQuery( document ).ready( function()
|
| 2535 |
-
|
| 2536 |
-
jQuery( '#duration_select' ).change( function()
|
| 2537 |
-
{
|
| 2538 |
var group_name = jQuery( '#duration_select' ).val();
|
| 2539 |
var today = new Date();
|
| 2540 |
var start_date = "";
|
| 2541 |
var end_date = "";
|
| 2542 |
-
if ( group_name == "yesterday" )
|
| 2543 |
-
{
|
| 2544 |
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 1 );
|
| 2545 |
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 1 );
|
| 2546 |
-
}
|
| 2547 |
-
else if ( group_name == "today")
|
| 2548 |
-
{
|
| 2549 |
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
| 2550 |
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
| 2551 |
-
}
|
| 2552 |
-
else if ( group_name == "last_seven" )
|
| 2553 |
-
{
|
| 2554 |
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 7 );
|
| 2555 |
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
| 2556 |
-
}
|
| 2557 |
-
else if ( group_name == "last_fifteen" )
|
| 2558 |
-
{
|
| 2559 |
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 15 );
|
| 2560 |
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
| 2561 |
-
}
|
| 2562 |
-
else if ( group_name == "last_thirty" )
|
| 2563 |
-
{
|
| 2564 |
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 30 );
|
| 2565 |
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
| 2566 |
-
}
|
| 2567 |
-
else if ( group_name == "last_ninety" )
|
| 2568 |
-
{
|
| 2569 |
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 90 );
|
| 2570 |
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
| 2571 |
-
}
|
| 2572 |
-
else if ( group_name == "last_year_days" )
|
| 2573 |
-
{
|
| 2574 |
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 365 );
|
| 2575 |
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
| 2576 |
}
|
|
@@ -2583,8 +2474,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 2583 |
|
| 2584 |
jQuery( '#start_date' ).val( start_date_value );
|
| 2585 |
jQuery( '#end_date' ).val( end_date_value );
|
| 2586 |
-
|
| 2587 |
-
});
|
| 2588 |
});
|
| 2589 |
</script>
|
| 2590 |
<?php
|
|
@@ -2601,7 +2491,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 2601 |
}
|
| 2602 |
if ($duration_range == "") $duration_range = "last_seven";
|
| 2603 |
|
| 2604 |
-
|
| 2605 |
?>
|
| 2606 |
<div id="recovered_stats" class="postbox" style="display:block">
|
| 2607 |
<div class="inside">
|
|
@@ -2721,12 +2611,16 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 2721 |
if ( $results[0]->user_type == "GUEST" && "0" != $results[0]->user_id ) {
|
| 2722 |
$query_guest = "SELECT * FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d";
|
| 2723 |
$results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $results[0]->user_id ) );
|
| 2724 |
-
$user_email
|
| 2725 |
-
$
|
| 2726 |
-
|
| 2727 |
-
|
| 2728 |
-
|
| 2729 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2730 |
$user_billing_company = $user_billing_address_1 = $user_billing_address_2 = $user_billing_city = $user_billing_state = $user_billing_country = $user_billing_phone = "";
|
| 2731 |
$user_shipping_company = $user_shipping_address_1 = $user_shipping_address_2 = $user_shipping_city = $user_shipping_state = $user_shipping_country = "";
|
| 2732 |
} else if ( $results[0]->user_type == "GUEST" && $results[0]->user_id == "0" ) {
|
|
@@ -2747,14 +2641,22 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 2747 |
$user_email = get_user_meta( $results[0]->user_id, 'billing_email', true );
|
| 2748 |
if( "" == $user_email ) {
|
| 2749 |
$user_data = get_userdata( $results[0]->user_id );
|
| 2750 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2751 |
}
|
| 2752 |
|
| 2753 |
$user_first_name = "";
|
| 2754 |
$user_first_name_temp = get_user_meta( $user_id, 'billing_first_name', true );
|
| 2755 |
if( isset( $user_first_name_temp ) && "" == $user_first_name_temp ) {
|
| 2756 |
$user_data = get_userdata( $user_id );
|
| 2757 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2758 |
} else {
|
| 2759 |
$user_first_name = $user_first_name_temp;
|
| 2760 |
}
|
|
@@ -2762,7 +2664,11 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 2762 |
$user_last_name_temp = get_user_meta( $user_id, 'billing_last_name', true );
|
| 2763 |
if( isset( $user_last_name_temp ) && "" == $user_last_name_temp ) {
|
| 2764 |
$user_data = get_userdata( $user_id );
|
| 2765 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2766 |
} else {
|
| 2767 |
$user_last_name = $user_last_name_temp;
|
| 2768 |
}
|
|
@@ -2878,43 +2784,32 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 2878 |
$name = $variation->get_formatted_name() ;
|
| 2879 |
$explode_all = explode ( "–", $name );
|
| 2880 |
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
| 2881 |
-
$
|
| 2882 |
-
|
| 2883 |
-
|
| 2884 |
-
$add_product_name = $explode_attributes[0];
|
| 2885 |
-
$add_product_name = rtrim( $add_product_name );
|
| 2886 |
-
if ( $product_name == $add_product_name ) {
|
| 2887 |
-
$wcal_selected_variation = '';
|
| 2888 |
-
$wcal_all_attribute = $v->variation;
|
| 2889 |
-
$variation_id_only = $v->variation_id;
|
| 2890 |
-
foreach ($wcal_all_attribute as $wcal_all_attribute_key => $wcal_all_attribute_value) {
|
| 2891 |
-
$taxonomy = explode( 'attribute_', $wcal_all_attribute_key );
|
| 2892 |
-
$meta = get_post_meta( $variation_id_only, $wcal_all_attribute_key, true );
|
| 2893 |
-
$term = get_term_by( 'slug', $meta, $taxonomy[1] );
|
| 2894 |
-
$variation_name_only = $term->name;
|
| 2895 |
-
$wcal_selected_variation .= $variation_name_only . "<br>";
|
| 2896 |
-
}
|
| 2897 |
-
$add_product_name = $product_name . ' - ' . $wcal_selected_variation;
|
| 2898 |
-
}
|
| 2899 |
-
$pro_name_variation = (array) $add_product_name;
|
| 2900 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2901 |
}else{
|
| 2902 |
-
$pro_name_variation
|
| 2903 |
}
|
| 2904 |
$product_name_with_variable = '';
|
| 2905 |
-
$explode_many_varaition = array();
|
| 2906 |
-
foreach
|
| 2907 |
$explode_many_varaition = explode ( ",", $pro_name_variation_value );
|
| 2908 |
-
if
|
| 2909 |
-
foreach( $explode_many_varaition as $explode_many_varaition_key => $explode_many_varaition_value ){
|
| 2910 |
-
$product_name_with_variable = $product_name_with_variable .
|
| 2911 |
}
|
| 2912 |
} else {
|
| 2913 |
-
$product_name_with_variable = $product_name_with_variable .
|
| 2914 |
}
|
| 2915 |
-
}
|
| 2916 |
$product_name = $product_name_with_variable;
|
| 2917 |
-
}
|
| 2918 |
// Item subtotal is calculated as product total including taxes
|
| 2919 |
if ( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
|
| 2920 |
$item_subtotal = $item_subtotal + $v->line_total + $v->line_subtotal_tax;
|
|
@@ -3010,7 +2905,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 3010 |
<form id="wcal-sent-emails" method="get" >
|
| 3011 |
<input type="hidden" name="page" value="woocommerce_ac_page" />
|
| 3012 |
<input type="hidden" name="action" value="report" />
|
| 3013 |
-
|
| 3014 |
</form>
|
| 3015 |
</div>
|
| 3016 |
<?php }
|
|
@@ -3024,32 +2919,36 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 3024 |
$mode = $_GET['mode'];
|
| 3025 |
}
|
| 3026 |
if ( $action == 'emailtemplates' && ( $mode == 'addnewtemplate' || $mode == 'edittemplate' ) ) {
|
| 3027 |
-
if ( $mode=='edittemplate' ) {
|
| 3028 |
-
$
|
| 3029 |
-
|
| 3030 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3031 |
}
|
| 3032 |
$active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
| 3033 |
?>
|
| 3034 |
<div id="content">
|
| 3035 |
<form method="post" action="admin.php?page=woocommerce_ac_page&action=emailtemplates" id="ac_settings">
|
| 3036 |
<input type="hidden" name="mode" value="<?php echo $mode;?>" />
|
| 3037 |
-
|
| 3038 |
-
|
| 3039 |
-
|
| 3040 |
$id_by = $_GET['id'];
|
| 3041 |
-
|
| 3042 |
-
|
| 3043 |
-
|
| 3044 |
-
|
| 3045 |
-
|
| 3046 |
-
|
| 3047 |
-
|
| 3048 |
-
|
| 3049 |
-
|
| 3050 |
-
|
| 3051 |
-
|
| 3052 |
-
|
| 3053 |
<div> <!-- <div class="postbox" > -->
|
| 3054 |
<h3 class="hndle"><?php _e( $display_message, 'woocommerce-ac' ); ?></h3>
|
| 3055 |
<div>
|
|
@@ -3061,7 +2960,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 3061 |
<td>
|
| 3062 |
<?php
|
| 3063 |
$template_name = "";
|
| 3064 |
-
if( $mode == 'edittemplate' ) {
|
| 3065 |
$template_name = $results[0]->template_name;
|
| 3066 |
}
|
| 3067 |
print'<input type="text" name="woocommerce_ac_template_name" id="woocommerce_ac_template_name" class="regular-text" value="'.$template_name.'">';?>
|
|
@@ -3076,7 +2975,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 3076 |
<td>
|
| 3077 |
<?php
|
| 3078 |
$subject_edit = "";
|
| 3079 |
-
if ( $mode == 'edittemplate' ) {
|
| 3080 |
$subject_edit= stripslashes ( $results[0]->subject );
|
| 3081 |
}
|
| 3082 |
print'<input type="text" name="woocommerce_ac_email_subject" id="woocommerce_ac_email_subject" class="regular-text" value="'.$subject_edit.'">';?>
|
|
@@ -3091,7 +2990,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 3091 |
<td>
|
| 3092 |
<?php
|
| 3093 |
$initial_data = "";
|
| 3094 |
-
if ( $mode == 'edittemplate' ) {
|
| 3095 |
$initial_data = stripslashes( $results[0]->body );
|
| 3096 |
}
|
| 3097 |
|
|
@@ -3124,7 +3023,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 3124 |
<td>
|
| 3125 |
<?php
|
| 3126 |
$is_wc_template = "";
|
| 3127 |
-
if ( $mode == 'edittemplate' ) {
|
| 3128 |
$use_wc_template = $results[0]->is_wc_template;
|
| 3129 |
|
| 3130 |
if ( $use_wc_template == '1' ) {
|
|
@@ -3148,7 +3047,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 3148 |
<?php
|
| 3149 |
|
| 3150 |
$wcal_wc_email_header = "";
|
| 3151 |
-
if ( $mode == 'edittemplate'
|
| 3152 |
$wcal_wc_email_header = $results[0]->wc_email_header;
|
| 3153 |
}
|
| 3154 |
if ( $wcal_wc_email_header == "" ) {
|
|
@@ -3167,7 +3066,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 3167 |
<select name="email_frequency" id="email_frequency">
|
| 3168 |
<?php
|
| 3169 |
$frequency_edit = "";
|
| 3170 |
-
if( $mode == 'edittemplate' ) {
|
| 3171 |
$frequency_edit = $results[0]->frequency;
|
| 3172 |
}
|
| 3173 |
for ( $i = 1; $i < 4; $i++ ) {
|
|
@@ -3183,7 +3082,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 3183 |
<select name="day_or_hour" id="day_or_hour">
|
| 3184 |
<?php
|
| 3185 |
$days_or_hours_edit = "";
|
| 3186 |
-
if ( $mode == 'edittemplate')
|
| 3187 |
{
|
| 3188 |
$days_or_hours_edit = $results[0]->day_or_hour;
|
| 3189 |
}
|
|
@@ -3313,19 +3212,18 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 3313 |
is_wc_template : is_wc_template,
|
| 3314 |
wc_template_header : wc_template_header,
|
| 3315 |
action : 'wcal_preview_email_sent'
|
| 3316 |
-
|
| 3317 |
|
| 3318 |
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
| 3319 |
-
$.post( ajaxurl, data, function( response )
|
| 3320 |
-
{
|
| 3321 |
if ( 'not sent' == response ) {
|
| 3322 |
-
|
| 3323 |
-
|
| 3324 |
-
|
| 3325 |
} else {
|
| 3326 |
-
|
| 3327 |
-
|
| 3328 |
-
|
| 3329 |
}
|
| 3330 |
//alert('Got this from the server: ' + response);
|
| 3331 |
});
|
|
@@ -3334,6 +3232,46 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 3334 |
</script>
|
| 3335 |
<?php
|
| 3336 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3337 |
// Send Test Email
|
| 3338 |
function wcal_preview_email_sent() {
|
| 3339 |
if ( '' != $_POST['body_email_preview'] ) {
|
|
@@ -3356,6 +3294,8 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 3356 |
$cart_url = wc_get_page_permalink( 'cart' );
|
| 3357 |
$body_email_preview = str_replace( '{{cart.link}}', $cart_url, $body_email_preview );
|
| 3358 |
$body_email_preview = str_replace( '{{cart.unsubscribe}}', '<a href=#>unsubscribe</a>', $body_email_preview );
|
|
|
|
|
|
|
| 3359 |
if ( class_exists( 'WP_Better_Emails' ) ) {
|
| 3360 |
$headers = "From: " . $from_email_name . " <" . $from_email_preview . ">" . "\r\n";
|
| 3361 |
$headers .= "Content-Type: text/plain" . "\r\n";
|
|
@@ -3373,22 +3313,22 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 3373 |
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/shoes.jpg"/></td>
|
| 3374 |
<td>'.__( "Men\'\s Formal Shoes", "woocommerce-ac" ).'</td>
|
| 3375 |
<td>1</td>
|
| 3376 |
-
<td
|
| 3377 |
-
<td
|
| 3378 |
</tr>
|
| 3379 |
<tr align="center">
|
| 3380 |
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/handbag.jpg"/></td>
|
| 3381 |
<td>'.__( "Woman\'\s Hand Bags", "woocommerce-ac" ).'</td>
|
| 3382 |
<td>1</td>
|
| 3383 |
-
<td
|
| 3384 |
-
<td
|
| 3385 |
</tr>
|
| 3386 |
<tr align="center">
|
| 3387 |
<td></td>
|
| 3388 |
<td></td>
|
| 3389 |
<td></td>
|
| 3390 |
<td>'.__( "Cart Total:", "woocommerce-ac" ).'</td>
|
| 3391 |
-
<td
|
| 3392 |
</tr>
|
| 3393 |
</table>';
|
| 3394 |
} else {
|
|
@@ -3408,22 +3348,22 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
| 3408 |
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/shoes.jpg"/></td>
|
| 3409 |
<td>'.__( "Men\'\s Formal Shoes", "woocommerce-ac" ).'</td>
|
| 3410 |
<td>1</td>
|
| 3411 |
-
<td
|
| 3412 |
-
<td
|
| 3413 |
</tr>
|
| 3414 |
<tr align="center">
|
| 3415 |
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/handbag.jpg"/></td>
|
| 3416 |
<td>'.__( "Woman\'\s Hand Bags", "woocommerce-ac" ).'</td>
|
| 3417 |
<td>1</td>
|
| 3418 |
-
<td
|
| 3419 |
-
<td
|
| 3420 |
</tr>
|
| 3421 |
<tr align="center">
|
| 3422 |
<td></td>
|
| 3423 |
<td></td>
|
| 3424 |
<td></td>
|
| 3425 |
<td>'.__( "Cart Total:", "woocommerce-ac" ).'</td>
|
| 3426 |
-
<td
|
| 3427 |
</tr>
|
| 3428 |
</table>';
|
| 3429 |
}
|
| 1 |
<?php
|
| 2 |
/*
|
| 3 |
+
* Plugin Name: Abandoned Cart Lite for WooCommerce
|
| 4 |
+
* Plugin URI: http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro
|
| 5 |
+
* Description: This plugin captures abandoned carts by logged-in users & emails them about it. <strong><a href="http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro">Click here to get the PRO Version.</a></strong>
|
| 6 |
+
* Version: 4.4
|
| 7 |
+
* Author: Tyche Softwares
|
| 8 |
+
* Author URI: http://www.tychesoftwares.com/
|
| 9 |
+
* Text Domain: woocommerce-ac
|
| 10 |
+
* Domain Path: /i18n/languages/
|
| 11 |
+
* Requires PHP: 5.6
|
| 12 |
+
* WC requires at least: 3.0.0
|
| 13 |
+
* WC tested up to: 3.2.0
|
| 14 |
*/
|
| 15 |
|
| 16 |
// Deletion Settings
|
| 60 |
add_action( 'woocommerce_ac_send_email_action', 'wcal_send_email_cron' );
|
| 61 |
|
| 62 |
function wcal_send_email_cron() {
|
| 63 |
+
//require_once( ABSPATH.'wp-content/plugins/woocommerce-abandoned-cart/cron/send_email.php' );
|
| 64 |
$plugin_dir_path = plugin_dir_path( __FILE__ );
|
| 65 |
require_once( $plugin_dir_path . 'cron/wcal_send_email.php' );
|
| 66 |
}
|
| 222 |
if ( is_admin() ) {
|
| 223 |
// Load "admin-only" scripts here
|
| 224 |
add_action ( 'admin_head', array( &$this, 'wcal_action_send_preview' ) );
|
| 225 |
+
add_action ( 'wp_ajax_wcal_preview_email_sent', array( &$this, 'wcal_preview_email_sent' ) );
|
| 226 |
+
add_action ( 'wp_ajax_wcal_toggle_template_status', array( &$this, 'wcal_toggle_template_status' ) );
|
| 227 |
}
|
| 228 |
|
| 229 |
// Send Email on order recovery
|
| 233 |
add_action( 'woocommerce_order_status_failed_to_processing_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
| 234 |
add_action( 'woocommerce_order_status_failed_to_completed_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
| 235 |
|
| 236 |
+
add_action('woocommerce_order_status_changed', array( &$this, 'wcal_email_admin_recovery_for_paypal' ), 10, 3);
|
| 237 |
|
| 238 |
add_action( 'admin_init', array( $this, 'wcal_preview_emails' ) );
|
| 239 |
add_action( 'init', array( $this, 'wcal_app_output_buffer') );
|
| 240 |
add_action( 'admin_init', array( &$this, 'wcal_check_pro_activated' ) );
|
| 241 |
add_action( 'woocommerce_checkout_order_processed', array( &$this, 'wcal_order_placed' ), 10 , 1 );
|
| 242 |
+
add_filter( 'woocommerce_payment_complete_order_status', array( &$this, 'wcal_order_complete_action' ), 10 , 2 );
|
| 243 |
add_filter( 'admin_footer_text', array( $this, 'wcal_admin_footer_text' ), 1 );
|
| 244 |
|
| 245 |
+
add_action( 'admin_notices', array( 'Wcal_Admin_Notice', 'wcal_pro_notice' ) );
|
| 246 |
add_action( 'admin_init', array( 'Wcal_Admin_Notice', 'wcal_pro_notice_ignore' ) );
|
| 247 |
|
| 248 |
+
/**
|
| 249 |
+
* @since: 4.2
|
| 250 |
+
* Check if WC is enabled or not.
|
| 251 |
+
*/
|
| 252 |
add_action( 'admin_init', array( &$this, 'wcal_wc_check_compatibility' ) );
|
| 253 |
}
|
| 254 |
|
| 325 |
$get_ac_id_query = "SELECT abandoned_order_id FROM ". $wcal_sent_email_table_name ." WHERE id = %d";
|
| 326 |
$get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query, $email_sent_id ) );
|
| 327 |
|
| 328 |
+
$abandoned_order_id = '';
|
| 329 |
+
if ( count( $get_ac_id_results ) > 0 ) {
|
| 330 |
+
$abandoned_order_id = $get_ac_id_results[0]->abandoned_order_id;
|
| 331 |
+
}
|
| 332 |
|
| 333 |
$wcal_account_password_check = 'no';
|
| 334 |
|
| 335 |
/*if user becomes the registered user */
|
| 336 |
if ( isset( $_POST['account_password'] ) && $_POST['account_password'] != '' ) {
|
| 337 |
|
| 338 |
+
$abandoned_cart_id_new_user = '';
|
| 339 |
+
if ( isset( $_SESSION['abandoned_cart_id_lite'] ) && '' != $_SESSION['abandoned_cart_id_lite'] ) {
|
| 340 |
+
$abandoned_cart_id_new_user = $_SESSION['abandoned_cart_id_lite'];
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
$wcal_user_id_of_guest = '';
|
| 344 |
+
if ( isset( $_SESSION['user_id'] ) && '' != $_SESSION['user_id'] ) {
|
| 345 |
+
$wcal_user_id_of_guest = $_SESSION['user_id'];
|
| 346 |
+
}
|
| 347 |
|
| 348 |
/* delete the guest record. As it become the logged in user */
|
| 349 |
|
| 350 |
+
$get_ac_id_guest_results = array();
|
| 351 |
+
if ( isset( $wcal_user_id_of_guest ) && '' != $wcal_user_id_of_guest ) {
|
| 352 |
+
$get_ac_id_guest_query = "SELECT id FROM `" . $wcal_history_table_name ."` WHERE user_id = %d ORDER BY id DESC";
|
| 353 |
+
$get_ac_id_guest_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_guest_query, $wcal_user_id_of_guest ) );
|
| 354 |
+
}
|
| 355 |
|
| 356 |
if ( count ($get_ac_id_guest_results) > 1 ) {
|
| 357 |
$abandoned_order_id_of_guest = $get_ac_id_guest_results[0]->id;
|
| 358 |
$wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_order_id_of_guest ) );
|
| 359 |
}
|
| 360 |
+
if ( isset( $abandoned_cart_id_new_user ) && '' != $abandoned_cart_id_new_user ) {
|
| 361 |
+
/* it is the new registered users cart id */
|
| 362 |
+
$wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_cart_id_new_user ) );
|
| 363 |
+
}
|
| 364 |
|
| 365 |
$wcal_account_password_check = 'yes';
|
| 366 |
}
|
| 371 |
$_POST['createaccount'] != '' &&
|
| 372 |
'no' == $wcal_account_password_check ) {
|
| 373 |
|
| 374 |
+
$abandoned_cart_id_new_user = '';
|
| 375 |
+
if ( isset ( $_SESSION['abandoned_cart_id_lite'] ) && '' != $_SESSION['abandoned_cart_id_lite'] ) {
|
| 376 |
+
$abandoned_cart_id_new_user = $_SESSION['abandoned_cart_id_lite'];
|
| 377 |
+
}
|
| 378 |
+
$wcal_user_id_of_guest = '';
|
| 379 |
+
if ( isset( $_SESSION['user_id'] ) && '' != $_SESSION['user_id'] ) {
|
| 380 |
+
$wcal_user_id_of_guest = $_SESSION['user_id'];
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
|
| 384 |
/* delete the guest record. As it become the logged in user */
|
| 385 |
+
$get_ac_id_guest_results = array();
|
| 386 |
+
if ( isset( $wcal_user_id_of_guest ) && '' != $wcal_user_id_of_guest ) {
|
| 387 |
+
$get_ac_id_guest_query = "SELECT id FROM `" . $wcal_history_table_name ."` WHERE user_id = %d ORDER BY id DESC";
|
| 388 |
+
$get_ac_id_guest_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_guest_query, $wcal_user_id_of_guest ) );
|
| 389 |
+
}
|
| 390 |
if ( count ($get_ac_id_guest_results) > 1 ){
|
| 391 |
$abandoned_order_id_of_guest = $get_ac_id_guest_results[0]->id;
|
| 392 |
$wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_order_id_of_guest ) );
|
| 393 |
}
|
| 394 |
|
| 395 |
/* it is the new registered users cart id */
|
| 396 |
+
if ( isset( $wcal_user_id_of_guest ) && '' != $wcal_user_id_of_guest ) {
|
| 397 |
+
$wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_cart_id_new_user ) );
|
| 398 |
+
}
|
| 399 |
|
| 400 |
$wcap_create_account = 'yes';
|
| 401 |
}
|
| 402 |
|
| 403 |
if ( 'no' == $wcal_account_password_check && 'no' == $wcap_create_account ) {
|
| 404 |
|
| 405 |
+
$wcal_user_id_of_guest = '';
|
| 406 |
+
if ( isset( $_SESSION['user_id'] ) && '' != $_SESSION['user_id'] ) {
|
| 407 |
+
$wcal_user_id_of_guest = $_SESSION['user_id'];
|
| 408 |
+
$get_ac_id_guest_query = "SELECT id FROM `" . $wcal_history_table_name ."` WHERE user_id = %d ORDER BY id DESC";
|
| 409 |
+
$get_ac_id_guest_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_guest_query, $wcal_user_id_of_guest ) );
|
| 410 |
|
| 411 |
+
if ( count ($get_ac_id_guest_results) > 1 ) {
|
| 412 |
+
$abandoned_order_id_of_guest = $get_ac_id_guest_results[0]->id;
|
| 413 |
+
$wpdb->delete( $wcal_history_table_name, array( 'id' => $abandoned_order_id_of_guest ) );
|
| 414 |
+
}
|
|
|
|
|
|
|
| 415 |
}
|
| 416 |
}
|
| 417 |
|
| 418 |
add_post_meta( $order_id , 'wcal_recover_order_placed_sent_id', $email_sent_id );
|
| 419 |
+
if ( isset( $abandoned_order_id ) && '' != $abandoned_order_id ) {
|
| 420 |
+
add_post_meta( $order_id , 'wcal_recover_order_placed', $abandoned_order_id );
|
| 421 |
+
}
|
| 422 |
|
| 423 |
}else if ( isset( $_SESSION['abandoned_cart_id_lite'] ) && $_SESSION['abandoned_cart_id_lite'] != '' ) {
|
| 424 |
|
| 425 |
+
/**
|
| 426 |
+
* In this codition we are cheking that if the order is placed before the cart cut off time then we
|
| 427 |
+
* will delete the abandond cart records.
|
| 428 |
+
* If the order is placed after the cart cutoff time then we will create the post meta with
|
| 429 |
+
* the abandoned cart id. So we will refer this abandoned cart id when order staus is changed
|
| 430 |
+
* while placing the order.
|
| 431 |
+
*/
|
| 432 |
+
if( session_id() === '' ){
|
| 433 |
+
//session has not started
|
| 434 |
+
session_start();
|
| 435 |
+
}
|
| 436 |
|
| 437 |
+
global $woocommerce, $wpdb;
|
| 438 |
|
| 439 |
+
$wcal_history_table_name = $wpdb->prefix . 'ac_abandoned_cart_history_lite';
|
| 440 |
+
$wcal_guest_table_name = $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite';
|
| 441 |
+
$wcal_sent_email_table_name = $wpdb->prefix . 'ac_sent_history_lite';
|
| 442 |
|
| 443 |
+
$current_time = current_time( 'timestamp' );
|
| 444 |
+
$wcal_cart_abandoned_time = '';
|
| 445 |
+
if ( isset( $_SESSION['abandoned_cart_id_lite'] ) && '' != $_SESSION['abandoned_cart_id_lite'] ) {
|
| 446 |
$wcal_abandoned_cart_id = $_SESSION['abandoned_cart_id_lite'];
|
|
|
|
| 447 |
|
| 448 |
$get_abandoned_cart_query = "SELECT abandoned_cart_time FROM `" . $wcal_history_table_name . "` WHERE id = %d ";
|
| 449 |
$get_abandoned_cart_results = $wpdb->get_results( $wpdb->prepare( $get_abandoned_cart_query, $wcal_abandoned_cart_id ) );
|
| 458 |
|
| 459 |
if ( $compare_time > $wcal_cart_abandoned_time ) {
|
| 460 |
/* cart is declared as adandoned */
|
|
|
|
| 461 |
add_post_meta( $order_id , 'wcal_recover_order_placed', $wcal_abandoned_cart_id );
|
| 462 |
}else {
|
| 463 |
+
/* cart order is placed within the cutoff time.
|
| 464 |
+
we will delete that abandoned cart */
|
| 465 |
|
| 466 |
+
/* if user becomes the registred user */
|
| 467 |
|
| 468 |
+
if ( isset( $_POST['account_password'] ) && $_POST['account_password'] != '' ) {
|
| 469 |
|
| 470 |
+
$abandoned_cart_id_new_user = $_SESSION['abandoned_cart_id_lite'];
|
| 471 |
+
$wcal_user_id_of_guest = $_SESSION['user_id'];
|
| 472 |
|
| 473 |
+
/* delete the guest record. As it become the logged in user */
|
| 474 |
|
| 475 |
+
$wpdb->delete( $wcal_history_table_name , array( 'user_id' => $wcal_user_id_of_guest ) );
|
| 476 |
+
$wpdb->delete( $wcal_guest_table_name , array( 'id' => $wcal_user_id_of_guest ) );
|
| 477 |
|
| 478 |
+
/* it is the new registered users cart id */
|
| 479 |
+
$wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_cart_id_new_user ) );
|
| 480 |
+
}else {
|
| 481 |
|
| 482 |
+
/**
|
| 483 |
+
* It will delete the order from history table if the order is placed before any email sent to
|
| 484 |
+
* the user.
|
| 485 |
+
*/
|
| 486 |
+
$wpdb->delete( $wcal_history_table_name , array( 'id' => $wcap_abandoned_cart_id ) );
|
| 487 |
|
| 488 |
+
/* this user id is set for the guest uesrs. */
|
| 489 |
+
if ( isset( $_SESSION['user_id'] ) && $_SESSION['user_id'] != '' ) {
|
| 490 |
|
| 491 |
+
$wcal_user_id_of_guest = $_SESSION['user_id'];
|
| 492 |
+
$wpdb->delete( $wcal_guest_table_name, array( 'id' => $wcal_user_id_of_guest ) );
|
| 493 |
+
}
|
| 494 |
+
}
|
| 495 |
+
}
|
| 496 |
}
|
| 497 |
}
|
| 498 |
}
|
| 567 |
* activated with PRO version is activated.
|
| 568 |
*/
|
| 569 |
public static function wcal_check_pro_notice() {
|
| 570 |
+
$class = 'notice notice-error is-dismissible';
|
| 571 |
$message = __( 'The Lite & Pro version of Abandoned Cart plugin for WooCommerce (from Tyche Softwares) are active on your website. <br> In this case, the abandoned carts will be captured in both plugins & email reminders will also be sent from both plugins. <br> It is recommended that you deactivate the Lite version & keep the Pro version active.', 'woocommerce-ac' );
|
| 572 |
printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
|
| 573 |
}
|
| 595 |
include( 'views/wcal-wc-email-template-preview.php' );
|
| 596 |
$mailer = WC()->mailer();
|
| 597 |
$message = ob_get_clean();
|
| 598 |
+
$email_heading = __( 'HTML Email Template', 'woocommerce-ac' );
|
| 599 |
$message = $mailer->wrap_message( $email_heading, $message );
|
| 600 |
} else {
|
| 601 |
// load the mailer class
|
| 815 |
array( 'When a contact receives your email and clicks reply, which email address should that reply be sent to?', 'woocommerce-ac' )
|
| 816 |
);
|
| 817 |
|
|
|
|
| 818 |
// Finally, we register the fields with WordPress
|
| 819 |
register_setting(
|
| 820 |
'woocommerce_ac_settings',
|
| 1127 |
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_abandoned_cart_history_lite ADD `session_id` varchar(50) COLLATE utf8_unicode_ci NOT NULL AFTER `unsubscribe_link`;" );
|
| 1128 |
}
|
| 1129 |
}
|
| 1130 |
+
/**
|
| 1131 |
+
*
|
| 1132 |
+
* This is used to prevent guest users wrong Id. If guest users id is less then 63000000 then this code will ensure that we
|
| 1133 |
+
* will change the id of guest tables so it wont affect on the next guest users.
|
| 1134 |
*/
|
| 1135 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_guest_abandoned_cart_history_lite';" ) && 'yes' != get_option( 'wcal_guest_user_id_altered' ) ) {
|
| 1136 |
$last_id = $wpdb->get_var( "SELECT max(id) FROM `{$wpdb->prefix}ac_guest_abandoned_cart_history_lite`;" );
|
| 1140 |
}
|
| 1141 |
}
|
| 1142 |
|
| 1143 |
+
/**
|
|
|
|
| 1144 |
* We have moved email templates fields in the setings section. SO to remove that fields column fro the db we need it.
|
| 1145 |
+
* For existing user we need to fill this setting with the first template.
|
| 1146 |
+
* @since 4.7
|
| 1147 |
*/
|
| 1148 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_email_templates_lite';" ) ) {
|
| 1149 |
if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'from_email';" ) ) {
|
| 1187 |
}
|
| 1188 |
}
|
| 1189 |
|
| 1190 |
+
/**
|
| 1191 |
* Send email to admin when cart is recovered only via PayPal.
|
| 1192 |
* @since 2.9 version
|
| 1193 |
*/
|
| 1208 |
$check_abandoned_cart = get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true );
|
| 1209 |
$created_via = get_post_meta ( $order_id, '_created_via', true );
|
| 1210 |
|
|
|
|
| 1211 |
if ( 'checkout' == $created_via && 'yes' != $recovered_email_sent && ( $check_abandoned_cart == md5( "yes" ) || $check_abandoned_cart == md5( "no" ) ) ) { // indicates cart is abandoned
|
| 1212 |
$order = new WC_Order( $order_id );
|
| 1213 |
$email_heading = __( 'New Customer Order - Recovered', 'woocommerce-ac' );
|
| 1236 |
}
|
| 1237 |
}
|
| 1238 |
|
| 1239 |
+
/**
|
| 1240 |
* Send email to admin when cart is recovered via any other payment gateway other than PayPal.
|
| 1241 |
* @since 2.3 version
|
| 1242 |
*/
|
| 1308 |
}
|
| 1309 |
|
| 1310 |
if( isset( $cut_off_time ) ) {
|
| 1311 |
+
$cart_cut_off_time = intval( $cut_off_time ) * 60;
|
| 1312 |
} else {
|
| 1313 |
$cart_cut_off_time = 60 * 60;
|
| 1314 |
}
|
| 1335 |
$abandoned_cart_id = $wpdb->insert_id;
|
| 1336 |
$_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
|
| 1337 |
} elseif ( isset( $results[0]->abandoned_cart_time ) && $compare_time > $results[0]->abandoned_cart_time ) {
|
| 1338 |
+
|
| 1339 |
+
$wcal_woocommerce_persistent_cart = version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
|
| 1340 |
$updated_cart_info = json_encode( get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true ) );
|
| 1341 |
|
| 1342 |
if ( ! $this->wcal_compare_carts( $user_id, $results[0]->abandoned_cart_info ) ) {
|
| 1354 |
|
| 1355 |
update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "yes" ) );
|
| 1356 |
|
| 1357 |
+
$abandoned_cart_id = $wpdb->insert_id;
|
| 1358 |
$_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
|
| 1359 |
} else {
|
| 1360 |
update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "no" ) );
|
| 1372 |
|
| 1373 |
$query_update = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE user_id ='" . $user_id . "' AND cart_ignored='0' ";
|
| 1374 |
$get_abandoned_record = $wpdb->get_results( $query_update );
|
| 1375 |
+
if ( count( $get_abandoned_record ) > 0 ) {
|
| 1376 |
+
$abandoned_cart_id = $get_abandoned_record[0]->id;
|
| 1377 |
+
$_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
|
| 1378 |
+
}
|
| 1379 |
}
|
| 1380 |
} else {
|
| 1381 |
//start here guest user
|
| 1422 |
$wpdb->query( $query_update );
|
| 1423 |
}
|
| 1424 |
} else {
|
| 1425 |
+
/**
|
|
|
|
| 1426 |
* Here we capture the guest cart from the cart page.
|
| 1427 |
+
* @since: 3.5
|
| 1428 |
+
*
|
| 1429 |
*/
|
| 1430 |
if ( $track_guest_user_cart_from_cart == "on" && $get_cookie[0] != '' ) {
|
| 1431 |
$query = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE session_id LIKE %s AND cart_ignored = '0' AND recovered_cart = '0' ";
|
| 1507 |
if( isset( $results_sent[0] ) ) {
|
| 1508 |
$email_address = $results_sent[0]->sent_email_id;
|
| 1509 |
}
|
| 1510 |
+
if( $validate_email_address_string == hash( 'sha256', $email_address ) && '' != $email_address ) {
|
| 1511 |
$email_sent_id = $validate_email_id_decode;
|
| 1512 |
$get_ac_id_query = "SELECT abandoned_order_id FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE id = %d";
|
| 1513 |
$get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query , $email_sent_id ) );
|
| 1521 |
}
|
| 1522 |
|
| 1523 |
$unsubscribe_query = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
| 1524 |
+
SET unsubscribe_link = '1'
|
| 1525 |
WHERE user_id= %d AND cart_ignored='0' ";
|
| 1526 |
$wpdb->query( $wpdb->prepare( $unsubscribe_query , $user_id ) );
|
| 1527 |
echo "Unsubscribed Successfully";
|
| 1578 |
$url = substr( $link_decode, $url_pos );
|
| 1579 |
$get_ac_id_query = "SELECT abandoned_order_id FROM `".$wpdb->prefix."ac_sent_history_lite` WHERE id = %d";
|
| 1580 |
$get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query, $email_sent_id ) );
|
| 1581 |
+
$get_user_results = array();
|
| 1582 |
+
if ( count( $get_ac_id_results ) > 0 ) {
|
| 1583 |
+
$get_user_id_query = "SELECT user_id FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE id = %d";
|
| 1584 |
+
$get_user_results = $wpdb->get_results( $wpdb->prepare( $get_user_id_query, $get_ac_id_results[0]->abandoned_order_id ) );
|
| 1585 |
+
}
|
| 1586 |
$user_id = 0;
|
| 1587 |
if ( isset( $get_user_results ) && count( $get_user_results ) > 0 ) {
|
| 1588 |
$user_id = $get_user_results[0]->user_id;
|
| 1628 |
|
| 1629 |
// load the information of the guest user
|
| 1630 |
function wcal_load_guest_persistent_cart() {
|
| 1631 |
+
if ( isset( $_SESSION['user_id'] ) && '' != $_SESSION['user_id'] ) {
|
| 1632 |
+
global $woocommerce;
|
| 1633 |
+
$saved_cart = json_decode( get_user_meta( $_SESSION['user_id'], '_woocommerce_persistent_cart',true ), true );
|
| 1634 |
+
$c = array();
|
| 1635 |
+
$cart_contents_total = $cart_contents_weight = $cart_contents_count = $cart_contents_tax = $total = $subtotal = $subtotal_ex_tax = $tax_total = 0;
|
| 1636 |
+
if ( count( $saved_cart ) > 0 ) {
|
| 1637 |
+
foreach ( $saved_cart as $key => $value ) {
|
| 1638 |
+
foreach ( $value as $a => $b ) {
|
| 1639 |
+
$c['product_id'] = $b['product_id'];
|
| 1640 |
+
$c['variation_id'] = $b['variation_id'];
|
| 1641 |
+
$c['variation'] = $b['variation'];
|
| 1642 |
+
$c['quantity'] = $b['quantity'];
|
| 1643 |
+
$product_id = $b['product_id'];
|
| 1644 |
+
$c['data'] = wc_get_product($product_id);
|
| 1645 |
+
$c['line_total'] = $b['line_total'];
|
| 1646 |
+
$c['line_tax'] = $cart_contents_tax;
|
| 1647 |
+
$c['line_subtotal'] = $b['line_subtotal'];
|
| 1648 |
+
$c['line_subtotal_tax'] = $cart_contents_tax;
|
| 1649 |
+
$value_new[ $a ] = $c;
|
| 1650 |
+
$cart_contents_total = $b['line_subtotal'] + $cart_contents_total;
|
| 1651 |
+
$cart_contents_count = $cart_contents_count + $b['quantity'];
|
| 1652 |
+
$total = $total + $b['line_total'];
|
| 1653 |
+
$subtotal = $subtotal + $b['line_subtotal'];
|
| 1654 |
+
$subtotal_ex_tax = $subtotal_ex_tax + $b['line_subtotal'];
|
| 1655 |
+
}
|
| 1656 |
+
$saved_cart_data[ $key ] = $value_new;
|
| 1657 |
+
$woocommerce_cart_hash = $a;
|
| 1658 |
+
}
|
| 1659 |
}
|
| 1660 |
+
|
| 1661 |
+
if( $saved_cart ) {
|
| 1662 |
+
if ( empty( $woocommerce->session->cart ) || ! is_array( $woocommerce->session->cart ) || sizeof( $woocommerce->session->cart ) == 0 ) {
|
| 1663 |
+
$woocommerce->session->cart = $saved_cart['cart'];
|
| 1664 |
+
$woocommerce->session->cart_contents_total = $cart_contents_total;
|
| 1665 |
+
$woocommerce->session->cart_contents_weight = $cart_contents_weight;
|
| 1666 |
+
$woocommerce->session->cart_contents_count = $cart_contents_count;
|
| 1667 |
+
$woocommerce->session->cart_contents_tax = $cart_contents_tax;
|
| 1668 |
+
$woocommerce->session->total = $total;
|
| 1669 |
+
$woocommerce->session->subtotal = $subtotal;
|
| 1670 |
+
$woocommerce->session->subtotal_ex_tax = $subtotal_ex_tax;
|
| 1671 |
+
$woocommerce->session->tax_total = $tax_total;
|
| 1672 |
+
$woocommerce->session->shipping_taxes = array();
|
| 1673 |
+
$woocommerce->session->taxes = array();
|
| 1674 |
+
$woocommerce->session->ac_customer = array();
|
| 1675 |
+
$woocommerce->cart->cart_contents = $saved_cart_data['cart'];
|
| 1676 |
+
$woocommerce->cart->cart_contents_total = $cart_contents_total;
|
| 1677 |
+
$woocommerce->cart->cart_contents_weight = $cart_contents_weight;
|
| 1678 |
+
$woocommerce->cart->cart_contents_count = $cart_contents_count;
|
| 1679 |
+
$woocommerce->cart->cart_contents_tax = $cart_contents_tax;
|
| 1680 |
+
$woocommerce->cart->total = $total;
|
| 1681 |
+
$woocommerce->cart->subtotal = $subtotal;
|
| 1682 |
+
$woocommerce->cart->subtotal_ex_tax = $subtotal_ex_tax;
|
| 1683 |
+
$woocommerce->cart->tax_total = $tax_total;
|
| 1684 |
+
}
|
|
|
|
|
|
|
| 1685 |
}
|
| 1686 |
}
|
| 1687 |
}
|
| 1748 |
$current_woo_cart = $abandoned_cart_arr;
|
| 1749 |
$abandoned_cart_arr = $temp_variable;
|
| 1750 |
}
|
| 1751 |
+
if ( is_array( $current_woo_cart ) && is_array( $abandoned_cart_arr ) ) {
|
| 1752 |
+
foreach ( $current_woo_cart as $key => $value ) {
|
| 1753 |
+
|
| 1754 |
+
foreach ( $value as $item_key => $item_value ) {
|
| 1755 |
+
$current_cart_product_id = $item_value['product_id'];
|
| 1756 |
+
$current_cart_variation_id = $item_value['variation_id'];
|
| 1757 |
+
$current_cart_quantity = $item_value['quantity'];
|
| 1758 |
+
|
| 1759 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['product_id'] ) ) {
|
| 1760 |
+
$abandoned_cart_product_id = $abandoned_cart_arr[$key][$item_key]['product_id'];
|
| 1761 |
+
} else {
|
| 1762 |
+
$abandoned_cart_product_id = "";
|
| 1763 |
+
}
|
| 1764 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['variation_id'] ) ) {
|
| 1765 |
+
$abandoned_cart_variation_id = $abandoned_cart_arr[$key][$item_key]['variation_id'];
|
| 1766 |
+
} else {
|
| 1767 |
+
$abandoned_cart_variation_id = "";
|
| 1768 |
+
}
|
| 1769 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['quantity'] ) ) {
|
| 1770 |
+
$abandoned_cart_quantity = $abandoned_cart_arr[$key][$item_key]['quantity'];
|
| 1771 |
+
} else {
|
| 1772 |
+
$abandoned_cart_quantity = "";
|
| 1773 |
+
}
|
| 1774 |
+
if ( ( $current_cart_product_id != $abandoned_cart_product_id ) ||
|
| 1775 |
+
( $current_cart_variation_id != $abandoned_cart_variation_id ) ||
|
| 1776 |
+
( $current_cart_quantity != $abandoned_cart_quantity ) )
|
| 1777 |
+
{
|
| 1778 |
+
return false;
|
| 1779 |
+
}
|
| 1780 |
}
|
| 1781 |
}
|
| 1782 |
}
|
| 2007 |
$js_src = includes_url('js/tinymce/') . 'tinymce.min.js';
|
| 2008 |
wp_enqueue_script( 'tinyMce_ac',$js_src );
|
| 2009 |
wp_enqueue_script( 'ac_email_variables', plugins_url() . '/woocommerce-abandoned-cart/assets/js/abandoncart_plugin_button.js' );
|
| 2010 |
+
wp_enqueue_script( 'wcal_activate_template', plugins_url() . '/woocommerce-abandoned-cart/assets/js/wcal_template_activate.js' );
|
| 2011 |
}
|
| 2012 |
}
|
| 2013 |
|
| 2044 |
wp_enqueue_style( 'woocommerce_admin_styles', plugins_url() . '/woocommerce/assets/css/admin.css' );
|
| 2045 |
wp_enqueue_style( 'jquery-ui-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
|
| 2046 |
wp_enqueue_style( 'abandoned-orders-list', plugins_url() . '/woocommerce-abandoned-cart/assets/css/view.abandoned.orders.style.css' );
|
| 2047 |
+
wp_enqueue_style( 'wcal_email_template', plugins_url() . '/woocommerce-abandoned-cart/assets/css/wcal_template_activate.css' );
|
| 2048 |
|
| 2049 |
}
|
| 2050 |
}
|
| 2156 |
<?php
|
| 2157 |
if ( $section == 'wcal_general_settings' || $section == '' ) {
|
| 2158 |
?>
|
| 2159 |
+
<form method="post" action="options.php">
|
| 2160 |
+
<?php settings_fields( 'woocommerce_ac_settings' ); ?>
|
| 2161 |
+
<?php do_settings_sections( 'woocommerce_ac_page' ); ?>
|
| 2162 |
+
<?php settings_errors(); ?>
|
| 2163 |
+
<?php submit_button(); ?>
|
| 2164 |
+
</form>
|
| 2165 |
<?php
|
| 2166 |
} else if ( $section == 'wcal_email_settings' ) {
|
| 2167 |
+
?>
|
| 2168 |
+
<form method="post" action="options.php">
|
| 2169 |
<?php settings_fields ( 'woocommerce_ac_email_settings' ); ?>
|
| 2170 |
<?php do_settings_sections( 'woocommerce_ac_email_page' ); ?>
|
| 2171 |
<?php settings_errors(); ?>
|
| 2172 |
<?php submit_button(); ?>
|
| 2173 |
+
</form>
|
| 2174 |
<?php
|
| 2175 |
}
|
| 2176 |
?>
|
| 2186 |
$get_visitor_user_ac_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_visitor' );
|
| 2187 |
|
| 2188 |
$wcal_user_reg_text = 'User';
|
| 2189 |
+
if ( $get_registered_user_ac_count > 1 ) {
|
| 2190 |
$wcal_user_reg_text = 'Users';
|
| 2191 |
}
|
| 2192 |
$wcal_user_gus_text = 'User';
|
| 2193 |
+
if ( $get_guest_user_ac_count > 1 ) {
|
| 2194 |
$wcal_user_gus_text = 'Users';
|
| 2195 |
}
|
| 2196 |
$wcal_all_abandoned_carts = $section = $wcal_all_registered = $wcal_all_guest = $wcal_all_visitor = "" ;
|
| 2263 |
// Save the field values
|
| 2264 |
$insert_template_successfuly = $update_template_successfuly = '';
|
| 2265 |
if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' ) {
|
| 2266 |
+
$woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
|
| 2267 |
+
$woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
|
| 2268 |
+
$woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
|
| 2269 |
+
$woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
|
| 2270 |
+
|
| 2271 |
+
$email_frequency = trim( $_POST['email_frequency'] );
|
| 2272 |
+
$day_or_hour = trim( $_POST['day_or_hour'] );
|
| 2273 |
+
$is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
|
| 2274 |
+
$default_value = 0 ;
|
| 2275 |
+
|
| 2276 |
+
$query = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
|
| 2277 |
+
(subject, body, frequency, day_or_hour, template_name, is_wc_template, default_template, wc_email_header )
|
| 2278 |
+
VALUES ( %s, %s, %d, %s, %s, %s, %d, %s )";
|
| 2279 |
+
|
| 2280 |
+
$insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query,
|
| 2281 |
+
$woocommerce_ac_email_subject,
|
| 2282 |
+
$woocommerce_ac_email_body,
|
| 2283 |
+
$email_frequency,
|
| 2284 |
+
$day_or_hour,
|
| 2285 |
+
$woocommerce_ac_template_name,
|
| 2286 |
+
$is_wc_template,
|
| 2287 |
+
$default_value,
|
| 2288 |
+
$woocommerce_ac_email_header )
|
| 2289 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2290 |
}
|
| 2291 |
|
| 2292 |
if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' ) {
|
| 2293 |
+
|
| 2294 |
+
$updated_is_active = '0';
|
| 2295 |
|
| 2296 |
+
$email_frequency = trim( $_POST['email_frequency'] );
|
| 2297 |
+
$day_or_hour = trim( $_POST['day_or_hour'] );
|
| 2298 |
+
$is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
|
| 2299 |
+
|
| 2300 |
+
$woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
|
| 2301 |
+
$woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
|
| 2302 |
+
$woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
|
| 2303 |
+
$woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
|
| 2304 |
+
$id = trim( $_POST['id'] );
|
| 2305 |
+
|
| 2306 |
+
$check_query = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite`
|
| 2307 |
+
WHERE id = %d ";
|
| 2308 |
+
$check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $id ) );
|
| 2309 |
+
$default_value = '';
|
| 2310 |
+
|
| 2311 |
+
if ( count( $check_results ) > 0 ) {
|
| 2312 |
+
if ( isset( $check_results[0]->default_template ) && $check_results[0]->default_template == '1' ) {
|
| 2313 |
+
$default_value = '1';
|
| 2314 |
+
}
|
| 2315 |
+
}
|
| 2316 |
+
|
| 2317 |
+
$query_update_latest = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2318 |
SET
|
| 2319 |
subject = %s,
|
| 2320 |
body = %s,
|
|
|
|
| 2321 |
frequency = %d,
|
| 2322 |
day_or_hour = %s,
|
| 2323 |
template_name = %s,
|
| 2325 |
default_template = %d,
|
| 2326 |
wc_email_header = %s
|
| 2327 |
WHERE id = %d ";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2328 |
|
| 2329 |
+
$update_template_successfuly = $wpdb->query( $wpdb->prepare( $query_update_latest,
|
| 2330 |
+
$woocommerce_ac_email_subject,
|
| 2331 |
+
$woocommerce_ac_email_body,
|
| 2332 |
+
$email_frequency,
|
| 2333 |
+
$day_or_hour,
|
| 2334 |
+
$woocommerce_ac_template_name,
|
| 2335 |
+
$is_wc_template,
|
| 2336 |
+
$default_value,
|
| 2337 |
+
$woocommerce_ac_email_header,
|
| 2338 |
+
$id )
|
| 2339 |
+
);
|
| 2340 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2341 |
}
|
| 2342 |
|
| 2343 |
if ( $action == 'emailtemplates' && $mode == 'removetemplate' ) {
|
| 2373 |
}
|
| 2374 |
|
| 2375 |
if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' && ( isset( $insert_template_successfuly ) && $insert_template_successfuly != '' ) ) { ?>
|
| 2376 |
+
<div id="message" class="updated fade">
|
| 2377 |
+
<p>
|
| 2378 |
+
<strong>
|
| 2379 |
+
<?php _e( 'The Email Template has been successfully added.', 'woocommerce-ac' ); ?>
|
| 2380 |
+
</strong>
|
| 2381 |
+
</p>
|
| 2382 |
+
</div>
|
| 2383 |
<?php } else if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' && ( isset( $insert_template_successfuly ) && $insert_template_successfuly == '' ) ) {
|
| 2384 |
?>
|
| 2385 |
+
<div id="message" class="error fade">
|
| 2386 |
+
<p>
|
| 2387 |
+
<strong>
|
| 2388 |
+
<?php _e( ' There was a problem adding the email template. Please contact the plugin author via <a href= "https://wordpress.org/support/plugin/woocommerce-abandoned-cart">support forum</a>.', 'woocommerce-ac' ); ?>
|
| 2389 |
+
</strong>
|
| 2390 |
+
</p>
|
| 2391 |
+
</div>
|
| 2392 |
<?php
|
| 2393 |
}
|
| 2394 |
|
| 2395 |
if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' && isset($update_template_successfuly) && $update_template_successfuly >= 0 ) { ?>
|
| 2396 |
+
<div id="message" class="updated fade">
|
| 2397 |
+
<p>
|
| 2398 |
+
<strong>
|
| 2399 |
+
<?php _e( 'The Email Template has been successfully updated.', 'woocommerce-ac' ); ?>
|
| 2400 |
+
</strong>
|
| 2401 |
+
</p>
|
| 2402 |
+
</div>
|
| 2403 |
<?php } else if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' && isset($update_template_successfuly) && $update_template_successfuly === false ){
|
| 2404 |
?>
|
| 2405 |
+
<div id="message" class="error fade">
|
| 2406 |
+
<p>
|
| 2407 |
+
<strong>
|
| 2408 |
+
<?php _e( ' There was a problem updating the email template. Please contact the plugin author via <a href= "https://wordpress.org/support/plugin/woocommerce-abandoned-cart">support forum</a>.', 'woocommerce-ac' ); ?>
|
| 2409 |
+
</strong>
|
| 2410 |
+
</p>
|
| 2411 |
+
</div>
|
| 2412 |
<?php
|
| 2413 |
}
|
| 2414 |
?>
|
| 2415 |
<div class="tablenav">
|
| 2416 |
<p style="float:left;">
|
| 2417 |
+
<a cursor: pointer; href="<?php echo "admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=addnewtemplate"; ?>" class="button-secondary"><?php _e( 'Add New Template', 'woocommerce-ac' ); ?>
|
| 2418 |
+
</a>
|
| 2419 |
</p>
|
| 2420 |
|
| 2421 |
<?php
|
| 2437 |
?>
|
| 2438 |
<p>
|
| 2439 |
<script language='javascript'>
|
| 2440 |
+
jQuery( document ).ready( function() {
|
| 2441 |
+
jQuery( '#duration_select' ).change( function() {
|
|
|
|
|
|
|
| 2442 |
var group_name = jQuery( '#duration_select' ).val();
|
| 2443 |
var today = new Date();
|
| 2444 |
var start_date = "";
|
| 2445 |
var end_date = "";
|
| 2446 |
+
if ( group_name == "yesterday" ) {
|
|
|
|
| 2447 |
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 1 );
|
| 2448 |
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 1 );
|
| 2449 |
+
} else if ( group_name == "today") {
|
|
|
|
|
|
|
| 2450 |
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
| 2451 |
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
| 2452 |
+
} else if ( group_name == "last_seven" ) {
|
|
|
|
|
|
|
| 2453 |
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 7 );
|
| 2454 |
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
| 2455 |
+
} else if ( group_name == "last_fifteen" ) {
|
|
|
|
|
|
|
| 2456 |
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 15 );
|
| 2457 |
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
| 2458 |
+
} else if ( group_name == "last_thirty" ) {
|
|
|
|
|
|
|
| 2459 |
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 30 );
|
| 2460 |
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
| 2461 |
+
} else if ( group_name == "last_ninety" ) {
|
|
|
|
|
|
|
| 2462 |
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 90 );
|
| 2463 |
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
| 2464 |
+
} else if ( group_name == "last_year_days" ) {
|
|
|
|
|
|
|
| 2465 |
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 365 );
|
| 2466 |
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
| 2467 |
}
|
| 2474 |
|
| 2475 |
jQuery( '#start_date' ).val( start_date_value );
|
| 2476 |
jQuery( '#end_date' ).val( end_date_value );
|
| 2477 |
+
} );
|
|
|
|
| 2478 |
});
|
| 2479 |
</script>
|
| 2480 |
<?php
|
| 2491 |
}
|
| 2492 |
if ($duration_range == "") $duration_range = "last_seven";
|
| 2493 |
|
| 2494 |
+
_e( 'The Report below shows how many Abandoned Carts we were able to recover for you by sending automatic emails to encourage shoppers.', 'woocommerce-ac');
|
| 2495 |
?>
|
| 2496 |
<div id="recovered_stats" class="postbox" style="display:block">
|
| 2497 |
<div class="inside">
|
| 2611 |
if ( $results[0]->user_type == "GUEST" && "0" != $results[0]->user_id ) {
|
| 2612 |
$query_guest = "SELECT * FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d";
|
| 2613 |
$results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $results[0]->user_id ) );
|
| 2614 |
+
$user_email = $user_first_name = $user_last_name = $user_billing_postcode = $user_shipping_postcode = '';
|
| 2615 |
+
$shipping_charges = '';
|
| 2616 |
+
if ( count( $results_guest ) > 0 ) {
|
| 2617 |
+
$user_email = $results_guest[0]->email_id;
|
| 2618 |
+
$user_first_name = $results_guest[0]->billing_first_name;
|
| 2619 |
+
$user_last_name = $results_guest[0]->billing_last_name;
|
| 2620 |
+
$user_billing_postcode = $results_guest[0]->billing_zipcode;
|
| 2621 |
+
$user_shipping_postcode = $results_guest[0]->shipping_zipcode;
|
| 2622 |
+
$shipping_charges = $results_guest[0]->shipping_charges;
|
| 2623 |
+
}
|
| 2624 |
$user_billing_company = $user_billing_address_1 = $user_billing_address_2 = $user_billing_city = $user_billing_state = $user_billing_country = $user_billing_phone = "";
|
| 2625 |
$user_shipping_company = $user_shipping_address_1 = $user_shipping_address_2 = $user_shipping_city = $user_shipping_state = $user_shipping_country = "";
|
| 2626 |
} else if ( $results[0]->user_type == "GUEST" && $results[0]->user_id == "0" ) {
|
| 2641 |
$user_email = get_user_meta( $results[0]->user_id, 'billing_email', true );
|
| 2642 |
if( "" == $user_email ) {
|
| 2643 |
$user_data = get_userdata( $results[0]->user_id );
|
| 2644 |
+
if ( isset( $user_data->user_email ) ) {
|
| 2645 |
+
$user_email = $user_data->user_email;
|
| 2646 |
+
} else {
|
| 2647 |
+
$user_email = '';
|
| 2648 |
+
}
|
| 2649 |
}
|
| 2650 |
|
| 2651 |
$user_first_name = "";
|
| 2652 |
$user_first_name_temp = get_user_meta( $user_id, 'billing_first_name', true );
|
| 2653 |
if( isset( $user_first_name_temp ) && "" == $user_first_name_temp ) {
|
| 2654 |
$user_data = get_userdata( $user_id );
|
| 2655 |
+
if ( isset( $user_data->first_name ) ) {
|
| 2656 |
+
$user_first_name = $user_data->first_name;
|
| 2657 |
+
} else {
|
| 2658 |
+
$user_first_name = '';
|
| 2659 |
+
}
|
| 2660 |
} else {
|
| 2661 |
$user_first_name = $user_first_name_temp;
|
| 2662 |
}
|
| 2664 |
$user_last_name_temp = get_user_meta( $user_id, 'billing_last_name', true );
|
| 2665 |
if( isset( $user_last_name_temp ) && "" == $user_last_name_temp ) {
|
| 2666 |
$user_data = get_userdata( $user_id );
|
| 2667 |
+
if ( isset( $user_data->last_name ) ) {
|
| 2668 |
+
$user_last_name = $user_data->last_name;
|
| 2669 |
+
} else {
|
| 2670 |
+
$user_last_name = '';
|
| 2671 |
+
}
|
| 2672 |
} else {
|
| 2673 |
$user_last_name = $user_last_name_temp;
|
| 2674 |
}
|
| 2784 |
$name = $variation->get_formatted_name() ;
|
| 2785 |
$explode_all = explode ( "–", $name );
|
| 2786 |
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
| 2787 |
+
$wcap_sku = '';
|
| 2788 |
+
if ( $variation->get_sku() ) {
|
| 2789 |
+
$wcap_sku = "SKU: " . $variation->get_sku() . "<br>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2790 |
}
|
| 2791 |
+
$wcap_get_formatted_variation = wc_get_formatted_variation( $variation, true );
|
| 2792 |
+
|
| 2793 |
+
$add_product_name = $product_name . ' - ' . $wcap_sku . $wcap_get_formatted_variation;
|
| 2794 |
+
|
| 2795 |
+
$pro_name_variation = (array) $add_product_name;
|
| 2796 |
}else{
|
| 2797 |
+
$pro_name_variation = array_slice( $explode_all, 1, -1 );
|
| 2798 |
}
|
| 2799 |
$product_name_with_variable = '';
|
| 2800 |
+
$explode_many_varaition = array();
|
| 2801 |
+
foreach( $pro_name_variation as $pro_name_variation_key => $pro_name_variation_value ) {
|
| 2802 |
$explode_many_varaition = explode ( ",", $pro_name_variation_value );
|
| 2803 |
+
if( !empty( $explode_many_varaition ) ) {
|
| 2804 |
+
foreach( $explode_many_varaition as $explode_many_varaition_key => $explode_many_varaition_value ) {
|
| 2805 |
+
$product_name_with_variable = $product_name_with_variable . html_entity_decode ( $explode_many_varaition_value ) . "<br>";
|
| 2806 |
}
|
| 2807 |
} else {
|
| 2808 |
+
$product_name_with_variable = $product_name_with_variable . html_entity_decode ( $explode_many_varaition_value ) . "<br>";
|
| 2809 |
}
|
| 2810 |
+
}
|
| 2811 |
$product_name = $product_name_with_variable;
|
| 2812 |
+
}
|
| 2813 |
// Item subtotal is calculated as product total including taxes
|
| 2814 |
if ( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
|
| 2815 |
$item_subtotal = $item_subtotal + $v->line_total + $v->line_subtotal_tax;
|
| 2905 |
<form id="wcal-sent-emails" method="get" >
|
| 2906 |
<input type="hidden" name="page" value="woocommerce_ac_page" />
|
| 2907 |
<input type="hidden" name="action" value="report" />
|
| 2908 |
+
<?php $wcal_product_report_list->display(); ?>
|
| 2909 |
</form>
|
| 2910 |
</div>
|
| 2911 |
<?php }
|
| 2919 |
$mode = $_GET['mode'];
|
| 2920 |
}
|
| 2921 |
if ( $action == 'emailtemplates' && ( $mode == 'addnewtemplate' || $mode == 'edittemplate' ) ) {
|
| 2922 |
+
if ( $mode=='edittemplate' ) {
|
| 2923 |
+
$results = array();
|
| 2924 |
+
if ( isset( $_GET['id'] ) ) {
|
| 2925 |
+
$edit_id = $_GET['id'];
|
| 2926 |
+
|
| 2927 |
+
$query = "SELECT wpet . * FROM `".$wpdb->prefix."ac_email_templates_lite` AS wpet WHERE id = %d ";
|
| 2928 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query, $edit_id ) );
|
| 2929 |
+
}
|
| 2930 |
}
|
| 2931 |
$active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
| 2932 |
?>
|
| 2933 |
<div id="content">
|
| 2934 |
<form method="post" action="admin.php?page=woocommerce_ac_page&action=emailtemplates" id="ac_settings">
|
| 2935 |
<input type="hidden" name="mode" value="<?php echo $mode;?>" />
|
| 2936 |
+
<?php
|
| 2937 |
+
$id_by = "";
|
| 2938 |
+
if ( isset( $_GET['id'] ) ) {
|
| 2939 |
$id_by = $_GET['id'];
|
| 2940 |
+
}
|
| 2941 |
+
?>
|
| 2942 |
+
<input type="hidden" name="id" value="<?php echo $id_by ;?>" />
|
| 2943 |
+
<?php
|
| 2944 |
+
$button_mode = "save";
|
| 2945 |
+
$display_message = "Add Email Template";
|
| 2946 |
+
if ( $mode == 'edittemplate' ) {
|
| 2947 |
+
$button_mode = "update";
|
| 2948 |
+
$display_message = "Edit Email Template";
|
| 2949 |
+
}
|
| 2950 |
+
print'<input type="hidden" name="ac_settings_frm" value="'.$button_mode.'">';?>
|
| 2951 |
+
<div id="poststuff">
|
| 2952 |
<div> <!-- <div class="postbox" > -->
|
| 2953 |
<h3 class="hndle"><?php _e( $display_message, 'woocommerce-ac' ); ?></h3>
|
| 2954 |
<div>
|
| 2960 |
<td>
|
| 2961 |
<?php
|
| 2962 |
$template_name = "";
|
| 2963 |
+
if( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->template_name ) ) {
|
| 2964 |
$template_name = $results[0]->template_name;
|
| 2965 |
}
|
| 2966 |
print'<input type="text" name="woocommerce_ac_template_name" id="woocommerce_ac_template_name" class="regular-text" value="'.$template_name.'">';?>
|
| 2975 |
<td>
|
| 2976 |
<?php
|
| 2977 |
$subject_edit = "";
|
| 2978 |
+
if ( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->subject ) ) {
|
| 2979 |
$subject_edit= stripslashes ( $results[0]->subject );
|
| 2980 |
}
|
| 2981 |
print'<input type="text" name="woocommerce_ac_email_subject" id="woocommerce_ac_email_subject" class="regular-text" value="'.$subject_edit.'">';?>
|
| 2990 |
<td>
|
| 2991 |
<?php
|
| 2992 |
$initial_data = "";
|
| 2993 |
+
if ( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->body ) ) {
|
| 2994 |
$initial_data = stripslashes( $results[0]->body );
|
| 2995 |
}
|
| 2996 |
|
| 3023 |
<td>
|
| 3024 |
<?php
|
| 3025 |
$is_wc_template = "";
|
| 3026 |
+
if ( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->is_wc_template ) ) {
|
| 3027 |
$use_wc_template = $results[0]->is_wc_template;
|
| 3028 |
|
| 3029 |
if ( $use_wc_template == '1' ) {
|
| 3047 |
<?php
|
| 3048 |
|
| 3049 |
$wcal_wc_email_header = "";
|
| 3050 |
+
if ( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->wc_email_header ) ) {
|
| 3051 |
$wcal_wc_email_header = $results[0]->wc_email_header;
|
| 3052 |
}
|
| 3053 |
if ( $wcal_wc_email_header == "" ) {
|
| 3066 |
<select name="email_frequency" id="email_frequency">
|
| 3067 |
<?php
|
| 3068 |
$frequency_edit = "";
|
| 3069 |
+
if( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->frequency ) ) {
|
| 3070 |
$frequency_edit = $results[0]->frequency;
|
| 3071 |
}
|
| 3072 |
for ( $i = 1; $i < 4; $i++ ) {
|
| 3082 |
<select name="day_or_hour" id="day_or_hour">
|
| 3083 |
<?php
|
| 3084 |
$days_or_hours_edit = "";
|
| 3085 |
+
if ( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->day_or_hour ) )
|
| 3086 |
{
|
| 3087 |
$days_or_hours_edit = $results[0]->day_or_hour;
|
| 3088 |
}
|
| 3212 |
is_wc_template : is_wc_template,
|
| 3213 |
wc_template_header : wc_template_header,
|
| 3214 |
action : 'wcal_preview_email_sent'
|
| 3215 |
+
};
|
| 3216 |
|
| 3217 |
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
| 3218 |
+
$.post( ajaxurl, data, function( response ) {
|
|
|
|
| 3219 |
if ( 'not sent' == response ) {
|
| 3220 |
+
$( "#preview_email_sent_msg" ).html( "Test email is not sent as the Email body is empty." );
|
| 3221 |
+
$( "#preview_email_sent_msg" ).fadeIn();
|
| 3222 |
+
setTimeout( function(){$( "#preview_email_sent_msg" ).fadeOut();}, 4000 );
|
| 3223 |
} else {
|
| 3224 |
+
$( "#preview_email_sent_msg" ).html( "<img src='<?php echo plugins_url(); ?>/woocommerce-abandoned-cart/assets/images/check.jpg'> Email has been sent successfully." );
|
| 3225 |
+
$( "#preview_email_sent_msg" ).fadeIn();
|
| 3226 |
+
setTimeout( function(){$( "#preview_email_sent_msg" ).fadeOut();}, 3000 );
|
| 3227 |
}
|
| 3228 |
//alert('Got this from the server: ' + response);
|
| 3229 |
});
|
| 3232 |
</script>
|
| 3233 |
<?php
|
| 3234 |
}
|
| 3235 |
+
public static function wcal_toggle_template_status () {
|
| 3236 |
+
global $wpdb;
|
| 3237 |
+
$template_id = $_POST['wcal_template_id'];
|
| 3238 |
+
$current_template_status = $_POST['current_state'];
|
| 3239 |
+
|
| 3240 |
+
if( "on" == $current_template_status ) {
|
| 3241 |
+
$query_update = "SELECT * FROM `" . $wpdb->prefix . "ac_email_templates_lite` WHERE id ='" . $template_id . "'";
|
| 3242 |
+
$get_selected_template_result = $wpdb->get_results( $query_update );
|
| 3243 |
+
$email_frequncy = $get_selected_template_result[0]->frequency;
|
| 3244 |
+
$email_day_or_hour = $get_selected_template_result[0]->day_or_hour;
|
| 3245 |
+
$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 . "' ";
|
| 3246 |
+
$wcal_updated = $wpdb->query( $query_update );
|
| 3247 |
+
|
| 3248 |
+
if ( 1 == $wcal_updated ){
|
| 3249 |
+
$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 . "' ";
|
| 3250 |
+
$wcal_updated_get_id = $wpdb->get_results( $query_update_get_id );
|
| 3251 |
+
$wcal_all_ids = '';
|
| 3252 |
+
foreach ($wcal_updated_get_id as $wcal_updated_get_id_key => $wcal_updated_get_id_value ) {
|
| 3253 |
+
# code...
|
| 3254 |
+
if ( '' == $wcal_all_ids ){
|
| 3255 |
+
$wcal_all_ids = $wcal_updated_get_id_value->id;
|
| 3256 |
+
}else{
|
| 3257 |
+
$wcal_all_ids = $wcal_all_ids . ',' .$wcal_updated_get_id_value->id;
|
| 3258 |
+
}
|
| 3259 |
+
}
|
| 3260 |
+
echo 'wcal-template-updated:'. $wcal_all_ids ;
|
| 3261 |
+
}
|
| 3262 |
+
|
| 3263 |
+
$active = "1";
|
| 3264 |
+
} else {
|
| 3265 |
+
$active = "0";
|
| 3266 |
+
}
|
| 3267 |
+
$query_update = "UPDATE `" . $wpdb->prefix . "ac_email_templates_lite`
|
| 3268 |
+
SET
|
| 3269 |
+
is_active = '" . $active . "'
|
| 3270 |
+
WHERE id = '" . $template_id . "' ";
|
| 3271 |
+
$wpdb->query( $query_update );
|
| 3272 |
+
wp_die();
|
| 3273 |
+
|
| 3274 |
+
}
|
| 3275 |
// Send Test Email
|
| 3276 |
function wcal_preview_email_sent() {
|
| 3277 |
if ( '' != $_POST['body_email_preview'] ) {
|
| 3294 |
$cart_url = wc_get_page_permalink( 'cart' );
|
| 3295 |
$body_email_preview = str_replace( '{{cart.link}}', $cart_url, $body_email_preview );
|
| 3296 |
$body_email_preview = str_replace( '{{cart.unsubscribe}}', '<a href=#>unsubscribe</a>', $body_email_preview );
|
| 3297 |
+
$wcal_price = wc_price( '100' );
|
| 3298 |
+
$wcal_total_price = wc_price( '200' );
|
| 3299 |
if ( class_exists( 'WP_Better_Emails' ) ) {
|
| 3300 |
$headers = "From: " . $from_email_name . " <" . $from_email_preview . ">" . "\r\n";
|
| 3301 |
$headers .= "Content-Type: text/plain" . "\r\n";
|
| 3313 |
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/shoes.jpg"/></td>
|
| 3314 |
<td>'.__( "Men\'\s Formal Shoes", "woocommerce-ac" ).'</td>
|
| 3315 |
<td>1</td>
|
| 3316 |
+
<td>' . $wcal_price . '</td>
|
| 3317 |
+
<td>' . $wcal_price . '</td>
|
| 3318 |
</tr>
|
| 3319 |
<tr align="center">
|
| 3320 |
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/handbag.jpg"/></td>
|
| 3321 |
<td>'.__( "Woman\'\s Hand Bags", "woocommerce-ac" ).'</td>
|
| 3322 |
<td>1</td>
|
| 3323 |
+
<td>' . $wcal_price . '</td>
|
| 3324 |
+
<td>' . $wcal_price . '</td>
|
| 3325 |
</tr>
|
| 3326 |
<tr align="center">
|
| 3327 |
<td></td>
|
| 3328 |
<td></td>
|
| 3329 |
<td></td>
|
| 3330 |
<td>'.__( "Cart Total:", "woocommerce-ac" ).'</td>
|
| 3331 |
+
<td>' . $wcal_total_price . '</td>
|
| 3332 |
</tr>
|
| 3333 |
</table>';
|
| 3334 |
} else {
|
| 3348 |
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/shoes.jpg"/></td>
|
| 3349 |
<td>'.__( "Men\'\s Formal Shoes", "woocommerce-ac" ).'</td>
|
| 3350 |
<td>1</td>
|
| 3351 |
+
<td>' . $wcal_price . '</td>
|
| 3352 |
+
<td>' . $wcal_price . '</td>
|
| 3353 |
</tr>
|
| 3354 |
<tr align="center">
|
| 3355 |
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/handbag.jpg"/></td>
|
| 3356 |
<td>'.__( "Woman\'\s Hand Bags", "woocommerce-ac" ).'</td>
|
| 3357 |
<td>1</td>
|
| 3358 |
+
<td>' . $wcal_price . '</td>
|
| 3359 |
+
<td>' . $wcal_price . '</td>
|
| 3360 |
</tr>
|
| 3361 |
<tr align="center">
|
| 3362 |
<td></td>
|
| 3363 |
<td></td>
|
| 3364 |
<td></td>
|
| 3365 |
<td>'.__( "Cart Total:", "woocommerce-ac" ).'</td>
|
| 3366 |
+
<td>' . $wcal_total_price . '</td>
|
| 3367 |
</tr>
|
| 3368 |
</table>';
|
| 3369 |
}
|
