Version Description
Download this release
Release Info
Developer | ashokrane |
Plugin | Abandoned Cart Lite for WooCommerce |
Version | 4.6 |
Comparing to | |
See all releases |
Code changes from version 4.5 to 4.6
- woocommerce-abandoned-cart/assets/css/wcal_template_activate.css +46 -46
- woocommerce-abandoned-cart/assets/js/wcal_template_activate.js +39 -39
- woocommerce-abandoned-cart/assets/js/wcal_ts_dismiss_notice.js +35 -35
- woocommerce-abandoned-cart/cron/wcal_send_email.php +619 -619
- woocommerce-abandoned-cart/includes/classes/class-wcal-abandoned-orders-table.php +475 -480
- woocommerce-abandoned-cart/includes/classes/class-wcal-aes-counter.php +171 -171
- woocommerce-abandoned-cart/includes/classes/class-wcal-aes.php +189 -189
- woocommerce-abandoned-cart/includes/classes/class-wcal-product-report-table.php +253 -253
- woocommerce-abandoned-cart/includes/classes/class-wcal-recover-orders-table.php +404 -407
- woocommerce-abandoned-cart/includes/classes/class-wcal-templates-table.php +262 -262
- woocommerce-abandoned-cart/includes/classes/class-wcal-ts-tracker.php +655 -655
- woocommerce-abandoned-cart/includes/wcal-common.php +65 -64
- woocommerce-abandoned-cart/includes/wcal_actions.php +44 -44
- woocommerce-abandoned-cart/includes/wcal_admin_notice.php +161 -161
- woocommerce-abandoned-cart/includes/wcal_class-guest.php +255 -255
- woocommerce-abandoned-cart/includes/wcal_default-settings.php +48 -48
- woocommerce-abandoned-cart/includes/wcal_ts_tracking.php +58 -58
- woocommerce-abandoned-cart/includes/welcome.php +330 -330
- woocommerce-abandoned-cart/readme.txt +19 -1
- woocommerce-abandoned-cart/woocommerce-ac.php +3334 -3376
woocommerce-abandoned-cart/assets/css/wcal_template_activate.css
CHANGED
@@ -1,47 +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 |
}
|
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 |
}
|
woocommerce-abandoned-cart/assets/js/wcal_template_activate.js
CHANGED
@@ -1,40 +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 |
});
|
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 |
});
|
woocommerce-abandoned-cart/assets/js/wcal_ts_dismiss_notice.js
CHANGED
@@ -1,36 +1,36 @@
|
|
1 |
-
// Make notices dismissible
|
2 |
-
jQuery(document).ready( function() {
|
3 |
-
jQuery( '.notice.is-dismissible' ).each( function() {
|
4 |
-
|
5 |
-
//console.log (this.className);
|
6 |
-
var wcal_get_name = this.className;
|
7 |
-
if (wcal_get_name.indexOf('wcal-tracker') !== -1){
|
8 |
-
var $this = jQuery( this ),
|
9 |
-
$button = jQuery( '<button type="button" class="notice-dismiss"><span class="wcal screen-reader-text"></span></button>' ),
|
10 |
-
btnText = commonL10n.dismiss || '';
|
11 |
-
|
12 |
-
// Ensure plain text
|
13 |
-
$button.find( '.screen-reader-text' ).text( btnText );
|
14 |
-
|
15 |
-
$this.append( $button );
|
16 |
-
$button.on( 'click.notice-dismiss', function( event ) {
|
17 |
-
console.log ('here');
|
18 |
-
//alert('This');
|
19 |
-
event.preventDefault();
|
20 |
-
$this.fadeTo( 100 , 0, function() {
|
21 |
-
//alert();
|
22 |
-
jQuery(this).slideUp( 100, function() {
|
23 |
-
jQuery(this).remove();
|
24 |
-
var data = {
|
25 |
-
action: "wcal_admin_notices"
|
26 |
-
};
|
27 |
-
var admin_url = jQuery( "#admin_url" ).val();
|
28 |
-
jQuery.post( admin_url + "/admin-ajax.php", data, function( response ) {
|
29 |
-
});
|
30 |
-
});
|
31 |
-
});
|
32 |
-
});
|
33 |
-
|
34 |
-
}
|
35 |
-
});
|
36 |
});
|
1 |
+
// Make notices dismissible
|
2 |
+
jQuery(document).ready( function() {
|
3 |
+
jQuery( '.notice.is-dismissible' ).each( function() {
|
4 |
+
|
5 |
+
//console.log (this.className);
|
6 |
+
var wcal_get_name = this.className;
|
7 |
+
if (wcal_get_name.indexOf('wcal-tracker') !== -1){
|
8 |
+
var $this = jQuery( this ),
|
9 |
+
$button = jQuery( '<button type="button" class="notice-dismiss"><span class="wcal screen-reader-text"></span></button>' ),
|
10 |
+
btnText = commonL10n.dismiss || '';
|
11 |
+
|
12 |
+
// Ensure plain text
|
13 |
+
$button.find( '.screen-reader-text' ).text( btnText );
|
14 |
+
|
15 |
+
$this.append( $button );
|
16 |
+
$button.on( 'click.notice-dismiss', function( event ) {
|
17 |
+
console.log ('here');
|
18 |
+
//alert('This');
|
19 |
+
event.preventDefault();
|
20 |
+
$this.fadeTo( 100 , 0, function() {
|
21 |
+
//alert();
|
22 |
+
jQuery(this).slideUp( 100, function() {
|
23 |
+
jQuery(this).remove();
|
24 |
+
var data = {
|
25 |
+
action: "wcal_admin_notices"
|
26 |
+
};
|
27 |
+
var admin_url = jQuery( "#admin_url" ).val();
|
28 |
+
jQuery.post( admin_url + "/admin-ajax.php", data, function( response ) {
|
29 |
+
});
|
30 |
+
});
|
31 |
+
});
|
32 |
+
});
|
33 |
+
|
34 |
+
}
|
35 |
+
});
|
36 |
});
|
woocommerce-abandoned-cart/cron/wcal_send_email.php
CHANGED
@@ -1,620 +1,620 @@
|
|
1 |
-
<?php
|
2 |
-
static $wp_load; // Since this will be called twice, hold onto it.
|
3 |
-
if ( ! isset( $wp_load ) ) {
|
4 |
-
$wp_load = false;
|
5 |
-
$dir = __FILE__;
|
6 |
-
while( '/' != ( $dir = dirname( $dir ) ) ) {
|
7 |
-
if( file_exists( $wp_load = "{$dir}/wp-load.php" ) ) {
|
8 |
-
break;
|
9 |
-
}
|
10 |
-
}
|
11 |
-
}
|
12 |
-
$wcal_root = dirname( dirname(__FILE__) ); // go two level up for directory from this file.
|
13 |
-
require_once $wp_load;
|
14 |
-
require_once $wcal_root.'/includes/classes/class-wcal-aes.php';
|
15 |
-
require_once $wcal_root.'/includes/classes/class-wcal-aes-counter.php';
|
16 |
-
/**
|
17 |
-
* woocommerce_abandon_cart_cron class
|
18 |
-
**/
|
19 |
-
if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
|
20 |
-
|
21 |
-
class woocommerce_abandon_cart_cron {
|
22 |
-
var $cart_settings_cron;
|
23 |
-
var $cart_abandon_cut_off_time_cron;
|
24 |
-
public function __construct() {
|
25 |
-
$this->cart_settings_cron = get_option( 'ac_lite_cart_abandoned_time' );
|
26 |
-
$this->cart_abandon_cut_off_time_cron = ( $this->cart_settings_cron ) * 60;
|
27 |
-
}
|
28 |
-
/**
|
29 |
-
* Function to send emails
|
30 |
-
*/
|
31 |
-
function wcal_send_email_notification() {
|
32 |
-
global $wpdb, $woocommerce;
|
33 |
-
//Grab the cart abandoned cut-off time from database.
|
34 |
-
$cart_settings = get_option( 'ac_lite_cart_abandoned_time' );
|
35 |
-
$cart_abandon_cut_off_time = $cart_settings * 60;
|
36 |
-
//Fetch all active templates present in the system
|
37 |
-
$query = "SELECT wpet . * FROM `".$wpdb->prefix."ac_email_templates_lite` AS wpet
|
38 |
-
WHERE wpet.is_active = '1' ORDER BY `day_or_hour` DESC, `frequency` ASC ";
|
39 |
-
$results = $wpdb->get_results( $query );
|
40 |
-
$hour_seconds = 3600; // 60 * 60
|
41 |
-
$day_seconds = 86400; // 24 * 60 * 60
|
42 |
-
foreach ( $results as $key => $value ) {
|
43 |
-
if ( $value->day_or_hour == 'Days' ) {
|
44 |
-
$time_to_send_template_after = $value->frequency * $day_seconds;
|
45 |
-
} elseif ( $value->day_or_hour == 'Hours' ) {
|
46 |
-
$time_to_send_template_after = $value->frequency * $hour_seconds;
|
47 |
-
}
|
48 |
-
$carts = $this->wcal_get_carts( $time_to_send_template_after, $cart_abandon_cut_off_time );
|
49 |
-
$email_frequency = $value->frequency;
|
50 |
-
$email_body_template = $value->body;
|
51 |
-
$email_subject = stripslashes ( $value->subject );
|
52 |
-
$email_subject = convert_smilies ( $email_subject );
|
53 |
-
$wcal_from_name = get_option ( 'wcal_from_name' );
|
54 |
-
$wcal_from_email = get_option ( 'wcal_from_email' );
|
55 |
-
$wcal_reply_email = get_option ( 'wcal_reply_email' );
|
56 |
-
if ( class_exists( 'WP_Better_Emails' ) ) {
|
57 |
-
$headers = "From: " . $wcal_from_name . " <" . $wcal_from_email . ">" . "\r\n";
|
58 |
-
$headers .= "Content-Type: text/plain"."\r\n";
|
59 |
-
$headers .= "Reply-To: " . $wcal_reply_email . " " . "\r\n";
|
60 |
-
} else {
|
61 |
-
$headers = "From: " . $wcal_from_name . " <" . $wcal_from_email . ">" . "\r\n";
|
62 |
-
$headers .= "Content-Type: text/html"."\r\n";
|
63 |
-
$headers .= "Reply-To: " . $wcal_reply_email . " " . "\r\n";
|
64 |
-
}
|
65 |
-
$template_id = $value->id;
|
66 |
-
$is_wc_template = $value->is_wc_template;
|
67 |
-
$wc_template_header_text = $value->wc_email_header != '' ? $value->wc_email_header : __( 'Abandoned cart reminder', 'woocommerce-ac');
|
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( $
|
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 |
-
|
116 |
-
/**
|
117 |
-
* When we click on the place order button, we check if the order is placed after the
|
118 |
-
* cut off time. And if yes then if the status of the order is pending or falied then
|
119 |
-
* we keep it as the abandonoed and we need to send reminder emails. So in below function
|
120 |
-
* we first check if any order is placed with todays date then we do not send the
|
121 |
-
* reminder email. But what if placed order status is pending or falied? So this
|
122 |
-
* condition will not call that function andthe reminder email will be sent.
|
123 |
-
*/
|
124 |
-
|
125 |
-
$wcal_check_if_cart_is_present_in_post_meta = "SELECT wpm.post_id, wpost.post_date, wpost.post_status FROM `" . $wpdb->prefix . "postmeta` AS wpm
|
126 |
-
LEFT JOIN `" . $wpdb->prefix . "posts` AS wpost
|
127 |
-
ON wpm.post_id = wpost.ID
|
128 |
-
WHERE wpm.meta_key = 'wcap_recover_order_placed' AND
|
129 |
-
wpm.meta_value = %s AND wpm.post_id = wpost.ID AND
|
130 |
-
wpost.post_type = 'shop_order'
|
131 |
-
ORDER BY wpm.post_id DESC LIMIT 1";
|
132 |
-
|
133 |
-
$results_wcal_check_if_cart_is_present_in_post_meta = $wpdb->get_results( $wpdb->prepare( $wcal_check_if_cart_is_present_in_post_meta, $value->id ) );
|
134 |
-
|
135 |
-
$wcap_check_cart_staus_need_to_update = false;
|
136 |
-
|
137 |
-
if ( empty ($results_wcal_check_if_cart_is_present_in_post_meta) ||
|
138 |
-
( isset( $results_wcal_check_if_cart_is_present_in_post_meta[0] ) &&
|
139 |
-
$results_wcal_check_if_cart_is_present_in_post_meta[0]->post_status != "wc-failed" &&
|
140 |
-
$results_wcal_check_if_cart_is_present_in_post_meta [0]->post_status != "wc-pending" ) ){
|
141 |
-
|
142 |
-
$wcap_check_cart_staus_need_to_update = woocommerce_abandon_cart_cron::wcal_update_abandoned_cart_status_for_placed_orders ( $time_to_send_template_after, $cart_update_time, $value->user_id, $value->user_type, $value->id, $value->user_email );
|
143 |
-
}
|
144 |
-
|
145 |
-
if ( false == $wcal_check_cart_needed_for_multiple_template &&
|
146 |
-
false == $wcap_check_cart_staus_need_to_update ) {
|
147 |
-
|
148 |
-
$cart_info_db = $value->abandoned_cart_info;
|
149 |
-
$email_body = $email_body_template;
|
150 |
-
$wcal_check_cart_total = $this->wcal_check_cart_total( $cart );
|
151 |
-
if( true == $wcal_check_cart_total ) {
|
152 |
-
if ( $value->user_type == "GUEST" ) {
|
153 |
-
if ( isset( $results_guest[0]->billing_first_name ) ) {
|
154 |
-
$email_body = str_replace( "{{customer.firstname}}", $results_guest[0]->billing_first_name, $email_body );
|
155 |
-
$email_subject = str_replace( "{{customer.firstname}}", $results_guest[0]->billing_first_name, $email_subject );
|
156 |
-
}
|
157 |
-
if ( isset( $results_guest[0]->billing_last_name ) ) {
|
158 |
-
$email_body = str_replace( "{{customer.lastname}}", $results_guest[0]->billing_last_name, $email_body );
|
159 |
-
}
|
160 |
-
if ( isset( $results_guest[0]->billing_first_name ) && isset( $results_guest[0]->billing_last_name ) ) {
|
161 |
-
$email_body = str_replace( "{{customer.fullname}}", $results_guest[0]->billing_first_name." ".$results_guest[0]->billing_last_name, $email_body );
|
162 |
-
}
|
163 |
-
else if ( isset( $results_guest[0]->billing_first_name ) ) {
|
164 |
-
$email_body = str_replace( "{{customer.fullname}}", $results_guest[0]->billing_first_name, $email_body );
|
165 |
-
}
|
166 |
-
else if ( isset( $results_guest[0]->billing_last_name ) ) {
|
167 |
-
$email_body = str_replace( "{{customer.fullname}}", $results_guest[0]->billing_last_name, $email_body );
|
168 |
-
}
|
169 |
-
} else {
|
170 |
-
$user_first_name = '';
|
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 |
-
}
|
182 |
-
$email_body = str_replace( "{{customer.firstname}}", $user_first_name, $email_body );
|
183 |
-
$email_subject = str_replace( "{{customer.firstname}}", $user_first_name, $email_subject );
|
184 |
-
$user_last_name = '';
|
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 |
-
}
|
196 |
-
$email_body = str_replace( "{{customer.lastname}}", $user_last_name, $email_body );
|
197 |
-
$email_body = str_replace( "{{customer.fullname}}", $user_first_name." ".$user_last_name, $email_body );
|
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 );
|
206 |
-
$query_sent = "INSERT INTO `".$wpdb->prefix."ac_sent_history_lite` ( template_id, abandoned_order_id, sent_time, sent_email_id )
|
207 |
-
VALUES ( %s, %s, '".current_time( 'mysql' )."', %s )";
|
208 |
-
|
209 |
-
$wpdb->query( $wpdb->prepare( $query_sent, $template_id, $value->id, $value->user_email ) );
|
210 |
-
|
211 |
-
$query_id = "SELECT * FROM `".$wpdb->prefix."ac_sent_history_lite`
|
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 |
-
}
|
376 |
-
}
|
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 |
-
}
|
405 |
-
}
|
406 |
-
return false;
|
407 |
-
}
|
408 |
-
/**
|
409 |
-
* get all carts which have the creation time earlier than the one that is passed
|
410 |
-
*/
|
411 |
-
function wcal_get_carts( $template_to_send_after_time, $cart_abandon_cut_off_time ) {
|
412 |
-
global $wpdb;
|
413 |
-
$cart_time = current_time( 'timestamp' ) - $template_to_send_after_time - $cart_abandon_cut_off_time;
|
414 |
-
$cart_ignored = 0;
|
415 |
-
$unsubscribe = 0;
|
416 |
-
$query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac
|
417 |
-
LEFT JOIN ".$wpdb->base_prefix."users AS wpu ON wpac.user_id = wpu.id
|
418 |
-
WHERE cart_ignored = %s AND unsubscribe_link = %s AND abandoned_cart_time < $cart_time
|
419 |
-
ORDER BY `id` ASC ";
|
420 |
-
|
421 |
-
$results = $wpdb->get_results( $wpdb->prepare( $query, $cart_ignored, $unsubscribe ) );
|
422 |
-
return $results;
|
423 |
-
exit;
|
424 |
-
}
|
425 |
-
|
426 |
-
public static function wcal_update_abandoned_cart_status_for_placed_orders( $time_to_send_template_after, $wcal_cart_time, $wcal_user_id, $wcal_user_type, $wcal_cart_id, $wcal_user_email ){
|
427 |
-
global $wpdb;
|
428 |
-
|
429 |
-
if( $wcal_user_id >= '63000000' && 'GUEST' == $wcal_user_type ) {
|
430 |
-
$updated_value = woocommerce_abandon_cart_cron::wcal_update_status_of_guest( $wcal_cart_id, $wcal_cart_time , $time_to_send_template_after, $wcal_user_email );
|
431 |
-
if( 1 == $updated_value ) {
|
432 |
-
return true;
|
433 |
-
}
|
434 |
-
} elseif ( $wcal_user_id < '63000000' && 'REGISTERED' == $wcal_user_type ) {
|
435 |
-
$updated_value = woocommerce_abandon_cart_cron::wcal_update_status_of_loggedin ( $wcal_cart_id, $wcal_cart_time , $time_to_send_template_after, $wcal_user_email );
|
436 |
-
if( 1 == $updated_value ) {
|
437 |
-
return true;
|
438 |
-
}
|
439 |
-
}
|
440 |
-
return false;
|
441 |
-
}
|
442 |
-
|
443 |
-
public static function wcal_update_status_of_guest ( $cart_id, $abandoned_cart_time , $time_to_send_template_after, $wcal_user_email_address ) {
|
444 |
-
global $wpdb;
|
445 |
-
|
446 |
-
$query_email_id = "SELECT wpm.post_id, wpost.post_date, wpost.post_status FROM `" . $wpdb->prefix . "postmeta` AS wpm LEFT JOIN `" . $wpdb->prefix . "posts` AS wpost ON wpm.post_id = wpost.ID
|
447 |
-
WHERE wpm.meta_key = '_billing_email' AND wpm.meta_value = %s AND wpm.post_id = wpost.ID AND wpost.post_type = 'shop_order' Order BY wpm.post_id DESC LIMIT 1";
|
448 |
-
|
449 |
-
$results_query_email = $wpdb->get_results( $wpdb->prepare( $query_email_id, $wcal_user_email_address ) );
|
450 |
-
|
451 |
-
/* This will check that For abc@abc.com email address we have order for todays date in WC post table */
|
452 |
-
if ( count( $results_query_email ) > 0 ) {
|
453 |
-
|
454 |
-
$current_time = current_time( 'timestamp' );
|
455 |
-
$todays_date = date( 'Y-m-d', $current_time );
|
456 |
-
|
457 |
-
$order_date_with_time = $results_query_email[0]->post_date;
|
458 |
-
$order_date = substr( $order_date_with_time, 0, 10 );
|
459 |
-
|
460 |
-
if ( $order_date == $todays_date ) {
|
461 |
-
|
462 |
-
/**
|
463 |
-
* in some case the cart is recovered but it is not marked as the recovred. So here we check if any
|
464 |
-
* record is found for that cart id if yes then update the record respectively.
|
465 |
-
*/
|
466 |
-
$wcal_check_email_sent_to_cart = woocommerce_abandon_cart_cron::wcal_get_cart_sent_data ( $cart_id );
|
467 |
-
|
468 |
-
if ( 0 != $wcal_check_email_sent_to_cart ) {
|
469 |
-
|
470 |
-
$wcal_query = "SELECT `post_id` FROM `" . $wpdb->prefix . "postmeta` WHERE meta_value = %s";
|
471 |
-
$wcal_results = $wpdb->get_results ( $wpdb->prepare( $wcal_query , $cart_id ) );
|
472 |
-
|
473 |
-
if ( count( $wcal_results ) > 0 ) {
|
474 |
-
|
475 |
-
$order_id = $wcal_results[0]->post_id;
|
476 |
-
|
477 |
-
$order = new WC_Order( $order_id );
|
478 |
-
|
479 |
-
$query_order = "UPDATE `" . $wpdb->prefix."ac_abandoned_cart_history_lite` SET recovered_cart= '" . $order_id . "', cart_ignored = '1' WHERE id = '".$cart_id."' ";
|
480 |
-
$wpdb->query( $query_order );
|
481 |
-
|
482 |
-
$order->add_order_note( __( 'This order was abandoned & subsequently recovered.', 'woocommerce-ac' ) );
|
483 |
-
|
484 |
-
delete_post_meta( $order_id, 'wcal_recover_order_placed', $cart_id );
|
485 |
-
delete_post_meta( $order_id , 'wcal_recover_order_placed_sent_id', $wcal_check_email_sent_to_cart );
|
486 |
-
}
|
487 |
-
}else{
|
488 |
-
|
489 |
-
$query_ignored = "UPDATE `" . $wpdb->prefix."ac_abandoned_cart_history_lite` SET cart_ignored = '1' WHERE id ='" . $cart_id . "'";
|
490 |
-
$wpdb->query( $query_ignored );
|
491 |
-
}
|
492 |
-
return 1;
|
493 |
-
}else if ( strtotime( $order_date_with_time ) > $abandoned_cart_time ) {
|
494 |
-
$query_ignored = "UPDATE `" . $wpdb->prefix."ac_abandoned_cart_history_lite` SET cart_ignored = '1' WHERE id ='" . $cart_id . "'";
|
495 |
-
$wpdb->query( $query_ignored );
|
496 |
-
return 1;
|
497 |
-
} else if( "wc-pending" == $results_query_email[0]->post_status || "wc-failed" == $results_query_email[0]->post_status ) {
|
498 |
-
|
499 |
-
/**
|
500 |
-
* If the post status are pending or failed the send them for abandoned cart reminder emails.
|
501 |
-
*/
|
502 |
-
return 0;
|
503 |
-
}
|
504 |
-
}
|
505 |
-
return 0;
|
506 |
-
}
|
507 |
-
|
508 |
-
public static function wcal_update_status_of_loggedin( $cart_id, $abandoned_cart_time , $time_to_send_template_after, $user_billing_email ) {
|
509 |
-
global $wpdb;
|
510 |
-
|
511 |
-
$query_email_id = "SELECT wpm.post_id, wpost.post_date, wpost.post_status FROM `" . $wpdb->prefix . "postmeta` AS wpm LEFT JOIN `" . $wpdb->prefix . "posts` AS wpost ON wpm.post_id = wpost.ID WHERE wpm.meta_key = '_billing_email' AND wpm.meta_value = %s AND wpm.post_id = wpost.ID Order BY wpm.post_id DESC LIMIT 1";
|
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 |
-
|
534 |
-
$order = new WC_Order( $order_id );
|
535 |
-
|
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 );
|
548 |
-
}
|
549 |
-
return 1;
|
550 |
-
}else if ( strtotime( $order_date_time ) >= $abandoned_cart_time ) {
|
551 |
-
$query_ignored = "UPDATE `" . $wpdb->prefix."ac_abandoned_cart_history_lite` SET cart_ignored = '1' WHERE id ='" . $cart_id . "'";
|
552 |
-
$wpdb->query( $query_ignored );
|
553 |
-
return 1; //We return here 1 so it indicate that the cart has been modifed so do not sent email and delete from the array.
|
554 |
-
}else if( "wc-pending" == $results_query_email[0]->post_status || "wc-failed" == $results_query_email[0]->post_status ) {
|
555 |
-
return 0; //if status of the order is pending or falied then return 0 so it will not delete that cart and send reminder email
|
556 |
-
}
|
557 |
-
}
|
558 |
-
return 0; // it means there are no record found to be update it.
|
559 |
-
}
|
560 |
-
|
561 |
-
public static function wcal_get_cart_sent_data ( $wcal_cart_id ) {
|
562 |
-
global $wpdb;
|
563 |
-
|
564 |
-
$wcal_query = "SELECT id FROM `" . $wpdb->prefix."ac_sent_history_lite` WHERE abandoned_order_id = %d ORDER BY 'id' DESC LIMIT 1 ";
|
565 |
-
$wcal_results = $wpdb->get_results ( $wpdb->prepare( $wcal_query , $wcal_cart_id ) );
|
566 |
-
|
567 |
-
if ( count( $wcal_results ) > 0 ) {
|
568 |
-
$wcal_sent_id = $wcal_results[0]->id;
|
569 |
-
return $wcal_sent_id;
|
570 |
-
}
|
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 |
-
|
577 |
-
$wcal_get_last_email_sent_time = "SELECT * FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE abandoned_order_id = $wcal_cart_id ORDER BY `sent_time` DESC LIMIT 1";
|
578 |
-
$wcal_get_last_email_sent_time_results_list = $wpdb->get_results( $wcal_get_last_email_sent_time );
|
579 |
-
|
580 |
-
if( count( $wcal_get_last_email_sent_time_results_list ) > 0 ) {
|
581 |
-
$last_template_send_time = strtotime( $wcal_get_last_email_sent_time_results_list[0]->sent_time );
|
582 |
-
$second_template_send_time = $last_template_send_time + $time_to_send_template_after ;
|
583 |
-
$current_time_test = current_time( 'timestamp' );
|
584 |
-
if( $second_template_send_time > $current_time_test ) {
|
585 |
-
return true;
|
586 |
-
}
|
587 |
-
}
|
588 |
-
|
589 |
-
return false;
|
590 |
-
}
|
591 |
-
/******
|
592 |
-
* This function is used to encode the validate string.
|
593 |
-
******/
|
594 |
-
function wcal_encrypt_validate( $validate ) {
|
595 |
-
$cryptKey = get_option( 'wcal_security_key' );
|
596 |
-
$validate_encoded = Wcal_Aes_Ctr::encrypt( $validate, $cryptKey, 256 );
|
597 |
-
return( $validate_encoded );
|
598 |
-
}
|
599 |
-
|
600 |
-
function wcal_check_sent_history( $user_id, $cart_update_time, $template_id, $id ) {
|
601 |
-
global $wpdb;
|
602 |
-
$query = "SELECT wpcs . * , wpac . abandoned_cart_time , wpac . user_id FROM `".$wpdb->prefix."ac_sent_history_lite` AS wpcs
|
603 |
-
LEFT JOIN ".$wpdb->prefix."ac_abandoned_cart_history_lite AS wpac ON wpcs.abandoned_order_id = wpac.id
|
604 |
-
WHERE template_id = %s AND wpcs.abandoned_order_id = %d ORDER BY 'id' DESC LIMIT 1 ";
|
605 |
-
|
606 |
-
$results = $wpdb->get_results( $wpdb->prepare( $query, $template_id, $id ) );
|
607 |
-
if ( count( $results ) == 0 ) {
|
608 |
-
return true;
|
609 |
-
} elseif ( $results[0]->abandoned_cart_time < $cart_update_time ) {
|
610 |
-
return true;
|
611 |
-
} else {
|
612 |
-
return false;
|
613 |
-
}
|
614 |
-
}
|
615 |
-
}
|
616 |
-
}
|
617 |
-
$woocommerce_abandon_cart_cron = new woocommerce_abandon_cart_cron();
|
618 |
-
$woocommerce_abandon_cart_cron->wcal_send_email_notification();
|
619 |
-
|
620 |
?>
|
1 |
+
<?php
|
2 |
+
static $wp_load; // Since this will be called twice, hold onto it.
|
3 |
+
if ( ! isset( $wp_load ) ) {
|
4 |
+
$wp_load = false;
|
5 |
+
$dir = __FILE__;
|
6 |
+
while( '/' != ( $dir = dirname( $dir ) ) ) {
|
7 |
+
if( file_exists( $wp_load = "{$dir}/wp-load.php" ) ) {
|
8 |
+
break;
|
9 |
+
}
|
10 |
+
}
|
11 |
+
}
|
12 |
+
$wcal_root = dirname( dirname(__FILE__) ); // go two level up for directory from this file.
|
13 |
+
require_once $wp_load;
|
14 |
+
require_once $wcal_root.'/includes/classes/class-wcal-aes.php';
|
15 |
+
require_once $wcal_root.'/includes/classes/class-wcal-aes-counter.php';
|
16 |
+
/**
|
17 |
+
* woocommerce_abandon_cart_cron class
|
18 |
+
**/
|
19 |
+
if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
|
20 |
+
|
21 |
+
class woocommerce_abandon_cart_cron {
|
22 |
+
var $cart_settings_cron;
|
23 |
+
var $cart_abandon_cut_off_time_cron;
|
24 |
+
public function __construct() {
|
25 |
+
$this->cart_settings_cron = get_option( 'ac_lite_cart_abandoned_time' );
|
26 |
+
$this->cart_abandon_cut_off_time_cron = ( $this->cart_settings_cron ) * 60;
|
27 |
+
}
|
28 |
+
/**
|
29 |
+
* Function to send emails
|
30 |
+
*/
|
31 |
+
function wcal_send_email_notification() {
|
32 |
+
global $wpdb, $woocommerce;
|
33 |
+
//Grab the cart abandoned cut-off time from database.
|
34 |
+
$cart_settings = get_option( 'ac_lite_cart_abandoned_time' );
|
35 |
+
$cart_abandon_cut_off_time = $cart_settings * 60;
|
36 |
+
//Fetch all active templates present in the system
|
37 |
+
$query = "SELECT wpet . * FROM `".$wpdb->prefix."ac_email_templates_lite` AS wpet
|
38 |
+
WHERE wpet.is_active = '1' ORDER BY `day_or_hour` DESC, `frequency` ASC ";
|
39 |
+
$results = $wpdb->get_results( $query );
|
40 |
+
$hour_seconds = 3600; // 60 * 60
|
41 |
+
$day_seconds = 86400; // 24 * 60 * 60
|
42 |
+
foreach ( $results as $key => $value ) {
|
43 |
+
if ( $value->day_or_hour == 'Days' ) {
|
44 |
+
$time_to_send_template_after = $value->frequency * $day_seconds;
|
45 |
+
} elseif ( $value->day_or_hour == 'Hours' ) {
|
46 |
+
$time_to_send_template_after = $value->frequency * $hour_seconds;
|
47 |
+
}
|
48 |
+
$carts = $this->wcal_get_carts( $time_to_send_template_after, $cart_abandon_cut_off_time );
|
49 |
+
$email_frequency = $value->frequency;
|
50 |
+
$email_body_template = $value->body;
|
51 |
+
$email_subject = stripslashes ( $value->subject );
|
52 |
+
$email_subject = convert_smilies ( $email_subject );
|
53 |
+
$wcal_from_name = get_option ( 'wcal_from_name' );
|
54 |
+
$wcal_from_email = get_option ( 'wcal_from_email' );
|
55 |
+
$wcal_reply_email = get_option ( 'wcal_reply_email' );
|
56 |
+
if ( class_exists( 'WP_Better_Emails' ) ) {
|
57 |
+
$headers = "From: " . $wcal_from_name . " <" . $wcal_from_email . ">" . "\r\n";
|
58 |
+
$headers .= "Content-Type: text/plain"."\r\n";
|
59 |
+
$headers .= "Reply-To: " . $wcal_reply_email . " " . "\r\n";
|
60 |
+
} else {
|
61 |
+
$headers = "From: " . $wcal_from_name . " <" . $wcal_from_email . ">" . "\r\n";
|
62 |
+
$headers .= "Content-Type: text/html"."\r\n";
|
63 |
+
$headers .= "Reply-To: " . $wcal_reply_email . " " . "\r\n";
|
64 |
+
}
|
65 |
+
$template_id = $value->id;
|
66 |
+
$is_wc_template = $value->is_wc_template;
|
67 |
+
$wc_template_header_text = $value->wc_email_header != '' ? $value->wc_email_header : __( 'Abandoned cart reminder', 'woocommerce-ac');
|
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->cart ) ) {
|
99 |
+
$cart = $cart_info_db_field->cart;
|
100 |
+
}
|
101 |
+
if( count( $cart ) > 0 && isset( $value->user_id ) && '0' != $value->user_id && isset( $value->id ) ) {
|
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 |
+
|
116 |
+
/**
|
117 |
+
* When we click on the place order button, we check if the order is placed after the
|
118 |
+
* cut off time. And if yes then if the status of the order is pending or falied then
|
119 |
+
* we keep it as the abandonoed and we need to send reminder emails. So in below function
|
120 |
+
* we first check if any order is placed with todays date then we do not send the
|
121 |
+
* reminder email. But what if placed order status is pending or falied? So this
|
122 |
+
* condition will not call that function andthe reminder email will be sent.
|
123 |
+
*/
|
124 |
+
|
125 |
+
$wcal_check_if_cart_is_present_in_post_meta = "SELECT wpm.post_id, wpost.post_date, wpost.post_status FROM `" . $wpdb->prefix . "postmeta` AS wpm
|
126 |
+
LEFT JOIN `" . $wpdb->prefix . "posts` AS wpost
|
127 |
+
ON wpm.post_id = wpost.ID
|
128 |
+
WHERE wpm.meta_key = 'wcap_recover_order_placed' AND
|
129 |
+
wpm.meta_value = %s AND wpm.post_id = wpost.ID AND
|
130 |
+
wpost.post_type = 'shop_order'
|
131 |
+
ORDER BY wpm.post_id DESC LIMIT 1";
|
132 |
+
|
133 |
+
$results_wcal_check_if_cart_is_present_in_post_meta = $wpdb->get_results( $wpdb->prepare( $wcal_check_if_cart_is_present_in_post_meta, $value->id ) );
|
134 |
+
|
135 |
+
$wcap_check_cart_staus_need_to_update = false;
|
136 |
+
|
137 |
+
if ( empty ($results_wcal_check_if_cart_is_present_in_post_meta) ||
|
138 |
+
( isset( $results_wcal_check_if_cart_is_present_in_post_meta[0] ) &&
|
139 |
+
$results_wcal_check_if_cart_is_present_in_post_meta[0]->post_status != "wc-failed" &&
|
140 |
+
$results_wcal_check_if_cart_is_present_in_post_meta [0]->post_status != "wc-pending" ) ){
|
141 |
+
|
142 |
+
$wcap_check_cart_staus_need_to_update = woocommerce_abandon_cart_cron::wcal_update_abandoned_cart_status_for_placed_orders ( $time_to_send_template_after, $cart_update_time, $value->user_id, $value->user_type, $value->id, $value->user_email );
|
143 |
+
}
|
144 |
+
|
145 |
+
if ( false == $wcal_check_cart_needed_for_multiple_template &&
|
146 |
+
false == $wcap_check_cart_staus_need_to_update ) {
|
147 |
+
|
148 |
+
$cart_info_db = $value->abandoned_cart_info;
|
149 |
+
$email_body = $email_body_template;
|
150 |
+
$wcal_check_cart_total = $this->wcal_check_cart_total( $cart );
|
151 |
+
if( true == $wcal_check_cart_total ) {
|
152 |
+
if ( $value->user_type == "GUEST" ) {
|
153 |
+
if ( isset( $results_guest[0]->billing_first_name ) ) {
|
154 |
+
$email_body = str_replace( "{{customer.firstname}}", $results_guest[0]->billing_first_name, $email_body );
|
155 |
+
$email_subject = str_replace( "{{customer.firstname}}", $results_guest[0]->billing_first_name, $email_subject );
|
156 |
+
}
|
157 |
+
if ( isset( $results_guest[0]->billing_last_name ) ) {
|
158 |
+
$email_body = str_replace( "{{customer.lastname}}", $results_guest[0]->billing_last_name, $email_body );
|
159 |
+
}
|
160 |
+
if ( isset( $results_guest[0]->billing_first_name ) && isset( $results_guest[0]->billing_last_name ) ) {
|
161 |
+
$email_body = str_replace( "{{customer.fullname}}", $results_guest[0]->billing_first_name." ".$results_guest[0]->billing_last_name, $email_body );
|
162 |
+
}
|
163 |
+
else if ( isset( $results_guest[0]->billing_first_name ) ) {
|
164 |
+
$email_body = str_replace( "{{customer.fullname}}", $results_guest[0]->billing_first_name, $email_body );
|
165 |
+
}
|
166 |
+
else if ( isset( $results_guest[0]->billing_last_name ) ) {
|
167 |
+
$email_body = str_replace( "{{customer.fullname}}", $results_guest[0]->billing_last_name, $email_body );
|
168 |
+
}
|
169 |
+
} else {
|
170 |
+
$user_first_name = '';
|
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 |
+
}
|
182 |
+
$email_body = str_replace( "{{customer.firstname}}", $user_first_name, $email_body );
|
183 |
+
$email_subject = str_replace( "{{customer.firstname}}", $user_first_name, $email_subject );
|
184 |
+
$user_last_name = '';
|
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 |
+
}
|
196 |
+
$email_body = str_replace( "{{customer.lastname}}", $user_last_name, $email_body );
|
197 |
+
$email_body = str_replace( "{{customer.fullname}}", $user_first_name." ".$user_last_name, $email_body );
|
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 );
|
206 |
+
$query_sent = "INSERT INTO `".$wpdb->prefix."ac_sent_history_lite` ( template_id, abandoned_order_id, sent_time, sent_email_id )
|
207 |
+
VALUES ( %s, %s, '".current_time( 'mysql' )."', %s )";
|
208 |
+
|
209 |
+
$wpdb->query( $wpdb->prepare( $query_sent, $template_id, $value->id, $value->user_email ) );
|
210 |
+
|
211 |
+
$query_id = "SELECT * FROM `".$wpdb->prefix."ac_sent_history_lite`
|
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 |
+
}
|
376 |
+
}
|
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 |
+
}
|
405 |
+
}
|
406 |
+
return false;
|
407 |
+
}
|
408 |
+
/**
|
409 |
+
* get all carts which have the creation time earlier than the one that is passed
|
410 |
+
*/
|
411 |
+
function wcal_get_carts( $template_to_send_after_time, $cart_abandon_cut_off_time ) {
|
412 |
+
global $wpdb;
|
413 |
+
$cart_time = current_time( 'timestamp' ) - $template_to_send_after_time - $cart_abandon_cut_off_time;
|
414 |
+
$cart_ignored = 0;
|
415 |
+
$unsubscribe = 0;
|
416 |
+
$query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac
|
417 |
+
LEFT JOIN ".$wpdb->base_prefix."users AS wpu ON wpac.user_id = wpu.id
|
418 |
+
WHERE cart_ignored = %s AND unsubscribe_link = %s AND abandoned_cart_time < $cart_time
|
419 |
+
ORDER BY `id` ASC ";
|
420 |
+
|
421 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query, $cart_ignored, $unsubscribe ) );
|
422 |
+
return $results;
|
423 |
+
exit;
|
424 |
+
}
|
425 |
+
|
426 |
+
public static function wcal_update_abandoned_cart_status_for_placed_orders( $time_to_send_template_after, $wcal_cart_time, $wcal_user_id, $wcal_user_type, $wcal_cart_id, $wcal_user_email ){
|
427 |
+
global $wpdb;
|
428 |
+
|
429 |
+
if( $wcal_user_id >= '63000000' && 'GUEST' == $wcal_user_type ) {
|
430 |
+
$updated_value = woocommerce_abandon_cart_cron::wcal_update_status_of_guest( $wcal_cart_id, $wcal_cart_time , $time_to_send_template_after, $wcal_user_email );
|
431 |
+
if( 1 == $updated_value ) {
|
432 |
+
return true;
|
433 |
+
}
|
434 |
+
} elseif ( $wcal_user_id < '63000000' && 'REGISTERED' == $wcal_user_type ) {
|
435 |
+
$updated_value = woocommerce_abandon_cart_cron::wcal_update_status_of_loggedin ( $wcal_cart_id, $wcal_cart_time , $time_to_send_template_after, $wcal_user_email );
|
436 |
+
if( 1 == $updated_value ) {
|
437 |
+
return true;
|
438 |
+
}
|
439 |
+
}
|
440 |
+
return false;
|
441 |
+
}
|
442 |
+
|
443 |
+
public static function wcal_update_status_of_guest ( $cart_id, $abandoned_cart_time , $time_to_send_template_after, $wcal_user_email_address ) {
|
444 |
+
global $wpdb;
|
445 |
+
|
446 |
+
$query_email_id = "SELECT wpm.post_id, wpost.post_date, wpost.post_status FROM `" . $wpdb->prefix . "postmeta` AS wpm LEFT JOIN `" . $wpdb->prefix . "posts` AS wpost ON wpm.post_id = wpost.ID
|
447 |
+
WHERE wpm.meta_key = '_billing_email' AND wpm.meta_value = %s AND wpm.post_id = wpost.ID AND wpost.post_type = 'shop_order' Order BY wpm.post_id DESC LIMIT 1";
|
448 |
+
|
449 |
+
$results_query_email = $wpdb->get_results( $wpdb->prepare( $query_email_id, $wcal_user_email_address ) );
|
450 |
+
|
451 |
+
/* This will check that For abc@abc.com email address we have order for todays date in WC post table */
|
452 |
+
if ( count( $results_query_email ) > 0 ) {
|
453 |
+
|
454 |
+
$current_time = current_time( 'timestamp' );
|
455 |
+
$todays_date = date( 'Y-m-d', $current_time );
|
456 |
+
|
457 |
+
$order_date_with_time = $results_query_email[0]->post_date;
|
458 |
+
$order_date = substr( $order_date_with_time, 0, 10 );
|
459 |
+
|
460 |
+
if ( $order_date == $todays_date ) {
|
461 |
+
|
462 |
+
/**
|
463 |
+
* in some case the cart is recovered but it is not marked as the recovred. So here we check if any
|
464 |
+
* record is found for that cart id if yes then update the record respectively.
|
465 |
+
*/
|
466 |
+
$wcal_check_email_sent_to_cart = woocommerce_abandon_cart_cron::wcal_get_cart_sent_data ( $cart_id );
|
467 |
+
|
468 |
+
if ( 0 != $wcal_check_email_sent_to_cart ) {
|
469 |
+
|
470 |
+
$wcal_query = "SELECT `post_id` FROM `" . $wpdb->prefix . "postmeta` WHERE meta_value = %s";
|
471 |
+
$wcal_results = $wpdb->get_results ( $wpdb->prepare( $wcal_query , $cart_id ) );
|
472 |
+
|
473 |
+
if ( count( $wcal_results ) > 0 ) {
|
474 |
+
|
475 |
+
$order_id = $wcal_results[0]->post_id;
|
476 |
+
|
477 |
+
$order = new WC_Order( $order_id );
|
478 |
+
|
479 |
+
$query_order = "UPDATE `" . $wpdb->prefix."ac_abandoned_cart_history_lite` SET recovered_cart= '" . $order_id . "', cart_ignored = '1' WHERE id = '".$cart_id."' ";
|
480 |
+
$wpdb->query( $query_order );
|
481 |
+
|
482 |
+
$order->add_order_note( __( 'This order was abandoned & subsequently recovered.', 'woocommerce-ac' ) );
|
483 |
+
|
484 |
+
delete_post_meta( $order_id, 'wcal_recover_order_placed', $cart_id );
|
485 |
+
delete_post_meta( $order_id , 'wcal_recover_order_placed_sent_id', $wcal_check_email_sent_to_cart );
|
486 |
+
}
|
487 |
+
}else{
|
488 |
+
|
489 |
+
$query_ignored = "UPDATE `" . $wpdb->prefix."ac_abandoned_cart_history_lite` SET cart_ignored = '1' WHERE id ='" . $cart_id . "'";
|
490 |
+
$wpdb->query( $query_ignored );
|
491 |
+
}
|
492 |
+
return 1;
|
493 |
+
}else if ( strtotime( $order_date_with_time ) > $abandoned_cart_time ) {
|
494 |
+
$query_ignored = "UPDATE `" . $wpdb->prefix."ac_abandoned_cart_history_lite` SET cart_ignored = '1' WHERE id ='" . $cart_id . "'";
|
495 |
+
$wpdb->query( $query_ignored );
|
496 |
+
return 1;
|
497 |
+
} else if( "wc-pending" == $results_query_email[0]->post_status || "wc-failed" == $results_query_email[0]->post_status ) {
|
498 |
+
|
499 |
+
/**
|
500 |
+
* If the post status are pending or failed the send them for abandoned cart reminder emails.
|
501 |
+
*/
|
502 |
+
return 0;
|
503 |
+
}
|
504 |
+
}
|
505 |
+
return 0;
|
506 |
+
}
|
507 |
+
|
508 |
+
public static function wcal_update_status_of_loggedin( $cart_id, $abandoned_cart_time , $time_to_send_template_after, $user_billing_email ) {
|
509 |
+
global $wpdb;
|
510 |
+
|
511 |
+
$query_email_id = "SELECT wpm.post_id, wpost.post_date, wpost.post_status FROM `" . $wpdb->prefix . "postmeta` AS wpm LEFT JOIN `" . $wpdb->prefix . "posts` AS wpost ON wpm.post_id = wpost.ID WHERE wpm.meta_key = '_billing_email' AND wpm.meta_value = %s AND wpm.post_id = wpost.ID Order BY wpm.post_id DESC LIMIT 1";
|
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 |
+
|
534 |
+
$order = new WC_Order( $order_id );
|
535 |
+
|
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 );
|
548 |
+
}
|
549 |
+
return 1;
|
550 |
+
}else if ( strtotime( $order_date_time ) >= $abandoned_cart_time ) {
|
551 |
+
$query_ignored = "UPDATE `" . $wpdb->prefix."ac_abandoned_cart_history_lite` SET cart_ignored = '1' WHERE id ='" . $cart_id . "'";
|
552 |
+
$wpdb->query( $query_ignored );
|
553 |
+
return 1; //We return here 1 so it indicate that the cart has been modifed so do not sent email and delete from the array.
|
554 |
+
}else if( "wc-pending" == $results_query_email[0]->post_status || "wc-failed" == $results_query_email[0]->post_status ) {
|
555 |
+
return 0; //if status of the order is pending or falied then return 0 so it will not delete that cart and send reminder email
|
556 |
+
}
|
557 |
+
}
|
558 |
+
return 0; // it means there are no record found to be update it.
|
559 |
+
}
|
560 |
+
|
561 |
+
public static function wcal_get_cart_sent_data ( $wcal_cart_id ) {
|
562 |
+
global $wpdb;
|
563 |
+
|
564 |
+
$wcal_query = "SELECT id FROM `" . $wpdb->prefix."ac_sent_history_lite` WHERE abandoned_order_id = %d ORDER BY 'id' DESC LIMIT 1 ";
|
565 |
+
$wcal_results = $wpdb->get_results ( $wpdb->prepare( $wcal_query , $wcal_cart_id ) );
|
566 |
+
|
567 |
+
if ( count( $wcal_results ) > 0 ) {
|
568 |
+
$wcal_sent_id = $wcal_results[0]->id;
|
569 |
+
return $wcal_sent_id;
|
570 |
+
}
|
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 |
+
|
577 |
+
$wcal_get_last_email_sent_time = "SELECT * FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE abandoned_order_id = $wcal_cart_id ORDER BY `sent_time` DESC LIMIT 1";
|
578 |
+
$wcal_get_last_email_sent_time_results_list = $wpdb->get_results( $wcal_get_last_email_sent_time );
|
579 |
+
|
580 |
+
if( count( $wcal_get_last_email_sent_time_results_list ) > 0 ) {
|
581 |
+
$last_template_send_time = strtotime( $wcal_get_last_email_sent_time_results_list[0]->sent_time );
|
582 |
+
$second_template_send_time = $last_template_send_time + $time_to_send_template_after ;
|
583 |
+
$current_time_test = current_time( 'timestamp' );
|
584 |
+
if( $second_template_send_time > $current_time_test ) {
|
585 |
+
return true;
|
586 |
+
}
|
587 |
+
}
|
588 |
+
|
589 |
+
return false;
|
590 |
+
}
|
591 |
+
/******
|
592 |
+
* This function is used to encode the validate string.
|
593 |
+
******/
|
594 |
+
function wcal_encrypt_validate( $validate ) {
|
595 |
+
$cryptKey = get_option( 'wcal_security_key' );
|
596 |
+
$validate_encoded = Wcal_Aes_Ctr::encrypt( $validate, $cryptKey, 256 );
|
597 |
+
return( $validate_encoded );
|
598 |
+
}
|
599 |
+
|
600 |
+
function wcal_check_sent_history( $user_id, $cart_update_time, $template_id, $id ) {
|
601 |
+
global $wpdb;
|
602 |
+
$query = "SELECT wpcs . * , wpac . abandoned_cart_time , wpac . user_id FROM `".$wpdb->prefix."ac_sent_history_lite` AS wpcs
|
603 |
+
LEFT JOIN ".$wpdb->prefix."ac_abandoned_cart_history_lite AS wpac ON wpcs.abandoned_order_id = wpac.id
|
604 |
+
WHERE template_id = %s AND wpcs.abandoned_order_id = %d ORDER BY 'id' DESC LIMIT 1 ";
|
605 |
+
|
606 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query, $template_id, $id ) );
|
607 |
+
if ( count( $results ) == 0 ) {
|
608 |
+
return true;
|
609 |
+
} elseif ( $results[0]->abandoned_cart_time < $cart_update_time ) {
|
610 |
+
return true;
|
611 |
+
} else {
|
612 |
+
return false;
|
613 |
+
}
|
614 |
+
}
|
615 |
+
}
|
616 |
+
}
|
617 |
+
$woocommerce_abandon_cart_cron = new woocommerce_abandon_cart_cron();
|
618 |
+
$woocommerce_abandon_cart_cron->wcal_send_email_notification();
|
619 |
+
|
620 |
?>
|
woocommerce-abandoned-cart/includes/classes/class-wcal-abandoned-orders-table.php
CHANGED
@@ -1,481 +1,476 @@
|
|
1 |
-
<?php
|
2 |
-
// Load WP_List_Table if not loaded
|
3 |
-
if ( ! class_exists( 'WP_List_Table' ) ) {
|
4 |
-
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
5 |
-
}
|
6 |
-
|
7 |
-
class WCAL_Abandoned_Orders_Table extends WP_List_Table {
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Number of results to show per page
|
11 |
-
*
|
12 |
-
* @var string
|
13 |
-
* @since 2.5.2
|
14 |
-
*/
|
15 |
-
public $per_page = 30;
|
16 |
-
|
17 |
-
/**
|
18 |
-
* URL of this page
|
19 |
-
*
|
20 |
-
* @var string
|
21 |
-
* @since 2.5.2
|
22 |
-
*/
|
23 |
-
public $base_url;
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Total number of bookings
|
27 |
-
*
|
28 |
-
* @var int
|
29 |
-
* @since 2.5.2
|
30 |
-
*/
|
31 |
-
public $total_count;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Get things started
|
35 |
-
*
|
36 |
-
* @see WP_List_Table::__construct()
|
37 |
-
*/
|
38 |
-
public function __construct() {
|
39 |
-
global $status, $page;
|
40 |
-
// Set parent defaults
|
41 |
-
parent::__construct( array(
|
42 |
-
'singular' => __( 'abandoned_order_id', 'woocommerce-ac' ), //singular name of the listed records
|
43 |
-
'plural' => __( 'abandoned_order_ids', 'woocommerce-ac' ), //plural name of the listed records
|
44 |
-
'ajax'
|
45 |
-
) );
|
46 |
-
$this->process_bulk_action();
|
47 |
-
$this->base_url = admin_url( 'admin.php?page=woocommerce_ac_page' );
|
48 |
-
}
|
49 |
-
|
50 |
-
public function wcal_abandoned_order_prepare_items() {
|
51 |
-
$columns = $this->get_columns();
|
52 |
-
$hidden = array(); // No hidden columns
|
53 |
-
$sortable = $this->get_sortable_columns();
|
54 |
-
$this->total_count = 0;
|
55 |
-
$data = $this->wcal_abandoned_cart_data();
|
56 |
-
$this->_column_headers = array( $columns, $hidden, $sortable );
|
57 |
-
$total_items = $this->total_count;
|
58 |
-
|
59 |
-
if( count( $data ) > 0 ) {
|
60 |
-
$this->items = $data;
|
61 |
-
} else {
|
62 |
-
$this->items = array();
|
63 |
-
}
|
64 |
-
$this->set_pagination_args( array(
|
65 |
-
'total_items' => $total_items, // WE have to calculate the total number of items
|
66 |
-
'per_page' => $this->per_page, // WE have to determine how many items to show on a page
|
67 |
-
'total_pages' => ceil( $total_items / $this->per_page ) // WE have to calculate the total number of pages
|
68 |
-
)
|
69 |
-
);
|
70 |
-
}
|
71 |
-
|
72 |
-
public function get_columns() {
|
73 |
-
$columns = array();
|
74 |
-
$columns = array(
|
75 |
-
'cb' => '<input type="checkbox" />',
|
76 |
-
'id' => __( 'Id', 'woocommerce-ac' ),
|
77 |
-
'email' => __( 'Email Address', 'woocommerce-ac' ),
|
78 |
-
'customer' => __( 'Customer', 'woocommerce-ac' ),
|
79 |
-
'order_total' => __( 'Order Total', 'woocommerce-ac' ),
|
80 |
-
'date' => __( 'Abandoned Date', 'woocommerce-ac' ),
|
81 |
-
'status' => __( 'Status of Cart', 'woocommerce-ac' )
|
82 |
-
);
|
83 |
-
return apply_filters( 'wcal_abandoned_orders_columns', $columns );
|
84 |
-
}
|
85 |
-
|
86 |
-
/***
|
87 |
-
* It is used to add the check box for the items
|
88 |
-
*/
|
89 |
-
function column_cb( $item ){
|
90 |
-
$abandoned_order_id = '';
|
91 |
-
if( isset( $item->id ) && "" != $item->id ) {
|
92 |
-
$abandoned_order_id = $item->id;
|
93 |
-
}
|
94 |
-
return sprintf(
|
95 |
-
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
|
96 |
-
'abandoned_order_id',
|
97 |
-
$abandoned_order_id
|
98 |
-
);
|
99 |
-
}
|
100 |
-
|
101 |
-
public function get_sortable_columns() {
|
102 |
-
$columns = array(
|
103 |
-
'date' => array( 'date', false ),
|
104 |
-
'status' => array( 'status',false),
|
105 |
-
);
|
106 |
-
return apply_filters( 'wcal_abandoned_orders_sortable_columns', $columns );
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Render the Email Column
|
111 |
-
*
|
112 |
-
* @access public
|
113 |
-
* @since 2.4.8
|
114 |
-
* @param array $abandoned_row_info Contains all the data of the abandoned order tabs row
|
115 |
-
* @return string Data shown in the Email column
|
116 |
-
*
|
117 |
-
* This function used for individual delete of row, It is for hover effect delete.
|
118 |
-
*/
|
119 |
-
public function column_email( $abandoned_row_info ) {
|
120 |
-
$row_actions
|
121 |
-
$value
|
122 |
-
$abandoned_order_id
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
$
|
137 |
-
$
|
138 |
-
$
|
139 |
-
$
|
140 |
-
$
|
141 |
-
|
142 |
-
$
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
$
|
152 |
-
|
153 |
-
|
154 |
-
$
|
155 |
-
|
156 |
-
|
157 |
-
$
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
$
|
169 |
-
|
170 |
-
|
171 |
-
$
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
$query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$
|
188 |
-
WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' wpac.user_id >= 63000000
|
189 |
-
$results = $wpdb->get_results($query);
|
190 |
-
}
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
$query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$
|
204 |
-
WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' wpac.user_id
|
205 |
-
$results = $wpdb->get_results($query);
|
206 |
-
}
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
break;
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
$
|
254 |
-
}
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
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 |
-
if(
|
298 |
-
$cart_details
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
$
|
339 |
-
$
|
340 |
-
$return_abandoned_orders[ $i ]->
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
}
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
$
|
397 |
-
if( isset( $
|
398 |
-
$
|
399 |
-
}
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
$
|
413 |
-
if( isset( $
|
414 |
-
$
|
415 |
-
}
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
case '
|
436 |
-
if( isset($wcal_abandoned_orders->
|
437 |
-
|
438 |
-
}
|
439 |
-
break;
|
440 |
-
case '
|
441 |
-
if( isset( $wcal_abandoned_orders->
|
442 |
-
|
443 |
-
}
|
444 |
-
break;
|
445 |
-
case '
|
446 |
-
if( isset( $wcal_abandoned_orders->
|
447 |
-
|
448 |
-
}
|
449 |
-
break;
|
450 |
-
case '
|
451 |
-
if( isset( $wcal_abandoned_orders->
|
452 |
-
|
453 |
-
}
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
)
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
$section = $_GET[ 'wcal_section' ];
|
477 |
-
}
|
478 |
-
return $section ;
|
479 |
-
}
|
480 |
-
}
|
481 |
?>
|
1 |
+
<?php
|
2 |
+
// Load WP_List_Table if not loaded
|
3 |
+
if ( ! class_exists( 'WP_List_Table' ) ) {
|
4 |
+
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
5 |
+
}
|
6 |
+
|
7 |
+
class WCAL_Abandoned_Orders_Table extends WP_List_Table {
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Number of results to show per page
|
11 |
+
*
|
12 |
+
* @var string
|
13 |
+
* @since 2.5.2
|
14 |
+
*/
|
15 |
+
public $per_page = 30;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* URL of this page
|
19 |
+
*
|
20 |
+
* @var string
|
21 |
+
* @since 2.5.2
|
22 |
+
*/
|
23 |
+
public $base_url;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Total number of bookings
|
27 |
+
*
|
28 |
+
* @var int
|
29 |
+
* @since 2.5.2
|
30 |
+
*/
|
31 |
+
public $total_count;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Get things started
|
35 |
+
*
|
36 |
+
* @see WP_List_Table::__construct()
|
37 |
+
*/
|
38 |
+
public function __construct() {
|
39 |
+
global $status, $page;
|
40 |
+
// Set parent defaults
|
41 |
+
parent::__construct( array(
|
42 |
+
'singular' => __( 'abandoned_order_id', 'woocommerce-ac' ), //singular name of the listed records
|
43 |
+
'plural' => __( 'abandoned_order_ids', 'woocommerce-ac' ), //plural name of the listed records
|
44 |
+
'ajax' => false // Does this table support ajax?
|
45 |
+
) );
|
46 |
+
$this->process_bulk_action();
|
47 |
+
$this->base_url = admin_url( 'admin.php?page=woocommerce_ac_page' );
|
48 |
+
}
|
49 |
+
|
50 |
+
public function wcal_abandoned_order_prepare_items() {
|
51 |
+
$columns = $this->get_columns();
|
52 |
+
$hidden = array(); // No hidden columns
|
53 |
+
$sortable = $this->get_sortable_columns();
|
54 |
+
$this->total_count = 0;
|
55 |
+
$data = $this->wcal_abandoned_cart_data();
|
56 |
+
$this->_column_headers = array( $columns, $hidden, $sortable );
|
57 |
+
$total_items = $this->total_count;
|
58 |
+
|
59 |
+
if( count( $data ) > 0 ) {
|
60 |
+
$this->items = $data;
|
61 |
+
} else {
|
62 |
+
$this->items = array();
|
63 |
+
}
|
64 |
+
$this->set_pagination_args( array(
|
65 |
+
'total_items' => $total_items, // WE have to calculate the total number of items
|
66 |
+
'per_page' => $this->per_page, // WE have to determine how many items to show on a page
|
67 |
+
'total_pages' => ceil( $total_items / $this->per_page ) // WE have to calculate the total number of pages
|
68 |
+
)
|
69 |
+
);
|
70 |
+
}
|
71 |
+
|
72 |
+
public function get_columns() {
|
73 |
+
$columns = array();
|
74 |
+
$columns = array(
|
75 |
+
'cb' => '<input type="checkbox" />',
|
76 |
+
'id' => __( 'Id', 'woocommerce-ac' ),
|
77 |
+
'email' => __( 'Email Address', 'woocommerce-ac' ),
|
78 |
+
'customer' => __( 'Customer', 'woocommerce-ac' ),
|
79 |
+
'order_total' => __( 'Order Total', 'woocommerce-ac' ),
|
80 |
+
'date' => __( 'Abandoned Date', 'woocommerce-ac' ),
|
81 |
+
'status' => __( 'Status of Cart', 'woocommerce-ac' )
|
82 |
+
);
|
83 |
+
return apply_filters( 'wcal_abandoned_orders_columns', $columns );
|
84 |
+
}
|
85 |
+
|
86 |
+
/***
|
87 |
+
* It is used to add the check box for the items
|
88 |
+
*/
|
89 |
+
function column_cb( $item ){
|
90 |
+
$abandoned_order_id = '';
|
91 |
+
if( isset( $item->id ) && "" != $item->id ) {
|
92 |
+
$abandoned_order_id = $item->id;
|
93 |
+
}
|
94 |
+
return sprintf(
|
95 |
+
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
|
96 |
+
'abandoned_order_id',
|
97 |
+
$abandoned_order_id
|
98 |
+
);
|
99 |
+
}
|
100 |
+
|
101 |
+
public function get_sortable_columns() {
|
102 |
+
$columns = array(
|
103 |
+
'date' => array( 'date', false ),
|
104 |
+
'status' => array( 'status',false),
|
105 |
+
);
|
106 |
+
return apply_filters( 'wcal_abandoned_orders_sortable_columns', $columns );
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Render the Email Column
|
111 |
+
*
|
112 |
+
* @access public
|
113 |
+
* @since 2.4.8
|
114 |
+
* @param array $abandoned_row_info Contains all the data of the abandoned order tabs row
|
115 |
+
* @return string Data shown in the Email column
|
116 |
+
*
|
117 |
+
* This function used for individual delete of row, It is for hover effect delete.
|
118 |
+
*/
|
119 |
+
public function column_email( $abandoned_row_info ) {
|
120 |
+
$row_actions = array();
|
121 |
+
$value = '';
|
122 |
+
$abandoned_order_id = 0;
|
123 |
+
if( isset( $abandoned_row_info->email ) ) {
|
124 |
+
$abandoned_order_id = $abandoned_row_info->id ;
|
125 |
+
$row_actions['edit'] = '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'orderdetails', 'id' => $abandoned_row_info->id ), $this->base_url ), 'abandoned_order_nonce') . '">' . __( 'View order', 'woocommerce-ac' ) . '</a>';
|
126 |
+
$row_actions['delete'] = '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'wcal_delete', 'abandoned_order_id' => $abandoned_row_info->id ), $this->base_url ), 'abandoned_order_nonce') . '">' . __( 'Delete', 'woocommerce-ac' ) . '</a>';
|
127 |
+
$email = $abandoned_row_info->email;
|
128 |
+
$value = $email . $this->row_actions( $row_actions );
|
129 |
+
}
|
130 |
+
return apply_filters( 'wcal_abandoned_orders_single_column', $value, $abandoned_order_id, 'email' );
|
131 |
+
}
|
132 |
+
|
133 |
+
public function wcal_abandoned_cart_data() {
|
134 |
+
global $wpdb;
|
135 |
+
$return_abandoned_orders = array();
|
136 |
+
$per_page = $this->per_page;
|
137 |
+
$results = array();
|
138 |
+
$blank_cart_info = '{"cart":[]}';
|
139 |
+
$blank_cart_info_guest = '[]';
|
140 |
+
$blank_cart = '""';
|
141 |
+
$get_section_of_page = WCAL_Abandoned_Orders_Table::wcal_get_current_section();
|
142 |
+
$results = array();
|
143 |
+
switch ( $get_section_of_page ) {
|
144 |
+
case 'wcal_all_abandoned':
|
145 |
+
# code...
|
146 |
+
if( is_multisite() ) {
|
147 |
+
// get main site's table prefix
|
148 |
+
$main_prefix = $wpdb->get_blog_prefix(1);
|
149 |
+
$query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$main_prefix."users AS wpu ON wpac.user_id = wpu.id
|
150 |
+
WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart%' ORDER BY wpac.abandoned_cart_time DESC";
|
151 |
+
$results = $wpdb->get_results( $query );
|
152 |
+
} else {
|
153 |
+
// non-multisite - regular table name
|
154 |
+
$query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$wpdb->prefix."users AS wpu ON wpac.user_id = wpu.id
|
155 |
+
WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart%' ORDER BY wpac.abandoned_cart_time DESC ";
|
156 |
+
|
157 |
+
$results = $wpdb->get_results( $query );
|
158 |
+
}
|
159 |
+
break;
|
160 |
+
|
161 |
+
case 'wcal_all_registered':
|
162 |
+
# code...
|
163 |
+
if( is_multisite() ) {
|
164 |
+
// get main site's table prefix
|
165 |
+
$main_prefix = $wpdb->get_blog_prefix(1);
|
166 |
+
$query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$main_prefix."users AS wpu ON wpac.user_id = wpu.id
|
167 |
+
WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart%' ORDER BY wpac.abandoned_cart_time DESC ";
|
168 |
+
$results = $wpdb->get_results( $query );
|
169 |
+
} else {
|
170 |
+
// non-multisite - regular table name
|
171 |
+
$query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$wpdb->prefix."users AS wpu ON wpac.user_id = wpu.id
|
172 |
+
WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND wpac.user_type = 'REGISTERED' AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart%' AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart%' ORDER BY wpac.abandoned_cart_time DESC ";
|
173 |
+
$results = $wpdb->get_results( $query );
|
174 |
+
}
|
175 |
+
break;
|
176 |
+
|
177 |
+
case 'wcal_all_guest':
|
178 |
+
# code...
|
179 |
+
if( is_multisite() ) {
|
180 |
+
// get main site's table prefix
|
181 |
+
$main_prefix = $wpdb->get_blog_prefix(1);
|
182 |
+
$query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$main_prefix."users AS wpu ON wpac.user_id = wpu.id
|
183 |
+
WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info' AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart%' AND wpac.user_id >= 63000000 ORDER BY wpac.abandoned_cart_time DESC ";
|
184 |
+
$results = $wpdb->get_results( $query );
|
185 |
+
} else {
|
186 |
+
// non-multisite - regular table name
|
187 |
+
$query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$wpdb->prefix."users AS wpu ON wpac.user_id = wpu.id
|
188 |
+
WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info' AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart%' AND wpac.user_id >= 63000000 ORDER BY wpac.abandoned_cart_time DESC ";
|
189 |
+
$results = $wpdb->get_results( $query );
|
190 |
+
}
|
191 |
+
break;
|
192 |
+
|
193 |
+
case 'wcal_all_visitor':
|
194 |
+
# code...
|
195 |
+
if( is_multisite() ) {
|
196 |
+
// get main site's table prefix
|
197 |
+
$main_prefix = $wpdb->get_blog_prefix(1);
|
198 |
+
$query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$main_prefix."users AS wpu ON wpac.user_id = wpu.id
|
199 |
+
WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info' AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart%' AND wpac.user_id >= 63000000 ORDER BY wpac.abandoned_cart_time DESC ";
|
200 |
+
$results = $wpdb->get_results( $query );
|
201 |
+
} else {
|
202 |
+
// non-multisite - regular table name
|
203 |
+
$query = "SELECT wpac . * , wpu.user_login, wpu.user_email FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac LEFT JOIN ".$wpdb->prefix."users AS wpu ON wpac.user_id = wpu.id
|
204 |
+
WHERE wpac.recovered_cart='0' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND wpac.abandoned_cart_info NOT LIKE '$blank_cart_info' AND wpac.abandoned_cart_info NOT LIKE '%$blank_cart%' AND wpac.user_id = 0 ORDER BY wpac.abandoned_cart_time DESC ";
|
205 |
+
$results = $wpdb->get_results( $query );
|
206 |
+
}
|
207 |
+
break;
|
208 |
+
|
209 |
+
|
210 |
+
default:
|
211 |
+
# code...
|
212 |
+
break;
|
213 |
+
}
|
214 |
+
$i = 0;
|
215 |
+
|
216 |
+
foreach( $results as $key => $value ) {
|
217 |
+
if( $value->user_type == "GUEST" ) {
|
218 |
+
$query_guest = "SELECT * from `" . $wpdb->prefix . "ac_guest_abandoned_cart_history_lite` WHERE id = %d";
|
219 |
+
$results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $value->user_id ) );
|
220 |
+
}
|
221 |
+
$abandoned_order_id = $value->id;
|
222 |
+
$user_id = $value->user_id;
|
223 |
+
$user_login = $value->user_login;
|
224 |
+
|
225 |
+
if ( $value->user_type == "GUEST" ) {
|
226 |
+
|
227 |
+
if ( isset( $results_guest[0]->email_id ) ) {
|
228 |
+
$user_email = $results_guest[0]->email_id;
|
229 |
+
} elseif ( $value->user_id == "0" ) {
|
230 |
+
$user_email = '';
|
231 |
+
} else {
|
232 |
+
$user_email = '';
|
233 |
+
}
|
234 |
+
|
235 |
+
if ( isset( $results_guest[0]->billing_first_name ) ) {
|
236 |
+
$user_first_name = $results_guest[0]->billing_first_name;
|
237 |
+
} else if( $value->user_id == "0" ) {
|
238 |
+
$user_first_name = "Visitor";
|
239 |
+
} else {
|
240 |
+
$user_first_name = "";
|
241 |
+
}
|
242 |
+
|
243 |
+
if ( isset( $results_guest[0]->billing_last_name ) ) {
|
244 |
+
$user_last_name = $results_guest[0]->billing_last_name;
|
245 |
+
} else if( $value->user_id == "0" ) {
|
246 |
+
$user_last_name = "";
|
247 |
+
} else {
|
248 |
+
$user_last_name = "";
|
249 |
+
}
|
250 |
+
} else {
|
251 |
+
$user_email_billing = get_user_meta( $value->user_id, 'billing_email', true );
|
252 |
+
if( $user_email_billing != '' ) {
|
253 |
+
$user_email = $user_email_billing;
|
254 |
+
} else {
|
255 |
+
$user_data = get_userdata( $value->user_id );
|
256 |
+
$user_email = $user_data->user_email;
|
257 |
+
}
|
258 |
+
$user_first_name = "";
|
259 |
+
$user_first_name_temp = get_user_meta( $user_id, 'billing_first_name', true );
|
260 |
+
if( isset( $user_first_name_temp ) && "" == $user_first_name_temp ) {
|
261 |
+
$user_data = get_userdata( $user_id );
|
262 |
+
$user_first_name = $user_data->first_name;
|
263 |
+
} else {
|
264 |
+
$user_first_name = $user_first_name_temp;
|
265 |
+
}
|
266 |
+
|
267 |
+
$user_last_name = "";
|
268 |
+
$user_last_name_temp = get_user_meta( $user_id, 'billing_last_name', true );
|
269 |
+
if( isset( $user_last_name_temp ) && "" == $user_last_name_temp ) {
|
270 |
+
$user_data = get_userdata( $user_id );
|
271 |
+
$user_last_name = $user_data->last_name;
|
272 |
+
} else {
|
273 |
+
$user_last_name = $user_last_name_temp;
|
274 |
+
}
|
275 |
+
}
|
276 |
+
|
277 |
+
$cart_info = json_decode( $value->abandoned_cart_info );
|
278 |
+
$order_date = "";
|
279 |
+
$cart_update_time = $value->abandoned_cart_time;
|
280 |
+
|
281 |
+
if ( $cart_update_time != "" && $cart_update_time != 0 ) {
|
282 |
+
$date_format = date_i18n( get_option( 'date_format' ), $cart_update_time );
|
283 |
+
$time_format = date_i18n( get_option( 'time_format' ), $cart_update_time );
|
284 |
+
$order_date = $date_format . ' ' . $time_format;
|
285 |
+
}
|
286 |
+
|
287 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
288 |
+
$cut_off_time = intval( $ac_cutoff_time ) * 60;
|
289 |
+
$current_time = current_time( 'timestamp' );
|
290 |
+
$compare_time = $current_time - $cart_update_time;
|
291 |
+
$cart_details = array();
|
292 |
+
if( isset( $cart_info->cart ) ){
|
293 |
+
$cart_details = $cart_info->cart;
|
294 |
+
}
|
295 |
+
$line_total = 0;
|
296 |
+
|
297 |
+
if( count( $cart_details ) > 0 ) {
|
298 |
+
foreach( $cart_details as $k => $v ) {
|
299 |
+
if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
|
300 |
+
$line_total = $line_total + $v->line_total + $v->line_subtotal_tax;
|
301 |
+
} else {
|
302 |
+
$line_total = $line_total + $v->line_total;
|
303 |
+
}
|
304 |
+
}
|
305 |
+
}
|
306 |
+
//$number_decimal = wc_get_price_decimals();
|
307 |
+
$line_total = wc_price( $line_total );
|
308 |
+
$quantity_total = 0;
|
309 |
+
|
310 |
+
if ( count( $cart_details ) > 0) {
|
311 |
+
foreach( $cart_details as $k => $v ) {
|
312 |
+
$quantity_total = $quantity_total + $v->quantity;
|
313 |
+
}
|
314 |
+
}
|
315 |
+
|
316 |
+
if ( 1 == $quantity_total ) {
|
317 |
+
$item_disp = __("item", "woocommerce-ac");
|
318 |
+
} else {
|
319 |
+
$item_disp = __("items", "woocommerce-ac");
|
320 |
+
}
|
321 |
+
|
322 |
+
if( $value->cart_ignored == 0 && $value->recovered_cart == 0 ) {
|
323 |
+
$ac_status = __( "Abandoned", "woocommerce-ac" );
|
324 |
+
} elseif( $value->cart_ignored == 1 && $value->recovered_cart == 0 ) {
|
325 |
+
$ac_status = __( "Abandoned but new","woocommerce-ac" )."</br>". __( "cart created after this", "woocommerce-ac" );
|
326 |
+
} else {
|
327 |
+
$ac_status = "";
|
328 |
+
}
|
329 |
+
|
330 |
+
if( $compare_time > $cut_off_time && $ac_status != "" ) {
|
331 |
+
$return_abandoned_orders[$i] = new stdClass();
|
332 |
+
if( $quantity_total > 0 ) {
|
333 |
+
$abandoned_order_id = $abandoned_order_id;
|
334 |
+
$customer_information = $user_first_name . " ".$user_last_name;
|
335 |
+
$return_abandoned_orders[ $i ]->id = $abandoned_order_id;
|
336 |
+
$return_abandoned_orders[ $i ]->email = $user_email;
|
337 |
+
$return_abandoned_orders[ $i ]->customer = $customer_information;
|
338 |
+
$return_abandoned_orders[ $i ]->order_total = $line_total;
|
339 |
+
$return_abandoned_orders[ $i ]->date = $order_date;
|
340 |
+
$return_abandoned_orders[ $i ]->status = $ac_status;
|
341 |
+
}else {
|
342 |
+
$abandoned_order_id = $abandoned_order_id;
|
343 |
+
$return_abandoned_orders[ $i ]->id = $abandoned_order_id;
|
344 |
+
$return_abandoned_orders[ $i ]->date = $order_date;
|
345 |
+
$return_abandoned_orders[ $i ]->status = $ac_status;
|
346 |
+
}
|
347 |
+
// To get the abandoned orders count
|
348 |
+
$this->total_count = count( $return_abandoned_orders );
|
349 |
+
$i++;
|
350 |
+
}
|
351 |
+
}
|
352 |
+
// sort for order date
|
353 |
+
if( isset( $_GET['orderby'] ) && $_GET['orderby'] == 'date' ) {
|
354 |
+
if( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
|
355 |
+
usort( $return_abandoned_orders, array( __CLASS__ , "wcal_class_order_date_asc") );
|
356 |
+
}
|
357 |
+
else {
|
358 |
+
usort( $return_abandoned_orders, array( __CLASS__ , "wcal_class_order_date_dsc") );
|
359 |
+
}
|
360 |
+
}
|
361 |
+
// sort for customer name
|
362 |
+
else if( isset( $_GET['orderby'] ) && $_GET['orderby'] == 'status' ) {
|
363 |
+
if( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
|
364 |
+
usort( $return_abandoned_orders, array( __CLASS__ , "wcal_class_status_asc" ) );
|
365 |
+
} else {
|
366 |
+
usort( $return_abandoned_orders, array( __CLASS__ , "wcal_class_status_dsc" ) );
|
367 |
+
}
|
368 |
+
}
|
369 |
+
|
370 |
+
if( isset( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
|
371 |
+
$page_number = $_GET['paged'] - 1;
|
372 |
+
$k = $per_page * $page_number;
|
373 |
+
} else {
|
374 |
+
$k = 0;
|
375 |
+
}
|
376 |
+
$return_abandoned_orders_display = array();
|
377 |
+
for( $j = $k; $j < ( $k+$per_page ); $j++ ) {
|
378 |
+
if( isset( $return_abandoned_orders[$j] ) ) {
|
379 |
+
$return_abandoned_orders_display[$j] = $return_abandoned_orders[$j];
|
380 |
+
} else {
|
381 |
+
break;
|
382 |
+
}
|
383 |
+
}
|
384 |
+
return apply_filters( 'wcal_abandoned_orders_table_data', $return_abandoned_orders_display );
|
385 |
+
}
|
386 |
+
|
387 |
+
function wcal_class_order_date_asc( $value1,$value2 ) {
|
388 |
+
$date_two = $date_one = '';
|
389 |
+
$value_one = $value1->date;
|
390 |
+
$value_two = $value2->date;
|
391 |
+
$date_formatted_one = date_create_from_format( 'd M, Y h:i A', $value_one );
|
392 |
+
if( isset( $date_formatted_one ) && $date_formatted_one != '' ) {
|
393 |
+
$date_one = date_format( $date_formatted_one, 'Y-m-d h:i A' );
|
394 |
+
}
|
395 |
+
|
396 |
+
$date_formatted_two = date_create_from_format( 'd M, Y h:i A', $value_two );
|
397 |
+
if( isset( $date_formatted_two ) && $date_formatted_two != '' ) {
|
398 |
+
$date_two = date_format( $date_formatted_two, 'Y-m-d h:i A' );
|
399 |
+
}
|
400 |
+
return strtotime( $date_one ) - strtotime( $date_two );
|
401 |
+
}
|
402 |
+
|
403 |
+
function wcal_class_order_date_dsc( $value1,$value2 ) {
|
404 |
+
$date_two = $date_one = '';
|
405 |
+
$value_one = $value1->date;
|
406 |
+
$value_two = $value2->date;
|
407 |
+
$date_formatted_one = date_create_from_format( 'd M, Y h:i A', $value_one );
|
408 |
+
if( isset( $date_formatted_one ) && $date_formatted_one != '' ) {
|
409 |
+
$date_one = date_format( $date_formatted_one, 'Y-m-d h:i A' );
|
410 |
+
}
|
411 |
+
|
412 |
+
$date_formatted_two = date_create_from_format( 'd M, Y h:i A', $value_two );
|
413 |
+
if( isset( $date_formatted_two ) && $date_formatted_two != '' ) {
|
414 |
+
$date_two = date_format( $date_formatted_two, 'Y-m-d h:i A' );
|
415 |
+
}
|
416 |
+
return strtotime($date_two) - strtotime($date_one);
|
417 |
+
}
|
418 |
+
|
419 |
+
function wcal_class_status_asc( $value1,$value2 ) {
|
420 |
+
return strcasecmp( $value1->status,$value2->status );
|
421 |
+
}
|
422 |
+
|
423 |
+
function wcal_class_status_dsc( $value1,$value2 ) {
|
424 |
+
return strcasecmp( $value2->status,$value1->status );
|
425 |
+
}
|
426 |
+
|
427 |
+
public function column_default( $wcal_abandoned_orders, $column_name ) {
|
428 |
+
$value = '';
|
429 |
+
switch( $column_name ) {
|
430 |
+
case 'id' :
|
431 |
+
if( isset($wcal_abandoned_orders->id ) ) {
|
432 |
+
$value = '<strong><a href="admin.php?page=woocommerce_ac_page&action=orderdetails&id='.$wcal_abandoned_orders->id.' ">'.$wcal_abandoned_orders->id.'</a> </strong>';
|
433 |
+
}
|
434 |
+
break;
|
435 |
+
case 'customer' :
|
436 |
+
if( isset( $wcal_abandoned_orders->customer ) ) {
|
437 |
+
$value = $wcal_abandoned_orders->customer;
|
438 |
+
}
|
439 |
+
break;
|
440 |
+
case 'order_total' :
|
441 |
+
if( isset( $wcal_abandoned_orders->order_total ) ) {
|
442 |
+
$value = $wcal_abandoned_orders->order_total;
|
443 |
+
}
|
444 |
+
break;
|
445 |
+
case 'date' :
|
446 |
+
if( isset( $wcal_abandoned_orders->date ) ) {
|
447 |
+
$value = $wcal_abandoned_orders->date;
|
448 |
+
}
|
449 |
+
break;
|
450 |
+
case 'status' :
|
451 |
+
if( isset( $wcal_abandoned_orders->status ) ) {
|
452 |
+
$value = $wcal_abandoned_orders->status;
|
453 |
+
}
|
454 |
+
break;
|
455 |
+
default:
|
456 |
+
$value = isset( $wcal_abandoned_orders->$column_name ) ? $wcal_abandoned_orders->$column_name : '';
|
457 |
+
break;
|
458 |
+
}
|
459 |
+
return apply_filters( 'wcal_abandoned_orders_column_default', $value, $wcal_abandoned_orders, $column_name );
|
460 |
+
}
|
461 |
+
|
462 |
+
public function get_bulk_actions() {
|
463 |
+
return array(
|
464 |
+
'wcal_delete' => __( 'Delete', 'woocommerce-ac' )
|
465 |
+
);
|
466 |
+
}
|
467 |
+
|
468 |
+
public function wcal_get_current_section () {
|
469 |
+
$section = 'wcal_all_abandoned';
|
470 |
+
if ( isset( $_GET[ 'wcal_section' ] ) ) {
|
471 |
+
$section = $_GET[ 'wcal_section' ];
|
472 |
+
}
|
473 |
+
return $section ;
|
474 |
+
}
|
475 |
+
}
|
|
|
|
|
|
|
|
|
|
|
476 |
?>
|
woocommerce-abandoned-cart/includes/classes/class-wcal-aes-counter.php
CHANGED
@@ -1,171 +1,171 @@
|
|
1 |
-
<?php
|
2 |
-
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
3 |
-
/* AES counter (CTR) mode implementation in PHP */
|
4 |
-
/* (c) Chris Veness 2005-2014 www.movable-type.co.uk/scripts */
|
5 |
-
/* Right of free use is granted for all commercial or non-commercial use under CC-BY licence. */
|
6 |
-
/* No warranty of any form is offered. */
|
7 |
-
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
8 |
-
|
9 |
-
Class Wcal_Aes_Ctr extends Wcal_Aes
|
10 |
-
{
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Encrypt a text using AES encryption in Counter mode of operation
|
14 |
-
* - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
|
15 |
-
*
|
16 |
-
* Unicode multi-byte character safe
|
17 |
-
*
|
18 |
-
* @param plaintext source text to be encrypted
|
19 |
-
* @param password the password to use to generate a key
|
20 |
-
* @param nBits number of bits to be used in the key (128, 192, or 256)
|
21 |
-
* @return encrypted text
|
22 |
-
*/
|
23 |
-
public static function encrypt($plaintext, $password, $nBits)
|
24 |
-
{
|
25 |
-
$blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
|
26 |
-
if (!($nBits == 128 || $nBits == 192 || $nBits == 256)) return ''; // standard allows 128/192/256 bit keys
|
27 |
-
// note PHP (5) gives us plaintext and password in UTF8 encoding!
|
28 |
-
|
29 |
-
// use AES itself to encrypt password to get cipher key (using plain password as source for
|
30 |
-
// key expansion) - gives us well encrypted key
|
31 |
-
$nBytes = $nBits / 8; // no bytes in key
|
32 |
-
$pwBytes = array();
|
33 |
-
for ($i = 0; $i < $nBytes; $i++) $pwBytes[$i] = ord(substr($password, $i, 1)) & 0xff;
|
34 |
-
$key = Wcal_Aes::cipher($pwBytes, Wcal_Aes::keyExpansion($pwBytes));
|
35 |
-
$key = array_merge($key, array_slice($key, 0, $nBytes - 16)); // expand key to 16/24/32 bytes long
|
36 |
-
|
37 |
-
// initialise 1st 8 bytes of counter block with nonce (NIST SP800-38A �B.2): [0-1] = millisec,
|
38 |
-
// [2-3] = random, [4-7] = seconds, giving guaranteed sub-ms uniqueness up to Feb 2106
|
39 |
-
$counterBlock = array();
|
40 |
-
$nonce = floor(microtime(true) * 1000); // timestamp: milliseconds since 1-Jan-1970
|
41 |
-
$nonceMs = $nonce % 1000;
|
42 |
-
$nonceSec = floor($nonce / 1000);
|
43 |
-
$nonceRnd = floor(rand(0, 0xffff));
|
44 |
-
|
45 |
-
for ($i = 0; $i < 2; $i++) $counterBlock[$i] = self::urs($nonceMs, $i * 8) & 0xff;
|
46 |
-
for ($i = 0; $i < 2; $i++) $counterBlock[$i + 2] = self::urs($nonceRnd, $i * 8) & 0xff;
|
47 |
-
for ($i = 0; $i < 4; $i++) $counterBlock[$i + 4] = self::urs($nonceSec, $i * 8) & 0xff;
|
48 |
-
|
49 |
-
// and convert it to a string to go on the front of the ciphertext
|
50 |
-
$ctrTxt = '';
|
51 |
-
for ($i = 0; $i < 8; $i++) $ctrTxt .= chr($counterBlock[$i]);
|
52 |
-
|
53 |
-
// generate key schedule - an expansion of the key into distinct Key Rounds for each round
|
54 |
-
$keySchedule = Wcal_Aes::keyExpansion($key);
|
55 |
-
//print_r($keySchedule);
|
56 |
-
|
57 |
-
$blockCount = ceil(strlen($plaintext) / $blockSize);
|
58 |
-
$ciphertxt = array(); // ciphertext as array of strings
|
59 |
-
|
60 |
-
for ($b = 0; $b < $blockCount; $b++) {
|
61 |
-
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
|
62 |
-
// done in two stages for 32-bit ops: using two words allows us to go past 2^32 blocks (68GB)
|
63 |
-
for ($c = 0; $c < 4; $c++) $counterBlock[15 - $c] = self::urs($b, $c * 8) & 0xff;
|
64 |
-
for ($c = 0; $c < 4; $c++) $counterBlock[15 - $c - 4] = self::urs($b / 0x100000000, $c * 8);
|
65 |
-
|
66 |
-
$cipherCntr = Wcal_Aes::cipher($counterBlock, $keySchedule); // -- encrypt counter block --
|
67 |
-
|
68 |
-
// block size is reduced on final block
|
69 |
-
$blockLength = $b < $blockCount - 1 ? $blockSize : (strlen($plaintext) - 1) % $blockSize + 1;
|
70 |
-
$cipherByte = array();
|
71 |
-
|
72 |
-
for ($i = 0; $i < $blockLength; $i++) { // -- xor plaintext with ciphered counter byte-by-byte --
|
73 |
-
$cipherByte[$i] = $cipherCntr[$i] ^ ord(substr($plaintext, $b * $blockSize + $i, 1));
|
74 |
-
$cipherByte[$i] = chr($cipherByte[$i]);
|
75 |
-
}
|
76 |
-
$ciphertxt[$b] = implode('', $cipherByte); // escape troublesome characters in ciphertext
|
77 |
-
}
|
78 |
-
|
79 |
-
// implode is more efficient than repeated string concatenation
|
80 |
-
$ciphertext = $ctrTxt . implode('', $ciphertxt);
|
81 |
-
$ciphertext = base64_encode($ciphertext);
|
82 |
-
return $ciphertext;
|
83 |
-
}
|
84 |
-
|
85 |
-
|
86 |
-
/**
|
87 |
-
* Decrypt a text encrypted by AES in counter mode of operation
|
88 |
-
*
|
89 |
-
* @param ciphertext source text to be decrypted
|
90 |
-
* @param password the password to use to generate a key
|
91 |
-
* @param nBits number of bits to be used in the key (128, 192, or 256)
|
92 |
-
* @return decrypted text
|
93 |
-
*/
|
94 |
-
public static function decrypt($ciphertext, $password, $nBits)
|
95 |
-
{
|
96 |
-
$blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
|
97 |
-
if (!($nBits == 128 || $nBits == 192 || $nBits == 256)) return ''; // standard allows 128/192/256 bit keys
|
98 |
-
$ciphertext = base64_decode($ciphertext);
|
99 |
-
|
100 |
-
// use AES to encrypt password (mirroring encrypt routine)
|
101 |
-
$nBytes = $nBits / 8; // no bytes in key
|
102 |
-
$pwBytes = array();
|
103 |
-
for ($i = 0; $i < $nBytes; $i++) $pwBytes[$i] = ord(substr($password, $i, 1)) & 0xff;
|
104 |
-
$key = Wcal_Aes::cipher($pwBytes, Wcal_Aes::keyExpansion($pwBytes));
|
105 |
-
$key = array_merge($key, array_slice($key, 0, $nBytes - 16)); // expand key to 16/24/32 bytes long
|
106 |
-
|
107 |
-
// recover nonce from 1st element of ciphertext
|
108 |
-
$counterBlock = array();
|
109 |
-
$ctrTxt = substr($ciphertext, 0, 8);
|
110 |
-
for ($i = 0; $i < 8; $i++) $counterBlock[$i] = ord(substr($ctrTxt, $i, 1));
|
111 |
-
|
112 |
-
// generate key schedule
|
113 |
-
$keySchedule = Wcal_Aes::keyExpansion($key);
|
114 |
-
|
115 |
-
// separate ciphertext into blocks (skipping past initial 8 bytes)
|
116 |
-
$nBlocks = ceil((strlen($ciphertext) - 8) / $blockSize);
|
117 |
-
$ct = array();
|
118 |
-
for ($b = 0; $b < $nBlocks; $b++) $ct[$b] = substr($ciphertext, 8 + $b * $blockSize, 16);
|
119 |
-
$ciphertext = $ct; // ciphertext is now array of block-length strings
|
120 |
-
|
121 |
-
// plaintext will get generated block-by-block into array of block-length strings
|
122 |
-
$plaintxt = array();
|
123 |
-
|
124 |
-
for ($b = 0; $b < $nBlocks; $b++) {
|
125 |
-
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
|
126 |
-
for ($c = 0; $c < 4; $c++) $counterBlock[15 - $c] = self::urs($b, $c * 8) & 0xff;
|
127 |
-
for ($c = 0; $c < 4; $c++) $counterBlock[15 - $c - 4] = self::urs(($b + 1) / 0x100000000 - 1, $c * 8) & 0xff;
|
128 |
-
|
129 |
-
$cipherCntr = Wcal_Aes::cipher($counterBlock, $keySchedule); // encrypt counter block
|
130 |
-
|
131 |
-
$plaintxtByte = array();
|
132 |
-
for ($i = 0; $i < strlen($ciphertext[$b]); $i++) {
|
133 |
-
// -- xor plaintext with ciphered counter byte-by-byte --
|
134 |
-
$plaintxtByte[$i] = $cipherCntr[$i] ^ ord(substr($ciphertext[$b], $i, 1));
|
135 |
-
$plaintxtByte[$i] = chr($plaintxtByte[$i]);
|
136 |
-
|
137 |
-
}
|
138 |
-
$plaintxt[$b] = implode('', $plaintxtByte);
|
139 |
-
}
|
140 |
-
|
141 |
-
// join array of blocks into single plaintext string
|
142 |
-
$plaintext = implode('', $plaintxt);
|
143 |
-
|
144 |
-
return $plaintext;
|
145 |
-
}
|
146 |
-
|
147 |
-
|
148 |
-
/*
|
149 |
-
* Unsigned right shift function, since PHP has neither >>> operator nor unsigned ints
|
150 |
-
*
|
151 |
-
* @param a number to be shifted (32-bit integer)
|
152 |
-
* @param b number of bits to shift a to the right (0..31)
|
153 |
-
* @return a right-shifted and zero-filled by b bits
|
154 |
-
*/
|
155 |
-
private static function urs($a, $b)
|
156 |
-
{
|
157 |
-
$a &= 0xffffffff;
|
158 |
-
$b &= 0x1f; // (bounds check)
|
159 |
-
if ($a & 0x80000000 && $b > 0) { // if left-most bit set
|
160 |
-
$a = ($a >> 1) & 0x7fffffff; // right-shift one bit & clear left-most bit
|
161 |
-
$check = $b - 1 ;
|
162 |
-
$a = $a >> ($check); // remaining right-shifts
|
163 |
-
} else { // otherwise
|
164 |
-
$a = ($a >> $b); // use normal right-shift
|
165 |
-
}
|
166 |
-
return $a;
|
167 |
-
}
|
168 |
-
|
169 |
-
}
|
170 |
-
|
171 |
-
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
1 |
+
<?php
|
2 |
+
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
3 |
+
/* AES counter (CTR) mode implementation in PHP */
|
4 |
+
/* (c) Chris Veness 2005-2014 www.movable-type.co.uk/scripts */
|
5 |
+
/* Right of free use is granted for all commercial or non-commercial use under CC-BY licence. */
|
6 |
+
/* No warranty of any form is offered. */
|
7 |
+
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
8 |
+
|
9 |
+
Class Wcal_Aes_Ctr extends Wcal_Aes
|
10 |
+
{
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Encrypt a text using AES encryption in Counter mode of operation
|
14 |
+
* - see http://csrc.nist.gov/publications/nistpubs/800-38a/sp800-38a.pdf
|
15 |
+
*
|
16 |
+
* Unicode multi-byte character safe
|
17 |
+
*
|
18 |
+
* @param plaintext source text to be encrypted
|
19 |
+
* @param password the password to use to generate a key
|
20 |
+
* @param nBits number of bits to be used in the key (128, 192, or 256)
|
21 |
+
* @return encrypted text
|
22 |
+
*/
|
23 |
+
public static function encrypt($plaintext, $password, $nBits)
|
24 |
+
{
|
25 |
+
$blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
|
26 |
+
if (!($nBits == 128 || $nBits == 192 || $nBits == 256)) return ''; // standard allows 128/192/256 bit keys
|
27 |
+
// note PHP (5) gives us plaintext and password in UTF8 encoding!
|
28 |
+
|
29 |
+
// use AES itself to encrypt password to get cipher key (using plain password as source for
|
30 |
+
// key expansion) - gives us well encrypted key
|
31 |
+
$nBytes = $nBits / 8; // no bytes in key
|
32 |
+
$pwBytes = array();
|
33 |
+
for ($i = 0; $i < $nBytes; $i++) $pwBytes[$i] = ord(substr($password, $i, 1)) & 0xff;
|
34 |
+
$key = Wcal_Aes::cipher($pwBytes, Wcal_Aes::keyExpansion($pwBytes));
|
35 |
+
$key = array_merge($key, array_slice($key, 0, $nBytes - 16)); // expand key to 16/24/32 bytes long
|
36 |
+
|
37 |
+
// initialise 1st 8 bytes of counter block with nonce (NIST SP800-38A �B.2): [0-1] = millisec,
|
38 |
+
// [2-3] = random, [4-7] = seconds, giving guaranteed sub-ms uniqueness up to Feb 2106
|
39 |
+
$counterBlock = array();
|
40 |
+
$nonce = floor(microtime(true) * 1000); // timestamp: milliseconds since 1-Jan-1970
|
41 |
+
$nonceMs = $nonce % 1000;
|
42 |
+
$nonceSec = floor($nonce / 1000);
|
43 |
+
$nonceRnd = floor(rand(0, 0xffff));
|
44 |
+
|
45 |
+
for ($i = 0; $i < 2; $i++) $counterBlock[$i] = self::urs($nonceMs, $i * 8) & 0xff;
|
46 |
+
for ($i = 0; $i < 2; $i++) $counterBlock[$i + 2] = self::urs($nonceRnd, $i * 8) & 0xff;
|
47 |
+
for ($i = 0; $i < 4; $i++) $counterBlock[$i + 4] = self::urs($nonceSec, $i * 8) & 0xff;
|
48 |
+
|
49 |
+
// and convert it to a string to go on the front of the ciphertext
|
50 |
+
$ctrTxt = '';
|
51 |
+
for ($i = 0; $i < 8; $i++) $ctrTxt .= chr($counterBlock[$i]);
|
52 |
+
|
53 |
+
// generate key schedule - an expansion of the key into distinct Key Rounds for each round
|
54 |
+
$keySchedule = Wcal_Aes::keyExpansion($key);
|
55 |
+
//print_r($keySchedule);
|
56 |
+
|
57 |
+
$blockCount = ceil(strlen($plaintext) / $blockSize);
|
58 |
+
$ciphertxt = array(); // ciphertext as array of strings
|
59 |
+
|
60 |
+
for ($b = 0; $b < $blockCount; $b++) {
|
61 |
+
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
|
62 |
+
// done in two stages for 32-bit ops: using two words allows us to go past 2^32 blocks (68GB)
|
63 |
+
for ($c = 0; $c < 4; $c++) $counterBlock[15 - $c] = self::urs($b, $c * 8) & 0xff;
|
64 |
+
for ($c = 0; $c < 4; $c++) $counterBlock[15 - $c - 4] = self::urs($b / 0x100000000, $c * 8);
|
65 |
+
|
66 |
+
$cipherCntr = Wcal_Aes::cipher($counterBlock, $keySchedule); // -- encrypt counter block --
|
67 |
+
|
68 |
+
// block size is reduced on final block
|
69 |
+
$blockLength = $b < $blockCount - 1 ? $blockSize : (strlen($plaintext) - 1) % $blockSize + 1;
|
70 |
+
$cipherByte = array();
|
71 |
+
|
72 |
+
for ($i = 0; $i < $blockLength; $i++) { // -- xor plaintext with ciphered counter byte-by-byte --
|
73 |
+
$cipherByte[$i] = $cipherCntr[$i] ^ ord(substr($plaintext, $b * $blockSize + $i, 1));
|
74 |
+
$cipherByte[$i] = chr($cipherByte[$i]);
|
75 |
+
}
|
76 |
+
$ciphertxt[$b] = implode('', $cipherByte); // escape troublesome characters in ciphertext
|
77 |
+
}
|
78 |
+
|
79 |
+
// implode is more efficient than repeated string concatenation
|
80 |
+
$ciphertext = $ctrTxt . implode('', $ciphertxt);
|
81 |
+
$ciphertext = base64_encode($ciphertext);
|
82 |
+
return $ciphertext;
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Decrypt a text encrypted by AES in counter mode of operation
|
88 |
+
*
|
89 |
+
* @param ciphertext source text to be decrypted
|
90 |
+
* @param password the password to use to generate a key
|
91 |
+
* @param nBits number of bits to be used in the key (128, 192, or 256)
|
92 |
+
* @return decrypted text
|
93 |
+
*/
|
94 |
+
public static function decrypt($ciphertext, $password, $nBits)
|
95 |
+
{
|
96 |
+
$blockSize = 16; // block size fixed at 16 bytes / 128 bits (Nb=4) for AES
|
97 |
+
if (!($nBits == 128 || $nBits == 192 || $nBits == 256)) return ''; // standard allows 128/192/256 bit keys
|
98 |
+
$ciphertext = base64_decode($ciphertext);
|
99 |
+
|
100 |
+
// use AES to encrypt password (mirroring encrypt routine)
|
101 |
+
$nBytes = $nBits / 8; // no bytes in key
|
102 |
+
$pwBytes = array();
|
103 |
+
for ($i = 0; $i < $nBytes; $i++) $pwBytes[$i] = ord(substr($password, $i, 1)) & 0xff;
|
104 |
+
$key = Wcal_Aes::cipher($pwBytes, Wcal_Aes::keyExpansion($pwBytes));
|
105 |
+
$key = array_merge($key, array_slice($key, 0, $nBytes - 16)); // expand key to 16/24/32 bytes long
|
106 |
+
|
107 |
+
// recover nonce from 1st element of ciphertext
|
108 |
+
$counterBlock = array();
|
109 |
+
$ctrTxt = substr($ciphertext, 0, 8);
|
110 |
+
for ($i = 0; $i < 8; $i++) $counterBlock[$i] = ord(substr($ctrTxt, $i, 1));
|
111 |
+
|
112 |
+
// generate key schedule
|
113 |
+
$keySchedule = Wcal_Aes::keyExpansion($key);
|
114 |
+
|
115 |
+
// separate ciphertext into blocks (skipping past initial 8 bytes)
|
116 |
+
$nBlocks = ceil((strlen($ciphertext) - 8) / $blockSize);
|
117 |
+
$ct = array();
|
118 |
+
for ($b = 0; $b < $nBlocks; $b++) $ct[$b] = substr($ciphertext, 8 + $b * $blockSize, 16);
|
119 |
+
$ciphertext = $ct; // ciphertext is now array of block-length strings
|
120 |
+
|
121 |
+
// plaintext will get generated block-by-block into array of block-length strings
|
122 |
+
$plaintxt = array();
|
123 |
+
|
124 |
+
for ($b = 0; $b < $nBlocks; $b++) {
|
125 |
+
// set counter (block #) in last 8 bytes of counter block (leaving nonce in 1st 8 bytes)
|
126 |
+
for ($c = 0; $c < 4; $c++) $counterBlock[15 - $c] = self::urs($b, $c * 8) & 0xff;
|
127 |
+
for ($c = 0; $c < 4; $c++) $counterBlock[15 - $c - 4] = self::urs(($b + 1) / 0x100000000 - 1, $c * 8) & 0xff;
|
128 |
+
|
129 |
+
$cipherCntr = Wcal_Aes::cipher($counterBlock, $keySchedule); // encrypt counter block
|
130 |
+
|
131 |
+
$plaintxtByte = array();
|
132 |
+
for ($i = 0; $i < strlen($ciphertext[$b]); $i++) {
|
133 |
+
// -- xor plaintext with ciphered counter byte-by-byte --
|
134 |
+
$plaintxtByte[$i] = $cipherCntr[$i] ^ ord(substr($ciphertext[$b], $i, 1));
|
135 |
+
$plaintxtByte[$i] = chr($plaintxtByte[$i]);
|
136 |
+
|
137 |
+
}
|
138 |
+
$plaintxt[$b] = implode('', $plaintxtByte);
|
139 |
+
}
|
140 |
+
|
141 |
+
// join array of blocks into single plaintext string
|
142 |
+
$plaintext = implode('', $plaintxt);
|
143 |
+
|
144 |
+
return $plaintext;
|
145 |
+
}
|
146 |
+
|
147 |
+
|
148 |
+
/*
|
149 |
+
* Unsigned right shift function, since PHP has neither >>> operator nor unsigned ints
|
150 |
+
*
|
151 |
+
* @param a number to be shifted (32-bit integer)
|
152 |
+
* @param b number of bits to shift a to the right (0..31)
|
153 |
+
* @return a right-shifted and zero-filled by b bits
|
154 |
+
*/
|
155 |
+
private static function urs($a, $b)
|
156 |
+
{
|
157 |
+
$a &= 0xffffffff;
|
158 |
+
$b &= 0x1f; // (bounds check)
|
159 |
+
if ($a & 0x80000000 && $b > 0) { // if left-most bit set
|
160 |
+
$a = ($a >> 1) & 0x7fffffff; // right-shift one bit & clear left-most bit
|
161 |
+
$check = $b - 1 ;
|
162 |
+
$a = $a >> ($check); // remaining right-shifts
|
163 |
+
} else { // otherwise
|
164 |
+
$a = ($a >> $b); // use normal right-shift
|
165 |
+
}
|
166 |
+
return $a;
|
167 |
+
}
|
168 |
+
|
169 |
+
}
|
170 |
+
|
171 |
+
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
woocommerce-abandoned-cart/includes/classes/class-wcal-aes.php
CHANGED
@@ -1,190 +1,190 @@
|
|
1 |
-
<?php
|
2 |
-
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
3 |
-
/* AES implementation in PHP */
|
4 |
-
/* (c) Chris Veness 2005-2014 www.movable-type.co.uk/scripts */
|
5 |
-
/* Right of free use is granted for all commercial or non-commercial use under CC-BY licence. */
|
6 |
-
/* No warranty of any form is offered. */
|
7 |
-
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
8 |
-
|
9 |
-
Class Wcal_Aes
|
10 |
-
{
|
11 |
-
/**
|
12 |
-
* AES Cipher function [�5.1]: encrypt 'input' with Rijndael algorithm
|
13 |
-
*
|
14 |
-
* @param input message as byte-array (16 bytes)
|
15 |
-
* @param w key schedule as 2D byte-array (Nr+1 x Nb bytes) -
|
16 |
-
* generated from the cipher key by keyExpansion()
|
17 |
-
* @return ciphertext as byte-array (16 bytes)
|
18 |
-
*/
|
19 |
-
public static function cipher($input, $w)
|
20 |
-
{
|
21 |
-
$Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
|
22 |
-
$Nr = count($w) / $Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys
|
23 |
-
$state = array(); // initialise 4xNb byte-array 'state' with input [�3.4]
|
24 |
-
for( $i = 0; $i < 4 * $Nb; $i++ ) $state[$i % 4][floor($i / 4)] = $input[$i];
|
25 |
-
|
26 |
-
$state = self::addRoundKey( $state, $w, 0, $Nb );
|
27 |
-
|
28 |
-
for ( $round = 1; $round < $Nr; $round++ ) { // apply Nr rounds
|
29 |
-
$state = self::subBytes( $state, $Nb );
|
30 |
-
$state = self::shiftRows( $state, $Nb );
|
31 |
-
$state = self::mixColumns( $state, $Nb );
|
32 |
-
$state = self::addRoundKey( $state, $w, $round, $Nb );
|
33 |
-
}
|
34 |
-
|
35 |
-
$state = self::subBytes( $state, $Nb );
|
36 |
-
$state = self::shiftRows( $state, $Nb );
|
37 |
-
$state = self::addRoundKey( $state, $w, $Nr, $Nb );
|
38 |
-
|
39 |
-
$output = array( 4 * $Nb ); // convert state to 1-d array before returning [�3.4]
|
40 |
-
for( $i = 0; $i < 4 * $Nb; $i++ ) $output[$i] = $state[$i % 4][floor($i / 4)];
|
41 |
-
return $output;
|
42 |
-
}
|
43 |
-
/**
|
44 |
-
* Xor Round Key into state S [�5.1.4].
|
45 |
-
*/
|
46 |
-
private static function addRoundKey( $state, $w, $rnd, $Nb )
|
47 |
-
{
|
48 |
-
for( $r = 0; $r < 4; $r++ ) {
|
49 |
-
for ($c = 0; $c < $Nb; $c++) $state[$r][$c] ^= $w[$rnd * 4 + $c][$r];
|
50 |
-
}
|
51 |
-
return $state;
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Apply SBox to state S [�5.1.1].
|
56 |
-
*/
|
57 |
-
private static function subBytes($s, $Nb)
|
58 |
-
{
|
59 |
-
for( $r = 0; $r < 4; $r++ ) {
|
60 |
-
for( $c = 0; $c < $Nb; $c++ ) $s[$r][$c] = self::$sBox[$s[$r][$c]];
|
61 |
-
}
|
62 |
-
return $s;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Shift row r of state S left by r bytes [�5.1.2].
|
67 |
-
*/
|
68 |
-
private static function shiftRows($s, $Nb)
|
69 |
-
{
|
70 |
-
$t = array(4);
|
71 |
-
for ($r = 1; $r < 4; $r++) {
|
72 |
-
for ($c = 0; $c < 4; $c++) $t[$c] = $s[$r][($c + $r) % $Nb]; // shift into temp copy
|
73 |
-
for ($c = 0; $c < 4; $c++) $s[$r][$c] = $t[$c]; // and copy back
|
74 |
-
} // note that this will work for Nb=4,5,6, but not 7,8 (always 4 for AES):
|
75 |
-
return $s; // see fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.311.pdf
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Combine bytes of each col of state S [�5.1.3].
|
80 |
-
*/
|
81 |
-
private static function mixColumns($s, $Nb)
|
82 |
-
{
|
83 |
-
for ($c = 0; $c < 4; $c++) {
|
84 |
-
$a = array(4); // 'a' is a copy of the current column from 's'
|
85 |
-
$b = array(4); // 'b' is a�{02} in GF(2^8)
|
86 |
-
for ($i = 0; $i < 4; $i++) {
|
87 |
-
$a[$i] = $s[$i][$c];
|
88 |
-
$b[$i] = $s[$i][$c] & 0x80 ? $s[$i][$c] << 1 ^ 0x011b : $s[$i][$c] << 1;
|
89 |
-
}
|
90 |
-
// a[n] ^ b[n] is a�{03} in GF(2^8)
|
91 |
-
$s[0][$c] = $b[0] ^ $a[1] ^ $b[1] ^ $a[2] ^ $a[3]; // 2*a0 + 3*a1 + a2 + a3
|
92 |
-
$s[1][$c] = $a[0] ^ $b[1] ^ $a[2] ^ $b[2] ^ $a[3]; // a0 * 2*a1 + 3*a2 + a3
|
93 |
-
$s[2][$c] = $a[0] ^ $a[1] ^ $b[2] ^ $a[3] ^ $b[3]; // a0 + a1 + 2*a2 + 3*a3
|
94 |
-
$s[3][$c] = $a[0] ^ $b[0] ^ $a[1] ^ $a[2] ^ $b[3]; // 3*a0 + a1 + a2 + 2*a3
|
95 |
-
}
|
96 |
-
return $s;
|
97 |
-
}
|
98 |
-
|
99 |
-
/**
|
100 |
-
* Generate Key Schedule from Cipher Key [�5.2].
|
101 |
-
*
|
102 |
-
* Perform key expansion on cipher key to generate a key schedule.
|
103 |
-
*
|
104 |
-
* @param key cipher key byte-array (16 bytes).
|
105 |
-
* @return key schedule as 2D byte-array (Nr+1 x Nb bytes).
|
106 |
-
*/
|
107 |
-
public static function keyExpansion($key)
|
108 |
-
{
|
109 |
-
$Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
|
110 |
-
$Nk = count($key) / 4; // key length (in words): 4/6/8 for 128/192/256-bit keys
|
111 |
-
$Nr = $Nk + 6; // no of rounds: 10/12/14 for 128/192/256-bit keys
|
112 |
-
|
113 |
-
$w = array();
|
114 |
-
$temp = array();
|
115 |
-
|
116 |
-
for ($i = 0; $i < $Nk; $i++) {
|
117 |
-
$r = array($key[4 * $i], $key[4 * $i + 1], $key[4 * $i + 2], $key[4 * $i + 3]);
|
118 |
-
$w[$i] = $r;
|
119 |
-
}
|
120 |
-
|
121 |
-
for ($i = $Nk; $i < ($Nb * ($Nr + 1)); $i++) {
|
122 |
-
$w[$i] = array();
|
123 |
-
for ($t = 0; $t < 4; $t++) $temp[$t] = $w[$i - 1][$t];
|
124 |
-
if ($i % $Nk == 0) {
|
125 |
-
$temp = self::subWord(self::rotWord($temp));
|
126 |
-
for ($t = 0; $t < 4; $t++) $temp[$t] ^= self::$rCon[$i / $Nk][$t];
|
127 |
-
} else if ($Nk > 6 && $i % $Nk == 4) {
|
128 |
-
$temp = self::subWord($temp);
|
129 |
-
}
|
130 |
-
for ($t = 0; $t < 4; $t++) $w[$i][$t] = $w[$i - $Nk][$t] ^ $temp[$t];
|
131 |
-
}
|
132 |
-
return $w;
|
133 |
-
}
|
134 |
-
|
135 |
-
/**
|
136 |
-
* Apply SBox to 4-byte word w.
|
137 |
-
*/
|
138 |
-
private static function subWord($w)
|
139 |
-
{
|
140 |
-
for ($i = 0; $i < 4; $i++) $w[$i] = self::$sBox[$w[$i]];
|
141 |
-
return $w;
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* Rotate 4-byte word w left by one byte.
|
146 |
-
*/
|
147 |
-
private static function rotWord($w)
|
148 |
-
{
|
149 |
-
$tmp = $w[0];
|
150 |
-
for ($i = 0; $i < 3; $i++) $w[$i] = $w[$i + 1];
|
151 |
-
$w[3] = $tmp;
|
152 |
-
return $w;
|
153 |
-
}
|
154 |
-
|
155 |
-
// sBox is pre-computed multiplicative inverse in GF(2^8) used in subBytes and keyExpansion [�5.1.1]
|
156 |
-
private static $sBox = array(
|
157 |
-
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
|
158 |
-
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
|
159 |
-
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
|
160 |
-
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
|
161 |
-
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
|
162 |
-
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
|
163 |
-
0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
|
164 |
-
0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
|
165 |
-
0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
|
166 |
-
0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
|
167 |
-
0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
|
168 |
-
0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
|
169 |
-
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
|
170 |
-
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
|
171 |
-
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
|
172 |
-
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16);
|
173 |
-
|
174 |
-
// rCon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [�5.2]
|
175 |
-
private static $rCon = array(
|
176 |
-
array(0x00, 0x00, 0x00, 0x00),
|
177 |
-
array(0x01, 0x00, 0x00, 0x00),
|
178 |
-
array(0x02, 0x00, 0x00, 0x00),
|
179 |
-
array(0x04, 0x00, 0x00, 0x00),
|
180 |
-
array(0x08, 0x00, 0x00, 0x00),
|
181 |
-
array(0x10, 0x00, 0x00, 0x00),
|
182 |
-
array(0x20, 0x00, 0x00, 0x00),
|
183 |
-
array(0x40, 0x00, 0x00, 0x00),
|
184 |
-
array(0x80, 0x00, 0x00, 0x00),
|
185 |
-
array(0x1b, 0x00, 0x00, 0x00),
|
186 |
-
array(0x36, 0x00, 0x00, 0x00));
|
187 |
-
|
188 |
-
}
|
189 |
-
|
190 |
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
1 |
+
<?php
|
2 |
+
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
3 |
+
/* AES implementation in PHP */
|
4 |
+
/* (c) Chris Veness 2005-2014 www.movable-type.co.uk/scripts */
|
5 |
+
/* Right of free use is granted for all commercial or non-commercial use under CC-BY licence. */
|
6 |
+
/* No warranty of any form is offered. */
|
7 |
+
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
8 |
+
|
9 |
+
Class Wcal_Aes
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* AES Cipher function [�5.1]: encrypt 'input' with Rijndael algorithm
|
13 |
+
*
|
14 |
+
* @param input message as byte-array (16 bytes)
|
15 |
+
* @param w key schedule as 2D byte-array (Nr+1 x Nb bytes) -
|
16 |
+
* generated from the cipher key by keyExpansion()
|
17 |
+
* @return ciphertext as byte-array (16 bytes)
|
18 |
+
*/
|
19 |
+
public static function cipher($input, $w)
|
20 |
+
{
|
21 |
+
$Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
|
22 |
+
$Nr = count($w) / $Nb - 1; // no of rounds: 10/12/14 for 128/192/256-bit keys
|
23 |
+
$state = array(); // initialise 4xNb byte-array 'state' with input [�3.4]
|
24 |
+
for( $i = 0; $i < 4 * $Nb; $i++ ) $state[$i % 4][floor($i / 4)] = $input[$i];
|
25 |
+
|
26 |
+
$state = self::addRoundKey( $state, $w, 0, $Nb );
|
27 |
+
|
28 |
+
for ( $round = 1; $round < $Nr; $round++ ) { // apply Nr rounds
|
29 |
+
$state = self::subBytes( $state, $Nb );
|
30 |
+
$state = self::shiftRows( $state, $Nb );
|
31 |
+
$state = self::mixColumns( $state, $Nb );
|
32 |
+
$state = self::addRoundKey( $state, $w, $round, $Nb );
|
33 |
+
}
|
34 |
+
|
35 |
+
$state = self::subBytes( $state, $Nb );
|
36 |
+
$state = self::shiftRows( $state, $Nb );
|
37 |
+
$state = self::addRoundKey( $state, $w, $Nr, $Nb );
|
38 |
+
|
39 |
+
$output = array( 4 * $Nb ); // convert state to 1-d array before returning [�3.4]
|
40 |
+
for( $i = 0; $i < 4 * $Nb; $i++ ) $output[$i] = $state[$i % 4][floor($i / 4)];
|
41 |
+
return $output;
|
42 |
+
}
|
43 |
+
/**
|
44 |
+
* Xor Round Key into state S [�5.1.4].
|
45 |
+
*/
|
46 |
+
private static function addRoundKey( $state, $w, $rnd, $Nb )
|
47 |
+
{
|
48 |
+
for( $r = 0; $r < 4; $r++ ) {
|
49 |
+
for ($c = 0; $c < $Nb; $c++) $state[$r][$c] ^= $w[$rnd * 4 + $c][$r];
|
50 |
+
}
|
51 |
+
return $state;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Apply SBox to state S [�5.1.1].
|
56 |
+
*/
|
57 |
+
private static function subBytes($s, $Nb)
|
58 |
+
{
|
59 |
+
for( $r = 0; $r < 4; $r++ ) {
|
60 |
+
for( $c = 0; $c < $Nb; $c++ ) $s[$r][$c] = self::$sBox[$s[$r][$c]];
|
61 |
+
}
|
62 |
+
return $s;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Shift row r of state S left by r bytes [�5.1.2].
|
67 |
+
*/
|
68 |
+
private static function shiftRows($s, $Nb)
|
69 |
+
{
|
70 |
+
$t = array(4);
|
71 |
+
for ($r = 1; $r < 4; $r++) {
|
72 |
+
for ($c = 0; $c < 4; $c++) $t[$c] = $s[$r][($c + $r) % $Nb]; // shift into temp copy
|
73 |
+
for ($c = 0; $c < 4; $c++) $s[$r][$c] = $t[$c]; // and copy back
|
74 |
+
} // note that this will work for Nb=4,5,6, but not 7,8 (always 4 for AES):
|
75 |
+
return $s; // see fp.gladman.plus.com/cryptography_technology/rijndael/aes.spec.311.pdf
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Combine bytes of each col of state S [�5.1.3].
|
80 |
+
*/
|
81 |
+
private static function mixColumns($s, $Nb)
|
82 |
+
{
|
83 |
+
for ($c = 0; $c < 4; $c++) {
|
84 |
+
$a = array(4); // 'a' is a copy of the current column from 's'
|
85 |
+
$b = array(4); // 'b' is a�{02} in GF(2^8)
|
86 |
+
for ($i = 0; $i < 4; $i++) {
|
87 |
+
$a[$i] = $s[$i][$c];
|
88 |
+
$b[$i] = $s[$i][$c] & 0x80 ? $s[$i][$c] << 1 ^ 0x011b : $s[$i][$c] << 1;
|
89 |
+
}
|
90 |
+
// a[n] ^ b[n] is a�{03} in GF(2^8)
|
91 |
+
$s[0][$c] = $b[0] ^ $a[1] ^ $b[1] ^ $a[2] ^ $a[3]; // 2*a0 + 3*a1 + a2 + a3
|
92 |
+
$s[1][$c] = $a[0] ^ $b[1] ^ $a[2] ^ $b[2] ^ $a[3]; // a0 * 2*a1 + 3*a2 + a3
|
93 |
+
$s[2][$c] = $a[0] ^ $a[1] ^ $b[2] ^ $a[3] ^ $b[3]; // a0 + a1 + 2*a2 + 3*a3
|
94 |
+
$s[3][$c] = $a[0] ^ $b[0] ^ $a[1] ^ $a[2] ^ $b[3]; // 3*a0 + a1 + a2 + 2*a3
|
95 |
+
}
|
96 |
+
return $s;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Generate Key Schedule from Cipher Key [�5.2].
|
101 |
+
*
|
102 |
+
* Perform key expansion on cipher key to generate a key schedule.
|
103 |
+
*
|
104 |
+
* @param key cipher key byte-array (16 bytes).
|
105 |
+
* @return key schedule as 2D byte-array (Nr+1 x Nb bytes).
|
106 |
+
*/
|
107 |
+
public static function keyExpansion($key)
|
108 |
+
{
|
109 |
+
$Nb = 4; // block size (in words): no of columns in state (fixed at 4 for AES)
|
110 |
+
$Nk = count($key) / 4; // key length (in words): 4/6/8 for 128/192/256-bit keys
|
111 |
+
$Nr = $Nk + 6; // no of rounds: 10/12/14 for 128/192/256-bit keys
|
112 |
+
|
113 |
+
$w = array();
|
114 |
+
$temp = array();
|
115 |
+
|
116 |
+
for ($i = 0; $i < $Nk; $i++) {
|
117 |
+
$r = array($key[4 * $i], $key[4 * $i + 1], $key[4 * $i + 2], $key[4 * $i + 3]);
|
118 |
+
$w[$i] = $r;
|
119 |
+
}
|
120 |
+
|
121 |
+
for ($i = $Nk; $i < ($Nb * ($Nr + 1)); $i++) {
|
122 |
+
$w[$i] = array();
|
123 |
+
for ($t = 0; $t < 4; $t++) $temp[$t] = $w[$i - 1][$t];
|
124 |
+
if ($i % $Nk == 0) {
|
125 |
+
$temp = self::subWord(self::rotWord($temp));
|
126 |
+
for ($t = 0; $t < 4; $t++) $temp[$t] ^= self::$rCon[$i / $Nk][$t];
|
127 |
+
} else if ($Nk > 6 && $i % $Nk == 4) {
|
128 |
+
$temp = self::subWord($temp);
|
129 |
+
}
|
130 |
+
for ($t = 0; $t < 4; $t++) $w[$i][$t] = $w[$i - $Nk][$t] ^ $temp[$t];
|
131 |
+
}
|
132 |
+
return $w;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Apply SBox to 4-byte word w.
|
137 |
+
*/
|
138 |
+
private static function subWord($w)
|
139 |
+
{
|
140 |
+
for ($i = 0; $i < 4; $i++) $w[$i] = self::$sBox[$w[$i]];
|
141 |
+
return $w;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Rotate 4-byte word w left by one byte.
|
146 |
+
*/
|
147 |
+
private static function rotWord($w)
|
148 |
+
{
|
149 |
+
$tmp = $w[0];
|
150 |
+
for ($i = 0; $i < 3; $i++) $w[$i] = $w[$i + 1];
|
151 |
+
$w[3] = $tmp;
|
152 |
+
return $w;
|
153 |
+
}
|
154 |
+
|
155 |
+
// sBox is pre-computed multiplicative inverse in GF(2^8) used in subBytes and keyExpansion [�5.1.1]
|
156 |
+
private static $sBox = array(
|
157 |
+
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
|
158 |
+
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
|
159 |
+
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
|
160 |
+
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
|
161 |
+
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
|
162 |
+
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
|
163 |
+
0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
|
164 |
+
0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
|
165 |
+
0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
|
166 |
+
0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
|
167 |
+
0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
|
168 |
+
0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
|
169 |
+
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
|
170 |
+
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
|
171 |
+
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
|
172 |
+
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16);
|
173 |
+
|
174 |
+
// rCon is Round Constant used for the Key Expansion [1st col is 2^(r-1) in GF(2^8)] [�5.2]
|
175 |
+
private static $rCon = array(
|
176 |
+
array(0x00, 0x00, 0x00, 0x00),
|
177 |
+
array(0x01, 0x00, 0x00, 0x00),
|
178 |
+
array(0x02, 0x00, 0x00, 0x00),
|
179 |
+
array(0x04, 0x00, 0x00, 0x00),
|
180 |
+
array(0x08, 0x00, 0x00, 0x00),
|
181 |
+
array(0x10, 0x00, 0x00, 0x00),
|
182 |
+
array(0x20, 0x00, 0x00, 0x00),
|
183 |
+
array(0x40, 0x00, 0x00, 0x00),
|
184 |
+
array(0x80, 0x00, 0x00, 0x00),
|
185 |
+
array(0x1b, 0x00, 0x00, 0x00),
|
186 |
+
array(0x36, 0x00, 0x00, 0x00));
|
187 |
+
|
188 |
+
}
|
189 |
+
|
190 |
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
woocommerce-abandoned-cart/includes/classes/class-wcal-product-report-table.php
CHANGED
@@ -1,254 +1,254 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if( session_id() === '' ){
|
4 |
-
//session has not started
|
5 |
-
session_start();
|
6 |
-
}
|
7 |
-
// Load WP_List_Table if not loaded
|
8 |
-
if ( ! class_exists( 'WP_List_Table' ) ) {
|
9 |
-
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
10 |
-
}
|
11 |
-
|
12 |
-
class WCAL_Product_Report_Table extends WP_List_Table {
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Number of results to show per page
|
16 |
-
*
|
17 |
-
* @var string
|
18 |
-
* @since 2.5.3
|
19 |
-
*/
|
20 |
-
public $per_page = 30;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* URL of this page
|
24 |
-
*
|
25 |
-
* @var string
|
26 |
-
* @since 2.5.3
|
27 |
-
*/
|
28 |
-
public $base_url;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Total number of recovred orders
|
32 |
-
*
|
33 |
-
* @var int
|
34 |
-
* @since 2.5.3
|
35 |
-
*/
|
36 |
-
public $total_count;
|
37 |
-
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Total number of recovred orders
|
41 |
-
*
|
42 |
-
* @var int
|
43 |
-
* @since 2.5.3
|
44 |
-
*/
|
45 |
-
public $open_emails;
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Total amount of abandoned orders
|
49 |
-
*
|
50 |
-
* @var int
|
51 |
-
* @since 2.5.3
|
52 |
-
*/
|
53 |
-
public $link_click_count;
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Total number recovred orders
|
57 |
-
*
|
58 |
-
* @var int
|
59 |
-
* @since 2.5.3
|
60 |
-
*/
|
61 |
-
public $start_date_db;
|
62 |
-
|
63 |
-
/**
|
64 |
-
* Total number recovred orders total
|
65 |
-
*
|
66 |
-
* @var int
|
67 |
-
* @since 2.5.3
|
68 |
-
*/
|
69 |
-
public $end_date_db;
|
70 |
-
|
71 |
-
public $duration;
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Get things started
|
75 |
-
*
|
76 |
-
* @see WP_List_Table::__construct()
|
77 |
-
*/
|
78 |
-
public function __construct() {
|
79 |
-
global $status, $page;
|
80 |
-
// Set parent defaults
|
81 |
-
parent::__construct( array(
|
82 |
-
'singular' => __( 'product_id', 'woocommerce-ac' ), //singular name of the listed records
|
83 |
-
'plural' => __( 'product_ids', 'woocommerce-ac' ), //plural name of the listed records
|
84 |
-
'ajax' => false // Does this table support ajax?
|
85 |
-
) );
|
86 |
-
$this->base_url = admin_url( 'admin.php?page=woocommerce_ac_page&action=stats' );
|
87 |
-
}
|
88 |
-
|
89 |
-
public function wcal_product_report_prepare_items() {
|
90 |
-
$columns = $this->get_columns();
|
91 |
-
$hidden = array(); // No hidden columns
|
92 |
-
$data = $this->wcal_product_report_data ();
|
93 |
-
$total_items = $this->total_count;
|
94 |
-
$this->items = $data;
|
95 |
-
$this->_column_headers = array( $columns, $hidden);
|
96 |
-
$this->set_pagination_args( array(
|
97 |
-
'total_items' => $total_items, // WE have to calculate the total number of items
|
98 |
-
'per_page' => $this->per_page, // WE have to determine how many items to show on a page
|
99 |
-
'total_pages' => ceil( $total_items / $this->per_page ) // WE have to calculate the total number of pages
|
100 |
-
)
|
101 |
-
);
|
102 |
-
}
|
103 |
-
|
104 |
-
public function get_columns() {
|
105 |
-
$columns = array(
|
106 |
-
'product_name' => __( 'Product Name', 'woocommerce-ac' ),
|
107 |
-
'abandoned_number' => __( 'Number of Times Abandoned', 'woocommerce-ac' ),
|
108 |
-
'recover_number' => __( 'Number of Times Recovered', 'woocommerce-ac' )
|
109 |
-
);
|
110 |
-
return apply_filters( 'wcal_product_report_columns', $columns );
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* Render the user name Column
|
115 |
-
*
|
116 |
-
* @access public
|
117 |
-
* @since 2.5.3
|
118 |
-
* @param array $abandoned_row_info Contains all the data of the template row
|
119 |
-
* @return string Data shown in the Email column
|
120 |
-
*
|
121 |
-
* This function used for individual delete of row, It is for hover effect delete.
|
122 |
-
*/
|
123 |
-
public function wcal_product_report_data () {
|
124 |
-
global $wpdb;
|
125 |
-
$wcal_class = new woocommerce_abandon_cart_lite ();
|
126 |
-
$per_page = $this->per_page;
|
127 |
-
$i = 0;
|
128 |
-
$order = "desc";
|
129 |
-
$query = "SELECT abandoned_cart_time, abandoned_cart_info, recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` ORDER BY recovered_cart DESC";
|
130 |
-
$recover_query = $wpdb->get_results( $query );
|
131 |
-
$rec_carts_array = array ( );
|
132 |
-
$recover_product_array = array( );
|
133 |
-
$return_product_report = array();
|
134 |
-
|
135 |
-
foreach( $recover_query as $recovered_cart_key => $recovered_cart_value ) {
|
136 |
-
$recovered_cart_info = json_decode( $recovered_cart_value->abandoned_cart_info );
|
137 |
-
$recovered_cart_dat = json_decode( $recovered_cart_value->recovered_cart);
|
138 |
-
$cart_update_time = $recovered_cart_value->abandoned_cart_time;
|
139 |
-
$quantity_total = 0;
|
140 |
-
$cart_details = array();
|
141 |
-
if( isset( $recovered_cart_info->cart ) ){
|
142 |
-
$cart_details = $recovered_cart_info->cart;
|
143 |
-
}
|
144 |
-
if ( count( $cart_details ) > 0) {
|
145 |
-
foreach ( $cart_details as $k => $v ) {
|
146 |
-
$quantity_total = $quantity_total + $v->quantity;
|
147 |
-
}
|
148 |
-
}
|
149 |
-
|
150 |
-
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
151 |
-
$cut_off_time = $ac_cutoff_time * 60 ;
|
152 |
-
$current_time = current_time( 'timestamp' );
|
153 |
-
$compare_time = $current_time - $cart_update_time;
|
154 |
-
if ( is_array( $recovered_cart_info ) || is_object( $recovered_cart_info ) ) {
|
155 |
-
foreach ( $recovered_cart_info as $rec_cart_key => $rec_cart_value ) {
|
156 |
-
foreach ( $rec_cart_value as $rec_product_id_key => $rec_product_id_value ) {
|
157 |
-
$product_id = $rec_product_id_value->product_id;
|
158 |
-
if ( $compare_time > $cut_off_time ) {
|
159 |
-
$rec_carts_array [] = $product_id;
|
160 |
-
}
|
161 |
-
if($recovered_cart_dat != 0) {
|
162 |
-
$recover_product_array[] = $product_id;
|
163 |
-
}
|
164 |
-
}
|
165 |
-
}
|
166 |
-
}
|
167 |
-
}
|
168 |
-
|
169 |
-
$count = array_count_values( $rec_carts_array );
|
170 |
-
$count1 = $count;
|
171 |
-
$count_new = $wcal_class->bubble_sort_function ( $count1 ,$order );
|
172 |
-
$recover_cart = "0";
|
173 |
-
$count_css = 0;
|
174 |
-
$chunck_array = array_chunk( $count_new,10, true ); // keep True for retaing the Array Index number which is product ids in our case.
|
175 |
-
$chunck_array_value = array();
|
176 |
-
|
177 |
-
foreach ( $chunck_array as $chunck_array_key => $chunck_array_value ) {
|
178 |
-
foreach ( $chunck_array_value as $k => $v ) {
|
179 |
-
$return_product_report[$i] = new stdClass();
|
180 |
-
$prod_name = get_post( $k );
|
181 |
-
if ( NULL != $prod_name || '' != $prod_name ) {
|
182 |
-
$product_name = $prod_name->post_title;
|
183 |
-
$abandoned_count = $v;
|
184 |
-
$recover = array_count_values( $recover_product_array );
|
185 |
-
foreach ( $recover as $ke => $ve ) {
|
186 |
-
if( array_key_exists ( $ke, $count ) ) {
|
187 |
-
if ( $ke == $k ) {
|
188 |
-
$recover_cart = $ve;
|
189 |
-
}
|
190 |
-
}
|
191 |
-
if( ! array_key_exists ( $k, $recover ) ) {
|
192 |
-
$recover_cart = "0";
|
193 |
-
}
|
194 |
-
}
|
195 |
-
|
196 |
-
$return_product_report[ $i ]->product_name = $product_name ;
|
197 |
-
$return_product_report[ $i ]->abandoned_number = $abandoned_count;
|
198 |
-
$return_product_report[ $i ]->recover_number = $recover_cart;
|
199 |
-
$return_product_report[ $i ]->product_id = $k;
|
200 |
-
$i++;
|
201 |
-
}
|
202 |
-
}
|
203 |
-
}
|
204 |
-
$this->total_count = count ( $return_product_report ) > 0 ? count ( $return_product_report ) : 0 ;
|
205 |
-
|
206 |
-
// Pagination per page
|
207 |
-
if( isset( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
|
208 |
-
$page_number = $_GET['paged'] - 1;
|
209 |
-
$k = $per_page * $page_number;
|
210 |
-
} else {
|
211 |
-
$k = 0;
|
212 |
-
}
|
213 |
-
$return_product_report_display = array();
|
214 |
-
for( $j = $k; $j < ( $k+$per_page ); $j++ ) {
|
215 |
-
if( isset( $return_product_report[$j] ) ) {
|
216 |
-
$return_product_report_display[$j] = $return_product_report[$j];
|
217 |
-
} else {
|
218 |
-
break;
|
219 |
-
}
|
220 |
-
}
|
221 |
-
return apply_filters( 'wcal_product_report_table_data', $return_product_report_display );
|
222 |
-
}
|
223 |
-
|
224 |
-
public function column_default( $wcal_sent_emails, $column_name ) {
|
225 |
-
$value = '';
|
226 |
-
switch ( $column_name ) {
|
227 |
-
|
228 |
-
case 'product_name' :
|
229 |
-
if( isset( $wcal_sent_emails->product_name ) ) {
|
230 |
-
$value = "<a href= post.php?post=$wcal_sent_emails->product_id&action=edit title = product name > $wcal_sent_emails->product_name </a>";
|
231 |
-
}
|
232 |
-
break;
|
233 |
-
|
234 |
-
case 'abandoned_number' :
|
235 |
-
if( isset( $wcal_sent_emails->abandoned_number ) ) {
|
236 |
-
$value = $wcal_sent_emails->abandoned_number;
|
237 |
-
}
|
238 |
-
break;
|
239 |
-
|
240 |
-
case 'recover_number' :
|
241 |
-
if( isset( $wcal_sent_emails->recover_number ) ) {
|
242 |
-
$value = $wcal_sent_emails->recover_number;
|
243 |
-
}
|
244 |
-
break;
|
245 |
-
default:
|
246 |
-
|
247 |
-
$value = isset( $wcal_sent_emails->$column_name ) ? $wcal_sent_emails->$column_name : '';
|
248 |
-
break;
|
249 |
-
}
|
250 |
-
|
251 |
-
return apply_filters( 'wcal_product_report_column_default', $value, $wcal_sent_emails, $column_name );
|
252 |
-
}
|
253 |
-
}
|
254 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if( session_id() === '' ){
|
4 |
+
//session has not started
|
5 |
+
session_start();
|
6 |
+
}
|
7 |
+
// Load WP_List_Table if not loaded
|
8 |
+
if ( ! class_exists( 'WP_List_Table' ) ) {
|
9 |
+
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
10 |
+
}
|
11 |
+
|
12 |
+
class WCAL_Product_Report_Table extends WP_List_Table {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Number of results to show per page
|
16 |
+
*
|
17 |
+
* @var string
|
18 |
+
* @since 2.5.3
|
19 |
+
*/
|
20 |
+
public $per_page = 30;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* URL of this page
|
24 |
+
*
|
25 |
+
* @var string
|
26 |
+
* @since 2.5.3
|
27 |
+
*/
|
28 |
+
public $base_url;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Total number of recovred orders
|
32 |
+
*
|
33 |
+
* @var int
|
34 |
+
* @since 2.5.3
|
35 |
+
*/
|
36 |
+
public $total_count;
|
37 |
+
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Total number of recovred orders
|
41 |
+
*
|
42 |
+
* @var int
|
43 |
+
* @since 2.5.3
|
44 |
+
*/
|
45 |
+
public $open_emails;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Total amount of abandoned orders
|
49 |
+
*
|
50 |
+
* @var int
|
51 |
+
* @since 2.5.3
|
52 |
+
*/
|
53 |
+
public $link_click_count;
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Total number recovred orders
|
57 |
+
*
|
58 |
+
* @var int
|
59 |
+
* @since 2.5.3
|
60 |
+
*/
|
61 |
+
public $start_date_db;
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Total number recovred orders total
|
65 |
+
*
|
66 |
+
* @var int
|
67 |
+
* @since 2.5.3
|
68 |
+
*/
|
69 |
+
public $end_date_db;
|
70 |
+
|
71 |
+
public $duration;
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Get things started
|
75 |
+
*
|
76 |
+
* @see WP_List_Table::__construct()
|
77 |
+
*/
|
78 |
+
public function __construct() {
|
79 |
+
global $status, $page;
|
80 |
+
// Set parent defaults
|
81 |
+
parent::__construct( array(
|
82 |
+
'singular' => __( 'product_id', 'woocommerce-ac' ), //singular name of the listed records
|
83 |
+
'plural' => __( 'product_ids', 'woocommerce-ac' ), //plural name of the listed records
|
84 |
+
'ajax' => false // Does this table support ajax?
|
85 |
+
) );
|
86 |
+
$this->base_url = admin_url( 'admin.php?page=woocommerce_ac_page&action=stats' );
|
87 |
+
}
|
88 |
+
|
89 |
+
public function wcal_product_report_prepare_items() {
|
90 |
+
$columns = $this->get_columns();
|
91 |
+
$hidden = array(); // No hidden columns
|
92 |
+
$data = $this->wcal_product_report_data ();
|
93 |
+
$total_items = $this->total_count;
|
94 |
+
$this->items = $data;
|
95 |
+
$this->_column_headers = array( $columns, $hidden);
|
96 |
+
$this->set_pagination_args( array(
|
97 |
+
'total_items' => $total_items, // WE have to calculate the total number of items
|
98 |
+
'per_page' => $this->per_page, // WE have to determine how many items to show on a page
|
99 |
+
'total_pages' => ceil( $total_items / $this->per_page ) // WE have to calculate the total number of pages
|
100 |
+
)
|
101 |
+
);
|
102 |
+
}
|
103 |
+
|
104 |
+
public function get_columns() {
|
105 |
+
$columns = array(
|
106 |
+
'product_name' => __( 'Product Name', 'woocommerce-ac' ),
|
107 |
+
'abandoned_number' => __( 'Number of Times Abandoned', 'woocommerce-ac' ),
|
108 |
+
'recover_number' => __( 'Number of Times Recovered', 'woocommerce-ac' )
|
109 |
+
);
|
110 |
+
return apply_filters( 'wcal_product_report_columns', $columns );
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Render the user name Column
|
115 |
+
*
|
116 |
+
* @access public
|
117 |
+
* @since 2.5.3
|
118 |
+
* @param array $abandoned_row_info Contains all the data of the template row
|
119 |
+
* @return string Data shown in the Email column
|
120 |
+
*
|
121 |
+
* This function used for individual delete of row, It is for hover effect delete.
|
122 |
+
*/
|
123 |
+
public function wcal_product_report_data () {
|
124 |
+
global $wpdb;
|
125 |
+
$wcal_class = new woocommerce_abandon_cart_lite ();
|
126 |
+
$per_page = $this->per_page;
|
127 |
+
$i = 0;
|
128 |
+
$order = "desc";
|
129 |
+
$query = "SELECT abandoned_cart_time, abandoned_cart_info, recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` ORDER BY recovered_cart DESC";
|
130 |
+
$recover_query = $wpdb->get_results( $query );
|
131 |
+
$rec_carts_array = array ( );
|
132 |
+
$recover_product_array = array( );
|
133 |
+
$return_product_report = array();
|
134 |
+
|
135 |
+
foreach( $recover_query as $recovered_cart_key => $recovered_cart_value ) {
|
136 |
+
$recovered_cart_info = json_decode( $recovered_cart_value->abandoned_cart_info );
|
137 |
+
$recovered_cart_dat = json_decode( $recovered_cart_value->recovered_cart);
|
138 |
+
$cart_update_time = $recovered_cart_value->abandoned_cart_time;
|
139 |
+
$quantity_total = 0;
|
140 |
+
$cart_details = array();
|
141 |
+
if( isset( $recovered_cart_info->cart ) ){
|
142 |
+
$cart_details = $recovered_cart_info->cart;
|
143 |
+
}
|
144 |
+
if ( count( $cart_details ) > 0) {
|
145 |
+
foreach ( $cart_details as $k => $v ) {
|
146 |
+
$quantity_total = $quantity_total + $v->quantity;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
151 |
+
$cut_off_time = $ac_cutoff_time * 60 ;
|
152 |
+
$current_time = current_time( 'timestamp' );
|
153 |
+
$compare_time = $current_time - $cart_update_time;
|
154 |
+
if ( is_array( $recovered_cart_info ) || is_object( $recovered_cart_info ) ) {
|
155 |
+
foreach ( $recovered_cart_info as $rec_cart_key => $rec_cart_value ) {
|
156 |
+
foreach ( $rec_cart_value as $rec_product_id_key => $rec_product_id_value ) {
|
157 |
+
$product_id = $rec_product_id_value->product_id;
|
158 |
+
if ( $compare_time > $cut_off_time ) {
|
159 |
+
$rec_carts_array [] = $product_id;
|
160 |
+
}
|
161 |
+
if($recovered_cart_dat != 0) {
|
162 |
+
$recover_product_array[] = $product_id;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
$count = array_count_values( $rec_carts_array );
|
170 |
+
$count1 = $count;
|
171 |
+
$count_new = $wcal_class->bubble_sort_function ( $count1 ,$order );
|
172 |
+
$recover_cart = "0";
|
173 |
+
$count_css = 0;
|
174 |
+
$chunck_array = array_chunk( $count_new,10, true ); // keep True for retaing the Array Index number which is product ids in our case.
|
175 |
+
$chunck_array_value = array();
|
176 |
+
|
177 |
+
foreach ( $chunck_array as $chunck_array_key => $chunck_array_value ) {
|
178 |
+
foreach ( $chunck_array_value as $k => $v ) {
|
179 |
+
$return_product_report[$i] = new stdClass();
|
180 |
+
$prod_name = get_post( $k );
|
181 |
+
if ( NULL != $prod_name || '' != $prod_name ) {
|
182 |
+
$product_name = $prod_name->post_title;
|
183 |
+
$abandoned_count = $v;
|
184 |
+
$recover = array_count_values( $recover_product_array );
|
185 |
+
foreach ( $recover as $ke => $ve ) {
|
186 |
+
if( array_key_exists ( $ke, $count ) ) {
|
187 |
+
if ( $ke == $k ) {
|
188 |
+
$recover_cart = $ve;
|
189 |
+
}
|
190 |
+
}
|
191 |
+
if( ! array_key_exists ( $k, $recover ) ) {
|
192 |
+
$recover_cart = "0";
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
$return_product_report[ $i ]->product_name = $product_name ;
|
197 |
+
$return_product_report[ $i ]->abandoned_number = $abandoned_count;
|
198 |
+
$return_product_report[ $i ]->recover_number = $recover_cart;
|
199 |
+
$return_product_report[ $i ]->product_id = $k;
|
200 |
+
$i++;
|
201 |
+
}
|
202 |
+
}
|
203 |
+
}
|
204 |
+
$this->total_count = count ( $return_product_report ) > 0 ? count ( $return_product_report ) : 0 ;
|
205 |
+
|
206 |
+
// Pagination per page
|
207 |
+
if( isset( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
|
208 |
+
$page_number = $_GET['paged'] - 1;
|
209 |
+
$k = $per_page * $page_number;
|
210 |
+
} else {
|
211 |
+
$k = 0;
|
212 |
+
}
|
213 |
+
$return_product_report_display = array();
|
214 |
+
for( $j = $k; $j < ( $k+$per_page ); $j++ ) {
|
215 |
+
if( isset( $return_product_report[$j] ) ) {
|
216 |
+
$return_product_report_display[$j] = $return_product_report[$j];
|
217 |
+
} else {
|
218 |
+
break;
|
219 |
+
}
|
220 |
+
}
|
221 |
+
return apply_filters( 'wcal_product_report_table_data', $return_product_report_display );
|
222 |
+
}
|
223 |
+
|
224 |
+
public function column_default( $wcal_sent_emails, $column_name ) {
|
225 |
+
$value = '';
|
226 |
+
switch ( $column_name ) {
|
227 |
+
|
228 |
+
case 'product_name' :
|
229 |
+
if( isset( $wcal_sent_emails->product_name ) ) {
|
230 |
+
$value = "<a href= post.php?post=$wcal_sent_emails->product_id&action=edit title = product name > $wcal_sent_emails->product_name </a>";
|
231 |
+
}
|
232 |
+
break;
|
233 |
+
|
234 |
+
case 'abandoned_number' :
|
235 |
+
if( isset( $wcal_sent_emails->abandoned_number ) ) {
|
236 |
+
$value = $wcal_sent_emails->abandoned_number;
|
237 |
+
}
|
238 |
+
break;
|
239 |
+
|
240 |
+
case 'recover_number' :
|
241 |
+
if( isset( $wcal_sent_emails->recover_number ) ) {
|
242 |
+
$value = $wcal_sent_emails->recover_number;
|
243 |
+
}
|
244 |
+
break;
|
245 |
+
default:
|
246 |
+
|
247 |
+
$value = isset( $wcal_sent_emails->$column_name ) ? $wcal_sent_emails->$column_name : '';
|
248 |
+
break;
|
249 |
+
}
|
250 |
+
|
251 |
+
return apply_filters( 'wcal_product_report_column_default', $value, $wcal_sent_emails, $column_name );
|
252 |
+
}
|
253 |
+
}
|
254 |
?>
|
woocommerce-abandoned-cart/includes/classes/class-wcal-recover-orders-table.php
CHANGED
@@ -1,408 +1,405 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// Load WP_List_Table if not loaded
|
4 |
-
if ( ! class_exists( 'WP_List_Table' ) ) {
|
5 |
-
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
6 |
-
}
|
7 |
-
|
8 |
-
class wcal_Recover_Orders_Table extends WP_List_Table {
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Number of results to show per page
|
12 |
-
*
|
13 |
-
* @var string
|
14 |
-
* @since 2.5.2
|
15 |
-
*/
|
16 |
-
public $per_page = 30;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* URL of this page
|
20 |
-
*
|
21 |
-
* @var string
|
22 |
-
* @since 2.5.2
|
23 |
-
*/
|
24 |
-
public $base_url;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Total number of recovered orders
|
28 |
-
*
|
29 |
-
* @var int
|
30 |
-
* @since 2.5.2
|
31 |
-
*/
|
32 |
-
public $total_count;
|
33 |
-
|
34 |
-
|
35 |
-
/**
|
36 |
-
* Total number of abandoned orders
|
37 |
-
*
|
38 |
-
* @var int
|
39 |
-
* @since 2.5.2
|
40 |
-
*/
|
41 |
-
public $total_abandoned_cart_count;
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Total amount of abandoned orders
|
45 |
-
*
|
46 |
-
* @var int
|
47 |
-
* @since 2.5.2
|
48 |
-
*/
|
49 |
-
public $total_order_amount;
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Total number recovered orders
|
53 |
-
*
|
54 |
-
* @var int
|
55 |
-
* @since 2.5.2
|
56 |
-
*/
|
57 |
-
public $recovered_item;
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Total number recovred orders total
|
61 |
-
*
|
62 |
-
* @var int
|
63 |
-
* @since 2.5.2
|
64 |
-
*/
|
65 |
-
public $total_recover_amount;
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Get things started
|
69 |
-
*
|
70 |
-
* @see WP_List_Table::__construct()
|
71 |
-
*/
|
72 |
-
public function __construct() {
|
73 |
-
global $status, $page;
|
74 |
-
// Set parent defaults
|
75 |
-
parent::__construct( array(
|
76 |
-
'singular' => __( 'rec_abandoned_id', 'woocommerce-ac' ), //singular name of the listed records
|
77 |
-
'plural' => __( 'rec_abandoned_ids', 'woocommerce-ac' ), //plural name of the listed records
|
78 |
-
'ajax' => false // Does this table support ajax?
|
79 |
-
) );
|
80 |
-
$this->base_url = admin_url( 'admin.php?page=woocommerce_ac_page&action=stats' );
|
81 |
-
}
|
82 |
-
|
83 |
-
public function wcal_recovered_orders_prepare_items() {
|
84 |
-
$columns = $this->get_columns();
|
85 |
-
$hidden = array(); // No hidden columns
|
86 |
-
$sortable = $this->recovered_orders_get_sortable_columns();
|
87 |
-
$data = $this->wcal_recovered_orders_data();
|
88 |
-
$total_items = $this->total_count;
|
89 |
-
$total_abandoned_cart_count = $this->total_abandoned_cart_count;
|
90 |
-
$total_order_amount = $this->total_order_amount;
|
91 |
-
$total_recover_amount = $this->total_recover_amount;
|
92 |
-
$recovered_item = $this->recovered_item;
|
93 |
-
$this->items = $data;
|
94 |
-
$this->_column_headers = array( $columns, $hidden, $sortable);
|
95 |
-
$this->set_pagination_args( array(
|
96 |
-
'total_items' => $total_items, // WE have to calculate the total number of items
|
97 |
-
'per_page' => $this->per_page, // WE have to determine how many items to show on a page
|
98 |
-
'total_pages' => ceil( $total_items / $this->per_page ) // WE have to calculate the total number of pages
|
99 |
-
)
|
100 |
-
);
|
101 |
-
}
|
102 |
-
|
103 |
-
public function get_columns() {
|
104 |
-
$columns = array(
|
105 |
-
'user_name' => __( 'Customer Name', 'woocommerce-ac' ),
|
106 |
-
'user_email_id' => __( 'Email Address', 'woocommerce-ac' ),
|
107 |
-
'created_on' => __( 'Cart Abandoned Date', 'woocommerce-ac' ),
|
108 |
-
'recovered_date' => __( 'Cart Recovered Date' , 'woocommerce-ac'),
|
109 |
-
'order_total' => __( 'Order Total', 'woocommerce-ac' )
|
110 |
-
);
|
111 |
-
return apply_filters( 'wcal_recovered_orders_columns', $columns );
|
112 |
-
}
|
113 |
-
|
114 |
-
public function recovered_orders_get_sortable_columns() {
|
115 |
-
$columns = array(
|
116 |
-
'created_on' => array( 'created_on', false ),
|
117 |
-
'recovered_date' => array( 'recovered_date',false)
|
118 |
-
);
|
119 |
-
return apply_filters( 'wcal_templates_sortable_columns', $columns );
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Render the user name Column
|
124 |
-
*
|
125 |
-
* @access public
|
126 |
-
* @since 2.5.2
|
127 |
-
* @param array $abandoned_row_info Contains all the data of the template row
|
128 |
-
* @return string Data shown in the Email column
|
129 |
-
*
|
130 |
-
* This function used for individual delete of row, It is for hover effect delete.
|
131 |
-
*/
|
132 |
-
public function column_user_name( $recovered_orders_row_info ) {
|
133 |
-
$row_actions = array();
|
134 |
-
$value = '';
|
135 |
-
$recovered_id = 0;
|
136 |
-
|
137 |
-
if( isset( $recovered_orders_row_info->user_name ) ) {
|
138 |
-
$recovered_id = $recovered_orders_row_info->recovered_id ;
|
139 |
-
$row_actions['view_details'] = "<a target=_blank href = post.php?post=$recovered_id&action=edit>". __( 'View Details', 'woocommerce-ac' )."</a>";
|
140 |
-
$user_name = $recovered_orders_row_info->user_name;
|
141 |
-
$value = $user_name . $this->row_actions( $row_actions );
|
142 |
-
}
|
143 |
-
return apply_filters( 'wcal_recovered_orders_single_column', $value, $recovered_id, 'email' );
|
144 |
-
}
|
145 |
-
|
146 |
-
public function wcal_recovered_orders_data() {
|
147 |
-
global $wpdb, $woocommerce;
|
148 |
-
$wcal_class = new woocommerce_abandon_cart_lite ();
|
149 |
-
$number_decimal = wc_get_price_decimals();
|
150 |
-
|
151 |
-
if ( isset( $_POST['duration_select'] ) ) {
|
152 |
-
$duration_range = $_POST['duration_select'];
|
153 |
-
}
|
154 |
-
else {
|
155 |
-
$duration_range = "";
|
156 |
-
}
|
157 |
-
|
158 |
-
if ( $duration_range == "" ) {
|
159 |
-
if ( isset( $_GET['duration_select'] ) ) {
|
160 |
-
$duration_range = $_GET['duration_select'];
|
161 |
-
}
|
162 |
-
}
|
163 |
-
|
164 |
-
if ( $duration_range == "" ) {
|
165 |
-
$duration_range = "last_seven";
|
166 |
-
}
|
167 |
-
else {
|
168 |
-
$duration_range = "";
|
169 |
-
}
|
170 |
-
|
171 |
-
if ( isset( $_POST['start_date'] ) ) {
|
172 |
-
$start_date_range = $_POST['start_date'];
|
173 |
-
}
|
174 |
-
else {
|
175 |
-
$start_date_range = "";
|
176 |
-
}
|
177 |
-
|
178 |
-
if ( $start_date_range == "" ) {
|
179 |
-
$start_date_range = $wcal_class->start_end_dates[$duration_range]['start_date'];
|
180 |
-
}
|
181 |
-
|
182 |
-
if ( isset( $_POST['end_date'] ) ) $end_date_range = $_POST['end_date'];
|
183 |
-
else $end_date_range = "";
|
184 |
-
|
185 |
-
if ( $end_date_range == "" ) {
|
186 |
-
$end_date_range = $wcal_class->start_end_dates[$duration_range]['end_date'];
|
187 |
-
}
|
188 |
-
|
189 |
-
$start_date
|
190 |
-
$end_date
|
191 |
-
|
192 |
-
$
|
193 |
-
$
|
194 |
-
$
|
195 |
-
$
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
$
|
207 |
-
$
|
208 |
-
$
|
209 |
-
|
210 |
-
|
211 |
-
$
|
212 |
-
$
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
$
|
231 |
-
$this->
|
232 |
-
$
|
233 |
-
$
|
234 |
-
$this->
|
235 |
-
$
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
$recovered_id
|
242 |
-
$rec_order
|
243 |
-
$woo_order
|
244 |
-
try{
|
245 |
-
$woo_order
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
$
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
$
|
257 |
-
|
258 |
-
|
259 |
-
|
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 |
-
$return_recovered_orders[ $i ]->
|
290 |
-
$return_recovered_orders[ $i ]->
|
291 |
-
$return_recovered_orders[ $i ]->
|
292 |
-
$return_recovered_orders[ $i ]->
|
293 |
-
$return_recovered_orders[ $i ]->
|
294 |
-
|
295 |
-
$
|
296 |
-
$
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
$
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
$value1
|
356 |
-
$value2
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
$value1
|
368 |
-
$value2
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
return apply_filters( 'wcal_recovered_orders_column_default', $value, $wcal_abandoned_orders, $column_name );
|
406 |
-
}
|
407 |
-
}
|
408 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Load WP_List_Table if not loaded
|
4 |
+
if ( ! class_exists( 'WP_List_Table' ) ) {
|
5 |
+
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
6 |
+
}
|
7 |
+
|
8 |
+
class wcal_Recover_Orders_Table extends WP_List_Table {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Number of results to show per page
|
12 |
+
*
|
13 |
+
* @var string
|
14 |
+
* @since 2.5.2
|
15 |
+
*/
|
16 |
+
public $per_page = 30;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* URL of this page
|
20 |
+
*
|
21 |
+
* @var string
|
22 |
+
* @since 2.5.2
|
23 |
+
*/
|
24 |
+
public $base_url;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Total number of recovered orders
|
28 |
+
*
|
29 |
+
* @var int
|
30 |
+
* @since 2.5.2
|
31 |
+
*/
|
32 |
+
public $total_count;
|
33 |
+
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Total number of abandoned orders
|
37 |
+
*
|
38 |
+
* @var int
|
39 |
+
* @since 2.5.2
|
40 |
+
*/
|
41 |
+
public $total_abandoned_cart_count;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Total amount of abandoned orders
|
45 |
+
*
|
46 |
+
* @var int
|
47 |
+
* @since 2.5.2
|
48 |
+
*/
|
49 |
+
public $total_order_amount;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Total number recovered orders
|
53 |
+
*
|
54 |
+
* @var int
|
55 |
+
* @since 2.5.2
|
56 |
+
*/
|
57 |
+
public $recovered_item;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Total number recovred orders total
|
61 |
+
*
|
62 |
+
* @var int
|
63 |
+
* @since 2.5.2
|
64 |
+
*/
|
65 |
+
public $total_recover_amount;
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Get things started
|
69 |
+
*
|
70 |
+
* @see WP_List_Table::__construct()
|
71 |
+
*/
|
72 |
+
public function __construct() {
|
73 |
+
global $status, $page;
|
74 |
+
// Set parent defaults
|
75 |
+
parent::__construct( array(
|
76 |
+
'singular' => __( 'rec_abandoned_id', 'woocommerce-ac' ), //singular name of the listed records
|
77 |
+
'plural' => __( 'rec_abandoned_ids', 'woocommerce-ac' ), //plural name of the listed records
|
78 |
+
'ajax' => false // Does this table support ajax?
|
79 |
+
) );
|
80 |
+
$this->base_url = admin_url( 'admin.php?page=woocommerce_ac_page&action=stats' );
|
81 |
+
}
|
82 |
+
|
83 |
+
public function wcal_recovered_orders_prepare_items() {
|
84 |
+
$columns = $this->get_columns();
|
85 |
+
$hidden = array(); // No hidden columns
|
86 |
+
$sortable = $this->recovered_orders_get_sortable_columns();
|
87 |
+
$data = $this->wcal_recovered_orders_data();
|
88 |
+
$total_items = $this->total_count;
|
89 |
+
$total_abandoned_cart_count = $this->total_abandoned_cart_count;
|
90 |
+
$total_order_amount = $this->total_order_amount;
|
91 |
+
$total_recover_amount = $this->total_recover_amount;
|
92 |
+
$recovered_item = $this->recovered_item;
|
93 |
+
$this->items = $data;
|
94 |
+
$this->_column_headers = array( $columns, $hidden, $sortable);
|
95 |
+
$this->set_pagination_args( array(
|
96 |
+
'total_items' => $total_items, // WE have to calculate the total number of items
|
97 |
+
'per_page' => $this->per_page, // WE have to determine how many items to show on a page
|
98 |
+
'total_pages' => ceil( $total_items / $this->per_page ) // WE have to calculate the total number of pages
|
99 |
+
)
|
100 |
+
);
|
101 |
+
}
|
102 |
+
|
103 |
+
public function get_columns() {
|
104 |
+
$columns = array(
|
105 |
+
'user_name' => __( 'Customer Name', 'woocommerce-ac' ),
|
106 |
+
'user_email_id' => __( 'Email Address', 'woocommerce-ac' ),
|
107 |
+
'created_on' => __( 'Cart Abandoned Date', 'woocommerce-ac' ),
|
108 |
+
'recovered_date' => __( 'Cart Recovered Date' , 'woocommerce-ac'),
|
109 |
+
'order_total' => __( 'Order Total', 'woocommerce-ac' )
|
110 |
+
);
|
111 |
+
return apply_filters( 'wcal_recovered_orders_columns', $columns );
|
112 |
+
}
|
113 |
+
|
114 |
+
public function recovered_orders_get_sortable_columns() {
|
115 |
+
$columns = array(
|
116 |
+
'created_on' => array( 'created_on', false ),
|
117 |
+
'recovered_date' => array( 'recovered_date',false)
|
118 |
+
);
|
119 |
+
return apply_filters( 'wcal_templates_sortable_columns', $columns );
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Render the user name Column
|
124 |
+
*
|
125 |
+
* @access public
|
126 |
+
* @since 2.5.2
|
127 |
+
* @param array $abandoned_row_info Contains all the data of the template row
|
128 |
+
* @return string Data shown in the Email column
|
129 |
+
*
|
130 |
+
* This function used for individual delete of row, It is for hover effect delete.
|
131 |
+
*/
|
132 |
+
public function column_user_name( $recovered_orders_row_info ) {
|
133 |
+
$row_actions = array();
|
134 |
+
$value = '';
|
135 |
+
$recovered_id = 0;
|
136 |
+
|
137 |
+
if( isset( $recovered_orders_row_info->user_name ) ) {
|
138 |
+
$recovered_id = $recovered_orders_row_info->recovered_id ;
|
139 |
+
$row_actions['view_details'] = "<a target=_blank href = post.php?post=$recovered_id&action=edit>". __( 'View Details', 'woocommerce-ac' )."</a>";
|
140 |
+
$user_name = $recovered_orders_row_info->user_name;
|
141 |
+
$value = $user_name . $this->row_actions( $row_actions );
|
142 |
+
}
|
143 |
+
return apply_filters( 'wcal_recovered_orders_single_column', $value, $recovered_id, 'email' );
|
144 |
+
}
|
145 |
+
|
146 |
+
public function wcal_recovered_orders_data() {
|
147 |
+
global $wpdb, $woocommerce;
|
148 |
+
$wcal_class = new woocommerce_abandon_cart_lite ();
|
149 |
+
$number_decimal = wc_get_price_decimals();
|
150 |
+
|
151 |
+
if ( isset( $_POST['duration_select'] ) ) {
|
152 |
+
$duration_range = $_POST['duration_select'];
|
153 |
+
}
|
154 |
+
else {
|
155 |
+
$duration_range = "";
|
156 |
+
}
|
157 |
+
|
158 |
+
if ( $duration_range == "" ) {
|
159 |
+
if ( isset( $_GET['duration_select'] ) ) {
|
160 |
+
$duration_range = $_GET['duration_select'];
|
161 |
+
}
|
162 |
+
}
|
163 |
+
|
164 |
+
if ( $duration_range == "" ) {
|
165 |
+
$duration_range = "last_seven";
|
166 |
+
}
|
167 |
+
else {
|
168 |
+
$duration_range = "";
|
169 |
+
}
|
170 |
+
|
171 |
+
if ( isset( $_POST['start_date'] ) ) {
|
172 |
+
$start_date_range = $_POST['start_date'];
|
173 |
+
}
|
174 |
+
else {
|
175 |
+
$start_date_range = "";
|
176 |
+
}
|
177 |
+
|
178 |
+
if ( $start_date_range == "" ) {
|
179 |
+
$start_date_range = $wcal_class->start_end_dates[$duration_range]['start_date'];
|
180 |
+
}
|
181 |
+
|
182 |
+
if ( isset( $_POST['end_date'] ) ) $end_date_range = $_POST['end_date'];
|
183 |
+
else $end_date_range = "";
|
184 |
+
|
185 |
+
if ( $end_date_range == "" ) {
|
186 |
+
$end_date_range = $wcal_class->start_end_dates[$duration_range]['end_date'];
|
187 |
+
}
|
188 |
+
|
189 |
+
$start_date = strtotime( $start_date_range." 00:01:01" );
|
190 |
+
$end_date = strtotime( $end_date_range." 23:59:59" );
|
191 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
192 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
193 |
+
$current_time = current_time( 'timestamp' );
|
194 |
+
$compare_time = $current_time - $cut_off_time;
|
195 |
+
$blank_cart_info = '{"cart":[]}';
|
196 |
+
$blank_cart_info_guest = '[]';
|
197 |
+
|
198 |
+
$query_ac = "SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history_lite
|
199 |
+
WHERE abandoned_cart_time >= %d AND abandoned_cart_time <= %d AND recovered_cart > 0 AND abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' ORDER BY recovered_cart desc";
|
200 |
+
$ac_results = $wpdb->get_results( $wpdb->prepare( $query_ac, $start_date, $end_date ) );
|
201 |
+
|
202 |
+
$query_ac_carts = "SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history_lite
|
203 |
+
WHERE abandoned_cart_time >= %d AND abandoned_cart_time <= %d AND abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' ";
|
204 |
+
$ac_carts_results = $wpdb->get_results( $wpdb->prepare( $query_ac_carts, $start_date, $end_date ) );
|
205 |
+
|
206 |
+
$recovered_item = $recovered_total = $count_carts = $total_value = $order_total = 0;
|
207 |
+
$return_recovered_orders = array();
|
208 |
+
$per_page = $this->per_page;
|
209 |
+
$i = 0;
|
210 |
+
foreach ( $ac_carts_results as $key => $value ) {
|
211 |
+
$count_carts += 1;
|
212 |
+
$cart_detail = json_decode( $value->abandoned_cart_info );
|
213 |
+
$product_details = array();
|
214 |
+
if( isset( $cart_detail->cart ) ) {
|
215 |
+
$product_details = $cart_detail->cart;
|
216 |
+
}
|
217 |
+
$line_total = 0;
|
218 |
+
|
219 |
+
if ( isset( $product_details ) && count( $product_details ) > 0 && $product_details != false ) {
|
220 |
+
foreach ( $product_details as $k => $v ) {
|
221 |
+
if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
|
222 |
+
$line_total = $line_total + $v->line_total + $v->line_subtotal_tax;
|
223 |
+
} else {
|
224 |
+
$line_total = $line_total + $v->line_total;
|
225 |
+
}
|
226 |
+
}
|
227 |
+
}
|
228 |
+
$total_value += $line_total;
|
229 |
+
}
|
230 |
+
$total_value = wc_price( $total_value );
|
231 |
+
$this->total_order_amount = $total_value;
|
232 |
+
$this->total_abandoned_cart_count = $count_carts;
|
233 |
+
$recovered_order_total = 0;
|
234 |
+
$this->total_recover_amount = round( $recovered_order_total, $number_decimal );
|
235 |
+
$this->recovered_item = 0;
|
236 |
+
$table_data = "";
|
237 |
+
|
238 |
+
foreach ( $ac_results as $key => $value ) {
|
239 |
+
if( $value->recovered_cart != 0 ) {
|
240 |
+
$return_recovered_orders[$i] = new stdClass();
|
241 |
+
$recovered_id = $value->recovered_cart;
|
242 |
+
$rec_order = get_post_meta( $recovered_id );
|
243 |
+
$woo_order = array();
|
244 |
+
try{
|
245 |
+
$woo_order = new WC_Order( $recovered_id );
|
246 |
+
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
247 |
+
$order = get_post( $recovered_id );
|
248 |
+
$recovered_date = strtotime ( $order->post_date );
|
249 |
+
$recovered_date_format = date_i18n( get_option( 'date_format' ), $recovered_date );
|
250 |
+
$recovered_time_format = date_i18n( get_option( 'time_format' ), $recovered_date );
|
251 |
+
$recovered_date_new = $recovered_date_format . ' ' . $recovered_time_format;
|
252 |
+
} else {
|
253 |
+
$recovered_date = strtotime( $woo_order->order_date );
|
254 |
+
$recovered_date_format = date_i18n( get_option( 'date_format' ), $recovered_date );
|
255 |
+
$recovered_time_format = date_i18n( get_option( 'time_format' ), $recovered_date );
|
256 |
+
$recovered_date_new = $recovered_date_format . ' ' . $recovered_time_format;
|
257 |
+
}
|
258 |
+
$recovered_item += 1;
|
259 |
+
|
260 |
+
if ( isset( $rec_order ) && $rec_order != false ) {
|
261 |
+
$recovered_total += $rec_order['_order_total'][0];
|
262 |
+
}
|
263 |
+
$date_format = date_i18n( get_option( 'date_format' ), $value->abandoned_cart_time );
|
264 |
+
$time_format = date_i18n( get_option( 'time_format' ), $value->abandoned_cart_time );
|
265 |
+
$abandoned_date = $date_format . ' ' . $time_format;
|
266 |
+
$abandoned_order_id = $value->id;
|
267 |
+
$billing_first_name = $billing_last_name = $billing_email = '';
|
268 |
+
$recovered_order_total = 0;
|
269 |
+
|
270 |
+
if( isset( $rec_order['_billing_first_name'][0] ) ) {
|
271 |
+
$billing_first_name = $rec_order['_billing_first_name'][0];
|
272 |
+
}
|
273 |
+
|
274 |
+
if( isset( $rec_order['_billing_last_name'][0] ) ) {
|
275 |
+
$billing_last_name = $rec_order['_billing_last_name'][0];
|
276 |
+
}
|
277 |
+
|
278 |
+
if( isset( $rec_order['_billing_email'][0] ) ) {
|
279 |
+
$billing_email = $rec_order['_billing_email'][0];
|
280 |
+
}
|
281 |
+
|
282 |
+
if( isset( $rec_order['_order_total'][0] ) ) {
|
283 |
+
$recovered_order_total = $rec_order['_order_total'][0];
|
284 |
+
}
|
285 |
+
|
286 |
+
$return_recovered_orders[ $i ]->user_name = $billing_first_name . " " . $billing_last_name ;
|
287 |
+
$return_recovered_orders[ $i ]->user_email_id = $billing_email;
|
288 |
+
$return_recovered_orders[ $i ]->created_on = $abandoned_date;
|
289 |
+
$return_recovered_orders[ $i ]->recovered_date = $recovered_date_new;
|
290 |
+
$return_recovered_orders[ $i ]->recovered_id = $recovered_id;
|
291 |
+
$return_recovered_orders[ $i ]->recover_order_date = $recovered_date;
|
292 |
+
$return_recovered_orders[ $i ]->abandoned_date = $value->abandoned_cart_time;
|
293 |
+
$return_recovered_orders[ $i ]->order_total = wc_price($recovered_order_total);
|
294 |
+
|
295 |
+
$this->recovered_item = $recovered_item;
|
296 |
+
$this->total_recover_amount = round( ( $recovered_order_total + $this->total_recover_amount ), $number_decimal );
|
297 |
+
$i++;
|
298 |
+
}catch (Exception $e){
|
299 |
+
|
300 |
+
}
|
301 |
+
|
302 |
+
}
|
303 |
+
}
|
304 |
+
$templates_count = count( $return_recovered_orders );
|
305 |
+
$this->total_count = $templates_count;
|
306 |
+
// sort for order date
|
307 |
+
if( isset( $_GET['orderby'] ) && $_GET['orderby'] == 'created_on' ) {
|
308 |
+
if( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
|
309 |
+
usort( $return_recovered_orders, array( __CLASS__ , "wcal_class_recovered_created_on_asc" ) );
|
310 |
+
} else {
|
311 |
+
usort( $return_recovered_orders, array( __CLASS__ , "wcal_class_recovered_created_on_dsc" ) );
|
312 |
+
}
|
313 |
+
}
|
314 |
+
// sort for customer name
|
315 |
+
else if( isset( $_GET['orderby'] ) && $_GET['orderby'] == 'recovered_date' ) {
|
316 |
+
if( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
|
317 |
+
usort( $return_recovered_orders, array( __CLASS__ , "wcal_class_recovered_date_asc" ) );
|
318 |
+
} else {
|
319 |
+
usort( $return_recovered_orders, array( __CLASS__ , "wcal_class_recovered_date_dsc" ) );
|
320 |
+
}
|
321 |
+
}
|
322 |
+
// Pagination per page
|
323 |
+
if( isset( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
|
324 |
+
$page_number = $_GET['paged'] - 1;
|
325 |
+
$k = $per_page * $page_number;
|
326 |
+
} else {
|
327 |
+
$k = 0;
|
328 |
+
}
|
329 |
+
$return_recovered_orders_display = array();
|
330 |
+
for( $j = $k; $j < ( $k+$per_page ); $j++ ) {
|
331 |
+
if( isset( $return_recovered_orders[$j] ) ) {
|
332 |
+
$return_recovered_orders_display[$j] = $return_recovered_orders[$j];
|
333 |
+
} else {
|
334 |
+
break;
|
335 |
+
}
|
336 |
+
}
|
337 |
+
return apply_filters( 'wcal_recovered_orders_table_data', $return_recovered_orders_display );
|
338 |
+
}
|
339 |
+
|
340 |
+
function wcal_class_recovered_created_on_asc( $value1,$value2 ) {
|
341 |
+
return $value1->abandoned_date - $value2->abandoned_date;
|
342 |
+
}
|
343 |
+
|
344 |
+
function wcal_class_recovered_created_on_dsc( $value1,$value2 ) {
|
345 |
+
return $value2->abandoned_date - $value1->abandoned_date;
|
346 |
+
}
|
347 |
+
|
348 |
+
function wcal_class_recovered_date_asc( $value1,$value2 ) {
|
349 |
+
|
350 |
+
global $woocommerce;
|
351 |
+
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
352 |
+
$value1 = $value1->recover_order_date;
|
353 |
+
$value2 = $value2->recover_order_date;
|
354 |
+
|
355 |
+
$value1->recover_order_date = $value1->getTimestamp();
|
356 |
+
$value2->recover_order_date = $value2->getTimestamp();
|
357 |
+
}
|
358 |
+
return $value1->recover_order_date - $value2->recover_order_date;
|
359 |
+
}
|
360 |
+
|
361 |
+
function wcal_class_recovered_date_dsc( $value1,$value2 ) {
|
362 |
+
global $woocommerce;
|
363 |
+
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
364 |
+
$value1 = $value1->recover_order_date;
|
365 |
+
$value2 = $value2->recover_order_date;
|
366 |
+
|
367 |
+
$value1->recover_order_date = $value1->getTimestamp();
|
368 |
+
$value2->recover_order_date = $value2->getTimestamp();
|
369 |
+
}
|
370 |
+
return $value2->recover_order_date - $value1->recover_order_date;
|
371 |
+
}
|
372 |
+
|
373 |
+
public function column_default( $wcal_abandoned_orders, $column_name ) {
|
374 |
+
$value = '';
|
375 |
+
switch ( $column_name ) {
|
376 |
+
case 'user_email_id' :
|
377 |
+
if( isset( $wcal_abandoned_orders->user_email_id ) ) {
|
378 |
+
|
379 |
+
$user_email_id = "<a href= mailto:$wcal_abandoned_orders->user_email_id>". $wcal_abandoned_orders->user_email_id."</a>" ;
|
380 |
+
$value = $user_email_id;
|
381 |
+
}
|
382 |
+
break;
|
383 |
+
case 'created_on' :
|
384 |
+
if( isset( $wcal_abandoned_orders->created_on ) ) {
|
385 |
+
$value = $wcal_abandoned_orders->created_on;
|
386 |
+
}
|
387 |
+
break;
|
388 |
+
case 'recovered_date' :
|
389 |
+
if( isset( $wcal_abandoned_orders->recovered_date ) ) {
|
390 |
+
$value = $wcal_abandoned_orders->recovered_date;
|
391 |
+
}
|
392 |
+
break;
|
393 |
+
case 'order_total' :
|
394 |
+
if( isset( $wcal_abandoned_orders->order_total ) ) {
|
395 |
+
$value = $wcal_abandoned_orders->order_total;
|
396 |
+
}
|
397 |
+
break;
|
398 |
+
default:
|
399 |
+
$value = isset( $wcal_abandoned_orders->$column_name ) ? $wcal_abandoned_orders->$column_name : '';
|
400 |
+
break;
|
401 |
+
}
|
402 |
+
return apply_filters( 'wcal_recovered_orders_column_default', $value, $wcal_abandoned_orders, $column_name );
|
403 |
+
}
|
404 |
+
}
|
|
|
|
|
|
|
405 |
?>
|
woocommerce-abandoned-cart/includes/classes/class-wcal-templates-table.php
CHANGED
@@ -1,263 +1,263 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// Load WP_List_Table if not loaded
|
4 |
-
if ( ! class_exists( 'WP_List_Table' ) ) {
|
5 |
-
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
6 |
-
}
|
7 |
-
|
8 |
-
class WCAL_Templates_Table extends WP_List_Table {
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Number of results to show per page
|
12 |
-
*
|
13 |
-
* @var string
|
14 |
-
* @since 2.5.2
|
15 |
-
*/
|
16 |
-
public $per_page = 30;
|
17 |
-
|
18 |
-
/**
|
19 |
-
* URL of this page
|
20 |
-
*
|
21 |
-
* @var string
|
22 |
-
* @since 2.5.2
|
23 |
-
*/
|
24 |
-
public $base_url;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Total number of email templates
|
28 |
-
*
|
29 |
-
* @var int
|
30 |
-
* @since 2.5.3
|
31 |
-
*/
|
32 |
-
public $total_count;
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Get things started
|
36 |
-
*
|
37 |
-
* @see WP_List_Table::__construct()
|
38 |
-
*/
|
39 |
-
public function __construct() {
|
40 |
-
global $status, $page;
|
41 |
-
// Set parent defaults
|
42 |
-
parent::__construct( array(
|
43 |
-
'singular' => __( 'template_id', 'woocommerce-ac' ), //singular name of the listed records
|
44 |
-
'plural' => __( 'template_ids', 'woocommerce-ac' ), //plural name of the listed records
|
45 |
-
'ajax' => false // Does this table support ajax?
|
46 |
-
) );
|
47 |
-
$this->process_bulk_action();
|
48 |
-
$this->base_url = admin_url( 'admin.php?page=woocommerce_ac_page&action=emailtemplates' );
|
49 |
-
}
|
50 |
-
|
51 |
-
public function wcal_templates_prepare_items() {
|
52 |
-
$columns = $this->get_columns();
|
53 |
-
$hidden = array(); // No hidden columns
|
54 |
-
$sortable = $this->templates_get_sortable_columns();
|
55 |
-
$data = $this->wcal_templates_data();
|
56 |
-
|
57 |
-
$this->_column_headers = array( $columns, $hidden, $sortable );
|
58 |
-
$total_items = $this->total_count;
|
59 |
-
$this->items = $data;
|
60 |
-
|
61 |
-
$this->set_pagination_args( array(
|
62 |
-
'total_items' => $total_items, // WE have to calculate the total number of items
|
63 |
-
'per_page' => $this->per_page, // WE have to determine how many items to show on a page
|
64 |
-
'total_pages' => ceil( $total_items / $this->per_page ) // WE have to calculate the total number of pages
|
65 |
-
)
|
66 |
-
);
|
67 |
-
}
|
68 |
-
|
69 |
-
public function get_columns() {
|
70 |
-
$columns = array(
|
71 |
-
'cb' => '<input type="checkbox" />',
|
72 |
-
'sr' => __( 'Sr', 'woocommerce-ac' ),
|
73 |
-
'template_name' => __( 'Name Of Template', 'woocommerce-ac' ),
|
74 |
-
'sent_time' => __( 'Sent After Set Time', 'woocommerce-ac' ),
|
75 |
-
'activate' => __( 'Active ?', 'woocommerce-ac' )
|
76 |
-
);
|
77 |
-
return apply_filters( 'wcal_templates_columns', $columns );
|
78 |
-
}
|
79 |
-
/***
|
80 |
-
* It is used to add the check box for the items
|
81 |
-
*/
|
82 |
-
function column_cb( $item ) {
|
83 |
-
$template_id = '';
|
84 |
-
if( isset( $item->id ) && "" != $item->id ) {
|
85 |
-
$template_id = $item->id;
|
86 |
-
}
|
87 |
-
return sprintf(
|
88 |
-
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
|
89 |
-
'template_id',
|
90 |
-
$template_id
|
91 |
-
);
|
92 |
-
}
|
93 |
-
|
94 |
-
public function templates_get_sortable_columns() {
|
95 |
-
$columns = array(
|
96 |
-
'template_name' => array( 'template_name', false ),
|
97 |
-
'sent_time' => array( 'sent_time',false),
|
98 |
-
);
|
99 |
-
return apply_filters( 'wcal_templates_sortable_columns', $columns );
|
100 |
-
}
|
101 |
-
|
102 |
-
/**
|
103 |
-
* Render the Email Column
|
104 |
-
*
|
105 |
-
* @access public
|
106 |
-
* @since 2.5.2
|
107 |
-
* @param array $abandoned_row_info Contains all the data of the template row
|
108 |
-
* @return string Data shown in the Email column
|
109 |
-
*
|
110 |
-
* This function used for individual delete of row, It is for hover effect delete.
|
111 |
-
*/
|
112 |
-
public function column_template_name( $template_row_info ) {
|
113 |
-
$row_actions = array();
|
114 |
-
$value = '';
|
115 |
-
$template_id = 0;
|
116 |
-
if( isset( $template_row_info->template_name ) ) {
|
117 |
-
$template_id = $template_row_info->id ;
|
118 |
-
|
119 |
-
$row_actions['edit'] = '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'emailtemplates', 'mode'=>'edittemplate', 'id' => $template_row_info->id ), $this->base_url ), 'abandoned_order_nonce') . '">' . __( 'Edit', 'woocommerce-ac' ) . '</a>';
|
120 |
-
$row_actions['delete'] = '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'wcal_delete_template', 'template_id' => $template_row_info->id ), $this->base_url ), 'abandoned_order_nonce') . '">' . __( 'Delete', 'woocommerce-ac' ) . '</a>';
|
121 |
-
|
122 |
-
$email = $template_row_info->template_name;
|
123 |
-
$value = $email . $this->row_actions( $row_actions );
|
124 |
-
}
|
125 |
-
return apply_filters( 'wcal_template_single_column', $value, $template_id, 'email' );
|
126 |
-
}
|
127 |
-
|
128 |
-
public function wcal_templates_data() {
|
129 |
-
global $wpdb;
|
130 |
-
$return_templates_data = array();
|
131 |
-
$per_page = $this->per_page;
|
132 |
-
$results = array();
|
133 |
-
$query = "SELECT wpet . * FROM `" . $wpdb->prefix . "ac_email_templates_lite` AS wpet ORDER BY day_or_hour desc , frequency asc";
|
134 |
-
$results = $wpdb->get_results( $query );
|
135 |
-
$i = 0;
|
136 |
-
|
137 |
-
foreach ( $results as $key => $value ) {
|
138 |
-
$return_templates_data[$i] = new stdClass();
|
139 |
-
$id = $value->id;
|
140 |
-
$query_no_emails = "SELECT * FROM " . $wpdb->prefix . "ac_sent_history_lite WHERE template_id= %d";
|
141 |
-
$subject = $value->subject;
|
142 |
-
$body = $value->body;
|
143 |
-
$is_active = $value->is_active;
|
144 |
-
|
145 |
-
if ( $is_active == '1' ) {
|
146 |
-
$active = "Deactivate";
|
147 |
-
} else {
|
148 |
-
$active = "Activate";
|
149 |
-
}
|
150 |
-
$frequency = $value->frequency;
|
151 |
-
$day_or_hour = $value->day_or_hour;
|
152 |
-
$return_templates_data[ $i ]->sr = $i+1;
|
153 |
-
$return_templates_data[ $i ]->id = $id;
|
154 |
-
$return_templates_data[ $i ]->template_name = $value->template_name;
|
155 |
-
$return_templates_data[ $i ]->sent_time = __( $frequency . " " . $day_or_hour . " After Abandonment", 'woocommerce-ac' );
|
156 |
-
$return_templates_data[ $i ]->activate = $active;
|
157 |
-
$return_templates_data[ $i ]->is_active = $is_active;
|
158 |
-
$i++;
|
159 |
-
}
|
160 |
-
$templates_count = count( $return_templates_data );
|
161 |
-
$this->total_count = $templates_count;
|
162 |
-
// sort for order date
|
163 |
-
if( isset( $_GET['orderby'] ) && $_GET['orderby'] == 'template_name' ) {
|
164 |
-
if( isset($_GET['order'] ) && $_GET['order'] == 'asc' ) {
|
165 |
-
usort( $return_templates_data, array( __CLASS__ , "wcal_class_template_name_asc" ) );
|
166 |
-
} else {
|
167 |
-
usort( $return_templates_data, array( __CLASS__ , "wcal_class_template_name_dsc") );
|
168 |
-
}
|
169 |
-
}
|
170 |
-
// sort for customer name
|
171 |
-
else if ( isset( $_GET['orderby']) && $_GET['orderby'] == 'sent_time' ) {
|
172 |
-
if ( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
|
173 |
-
usort( $return_templates_data, array( __CLASS__ , "wcal_class_sent_time_asc" ) );
|
174 |
-
} else {
|
175 |
-
usort( $return_templates_data, array( __CLASS__ , "wcal_class_sent_time_dsc" ) );
|
176 |
-
}
|
177 |
-
}
|
178 |
-
// Pagination per page
|
179 |
-
if( isset( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
|
180 |
-
$page_number = $_GET['paged'] - 1;
|
181 |
-
$k = $per_page * $page_number;
|
182 |
-
} else {
|
183 |
-
$k = 0;
|
184 |
-
}
|
185 |
-
$return_templates_data_display = array();
|
186 |
-
for( $j = $k; $j < ( $k+$per_page ); $j++ ) {
|
187 |
-
if( isset( $return_templates_data[$j] ) ) {
|
188 |
-
$return_templates_data_display[$j] = $return_templates_data[$j];
|
189 |
-
} else {
|
190 |
-
break;
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
return apply_filters( 'wcal_templates_table_data', $return_templates_data_display );
|
195 |
-
}
|
196 |
-
|
197 |
-
function wcal_class_template_name_asc( $value1,$value2 ) {
|
198 |
-
return strcasecmp( $value1->template_name,$value2->template_name );
|
199 |
-
}
|
200 |
-
|
201 |
-
function wcal_class_template_name_dsc( $value1,$value2 ) {
|
202 |
-
return strcasecmp( $value2->template_name,$value1->template_name );
|
203 |
-
}
|
204 |
-
|
205 |
-
function wcal_class_sent_time_asc( $value1,$value2 ) {
|
206 |
-
return strnatcasecmp( $value1->sent_time,$value2->sent_time );
|
207 |
-
}
|
208 |
-
|
209 |
-
function wcal_class_sent_time_dsc( $value1,$value2 ) {
|
210 |
-
return strnatcasecmp( $value2->sent_time,$value1->sent_time );
|
211 |
-
}
|
212 |
-
|
213 |
-
public function column_default( $wcal_abandoned_orders, $column_name ) {
|
214 |
-
$value = '';
|
215 |
-
switch ( $column_name ) {
|
216 |
-
case 'sr' :
|
217 |
-
if( isset( $wcal_abandoned_orders->sr ) ) {
|
218 |
-
$value = $wcal_abandoned_orders->sr;
|
219 |
-
}
|
220 |
-
break;
|
221 |
-
case 'template_name' :
|
222 |
-
if( isset( $wcal_abandoned_orders->template_name ) ) {
|
223 |
-
$value = $wcal_abandoned_orders->template_name;
|
224 |
-
}
|
225 |
-
break;
|
226 |
-
case 'sent_time' :
|
227 |
-
if( isset( $wcal_abandoned_orders->sent_time ) ) {
|
228 |
-
$value = $wcal_abandoned_orders->sent_time;
|
229 |
-
}
|
230 |
-
break;
|
231 |
-
case 'activate' :
|
232 |
-
if( isset( $wcal_abandoned_orders->activate ) ) {
|
233 |
-
$active = $wcal_abandoned_orders->activate;
|
234 |
-
$id = $wcal_abandoned_orders->id;
|
235 |
-
$is_active = $wcal_abandoned_orders->is_active;
|
236 |
-
$active = '';
|
237 |
-
if ( $is_active == '1' ) {
|
238 |
-
$active = "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:
|
251 |
-
$value = isset( $wcal_abandoned_orders->$column_name ) ? $wcal_abandoned_orders->$column_name : '';
|
252 |
-
break;
|
253 |
-
}
|
254 |
-
return apply_filters( 'wcal_template_column_default', $value, $wcal_abandoned_orders, $column_name );
|
255 |
-
}
|
256 |
-
|
257 |
-
public function get_bulk_actions() {
|
258 |
-
return array(
|
259 |
-
'wcal_delete_template' => __( 'Delete', 'woocommerce-ac' )
|
260 |
-
);
|
261 |
-
}
|
262 |
-
}
|
263 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Load WP_List_Table if not loaded
|
4 |
+
if ( ! class_exists( 'WP_List_Table' ) ) {
|
5 |
+
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
|
6 |
+
}
|
7 |
+
|
8 |
+
class WCAL_Templates_Table extends WP_List_Table {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Number of results to show per page
|
12 |
+
*
|
13 |
+
* @var string
|
14 |
+
* @since 2.5.2
|
15 |
+
*/
|
16 |
+
public $per_page = 30;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* URL of this page
|
20 |
+
*
|
21 |
+
* @var string
|
22 |
+
* @since 2.5.2
|
23 |
+
*/
|
24 |
+
public $base_url;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Total number of email templates
|
28 |
+
*
|
29 |
+
* @var int
|
30 |
+
* @since 2.5.3
|
31 |
+
*/
|
32 |
+
public $total_count;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Get things started
|
36 |
+
*
|
37 |
+
* @see WP_List_Table::__construct()
|
38 |
+
*/
|
39 |
+
public function __construct() {
|
40 |
+
global $status, $page;
|
41 |
+
// Set parent defaults
|
42 |
+
parent::__construct( array(
|
43 |
+
'singular' => __( 'template_id', 'woocommerce-ac' ), //singular name of the listed records
|
44 |
+
'plural' => __( 'template_ids', 'woocommerce-ac' ), //plural name of the listed records
|
45 |
+
'ajax' => false // Does this table support ajax?
|
46 |
+
) );
|
47 |
+
$this->process_bulk_action();
|
48 |
+
$this->base_url = admin_url( 'admin.php?page=woocommerce_ac_page&action=emailtemplates' );
|
49 |
+
}
|
50 |
+
|
51 |
+
public function wcal_templates_prepare_items() {
|
52 |
+
$columns = $this->get_columns();
|
53 |
+
$hidden = array(); // No hidden columns
|
54 |
+
$sortable = $this->templates_get_sortable_columns();
|
55 |
+
$data = $this->wcal_templates_data();
|
56 |
+
|
57 |
+
$this->_column_headers = array( $columns, $hidden, $sortable );
|
58 |
+
$total_items = $this->total_count;
|
59 |
+
$this->items = $data;
|
60 |
+
|
61 |
+
$this->set_pagination_args( array(
|
62 |
+
'total_items' => $total_items, // WE have to calculate the total number of items
|
63 |
+
'per_page' => $this->per_page, // WE have to determine how many items to show on a page
|
64 |
+
'total_pages' => ceil( $total_items / $this->per_page ) // WE have to calculate the total number of pages
|
65 |
+
)
|
66 |
+
);
|
67 |
+
}
|
68 |
+
|
69 |
+
public function get_columns() {
|
70 |
+
$columns = array(
|
71 |
+
'cb' => '<input type="checkbox" />',
|
72 |
+
'sr' => __( 'Sr', 'woocommerce-ac' ),
|
73 |
+
'template_name' => __( 'Name Of Template', 'woocommerce-ac' ),
|
74 |
+
'sent_time' => __( 'Sent After Set Time', 'woocommerce-ac' ),
|
75 |
+
'activate' => __( 'Active ?', 'woocommerce-ac' )
|
76 |
+
);
|
77 |
+
return apply_filters( 'wcal_templates_columns', $columns );
|
78 |
+
}
|
79 |
+
/***
|
80 |
+
* It is used to add the check box for the items
|
81 |
+
*/
|
82 |
+
function column_cb( $item ) {
|
83 |
+
$template_id = '';
|
84 |
+
if( isset( $item->id ) && "" != $item->id ) {
|
85 |
+
$template_id = $item->id;
|
86 |
+
}
|
87 |
+
return sprintf(
|
88 |
+
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
|
89 |
+
'template_id',
|
90 |
+
$template_id
|
91 |
+
);
|
92 |
+
}
|
93 |
+
|
94 |
+
public function templates_get_sortable_columns() {
|
95 |
+
$columns = array(
|
96 |
+
'template_name' => array( 'template_name', false ),
|
97 |
+
'sent_time' => array( 'sent_time',false),
|
98 |
+
);
|
99 |
+
return apply_filters( 'wcal_templates_sortable_columns', $columns );
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Render the Email Column
|
104 |
+
*
|
105 |
+
* @access public
|
106 |
+
* @since 2.5.2
|
107 |
+
* @param array $abandoned_row_info Contains all the data of the template row
|
108 |
+
* @return string Data shown in the Email column
|
109 |
+
*
|
110 |
+
* This function used for individual delete of row, It is for hover effect delete.
|
111 |
+
*/
|
112 |
+
public function column_template_name( $template_row_info ) {
|
113 |
+
$row_actions = array();
|
114 |
+
$value = '';
|
115 |
+
$template_id = 0;
|
116 |
+
if( isset( $template_row_info->template_name ) ) {
|
117 |
+
$template_id = $template_row_info->id ;
|
118 |
+
|
119 |
+
$row_actions['edit'] = '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'emailtemplates', 'mode'=>'edittemplate', 'id' => $template_row_info->id ), $this->base_url ), 'abandoned_order_nonce') . '">' . __( 'Edit', 'woocommerce-ac' ) . '</a>';
|
120 |
+
$row_actions['delete'] = '<a href="' . wp_nonce_url( add_query_arg( array( 'action' => 'wcal_delete_template', 'template_id' => $template_row_info->id ), $this->base_url ), 'abandoned_order_nonce') . '">' . __( 'Delete', 'woocommerce-ac' ) . '</a>';
|
121 |
+
|
122 |
+
$email = $template_row_info->template_name;
|
123 |
+
$value = $email . $this->row_actions( $row_actions );
|
124 |
+
}
|
125 |
+
return apply_filters( 'wcal_template_single_column', $value, $template_id, 'email' );
|
126 |
+
}
|
127 |
+
|
128 |
+
public function wcal_templates_data() {
|
129 |
+
global $wpdb;
|
130 |
+
$return_templates_data = array();
|
131 |
+
$per_page = $this->per_page;
|
132 |
+
$results = array();
|
133 |
+
$query = "SELECT wpet . * FROM `" . $wpdb->prefix . "ac_email_templates_lite` AS wpet ORDER BY day_or_hour desc , frequency asc";
|
134 |
+
$results = $wpdb->get_results( $query );
|
135 |
+
$i = 0;
|
136 |
+
|
137 |
+
foreach ( $results as $key => $value ) {
|
138 |
+
$return_templates_data[$i] = new stdClass();
|
139 |
+
$id = $value->id;
|
140 |
+
$query_no_emails = "SELECT * FROM " . $wpdb->prefix . "ac_sent_history_lite WHERE template_id= %d";
|
141 |
+
$subject = $value->subject;
|
142 |
+
$body = $value->body;
|
143 |
+
$is_active = $value->is_active;
|
144 |
+
|
145 |
+
if ( $is_active == '1' ) {
|
146 |
+
$active = "Deactivate";
|
147 |
+
} else {
|
148 |
+
$active = "Activate";
|
149 |
+
}
|
150 |
+
$frequency = $value->frequency;
|
151 |
+
$day_or_hour = $value->day_or_hour;
|
152 |
+
$return_templates_data[ $i ]->sr = $i+1;
|
153 |
+
$return_templates_data[ $i ]->id = $id;
|
154 |
+
$return_templates_data[ $i ]->template_name = $value->template_name;
|
155 |
+
$return_templates_data[ $i ]->sent_time = __( $frequency . " " . $day_or_hour . " After Abandonment", 'woocommerce-ac' );
|
156 |
+
$return_templates_data[ $i ]->activate = $active;
|
157 |
+
$return_templates_data[ $i ]->is_active = $is_active;
|
158 |
+
$i++;
|
159 |
+
}
|
160 |
+
$templates_count = count( $return_templates_data );
|
161 |
+
$this->total_count = $templates_count;
|
162 |
+
// sort for order date
|
163 |
+
if( isset( $_GET['orderby'] ) && $_GET['orderby'] == 'template_name' ) {
|
164 |
+
if( isset($_GET['order'] ) && $_GET['order'] == 'asc' ) {
|
165 |
+
usort( $return_templates_data, array( __CLASS__ , "wcal_class_template_name_asc" ) );
|
166 |
+
} else {
|
167 |
+
usort( $return_templates_data, array( __CLASS__ , "wcal_class_template_name_dsc") );
|
168 |
+
}
|
169 |
+
}
|
170 |
+
// sort for customer name
|
171 |
+
else if ( isset( $_GET['orderby']) && $_GET['orderby'] == 'sent_time' ) {
|
172 |
+
if ( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
|
173 |
+
usort( $return_templates_data, array( __CLASS__ , "wcal_class_sent_time_asc" ) );
|
174 |
+
} else {
|
175 |
+
usort( $return_templates_data, array( __CLASS__ , "wcal_class_sent_time_dsc" ) );
|
176 |
+
}
|
177 |
+
}
|
178 |
+
// Pagination per page
|
179 |
+
if( isset( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
|
180 |
+
$page_number = $_GET['paged'] - 1;
|
181 |
+
$k = $per_page * $page_number;
|
182 |
+
} else {
|
183 |
+
$k = 0;
|
184 |
+
}
|
185 |
+
$return_templates_data_display = array();
|
186 |
+
for( $j = $k; $j < ( $k+$per_page ); $j++ ) {
|
187 |
+
if( isset( $return_templates_data[$j] ) ) {
|
188 |
+
$return_templates_data_display[$j] = $return_templates_data[$j];
|
189 |
+
} else {
|
190 |
+
break;
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
return apply_filters( 'wcal_templates_table_data', $return_templates_data_display );
|
195 |
+
}
|
196 |
+
|
197 |
+
function wcal_class_template_name_asc( $value1,$value2 ) {
|
198 |
+
return strcasecmp( $value1->template_name,$value2->template_name );
|
199 |
+
}
|
200 |
+
|
201 |
+
function wcal_class_template_name_dsc( $value1,$value2 ) {
|
202 |
+
return strcasecmp( $value2->template_name,$value1->template_name );
|
203 |
+
}
|
204 |
+
|
205 |
+
function wcal_class_sent_time_asc( $value1,$value2 ) {
|
206 |
+
return strnatcasecmp( $value1->sent_time,$value2->sent_time );
|
207 |
+
}
|
208 |
+
|
209 |
+
function wcal_class_sent_time_dsc( $value1,$value2 ) {
|
210 |
+
return strnatcasecmp( $value2->sent_time,$value1->sent_time );
|
211 |
+
}
|
212 |
+
|
213 |
+
public function column_default( $wcal_abandoned_orders, $column_name ) {
|
214 |
+
$value = '';
|
215 |
+
switch ( $column_name ) {
|
216 |
+
case 'sr' :
|
217 |
+
if( isset( $wcal_abandoned_orders->sr ) ) {
|
218 |
+
$value = $wcal_abandoned_orders->sr;
|
219 |
+
}
|
220 |
+
break;
|
221 |
+
case 'template_name' :
|
222 |
+
if( isset( $wcal_abandoned_orders->template_name ) ) {
|
223 |
+
$value = $wcal_abandoned_orders->template_name;
|
224 |
+
}
|
225 |
+
break;
|
226 |
+
case 'sent_time' :
|
227 |
+
if( isset( $wcal_abandoned_orders->sent_time ) ) {
|
228 |
+
$value = $wcal_abandoned_orders->sent_time;
|
229 |
+
}
|
230 |
+
break;
|
231 |
+
case 'activate' :
|
232 |
+
if( isset( $wcal_abandoned_orders->activate ) ) {
|
233 |
+
$active = $wcal_abandoned_orders->activate;
|
234 |
+
$id = $wcal_abandoned_orders->id;
|
235 |
+
$is_active = $wcal_abandoned_orders->is_active;
|
236 |
+
$active = '';
|
237 |
+
if ( $is_active == '1' ) {
|
238 |
+
$active = "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:
|
251 |
+
$value = isset( $wcal_abandoned_orders->$column_name ) ? $wcal_abandoned_orders->$column_name : '';
|
252 |
+
break;
|
253 |
+
}
|
254 |
+
return apply_filters( 'wcal_template_column_default', $value, $wcal_abandoned_orders, $column_name );
|
255 |
+
}
|
256 |
+
|
257 |
+
public function get_bulk_actions() {
|
258 |
+
return array(
|
259 |
+
'wcal_delete_template' => __( 'Delete', 'woocommerce-ac' )
|
260 |
+
);
|
261 |
+
}
|
262 |
+
}
|
263 |
?>
|
woocommerce-abandoned-cart/includes/classes/class-wcal-ts-tracker.php
CHANGED
@@ -1,656 +1,656 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Abandoned cart data tracker
|
4 |
-
*
|
5 |
-
* The Abandoned Cart lite tracker class adds functionality to track Abandoned Cart lite Date usage based on if the customer opted in.
|
6 |
-
* No personal information is tracked, only general Abandoned Cart lite settings, abandoned orders and recovered orders, abandoned orders amount, recovred orders amount, total templates, total email sent, logged-in users abandoned & recovered amount, guest users abandoned and admin email for discount code.
|
7 |
-
*
|
8 |
-
* @class Class_Wcal_Ts_Tracker
|
9 |
-
* @version 6.8
|
10 |
-
*/
|
11 |
-
|
12 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
13 |
-
exit;
|
14 |
-
}
|
15 |
-
|
16 |
-
class Class_Wcal_Ts_Tracker {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* URL to the Tracker API endpoint.
|
20 |
-
* @var string
|
21 |
-
*/
|
22 |
-
private static $wcal_api_url = 'http://tracking.tychesoftwares.com/v1/';
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Hook into cron event.
|
26 |
-
*/
|
27 |
-
public static function init() {
|
28 |
-
add_action( 'wcal_ts_tracker_send_event', array( __CLASS__, 'wcal_ts_send_tracking_data' ) );
|
29 |
-
add_filter( 'ts_tracker_data', array( __CLASS__, 'wcal_ts_add_plugin_tracking_data' ), 10, 1);
|
30 |
-
add_filter( 'ts_tracker_opt_out_data', array( __CLASS__, 'wcal_get_data_for_opt_out' ), 10, 1);
|
31 |
-
}
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Decide whether to send tracking data or not.
|
35 |
-
*
|
36 |
-
* @param boolean $override
|
37 |
-
*/
|
38 |
-
public static function wcal_ts_send_tracking_data( $override = false ) {
|
39 |
-
|
40 |
-
if ( ! apply_filters( 'wcal_ts_tracker_send_override', $override ) ) {
|
41 |
-
// Send a maximum of once per week by default.
|
42 |
-
$wcal_last_send = self::wcal_ts_get_last_send_time();
|
43 |
-
if ( $wcal_last_send && $wcal_last_send > apply_filters( 'wcal_ts_tracker_last_send_interval', strtotime( '-1 week' ) ) ) {
|
44 |
-
return;
|
45 |
-
}
|
46 |
-
} else {
|
47 |
-
// Make sure there is at least a 1 hour delay between override sends, we don't want duplicate calls due to double clicking links.
|
48 |
-
$wcal_last_send = self::wcal_ts_get_last_send_time();
|
49 |
-
if ( $wcal_last_send && $wcal_last_send > strtotime( '-1 hours' ) ) {
|
50 |
-
return;
|
51 |
-
}
|
52 |
-
}
|
53 |
-
|
54 |
-
$allow_tracking = get_option('wcal_allow_tracking');
|
55 |
-
if ( 'yes' == $allow_tracking ){
|
56 |
-
$override = true;
|
57 |
-
}
|
58 |
-
|
59 |
-
// Update time first before sending to ensure it is set
|
60 |
-
update_option( 'wcal_ts_tracker_last_send', time() );
|
61 |
-
|
62 |
-
if( $override == false ) {
|
63 |
-
$params = array();
|
64 |
-
$params[ 'tracking_usage' ] = 'no';
|
65 |
-
$params[ 'url' ] = home_url();
|
66 |
-
$params[ 'email' ] = apply_filters( 'wcal_ts_tracker_admin_email', get_option( 'admin_email' ) );
|
67 |
-
|
68 |
-
$params = apply_filters( 'ts_tracker_opt_out_data', $params );
|
69 |
-
} else {
|
70 |
-
|
71 |
-
$params = self::wcal_ts_get_tracking_data();
|
72 |
-
}
|
73 |
-
|
74 |
-
wp_safe_remote_post( self::$wcal_api_url, array(
|
75 |
-
'method' => 'POST',
|
76 |
-
'timeout' => 45,
|
77 |
-
'redirection' => 5,
|
78 |
-
'httpversion' => '1.0',
|
79 |
-
'blocking' => false,
|
80 |
-
'headers' => array( 'user-agent' => 'TSTracker/' . md5( esc_url( home_url( '/' ) ) ) . ';' ),
|
81 |
-
'body' => json_encode( $params ),
|
82 |
-
'cookies' => array(),
|
83 |
-
)
|
84 |
-
);
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Get the last time tracking data was sent.
|
89 |
-
* @return int|bool
|
90 |
-
*/
|
91 |
-
private static function wcal_ts_get_last_send_time() {
|
92 |
-
return apply_filters( 'wcal_ts_tracker_last_send_time', get_option( 'wcal_ts_tracker_last_send', false ) );
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Get all the tracking data.
|
97 |
-
* @return array
|
98 |
-
*/
|
99 |
-
private static function wcal_ts_get_tracking_data() {
|
100 |
-
$data = array();
|
101 |
-
|
102 |
-
// General site info
|
103 |
-
$data[ 'url' ] = home_url();
|
104 |
-
$data[ 'email' ] = apply_filters( 'wcal_ts_tracker_admin_email', get_option( 'admin_email' ) );
|
105 |
-
|
106 |
-
// WordPress Info
|
107 |
-
$data[ 'wp' ] = self::wcal_ts_get_wordpress_info();
|
108 |
-
|
109 |
-
$data[ 'theme_info' ] = self::wcal_ts_get_theme_info();
|
110 |
-
|
111 |
-
// Server Info
|
112 |
-
$data[ 'server' ] = self::wcal_ts_get_server_info();
|
113 |
-
|
114 |
-
// Plugin info
|
115 |
-
$all_plugins = self::wcal_ts_get_all_plugins();
|
116 |
-
$data[ 'active_plugins' ] = $all_plugins[ 'active_plugins' ];
|
117 |
-
$data[ 'inactive_plugins' ] = $all_plugins[ 'inactive_plugins' ];
|
118 |
-
|
119 |
-
//WooCommerce version
|
120 |
-
$data[ 'wc_plugin_version' ] = self::wcal_ts_get_wc_plugin_version();
|
121 |
-
return apply_filters( 'ts_tracker_data', $data );
|
122 |
-
}
|
123 |
-
|
124 |
-
/**
|
125 |
-
* Get plugin related data.
|
126 |
-
* @return array
|
127 |
-
*/
|
128 |
-
public static function wcal_ts_add_plugin_tracking_data ( $data ){
|
129 |
-
|
130 |
-
|
131 |
-
if ( isset( $_GET[ 'wcal_tracker_optin' ] ) && isset( $_GET[ 'wcal_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ 'wcal_tracker_nonce' ], 'wcal_tracker_optin' ) ) {
|
132 |
-
|
133 |
-
$plugin_data[ 'ts_meta_data_table_name'] = 'ts_wcal_tracking_meta_data';
|
134 |
-
|
135 |
-
$plugin_data[ 'ts_plugin_name' ] = 'Abandoned Cart Lite for WooCommerce';
|
136 |
-
|
137 |
-
// Store abandoned count info
|
138 |
-
$plugin_data[ 'abandoned_orders' ] = self::wcal_ts_get_abandoned_order_counts();
|
139 |
-
|
140 |
-
// Store recovred count info
|
141 |
-
$plugin_data[ 'recovered_orders' ] = self::wcal_ts_get_recovered_order_counts();
|
142 |
-
|
143 |
-
// store abandoned orders amount
|
144 |
-
$plugin_data[ 'abandoned_orders_amount' ] = self::wcal_ts_get_abandoned_order_total_amount();
|
145 |
-
|
146 |
-
// Store recovered count info
|
147 |
-
$plugin_data[ 'recovered_orders_amount' ] = self::wcal_ts_get_recovered_order_total_amount();
|
148 |
-
|
149 |
-
// Store abandoned cart emails sent count info
|
150 |
-
$plugin_data[ 'sent_emails' ] = self::wcal_ts_get_sent_emails_total_count();
|
151 |
-
|
152 |
-
// Store email template count info
|
153 |
-
$plugin_data[ 'email_templates_data' ] = self::wcal_ts_get_email_templates_data();
|
154 |
-
|
155 |
-
// Store only logged-in users abandoned cart count info
|
156 |
-
$plugin_data[ 'logged_in_abandoned_orders' ] = self::wcal_ts_get_logged_in_users_abandoned_cart_total_count();
|
157 |
-
|
158 |
-
// Store only logged-in users abandoned cart count info
|
159 |
-
$plugin_data[ 'guest_abandoned_orders' ] = self::wcal_ts_get_guest_users_abandoned_cart_total_count();
|
160 |
-
|
161 |
-
// Store only logged-in users abandoned cart amount info
|
162 |
-
$plugin_data[ 'logged_in_abandoned_orders_amount' ] = self::wcal_ts_get_logged_in_users_abandoned_cart_total_amount();
|
163 |
-
|
164 |
-
// store only guest users abandoned cart amount
|
165 |
-
$plugin_data[ 'guest_abandoned_orders_amount' ] = self::wcal_ts_get_guest_users_abandoned_cart_total_amount();
|
166 |
-
|
167 |
-
// Store only logged-in users recovered cart amount info
|
168 |
-
$plugin_data[ 'logged_in_recovered_orders_amount' ] = self::wcal_ts_get_logged_in_users_recovered_cart_total_amount();
|
169 |
-
|
170 |
-
// Store only guest users recovered cart amount
|
171 |
-
$plugin_data[ 'guest_recovered_orders_amount' ] = self::wcal_ts_get_guest_users_recovered_cart_total_amount();
|
172 |
-
|
173 |
-
// Get all plugin options info
|
174 |
-
$plugin_data[ 'settings' ] = self::wcal_ts_get_all_plugin_options_values();
|
175 |
-
$plugin_data[ 'plugin_version' ] = self::wcal_ts_get_plugin_version();
|
176 |
-
$plugin_data[ 'wcal_allow_tracking' ] = get_option ('wcal_allow_tracking');
|
177 |
-
|
178 |
-
$data [ 'plugin_data' ] = $plugin_data;
|
179 |
-
}
|
180 |
-
return $data;
|
181 |
-
}
|
182 |
-
|
183 |
-
/**
|
184 |
-
* Get data when user dont want to share information.
|
185 |
-
* @return array
|
186 |
-
*/
|
187 |
-
public static function wcal_get_data_for_opt_out( $params ){
|
188 |
-
|
189 |
-
$plugin_data[ 'ts_meta_data_table_name'] = 'ts_wcal_tracking_meta_data';
|
190 |
-
$plugin_data[ 'ts_plugin_name' ] = 'Abandoned Cart Lite for WooCommerce';
|
191 |
-
$plugin_data[ 'abandoned_orders_amount' ] = self::wcal_ts_get_abandoned_order_total_amount();
|
192 |
-
// Store recovered count info
|
193 |
-
$plugin_data[ 'recovered_orders_amount' ] = self::wcal_ts_get_recovered_order_total_amount();
|
194 |
-
|
195 |
-
$params[ 'plugin_data' ] = $plugin_data;
|
196 |
-
|
197 |
-
return $params;
|
198 |
-
}
|
199 |
-
|
200 |
-
|
201 |
-
/**
|
202 |
-
* Get WordPress related data.
|
203 |
-
* @return array
|
204 |
-
*/
|
205 |
-
private static function wcal_ts_get_wordpress_info() {
|
206 |
-
$wp_data = array();
|
207 |
-
|
208 |
-
$memory = wc_let_to_num( WP_MEMORY_LIMIT );
|
209 |
-
|
210 |
-
if ( function_exists( 'memory_get_usage' ) ) {
|
211 |
-
$system_memory = wc_let_to_num( @ini_get( 'memory_limit' ) );
|
212 |
-
$memory = max( $memory, $system_memory );
|
213 |
-
}
|
214 |
-
|
215 |
-
$wp_data[ 'memory_limit' ] = size_format( $memory );
|
216 |
-
$wp_data[ 'debug_mode' ] = ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? 'Yes' : 'No';
|
217 |
-
$wp_data[ 'locale' ] = get_locale();
|
218 |
-
$wp_data[ 'wp_version' ] = get_bloginfo( 'version' );
|
219 |
-
$wp_data[ 'multisite' ] = is_multisite() ? 'Yes' : 'No';
|
220 |
-
|
221 |
-
return $wp_data;
|
222 |
-
}
|
223 |
-
|
224 |
-
/**
|
225 |
-
* Get the current theme info, theme name and version.
|
226 |
-
* @return array
|
227 |
-
*/
|
228 |
-
public static function wcal_ts_get_theme_info() {
|
229 |
-
$theme_data = wp_get_theme();
|
230 |
-
$theme_child_theme = is_child_theme() ? 'Yes' : 'No';
|
231 |
-
|
232 |
-
return array( 'theme_name' => $theme_data->Name,
|
233 |
-
'theme_version' => $theme_data->Version,
|
234 |
-
'child_theme' => $theme_child_theme );
|
235 |
-
}
|
236 |
-
|
237 |
-
/**
|
238 |
-
* Get server related info.
|
239 |
-
* @return array
|
240 |
-
*/
|
241 |
-
private static function wcal_ts_get_server_info() {
|
242 |
-
$server_data = array();
|
243 |
-
|
244 |
-
if ( isset( $_SERVER[ 'SERVER_SOFTWARE' ] ) && ! empty( $_SERVER[ 'SERVER_SOFTWARE' ] ) ) {
|
245 |
-
$server_data[ 'software' ] = $_SERVER[ 'SERVER_SOFTWARE' ];
|
246 |
-
}
|
247 |
-
|
248 |
-
if ( function_exists( 'phpversion' ) ) {
|
249 |
-
$server_data[ 'php_version' ] = phpversion();
|
250 |
-
}
|
251 |
-
|
252 |
-
if ( function_exists( 'ini_get' ) ) {
|
253 |
-
$server_data[ 'php_post_max_size' ] = size_format( wc_let_to_num( ini_get( 'post_max_size' ) ) );
|
254 |
-
$server_data[ 'php_time_limt' ] = ini_get( 'max_execution_time' );
|
255 |
-
$server_data[ 'php_max_input_vars' ] = ini_get( 'max_input_vars' );
|
256 |
-
$server_data[ 'php_suhosin' ] = extension_loaded( 'suhosin' ) ? 'Yes' : 'No';
|
257 |
-
}
|
258 |
-
|
259 |
-
global $wpdb;
|
260 |
-
$server_data[ 'mysql_version' ] = $wpdb->db_version();
|
261 |
-
|
262 |
-
$server_data[ 'php_max_upload_size' ] = size_format( wp_max_upload_size() );
|
263 |
-
$server_data[ 'php_default_timezone' ] = date_default_timezone_get();
|
264 |
-
$server_data[ 'php_soap' ] = class_exists( 'SoapClient' ) ? 'Yes' : 'No';
|
265 |
-
$server_data[ 'php_fsockopen' ] = function_exists( 'fsockopen' ) ? 'Yes' : 'No';
|
266 |
-
$server_data[ 'php_curl' ] = function_exists( 'curl_init' ) ? 'Yes' : 'No';
|
267 |
-
|
268 |
-
return $server_data;
|
269 |
-
}
|
270 |
-
|
271 |
-
/**
|
272 |
-
* Get all plugins grouped into activated or not.
|
273 |
-
* @return array
|
274 |
-
*/
|
275 |
-
private static function wcal_ts_get_all_plugins() {
|
276 |
-
// Ensure get_plugins function is loaded
|
277 |
-
if ( ! function_exists( 'get_plugins' ) ) {
|
278 |
-
include ABSPATH . '/wp-admin/includes/plugin.php';
|
279 |
-
}
|
280 |
-
|
281 |
-
$plugins = get_plugins();
|
282 |
-
$active_plugins_keys = get_option( 'active_plugins', array() );
|
283 |
-
$active_plugins = array();
|
284 |
-
|
285 |
-
foreach ( $plugins as $k => $v ) {
|
286 |
-
// Take care of formatting the data how we want it.
|
287 |
-
$formatted = array();
|
288 |
-
$formatted[ 'name' ] = strip_tags( $v[ 'Name' ] );
|
289 |
-
if ( isset( $v[ 'Version' ] ) ) {
|
290 |
-
$formatted[ 'version' ] = strip_tags( $v[ 'Version' ] );
|
291 |
-
}
|
292 |
-
if ( isset( $v[ 'Author' ] ) ) {
|
293 |
-
$formatted[ 'author' ] = strip_tags( $v[ 'Author' ] );
|
294 |
-
}
|
295 |
-
if ( isset( $v[ 'Network' ] ) ) {
|
296 |
-
$formatted[ 'network' ] = strip_tags( $v[ 'Network' ] );
|
297 |
-
}
|
298 |
-
if ( isset( $v[ 'PluginURI' ] ) ) {
|
299 |
-
$formatted[ 'plugin_uri' ] = strip_tags( $v[ 'PluginURI' ] );
|
300 |
-
}
|
301 |
-
if ( in_array( $k, $active_plugins_keys ) ) {
|
302 |
-
// Remove active plugins from list so we can show active and inactive separately
|
303 |
-
unset( $plugins[ $k ] );
|
304 |
-
$active_plugins[ $k ] = $formatted;
|
305 |
-
} else {
|
306 |
-
$plugins[ $k ] = $formatted;
|
307 |
-
}
|
308 |
-
}
|
309 |
-
|
310 |
-
return array( 'active_plugins' => $active_plugins, 'inactive_plugins' => $plugins );
|
311 |
-
}
|
312 |
-
|
313 |
-
/**
|
314 |
-
* Get abandoned orders counts.
|
315 |
-
* @return string
|
316 |
-
*/
|
317 |
-
private static function wcal_ts_get_abandoned_order_counts() {
|
318 |
-
global $wpdb;
|
319 |
-
$wcal_order_count = 0;
|
320 |
-
|
321 |
-
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
322 |
-
$cut_off_time = $ac_cutoff_time * 60;
|
323 |
-
$current_time = current_time( 'timestamp' );
|
324 |
-
$compare_time = $current_time - $cut_off_time;
|
325 |
-
|
326 |
-
$blank_cart_info = '{"cart":[]}';
|
327 |
-
$blank_cart_info_guest = '[]';
|
328 |
-
|
329 |
-
$wcal_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest'";
|
330 |
-
|
331 |
-
$wcal_order_count = $wpdb->get_var( $wcal_query );
|
332 |
-
|
333 |
-
return $wcal_order_count;
|
334 |
-
}
|
335 |
-
|
336 |
-
|
337 |
-
/**
|
338 |
-
* Get recovered orders counts.
|
339 |
-
* @return string
|
340 |
-
*/
|
341 |
-
private static function wcal_ts_get_recovered_order_counts(){
|
342 |
-
|
343 |
-
global $wpdb;
|
344 |
-
$wcal_recovered_order_count = 0;
|
345 |
-
|
346 |
-
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
347 |
-
$cut_off_time = $ac_cutoff_time * 60;
|
348 |
-
$current_time = current_time( 'timestamp' );
|
349 |
-
$compare_time = $current_time - $cut_off_time;
|
350 |
-
|
351 |
-
$wcal_recovery_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time'";
|
352 |
-
|
353 |
-
$wcal_recovered_order_count = $wpdb->get_var( $wcal_recovery_query );
|
354 |
-
|
355 |
-
return $wcal_recovered_order_count;
|
356 |
-
}
|
357 |
-
|
358 |
-
/*
|
359 |
-
* Get Total abandoned orders amount
|
360 |
-
*
|
361 |
-
*/
|
362 |
-
private static function wcal_ts_get_abandoned_order_total_amount(){
|
363 |
-
global $wpdb;
|
364 |
-
$wcal_abandoned_orders_amount = 0;
|
365 |
-
|
366 |
-
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
367 |
-
$cut_off_time = $ac_cutoff_time * 60;
|
368 |
-
$current_time = current_time( 'timestamp' );
|
369 |
-
$compare_time = $current_time - $cut_off_time;
|
370 |
-
|
371 |
-
$blank_cart_info = '{"cart":[]}';
|
372 |
-
$blank_cart_info_guest = '[]';
|
373 |
-
|
374 |
-
$wcal_abandoned_query = "SELECT abandoned_cart_info FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest'";
|
375 |
-
|
376 |
-
$wcal_abandoned_query_result = $wpdb->get_results( $wcal_abandoned_query );
|
377 |
-
|
378 |
-
$wcal_abandoned_orders_amount = self::wcal_get_abandoned_amount( $wcal_abandoned_query_result );
|
379 |
-
|
380 |
-
return $wcal_abandoned_orders_amount;
|
381 |
-
}
|
382 |
-
|
383 |
-
private static function wcal_get_abandoned_amount( $wcal_abandoned_query_result ){
|
384 |
-
|
385 |
-
$wcal_abandoned_orders_amount = 0;
|
386 |
-
foreach ( $wcal_abandoned_query_result as $wcal_abandoned_query_key => $wcal_abandoned_query_value ) {
|
387 |
-
# code...
|
388 |
-
$cart_info = json_decode( $wcal_abandoned_query_value->abandoned_cart_info );
|
389 |
-
|
390 |
-
$cart_details = array();
|
391 |
-
if( isset( $cart_info->cart ) ){
|
392 |
-
$cart_details = $cart_info->cart;
|
393 |
-
}
|
394 |
-
|
395 |
-
if( count( $cart_details ) > 0 ) {
|
396 |
-
foreach( $cart_details as $k => $v ) {
|
397 |
-
if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
|
398 |
-
$wcal_abandoned_orders_amount = $wcal_abandoned_orders_amount + $v->line_total + $v->line_subtotal_tax;
|
399 |
-
} else {
|
400 |
-
$wcal_abandoned_orders_amount = $wcal_abandoned_orders_amount + $v->line_total;
|
401 |
-
}
|
402 |
-
}
|
403 |
-
}
|
404 |
-
}
|
405 |
-
return $wcal_abandoned_orders_amount;
|
406 |
-
}
|
407 |
-
|
408 |
-
/*
|
409 |
-
* Get recovered orders total amount
|
410 |
-
*/
|
411 |
-
private static function wcal_ts_get_recovered_order_total_amount(){
|
412 |
-
|
413 |
-
global $wpdb;
|
414 |
-
$wcal_recovered_orders_amount = 0;
|
415 |
-
|
416 |
-
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
417 |
-
$cut_off_time = $ac_cutoff_time * 60;
|
418 |
-
$current_time = current_time( 'timestamp' );
|
419 |
-
$compare_time = $current_time - $cut_off_time;
|
420 |
-
|
421 |
-
$wcal_recovery_query_amount = "SELECT recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time'";
|
422 |
-
|
423 |
-
$wcal_recovered_order_amount_result = $wpdb->get_results( $wcal_recovery_query_amount );
|
424 |
-
|
425 |
-
$wcal_recovered_orders_amount = self::wcal_get_recovered_amount ($wcal_recovered_order_amount_result );
|
426 |
-
|
427 |
-
return $wcal_recovered_orders_amount;
|
428 |
-
}
|
429 |
-
|
430 |
-
private static function wcal_get_recovered_amount ( $wcal_data ){
|
431 |
-
|
432 |
-
$wcal_recovered_orders_amount = 0;
|
433 |
-
|
434 |
-
foreach ($wcal_data as $wcal_data_key => $wcal_data_value) {
|
435 |
-
|
436 |
-
$wcal_order_total = get_post_meta( $wcal_data_value->recovered_cart , '_order_total', true);
|
437 |
-
$wcal_recovered_orders_amount = $wcal_recovered_orders_amount + $wcal_order_total;
|
438 |
-
}
|
439 |
-
return $wcal_recovered_orders_amount;
|
440 |
-
}
|
441 |
-
|
442 |
-
/*
|
443 |
-
* Get sent email total count
|
444 |
-
*/
|
445 |
-
private static function wcal_ts_get_sent_emails_total_count(){
|
446 |
-
|
447 |
-
global $wpdb;
|
448 |
-
$wcal_sent_emails_count = 0;
|
449 |
-
$wcal_sent_emails_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_sent_history_lite`";
|
450 |
-
$wcal_sent_emails_count = $wpdb->get_var( $wcal_sent_emails_query );
|
451 |
-
return $wcal_sent_emails_count;
|
452 |
-
}
|
453 |
-
|
454 |
-
/*
|
455 |
-
* Get email templates total count
|
456 |
-
*/
|
457 |
-
private static function wcal_ts_get_email_templates_data(){
|
458 |
-
|
459 |
-
global $wpdb;
|
460 |
-
$wcal_email_templates_count = 0;
|
461 |
-
$wcal_email_templates_query = "SELECT id, is_active, is_wc_template,frequency, day_or_hour FROM `" . $wpdb->prefix . "ac_email_templates_lite`";
|
462 |
-
$wcal_email_templates_results = $wpdb->get_results( $wcal_email_templates_query );
|
463 |
-
|
464 |
-
$wcal_email_templates_count = count( $wcal_email_templates_results );
|
465 |
-
|
466 |
-
$wcal_templates_data = array();
|
467 |
-
$wcal_templates_data ['total_templates'] = $wcal_email_templates_count;
|
468 |
-
|
469 |
-
foreach ($wcal_email_templates_results as $wcal_email_templates_results_key => $wcal_email_templates_results_value ) {
|
470 |
-
|
471 |
-
$wcal_template_time = $wcal_email_templates_results_value->frequency . ' ' .$wcal_email_templates_results_value->day_or_hour ;
|
472 |
-
|
473 |
-
$wcal_get_total_email_sent_for_template = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE template_id = ". $wcal_email_templates_results_value->id;
|
474 |
-
$wcal_get_total_email_sent_for_template_count = $wpdb->get_var( $wcal_get_total_email_sent_for_template );
|
475 |
-
|
476 |
-
$wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['is_activate'] = ( $wcal_email_templates_results_value->is_active == 1 ) ? 'Active' : 'Deactive';
|
477 |
-
$wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['is_wc_template'] = ( $wcal_email_templates_results_value->is_wc_template == 1 ) ? 'Yes' : 'No';
|
478 |
-
$wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['template_time'] = $wcal_template_time;
|
479 |
-
$wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['total_email_sent'] = $wcal_get_total_email_sent_for_template_count;
|
480 |
-
}
|
481 |
-
|
482 |
-
return $wcal_templates_data;
|
483 |
-
}
|
484 |
-
|
485 |
-
/*
|
486 |
-
* Get logged-in users total abandoned count
|
487 |
-
*/
|
488 |
-
private static function wcal_ts_get_logged_in_users_abandoned_cart_total_count (){
|
489 |
-
|
490 |
-
global $wpdb;
|
491 |
-
$wcal_logged_in_user_query_count = 0;
|
492 |
-
|
493 |
-
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
494 |
-
$cut_off_time = $ac_cutoff_time * 60;
|
495 |
-
$current_time = current_time( 'timestamp' );
|
496 |
-
$compare_time = $current_time - $cut_off_time;
|
497 |
-
|
498 |
-
$blank_cart_info = '{"cart":[]}';
|
499 |
-
$blank_cart_info_guest = '[]';
|
500 |
-
|
501 |
-
$wcal_logged_in_user_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id < 63000000 AND user_id != 0";
|
502 |
-
|
503 |
-
$wcal_logged_in_user_query_count = $wpdb->get_var( $wcal_logged_in_user_query );
|
504 |
-
|
505 |
-
return $wcal_logged_in_user_query_count;
|
506 |
-
}
|
507 |
-
|
508 |
-
/*
|
509 |
-
* Get logged-in users total abandoned count
|
510 |
-
*/
|
511 |
-
private static function wcal_ts_get_guest_users_abandoned_cart_total_count(){
|
512 |
-
global $wpdb;
|
513 |
-
$wcal_guest_user_query_count = 0;
|
514 |
-
|
515 |
-
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
516 |
-
$cut_off_time = $ac_cutoff_time * 60;
|
517 |
-
$current_time = current_time( 'timestamp' );
|
518 |
-
$compare_time = $current_time - $cut_off_time;
|
519 |
-
|
520 |
-
$blank_cart_info = '{"cart":[]}';
|
521 |
-
$blank_cart_info_guest = '[]';
|
522 |
-
|
523 |
-
$wcal_guest_user_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id >= 63000000 AND user_id != 0";
|
524 |
-
|
525 |
-
$wcal_guest_user_query_count = $wpdb->get_var( $wcal_guest_user_query );
|
526 |
-
|
527 |
-
return $wcal_guest_user_query_count;
|
528 |
-
}
|
529 |
-
|
530 |
-
private static function wcal_ts_get_logged_in_users_abandoned_cart_total_amount (){
|
531 |
-
|
532 |
-
global $wpdb;
|
533 |
-
$wcal_abandoned_orders_amount = 0;
|
534 |
-
|
535 |
-
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
536 |
-
$cut_off_time = $ac_cutoff_time * 60;
|
537 |
-
$current_time = current_time( 'timestamp' );
|
538 |
-
$compare_time = $current_time - $cut_off_time;
|
539 |
-
|
540 |
-
$blank_cart_info = '{"cart":[]}';
|
541 |
-
$blank_cart_info_guest = '[]';
|
542 |
-
|
543 |
-
$wcal_abandoned_query = "SELECT abandoned_cart_info FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id < 63000000 AND user_id != 0 ";
|
544 |
-
|
545 |
-
$wcal_abandoned_query_result = $wpdb->get_results( $wcal_abandoned_query );
|
546 |
-
|
547 |
-
$wcal_abandoned_orders_amount = self::wcal_get_abandoned_amount( $wcal_abandoned_query_result );
|
548 |
-
|
549 |
-
return $wcal_abandoned_orders_amount;
|
550 |
-
}
|
551 |
-
|
552 |
-
private static function wcal_ts_get_guest_users_abandoned_cart_total_amount (){
|
553 |
-
|
554 |
-
global $wpdb;
|
555 |
-
$wcal_abandoned_orders_amount = 0;
|
556 |
-
|
557 |
-
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
558 |
-
$cut_off_time = $ac_cutoff_time * 60;
|
559 |
-
$current_time = current_time( 'timestamp' );
|
560 |
-
$compare_time = $current_time - $cut_off_time;
|
561 |
-
|
562 |
-
$blank_cart_info = '{"cart":[]}';
|
563 |
-
$blank_cart_info_guest = '[]';
|
564 |
-
|
565 |
-
$wcal_abandoned_query = "SELECT abandoned_cart_info FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id >= 63000000 AND user_id != 0 ";
|
566 |
-
|
567 |
-
$wcal_abandoned_query_result = $wpdb->get_results( $wcal_abandoned_query );
|
568 |
-
|
569 |
-
$wcal_abandoned_orders_amount = self::wcal_get_abandoned_amount( $wcal_abandoned_query_result );
|
570 |
-
|
571 |
-
return $wcal_abandoned_orders_amount;
|
572 |
-
}
|
573 |
-
|
574 |
-
private static function wcal_ts_get_logged_in_users_recovered_cart_total_amount(){
|
575 |
-
|
576 |
-
global $wpdb;
|
577 |
-
$wcal_recovered_orders_amount = 0;
|
578 |
-
|
579 |
-
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
580 |
-
$cut_off_time = $ac_cutoff_time * 60;
|
581 |
-
$current_time = current_time( 'timestamp' );
|
582 |
-
$compare_time = $current_time - $cut_off_time;
|
583 |
-
|
584 |
-
$wcal_recovery_query_amount = "SELECT recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time' AND user_id < 63000000 AND user_id != 0 ";
|
585 |
-
|
586 |
-
$wcal_recovered_order_amount_result = $wpdb->get_results( $wcal_recovery_query_amount );
|
587 |
-
|
588 |
-
$wcal_recovered_orders_amount = self::wcal_get_recovered_amount ($wcal_recovered_order_amount_result );
|
589 |
-
|
590 |
-
return $wcal_recovered_orders_amount;
|
591 |
-
|
592 |
-
}
|
593 |
-
|
594 |
-
|
595 |
-
private static function wcal_ts_get_guest_users_recovered_cart_total_amount (){
|
596 |
-
|
597 |
-
global $wpdb;
|
598 |
-
$wcal_recovered_orders_amount = 0;
|
599 |
-
|
600 |
-
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
601 |
-
$cut_off_time = $ac_cutoff_time * 60;
|
602 |
-
$current_time = current_time( 'timestamp' );
|
603 |
-
$compare_time = $current_time - $cut_off_time;
|
604 |
-
|
605 |
-
$wcal_recovery_query_amount = "SELECT recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time' AND user_id >= 63000000 AND user_id != 0 ";
|
606 |
-
|
607 |
-
$wcal_recovered_order_amount_result = $wpdb->get_results( $wcal_recovery_query_amount );
|
608 |
-
|
609 |
-
$wcal_recovered_orders_amount = self::wcal_get_recovered_amount ($wcal_recovered_order_amount_result );
|
610 |
-
|
611 |
-
return $wcal_recovered_orders_amount;
|
612 |
-
|
613 |
-
}
|
614 |
-
/**
|
615 |
-
* Get all options starting with woocommerce_ prefix.
|
616 |
-
* @return array
|
617 |
-
*/
|
618 |
-
private static function wcal_ts_get_all_plugin_options_values() {
|
619 |
-
|
620 |
-
return array(
|
621 |
-
'wcal_cart_cut_off_time' => get_option( 'ac_lite_cart_abandoned_time' ),
|
622 |
-
'wcal_admin_recovery_email' => get_option( 'ac_lite_email_admin_on_recovery' ),
|
623 |
-
'wcal_capture_visitors_cart' => get_option( 'ac_lite_track_guest_cart_from_cart_page' )
|
624 |
-
);
|
625 |
-
}
|
626 |
-
|
627 |
-
private static function wcal_ts_get_wc_plugin_version() {
|
628 |
-
return WC()->version;
|
629 |
-
}
|
630 |
-
|
631 |
-
private static function wcal_ts_get_plugin_license_key() {
|
632 |
-
return 'Abandoned Cart Lite';
|
633 |
-
}
|
634 |
-
|
635 |
-
private static function wcal_ts_get_plugin_version() {
|
636 |
-
$wcal_plugin_version = self::wcal_plugin_get_version();
|
637 |
-
return $wcal_plugin_version;
|
638 |
-
}
|
639 |
-
|
640 |
-
/**
|
641 |
-
* @return string Plugin version
|
642 |
-
*/
|
643 |
-
|
644 |
-
public static function wcal_plugin_get_version() {
|
645 |
-
|
646 |
-
|
647 |
-
$plugin_path = dirname ( dirname ( dirname ( __FILE__ ) ) ) ;
|
648 |
-
$plugin_path_with_base_file_name = $plugin_path . "/woocommerce-ac.php";
|
649 |
-
$plugin_data = get_plugin_data( $plugin_path_with_base_file_name );
|
650 |
-
$plugin_version = $plugin_data['Version'];
|
651 |
-
|
652 |
-
return $plugin_version;
|
653 |
-
}
|
654 |
-
|
655 |
-
}
|
656 |
Class_Wcal_Ts_Tracker::init();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Abandoned cart data tracker
|
4 |
+
*
|
5 |
+
* The Abandoned Cart lite tracker class adds functionality to track Abandoned Cart lite Date usage based on if the customer opted in.
|
6 |
+
* No personal information is tracked, only general Abandoned Cart lite settings, abandoned orders and recovered orders, abandoned orders amount, recovred orders amount, total templates, total email sent, logged-in users abandoned & recovered amount, guest users abandoned and admin email for discount code.
|
7 |
+
*
|
8 |
+
* @class Class_Wcal_Ts_Tracker
|
9 |
+
* @version 6.8
|
10 |
+
*/
|
11 |
+
|
12 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
13 |
+
exit;
|
14 |
+
}
|
15 |
+
|
16 |
+
class Class_Wcal_Ts_Tracker {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* URL to the Tracker API endpoint.
|
20 |
+
* @var string
|
21 |
+
*/
|
22 |
+
private static $wcal_api_url = 'http://tracking.tychesoftwares.com/v1/';
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Hook into cron event.
|
26 |
+
*/
|
27 |
+
public static function init() {
|
28 |
+
add_action( 'wcal_ts_tracker_send_event', array( __CLASS__, 'wcal_ts_send_tracking_data' ) );
|
29 |
+
add_filter( 'ts_tracker_data', array( __CLASS__, 'wcal_ts_add_plugin_tracking_data' ), 10, 1);
|
30 |
+
add_filter( 'ts_tracker_opt_out_data', array( __CLASS__, 'wcal_get_data_for_opt_out' ), 10, 1);
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Decide whether to send tracking data or not.
|
35 |
+
*
|
36 |
+
* @param boolean $override
|
37 |
+
*/
|
38 |
+
public static function wcal_ts_send_tracking_data( $override = false ) {
|
39 |
+
|
40 |
+
if ( ! apply_filters( 'wcal_ts_tracker_send_override', $override ) ) {
|
41 |
+
// Send a maximum of once per week by default.
|
42 |
+
$wcal_last_send = self::wcal_ts_get_last_send_time();
|
43 |
+
if ( $wcal_last_send && $wcal_last_send > apply_filters( 'wcal_ts_tracker_last_send_interval', strtotime( '-1 week' ) ) ) {
|
44 |
+
return;
|
45 |
+
}
|
46 |
+
} else {
|
47 |
+
// Make sure there is at least a 1 hour delay between override sends, we don't want duplicate calls due to double clicking links.
|
48 |
+
$wcal_last_send = self::wcal_ts_get_last_send_time();
|
49 |
+
if ( $wcal_last_send && $wcal_last_send > strtotime( '-1 hours' ) ) {
|
50 |
+
return;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
$allow_tracking = get_option('wcal_allow_tracking');
|
55 |
+
if ( 'yes' == $allow_tracking ){
|
56 |
+
$override = true;
|
57 |
+
}
|
58 |
+
|
59 |
+
// Update time first before sending to ensure it is set
|
60 |
+
update_option( 'wcal_ts_tracker_last_send', time() );
|
61 |
+
|
62 |
+
if( $override == false ) {
|
63 |
+
$params = array();
|
64 |
+
$params[ 'tracking_usage' ] = 'no';
|
65 |
+
$params[ 'url' ] = home_url();
|
66 |
+
$params[ 'email' ] = apply_filters( 'wcal_ts_tracker_admin_email', get_option( 'admin_email' ) );
|
67 |
+
|
68 |
+
$params = apply_filters( 'ts_tracker_opt_out_data', $params );
|
69 |
+
} else {
|
70 |
+
|
71 |
+
$params = self::wcal_ts_get_tracking_data();
|
72 |
+
}
|
73 |
+
|
74 |
+
wp_safe_remote_post( self::$wcal_api_url, array(
|
75 |
+
'method' => 'POST',
|
76 |
+
'timeout' => 45,
|
77 |
+
'redirection' => 5,
|
78 |
+
'httpversion' => '1.0',
|
79 |
+
'blocking' => false,
|
80 |
+
'headers' => array( 'user-agent' => 'TSTracker/' . md5( esc_url( home_url( '/' ) ) ) . ';' ),
|
81 |
+
'body' => json_encode( $params ),
|
82 |
+
'cookies' => array(),
|
83 |
+
)
|
84 |
+
);
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Get the last time tracking data was sent.
|
89 |
+
* @return int|bool
|
90 |
+
*/
|
91 |
+
private static function wcal_ts_get_last_send_time() {
|
92 |
+
return apply_filters( 'wcal_ts_tracker_last_send_time', get_option( 'wcal_ts_tracker_last_send', false ) );
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* Get all the tracking data.
|
97 |
+
* @return array
|
98 |
+
*/
|
99 |
+
private static function wcal_ts_get_tracking_data() {
|
100 |
+
$data = array();
|
101 |
+
|
102 |
+
// General site info
|
103 |
+
$data[ 'url' ] = home_url();
|
104 |
+
$data[ 'email' ] = apply_filters( 'wcal_ts_tracker_admin_email', get_option( 'admin_email' ) );
|
105 |
+
|
106 |
+
// WordPress Info
|
107 |
+
$data[ 'wp' ] = self::wcal_ts_get_wordpress_info();
|
108 |
+
|
109 |
+
$data[ 'theme_info' ] = self::wcal_ts_get_theme_info();
|
110 |
+
|
111 |
+
// Server Info
|
112 |
+
$data[ 'server' ] = self::wcal_ts_get_server_info();
|
113 |
+
|
114 |
+
// Plugin info
|
115 |
+
$all_plugins = self::wcal_ts_get_all_plugins();
|
116 |
+
$data[ 'active_plugins' ] = $all_plugins[ 'active_plugins' ];
|
117 |
+
$data[ 'inactive_plugins' ] = $all_plugins[ 'inactive_plugins' ];
|
118 |
+
|
119 |
+
//WooCommerce version
|
120 |
+
$data[ 'wc_plugin_version' ] = self::wcal_ts_get_wc_plugin_version();
|
121 |
+
return apply_filters( 'ts_tracker_data', $data );
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Get plugin related data.
|
126 |
+
* @return array
|
127 |
+
*/
|
128 |
+
public static function wcal_ts_add_plugin_tracking_data ( $data ){
|
129 |
+
|
130 |
+
|
131 |
+
if ( isset( $_GET[ 'wcal_tracker_optin' ] ) && isset( $_GET[ 'wcal_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ 'wcal_tracker_nonce' ], 'wcal_tracker_optin' ) ) {
|
132 |
+
|
133 |
+
$plugin_data[ 'ts_meta_data_table_name'] = 'ts_wcal_tracking_meta_data';
|
134 |
+
|
135 |
+
$plugin_data[ 'ts_plugin_name' ] = 'Abandoned Cart Lite for WooCommerce';
|
136 |
+
|
137 |
+
// Store abandoned count info
|
138 |
+
$plugin_data[ 'abandoned_orders' ] = self::wcal_ts_get_abandoned_order_counts();
|
139 |
+
|
140 |
+
// Store recovred count info
|
141 |
+
$plugin_data[ 'recovered_orders' ] = self::wcal_ts_get_recovered_order_counts();
|
142 |
+
|
143 |
+
// store abandoned orders amount
|
144 |
+
$plugin_data[ 'abandoned_orders_amount' ] = self::wcal_ts_get_abandoned_order_total_amount();
|
145 |
+
|
146 |
+
// Store recovered count info
|
147 |
+
$plugin_data[ 'recovered_orders_amount' ] = self::wcal_ts_get_recovered_order_total_amount();
|
148 |
+
|
149 |
+
// Store abandoned cart emails sent count info
|
150 |
+
$plugin_data[ 'sent_emails' ] = self::wcal_ts_get_sent_emails_total_count();
|
151 |
+
|
152 |
+
// Store email template count info
|
153 |
+
$plugin_data[ 'email_templates_data' ] = self::wcal_ts_get_email_templates_data();
|
154 |
+
|
155 |
+
// Store only logged-in users abandoned cart count info
|
156 |
+
$plugin_data[ 'logged_in_abandoned_orders' ] = self::wcal_ts_get_logged_in_users_abandoned_cart_total_count();
|
157 |
+
|
158 |
+
// Store only logged-in users abandoned cart count info
|
159 |
+
$plugin_data[ 'guest_abandoned_orders' ] = self::wcal_ts_get_guest_users_abandoned_cart_total_count();
|
160 |
+
|
161 |
+
// Store only logged-in users abandoned cart amount info
|
162 |
+
$plugin_data[ 'logged_in_abandoned_orders_amount' ] = self::wcal_ts_get_logged_in_users_abandoned_cart_total_amount();
|
163 |
+
|
164 |
+
// store only guest users abandoned cart amount
|
165 |
+
$plugin_data[ 'guest_abandoned_orders_amount' ] = self::wcal_ts_get_guest_users_abandoned_cart_total_amount();
|
166 |
+
|
167 |
+
// Store only logged-in users recovered cart amount info
|
168 |
+
$plugin_data[ 'logged_in_recovered_orders_amount' ] = self::wcal_ts_get_logged_in_users_recovered_cart_total_amount();
|
169 |
+
|
170 |
+
// Store only guest users recovered cart amount
|
171 |
+
$plugin_data[ 'guest_recovered_orders_amount' ] = self::wcal_ts_get_guest_users_recovered_cart_total_amount();
|
172 |
+
|
173 |
+
// Get all plugin options info
|
174 |
+
$plugin_data[ 'settings' ] = self::wcal_ts_get_all_plugin_options_values();
|
175 |
+
$plugin_data[ 'plugin_version' ] = self::wcal_ts_get_plugin_version();
|
176 |
+
$plugin_data[ 'wcal_allow_tracking' ] = get_option ('wcal_allow_tracking');
|
177 |
+
|
178 |
+
$data [ 'plugin_data' ] = $plugin_data;
|
179 |
+
}
|
180 |
+
return $data;
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Get data when user dont want to share information.
|
185 |
+
* @return array
|
186 |
+
*/
|
187 |
+
public static function wcal_get_data_for_opt_out( $params ){
|
188 |
+
|
189 |
+
$plugin_data[ 'ts_meta_data_table_name'] = 'ts_wcal_tracking_meta_data';
|
190 |
+
$plugin_data[ 'ts_plugin_name' ] = 'Abandoned Cart Lite for WooCommerce';
|
191 |
+
$plugin_data[ 'abandoned_orders_amount' ] = self::wcal_ts_get_abandoned_order_total_amount();
|
192 |
+
// Store recovered count info
|
193 |
+
$plugin_data[ 'recovered_orders_amount' ] = self::wcal_ts_get_recovered_order_total_amount();
|
194 |
+
|
195 |
+
$params[ 'plugin_data' ] = $plugin_data;
|
196 |
+
|
197 |
+
return $params;
|
198 |
+
}
|
199 |
+
|
200 |
+
|
201 |
+
/**
|
202 |
+
* Get WordPress related data.
|
203 |
+
* @return array
|
204 |
+
*/
|
205 |
+
private static function wcal_ts_get_wordpress_info() {
|
206 |
+
$wp_data = array();
|
207 |
+
|
208 |
+
$memory = wc_let_to_num( WP_MEMORY_LIMIT );
|
209 |
+
|
210 |
+
if ( function_exists( 'memory_get_usage' ) ) {
|
211 |
+
$system_memory = wc_let_to_num( @ini_get( 'memory_limit' ) );
|
212 |
+
$memory = max( $memory, $system_memory );
|
213 |
+
}
|
214 |
+
|
215 |
+
$wp_data[ 'memory_limit' ] = size_format( $memory );
|
216 |
+
$wp_data[ 'debug_mode' ] = ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? 'Yes' : 'No';
|
217 |
+
$wp_data[ 'locale' ] = get_locale();
|
218 |
+
$wp_data[ 'wp_version' ] = get_bloginfo( 'version' );
|
219 |
+
$wp_data[ 'multisite' ] = is_multisite() ? 'Yes' : 'No';
|
220 |
+
|
221 |
+
return $wp_data;
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Get the current theme info, theme name and version.
|
226 |
+
* @return array
|
227 |
+
*/
|
228 |
+
public static function wcal_ts_get_theme_info() {
|
229 |
+
$theme_data = wp_get_theme();
|
230 |
+
$theme_child_theme = is_child_theme() ? 'Yes' : 'No';
|
231 |
+
|
232 |
+
return array( 'theme_name' => $theme_data->Name,
|
233 |
+
'theme_version' => $theme_data->Version,
|
234 |
+
'child_theme' => $theme_child_theme );
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Get server related info.
|
239 |
+
* @return array
|
240 |
+
*/
|
241 |
+
private static function wcal_ts_get_server_info() {
|
242 |
+
$server_data = array();
|
243 |
+
|
244 |
+
if ( isset( $_SERVER[ 'SERVER_SOFTWARE' ] ) && ! empty( $_SERVER[ 'SERVER_SOFTWARE' ] ) ) {
|
245 |
+
$server_data[ 'software' ] = $_SERVER[ 'SERVER_SOFTWARE' ];
|
246 |
+
}
|
247 |
+
|
248 |
+
if ( function_exists( 'phpversion' ) ) {
|
249 |
+
$server_data[ 'php_version' ] = phpversion();
|
250 |
+
}
|
251 |
+
|
252 |
+
if ( function_exists( 'ini_get' ) ) {
|
253 |
+
$server_data[ 'php_post_max_size' ] = size_format( wc_let_to_num( ini_get( 'post_max_size' ) ) );
|
254 |
+
$server_data[ 'php_time_limt' ] = ini_get( 'max_execution_time' );
|
255 |
+
$server_data[ 'php_max_input_vars' ] = ini_get( 'max_input_vars' );
|
256 |
+
$server_data[ 'php_suhosin' ] = extension_loaded( 'suhosin' ) ? 'Yes' : 'No';
|
257 |
+
}
|
258 |
+
|
259 |
+
global $wpdb;
|
260 |
+
$server_data[ 'mysql_version' ] = $wpdb->db_version();
|
261 |
+
|
262 |
+
$server_data[ 'php_max_upload_size' ] = size_format( wp_max_upload_size() );
|
263 |
+
$server_data[ 'php_default_timezone' ] = date_default_timezone_get();
|
264 |
+
$server_data[ 'php_soap' ] = class_exists( 'SoapClient' ) ? 'Yes' : 'No';
|
265 |
+
$server_data[ 'php_fsockopen' ] = function_exists( 'fsockopen' ) ? 'Yes' : 'No';
|
266 |
+
$server_data[ 'php_curl' ] = function_exists( 'curl_init' ) ? 'Yes' : 'No';
|
267 |
+
|
268 |
+
return $server_data;
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Get all plugins grouped into activated or not.
|
273 |
+
* @return array
|
274 |
+
*/
|
275 |
+
private static function wcal_ts_get_all_plugins() {
|
276 |
+
// Ensure get_plugins function is loaded
|
277 |
+
if ( ! function_exists( 'get_plugins' ) ) {
|
278 |
+
include ABSPATH . '/wp-admin/includes/plugin.php';
|
279 |
+
}
|
280 |
+
|
281 |
+
$plugins = get_plugins();
|
282 |
+
$active_plugins_keys = get_option( 'active_plugins', array() );
|
283 |
+
$active_plugins = array();
|
284 |
+
|
285 |
+
foreach ( $plugins as $k => $v ) {
|
286 |
+
// Take care of formatting the data how we want it.
|
287 |
+
$formatted = array();
|
288 |
+
$formatted[ 'name' ] = strip_tags( $v[ 'Name' ] );
|
289 |
+
if ( isset( $v[ 'Version' ] ) ) {
|
290 |
+
$formatted[ 'version' ] = strip_tags( $v[ 'Version' ] );
|
291 |
+
}
|
292 |
+
if ( isset( $v[ 'Author' ] ) ) {
|
293 |
+
$formatted[ 'author' ] = strip_tags( $v[ 'Author' ] );
|
294 |
+
}
|
295 |
+
if ( isset( $v[ 'Network' ] ) ) {
|
296 |
+
$formatted[ 'network' ] = strip_tags( $v[ 'Network' ] );
|
297 |
+
}
|
298 |
+
if ( isset( $v[ 'PluginURI' ] ) ) {
|
299 |
+
$formatted[ 'plugin_uri' ] = strip_tags( $v[ 'PluginURI' ] );
|
300 |
+
}
|
301 |
+
if ( in_array( $k, $active_plugins_keys ) ) {
|
302 |
+
// Remove active plugins from list so we can show active and inactive separately
|
303 |
+
unset( $plugins[ $k ] );
|
304 |
+
$active_plugins[ $k ] = $formatted;
|
305 |
+
} else {
|
306 |
+
$plugins[ $k ] = $formatted;
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
+
return array( 'active_plugins' => $active_plugins, 'inactive_plugins' => $plugins );
|
311 |
+
}
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Get abandoned orders counts.
|
315 |
+
* @return string
|
316 |
+
*/
|
317 |
+
private static function wcal_ts_get_abandoned_order_counts() {
|
318 |
+
global $wpdb;
|
319 |
+
$wcal_order_count = 0;
|
320 |
+
|
321 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
322 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
323 |
+
$current_time = current_time( 'timestamp' );
|
324 |
+
$compare_time = $current_time - $cut_off_time;
|
325 |
+
|
326 |
+
$blank_cart_info = '{"cart":[]}';
|
327 |
+
$blank_cart_info_guest = '[]';
|
328 |
+
|
329 |
+
$wcal_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest'";
|
330 |
+
|
331 |
+
$wcal_order_count = $wpdb->get_var( $wcal_query );
|
332 |
+
|
333 |
+
return $wcal_order_count;
|
334 |
+
}
|
335 |
+
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Get recovered orders counts.
|
339 |
+
* @return string
|
340 |
+
*/
|
341 |
+
private static function wcal_ts_get_recovered_order_counts(){
|
342 |
+
|
343 |
+
global $wpdb;
|
344 |
+
$wcal_recovered_order_count = 0;
|
345 |
+
|
346 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
347 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
348 |
+
$current_time = current_time( 'timestamp' );
|
349 |
+
$compare_time = $current_time - $cut_off_time;
|
350 |
+
|
351 |
+
$wcal_recovery_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time'";
|
352 |
+
|
353 |
+
$wcal_recovered_order_count = $wpdb->get_var( $wcal_recovery_query );
|
354 |
+
|
355 |
+
return $wcal_recovered_order_count;
|
356 |
+
}
|
357 |
+
|
358 |
+
/*
|
359 |
+
* Get Total abandoned orders amount
|
360 |
+
*
|
361 |
+
*/
|
362 |
+
private static function wcal_ts_get_abandoned_order_total_amount(){
|
363 |
+
global $wpdb;
|
364 |
+
$wcal_abandoned_orders_amount = 0;
|
365 |
+
|
366 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
367 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
368 |
+
$current_time = current_time( 'timestamp' );
|
369 |
+
$compare_time = $current_time - $cut_off_time;
|
370 |
+
|
371 |
+
$blank_cart_info = '{"cart":[]}';
|
372 |
+
$blank_cart_info_guest = '[]';
|
373 |
+
|
374 |
+
$wcal_abandoned_query = "SELECT abandoned_cart_info FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest'";
|
375 |
+
|
376 |
+
$wcal_abandoned_query_result = $wpdb->get_results( $wcal_abandoned_query );
|
377 |
+
|
378 |
+
$wcal_abandoned_orders_amount = self::wcal_get_abandoned_amount( $wcal_abandoned_query_result );
|
379 |
+
|
380 |
+
return $wcal_abandoned_orders_amount;
|
381 |
+
}
|
382 |
+
|
383 |
+
private static function wcal_get_abandoned_amount( $wcal_abandoned_query_result ){
|
384 |
+
|
385 |
+
$wcal_abandoned_orders_amount = 0;
|
386 |
+
foreach ( $wcal_abandoned_query_result as $wcal_abandoned_query_key => $wcal_abandoned_query_value ) {
|
387 |
+
# code...
|
388 |
+
$cart_info = json_decode( $wcal_abandoned_query_value->abandoned_cart_info );
|
389 |
+
|
390 |
+
$cart_details = array();
|
391 |
+
if( isset( $cart_info->cart ) ){
|
392 |
+
$cart_details = $cart_info->cart;
|
393 |
+
}
|
394 |
+
|
395 |
+
if( count( $cart_details ) > 0 ) {
|
396 |
+
foreach( $cart_details as $k => $v ) {
|
397 |
+
if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
|
398 |
+
$wcal_abandoned_orders_amount = $wcal_abandoned_orders_amount + $v->line_total + $v->line_subtotal_tax;
|
399 |
+
} else {
|
400 |
+
$wcal_abandoned_orders_amount = $wcal_abandoned_orders_amount + $v->line_total;
|
401 |
+
}
|
402 |
+
}
|
403 |
+
}
|
404 |
+
}
|
405 |
+
return $wcal_abandoned_orders_amount;
|
406 |
+
}
|
407 |
+
|
408 |
+
/*
|
409 |
+
* Get recovered orders total amount
|
410 |
+
*/
|
411 |
+
private static function wcal_ts_get_recovered_order_total_amount(){
|
412 |
+
|
413 |
+
global $wpdb;
|
414 |
+
$wcal_recovered_orders_amount = 0;
|
415 |
+
|
416 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
417 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
418 |
+
$current_time = current_time( 'timestamp' );
|
419 |
+
$compare_time = $current_time - $cut_off_time;
|
420 |
+
|
421 |
+
$wcal_recovery_query_amount = "SELECT recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time'";
|
422 |
+
|
423 |
+
$wcal_recovered_order_amount_result = $wpdb->get_results( $wcal_recovery_query_amount );
|
424 |
+
|
425 |
+
$wcal_recovered_orders_amount = self::wcal_get_recovered_amount ($wcal_recovered_order_amount_result );
|
426 |
+
|
427 |
+
return $wcal_recovered_orders_amount;
|
428 |
+
}
|
429 |
+
|
430 |
+
private static function wcal_get_recovered_amount ( $wcal_data ){
|
431 |
+
|
432 |
+
$wcal_recovered_orders_amount = 0;
|
433 |
+
|
434 |
+
foreach ($wcal_data as $wcal_data_key => $wcal_data_value) {
|
435 |
+
|
436 |
+
$wcal_order_total = get_post_meta( $wcal_data_value->recovered_cart , '_order_total', true);
|
437 |
+
$wcal_recovered_orders_amount = $wcal_recovered_orders_amount + $wcal_order_total;
|
438 |
+
}
|
439 |
+
return $wcal_recovered_orders_amount;
|
440 |
+
}
|
441 |
+
|
442 |
+
/*
|
443 |
+
* Get sent email total count
|
444 |
+
*/
|
445 |
+
private static function wcal_ts_get_sent_emails_total_count(){
|
446 |
+
|
447 |
+
global $wpdb;
|
448 |
+
$wcal_sent_emails_count = 0;
|
449 |
+
$wcal_sent_emails_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_sent_history_lite`";
|
450 |
+
$wcal_sent_emails_count = $wpdb->get_var( $wcal_sent_emails_query );
|
451 |
+
return $wcal_sent_emails_count;
|
452 |
+
}
|
453 |
+
|
454 |
+
/*
|
455 |
+
* Get email templates total count
|
456 |
+
*/
|
457 |
+
private static function wcal_ts_get_email_templates_data(){
|
458 |
+
|
459 |
+
global $wpdb;
|
460 |
+
$wcal_email_templates_count = 0;
|
461 |
+
$wcal_email_templates_query = "SELECT id, is_active, is_wc_template,frequency, day_or_hour FROM `" . $wpdb->prefix . "ac_email_templates_lite`";
|
462 |
+
$wcal_email_templates_results = $wpdb->get_results( $wcal_email_templates_query );
|
463 |
+
|
464 |
+
$wcal_email_templates_count = count( $wcal_email_templates_results );
|
465 |
+
|
466 |
+
$wcal_templates_data = array();
|
467 |
+
$wcal_templates_data ['total_templates'] = $wcal_email_templates_count;
|
468 |
+
|
469 |
+
foreach ($wcal_email_templates_results as $wcal_email_templates_results_key => $wcal_email_templates_results_value ) {
|
470 |
+
|
471 |
+
$wcal_template_time = $wcal_email_templates_results_value->frequency . ' ' .$wcal_email_templates_results_value->day_or_hour ;
|
472 |
+
|
473 |
+
$wcal_get_total_email_sent_for_template = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE template_id = ". $wcal_email_templates_results_value->id;
|
474 |
+
$wcal_get_total_email_sent_for_template_count = $wpdb->get_var( $wcal_get_total_email_sent_for_template );
|
475 |
+
|
476 |
+
$wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['is_activate'] = ( $wcal_email_templates_results_value->is_active == 1 ) ? 'Active' : 'Deactive';
|
477 |
+
$wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['is_wc_template'] = ( $wcal_email_templates_results_value->is_wc_template == 1 ) ? 'Yes' : 'No';
|
478 |
+
$wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['template_time'] = $wcal_template_time;
|
479 |
+
$wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['total_email_sent'] = $wcal_get_total_email_sent_for_template_count;
|
480 |
+
}
|
481 |
+
|
482 |
+
return $wcal_templates_data;
|
483 |
+
}
|
484 |
+
|
485 |
+
/*
|
486 |
+
* Get logged-in users total abandoned count
|
487 |
+
*/
|
488 |
+
private static function wcal_ts_get_logged_in_users_abandoned_cart_total_count (){
|
489 |
+
|
490 |
+
global $wpdb;
|
491 |
+
$wcal_logged_in_user_query_count = 0;
|
492 |
+
|
493 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
494 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
495 |
+
$current_time = current_time( 'timestamp' );
|
496 |
+
$compare_time = $current_time - $cut_off_time;
|
497 |
+
|
498 |
+
$blank_cart_info = '{"cart":[]}';
|
499 |
+
$blank_cart_info_guest = '[]';
|
500 |
+
|
501 |
+
$wcal_logged_in_user_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id < 63000000 AND user_id != 0";
|
502 |
+
|
503 |
+
$wcal_logged_in_user_query_count = $wpdb->get_var( $wcal_logged_in_user_query );
|
504 |
+
|
505 |
+
return $wcal_logged_in_user_query_count;
|
506 |
+
}
|
507 |
+
|
508 |
+
/*
|
509 |
+
* Get logged-in users total abandoned count
|
510 |
+
*/
|
511 |
+
private static function wcal_ts_get_guest_users_abandoned_cart_total_count(){
|
512 |
+
global $wpdb;
|
513 |
+
$wcal_guest_user_query_count = 0;
|
514 |
+
|
515 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
516 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
517 |
+
$current_time = current_time( 'timestamp' );
|
518 |
+
$compare_time = $current_time - $cut_off_time;
|
519 |
+
|
520 |
+
$blank_cart_info = '{"cart":[]}';
|
521 |
+
$blank_cart_info_guest = '[]';
|
522 |
+
|
523 |
+
$wcal_guest_user_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id >= 63000000 AND user_id != 0";
|
524 |
+
|
525 |
+
$wcal_guest_user_query_count = $wpdb->get_var( $wcal_guest_user_query );
|
526 |
+
|
527 |
+
return $wcal_guest_user_query_count;
|
528 |
+
}
|
529 |
+
|
530 |
+
private static function wcal_ts_get_logged_in_users_abandoned_cart_total_amount (){
|
531 |
+
|
532 |
+
global $wpdb;
|
533 |
+
$wcal_abandoned_orders_amount = 0;
|
534 |
+
|
535 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
536 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
537 |
+
$current_time = current_time( 'timestamp' );
|
538 |
+
$compare_time = $current_time - $cut_off_time;
|
539 |
+
|
540 |
+
$blank_cart_info = '{"cart":[]}';
|
541 |
+
$blank_cart_info_guest = '[]';
|
542 |
+
|
543 |
+
$wcal_abandoned_query = "SELECT abandoned_cart_info FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id < 63000000 AND user_id != 0 ";
|
544 |
+
|
545 |
+
$wcal_abandoned_query_result = $wpdb->get_results( $wcal_abandoned_query );
|
546 |
+
|
547 |
+
$wcal_abandoned_orders_amount = self::wcal_get_abandoned_amount( $wcal_abandoned_query_result );
|
548 |
+
|
549 |
+
return $wcal_abandoned_orders_amount;
|
550 |
+
}
|
551 |
+
|
552 |
+
private static function wcal_ts_get_guest_users_abandoned_cart_total_amount (){
|
553 |
+
|
554 |
+
global $wpdb;
|
555 |
+
$wcal_abandoned_orders_amount = 0;
|
556 |
+
|
557 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
558 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
559 |
+
$current_time = current_time( 'timestamp' );
|
560 |
+
$compare_time = $current_time - $cut_off_time;
|
561 |
+
|
562 |
+
$blank_cart_info = '{"cart":[]}';
|
563 |
+
$blank_cart_info_guest = '[]';
|
564 |
+
|
565 |
+
$wcal_abandoned_query = "SELECT abandoned_cart_info FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id >= 63000000 AND user_id != 0 ";
|
566 |
+
|
567 |
+
$wcal_abandoned_query_result = $wpdb->get_results( $wcal_abandoned_query );
|
568 |
+
|
569 |
+
$wcal_abandoned_orders_amount = self::wcal_get_abandoned_amount( $wcal_abandoned_query_result );
|
570 |
+
|
571 |
+
return $wcal_abandoned_orders_amount;
|
572 |
+
}
|
573 |
+
|
574 |
+
private static function wcal_ts_get_logged_in_users_recovered_cart_total_amount(){
|
575 |
+
|
576 |
+
global $wpdb;
|
577 |
+
$wcal_recovered_orders_amount = 0;
|
578 |
+
|
579 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
580 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
581 |
+
$current_time = current_time( 'timestamp' );
|
582 |
+
$compare_time = $current_time - $cut_off_time;
|
583 |
+
|
584 |
+
$wcal_recovery_query_amount = "SELECT recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time' AND user_id < 63000000 AND user_id != 0 ";
|
585 |
+
|
586 |
+
$wcal_recovered_order_amount_result = $wpdb->get_results( $wcal_recovery_query_amount );
|
587 |
+
|
588 |
+
$wcal_recovered_orders_amount = self::wcal_get_recovered_amount ($wcal_recovered_order_amount_result );
|
589 |
+
|
590 |
+
return $wcal_recovered_orders_amount;
|
591 |
+
|
592 |
+
}
|
593 |
+
|
594 |
+
|
595 |
+
private static function wcal_ts_get_guest_users_recovered_cart_total_amount (){
|
596 |
+
|
597 |
+
global $wpdb;
|
598 |
+
$wcal_recovered_orders_amount = 0;
|
599 |
+
|
600 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
601 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
602 |
+
$current_time = current_time( 'timestamp' );
|
603 |
+
$compare_time = $current_time - $cut_off_time;
|
604 |
+
|
605 |
+
$wcal_recovery_query_amount = "SELECT recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time' AND user_id >= 63000000 AND user_id != 0 ";
|
606 |
+
|
607 |
+
$wcal_recovered_order_amount_result = $wpdb->get_results( $wcal_recovery_query_amount );
|
608 |
+
|
609 |
+
$wcal_recovered_orders_amount = self::wcal_get_recovered_amount ($wcal_recovered_order_amount_result );
|
610 |
+
|
611 |
+
return $wcal_recovered_orders_amount;
|
612 |
+
|
613 |
+
}
|
614 |
+
/**
|
615 |
+
* Get all options starting with woocommerce_ prefix.
|
616 |
+
* @return array
|
617 |
+
*/
|
618 |
+
private static function wcal_ts_get_all_plugin_options_values() {
|
619 |
+
|
620 |
+
return array(
|
621 |
+
'wcal_cart_cut_off_time' => get_option( 'ac_lite_cart_abandoned_time' ),
|
622 |
+
'wcal_admin_recovery_email' => get_option( 'ac_lite_email_admin_on_recovery' ),
|
623 |
+
'wcal_capture_visitors_cart' => get_option( 'ac_lite_track_guest_cart_from_cart_page' )
|
624 |
+
);
|
625 |
+
}
|
626 |
+
|
627 |
+
private static function wcal_ts_get_wc_plugin_version() {
|
628 |
+
return WC()->version;
|
629 |
+
}
|
630 |
+
|
631 |
+
private static function wcal_ts_get_plugin_license_key() {
|
632 |
+
return 'Abandoned Cart Lite';
|
633 |
+
}
|
634 |
+
|
635 |
+
private static function wcal_ts_get_plugin_version() {
|
636 |
+
$wcal_plugin_version = self::wcal_plugin_get_version();
|
637 |
+
return $wcal_plugin_version;
|
638 |
+
}
|
639 |
+
|
640 |
+
/**
|
641 |
+
* @return string Plugin version
|
642 |
+
*/
|
643 |
+
|
644 |
+
public static function wcal_plugin_get_version() {
|
645 |
+
|
646 |
+
|
647 |
+
$plugin_path = dirname ( dirname ( dirname ( __FILE__ ) ) ) ;
|
648 |
+
$plugin_path_with_base_file_name = $plugin_path . "/woocommerce-ac.php";
|
649 |
+
$plugin_data = get_plugin_data( $plugin_path_with_base_file_name );
|
650 |
+
$plugin_version = $plugin_data['Version'];
|
651 |
+
|
652 |
+
return $plugin_version;
|
653 |
+
}
|
654 |
+
|
655 |
+
}
|
656 |
Class_Wcal_Ts_Tracker::init();
|
woocommerce-abandoned-cart/includes/wcal-common.php
CHANGED
@@ -1,65 +1,66 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class wcal_common {
|
4 |
-
public static function wcal_get_abandoned_order_count( $get_section_result ){
|
5 |
-
global $wpdb;
|
6 |
-
$return_abandoned_count = 0;
|
7 |
-
$blank_cart_info = '{"cart":[]}';
|
8 |
-
$blank_cart_info_guest = '[]';
|
9 |
-
$
|
10 |
-
$
|
11 |
-
$
|
12 |
-
$
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
$
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
$
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
$
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
$
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
$
|
49 |
-
$wcap_plugin_dir
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
}
|
|
|
65 |
?>
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class wcal_common {
|
4 |
+
public static function wcal_get_abandoned_order_count( $get_section_result ){
|
5 |
+
global $wpdb;
|
6 |
+
$return_abandoned_count = 0;
|
7 |
+
$blank_cart_info = '{"cart":[]}';
|
8 |
+
$blank_cart_info_guest = '[]';
|
9 |
+
$blank_cart = '""';
|
10 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
11 |
+
$cut_off_time = intval( $ac_cutoff_time ) * 60;
|
12 |
+
$current_time = current_time( 'timestamp' );
|
13 |
+
$compare_time = $current_time - $cut_off_time;
|
14 |
+
|
15 |
+
switch ( $get_section_result ) {
|
16 |
+
case 'wcal_all_abandoned':
|
17 |
+
$query_ac = "SELECT COUNT(`id`) as cnt FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE ( user_type = 'REGISTERED' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '%$blank_cart%' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 ) OR ( user_type = 'GUEST' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '%$blank_cart%' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 ) ORDER BY recovered_cart desc ";
|
18 |
+
$return_abandoned_count = $wpdb->get_var( $query_ac );
|
19 |
+
break;
|
20 |
+
|
21 |
+
case 'wcal_all_registered':
|
22 |
+
$query_ac = "SELECT COUNT(`id`) FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE ( user_type = 'REGISTERED' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '%$blank_cart%' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 ) ORDER BY recovered_cart desc ";
|
23 |
+
$return_abandoned_count = $wpdb->get_var( $query_ac );
|
24 |
+
break;
|
25 |
+
|
26 |
+
case 'wcal_all_guest':
|
27 |
+
$query_ac = "SELECT COUNT(`id`) FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE ( user_type = 'GUEST' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '%$blank_cart%' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 AND user_id >= 63000000 ) ORDER BY recovered_cart desc ";
|
28 |
+
$return_abandoned_count = $wpdb->get_var( $query_ac );
|
29 |
+
break;
|
30 |
+
|
31 |
+
case 'wcal_all_visitor':
|
32 |
+
$query_ac = "SELECT COUNT(`id`) FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE ( user_type = 'GUEST' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '%$blank_cart%' AND abandoned_cart_time <= '$compare_time' AND recovered_cart = 0 AND user_id = 0 ) ORDER BY recovered_cart desc ";
|
33 |
+
$return_abandoned_count = $wpdb->get_var( $query_ac );
|
34 |
+
break;
|
35 |
+
|
36 |
+
default:
|
37 |
+
# code...
|
38 |
+
break;
|
39 |
+
}
|
40 |
+
return $return_abandoned_count;
|
41 |
+
}
|
42 |
+
|
43 |
+
|
44 |
+
/**
|
45 |
+
* This function returns the Abandoned Cart Lite plugin version number.
|
46 |
+
*/
|
47 |
+
public static function wcal_get_version() {
|
48 |
+
$plugin_version = '';
|
49 |
+
$wcap_plugin_dir = dirname ( dirname (__FILE__) );
|
50 |
+
$wcap_plugin_dir .= '/woocommerce-ac.php';
|
51 |
+
|
52 |
+
$plugin_data = get_file_data( $wcap_plugin_dir, array( 'Version' => 'Version' ) );
|
53 |
+
if ( ! empty( $plugin_data['Version'] ) ) {
|
54 |
+
$plugin_version = $plugin_data[ 'Version' ];
|
55 |
+
}
|
56 |
+
return $plugin_version;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* This function returns the plugin url
|
61 |
+
*/
|
62 |
+
public static function wcal_get_plugin_url() {
|
63 |
+
return plugins_url() . '/woocommerce-abandoned-cart/';
|
64 |
+
}
|
65 |
+
}
|
66 |
?>
|
woocommerce-abandoned-cart/includes/wcal_actions.php
CHANGED
@@ -1,45 +1,45 @@
|
|
1 |
-
<?php
|
2 |
-
// Exit if accessed directly
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
/**
|
8 |
-
* Trigger a abandoned cart Deletion
|
9 |
-
*
|
10 |
-
* @since 2.5.2
|
11 |
-
* @param $abandoned_cart_id Arguments passed
|
12 |
-
* @return void
|
13 |
-
*/
|
14 |
-
|
15 |
-
class wcal_delete_bulk_action_handler {
|
16 |
-
|
17 |
-
function wcal_delete_bulk_action_handler_function( $abandoned_cart_id ) {
|
18 |
-
global $wpdb;
|
19 |
-
$get_user_id = "SELECT user_id FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
20 |
-
WHERE id = '$abandoned_cart_id' ";
|
21 |
-
$results_get_user_id = $wpdb->get_results( $get_user_id );
|
22 |
-
$user_id_of_guest = $results_get_user_id[0]->user_id;
|
23 |
-
|
24 |
-
$query_delete = "DELETE FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
25 |
-
WHERE id = '$abandoned_cart_id' ";
|
26 |
-
$results_delete = $wpdb->get_results( $query_delete );
|
27 |
-
|
28 |
-
if ( $user_id_of_guest >= '63000000' ) {
|
29 |
-
$guest_query_delete = "DELETE FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
30 |
-
WHERE id = '" . $user_id_of_guest . "'";
|
31 |
-
$results_guest = $wpdb->get_results( $guest_query_delete );
|
32 |
-
//guest user
|
33 |
-
}
|
34 |
-
wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&wcal_deleted=YES' ) );
|
35 |
-
}
|
36 |
-
function wcal_delete_template_bulk_action_handler_function( $template_id ) {
|
37 |
-
global $wpdb;
|
38 |
-
$id_remove = $template_id;
|
39 |
-
$query_remove = "DELETE FROM `" . $wpdb->prefix . "ac_email_templates_lite`
|
40 |
-
WHERE id='" . $id_remove . "' ";
|
41 |
-
$wpdb->query( $query_remove );
|
42 |
-
|
43 |
-
wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&action=emailtemplates&wcal_template_deleted=YES' ) );
|
44 |
-
}
|
45 |
}
|
1 |
+
<?php
|
2 |
+
// Exit if accessed directly
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Trigger a abandoned cart Deletion
|
9 |
+
*
|
10 |
+
* @since 2.5.2
|
11 |
+
* @param $abandoned_cart_id Arguments passed
|
12 |
+
* @return void
|
13 |
+
*/
|
14 |
+
|
15 |
+
class wcal_delete_bulk_action_handler {
|
16 |
+
|
17 |
+
function wcal_delete_bulk_action_handler_function( $abandoned_cart_id ) {
|
18 |
+
global $wpdb;
|
19 |
+
$get_user_id = "SELECT user_id FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
20 |
+
WHERE id = '$abandoned_cart_id' ";
|
21 |
+
$results_get_user_id = $wpdb->get_results( $get_user_id );
|
22 |
+
$user_id_of_guest = $results_get_user_id[0]->user_id;
|
23 |
+
|
24 |
+
$query_delete = "DELETE FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
25 |
+
WHERE id = '$abandoned_cart_id' ";
|
26 |
+
$results_delete = $wpdb->get_results( $query_delete );
|
27 |
+
|
28 |
+
if ( $user_id_of_guest >= '63000000' ) {
|
29 |
+
$guest_query_delete = "DELETE FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
30 |
+
WHERE id = '" . $user_id_of_guest . "'";
|
31 |
+
$results_guest = $wpdb->get_results( $guest_query_delete );
|
32 |
+
//guest user
|
33 |
+
}
|
34 |
+
wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&wcal_deleted=YES' ) );
|
35 |
+
}
|
36 |
+
function wcal_delete_template_bulk_action_handler_function( $template_id ) {
|
37 |
+
global $wpdb;
|
38 |
+
$id_remove = $template_id;
|
39 |
+
$query_remove = "DELETE FROM `" . $wpdb->prefix . "ac_email_templates_lite`
|
40 |
+
WHERE id='" . $id_remove . "' ";
|
41 |
+
$wpdb->query( $query_remove );
|
42 |
+
|
43 |
+
wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&action=emailtemplates&wcal_template_deleted=YES' ) );
|
44 |
+
}
|
45 |
}
|
woocommerce-abandoned-cart/includes/wcal_admin_notice.php
CHANGED
@@ -1,162 +1,162 @@
|
|
1 |
-
<?php
|
2 |
-
// Exit if accessed directly
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
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 );
|
13 |
-
$wcal_current_time = current_time( 'timestamp' );
|
14 |
-
|
15 |
-
if( !is_plugin_active( 'woocommerce-abandon-cart-pro/woocommerce-ac.php' ) &&
|
16 |
-
( false === $wcal_activate_time || ( $wcal_activate_time > 0 && $wcal_current_time >= $wcal_sixty_days ) ) ) {
|
17 |
-
global $current_user ;
|
18 |
-
$user_id = $current_user->ID;
|
19 |
-
$wcal_current_time = current_time( 'timestamp' );
|
20 |
-
|
21 |
-
if ( ! get_user_meta( get_current_user_id(), 'wcal_pro_first_notice_ignore' ) ) {
|
22 |
-
|
23 |
-
$class = 'updated notice-info point-notice';
|
24 |
-
$style = 'position:relative';
|
25 |
-
|
26 |
-
$wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/checkout?edd_action=add_to_cart&download_id=20&utm_source=wpnotice&utm_medium=first&utm_campaign=AbandonedCartLitePlugin';
|
27 |
-
|
28 |
-
$message = wp_kses_post ( __( 'Thank you for using Abandoned Cart Lite for WooCommerce! You can use the Pro version for recovering more sales with some additional features. <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'">Get it now!</a></strong>', 'woocommerce-ac' ) );
|
29 |
-
|
30 |
-
$add_query_arguments = add_query_arg( 'wcal_pro_first_notice_ignore', '0' );
|
31 |
-
$cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
|
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]);
|
39 |
-
|
40 |
-
if ( $wcal_current_time >= $wcal_fifteen_days ){
|
41 |
-
$class = 'updated notice-info point-notice';
|
42 |
-
$style = 'position:relative';
|
43 |
-
|
44 |
-
$wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/checkout?edd_action=add_to_cart&download_id=20&utm_source=wpnotice&utm_medium=second&utm_campaign=AbandonedCartLitePlugin';
|
45 |
-
|
46 |
-
$message = wp_kses_post ( __( 'Abandoned Cart Pro plugin allows you to recover more revenue by offering discount coupons in the abandoned cart email notifications. <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'">Grab it now!</a></strong>', 'woocommerce-ac' ) );
|
47 |
-
|
48 |
-
$add_query_arguments = add_query_arg( 'wcal_pro_second_notice_ignore', '0' );
|
49 |
-
$cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
|
50 |
-
printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, $message, $cancel_button );
|
51 |
-
}
|
52 |
-
}
|
53 |
-
|
54 |
-
if ( get_user_meta( get_current_user_id(), 'wcal_pro_first_notice_ignore' ) &&
|
55 |
-
get_user_meta( get_current_user_id(), 'wcal_pro_second_notice_ignore' ) &&
|
56 |
-
! get_user_meta( get_current_user_id(), 'wcal_pro_third_notice_ignore' ) &&
|
57 |
-
! is_plugin_active( 'order-delivery-date/order_delivery_date.php' ) &&
|
58 |
-
! is_plugin_active( 'order-delivery-date-for-woocommerce/order_delivery_date.php' ) ) {
|
59 |
-
|
60 |
-
$wcal_second_ignore_time = get_user_meta( get_current_user_id(), 'wcal_pro_second_notice_ignore_time' );
|
61 |
-
$wcal_seven_days = strtotime( '+7 Days', $wcal_second_ignore_time[0] );
|
62 |
-
|
63 |
-
if ( $wcal_current_time >= $wcal_seven_days ){
|
64 |
-
$class = 'updated notice-info point-notice';
|
65 |
-
$style = 'position:relative';
|
66 |
-
|
67 |
-
$wcal_ordd_lite_link = admin_url( '/plugin-install.php?s=order+delivery+date+tyche+softwares&tab=search&type=term' );
|
68 |
-
|
69 |
-
$message = wp_kses_post ( __( 'Reduce cart abandonment rate by 57% with our FREE Order Delivery Date plugin. Also increase customer satisfaction with this simple plugin. <strong><a target="_blank" href= "'.$wcal_ordd_lite_link.'">Install Now</a></strong>.', 'woocommerce-ac' ) );
|
70 |
-
$add_query_arguments = add_query_arg( 'wcal_pro_third_notice_ignore', '0' );
|
71 |
-
$cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
|
72 |
-
printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, $message, $cancel_button );
|
73 |
-
}
|
74 |
-
}
|
75 |
-
|
76 |
-
if ( get_user_meta( get_current_user_id(), 'wcal_pro_first_notice_ignore' ) &&
|
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] );
|
84 |
-
|
85 |
-
if ( $wcal_current_time >= $wcal_seven_days ){
|
86 |
-
$class = 'updated notice-info point-notice';
|
87 |
-
$style = 'position:relative';
|
88 |
-
|
89 |
-
$wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/checkout?edd_action=add_to_cart&download_id=20&utm_source=wpnotice&utm_medium=fourth&utm_campaign=AbandonedCartLitePlugin';
|
90 |
-
|
91 |
-
$wcal_pro_diff = 'https://www.tychesoftwares.com/differences-between-pro-and-lite-versions-of-abandoned-cart-for-woocommerce-plugin/';
|
92 |
-
|
93 |
-
$message = wp_kses_post ( __( 'Using Abandoned Cart Pro plugin, you can add more merge tags, one-click Cart & Checkout page button, send customised abandoned cart reminder email to specific customers & <strong><a target="_blank" href= "'.$wcal_pro_diff.'">much more</a></strong>. <br>Grab 20% discount on the purchase using ACPRO20 discount code and save $24. Coupon is limited to first 20 customers only. <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'">Purchase now</a></strong>.', 'woocommerce-ac' ) );
|
94 |
-
|
95 |
-
$add_query_arguments = add_query_arg( 'wcal_pro_fourth_notice_ignore', '0' );
|
96 |
-
|
97 |
-
$cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important ;"></a>';
|
98 |
-
printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, $message, $cancel_button );
|
99 |
-
}
|
100 |
-
|
101 |
-
}else if ( get_user_meta( get_current_user_id(), 'wcal_pro_first_notice_ignore' ) &&
|
102 |
-
get_user_meta( get_current_user_id(), 'wcal_pro_second_notice_ignore' ) &&
|
103 |
-
get_user_meta( get_current_user_id(), 'wcal_pro_third_notice_ignore' ) &&
|
104 |
-
! get_user_meta( get_current_user_id(), 'wcal_pro_fourth_notice_ignore' ) &&
|
105 |
-
( ! is_plugin_active( 'order-delivery-date/order_delivery_date.php' ) ||
|
106 |
-
! is_plugin_active( 'order-delivery-date-for-woocommerce/order_delivery_date.php' ) ) ) {
|
107 |
-
|
108 |
-
$wcal_third_ignore_time = get_user_meta( get_current_user_id(), 'wcal_pro_third_notice_ignore_time' );
|
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 |
-
|
116 |
-
$wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/checkout?edd_action=add_to_cart&download_id=20&utm_source=wpnotice&utm_medium=fourth&utm_campaign=AbandonedCartLitePlugin';
|
117 |
-
|
118 |
-
$wcal_pro_diff = 'https://www.tychesoftwares.com/differences-between-pro-and-lite-versions-of-abandoned-cart-for-woocommerce-plugin/';
|
119 |
-
|
120 |
-
$message = wp_kses_post ( __( 'Using Abandoned Cart Pro plugin, you can add more merge tags, one-click Cart & Checkout page button, send customised abandoned cart reminder email to specific customers & <strong><a target="_blank" href= "'.$wcal_pro_diff.'">much more</a></strong>. <br>Grab 20% discount on the purchase using ABPRO20 discount code and save $24. Coupon is limited to first 20 customers only. <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'">Purchase now</a></strong>.', 'woocommerce-ac' ) );
|
121 |
-
|
122 |
-
$add_query_arguments = add_query_arg( 'wcal_pro_fourth_notice_ignore', '0' );
|
123 |
-
|
124 |
-
$cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important ;"></a>';
|
125 |
-
printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, $message, $cancel_button );
|
126 |
-
}
|
127 |
-
}
|
128 |
-
}
|
129 |
-
}
|
130 |
-
|
131 |
-
/**
|
132 |
-
* Ignore pro notice
|
133 |
-
*/
|
134 |
-
public static function wcal_pro_notice_ignore() {
|
135 |
-
|
136 |
-
// If user clicks to ignore the notice, add that to their user meta
|
137 |
-
if ( isset( $_GET['wcal_pro_first_notice_ignore'] ) && '0' === $_GET['wcal_pro_first_notice_ignore'] ) {
|
138 |
-
add_user_meta( get_current_user_id(), 'wcal_pro_first_notice_ignore', 'true', true );
|
139 |
-
add_user_meta( get_current_user_id(), 'wcal_pro_first_notice_ignore_time', current_time( 'timestamp' ), true );
|
140 |
-
wp_safe_redirect( remove_query_arg( 'wcal_pro_first_notice_ignore' ) );
|
141 |
-
|
142 |
-
}
|
143 |
-
|
144 |
-
if ( isset( $_GET['wcal_pro_second_notice_ignore'] ) && '0' === $_GET['wcal_pro_second_notice_ignore'] ) {
|
145 |
-
add_user_meta( get_current_user_id(), 'wcal_pro_second_notice_ignore', 'true', true );
|
146 |
-
add_user_meta( get_current_user_id(), 'wcal_pro_second_notice_ignore_time', current_time( 'timestamp' ), true );
|
147 |
-
wp_safe_redirect( remove_query_arg( 'wcal_pro_second_notice_ignore' ) );
|
148 |
-
}
|
149 |
-
|
150 |
-
if ( isset( $_GET['wcal_pro_third_notice_ignore'] ) && '0' === $_GET['wcal_pro_third_notice_ignore'] ) {
|
151 |
-
add_user_meta( get_current_user_id(), 'wcal_pro_third_notice_ignore', 'true', true );
|
152 |
-
add_user_meta( get_current_user_id(), 'wcal_pro_third_notice_ignore_time', current_time( 'timestamp' ), true );
|
153 |
-
wp_safe_redirect( remove_query_arg( 'wcal_pro_third_notice_ignore' ) );
|
154 |
-
}
|
155 |
-
|
156 |
-
if ( isset( $_GET['wcal_pro_fourth_notice_ignore'] ) && '0' === $_GET['wcal_pro_fourth_notice_ignore'] ) {
|
157 |
-
add_user_meta( get_current_user_id(), 'wcal_pro_fourth_notice_ignore', 'true', true );
|
158 |
-
add_user_meta( get_current_user_id(), 'wcal_pro_fourth_notice_ignore_time', current_time( 'timestamp' ), true );
|
159 |
-
wp_safe_redirect( remove_query_arg( 'wcal_pro_fourth_notice_ignore' ) );
|
160 |
-
}
|
161 |
-
}
|
162 |
}
|
1 |
+
<?php
|
2 |
+
// Exit if accessed directly
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
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 );
|
13 |
+
$wcal_current_time = current_time( 'timestamp' );
|
14 |
+
|
15 |
+
if( !is_plugin_active( 'woocommerce-abandon-cart-pro/woocommerce-ac.php' ) &&
|
16 |
+
( false === $wcal_activate_time || ( $wcal_activate_time > 0 && $wcal_current_time >= $wcal_sixty_days ) ) ) {
|
17 |
+
global $current_user ;
|
18 |
+
$user_id = $current_user->ID;
|
19 |
+
$wcal_current_time = current_time( 'timestamp' );
|
20 |
+
|
21 |
+
if ( ! get_user_meta( get_current_user_id(), 'wcal_pro_first_notice_ignore' ) ) {
|
22 |
+
|
23 |
+
$class = 'updated notice-info point-notice';
|
24 |
+
$style = 'position:relative';
|
25 |
+
|
26 |
+
$wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/checkout?edd_action=add_to_cart&download_id=20&utm_source=wpnotice&utm_medium=first&utm_campaign=AbandonedCartLitePlugin';
|
27 |
+
|
28 |
+
$message = wp_kses_post ( __( 'Thank you for using Abandoned Cart Lite for WooCommerce! You can use the Pro version for recovering more sales with some additional features. <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'">Get it now!</a></strong>', 'woocommerce-ac' ) );
|
29 |
+
|
30 |
+
$add_query_arguments = add_query_arg( 'wcal_pro_first_notice_ignore', '0' );
|
31 |
+
$cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
|
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]);
|
39 |
+
|
40 |
+
if ( $wcal_current_time >= $wcal_fifteen_days ){
|
41 |
+
$class = 'updated notice-info point-notice';
|
42 |
+
$style = 'position:relative';
|
43 |
+
|
44 |
+
$wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/checkout?edd_action=add_to_cart&download_id=20&utm_source=wpnotice&utm_medium=second&utm_campaign=AbandonedCartLitePlugin';
|
45 |
+
|
46 |
+
$message = wp_kses_post ( __( 'Abandoned Cart Pro plugin allows you to recover more revenue by offering discount coupons in the abandoned cart email notifications. <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'">Grab it now!</a></strong>', 'woocommerce-ac' ) );
|
47 |
+
|
48 |
+
$add_query_arguments = add_query_arg( 'wcal_pro_second_notice_ignore', '0' );
|
49 |
+
$cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
|
50 |
+
printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, $message, $cancel_button );
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
if ( get_user_meta( get_current_user_id(), 'wcal_pro_first_notice_ignore' ) &&
|
55 |
+
get_user_meta( get_current_user_id(), 'wcal_pro_second_notice_ignore' ) &&
|
56 |
+
! get_user_meta( get_current_user_id(), 'wcal_pro_third_notice_ignore' ) &&
|
57 |
+
! is_plugin_active( 'order-delivery-date/order_delivery_date.php' ) &&
|
58 |
+
! is_plugin_active( 'order-delivery-date-for-woocommerce/order_delivery_date.php' ) ) {
|
59 |
+
|
60 |
+
$wcal_second_ignore_time = get_user_meta( get_current_user_id(), 'wcal_pro_second_notice_ignore_time' );
|
61 |
+
$wcal_seven_days = strtotime( '+7 Days', $wcal_second_ignore_time[0] );
|
62 |
+
|
63 |
+
if ( $wcal_current_time >= $wcal_seven_days ){
|
64 |
+
$class = 'updated notice-info point-notice';
|
65 |
+
$style = 'position:relative';
|
66 |
+
|
67 |
+
$wcal_ordd_lite_link = admin_url( '/plugin-install.php?s=order+delivery+date+tyche+softwares&tab=search&type=term' );
|
68 |
+
|
69 |
+
$message = wp_kses_post ( __( 'Reduce cart abandonment rate by 57% with our FREE Order Delivery Date plugin. Also increase customer satisfaction with this simple plugin. <strong><a target="_blank" href= "'.$wcal_ordd_lite_link.'">Install Now</a></strong>.', 'woocommerce-ac' ) );
|
70 |
+
$add_query_arguments = add_query_arg( 'wcal_pro_third_notice_ignore', '0' );
|
71 |
+
$cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
|
72 |
+
printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, $message, $cancel_button );
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
if ( get_user_meta( get_current_user_id(), 'wcal_pro_first_notice_ignore' ) &&
|
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] );
|
84 |
+
|
85 |
+
if ( $wcal_current_time >= $wcal_seven_days ){
|
86 |
+
$class = 'updated notice-info point-notice';
|
87 |
+
$style = 'position:relative';
|
88 |
+
|
89 |
+
$wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/checkout?edd_action=add_to_cart&download_id=20&utm_source=wpnotice&utm_medium=fourth&utm_campaign=AbandonedCartLitePlugin';
|
90 |
+
|
91 |
+
$wcal_pro_diff = 'https://www.tychesoftwares.com/differences-between-pro-and-lite-versions-of-abandoned-cart-for-woocommerce-plugin/';
|
92 |
+
|
93 |
+
$message = wp_kses_post ( __( 'Using Abandoned Cart Pro plugin, you can add more merge tags, one-click Cart & Checkout page button, send customised abandoned cart reminder email to specific customers & <strong><a target="_blank" href= "'.$wcal_pro_diff.'">much more</a></strong>. <br>Grab 20% discount on the purchase using ACPRO20 discount code and save $24. Coupon is limited to first 20 customers only. <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'">Purchase now</a></strong>.', 'woocommerce-ac' ) );
|
94 |
+
|
95 |
+
$add_query_arguments = add_query_arg( 'wcal_pro_fourth_notice_ignore', '0' );
|
96 |
+
|
97 |
+
$cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important ;"></a>';
|
98 |
+
printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, $message, $cancel_button );
|
99 |
+
}
|
100 |
+
|
101 |
+
}else if ( get_user_meta( get_current_user_id(), 'wcal_pro_first_notice_ignore' ) &&
|
102 |
+
get_user_meta( get_current_user_id(), 'wcal_pro_second_notice_ignore' ) &&
|
103 |
+
get_user_meta( get_current_user_id(), 'wcal_pro_third_notice_ignore' ) &&
|
104 |
+
! get_user_meta( get_current_user_id(), 'wcal_pro_fourth_notice_ignore' ) &&
|
105 |
+
( ! is_plugin_active( 'order-delivery-date/order_delivery_date.php' ) ||
|
106 |
+
! is_plugin_active( 'order-delivery-date-for-woocommerce/order_delivery_date.php' ) ) ) {
|
107 |
+
|
108 |
+
$wcal_third_ignore_time = get_user_meta( get_current_user_id(), 'wcal_pro_third_notice_ignore_time' );
|
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 |
+
|
116 |
+
$wcal_ac_pro_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/checkout?edd_action=add_to_cart&download_id=20&utm_source=wpnotice&utm_medium=fourth&utm_campaign=AbandonedCartLitePlugin';
|
117 |
+
|
118 |
+
$wcal_pro_diff = 'https://www.tychesoftwares.com/differences-between-pro-and-lite-versions-of-abandoned-cart-for-woocommerce-plugin/';
|
119 |
+
|
120 |
+
$message = wp_kses_post ( __( 'Using Abandoned Cart Pro plugin, you can add more merge tags, one-click Cart & Checkout page button, send customised abandoned cart reminder email to specific customers & <strong><a target="_blank" href= "'.$wcal_pro_diff.'">much more</a></strong>. <br>Grab 20% discount on the purchase using ABPRO20 discount code and save $24. Coupon is limited to first 20 customers only. <strong><a target="_blank" href= "'.$wcal_ac_pro_link.'">Purchase now</a></strong>.', 'woocommerce-ac' ) );
|
121 |
+
|
122 |
+
$add_query_arguments = add_query_arg( 'wcal_pro_fourth_notice_ignore', '0' );
|
123 |
+
|
124 |
+
$cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important ;"></a>';
|
125 |
+
printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, $message, $cancel_button );
|
126 |
+
}
|
127 |
+
}
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Ignore pro notice
|
133 |
+
*/
|
134 |
+
public static function wcal_pro_notice_ignore() {
|
135 |
+
|
136 |
+
// If user clicks to ignore the notice, add that to their user meta
|
137 |
+
if ( isset( $_GET['wcal_pro_first_notice_ignore'] ) && '0' === $_GET['wcal_pro_first_notice_ignore'] ) {
|
138 |
+
add_user_meta( get_current_user_id(), 'wcal_pro_first_notice_ignore', 'true', true );
|
139 |
+
add_user_meta( get_current_user_id(), 'wcal_pro_first_notice_ignore_time', current_time( 'timestamp' ), true );
|
140 |
+
wp_safe_redirect( remove_query_arg( 'wcal_pro_first_notice_ignore' ) );
|
141 |
+
|
142 |
+
}
|
143 |
+
|
144 |
+
if ( isset( $_GET['wcal_pro_second_notice_ignore'] ) && '0' === $_GET['wcal_pro_second_notice_ignore'] ) {
|
145 |
+
add_user_meta( get_current_user_id(), 'wcal_pro_second_notice_ignore', 'true', true );
|
146 |
+
add_user_meta( get_current_user_id(), 'wcal_pro_second_notice_ignore_time', current_time( 'timestamp' ), true );
|
147 |
+
wp_safe_redirect( remove_query_arg( 'wcal_pro_second_notice_ignore' ) );
|
148 |
+
}
|
149 |
+
|
150 |
+
if ( isset( $_GET['wcal_pro_third_notice_ignore'] ) && '0' === $_GET['wcal_pro_third_notice_ignore'] ) {
|
151 |
+
add_user_meta( get_current_user_id(), 'wcal_pro_third_notice_ignore', 'true', true );
|
152 |
+
add_user_meta( get_current_user_id(), 'wcal_pro_third_notice_ignore_time', current_time( 'timestamp' ), true );
|
153 |
+
wp_safe_redirect( remove_query_arg( 'wcal_pro_third_notice_ignore' ) );
|
154 |
+
}
|
155 |
+
|
156 |
+
if ( isset( $_GET['wcal_pro_fourth_notice_ignore'] ) && '0' === $_GET['wcal_pro_fourth_notice_ignore'] ) {
|
157 |
+
add_user_meta( get_current_user_id(), 'wcal_pro_fourth_notice_ignore', 'true', true );
|
158 |
+
add_user_meta( get_current_user_id(), 'wcal_pro_fourth_notice_ignore_time', current_time( 'timestamp' ), true );
|
159 |
+
wp_safe_redirect( remove_query_arg( 'wcal_pro_fourth_notice_ignore' ) );
|
160 |
+
}
|
161 |
+
}
|
162 |
}
|
woocommerce-abandoned-cart/includes/wcal_class-guest.php
CHANGED
@@ -1,256 +1,256 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Woocommerce Abandoned Cart Lite Plugin - Saves guest cart information
|
4 |
-
*/
|
5 |
-
if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
|
6 |
-
|
7 |
-
class woocommerce_guest_ac {
|
8 |
-
var $a;
|
9 |
-
public function __construct() {
|
10 |
-
add_action( 'woocommerce_after_checkout_billing_form', 'user_side_js' );
|
11 |
-
add_action( 'init','load_ac_ajax' );
|
12 |
-
add_filter( 'woocommerce_checkout_fields', 'guest_checkout_fields' );
|
13 |
-
}
|
14 |
-
}
|
15 |
-
/*-----------------------------------------------------------------------------------*/
|
16 |
-
/* Class Functions */
|
17 |
-
/*-----------------------------------------------------------------------------------*/
|
18 |
-
function load_ac_ajax() {
|
19 |
-
if ( ! is_user_logged_in() ) {
|
20 |
-
add_action( 'wp_ajax_nopriv_save_data', 'save_data' );
|
21 |
-
}
|
22 |
-
}
|
23 |
-
|
24 |
-
function user_side_js() {
|
25 |
-
?>
|
26 |
-
<script type="text/javascript">
|
27 |
-
jQuery( 'input#billing_email' ).on( 'change', function() {
|
28 |
-
var data = {
|
29 |
-
billing_first_name : jQuery('#billing_first_name').val(),
|
30 |
-
billing_last_name : jQuery('#billing_last_name').val(),
|
31 |
-
billing_company : jQuery('#billing_company').val(),
|
32 |
-
billing_address_1 : jQuery('#billing_address_1').val(),
|
33 |
-
billing_address_2 : jQuery('#billing_address_2').val(),
|
34 |
-
billing_city : jQuery('#billing_city').val(),
|
35 |
-
billing_state : jQuery('#billing_state').val(),
|
36 |
-
billing_postcode : jQuery('#billing_postcode').val(),
|
37 |
-
billing_country : jQuery('#billing_country').val(),
|
38 |
-
billing_phone : jQuery('#billing_phone').val(),
|
39 |
-
billing_email : jQuery('#billing_email').val(),
|
40 |
-
order_notes : jQuery('#order_comments').val(),
|
41 |
-
shipping_first_name : jQuery('#shipping_first_name').val(),
|
42 |
-
shipping_last_name : jQuery('#shipping_last_name').val(),
|
43 |
-
shipping_company : jQuery('#shipping_company').val(),
|
44 |
-
shipping_address_1 : jQuery('#shipping_address_1').val(),
|
45 |
-
shipping_address_2 : jQuery('#shipping_address_2').val(),
|
46 |
-
shipping_city : jQuery('#shipping_city').val(),
|
47 |
-
shipping_state : jQuery('#shipping_state').val(),
|
48 |
-
shipping_postcode : jQuery('#shipping_postcode').val(),
|
49 |
-
shipping_country : jQuery('#shipping_country').val(),
|
50 |
-
ship_to_billing : jQuery('#shiptobilling-checkbox').val(),
|
51 |
-
action: 'save_data'
|
52 |
-
};
|
53 |
-
jQuery.post( "<?php echo get_admin_url();?>admin-ajax.php", data, function(response) {
|
54 |
-
});
|
55 |
-
});
|
56 |
-
</script>
|
57 |
-
<?php
|
58 |
-
}
|
59 |
-
|
60 |
-
function save_data() {
|
61 |
-
if ( ! is_user_logged_in() ) {
|
62 |
-
if( session_id() === '' ) {
|
63 |
-
//session has not started
|
64 |
-
session_start();
|
65 |
-
}
|
66 |
-
global $wpdb, $woocommerce;
|
67 |
-
if ( isset($_POST['billing_first_name']) && $_POST['billing_first_name'] != '' ){
|
68 |
-
$_SESSION['billing_first_name'] = $_POST['billing_first_name'];
|
69 |
-
}
|
70 |
-
if ( isset($_POST['billing_last_name']) && $_POST['billing_last_name'] != '' ) {
|
71 |
-
$_SESSION['billing_last_name'] = $_POST['billing_last_name'];
|
72 |
-
}
|
73 |
-
if ( isset($_POST['billing_company']) && $_POST['billing_company'] != '' ) {
|
74 |
-
$_SESSION['billing_company'] = $_POST['billing_company'];
|
75 |
-
}
|
76 |
-
if ( isset($_POST['billing_address_1']) && $_POST['billing_address_1'] != '' ) {
|
77 |
-
$_SESSION['billing_address_1'] = $_POST['billing_address_1'];
|
78 |
-
}
|
79 |
-
if ( isset($_POST['billing_address_2']) && $_POST['billing_address_2'] != '' ) {
|
80 |
-
$_SESSION['billing_address_2'] = $_POST['billing_address_2'];
|
81 |
-
}
|
82 |
-
if ( isset($_POST['billing_city']) && $_POST['billing_city'] != '' ) {
|
83 |
-
$_SESSION['billing_city'] = $_POST['billing_city'];
|
84 |
-
}
|
85 |
-
if ( isset($_POST['billing_state']) && $_POST['billing_state'] != '' ) {
|
86 |
-
$_SESSION['billing_state'] = $_POST['billing_state'];
|
87 |
-
}
|
88 |
-
if ( isset($_POST['billing_postcode']) && $_POST['billing_postcode'] != '' ) {
|
89 |
-
$_SESSION['billing_postcode'] = $_POST['billing_postcode'];
|
90 |
-
}
|
91 |
-
if ( isset($_POST['billing_country']) && $_POST['billing_country'] != '' ) {
|
92 |
-
$_SESSION['billing_country'] = $_POST['billing_country'];
|
93 |
-
}
|
94 |
-
if ( isset($_POST['billing_email']) && $_POST['billing_email'] != '' ) {
|
95 |
-
$_SESSION['billing_email'] = $_POST['billing_email'];
|
96 |
-
}
|
97 |
-
if ( isset($_POST['billing_phone']) && $_POST['billing_phone'] != '' ) {
|
98 |
-
$_SESSION['billing_phone'] = $_POST['billing_phone'];
|
99 |
-
}
|
100 |
-
if ( isset($_POST['order_notes']) && $_POST['order_notes'] != '' ) {
|
101 |
-
$_SESSION['order_notes'] = $_POST['order_notes'];
|
102 |
-
}
|
103 |
-
if( isset( $_POST['ship_to_billing'] ) && $_POST['ship_to_billing'] != '' ) {
|
104 |
-
$_SESSION['ship_to_billing'] = $_POST['ship_to_billing'];
|
105 |
-
}
|
106 |
-
if ( isset($_POST['shipping_first_name']) && $_POST['shipping_first_name'] != '' ) {
|
107 |
-
$_SESSION['shipping_first_name'] = $_POST['shipping_first_name'];
|
108 |
-
}
|
109 |
-
if ( isset($_POST['shipping_last_name']) && $_POST['shipping_last_name'] != '' ) {
|
110 |
-
$_SESSION['shipping_last_name'] = $_POST['shipping_last_name'];
|
111 |
-
}
|
112 |
-
if ( isset($_POST['shipping_company']) && $_POST['shipping_company'] != '' ) {
|
113 |
-
$_SESSION['shipping_company'] = $_POST['shipping_company'];
|
114 |
-
}
|
115 |
-
if ( isset($_POST['shipping_address_1']) && $_POST['shipping_address_1'] != '' ) {
|
116 |
-
$_SESSION['shipping_address_1'] = $_POST['shipping_address_1'];
|
117 |
-
}
|
118 |
-
if ( isset($_POST['shipping_address_2']) && $_POST['shipping_address_2'] != '' ) {
|
119 |
-
$_SESSION['shipping_address_2'] = $_POST['shipping_address_2'];
|
120 |
-
}
|
121 |
-
if ( isset($_POST['shipping_city']) && $_POST['shipping_city'] != '' ) {
|
122 |
-
$_SESSION['shipping_city'] = $_POST['shipping_city'];
|
123 |
-
}
|
124 |
-
if ( isset($_POST['shipping_state']) && $_POST['shipping_state'] != '' ) {
|
125 |
-
$_SESSION['shipping_state'] = $_POST['shipping_state'];
|
126 |
-
}
|
127 |
-
if ( isset($_POST['shipping_postcode']) && $_POST['shipping_postcode'] != '' ) {
|
128 |
-
$_SESSION['shipping_postcode'] = $_POST['shipping_postcode'];
|
129 |
-
}
|
130 |
-
if ( isset($_POST['shipping_country']) && $_POST['shipping_country'] != '' ) {
|
131 |
-
$_SESSION['shipping_country'] = $_POST['shipping_country'];
|
132 |
-
}
|
133 |
-
// If a record is present in the guest cart history table for the same email id, then delete the previous records
|
134 |
-
$query_guest = "SELECT id FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite`
|
135 |
-
WHERE email_id = %s";
|
136 |
-
$results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $_SESSION['billing_email'] ) );
|
137 |
-
|
138 |
-
if ( $results_guest ) {
|
139 |
-
foreach ( $results_guest as $key => $value ) {
|
140 |
-
$query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
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 );
|
148 |
-
$delete_query = "DELETE FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
149 |
-
WHERE user_id = '".$value->id."'";
|
150 |
-
$wpdb->query( $delete_query );
|
151 |
-
}
|
152 |
-
$guest_delete = "DELETE FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite`
|
153 |
-
WHERE id = '".$value->id."'";
|
154 |
-
$wpdb->query( $guest_delete );
|
155 |
-
}
|
156 |
-
}
|
157 |
-
// Insert record in guest table
|
158 |
-
if ( isset( $_SESSION['billing_first_name'] ) ) {
|
159 |
-
$billing_first_name = $_SESSION['billing_first_name'];
|
160 |
-
} else {
|
161 |
-
$billing_first_name = '';
|
162 |
-
}
|
163 |
-
if ( isset( $_SESSION['billing_last_name'] ) ) {
|
164 |
-
$billing_last_name = $_SESSION['billing_last_name'];
|
165 |
-
} else {
|
166 |
-
$billing_last_name = '';
|
167 |
-
}
|
168 |
-
$shipping_zipcode = $billing_zipcode = '';
|
169 |
-
|
170 |
-
if ( isset( $_SESSION['shipping_postcode'] ) && $_SESSION['shipping_postcode'] != "" ) {
|
171 |
-
$shipping_zipcode = $_SESSION['shipping_postcode'];
|
172 |
-
} elseif( isset( $_SESSION['billing_postcode'] ) && $_SESSION['billing_postcode'] != "" ) {
|
173 |
-
$shipping_zipcode = $billing_zipcode = $_SESSION['billing_postcode'];
|
174 |
-
}
|
175 |
-
$shipping_charges = $woocommerce->cart->shipping_total;
|
176 |
-
$insert_guest = "INSERT INTO `".$wpdb->prefix . "ac_guest_abandoned_cart_history_lite`( billing_first_name, billing_last_name, email_id, billing_zipcode, shipping_zipcode, shipping_charges )
|
177 |
-
VALUES ( '".$billing_first_name."', '".$billing_last_name."', '".$_SESSION['billing_email']."', '".$billing_zipcode."', '".$shipping_zipcode."', '".$shipping_charges."' )";
|
178 |
-
$wpdb->query( $insert_guest );
|
179 |
-
|
180 |
-
//Insert record in abandoned cart table for the guest user
|
181 |
-
$user_id = $wpdb->insert_id;
|
182 |
-
$_SESSION['user_id'] = $user_id;
|
183 |
-
$current_time = current_time( 'timestamp' );
|
184 |
-
$cut_off_time = get_option( 'ac_cart_abandoned_time' );
|
185 |
-
$cart_cut_off_time = $cut_off_time * 60;
|
186 |
-
$compare_time = $current_time - $cart_cut_off_time;
|
187 |
-
|
188 |
-
$query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
189 |
-
WHERE user_id = %d AND cart_ignored = '0' AND recovered_cart = '0' AND user_type = 'GUEST'";
|
190 |
-
$results = $wpdb->get_results( $wpdb->prepare( $query, $user_id ) );
|
191 |
-
|
192 |
-
$cart = array();
|
193 |
-
|
194 |
-
if ( function_exists('WC') ) {
|
195 |
-
$cart['cart'] = WC()->session->cart;
|
196 |
-
} else {
|
197 |
-
$cart['cart'] = $woocommerce->session->cart;
|
198 |
-
}
|
199 |
-
|
200 |
-
if ( count( $results ) == 0 ) {
|
201 |
-
$get_cookie = WC()->session->get_session_cookie();
|
202 |
-
$cart_info = addslashes( json_encode( $cart ) );
|
203 |
-
|
204 |
-
$query = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
205 |
-
WHERE session_id LIKE %s AND cart_ignored = '0' AND recovered_cart = '0' ";
|
206 |
-
$results = $wpdb->get_results( $wpdb->prepare( $query, $get_cookie[0] ) );
|
207 |
-
|
208 |
-
if ( count( $results ) == 0 ) {
|
209 |
-
$insert_query = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`( user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, recovered_cart, user_type, session_id )
|
210 |
-
VALUES ( '".$user_id."', '".$cart_info."', '".$current_time."', '0', '0', 'GUEST', '".$get_cookie[0] ."' )";
|
211 |
-
$wpdb->query( $insert_query );
|
212 |
-
|
213 |
-
$abandoned_cart_id = $wpdb->insert_id;
|
214 |
-
$_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
|
215 |
-
|
216 |
-
$insert_persistent_cart = "INSERT INTO `".$wpdb->prefix."usermeta`( user_id, meta_key, meta_value )
|
217 |
-
VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
|
218 |
-
$wpdb->query( $insert_persistent_cart );
|
219 |
-
} else {
|
220 |
-
$query_update = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET user_id = '" . $user_id . "', abandoned_cart_info = '" . $cart_info . "', abandoned_cart_time = '" . $current_time . "' WHERE session_id ='" . $get_cookie[0] . "' AND cart_ignored='0' ";
|
221 |
-
$wpdb->query( $query_update );
|
222 |
-
$query_update_get = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
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."' )";
|
233 |
-
$wpdb->query( $insert_persistent_cart );
|
234 |
-
}
|
235 |
-
}
|
236 |
-
}
|
237 |
-
}
|
238 |
-
|
239 |
-
function guest_checkout_fields( $fields ) {
|
240 |
-
if ( isset( $_SESSION['guest_first_name'] ) && $_SESSION['guest_first_name'] != "" ) {
|
241 |
-
$_POST['billing_first_name'] = $_SESSION['guest_first_name'];
|
242 |
-
}
|
243 |
-
if ( isset( $_SESSION['guest_last_name'] ) && $_SESSION['guest_last_name'] != "" ) {
|
244 |
-
$_POST['billing_last_name'] = $_SESSION['guest_last_name'];
|
245 |
-
}
|
246 |
-
if ( isset( $_SESSION['guest_email']) && $_SESSION['guest_email'] != "" ) {
|
247 |
-
$_POST['billing_email'] = $_SESSION['guest_email'];
|
248 |
-
}
|
249 |
-
if ( isset( $_SESSION['guest_phone']) && $_SESSION['guest_phone'] != "" ) {
|
250 |
-
$_POST['billing_phone'] = $_SESSION['guest_phone'];
|
251 |
-
}
|
252 |
-
return $fields;
|
253 |
-
}
|
254 |
-
}
|
255 |
-
$woocommerce_guest_ac = new woocommerce_guest_ac();
|
256 |
?>
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Woocommerce Abandoned Cart Lite Plugin - Saves guest cart information
|
4 |
+
*/
|
5 |
+
if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
|
6 |
+
|
7 |
+
class woocommerce_guest_ac {
|
8 |
+
var $a;
|
9 |
+
public function __construct() {
|
10 |
+
add_action( 'woocommerce_after_checkout_billing_form', 'user_side_js' );
|
11 |
+
add_action( 'init','load_ac_ajax' );
|
12 |
+
add_filter( 'woocommerce_checkout_fields', 'guest_checkout_fields' );
|
13 |
+
}
|
14 |
+
}
|
15 |
+
/*-----------------------------------------------------------------------------------*/
|
16 |
+
/* Class Functions */
|
17 |
+
/*-----------------------------------------------------------------------------------*/
|
18 |
+
function load_ac_ajax() {
|
19 |
+
if ( ! is_user_logged_in() ) {
|
20 |
+
add_action( 'wp_ajax_nopriv_save_data', 'save_data' );
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
function user_side_js() {
|
25 |
+
?>
|
26 |
+
<script type="text/javascript">
|
27 |
+
jQuery( 'input#billing_email' ).on( 'change', function() {
|
28 |
+
var data = {
|
29 |
+
billing_first_name : jQuery('#billing_first_name').val(),
|
30 |
+
billing_last_name : jQuery('#billing_last_name').val(),
|
31 |
+
billing_company : jQuery('#billing_company').val(),
|
32 |
+
billing_address_1 : jQuery('#billing_address_1').val(),
|
33 |
+
billing_address_2 : jQuery('#billing_address_2').val(),
|
34 |
+
billing_city : jQuery('#billing_city').val(),
|
35 |
+
billing_state : jQuery('#billing_state').val(),
|
36 |
+
billing_postcode : jQuery('#billing_postcode').val(),
|
37 |
+
billing_country : jQuery('#billing_country').val(),
|
38 |
+
billing_phone : jQuery('#billing_phone').val(),
|
39 |
+
billing_email : jQuery('#billing_email').val(),
|
40 |
+
order_notes : jQuery('#order_comments').val(),
|
41 |
+
shipping_first_name : jQuery('#shipping_first_name').val(),
|
42 |
+
shipping_last_name : jQuery('#shipping_last_name').val(),
|
43 |
+
shipping_company : jQuery('#shipping_company').val(),
|
44 |
+
shipping_address_1 : jQuery('#shipping_address_1').val(),
|
45 |
+
shipping_address_2 : jQuery('#shipping_address_2').val(),
|
46 |
+
shipping_city : jQuery('#shipping_city').val(),
|
47 |
+
shipping_state : jQuery('#shipping_state').val(),
|
48 |
+
shipping_postcode : jQuery('#shipping_postcode').val(),
|
49 |
+
shipping_country : jQuery('#shipping_country').val(),
|
50 |
+
ship_to_billing : jQuery('#shiptobilling-checkbox').val(),
|
51 |
+
action: 'save_data'
|
52 |
+
};
|
53 |
+
jQuery.post( "<?php echo get_admin_url();?>admin-ajax.php", data, function(response) {
|
54 |
+
});
|
55 |
+
});
|
56 |
+
</script>
|
57 |
+
<?php
|
58 |
+
}
|
59 |
+
|
60 |
+
function save_data() {
|
61 |
+
if ( ! is_user_logged_in() ) {
|
62 |
+
if( session_id() === '' ) {
|
63 |
+
//session has not started
|
64 |
+
session_start();
|
65 |
+
}
|
66 |
+
global $wpdb, $woocommerce;
|
67 |
+
if ( isset($_POST['billing_first_name']) && $_POST['billing_first_name'] != '' ){
|
68 |
+
$_SESSION['billing_first_name'] = $_POST['billing_first_name'];
|
69 |
+
}
|
70 |
+
if ( isset($_POST['billing_last_name']) && $_POST['billing_last_name'] != '' ) {
|
71 |
+
$_SESSION['billing_last_name'] = $_POST['billing_last_name'];
|
72 |
+
}
|
73 |
+
if ( isset($_POST['billing_company']) && $_POST['billing_company'] != '' ) {
|
74 |
+
$_SESSION['billing_company'] = $_POST['billing_company'];
|
75 |
+
}
|
76 |
+
if ( isset($_POST['billing_address_1']) && $_POST['billing_address_1'] != '' ) {
|
77 |
+
$_SESSION['billing_address_1'] = $_POST['billing_address_1'];
|
78 |
+
}
|
79 |
+
if ( isset($_POST['billing_address_2']) && $_POST['billing_address_2'] != '' ) {
|
80 |
+
$_SESSION['billing_address_2'] = $_POST['billing_address_2'];
|
81 |
+
}
|
82 |
+
if ( isset($_POST['billing_city']) && $_POST['billing_city'] != '' ) {
|
83 |
+
$_SESSION['billing_city'] = $_POST['billing_city'];
|
84 |
+
}
|
85 |
+
if ( isset($_POST['billing_state']) && $_POST['billing_state'] != '' ) {
|
86 |
+
$_SESSION['billing_state'] = $_POST['billing_state'];
|
87 |
+
}
|
88 |
+
if ( isset($_POST['billing_postcode']) && $_POST['billing_postcode'] != '' ) {
|
89 |
+
$_SESSION['billing_postcode'] = $_POST['billing_postcode'];
|
90 |
+
}
|
91 |
+
if ( isset($_POST['billing_country']) && $_POST['billing_country'] != '' ) {
|
92 |
+
$_SESSION['billing_country'] = $_POST['billing_country'];
|
93 |
+
}
|
94 |
+
if ( isset($_POST['billing_email']) && $_POST['billing_email'] != '' ) {
|
95 |
+
$_SESSION['billing_email'] = $_POST['billing_email'];
|
96 |
+
}
|
97 |
+
if ( isset($_POST['billing_phone']) && $_POST['billing_phone'] != '' ) {
|
98 |
+
$_SESSION['billing_phone'] = $_POST['billing_phone'];
|
99 |
+
}
|
100 |
+
if ( isset($_POST['order_notes']) && $_POST['order_notes'] != '' ) {
|
101 |
+
$_SESSION['order_notes'] = $_POST['order_notes'];
|
102 |
+
}
|
103 |
+
if( isset( $_POST['ship_to_billing'] ) && $_POST['ship_to_billing'] != '' ) {
|
104 |
+
$_SESSION['ship_to_billing'] = $_POST['ship_to_billing'];
|
105 |
+
}
|
106 |
+
if ( isset($_POST['shipping_first_name']) && $_POST['shipping_first_name'] != '' ) {
|
107 |
+
$_SESSION['shipping_first_name'] = $_POST['shipping_first_name'];
|
108 |
+
}
|
109 |
+
if ( isset($_POST['shipping_last_name']) && $_POST['shipping_last_name'] != '' ) {
|
110 |
+
$_SESSION['shipping_last_name'] = $_POST['shipping_last_name'];
|
111 |
+
}
|
112 |
+
if ( isset($_POST['shipping_company']) && $_POST['shipping_company'] != '' ) {
|
113 |
+
$_SESSION['shipping_company'] = $_POST['shipping_company'];
|
114 |
+
}
|
115 |
+
if ( isset($_POST['shipping_address_1']) && $_POST['shipping_address_1'] != '' ) {
|
116 |
+
$_SESSION['shipping_address_1'] = $_POST['shipping_address_1'];
|
117 |
+
}
|
118 |
+
if ( isset($_POST['shipping_address_2']) && $_POST['shipping_address_2'] != '' ) {
|
119 |
+
$_SESSION['shipping_address_2'] = $_POST['shipping_address_2'];
|
120 |
+
}
|
121 |
+
if ( isset($_POST['shipping_city']) && $_POST['shipping_city'] != '' ) {
|
122 |
+
$_SESSION['shipping_city'] = $_POST['shipping_city'];
|
123 |
+
}
|
124 |
+
if ( isset($_POST['shipping_state']) && $_POST['shipping_state'] != '' ) {
|
125 |
+
$_SESSION['shipping_state'] = $_POST['shipping_state'];
|
126 |
+
}
|
127 |
+
if ( isset($_POST['shipping_postcode']) && $_POST['shipping_postcode'] != '' ) {
|
128 |
+
$_SESSION['shipping_postcode'] = $_POST['shipping_postcode'];
|
129 |
+
}
|
130 |
+
if ( isset($_POST['shipping_country']) && $_POST['shipping_country'] != '' ) {
|
131 |
+
$_SESSION['shipping_country'] = $_POST['shipping_country'];
|
132 |
+
}
|
133 |
+
// If a record is present in the guest cart history table for the same email id, then delete the previous records
|
134 |
+
$query_guest = "SELECT id FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite`
|
135 |
+
WHERE email_id = %s";
|
136 |
+
$results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $_SESSION['billing_email'] ) );
|
137 |
+
|
138 |
+
if ( $results_guest ) {
|
139 |
+
foreach ( $results_guest as $key => $value ) {
|
140 |
+
$query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
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 );
|
148 |
+
$delete_query = "DELETE FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
149 |
+
WHERE user_id = '".$value->id."'";
|
150 |
+
$wpdb->query( $delete_query );
|
151 |
+
}
|
152 |
+
$guest_delete = "DELETE FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite`
|
153 |
+
WHERE id = '".$value->id."'";
|
154 |
+
$wpdb->query( $guest_delete );
|
155 |
+
}
|
156 |
+
}
|
157 |
+
// Insert record in guest table
|
158 |
+
if ( isset( $_SESSION['billing_first_name'] ) ) {
|
159 |
+
$billing_first_name = $_SESSION['billing_first_name'];
|
160 |
+
} else {
|
161 |
+
$billing_first_name = '';
|
162 |
+
}
|
163 |
+
if ( isset( $_SESSION['billing_last_name'] ) ) {
|
164 |
+
$billing_last_name = $_SESSION['billing_last_name'];
|
165 |
+
} else {
|
166 |
+
$billing_last_name = '';
|
167 |
+
}
|
168 |
+
$shipping_zipcode = $billing_zipcode = '';
|
169 |
+
|
170 |
+
if ( isset( $_SESSION['shipping_postcode'] ) && $_SESSION['shipping_postcode'] != "" ) {
|
171 |
+
$shipping_zipcode = $_SESSION['shipping_postcode'];
|
172 |
+
} elseif( isset( $_SESSION['billing_postcode'] ) && $_SESSION['billing_postcode'] != "" ) {
|
173 |
+
$shipping_zipcode = $billing_zipcode = $_SESSION['billing_postcode'];
|
174 |
+
}
|
175 |
+
$shipping_charges = $woocommerce->cart->shipping_total;
|
176 |
+
$insert_guest = "INSERT INTO `".$wpdb->prefix . "ac_guest_abandoned_cart_history_lite`( billing_first_name, billing_last_name, email_id, billing_zipcode, shipping_zipcode, shipping_charges )
|
177 |
+
VALUES ( '".$billing_first_name."', '".$billing_last_name."', '".$_SESSION['billing_email']."', '".$billing_zipcode."', '".$shipping_zipcode."', '".$shipping_charges."' )";
|
178 |
+
$wpdb->query( $insert_guest );
|
179 |
+
|
180 |
+
//Insert record in abandoned cart table for the guest user
|
181 |
+
$user_id = $wpdb->insert_id;
|
182 |
+
$_SESSION['user_id'] = $user_id;
|
183 |
+
$current_time = current_time( 'timestamp' );
|
184 |
+
$cut_off_time = get_option( 'ac_cart_abandoned_time' );
|
185 |
+
$cart_cut_off_time = $cut_off_time * 60;
|
186 |
+
$compare_time = $current_time - $cart_cut_off_time;
|
187 |
+
|
188 |
+
$query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
189 |
+
WHERE user_id = %d AND cart_ignored = '0' AND recovered_cart = '0' AND user_type = 'GUEST'";
|
190 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query, $user_id ) );
|
191 |
+
|
192 |
+
$cart = array();
|
193 |
+
|
194 |
+
if ( function_exists('WC') ) {
|
195 |
+
$cart['cart'] = WC()->session->cart;
|
196 |
+
} else {
|
197 |
+
$cart['cart'] = $woocommerce->session->cart;
|
198 |
+
}
|
199 |
+
|
200 |
+
if ( count( $results ) == 0 ) {
|
201 |
+
$get_cookie = WC()->session->get_session_cookie();
|
202 |
+
$cart_info = addslashes( json_encode( $cart ) );
|
203 |
+
|
204 |
+
$query = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
205 |
+
WHERE session_id LIKE %s AND cart_ignored = '0' AND recovered_cart = '0' ";
|
206 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query, $get_cookie[0] ) );
|
207 |
+
|
208 |
+
if ( count( $results ) == 0 ) {
|
209 |
+
$insert_query = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`( user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, recovered_cart, user_type, session_id )
|
210 |
+
VALUES ( '".$user_id."', '".$cart_info."', '".$current_time."', '0', '0', 'GUEST', '".$get_cookie[0] ."' )";
|
211 |
+
$wpdb->query( $insert_query );
|
212 |
+
|
213 |
+
$abandoned_cart_id = $wpdb->insert_id;
|
214 |
+
$_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
|
215 |
+
|
216 |
+
$insert_persistent_cart = "INSERT INTO `".$wpdb->prefix."usermeta`( user_id, meta_key, meta_value )
|
217 |
+
VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
|
218 |
+
$wpdb->query( $insert_persistent_cart );
|
219 |
+
} else {
|
220 |
+
$query_update = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET user_id = '" . $user_id . "', abandoned_cart_info = '" . $cart_info . "', abandoned_cart_time = '" . $current_time . "' WHERE session_id ='" . $get_cookie[0] . "' AND cart_ignored='0' ";
|
221 |
+
$wpdb->query( $query_update );
|
222 |
+
$query_update_get = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
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."' )";
|
233 |
+
$wpdb->query( $insert_persistent_cart );
|
234 |
+
}
|
235 |
+
}
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
function guest_checkout_fields( $fields ) {
|
240 |
+
if ( isset( $_SESSION['guest_first_name'] ) && $_SESSION['guest_first_name'] != "" ) {
|
241 |
+
$_POST['billing_first_name'] = $_SESSION['guest_first_name'];
|
242 |
+
}
|
243 |
+
if ( isset( $_SESSION['guest_last_name'] ) && $_SESSION['guest_last_name'] != "" ) {
|
244 |
+
$_POST['billing_last_name'] = $_SESSION['guest_last_name'];
|
245 |
+
}
|
246 |
+
if ( isset( $_SESSION['guest_email']) && $_SESSION['guest_email'] != "" ) {
|
247 |
+
$_POST['billing_email'] = $_SESSION['guest_email'];
|
248 |
+
}
|
249 |
+
if ( isset( $_SESSION['guest_phone']) && $_SESSION['guest_phone'] != "" ) {
|
250 |
+
$_POST['billing_phone'] = $_SESSION['guest_phone'];
|
251 |
+
}
|
252 |
+
return $fields;
|
253 |
+
}
|
254 |
+
}
|
255 |
+
$woocommerce_guest_ac = new woocommerce_guest_ac();
|
256 |
?>
|
woocommerce-abandoned-cart/includes/wcal_default-settings.php
CHANGED
@@ -1,48 +1,48 @@
|
|
1 |
-
<?php
|
2 |
-
class wcal_default_template_settings {
|
3 |
-
/* This function will load default template while activating the plugin.
|
4 |
-
*
|
5 |
-
* @since: AFter 2.5 version
|
6 |
-
*/
|
7 |
-
function wcal_create_default_templates() {
|
8 |
-
global $wpdb;
|
9 |
-
$template_name_array = 'Initial';
|
10 |
-
$site_title = get_bloginfo( 'name' );
|
11 |
-
$site_url = get_option( 'siteurl' );
|
12 |
-
$template_subject_array = $site_title . ": Did you have checkout trouble?";
|
13 |
-
$active_post_array = 0;
|
14 |
-
$email_frequency_array = 1;
|
15 |
-
$day_or_hour_array = 'Hours';
|
16 |
-
$body_content_array = addslashes( "<html>
|
17 |
-
<body>
|
18 |
-
<p> Hello {{customer.fullname}}, </p>
|
19 |
-
<p> </p>
|
20 |
-
<p> We\'re following up with you, because we noticed that on {{cart.abandoned_date}} you attempted to purchase the following products on $site_title. </p>
|
21 |
-
<p> </p>
|
22 |
-
<p> {{products.cart}} </p>
|
23 |
-
<p> </p>
|
24 |
-
<p> If you had any purchase troubles, could you please Contact to share them? </p>
|
25 |
-
<p> </p>
|
26 |
-
<p> Otherwise, how about giving us another chance? Shop <a href= $site_url >$site_title</a>. </p>
|
27 |
-
<hr></hr>
|
28 |
-
<p> You may <a href='{{cart.unsubscribe}}'>unsubscribe</a> to stop receiving these emails. </p>
|
29 |
-
<p> </p>
|
30 |
-
<p> <a href=$site_url>$site_title</a> appreciates your business. </p>
|
31 |
-
</body>
|
32 |
-
</html>" );
|
33 |
-
$is_wc_template = 1 ;
|
34 |
-
$default_template = 1;
|
35 |
-
|
36 |
-
$query = "INSERT INTO `" . $wpdb->prefix . "ac_email_templates_lite`
|
37 |
-
( subject, body, is_active, frequency, day_or_hour, template_name, is_wc_template, default_template )
|
38 |
-
VALUES ( '" . $template_subject_array . "',
|
39 |
-
'" . $body_content_array . "',
|
40 |
-
'" . $active_post_array . "',
|
41 |
-
'" . $email_frequency_array . "',
|
42 |
-
'" . $day_or_hour_array . "',
|
43 |
-
'" . $template_name_array . "',
|
44 |
-
'" . $is_wc_template . "',
|
45 |
-
'" . $default_template . "' )";
|
46 |
-
$wpdb->query( $query );
|
47 |
-
}
|
48 |
-
}
|
1 |
+
<?php
|
2 |
+
class wcal_default_template_settings {
|
3 |
+
/* This function will load default template while activating the plugin.
|
4 |
+
*
|
5 |
+
* @since: AFter 2.5 version
|
6 |
+
*/
|
7 |
+
function wcal_create_default_templates() {
|
8 |
+
global $wpdb;
|
9 |
+
$template_name_array = 'Initial';
|
10 |
+
$site_title = get_bloginfo( 'name' );
|
11 |
+
$site_url = get_option( 'siteurl' );
|
12 |
+
$template_subject_array = $site_title . ": Did you have checkout trouble?";
|
13 |
+
$active_post_array = 0;
|
14 |
+
$email_frequency_array = 1;
|
15 |
+
$day_or_hour_array = 'Hours';
|
16 |
+
$body_content_array = addslashes( "<html>
|
17 |
+
<body>
|
18 |
+
<p> Hello {{customer.fullname}}, </p>
|
19 |
+
<p> </p>
|
20 |
+
<p> We\'re following up with you, because we noticed that on {{cart.abandoned_date}} you attempted to purchase the following products on $site_title. </p>
|
21 |
+
<p> </p>
|
22 |
+
<p> {{products.cart}} </p>
|
23 |
+
<p> </p>
|
24 |
+
<p> If you had any purchase troubles, could you please Contact to share them? </p>
|
25 |
+
<p> </p>
|
26 |
+
<p> Otherwise, how about giving us another chance? Shop <a href= $site_url >$site_title</a>. </p>
|
27 |
+
<hr></hr>
|
28 |
+
<p> You may <a href='{{cart.unsubscribe}}'>unsubscribe</a> to stop receiving these emails. </p>
|
29 |
+
<p> </p>
|
30 |
+
<p> <a href=$site_url>$site_title</a> appreciates your business. </p>
|
31 |
+
</body>
|
32 |
+
</html>" );
|
33 |
+
$is_wc_template = 1 ;
|
34 |
+
$default_template = 1;
|
35 |
+
|
36 |
+
$query = "INSERT INTO `" . $wpdb->prefix . "ac_email_templates_lite`
|
37 |
+
( subject, body, is_active, frequency, day_or_hour, template_name, is_wc_template, default_template )
|
38 |
+
VALUES ( '" . $template_subject_array . "',
|
39 |
+
'" . $body_content_array . "',
|
40 |
+
'" . $active_post_array . "',
|
41 |
+
'" . $email_frequency_array . "',
|
42 |
+
'" . $day_or_hour_array . "',
|
43 |
+
'" . $template_name_array . "',
|
44 |
+
'" . $is_wc_template . "',
|
45 |
+
'" . $default_template . "' )";
|
46 |
+
$wpdb->query( $query );
|
47 |
+
}
|
48 |
+
}
|
woocommerce-abandoned-cart/includes/wcal_ts_tracking.php
CHANGED
@@ -1,59 +1,59 @@
|
|
1 |
-
<?php
|
2 |
-
include_once( 'classes/class-wcal-ts-tracker.php' );
|
3 |
-
class Wcal_TS_Tracking {
|
4 |
-
public function __construct() {
|
5 |
-
//Tracking Data
|
6 |
-
add_action( 'admin_notices', array( &$this, 'wcal_track_usage_data' ), 10 );
|
7 |
-
add_action( 'admin_footer', array( &$this, 'wcal_admin_notices_scripts' ) );
|
8 |
-
add_action( 'wp_ajax_wcal_admin_notices', array( &$this, 'wcal_admin_notices' ) );
|
9 |
-
}
|
10 |
-
|
11 |
-
public static function wcal_admin_notices_scripts() {
|
12 |
-
|
13 |
-
|
14 |
-
wp_enqueue_script( 'wcal_admin_dismissal_notice', plugins_url() . '/woocommerce-abandoned-cart/assets/js/wcal_ts_dismiss_notice.js' );
|
15 |
-
}
|
16 |
-
|
17 |
-
public static function wcal_admin_notices() {
|
18 |
-
Class_Wcal_Ts_Tracker::wcal_ts_send_tracking_data( false );
|
19 |
-
update_option( 'wcal_allow_tracking', 'dismissed' );
|
20 |
-
die();
|
21 |
-
}
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Actions on the final step.
|
25 |
-
*/
|
26 |
-
private function wcal_ts_tracking_actions() {
|
27 |
-
|
28 |
-
if ( isset( $_GET[ 'wcal_tracker_optin' ] ) && isset( $_GET[ 'wcal_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ 'wcal_tracker_nonce' ], 'wcal_tracker_optin' ) ) {
|
29 |
-
update_option( 'wcal_allow_tracking', 'yes' );
|
30 |
-
Class_Wcal_Ts_Tracker::wcal_ts_send_tracking_data( true );
|
31 |
-
header( 'Location: ' . $_SERVER[ 'HTTP_REFERER' ] );
|
32 |
-
} elseif ( isset( $_GET[ 'wcal_tracker_optout' ] ) && isset( $_GET[ 'wcal_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ 'wcal_tracker_nonce' ], 'wcal_tracker_optout' ) ) {
|
33 |
-
update_option( 'wcal_allow_tracking', 'no' );
|
34 |
-
Class_Wcal_Ts_Tracker::wcal_ts_send_tracking_data( false );
|
35 |
-
header( 'Location: ' . $_SERVER[ 'HTTP_REFERER' ] );
|
36 |
-
}
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Data Usage tracking notice
|
41 |
-
*/
|
42 |
-
function wcal_track_usage_data() {
|
43 |
-
$wcal_admin_url = get_admin_url();
|
44 |
-
echo '<input type="hidden" id="admin_url" value="' . $wcal_admin_url . '"/>';
|
45 |
-
$this->wcal_ts_tracking_actions();
|
46 |
-
if ( 'unknown' === get_option( 'wcal_allow_tracking', 'unknown' ) ) : ?>
|
47 |
-
<div class="wcal-message wcal-tracker notice notice-info is-dismissible" style="position: relative;">
|
48 |
-
<div style="position: absolute;"><img class="site-logo" src="<?php echo plugins_url(); ?>/woocommerce-abandoned-cart/assets/images/site-logo-new.jpg"></div>
|
49 |
-
<p style="margin: 10px 0 10px 130px; font-size: medium;">
|
50 |
-
<?php print( __( 'Want to help make Abandoned Cart even more awesome? Allow Abandoned Cart to collect non-sensitive diagnostic data and usage information and get 20% off on your next purchase. <a href="https://www.tychesoftwares.com/abandoned-cart-lite-usage-tracking/" target="_blank">Find out more</a>. <br><br>', 'woocommerce-ac' ) ); ?></p>
|
51 |
-
<p class="submit">
|
52 |
-
<a class="button-primary button button-large" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wcal_tracker_optin', 'true' ), 'wcal_tracker_optin', 'wcal_tracker_nonce' ) ); ?>"><?php esc_html_e( 'Allow', 'woocommerce-ac' ); ?></a>
|
53 |
-
<a class="button-secondary button button-large skip" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wcal_tracker_optout', 'true' ), 'wcal_tracker_optout', 'wcal_tracker_nonce' ) ); ?>"><?php esc_html_e( 'No thanks', 'woocommerce-ac' ); ?></a>
|
54 |
-
</p>
|
55 |
-
</div>
|
56 |
-
<?php endif;
|
57 |
-
}
|
58 |
-
}
|
59 |
$TS_tracking = new Wcal_TS_Tracking();
|
1 |
+
<?php
|
2 |
+
include_once( 'classes/class-wcal-ts-tracker.php' );
|
3 |
+
class Wcal_TS_Tracking {
|
4 |
+
public function __construct() {
|
5 |
+
//Tracking Data
|
6 |
+
add_action( 'admin_notices', array( &$this, 'wcal_track_usage_data' ), 10 );
|
7 |
+
add_action( 'admin_footer', array( &$this, 'wcal_admin_notices_scripts' ) );
|
8 |
+
add_action( 'wp_ajax_wcal_admin_notices', array( &$this, 'wcal_admin_notices' ) );
|
9 |
+
}
|
10 |
+
|
11 |
+
public static function wcal_admin_notices_scripts() {
|
12 |
+
|
13 |
+
|
14 |
+
wp_enqueue_script( 'wcal_admin_dismissal_notice', plugins_url() . '/woocommerce-abandoned-cart/assets/js/wcal_ts_dismiss_notice.js' );
|
15 |
+
}
|
16 |
+
|
17 |
+
public static function wcal_admin_notices() {
|
18 |
+
Class_Wcal_Ts_Tracker::wcal_ts_send_tracking_data( false );
|
19 |
+
update_option( 'wcal_allow_tracking', 'dismissed' );
|
20 |
+
die();
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Actions on the final step.
|
25 |
+
*/
|
26 |
+
private function wcal_ts_tracking_actions() {
|
27 |
+
|
28 |
+
if ( isset( $_GET[ 'wcal_tracker_optin' ] ) && isset( $_GET[ 'wcal_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ 'wcal_tracker_nonce' ], 'wcal_tracker_optin' ) ) {
|
29 |
+
update_option( 'wcal_allow_tracking', 'yes' );
|
30 |
+
Class_Wcal_Ts_Tracker::wcal_ts_send_tracking_data( true );
|
31 |
+
header( 'Location: ' . $_SERVER[ 'HTTP_REFERER' ] );
|
32 |
+
} elseif ( isset( $_GET[ 'wcal_tracker_optout' ] ) && isset( $_GET[ 'wcal_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ 'wcal_tracker_nonce' ], 'wcal_tracker_optout' ) ) {
|
33 |
+
update_option( 'wcal_allow_tracking', 'no' );
|
34 |
+
Class_Wcal_Ts_Tracker::wcal_ts_send_tracking_data( false );
|
35 |
+
header( 'Location: ' . $_SERVER[ 'HTTP_REFERER' ] );
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Data Usage tracking notice
|
41 |
+
*/
|
42 |
+
function wcal_track_usage_data() {
|
43 |
+
$wcal_admin_url = get_admin_url();
|
44 |
+
echo '<input type="hidden" id="admin_url" value="' . $wcal_admin_url . '"/>';
|
45 |
+
$this->wcal_ts_tracking_actions();
|
46 |
+
if ( 'unknown' === get_option( 'wcal_allow_tracking', 'unknown' ) ) : ?>
|
47 |
+
<div class="wcal-message wcal-tracker notice notice-info is-dismissible" style="position: relative;">
|
48 |
+
<div style="position: absolute;"><img class="site-logo" src="<?php echo plugins_url(); ?>/woocommerce-abandoned-cart/assets/images/site-logo-new.jpg"></div>
|
49 |
+
<p style="margin: 10px 0 10px 130px; font-size: medium;">
|
50 |
+
<?php print( __( 'Want to help make Abandoned Cart even more awesome? Allow Abandoned Cart to collect non-sensitive diagnostic data and usage information and get 20% off on your next purchase. <a href="https://www.tychesoftwares.com/abandoned-cart-lite-usage-tracking/" target="_blank">Find out more</a>. <br><br>', 'woocommerce-ac' ) ); ?></p>
|
51 |
+
<p class="submit">
|
52 |
+
<a class="button-primary button button-large" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wcal_tracker_optin', 'true' ), 'wcal_tracker_optin', 'wcal_tracker_nonce' ) ); ?>"><?php esc_html_e( 'Allow', 'woocommerce-ac' ); ?></a>
|
53 |
+
<a class="button-secondary button button-large skip" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wcal_tracker_optout', 'true' ), 'wcal_tracker_optout', 'wcal_tracker_nonce' ) ); ?>"><?php esc_html_e( 'No thanks', 'woocommerce-ac' ); ?></a>
|
54 |
+
</p>
|
55 |
+
</div>
|
56 |
+
<?php endif;
|
57 |
+
}
|
58 |
+
}
|
59 |
$TS_tracking = new Wcal_TS_Tracking();
|
woocommerce-abandoned-cart/includes/welcome.php
CHANGED
@@ -1,330 +1,330 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Abandoned Cart Lite Welcome Page Class
|
5 |
-
*
|
6 |
-
* Displays on plugin activation
|
7 |
-
*/
|
8 |
-
|
9 |
-
// Exit if accessed directly.
|
10 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
-
exit;
|
12 |
-
}
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Wcal_Welcome Class
|
16 |
-
*
|
17 |
-
* A general class for About page.
|
18 |
-
*
|
19 |
-
* @since 4.5
|
20 |
-
*/
|
21 |
-
class Wcal_Welcome {
|
22 |
-
|
23 |
-
/**
|
24 |
-
* @var string The capability users should have to view the page
|
25 |
-
*/
|
26 |
-
public $minimum_capability = 'manage_options';
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Get things started
|
30 |
-
*
|
31 |
-
* @since 4.5
|
32 |
-
*/
|
33 |
-
public function __construct() {
|
34 |
-
|
35 |
-
add_action( 'admin_menu', array( $this, 'admin_menus' ) );
|
36 |
-
add_action( 'admin_head', array( $this, 'admin_head' ) );
|
37 |
-
|
38 |
-
if ( !isset( $_GET[ 'page' ] ) ||
|
39 |
-
( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] != 'wcal-about' ) ) {
|
40 |
-
add_action( 'admin_init', array( $this, 'welcome' ) );
|
41 |
-
}
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Register the Dashboard Page which is later hidden but this pages
|
46 |
-
* is used to render the Welcome page.
|
47 |
-
*
|
48 |
-
* @access public
|
49 |
-
* @since 4.5
|
50 |
-
* @return void
|
51 |
-
*/
|
52 |
-
public function admin_menus() {
|
53 |
-
$display_version = WCAL_VERSION;
|
54 |
-
|
55 |
-
// About Page
|
56 |
-
add_dashboard_page(
|
57 |
-
sprintf( esc_html__( 'Welcome to Abandoned Cart Lite %s', 'woocommerce-ac' ), $display_version ),
|
58 |
-
esc_html__( 'Welcome to Abandoned Cart Lite', 'woocommerce-ac' ),
|
59 |
-
$this->minimum_capability,
|
60 |
-
'wcal-about',
|
61 |
-
array( $this, 'about_screen' )
|
62 |
-
);
|
63 |
-
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Hide Individual Dashboard Pages
|
68 |
-
*
|
69 |
-
* @access public
|
70 |
-
* @since 4.5
|
71 |
-
* @return void
|
72 |
-
*/
|
73 |
-
public function admin_head() {
|
74 |
-
remove_submenu_page( 'index.php', 'wcal-about' );
|
75 |
-
}
|
76 |
-
|
77 |
-
/**
|
78 |
-
* Render About Screen
|
79 |
-
*
|
80 |
-
* @access public
|
81 |
-
* @since 4.5
|
82 |
-
* @return void
|
83 |
-
*/
|
84 |
-
public function about_screen() {
|
85 |
-
$display_version = WCAL_VERSION;
|
86 |
-
// Badge for welcome page
|
87 |
-
$badge_url = WCAL_PLUGIN_URL . 'assets/images/icon-256x256.png';
|
88 |
-
?>
|
89 |
-
<style>
|
90 |
-
.feature-section .feature-section-item {
|
91 |
-
float:left;
|
92 |
-
width:48%;
|
93 |
-
}
|
94 |
-
</style>
|
95 |
-
<div class="wrap about-wrap">
|
96 |
-
|
97 |
-
<?php $this->get_welcome_header() ?>
|
98 |
-
|
99 |
-
<div style="float:left;width: 80%;">
|
100 |
-
<p class="about-text" style="margin-right:20px;"><?php
|
101 |
-
printf(
|
102 |
-
__( "Thank you for activating or updating to the latest version of Abandoned Cart Lite! If you're a first time user, welcome! You're well on your way to start recovering your lost revenues." )
|
103 |
-
);
|
104 |
-
?></p>
|
105 |
-
</div>
|
106 |
-
<div class="wcal-badge"><img src="<?php echo $badge_url; ?>" style="width:150px;"/></div>
|
107 |
-
|
108 |
-
<p> </p>
|
109 |
-
|
110 |
-
<div class="feature-section clearfix introduction">
|
111 |
-
|
112 |
-
<h3><?php esc_html_e( "Get Started with Abandoned Cart Lite", 'woocommerce-ac' ); ?></h3>
|
113 |
-
|
114 |
-
<div class="video feature-section-item" style="float:left;padding-right:10px;">
|
115 |
-
<img src="<?php echo WCAL_PLUGIN_URL . '/assets/images/abandoned-cart-lite-email-templates.png' ?>"
|
116 |
-
alt="<?php esc_attr_e( 'WooCommerce Abandoned Cart Lite', 'woocommerce-ac' ); ?>" style="width:600px;">
|
117 |
-
</div>
|
118 |
-
|
119 |
-
<div class="content feature-section-item last-feature">
|
120 |
-
<h3><?php esc_html_e( 'Activate Email Template', 'woocommerce-ac' ); ?></h3>
|
121 |
-
|
122 |
-
<p><?php esc_html_e( 'To start sending out abandoned cart notification emails, simply activate the email template from under WooCommerce -> Abandoned Carts -> Email Templates page.', 'woocommerce-ac' ); ?></p>
|
123 |
-
<a href="admin.php?page=woocommerce_ac_page&action=emailtemplates" target="_blank" class="button-secondary">
|
124 |
-
<?php esc_html_e( 'Click Here to go to Email Templates page', 'woocommerce-ac' ); ?>
|
125 |
-
<span class="dashicons dashicons-external"></span>
|
126 |
-
</a>
|
127 |
-
</div>
|
128 |
-
</div>
|
129 |
-
|
130 |
-
<!-- /.intro-section -->
|
131 |
-
|
132 |
-
<div class="content">
|
133 |
-
|
134 |
-
<h3><?php esc_html_e( "Know more about Abandoned Cart Pro", 'woocommerce-ac' ); ?></h3>
|
135 |
-
|
136 |
-
<p><?php _e( 'The Abandoned Cart Pro plugin gives you features where you are able to recover more sales compared to the Lite plugin. Here are some notable features the Pro version provides.' ); ?></p>
|
137 |
-
|
138 |
-
<div class="feature-section clearfix introduction">
|
139 |
-
<div class="video feature-section-item" style="float:left;padding-right:10px;">
|
140 |
-
<img src="https://www.tychesoftwares.com/wp-content/uploads/2017/08/atc_frontend.png"
|
141 |
-
alt="<?php esc_attr_e( 'WooCommerce Abandoned Cart Lite', 'woocommerce-ac' ); ?>" style="width:500px;">
|
142 |
-
</div>
|
143 |
-
|
144 |
-
<div class="content feature-section-item last-feature">
|
145 |
-
<h3><?php esc_html_e( 'Capture Visitor Emails on click of Add to Cart button', 'woocommerce-ac' ); ?></h3>
|
146 |
-
|
147 |
-
<p><?php esc_html_e( 'The ability to capture the email address early in the order process is very important to reduce cart abandonment by unknown users as well as to be able to recover their carts if they abandon it. This ultimately leads to increase in your store sales.', 'woocommerce-ac' ); ?></p>
|
148 |
-
<a href="https://www.tychesoftwares.com/capture-guest-user-email-address-before-checkout-page-with-woocommerce-abandoned-cart-pro/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank" class="button-secondary">
|
149 |
-
<?php esc_html_e( 'Learn More', 'woocommerce-ac' ); ?>
|
150 |
-
<span class="dashicons dashicons-external"></span>
|
151 |
-
</a>
|
152 |
-
</div>
|
153 |
-
</div>
|
154 |
-
|
155 |
-
<div class="feature-section clearfix">
|
156 |
-
<div class="content feature-section-item">
|
157 |
-
|
158 |
-
<h3><?php esc_html_e( 'Set different cut-off times for visitors & logged-in users', 'woocommerce-ac' ); ?></h3>
|
159 |
-
|
160 |
-
<p><?php esc_html_e( 'The provision for setting two separate cut-off times for different roles is mainly because sometimes if the store admin wants the visitor carts to be captured earlier than the registered user carts, then these different settings can play an important role.', 'woocommerce-ac' ); ?></p>
|
161 |
-
<a href="https://www.tychesoftwares.com/capturing-abandoned-carts-woocommerce-abandoned-cart-pro-plugin/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank" class="button-secondary">
|
162 |
-
<?php esc_html_e( 'Learn More', 'woocommerce-ac' ); ?>
|
163 |
-
<span class="dashicons dashicons-external"></span>
|
164 |
-
</a>
|
165 |
-
</div>
|
166 |
-
|
167 |
-
<div class="content feature-section-item last-feature">
|
168 |
-
<img src="<?php echo WCAL_PLUGIN_URL . 'assets/images/abandon-cart-cut-off-time.png'; ?>" alt="<?php esc_attr_e( 'WooCommerce Abandoned Cart Lite', 'woocommerce-ac' ); ?>" style="width:450px;">
|
169 |
-
</div>
|
170 |
-
</div>
|
171 |
-
|
172 |
-
|
173 |
-
<div class="feature-section clearfix introduction">
|
174 |
-
<div class="video feature-section-item" style="float:left;padding-right:10px;">
|
175 |
-
<img src="<?php echo WCAL_PLUGIN_URL . 'assets/images/email-templates-send-time.png'; ?>" alt="<?php esc_attr_e( 'WooCommerce Abandoned Cart Lite', 'woocommerce-ac' ); ?>" style="width:450px;">
|
176 |
-
</div>
|
177 |
-
|
178 |
-
<div class="content feature-section-item last-feature">
|
179 |
-
<h3><?php esc_html_e( 'Send abandoned cart recovery email in minutes of cart being abandoned', 'woocommerce-ac' ); ?></h3>
|
180 |
-
|
181 |
-
<p><?php esc_html_e( 'The ability to send the abandoned cart recovery email within first few minutes of cart being abandoned is a big advantage. In the Lite plugin, the earliest an email can be sent is after 1 hour. Whereas in the Pro version, the first recovery email gets sent 15 minutes after the cart is abandoned. This increases the recovery chances manifold.', 'woocommerce-ac' ); ?></p>
|
182 |
-
<a href="https://www.tychesoftwares.com/understanding-the-default-email-templates-of-abandoned-cart-pro-for-woocommerce-plugin/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank" class="button-secondary">
|
183 |
-
<?php esc_html_e( 'Learn More', 'woocommerce-ac' ); ?>
|
184 |
-
<span class="dashicons dashicons-external"></span>
|
185 |
-
</a>
|
186 |
-
</div>
|
187 |
-
</div>
|
188 |
-
|
189 |
-
<div class="feature-section clearfix">
|
190 |
-
<div class="content feature-section-item">
|
191 |
-
|
192 |
-
<h3><?php esc_html_e( 'Full range of merge tags that allow you to personalize the abandoned cart email', 'woocommerce-ac' ); ?></h3>
|
193 |
-
|
194 |
-
<p><?php esc_html_e( 'The Lite version has only 3 merge tags available to personalize the abandoned cart recovery emails. The Pro version instead, has 20 different merge tags that can be used effectively to personalize each email that gets sent out to the customers for recovering their abandoned carts.', 'woocommerce-ac' ); ?></p>
|
195 |
-
<a href="https://www.tychesoftwares.com/understanding-the-default-email-templates-of-abandoned-cart-pro-for-woocommerce-plugin/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank" class="button-secondary">
|
196 |
-
<?php esc_html_e( 'Learn More', 'woocommerce-ac' ); ?>
|
197 |
-
<span class="dashicons dashicons-external"></span>
|
198 |
-
</a>
|
199 |
-
</div>
|
200 |
-
|
201 |
-
<div class="content feature-section-item last-feature">
|
202 |
-
<img src="https://www.tychesoftwares.com/wp-content/uploads/2016/10/drop-down-of-AC.png" alt="<?php esc_attr_e( 'WooCommerce Abandoned Cart Lite', 'woocommerce-ac' ); ?>" style="width:450px;">
|
203 |
-
</div>
|
204 |
-
</div>
|
205 |
-
|
206 |
-
<a href="https://www.tychesoftwares.com/differences-between-pro-and-lite-versions-of-abandoned-cart-for-woocommerce-plugin/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank" class="button-secondary">
|
207 |
-
<?php esc_html_e( 'View full list of differences between Lite & Pro plugin', 'woocommerce-ac' ); ?>
|
208 |
-
<span class="dashicons dashicons-external"></span>
|
209 |
-
</a>
|
210 |
-
</div>
|
211 |
-
|
212 |
-
<div class="feature-section clearfix">
|
213 |
-
|
214 |
-
<div class="content feature-section-item">
|
215 |
-
|
216 |
-
<h3><?php esc_html_e( 'Getting to Know Tyche Softwares', 'woocommerce-ac' ); ?></h3>
|
217 |
-
|
218 |
-
<ul class="ul-disc">
|
219 |
-
<li><a href="https://tychesoftwares.com/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank"><?php esc_html_e( 'Visit the Tyche Softwares Website', 'woocommerce-ac' ); ?></a></li>
|
220 |
-
<li><a href="https://tychesoftwares.com/premium-plugins/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank"><?php esc_html_e( 'View all Premium Plugins', 'woocommerce-ac' ); ?></a>
|
221 |
-
<ul class="ul-disc">
|
222 |
-
<li><a href="https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank">Abandoned Cart Pro Plugin for WooCommerce</a></li>
|
223 |
-
<li><a href="https://www.tychesoftwares.com/store/premium-plugins/woocommerce-booking-plugin/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank">Booking & Appointment Plugin for WooCommerce</a></li>
|
224 |
-
<li><a href="https://www.tychesoftwares.com/store/premium-plugins/order-delivery-date-for-woocommerce-pro-21/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank">Order Delivery Date for WooCommerce</a></li>
|
225 |
-
<li><a href="https://www.tychesoftwares.com/store/premium-plugins/product-delivery-date-pro-for-woocommerce/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank">Product Delivery Date for WooCommerce</a></li>
|
226 |
-
<li><a href="https://www.tychesoftwares.com/store/premium-plugins/deposits-for-woocommerce/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank">Deposits for WooCommerce</a></li>
|
227 |
-
</ul>
|
228 |
-
</li>
|
229 |
-
<li><a href="https://tychesoftwares.com/about/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank"><?php esc_html_e( 'Meet the team', 'woocommerce-ac' ); ?></a></li>
|
230 |
-
</ul>
|
231 |
-
|
232 |
-
</div>
|
233 |
-
|
234 |
-
|
235 |
-
<div class="content feature-section-item">
|
236 |
-
|
237 |
-
<h3><?php esc_html_e( 'Current Offers', 'woocommerce-ac' ); ?></h3>
|
238 |
-
|
239 |
-
<p>Buy all our <a href="https://tychesoftwares.com/premium-plugins/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank">premium plugins</a> at 30% off till 31st December 2017</p>
|
240 |
-
|
241 |
-
</div>
|
242 |
-
|
243 |
-
</div>
|
244 |
-
<!-- /.feature-section -->
|
245 |
-
|
246 |
-
</div>
|
247 |
-
<?php
|
248 |
-
|
249 |
-
update_option( 'wcal_welcome_page_shown', 'yes' );
|
250 |
-
update_option( 'wcal_welcome_page_shown_time', current_time( 'timestamp' ) );
|
251 |
-
}
|
252 |
-
|
253 |
-
|
254 |
-
/**
|
255 |
-
* The header section for the welcome screen.
|
256 |
-
*
|
257 |
-
* @since 4.5
|
258 |
-
*/
|
259 |
-
public function get_welcome_header() {
|
260 |
-
// Badge for welcome page
|
261 |
-
$badge_url = WCAL_PLUGIN_URL . 'assets/images/icon-256x256.png';
|
262 |
-
?>
|
263 |
-
<h1 class="welcome-h1"><?php echo get_admin_page_title(); ?></h1>
|
264 |
-
<?php $this->social_media_elements(); ?>
|
265 |
-
|
266 |
-
<?php }
|
267 |
-
|
268 |
-
|
269 |
-
/**
|
270 |
-
* Social Media Like Buttons
|
271 |
-
*
|
272 |
-
* Various social media elements to Tyche Softwares
|
273 |
-
*/
|
274 |
-
public function social_media_elements() { ?>
|
275 |
-
|
276 |
-
<div class="social-items-wrap">
|
277 |
-
|
278 |
-
<iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2Ftychesoftwares&send=false&layout=button_count&width=100&show_faces=false&font&colorscheme=light&action=like&height=21&appId=220596284639969"
|
279 |
-
scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;"
|
280 |
-
allowTransparency="true"></iframe>
|
281 |
-
|
282 |
-
<a href="https://twitter.com/tychesoftwares" class="twitter-follow-button" data-show-count="false"><?php
|
283 |
-
printf(
|
284 |
-
esc_html_e( 'Follow %s', 'tychesoftwares' ),
|
285 |
-
'@tychesoftwares'
|
286 |
-
);
|
287 |
-
?></a>
|
288 |
-
<script>!function (d, s, id) {
|
289 |
-
var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https';
|
290 |
-
if (!d.getElementById(id)) {
|
291 |
-
js = d.createElement(s);
|
292 |
-
js.id = id;
|
293 |
-
js.src = p + '://platform.twitter.com/widgets.js';
|
294 |
-
fjs.parentNode.insertBefore(js, fjs);
|
295 |
-
}
|
296 |
-
}(document, 'script', 'twitter-wjs');
|
297 |
-
</script>
|
298 |
-
|
299 |
-
</div>
|
300 |
-
<!--/.social-items-wrap -->
|
301 |
-
|
302 |
-
<?php
|
303 |
-
}
|
304 |
-
|
305 |
-
|
306 |
-
/**
|
307 |
-
* Sends user to the Welcome page on first activation of Abandoned Cart Lite as well as each
|
308 |
-
* time Abandoned Cart Lite is upgraded to a new version
|
309 |
-
*
|
310 |
-
* @access public
|
311 |
-
* @since 4.5
|
312 |
-
*
|
313 |
-
* @return void
|
314 |
-
*/
|
315 |
-
public function welcome() {
|
316 |
-
|
317 |
-
// Bail if activating from network, or bulk
|
318 |
-
if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
|
319 |
-
return;
|
320 |
-
}
|
321 |
-
|
322 |
-
if( !get_option( 'wcal_welcome_page_shown' ) ) {
|
323 |
-
wp_safe_redirect( admin_url( 'index.php?page=wcal-about' ) );
|
324 |
-
exit;
|
325 |
-
}
|
326 |
-
}
|
327 |
-
|
328 |
-
}
|
329 |
-
|
330 |
-
new Wcal_Welcome();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Abandoned Cart Lite Welcome Page Class
|
5 |
+
*
|
6 |
+
* Displays on plugin activation
|
7 |
+
*/
|
8 |
+
|
9 |
+
// Exit if accessed directly.
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
+
exit;
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Wcal_Welcome Class
|
16 |
+
*
|
17 |
+
* A general class for About page.
|
18 |
+
*
|
19 |
+
* @since 4.5
|
20 |
+
*/
|
21 |
+
class Wcal_Welcome {
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @var string The capability users should have to view the page
|
25 |
+
*/
|
26 |
+
public $minimum_capability = 'manage_options';
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Get things started
|
30 |
+
*
|
31 |
+
* @since 4.5
|
32 |
+
*/
|
33 |
+
public function __construct() {
|
34 |
+
|
35 |
+
add_action( 'admin_menu', array( $this, 'admin_menus' ) );
|
36 |
+
add_action( 'admin_head', array( $this, 'admin_head' ) );
|
37 |
+
|
38 |
+
if ( !isset( $_GET[ 'page' ] ) ||
|
39 |
+
( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] != 'wcal-about' ) ) {
|
40 |
+
add_action( 'admin_init', array( $this, 'welcome' ) );
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Register the Dashboard Page which is later hidden but this pages
|
46 |
+
* is used to render the Welcome page.
|
47 |
+
*
|
48 |
+
* @access public
|
49 |
+
* @since 4.5
|
50 |
+
* @return void
|
51 |
+
*/
|
52 |
+
public function admin_menus() {
|
53 |
+
$display_version = WCAL_VERSION;
|
54 |
+
|
55 |
+
// About Page
|
56 |
+
add_dashboard_page(
|
57 |
+
sprintf( esc_html__( 'Welcome to Abandoned Cart Lite %s', 'woocommerce-ac' ), $display_version ),
|
58 |
+
esc_html__( 'Welcome to Abandoned Cart Lite', 'woocommerce-ac' ),
|
59 |
+
$this->minimum_capability,
|
60 |
+
'wcal-about',
|
61 |
+
array( $this, 'about_screen' )
|
62 |
+
);
|
63 |
+
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Hide Individual Dashboard Pages
|
68 |
+
*
|
69 |
+
* @access public
|
70 |
+
* @since 4.5
|
71 |
+
* @return void
|
72 |
+
*/
|
73 |
+
public function admin_head() {
|
74 |
+
remove_submenu_page( 'index.php', 'wcal-about' );
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Render About Screen
|
79 |
+
*
|
80 |
+
* @access public
|
81 |
+
* @since 4.5
|
82 |
+
* @return void
|
83 |
+
*/
|
84 |
+
public function about_screen() {
|
85 |
+
$display_version = WCAL_VERSION;
|
86 |
+
// Badge for welcome page
|
87 |
+
$badge_url = WCAL_PLUGIN_URL . 'assets/images/icon-256x256.png';
|
88 |
+
?>
|
89 |
+
<style>
|
90 |
+
.feature-section .feature-section-item {
|
91 |
+
float:left;
|
92 |
+
width:48%;
|
93 |
+
}
|
94 |
+
</style>
|
95 |
+
<div class="wrap about-wrap">
|
96 |
+
|
97 |
+
<?php $this->get_welcome_header() ?>
|
98 |
+
|
99 |
+
<div style="float:left;width: 80%;">
|
100 |
+
<p class="about-text" style="margin-right:20px;"><?php
|
101 |
+
printf(
|
102 |
+
__( "Thank you for activating or updating to the latest version of Abandoned Cart Lite! If you're a first time user, welcome! You're well on your way to start recovering your lost revenues." )
|
103 |
+
);
|
104 |
+
?></p>
|
105 |
+
</div>
|
106 |
+
<div class="wcal-badge"><img src="<?php echo $badge_url; ?>" style="width:150px;"/></div>
|
107 |
+
|
108 |
+
<p> </p>
|
109 |
+
|
110 |
+
<div class="feature-section clearfix introduction">
|
111 |
+
|
112 |
+
<h3><?php esc_html_e( "Get Started with Abandoned Cart Lite", 'woocommerce-ac' ); ?></h3>
|
113 |
+
|
114 |
+
<div class="video feature-section-item" style="float:left;padding-right:10px;">
|
115 |
+
<img src="<?php echo WCAL_PLUGIN_URL . '/assets/images/abandoned-cart-lite-email-templates.png' ?>"
|
116 |
+
alt="<?php esc_attr_e( 'WooCommerce Abandoned Cart Lite', 'woocommerce-ac' ); ?>" style="width:600px;">
|
117 |
+
</div>
|
118 |
+
|
119 |
+
<div class="content feature-section-item last-feature">
|
120 |
+
<h3><?php esc_html_e( 'Activate Email Template', 'woocommerce-ac' ); ?></h3>
|
121 |
+
|
122 |
+
<p><?php esc_html_e( 'To start sending out abandoned cart notification emails, simply activate the email template from under WooCommerce -> Abandoned Carts -> Email Templates page.', 'woocommerce-ac' ); ?></p>
|
123 |
+
<a href="admin.php?page=woocommerce_ac_page&action=emailtemplates" target="_blank" class="button-secondary">
|
124 |
+
<?php esc_html_e( 'Click Here to go to Email Templates page', 'woocommerce-ac' ); ?>
|
125 |
+
<span class="dashicons dashicons-external"></span>
|
126 |
+
</a>
|
127 |
+
</div>
|
128 |
+
</div>
|
129 |
+
|
130 |
+
<!-- /.intro-section -->
|
131 |
+
|
132 |
+
<div class="content">
|
133 |
+
|
134 |
+
<h3><?php esc_html_e( "Know more about Abandoned Cart Pro", 'woocommerce-ac' ); ?></h3>
|
135 |
+
|
136 |
+
<p><?php _e( 'The Abandoned Cart Pro plugin gives you features where you are able to recover more sales compared to the Lite plugin. Here are some notable features the Pro version provides.' ); ?></p>
|
137 |
+
|
138 |
+
<div class="feature-section clearfix introduction">
|
139 |
+
<div class="video feature-section-item" style="float:left;padding-right:10px;">
|
140 |
+
<img src="https://www.tychesoftwares.com/wp-content/uploads/2017/08/atc_frontend.png"
|
141 |
+
alt="<?php esc_attr_e( 'WooCommerce Abandoned Cart Lite', 'woocommerce-ac' ); ?>" style="width:500px;">
|
142 |
+
</div>
|
143 |
+
|
144 |
+
<div class="content feature-section-item last-feature">
|
145 |
+
<h3><?php esc_html_e( 'Capture Visitor Emails on click of Add to Cart button', 'woocommerce-ac' ); ?></h3>
|
146 |
+
|
147 |
+
<p><?php esc_html_e( 'The ability to capture the email address early in the order process is very important to reduce cart abandonment by unknown users as well as to be able to recover their carts if they abandon it. This ultimately leads to increase in your store sales.', 'woocommerce-ac' ); ?></p>
|
148 |
+
<a href="https://www.tychesoftwares.com/capture-guest-user-email-address-before-checkout-page-with-woocommerce-abandoned-cart-pro/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank" class="button-secondary">
|
149 |
+
<?php esc_html_e( 'Learn More', 'woocommerce-ac' ); ?>
|
150 |
+
<span class="dashicons dashicons-external"></span>
|
151 |
+
</a>
|
152 |
+
</div>
|
153 |
+
</div>
|
154 |
+
|
155 |
+
<div class="feature-section clearfix">
|
156 |
+
<div class="content feature-section-item">
|
157 |
+
|
158 |
+
<h3><?php esc_html_e( 'Set different cut-off times for visitors & logged-in users', 'woocommerce-ac' ); ?></h3>
|
159 |
+
|
160 |
+
<p><?php esc_html_e( 'The provision for setting two separate cut-off times for different roles is mainly because sometimes if the store admin wants the visitor carts to be captured earlier than the registered user carts, then these different settings can play an important role.', 'woocommerce-ac' ); ?></p>
|
161 |
+
<a href="https://www.tychesoftwares.com/capturing-abandoned-carts-woocommerce-abandoned-cart-pro-plugin/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank" class="button-secondary">
|
162 |
+
<?php esc_html_e( 'Learn More', 'woocommerce-ac' ); ?>
|
163 |
+
<span class="dashicons dashicons-external"></span>
|
164 |
+
</a>
|
165 |
+
</div>
|
166 |
+
|
167 |
+
<div class="content feature-section-item last-feature">
|
168 |
+
<img src="<?php echo WCAL_PLUGIN_URL . 'assets/images/abandon-cart-cut-off-time.png'; ?>" alt="<?php esc_attr_e( 'WooCommerce Abandoned Cart Lite', 'woocommerce-ac' ); ?>" style="width:450px;">
|
169 |
+
</div>
|
170 |
+
</div>
|
171 |
+
|
172 |
+
|
173 |
+
<div class="feature-section clearfix introduction">
|
174 |
+
<div class="video feature-section-item" style="float:left;padding-right:10px;">
|
175 |
+
<img src="<?php echo WCAL_PLUGIN_URL . 'assets/images/email-templates-send-time.png'; ?>" alt="<?php esc_attr_e( 'WooCommerce Abandoned Cart Lite', 'woocommerce-ac' ); ?>" style="width:450px;">
|
176 |
+
</div>
|
177 |
+
|
178 |
+
<div class="content feature-section-item last-feature">
|
179 |
+
<h3><?php esc_html_e( 'Send abandoned cart recovery email in minutes of cart being abandoned', 'woocommerce-ac' ); ?></h3>
|
180 |
+
|
181 |
+
<p><?php esc_html_e( 'The ability to send the abandoned cart recovery email within first few minutes of cart being abandoned is a big advantage. In the Lite plugin, the earliest an email can be sent is after 1 hour. Whereas in the Pro version, the first recovery email gets sent 15 minutes after the cart is abandoned. This increases the recovery chances manifold.', 'woocommerce-ac' ); ?></p>
|
182 |
+
<a href="https://www.tychesoftwares.com/understanding-the-default-email-templates-of-abandoned-cart-pro-for-woocommerce-plugin/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank" class="button-secondary">
|
183 |
+
<?php esc_html_e( 'Learn More', 'woocommerce-ac' ); ?>
|
184 |
+
<span class="dashicons dashicons-external"></span>
|
185 |
+
</a>
|
186 |
+
</div>
|
187 |
+
</div>
|
188 |
+
|
189 |
+
<div class="feature-section clearfix">
|
190 |
+
<div class="content feature-section-item">
|
191 |
+
|
192 |
+
<h3><?php esc_html_e( 'Full range of merge tags that allow you to personalize the abandoned cart email', 'woocommerce-ac' ); ?></h3>
|
193 |
+
|
194 |
+
<p><?php esc_html_e( 'The Lite version has only 3 merge tags available to personalize the abandoned cart recovery emails. The Pro version instead, has 20 different merge tags that can be used effectively to personalize each email that gets sent out to the customers for recovering their abandoned carts.', 'woocommerce-ac' ); ?></p>
|
195 |
+
<a href="https://www.tychesoftwares.com/understanding-the-default-email-templates-of-abandoned-cart-pro-for-woocommerce-plugin/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank" class="button-secondary">
|
196 |
+
<?php esc_html_e( 'Learn More', 'woocommerce-ac' ); ?>
|
197 |
+
<span class="dashicons dashicons-external"></span>
|
198 |
+
</a>
|
199 |
+
</div>
|
200 |
+
|
201 |
+
<div class="content feature-section-item last-feature">
|
202 |
+
<img src="https://www.tychesoftwares.com/wp-content/uploads/2016/10/drop-down-of-AC.png" alt="<?php esc_attr_e( 'WooCommerce Abandoned Cart Lite', 'woocommerce-ac' ); ?>" style="width:450px;">
|
203 |
+
</div>
|
204 |
+
</div>
|
205 |
+
|
206 |
+
<a href="https://www.tychesoftwares.com/differences-between-pro-and-lite-versions-of-abandoned-cart-for-woocommerce-plugin/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank" class="button-secondary">
|
207 |
+
<?php esc_html_e( 'View full list of differences between Lite & Pro plugin', 'woocommerce-ac' ); ?>
|
208 |
+
<span class="dashicons dashicons-external"></span>
|
209 |
+
</a>
|
210 |
+
</div>
|
211 |
+
|
212 |
+
<div class="feature-section clearfix">
|
213 |
+
|
214 |
+
<div class="content feature-section-item">
|
215 |
+
|
216 |
+
<h3><?php esc_html_e( 'Getting to Know Tyche Softwares', 'woocommerce-ac' ); ?></h3>
|
217 |
+
|
218 |
+
<ul class="ul-disc">
|
219 |
+
<li><a href="https://tychesoftwares.com/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank"><?php esc_html_e( 'Visit the Tyche Softwares Website', 'woocommerce-ac' ); ?></a></li>
|
220 |
+
<li><a href="https://tychesoftwares.com/premium-plugins/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank"><?php esc_html_e( 'View all Premium Plugins', 'woocommerce-ac' ); ?></a>
|
221 |
+
<ul class="ul-disc">
|
222 |
+
<li><a href="https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank">Abandoned Cart Pro Plugin for WooCommerce</a></li>
|
223 |
+
<li><a href="https://www.tychesoftwares.com/store/premium-plugins/woocommerce-booking-plugin/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank">Booking & Appointment Plugin for WooCommerce</a></li>
|
224 |
+
<li><a href="https://www.tychesoftwares.com/store/premium-plugins/order-delivery-date-for-woocommerce-pro-21/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank">Order Delivery Date for WooCommerce</a></li>
|
225 |
+
<li><a href="https://www.tychesoftwares.com/store/premium-plugins/product-delivery-date-pro-for-woocommerce/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank">Product Delivery Date for WooCommerce</a></li>
|
226 |
+
<li><a href="https://www.tychesoftwares.com/store/premium-plugins/deposits-for-woocommerce/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank">Deposits for WooCommerce</a></li>
|
227 |
+
</ul>
|
228 |
+
</li>
|
229 |
+
<li><a href="https://tychesoftwares.com/about/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank"><?php esc_html_e( 'Meet the team', 'woocommerce-ac' ); ?></a></li>
|
230 |
+
</ul>
|
231 |
+
|
232 |
+
</div>
|
233 |
+
|
234 |
+
|
235 |
+
<div class="content feature-section-item">
|
236 |
+
|
237 |
+
<h3><?php esc_html_e( 'Current Offers', 'woocommerce-ac' ); ?></h3>
|
238 |
+
|
239 |
+
<p>Buy all our <a href="https://tychesoftwares.com/premium-plugins/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank">premium plugins</a> at 30% off till 31st December 2017</p>
|
240 |
+
|
241 |
+
</div>
|
242 |
+
|
243 |
+
</div>
|
244 |
+
<!-- /.feature-section -->
|
245 |
+
|
246 |
+
</div>
|
247 |
+
<?php
|
248 |
+
|
249 |
+
update_option( 'wcal_welcome_page_shown', 'yes' );
|
250 |
+
update_option( 'wcal_welcome_page_shown_time', current_time( 'timestamp' ) );
|
251 |
+
}
|
252 |
+
|
253 |
+
|
254 |
+
/**
|
255 |
+
* The header section for the welcome screen.
|
256 |
+
*
|
257 |
+
* @since 4.5
|
258 |
+
*/
|
259 |
+
public function get_welcome_header() {
|
260 |
+
// Badge for welcome page
|
261 |
+
$badge_url = WCAL_PLUGIN_URL . 'assets/images/icon-256x256.png';
|
262 |
+
?>
|
263 |
+
<h1 class="welcome-h1"><?php echo get_admin_page_title(); ?></h1>
|
264 |
+
<?php $this->social_media_elements(); ?>
|
265 |
+
|
266 |
+
<?php }
|
267 |
+
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Social Media Like Buttons
|
271 |
+
*
|
272 |
+
* Various social media elements to Tyche Softwares
|
273 |
+
*/
|
274 |
+
public function social_media_elements() { ?>
|
275 |
+
|
276 |
+
<div class="social-items-wrap">
|
277 |
+
|
278 |
+
<iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2Ftychesoftwares&send=false&layout=button_count&width=100&show_faces=false&font&colorscheme=light&action=like&height=21&appId=220596284639969"
|
279 |
+
scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;"
|
280 |
+
allowTransparency="true"></iframe>
|
281 |
+
|
282 |
+
<a href="https://twitter.com/tychesoftwares" class="twitter-follow-button" data-show-count="false"><?php
|
283 |
+
printf(
|
284 |
+
esc_html_e( 'Follow %s', 'tychesoftwares' ),
|
285 |
+
'@tychesoftwares'
|
286 |
+
);
|
287 |
+
?></a>
|
288 |
+
<script>!function (d, s, id) {
|
289 |
+
var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https';
|
290 |
+
if (!d.getElementById(id)) {
|
291 |
+
js = d.createElement(s);
|
292 |
+
js.id = id;
|
293 |
+
js.src = p + '://platform.twitter.com/widgets.js';
|
294 |
+
fjs.parentNode.insertBefore(js, fjs);
|
295 |
+
}
|
296 |
+
}(document, 'script', 'twitter-wjs');
|
297 |
+
</script>
|
298 |
+
|
299 |
+
</div>
|
300 |
+
<!--/.social-items-wrap -->
|
301 |
+
|
302 |
+
<?php
|
303 |
+
}
|
304 |
+
|
305 |
+
|
306 |
+
/**
|
307 |
+
* Sends user to the Welcome page on first activation of Abandoned Cart Lite as well as each
|
308 |
+
* time Abandoned Cart Lite is upgraded to a new version
|
309 |
+
*
|
310 |
+
* @access public
|
311 |
+
* @since 4.5
|
312 |
+
*
|
313 |
+
* @return void
|
314 |
+
*/
|
315 |
+
public function welcome() {
|
316 |
+
|
317 |
+
// Bail if activating from network, or bulk
|
318 |
+
if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
|
319 |
+
return;
|
320 |
+
}
|
321 |
+
|
322 |
+
if( !get_option( 'wcal_welcome_page_shown' ) ) {
|
323 |
+
wp_safe_redirect( admin_url( 'index.php?page=wcal-about' ) );
|
324 |
+
exit;
|
325 |
+
}
|
326 |
+
}
|
327 |
+
|
328 |
+
}
|
329 |
+
|
330 |
+
new Wcal_Welcome();
|
woocommerce-abandoned-cart/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.9.
|
8 |
Stable tag: trunk
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -188,6 +188,24 @@ You can refer **[here](https://www.tychesoftwares.com/differences-between-pro-an
|
|
188 |
|
189 |
== Changelog ==
|
190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
= 4.5 (28.12-2017) =
|
192 |
|
193 |
* This version has 1 bug fix.
|
4 |
Tags: abandon cart, cart recovery, increase woocommerce conversion rate , recover woocommerce cart, increase sales with woocommerce
|
5 |
Author URI: https://www.tychesoftwares.com/
|
6 |
Requires at least: 1.3
|
7 |
+
Tested up to: 4.9.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.6 (31.01-2018) =
|
192 |
+
|
193 |
+
* This version has 7 bugs fixes.
|
194 |
+
|
195 |
+
* Bug Fixed - When the guest user places the order after the "Cart abandoned cut off time" then the plugin was capturing the blank records on Abandoned Orders tab. This has been fixed.
|
196 |
+
|
197 |
+
* Bug Fixed - Compatibility issues pertaining to PHP 7.2 has been fixed.
|
198 |
+
|
199 |
+
* Bug Fixed - Fixed some minor bugs related to notices coming in Debug Log.
|
200 |
+
|
201 |
+
* Bug Fixed - Fixed issue related to error occurring when clicked on cart link from abandoned cart reminder email.
|
202 |
+
|
203 |
+
* Bug Fixed - When the user places an order and goes to the order received page, blank carts were added in the database. So, twice entries had been created under Recovered Orders tab. This issue has been fixed.
|
204 |
+
|
205 |
+
* Bug Fixed - If "Email admin On Order Recovery" setting is enabled and admin of the store create manual order from WooCommerce -> Orders page then Recovery Email was getting sent to the Admin. This has been fixed.
|
206 |
+
|
207 |
+
* Bug Fixed - With the PHP 7.1.7, Abandoned cart reminder emails were not being sent. This issue has been fixed now.
|
208 |
+
|
209 |
= 4.5 (28.12-2017) =
|
210 |
|
211 |
* This version has 1 bug fix.
|
woocommerce-abandoned-cart/woocommerce-ac.php
CHANGED
@@ -1,3377 +1,3335 @@
|
|
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 |
-
* 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
|
17 |
-
register_uninstall_hook( __FILE__, 'woocommerce_ac_delete_lite' );
|
18 |
-
|
19 |
-
require_once( "includes/wcal_class-guest.php" );
|
20 |
-
require_once( "includes/wcal_default-settings.php" );
|
21 |
-
require_once( "includes/wcal_actions.php" );
|
22 |
-
require_once( "includes/classes/class-wcal-aes.php" );
|
23 |
-
require_once( "includes/classes/class-wcal-aes-counter.php" );
|
24 |
-
require_once( "includes/wcal-common.php" );
|
25 |
-
require_once( "includes/wcal_ts_tracking.php");
|
26 |
-
require_once( "includes/wcal_admin_notice.php");
|
27 |
-
|
28 |
-
if ( is_admin() ) {
|
29 |
-
require_once( 'includes/welcome.php' );
|
30 |
-
|
31 |
-
define( 'WCAL_VERSION', wcal_common::wcal_get_version() );
|
32 |
-
|
33 |
-
define( 'WCAL_PLUGIN_URL', wcal_common::wcal_get_plugin_url() );
|
34 |
-
}
|
35 |
-
|
36 |
-
// Add a new interval of 15 minutes
|
37 |
-
add_filter( 'cron_schedules', 'wcal_add_cron_schedule' );
|
38 |
-
|
39 |
-
function wcal_add_cron_schedule( $schedules ) {
|
40 |
-
$schedules['15_minutes_lite'] = array(
|
41 |
-
'interval' => 900, // 15 minutes in seconds
|
42 |
-
'display' => __( 'Once Every Fifteen Minutes' ),
|
43 |
-
);
|
44 |
-
return $schedules;
|
45 |
-
}
|
46 |
-
// Schedule an action if it's not already scheduled
|
47 |
-
if ( ! wp_next_scheduled( 'woocommerce_ac_send_email_action' ) ) {
|
48 |
-
wp_schedule_event( time(), '15_minutes_lite', 'woocommerce_ac_send_email_action' );
|
49 |
-
}
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Run a cron once in week to delete old records for lockout
|
53 |
-
*/
|
54 |
-
function wcal_add_tracking_cron_schedule( $schedules ) {
|
55 |
-
$schedules[ 'daily_once' ] = array(
|
56 |
-
'interval' => 604800, // one week in seconds
|
57 |
-
'display' => __( 'Once in a Week', 'woocommerce-ac' )
|
58 |
-
);
|
59 |
-
return $schedules;
|
60 |
-
}
|
61 |
-
|
62 |
-
/* To capture the data from the client site */
|
63 |
-
if ( ! wp_next_scheduled( 'wcal_ts_tracker_send_event' ) ) {
|
64 |
-
wp_schedule_event( time(), 'daily_once', 'wcal_ts_tracker_send_event' );
|
65 |
-
}
|
66 |
-
|
67 |
-
// Hook into that action that'll fire every 15 minutes
|
68 |
-
add_action( 'woocommerce_ac_send_email_action', 'wcal_send_email_cron' );
|
69 |
-
|
70 |
-
function wcal_send_email_cron() {
|
71 |
-
//require_once( ABSPATH.'wp-content/plugins/woocommerce-abandoned-cart/cron/send_email.php' );
|
72 |
-
$plugin_dir_path = plugin_dir_path( __FILE__ );
|
73 |
-
require_once( $plugin_dir_path . 'cron/wcal_send_email.php' );
|
74 |
-
}
|
75 |
-
|
76 |
-
function woocommerce_ac_delete_lite() {
|
77 |
-
global $wpdb;
|
78 |
-
if ( ! is_multisite() ) {
|
79 |
-
$table_name_ac_abandoned_cart_history = $wpdb->prefix . "ac_abandoned_cart_history_lite";
|
80 |
-
$sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_abandoned_cart_history ;
|
81 |
-
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
82 |
-
$wpdb->get_results( $sql_ac_abandoned_cart_history );
|
83 |
-
|
84 |
-
$table_name_ac_email_templates = $wpdb->prefix . "ac_email_templates_lite";
|
85 |
-
$sql_ac_email_templates = "DROP TABLE " . $table_name_ac_email_templates ;
|
86 |
-
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
87 |
-
$wpdb->get_results( $sql_ac_email_templates );
|
88 |
-
|
89 |
-
$table_name_ac_sent_history = $wpdb->prefix . "ac_sent_history_lite";
|
90 |
-
$sql_ac_sent_history = "DROP TABLE " . $table_name_ac_sent_history ;
|
91 |
-
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
92 |
-
$wpdb->get_results( $sql_ac_sent_history );
|
93 |
-
|
94 |
-
$table_name_ac_guest_abandoned_cart_history = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
|
95 |
-
$sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_guest_abandoned_cart_history ;
|
96 |
-
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
97 |
-
$wpdb->get_results( $sql_ac_abandoned_cart_history );
|
98 |
-
|
99 |
-
$sql_table_user_meta_cart = "DELETE FROM `" . $wpdb->prefix . "usermeta` WHERE meta_key = '_woocommerce_persistent_cart'";
|
100 |
-
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
101 |
-
$wpdb->get_results( $sql_table_user_meta_cart );
|
102 |
-
|
103 |
-
$sql_table_user_meta_cart_modified = "DELETE FROM `" . $wpdb->prefix . "usermeta` WHERE meta_key = '_woocommerce_ac_modified_cart'";
|
104 |
-
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
105 |
-
$wpdb->get_results( $sql_table_user_meta_cart_modified );
|
106 |
-
} else {
|
107 |
-
$query = "SELECT blog_id FROM `".$wpdb->prefix."blogs`";
|
108 |
-
$results = $wpdb->get_results( $query );
|
109 |
-
|
110 |
-
foreach( $results as $key => $value ) {
|
111 |
-
$table_name_ac_abandoned_cart_history = $wpdb->prefix .$value->blog_id."_"."ac_abandoned_cart_history_lite";
|
112 |
-
$sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_abandoned_cart_history ;
|
113 |
-
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
114 |
-
$wpdb->get_results( $sql_ac_abandoned_cart_history );
|
115 |
-
|
116 |
-
$table_name_ac_email_templates = $wpdb->prefix .$value->blog_id."_"."ac_email_templates_lite";
|
117 |
-
$sql_ac_email_templates = "DROP TABLE " . $table_name_ac_email_templates ;
|
118 |
-
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
119 |
-
$wpdb->get_results( $sql_ac_email_templates );
|
120 |
-
|
121 |
-
$table_name_ac_sent_history = $wpdb->prefix .$value->blog_id."_"."ac_sent_history_lite";
|
122 |
-
$sql_ac_sent_history = "DROP TABLE " . $table_name_ac_sent_history ;
|
123 |
-
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
124 |
-
$wpdb->get_results( $sql_ac_sent_history );
|
125 |
-
|
126 |
-
$table_name_ac_guest_abandoned_cart_history = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
|
127 |
-
$sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_guest_abandoned_cart_history ;
|
128 |
-
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
129 |
-
$wpdb->get_results( $sql_ac_abandoned_cart_history );
|
130 |
-
|
131 |
-
$sql_table_user_meta_cart = "DELETE FROM `" . $wpdb->prefix.$value->blog_id."_"."usermeta` WHERE meta_key = '_woocommerce_persistent_cart'";
|
132 |
-
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
133 |
-
$wpdb->get_results( $sql_table_user_meta_cart );
|
134 |
-
|
135 |
-
$sql_table_user_meta_cart_modified = "DELETE FROM `" . $wpdb->prefix.$value->blog_id."_"."usermeta` WHERE meta_key = '_woocommerce_ac_modified_cart'";
|
136 |
-
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
137 |
-
$wpdb->get_results( $sql_table_user_meta_cart_modified );
|
138 |
-
}
|
139 |
-
}
|
140 |
-
delete_option( 'woocommerce_ac_email_body' );
|
141 |
-
delete_option( 'ac_lite_cart_abandoned_time' );
|
142 |
-
delete_option( 'ac_lite_email_admin_on_recovery' );
|
143 |
-
delete_option( 'ac_lite_settings_status' );
|
144 |
-
delete_option( 'woocommerce_ac_default_templates_installed' );
|
145 |
-
delete_option( 'wcal_security_key' );
|
146 |
-
delete_option( 'ac_lite_track_guest_cart_from_cart_page' );
|
147 |
-
delete_option( 'wcal_from_name' );
|
148 |
-
delete_option( 'wcal_from_email' );
|
149 |
-
delete_option( 'wcal_reply_email' );
|
150 |
-
|
151 |
-
delete_option( 'ac_security_key' );
|
152 |
-
delete_option( 'wcal_activate_time' );
|
153 |
-
delete_option( 'ac_lite_alter_table_queries' );
|
154 |
-
delete_option( 'ac_lite_delete_alter_table_queries' );
|
155 |
-
delete_option( 'wcal_allow_tracking' );
|
156 |
-
delete_option( 'wcal_ts_tracker_last_send' );
|
157 |
-
|
158 |
-
delete_option( 'wcal_welcome_page_shown_time' );
|
159 |
-
delete_option( 'wcal_welcome_page_shown' );
|
160 |
-
}
|
161 |
-
/**
|
162 |
-
* woocommerce_abandon_cart_lite class
|
163 |
-
**/
|
164 |
-
if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
165 |
-
|
166 |
-
class woocommerce_abandon_cart_lite {
|
167 |
-
var $one_hour;
|
168 |
-
var $three_hours;
|
169 |
-
var $six_hours;
|
170 |
-
var $twelve_hours;
|
171 |
-
var $one_day;
|
172 |
-
var $one_week;
|
173 |
-
var $duration_range_select = array();
|
174 |
-
var $start_end_dates = array();
|
175 |
-
|
176 |
-
public function __construct() {
|
177 |
-
$this->one_hour = 60 * 60;
|
178 |
-
$this->three_hours = 3 * $this->one_hour;
|
179 |
-
$this->six_hours = 6 * $this->one_hour;
|
180 |
-
$this->twelve_hours = 12 * $this->one_hour;
|
181 |
-
$this->one_day = 24 * $this->one_hour;
|
182 |
-
$this->one_week = 7 * $this->one_day;
|
183 |
-
$this->duration_range_select = array( 'yesterday' => 'Yesterday',
|
184 |
-
'today' => 'Today',
|
185 |
-
'last_seven' => 'Last 7 days',
|
186 |
-
'last_fifteen' => 'Last 15 days',
|
187 |
-
'last_thirty' => 'Last 30 days',
|
188 |
-
'last_ninety' => 'Last 90 days',
|
189 |
-
'last_year_days' => 'Last 365'
|
190 |
-
);
|
191 |
-
|
192 |
-
$this->start_end_dates = array( 'yesterday' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 24*60*60 ) ),
|
193 |
-
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) - 7*24*60*60 ) ) ),
|
194 |
-
'today' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ),
|
195 |
-
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
196 |
-
'last_seven' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 7*24*60*60 ) ),
|
197 |
-
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
198 |
-
'last_fifteen' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 15*24*60*60 ) ),
|
199 |
-
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
200 |
-
'last_thirty' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 30*24*60*60 ) ),
|
201 |
-
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
202 |
-
'last_ninety' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 90*24*60*60 ) ),
|
203 |
-
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
204 |
-
'last_year_days' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 365*24*60*60 ) ),
|
205 |
-
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) )
|
206 |
-
);
|
207 |
-
|
208 |
-
// Initialize settings
|
209 |
-
register_activation_hook ( __FILE__, array( &$this, 'wcal_activate' ) );
|
210 |
-
|
211 |
-
// WordPress Administration Menu
|
212 |
-
add_action ( 'admin_menu', array( &$this, 'wcal_admin_menu' ) );
|
213 |
-
|
214 |
-
// Actions to be done on cart update
|
215 |
-
add_action ( 'woocommerce_cart_updated', array( &$this, 'wcal_store_cart_timestamp' ) );
|
216 |
-
|
217 |
-
// delete added temp fields after order is placed
|
218 |
-
add_filter ( 'woocommerce_order_details_after_order_table', array( &$this, 'wcal_action_after_delivery_session' ) );
|
219 |
-
|
220 |
-
add_action ( 'admin_init', array( &$this, 'wcal_action_admin_init' ) );
|
221 |
-
|
222 |
-
// Update the options as per settings API
|
223 |
-
add_action ( 'admin_init', array( &$this, 'wcal_update_db_check' ) );
|
224 |
-
|
225 |
-
// Wordpress settings API
|
226 |
-
add_action( 'admin_init', array( &$this, 'wcal_initialize_plugin_options' ) );
|
227 |
-
|
228 |
-
// Language Translation
|
229 |
-
add_action ( 'init', array( &$this, 'wcal_update_po_file' ) );
|
230 |
-
|
231 |
-
// track links
|
232 |
-
add_filter( 'template_include', array( &$this, 'wcal_email_track_links' ), 99, 1 );
|
233 |
-
|
234 |
-
//It will used to unsubcribe the emails.
|
235 |
-
add_action( 'template_include', array( &$this, 'wcal_email_unsubscribe'),99, 1 );
|
236 |
-
|
237 |
-
add_action ( 'admin_enqueue_scripts', array( &$this, 'wcal_enqueue_scripts_js' ) );
|
238 |
-
add_action ( 'admin_enqueue_scripts', array( &$this, 'wcal_enqueue_scripts_css' ) );
|
239 |
-
|
240 |
-
if ( is_admin() ) {
|
241 |
-
// Load "admin-only" scripts here
|
242 |
-
add_action ( 'admin_head', array( &$this, 'wcal_action_send_preview' ) );
|
243 |
-
add_action ( 'wp_ajax_wcal_preview_email_sent', array( &$this, 'wcal_preview_email_sent' ) );
|
244 |
-
add_action ( 'wp_ajax_wcal_toggle_template_status', array( &$this, 'wcal_toggle_template_status' ) );
|
245 |
-
}
|
246 |
-
|
247 |
-
// Send Email on order recovery
|
248 |
-
add_action( 'woocommerce_order_status_pending_to_processing_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
249 |
-
add_action( 'woocommerce_order_status_pending_to_completed_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
250 |
-
add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
251 |
-
add_action( 'woocommerce_order_status_failed_to_processing_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
252 |
-
add_action( 'woocommerce_order_status_failed_to_completed_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
253 |
-
|
254 |
-
add_action('woocommerce_order_status_changed', array( &$this, 'wcal_email_admin_recovery_for_paypal' ), 10, 3);
|
255 |
-
|
256 |
-
add_action( 'admin_init', array( $this, 'wcal_preview_emails' ) );
|
257 |
-
add_action( 'init', array( $this, 'wcal_app_output_buffer') );
|
258 |
-
add_action( '
|
259 |
-
|
260 |
-
add_filter( '
|
261 |
-
|
262 |
-
|
263 |
-
add_action( '
|
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 |
-
|
306 |
-
|
307 |
-
*
|
308 |
-
*
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
$
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
*
|
327 |
-
*
|
328 |
-
*
|
329 |
-
*
|
330 |
-
*
|
331 |
-
*
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
$
|
338 |
-
$
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
$
|
344 |
-
|
345 |
-
|
346 |
-
$
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
$
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
$
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
$
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
$abandoned_order_id_of_guest
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
$
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
$
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
$
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
$abandoned_order_id_of_guest
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
$
|
424 |
-
|
425 |
-
$
|
426 |
-
$
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
$abandoned_order_id_of_guest
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
*
|
445 |
-
* will
|
446 |
-
*
|
447 |
-
*
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
$
|
458 |
-
$
|
459 |
-
|
460 |
-
|
461 |
-
$
|
462 |
-
$
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
$
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
$
|
474 |
-
$
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
$
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
$wpdb->delete( $
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
*
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
$
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
*
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
$
|
529 |
-
|
530 |
-
|
531 |
-
$
|
532 |
-
$
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
*
|
537 |
-
* email is sent
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
$
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
delete_post_meta( $order_id,
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
$
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
$
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
`id`
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
)
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
'
|
830 |
-
|
831 |
-
|
832 |
-
'
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
'
|
846 |
-
)
|
847 |
-
|
848 |
-
|
849 |
-
'
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
$
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
//
|
926 |
-
$
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
$
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
979 |
-
// We also access the show_header element of the options collection in the call to the checked() helper function
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
$
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
}
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
if (
|
1060 |
-
$
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
}
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
$
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
$
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
/*
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
}
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
update_option( '
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
}
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
$
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
}
|
1291 |
-
|
1292 |
-
|
1293 |
-
$
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
$
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
}
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
$
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
}
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
}
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
$
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
$
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
if ( $
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
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 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
$
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
$abandoned_cart_arr
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
$
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
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 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
}
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
}
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
|
2145 |
-
|
2146 |
-
|
2147 |
-
|
2148 |
-
|
2149 |
-
|
2150 |
-
|
2151 |
-
|
2152 |
-
|
2153 |
-
|
2154 |
-
|
2155 |
-
|
2156 |
-
|
2157 |
-
|
2158 |
-
|
2159 |
-
|
2160 |
-
|
2161 |
-
|
2162 |
-
|
2163 |
-
|
2164 |
-
|
2165 |
-
|
2166 |
-
|
2167 |
-
|
2168 |
-
|
2169 |
-
|
2170 |
-
|
2171 |
-
|
2172 |
-
|
2173 |
-
|
2174 |
-
|
2175 |
-
|
2176 |
-
|
2177 |
-
|
2178 |
-
|
2179 |
-
|
2180 |
-
|
2181 |
-
|
2182 |
-
|
2183 |
-
$
|
2184 |
-
|
2185 |
-
|
2186 |
-
|
2187 |
-
|
2188 |
-
|
2189 |
-
|
2190 |
-
|
2191 |
-
|
2192 |
-
|
2193 |
-
|
2194 |
-
|
2195 |
-
|
2196 |
-
|
2197 |
-
|
2198 |
-
|
2199 |
-
|
2200 |
-
|
2201 |
-
|
2202 |
-
|
2203 |
-
|
2204 |
-
|
2205 |
-
|
2206 |
-
|
2207 |
-
|
2208 |
-
|
2209 |
-
|
2210 |
-
|
2211 |
-
|
2212 |
-
|
2213 |
-
|
2214 |
-
|
2215 |
-
|
2216 |
-
|
2217 |
-
|
2218 |
-
|
2219 |
-
|
2220 |
-
|
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 |
-
|
2247 |
-
|
2248 |
-
|
2249 |
-
|
2250 |
-
|
2251 |
-
|
2252 |
-
|
2253 |
-
|
2254 |
-
|
2255 |
-
|
2256 |
-
|
2257 |
-
|
2258 |
-
|
2259 |
-
$
|
2260 |
-
$
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
|
2265 |
-
|
2266 |
-
|
2267 |
-
|
2268 |
-
|
2269 |
-
|
2270 |
-
|
2271 |
-
|
2272 |
-
|
2273 |
-
|
2274 |
-
|
2275 |
-
|
2276 |
-
|
2277 |
-
|
2278 |
-
|
2279 |
-
|
2280 |
-
|
2281 |
-
$
|
2282 |
-
|
2283 |
-
|
2284 |
-
|
2285 |
-
|
2286 |
-
|
2287 |
-
|
2288 |
-
|
2289 |
-
|
2290 |
-
|
2291 |
-
|
2292 |
-
|
2293 |
-
|
2294 |
-
|
2295 |
-
$
|
2296 |
-
$
|
2297 |
-
$
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
2301 |
-
$
|
2302 |
-
$
|
2303 |
-
|
2304 |
-
if
|
2305 |
-
|
2306 |
-
|
2307 |
-
|
2308 |
-
|
2309 |
-
|
2310 |
-
|
2311 |
-
|
2312 |
-
|
2313 |
-
|
2314 |
-
|
2315 |
-
|
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 |
-
|
2342 |
-
|
2343 |
-
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
|
2349 |
-
|
2350 |
-
|
2351 |
-
|
2352 |
-
|
2353 |
-
|
2354 |
-
|
2355 |
-
|
2356 |
-
|
2357 |
-
|
2358 |
-
|
2359 |
-
|
2360 |
-
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
|
2365 |
-
|
2366 |
-
|
2367 |
-
|
2368 |
-
|
2369 |
-
|
2370 |
-
|
2371 |
-
|
2372 |
-
|
2373 |
-
|
2374 |
-
|
2375 |
-
|
2376 |
-
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
|
2385 |
-
|
2386 |
-
|
2387 |
-
|
2388 |
-
|
2389 |
-
|
2390 |
-
|
2391 |
-
|
2392 |
-
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
|
2397 |
-
|
2398 |
-
|
2399 |
-
|
2400 |
-
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
2405 |
-
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
2410 |
-
|
2411 |
-
|
2412 |
-
|
2413 |
-
|
2414 |
-
|
2415 |
-
|
2416 |
-
|
2417 |
-
|
2418 |
-
|
2419 |
-
|
2420 |
-
|
2421 |
-
|
2422 |
-
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
2426 |
-
|
2427 |
-
|
2428 |
-
|
2429 |
-
|
2430 |
-
|
2431 |
-
|
2432 |
-
|
2433 |
-
|
2434 |
-
|
2435 |
-
|
2436 |
-
|
2437 |
-
|
2438 |
-
|
2439 |
-
|
2440 |
-
|
2441 |
-
|
2442 |
-
|
2443 |
-
|
2444 |
-
|
2445 |
-
|
2446 |
-
|
2447 |
-
|
2448 |
-
|
2449 |
-
|
2450 |
-
|
2451 |
-
|
2452 |
-
|
2453 |
-
|
2454 |
-
|
2455 |
-
|
2456 |
-
|
2457 |
-
|
2458 |
-
|
2459 |
-
|
2460 |
-
|
2461 |
-
|
2462 |
-
|
2463 |
-
|
2464 |
-
|
2465 |
-
|
2466 |
-
|
2467 |
-
|
2468 |
-
|
2469 |
-
|
2470 |
-
|
2471 |
-
|
2472 |
-
|
2473 |
-
|
2474 |
-
|
2475 |
-
|
2476 |
-
|
2477 |
-
|
2478 |
-
|
2479 |
-
|
2480 |
-
|
2481 |
-
|
2482 |
-
|
2483 |
-
|
2484 |
-
|
2485 |
-
|
2486 |
-
|
2487 |
-
|
2488 |
-
|
2489 |
-
|
2490 |
-
|
2491 |
-
|
2492 |
-
|
2493 |
-
|
2494 |
-
|
2495 |
-
|
2496 |
-
|
2497 |
-
|
2498 |
-
|
2499 |
-
|
2500 |
-
|
2501 |
-
|
2502 |
-
|
2503 |
-
|
2504 |
-
|
2505 |
-
|
2506 |
-
|
2507 |
-
|
2508 |
-
|
2509 |
-
|
2510 |
-
|
2511 |
-
|
2512 |
-
|
2513 |
-
|
2514 |
-
|
2515 |
-
|
2516 |
-
|
2517 |
-
|
2518 |
-
|
2519 |
-
|
2520 |
-
|
2521 |
-
|
2522 |
-
|
2523 |
-
|
2524 |
-
|
2525 |
-
|
2526 |
-
|
2527 |
-
|
2528 |
-
|
2529 |
-
|
2530 |
-
|
2531 |
-
|
2532 |
-
|
2533 |
-
|
2534 |
-
|
2535 |
-
|
2536 |
-
|
2537 |
-
|
2538 |
-
|
2539 |
-
|
2540 |
-
|
2541 |
-
|
2542 |
-
|
2543 |
-
</
|
2544 |
-
<div id="
|
2545 |
-
<
|
2546 |
-
|
2547 |
-
|
2548 |
-
|
2549 |
-
|
2550 |
-
|
2551 |
-
|
2552 |
-
|
2553 |
-
<?php
|
2554 |
-
|
2555 |
-
|
2556 |
-
|
2557 |
-
|
2558 |
-
|
2559 |
-
|
2560 |
-
|
2561 |
-
|
2562 |
-
|
2563 |
-
|
2564 |
-
|
2565 |
-
|
2566 |
-
|
2567 |
-
|
2568 |
-
|
2569 |
-
|
2570 |
-
|
2571 |
-
|
2572 |
-
|
2573 |
-
|
2574 |
-
|
2575 |
-
|
2576 |
-
|
2577 |
-
|
2578 |
-
|
2579 |
-
|
2580 |
-
|
2581 |
-
|
2582 |
-
|
2583 |
-
|
2584 |
-
|
2585 |
-
|
2586 |
-
|
2587 |
-
|
2588 |
-
|
2589 |
-
|
2590 |
-
|
2591 |
-
|
2592 |
-
|
2593 |
-
|
2594 |
-
|
2595 |
-
|
2596 |
-
|
2597 |
-
|
2598 |
-
|
2599 |
-
|
2600 |
-
|
2601 |
-
|
2602 |
-
|
2603 |
-
|
2604 |
-
|
2605 |
-
|
2606 |
-
|
2607 |
-
|
2608 |
-
|
2609 |
-
|
2610 |
-
|
2611 |
-
|
2612 |
-
$
|
2613 |
-
|
2614 |
-
|
2615 |
-
|
2616 |
-
|
2617 |
-
|
2618 |
-
|
2619 |
-
|
2620 |
-
|
2621 |
-
|
2622 |
-
|
2623 |
-
|
2624 |
-
|
2625 |
-
|
2626 |
-
$
|
2627 |
-
$
|
2628 |
-
$
|
2629 |
-
|
2630 |
-
|
2631 |
-
|
2632 |
-
$
|
2633 |
-
}
|
2634 |
-
$
|
2635 |
-
if(
|
2636 |
-
$
|
2637 |
-
|
2638 |
-
|
2639 |
-
|
2640 |
-
|
2641 |
-
|
2642 |
-
|
2643 |
-
|
2644 |
-
|
2645 |
-
|
2646 |
-
|
2647 |
-
|
2648 |
-
|
2649 |
-
|
2650 |
-
|
2651 |
-
|
2652 |
-
|
2653 |
-
|
2654 |
-
$
|
2655 |
-
}
|
2656 |
-
|
2657 |
-
|
2658 |
-
|
2659 |
-
|
2660 |
-
|
2661 |
-
|
2662 |
-
|
2663 |
-
|
2664 |
-
|
2665 |
-
|
2666 |
-
$
|
2667 |
-
}
|
2668 |
-
|
2669 |
-
|
2670 |
-
$
|
2671 |
-
if ( isset( $
|
2672 |
-
$
|
2673 |
-
} else {
|
2674 |
-
$
|
2675 |
-
}
|
2676 |
-
$
|
2677 |
-
|
2678 |
-
|
2679 |
-
|
2680 |
-
$
|
2681 |
-
}
|
2682 |
-
|
2683 |
-
|
2684 |
-
|
2685 |
-
|
2686 |
-
$
|
2687 |
-
}
|
2688 |
-
|
2689 |
-
|
2690 |
-
|
2691 |
-
|
2692 |
-
$
|
2693 |
-
}
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
2697 |
-
|
2698 |
-
$
|
2699 |
-
}
|
2700 |
-
|
2701 |
-
|
2702 |
-
|
2703 |
-
|
2704 |
-
$
|
2705 |
-
}
|
2706 |
-
|
2707 |
-
|
2708 |
-
|
2709 |
-
|
2710 |
-
$
|
2711 |
-
}
|
2712 |
-
|
2713 |
-
|
2714 |
-
|
2715 |
-
|
2716 |
-
$
|
2717 |
-
}
|
2718 |
-
|
2719 |
-
|
2720 |
-
|
2721 |
-
|
2722 |
-
|
2723 |
-
|
2724 |
-
|
2725 |
-
|
2726 |
-
|
2727 |
-
|
2728 |
-
$
|
2729 |
-
|
2730 |
-
$
|
2731 |
-
|
2732 |
-
|
2733 |
-
|
2734 |
-
|
2735 |
-
|
2736 |
-
|
2737 |
-
|
2738 |
-
|
2739 |
-
|
2740 |
-
|
2741 |
-
|
2742 |
-
|
2743 |
-
|
2744 |
-
|
2745 |
-
|
2746 |
-
|
2747 |
-
|
2748 |
-
|
2749 |
-
|
2750 |
-
|
2751 |
-
|
2752 |
-
|
2753 |
-
|
2754 |
-
|
2755 |
-
|
2756 |
-
|
2757 |
-
|
2758 |
-
|
2759 |
-
|
2760 |
-
|
2761 |
-
|
2762 |
-
|
2763 |
-
|
2764 |
-
|
2765 |
-
|
2766 |
-
|
2767 |
-
|
2768 |
-
|
2769 |
-
|
2770 |
-
|
2771 |
-
$
|
2772 |
-
$
|
2773 |
-
$
|
2774 |
-
|
2775 |
-
|
2776 |
-
|
2777 |
-
|
2778 |
-
|
2779 |
-
|
2780 |
-
|
2781 |
-
|
2782 |
-
|
2783 |
-
|
2784 |
-
|
2785 |
-
|
2786 |
-
|
2787 |
-
|
2788 |
-
|
2789 |
-
|
2790 |
-
|
2791 |
-
|
2792 |
-
|
2793 |
-
|
2794 |
-
|
2795 |
-
|
2796 |
-
|
2797 |
-
|
2798 |
-
|
2799 |
-
|
2800 |
-
|
2801 |
-
|
2802 |
-
|
2803 |
-
|
2804 |
-
|
2805 |
-
|
2806 |
-
|
2807 |
-
|
2808 |
-
|
2809 |
-
|
2810 |
-
|
2811 |
-
|
2812 |
-
|
2813 |
-
$
|
2814 |
-
|
2815 |
-
|
2816 |
-
|
2817 |
-
|
2818 |
-
|
2819 |
-
|
2820 |
-
|
2821 |
-
|
2822 |
-
|
2823 |
-
|
2824 |
-
|
2825 |
-
|
2826 |
-
|
2827 |
-
|
2828 |
-
|
2829 |
-
|
2830 |
-
|
2831 |
-
|
2832 |
-
|
2833 |
-
|
2834 |
-
|
2835 |
-
|
2836 |
-
|
2837 |
-
|
2838 |
-
|
2839 |
-
|
2840 |
-
|
2841 |
-
|
2842 |
-
|
2843 |
-
|
2844 |
-
|
2845 |
-
<?php
|
2846 |
-
|
2847 |
-
|
2848 |
-
|
2849 |
-
|
2850 |
-
|
2851 |
-
|
2852 |
-
|
2853 |
-
|
2854 |
-
|
2855 |
-
|
2856 |
-
|
2857 |
-
|
2858 |
-
|
2859 |
-
|
2860 |
-
|
2861 |
-
|
2862 |
-
|
2863 |
-
|
2864 |
-
|
2865 |
-
|
2866 |
-
|
2867 |
-
|
2868 |
-
|
2869 |
-
|
2870 |
-
|
2871 |
-
|
2872 |
-
|
2873 |
-
|
2874 |
-
|
2875 |
-
|
2876 |
-
|
2877 |
-
|
2878 |
-
|
2879 |
-
|
2880 |
-
|
2881 |
-
|
2882 |
-
|
2883 |
-
|
2884 |
-
|
2885 |
-
|
2886 |
-
|
2887 |
-
|
2888 |
-
|
2889 |
-
|
2890 |
-
|
2891 |
-
|
2892 |
-
|
2893 |
-
|
2894 |
-
|
2895 |
-
$
|
2896 |
-
|
2897 |
-
|
2898 |
-
|
2899 |
-
|
2900 |
-
|
2901 |
-
|
2902 |
-
|
2903 |
-
|
2904 |
-
|
2905 |
-
|
2906 |
-
|
2907 |
-
|
2908 |
-
|
2909 |
-
|
2910 |
-
|
2911 |
-
|
2912 |
-
|
2913 |
-
|
2914 |
-
|
2915 |
-
|
2916 |
-
|
2917 |
-
|
2918 |
-
|
2919 |
-
|
2920 |
-
|
2921 |
-
|
2922 |
-
|
2923 |
-
|
2924 |
-
|
2925 |
-
|
2926 |
-
|
2927 |
-
|
2928 |
-
|
2929 |
-
|
2930 |
-
|
2931 |
-
|
2932 |
-
|
2933 |
-
|
2934 |
-
|
2935 |
-
|
2936 |
-
|
2937 |
-
|
2938 |
-
|
2939 |
-
|
2940 |
-
|
2941 |
-
|
2942 |
-
|
2943 |
-
|
2944 |
-
|
2945 |
-
|
2946 |
-
|
2947 |
-
|
2948 |
-
|
2949 |
-
|
2950 |
-
|
2951 |
-
|
2952 |
-
|
2953 |
-
|
2954 |
-
|
2955 |
-
|
2956 |
-
|
2957 |
-
|
2958 |
-
|
2959 |
-
|
2960 |
-
|
2961 |
-
|
2962 |
-
|
2963 |
-
|
2964 |
-
|
2965 |
-
|
2966 |
-
|
2967 |
-
</
|
2968 |
-
|
2969 |
-
|
2970 |
-
|
2971 |
-
|
2972 |
-
|
2973 |
-
|
2974 |
-
|
2975 |
-
|
2976 |
-
|
2977 |
-
|
2978 |
-
|
2979 |
-
|
2980 |
-
|
2981 |
-
|
2982 |
-
|
2983 |
-
|
2984 |
-
|
2985 |
-
|
2986 |
-
|
2987 |
-
|
2988 |
-
|
2989 |
-
|
2990 |
-
|
2991 |
-
|
2992 |
-
|
2993 |
-
|
2994 |
-
|
2995 |
-
|
2996 |
-
|
2997 |
-
|
2998 |
-
|
2999 |
-
|
3000 |
-
|
3001 |
-
|
3002 |
-
|
3003 |
-
|
3004 |
-
|
3005 |
-
|
3006 |
-
|
3007 |
-
|
3008 |
-
|
3009 |
-
</td>
|
3010 |
-
</tr>
|
3011 |
-
|
3012 |
-
|
3013 |
-
<th>
|
3014 |
-
<label for="
|
3015 |
-
</th>
|
3016 |
-
<td>
|
3017 |
-
|
3018 |
-
|
3019 |
-
|
3020 |
-
$
|
3021 |
-
|
3022 |
-
|
3023 |
-
|
3024 |
-
|
3025 |
-
|
3026 |
-
|
3027 |
-
|
3028 |
-
|
3029 |
-
|
3030 |
-
|
3031 |
-
|
3032 |
-
|
3033 |
-
|
3034 |
-
|
3035 |
-
|
3036 |
-
|
3037 |
-
|
3038 |
-
|
3039 |
-
|
3040 |
-
|
3041 |
-
|
3042 |
-
|
3043 |
-
|
3044 |
-
|
3045 |
-
|
3046 |
-
|
3047 |
-
|
3048 |
-
|
3049 |
-
|
3050 |
-
|
3051 |
-
|
3052 |
-
|
3053 |
-
|
3054 |
-
|
3055 |
-
|
3056 |
-
|
3057 |
-
</
|
3058 |
-
|
3059 |
-
|
3060 |
-
|
3061 |
-
|
3062 |
-
|
3063 |
-
|
3064 |
-
|
3065 |
-
|
3066 |
-
|
3067 |
-
|
3068 |
-
|
3069 |
-
|
3070 |
-
|
3071 |
-
|
3072 |
-
|
3073 |
-
|
3074 |
-
|
3075 |
-
|
3076 |
-
|
3077 |
-
|
3078 |
-
|
3079 |
-
|
3080 |
-
|
3081 |
-
|
3082 |
-
|
3083 |
-
|
3084 |
-
|
3085 |
-
|
3086 |
-
|
3087 |
-
|
3088 |
-
|
3089 |
-
|
3090 |
-
|
3091 |
-
|
3092 |
-
|
3093 |
-
|
3094 |
-
|
3095 |
-
|
3096 |
-
|
3097 |
-
|
3098 |
-
|
3099 |
-
|
3100 |
-
|
3101 |
-
|
3102 |
-
|
3103 |
-
|
3104 |
-
|
3105 |
-
|
3106 |
-
|
3107 |
-
|
3108 |
-
|
3109 |
-
|
3110 |
-
|
3111 |
-
|
3112 |
-
|
3113 |
-
|
3114 |
-
|
3115 |
-
|
3116 |
-
|
3117 |
-
|
3118 |
-
|
3119 |
-
|
3120 |
-
|
3121 |
-
|
3122 |
-
|
3123 |
-
|
3124 |
-
|
3125 |
-
|
3126 |
-
|
3127 |
-
|
3128 |
-
|
3129 |
-
|
3130 |
-
|
3131 |
-
|
3132 |
-
|
3133 |
-
|
3134 |
-
|
3135 |
-
|
3136 |
-
|
3137 |
-
|
3138 |
-
|
3139 |
-
|
3140 |
-
|
3141 |
-
|
3142 |
-
|
3143 |
-
|
3144 |
-
|
3145 |
-
|
3146 |
-
|
3147 |
-
|
3148 |
-
|
3149 |
-
|
3150 |
-
|
3151 |
-
|
3152 |
-
|
3153 |
-
|
3154 |
-
|
3155 |
-
|
3156 |
-
|
3157 |
-
|
3158 |
-
|
3159 |
-
|
3160 |
-
|
3161 |
-
|
3162 |
-
|
3163 |
-
|
3164 |
-
|
3165 |
-
|
3166 |
-
|
3167 |
-
|
3168 |
-
|
3169 |
-
|
3170 |
-
|
3171 |
-
|
3172 |
-
|
3173 |
-
|
3174 |
-
|
3175 |
-
|
3176 |
-
|
3177 |
-
|
3178 |
-
|
3179 |
-
|
3180 |
-
|
3181 |
-
|
3182 |
-
|
3183 |
-
|
3184 |
-
|
3185 |
-
|
3186 |
-
|
3187 |
-
|
3188 |
-
|
3189 |
-
|
3190 |
-
|
3191 |
-
|
3192 |
-
|
3193 |
-
|
3194 |
-
|
3195 |
-
|
3196 |
-
|
3197 |
-
|
3198 |
-
|
3199 |
-
|
3200 |
-
|
3201 |
-
|
3202 |
-
|
3203 |
-
|
3204 |
-
|
3205 |
-
|
3206 |
-
|
3207 |
-
|
3208 |
-
|
3209 |
-
|
3210 |
-
|
3211 |
-
|
3212 |
-
$
|
3213 |
-
$
|
3214 |
-
$
|
3215 |
-
$
|
3216 |
-
$
|
3217 |
-
$
|
3218 |
-
|
3219 |
-
|
3220 |
-
|
3221 |
-
|
3222 |
-
|
3223 |
-
|
3224 |
-
|
3225 |
-
|
3226 |
-
|
3227 |
-
|
3228 |
-
|
3229 |
-
|
3230 |
-
|
3231 |
-
|
3232 |
-
|
3233 |
-
|
3234 |
-
|
3235 |
-
|
3236 |
-
|
3237 |
-
|
3238 |
-
|
3239 |
-
|
3240 |
-
|
3241 |
-
|
3242 |
-
|
3243 |
-
|
3244 |
-
|
3245 |
-
|
3246 |
-
|
3247 |
-
|
3248 |
-
|
3249 |
-
|
3250 |
-
|
3251 |
-
|
3252 |
-
|
3253 |
-
|
3254 |
-
|
3255 |
-
|
3256 |
-
|
3257 |
-
|
3258 |
-
|
3259 |
-
|
3260 |
-
|
3261 |
-
|
3262 |
-
|
3263 |
-
|
3264 |
-
|
3265 |
-
|
3266 |
-
|
3267 |
-
|
3268 |
-
|
3269 |
-
|
3270 |
-
|
3271 |
-
|
3272 |
-
|
3273 |
-
|
3274 |
-
|
3275 |
-
|
3276 |
-
<tr align="center">
|
3277 |
-
<
|
3278 |
-
<
|
3279 |
-
<
|
3280 |
-
<
|
3281 |
-
<
|
3282 |
-
</tr>
|
3283 |
-
<tr align="center">
|
3284 |
-
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/
|
3285 |
-
<td>'.__( "
|
3286 |
-
<td>1</td>
|
3287 |
-
<td>' . $wcal_price . '</td>
|
3288 |
-
<td>' . $wcal_price . '</td>
|
3289 |
-
</tr>
|
3290 |
-
<tr align="center">
|
3291 |
-
<td
|
3292 |
-
<td
|
3293 |
-
<td
|
3294 |
-
<td>'
|
3295 |
-
<td>' . $
|
3296 |
-
</tr>
|
3297 |
-
|
3298 |
-
|
3299 |
-
|
3300 |
-
|
3301 |
-
|
3302 |
-
|
3303 |
-
|
3304 |
-
|
3305 |
-
|
3306 |
-
|
3307 |
-
|
3308 |
-
|
3309 |
-
|
3310 |
-
|
3311 |
-
|
3312 |
-
|
3313 |
-
|
3314 |
-
|
3315 |
-
|
3316 |
-
|
3317 |
-
|
3318 |
-
|
3319 |
-
|
3320 |
-
|
3321 |
-
|
3322 |
-
|
3323 |
-
|
3324 |
-
|
3325 |
-
|
3326 |
-
|
3327 |
-
|
3328 |
-
|
3329 |
-
|
3330 |
-
|
3331 |
-
|
3332 |
-
|
3333 |
-
|
3334 |
-
|
3335 |
-
<td></td>
|
3336 |
-
<td>'.__( "Cart Total:", "woocommerce-ac" ).'</td>
|
3337 |
-
<td>' . $wcal_total_price . '</td>
|
3338 |
-
</tr>
|
3339 |
-
</table>';
|
3340 |
-
}
|
3341 |
-
$body_email_preview = str_replace( '{{products.cart}}', $var, $body_email_preview );
|
3342 |
-
if ( isset( $_POST['send_email_id'] ) ) {
|
3343 |
-
$to_email_preview = $_POST['send_email_id'];
|
3344 |
-
} else {
|
3345 |
-
$to_email_preview = "";
|
3346 |
-
}
|
3347 |
-
$user_email_from = get_option( 'admin_email' );
|
3348 |
-
$body_email_final_preview = stripslashes( $body_email_preview );
|
3349 |
-
|
3350 |
-
if ( isset( $is_wc_template ) && "true" == $is_wc_template ) {
|
3351 |
-
ob_start();
|
3352 |
-
// Get email heading
|
3353 |
-
wc_get_template( 'emails/email-header.php', array( 'email_heading' => $wc_template_header ) );
|
3354 |
-
$email_body_template_header = ob_get_clean();
|
3355 |
-
|
3356 |
-
ob_start();
|
3357 |
-
wc_get_template( 'emails/email-footer.php' );
|
3358 |
-
$email_body_template_footer = ob_get_clean();
|
3359 |
-
|
3360 |
-
$final_email_body = $email_body_template_header . $body_email_final_preview . $email_body_template_footer;
|
3361 |
-
|
3362 |
-
wc_mail( $to_email_preview, $subject_email_preview, $final_email_body , $headers );
|
3363 |
-
}
|
3364 |
-
else {
|
3365 |
-
wp_mail( $to_email_preview, $subject_email_preview, stripslashes( $body_email_preview ), $headers );
|
3366 |
-
}
|
3367 |
-
echo "email sent";
|
3368 |
-
die();
|
3369 |
-
} else {
|
3370 |
-
echo "not sent";
|
3371 |
-
die();
|
3372 |
-
}
|
3373 |
-
}
|
3374 |
-
}
|
3375 |
-
}
|
3376 |
-
$woocommerce_abandon_cart = new woocommerce_abandon_cart_lite();
|
3377 |
?>
|
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.6
|
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
|
17 |
+
register_uninstall_hook( __FILE__, 'woocommerce_ac_delete_lite' );
|
18 |
+
|
19 |
+
require_once( "includes/wcal_class-guest.php" );
|
20 |
+
require_once( "includes/wcal_default-settings.php" );
|
21 |
+
require_once( "includes/wcal_actions.php" );
|
22 |
+
require_once( "includes/classes/class-wcal-aes.php" );
|
23 |
+
require_once( "includes/classes/class-wcal-aes-counter.php" );
|
24 |
+
require_once( "includes/wcal-common.php" );
|
25 |
+
require_once( "includes/wcal_ts_tracking.php");
|
26 |
+
require_once( "includes/wcal_admin_notice.php");
|
27 |
+
|
28 |
+
if ( is_admin() ) {
|
29 |
+
require_once( 'includes/welcome.php' );
|
30 |
+
|
31 |
+
define( 'WCAL_VERSION', wcal_common::wcal_get_version() );
|
32 |
+
|
33 |
+
define( 'WCAL_PLUGIN_URL', wcal_common::wcal_get_plugin_url() );
|
34 |
+
}
|
35 |
+
|
36 |
+
// Add a new interval of 15 minutes
|
37 |
+
add_filter( 'cron_schedules', 'wcal_add_cron_schedule' );
|
38 |
+
|
39 |
+
function wcal_add_cron_schedule( $schedules ) {
|
40 |
+
$schedules['15_minutes_lite'] = array(
|
41 |
+
'interval' => 900, // 15 minutes in seconds
|
42 |
+
'display' => __( 'Once Every Fifteen Minutes' ),
|
43 |
+
);
|
44 |
+
return $schedules;
|
45 |
+
}
|
46 |
+
// Schedule an action if it's not already scheduled
|
47 |
+
if ( ! wp_next_scheduled( 'woocommerce_ac_send_email_action' ) ) {
|
48 |
+
wp_schedule_event( time(), '15_minutes_lite', 'woocommerce_ac_send_email_action' );
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Run a cron once in week to delete old records for lockout
|
53 |
+
*/
|
54 |
+
function wcal_add_tracking_cron_schedule( $schedules ) {
|
55 |
+
$schedules[ 'daily_once' ] = array(
|
56 |
+
'interval' => 604800, // one week in seconds
|
57 |
+
'display' => __( 'Once in a Week', 'woocommerce-ac' )
|
58 |
+
);
|
59 |
+
return $schedules;
|
60 |
+
}
|
61 |
+
|
62 |
+
/* To capture the data from the client site */
|
63 |
+
if ( ! wp_next_scheduled( 'wcal_ts_tracker_send_event' ) ) {
|
64 |
+
wp_schedule_event( time(), 'daily_once', 'wcal_ts_tracker_send_event' );
|
65 |
+
}
|
66 |
+
|
67 |
+
// Hook into that action that'll fire every 15 minutes
|
68 |
+
add_action( 'woocommerce_ac_send_email_action', 'wcal_send_email_cron' );
|
69 |
+
|
70 |
+
function wcal_send_email_cron() {
|
71 |
+
//require_once( ABSPATH.'wp-content/plugins/woocommerce-abandoned-cart/cron/send_email.php' );
|
72 |
+
$plugin_dir_path = plugin_dir_path( __FILE__ );
|
73 |
+
require_once( $plugin_dir_path . 'cron/wcal_send_email.php' );
|
74 |
+
}
|
75 |
+
|
76 |
+
function woocommerce_ac_delete_lite() {
|
77 |
+
global $wpdb;
|
78 |
+
if ( ! is_multisite() ) {
|
79 |
+
$table_name_ac_abandoned_cart_history = $wpdb->prefix . "ac_abandoned_cart_history_lite";
|
80 |
+
$sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_abandoned_cart_history ;
|
81 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
82 |
+
$wpdb->get_results( $sql_ac_abandoned_cart_history );
|
83 |
+
|
84 |
+
$table_name_ac_email_templates = $wpdb->prefix . "ac_email_templates_lite";
|
85 |
+
$sql_ac_email_templates = "DROP TABLE " . $table_name_ac_email_templates ;
|
86 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
87 |
+
$wpdb->get_results( $sql_ac_email_templates );
|
88 |
+
|
89 |
+
$table_name_ac_sent_history = $wpdb->prefix . "ac_sent_history_lite";
|
90 |
+
$sql_ac_sent_history = "DROP TABLE " . $table_name_ac_sent_history ;
|
91 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
92 |
+
$wpdb->get_results( $sql_ac_sent_history );
|
93 |
+
|
94 |
+
$table_name_ac_guest_abandoned_cart_history = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
|
95 |
+
$sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_guest_abandoned_cart_history ;
|
96 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
97 |
+
$wpdb->get_results( $sql_ac_abandoned_cart_history );
|
98 |
+
|
99 |
+
$sql_table_user_meta_cart = "DELETE FROM `" . $wpdb->prefix . "usermeta` WHERE meta_key = '_woocommerce_persistent_cart'";
|
100 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
101 |
+
$wpdb->get_results( $sql_table_user_meta_cart );
|
102 |
+
|
103 |
+
$sql_table_user_meta_cart_modified = "DELETE FROM `" . $wpdb->prefix . "usermeta` WHERE meta_key = '_woocommerce_ac_modified_cart'";
|
104 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
105 |
+
$wpdb->get_results( $sql_table_user_meta_cart_modified );
|
106 |
+
} else {
|
107 |
+
$query = "SELECT blog_id FROM `".$wpdb->prefix."blogs`";
|
108 |
+
$results = $wpdb->get_results( $query );
|
109 |
+
|
110 |
+
foreach( $results as $key => $value ) {
|
111 |
+
$table_name_ac_abandoned_cart_history = $wpdb->prefix .$value->blog_id."_"."ac_abandoned_cart_history_lite";
|
112 |
+
$sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_abandoned_cart_history ;
|
113 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
114 |
+
$wpdb->get_results( $sql_ac_abandoned_cart_history );
|
115 |
+
|
116 |
+
$table_name_ac_email_templates = $wpdb->prefix .$value->blog_id."_"."ac_email_templates_lite";
|
117 |
+
$sql_ac_email_templates = "DROP TABLE " . $table_name_ac_email_templates ;
|
118 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
119 |
+
$wpdb->get_results( $sql_ac_email_templates );
|
120 |
+
|
121 |
+
$table_name_ac_sent_history = $wpdb->prefix .$value->blog_id."_"."ac_sent_history_lite";
|
122 |
+
$sql_ac_sent_history = "DROP TABLE " . $table_name_ac_sent_history ;
|
123 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
124 |
+
$wpdb->get_results( $sql_ac_sent_history );
|
125 |
+
|
126 |
+
$table_name_ac_guest_abandoned_cart_history = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
|
127 |
+
$sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_guest_abandoned_cart_history ;
|
128 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
129 |
+
$wpdb->get_results( $sql_ac_abandoned_cart_history );
|
130 |
+
|
131 |
+
$sql_table_user_meta_cart = "DELETE FROM `" . $wpdb->prefix.$value->blog_id."_"."usermeta` WHERE meta_key = '_woocommerce_persistent_cart'";
|
132 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
133 |
+
$wpdb->get_results( $sql_table_user_meta_cart );
|
134 |
+
|
135 |
+
$sql_table_user_meta_cart_modified = "DELETE FROM `" . $wpdb->prefix.$value->blog_id."_"."usermeta` WHERE meta_key = '_woocommerce_ac_modified_cart'";
|
136 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
137 |
+
$wpdb->get_results( $sql_table_user_meta_cart_modified );
|
138 |
+
}
|
139 |
+
}
|
140 |
+
delete_option( 'woocommerce_ac_email_body' );
|
141 |
+
delete_option( 'ac_lite_cart_abandoned_time' );
|
142 |
+
delete_option( 'ac_lite_email_admin_on_recovery' );
|
143 |
+
delete_option( 'ac_lite_settings_status' );
|
144 |
+
delete_option( 'woocommerce_ac_default_templates_installed' );
|
145 |
+
delete_option( 'wcal_security_key' );
|
146 |
+
delete_option( 'ac_lite_track_guest_cart_from_cart_page' );
|
147 |
+
delete_option( 'wcal_from_name' );
|
148 |
+
delete_option( 'wcal_from_email' );
|
149 |
+
delete_option( 'wcal_reply_email' );
|
150 |
+
|
151 |
+
delete_option( 'ac_security_key' );
|
152 |
+
delete_option( 'wcal_activate_time' );
|
153 |
+
delete_option( 'ac_lite_alter_table_queries' );
|
154 |
+
delete_option( 'ac_lite_delete_alter_table_queries' );
|
155 |
+
delete_option( 'wcal_allow_tracking' );
|
156 |
+
delete_option( 'wcal_ts_tracker_last_send' );
|
157 |
+
|
158 |
+
delete_option( 'wcal_welcome_page_shown_time' );
|
159 |
+
delete_option( 'wcal_welcome_page_shown' );
|
160 |
+
}
|
161 |
+
/**
|
162 |
+
* woocommerce_abandon_cart_lite class
|
163 |
+
**/
|
164 |
+
if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
165 |
+
|
166 |
+
class woocommerce_abandon_cart_lite {
|
167 |
+
var $one_hour;
|
168 |
+
var $three_hours;
|
169 |
+
var $six_hours;
|
170 |
+
var $twelve_hours;
|
171 |
+
var $one_day;
|
172 |
+
var $one_week;
|
173 |
+
var $duration_range_select = array();
|
174 |
+
var $start_end_dates = array();
|
175 |
+
|
176 |
+
public function __construct() {
|
177 |
+
$this->one_hour = 60 * 60;
|
178 |
+
$this->three_hours = 3 * $this->one_hour;
|
179 |
+
$this->six_hours = 6 * $this->one_hour;
|
180 |
+
$this->twelve_hours = 12 * $this->one_hour;
|
181 |
+
$this->one_day = 24 * $this->one_hour;
|
182 |
+
$this->one_week = 7 * $this->one_day;
|
183 |
+
$this->duration_range_select = array( 'yesterday' => 'Yesterday',
|
184 |
+
'today' => 'Today',
|
185 |
+
'last_seven' => 'Last 7 days',
|
186 |
+
'last_fifteen' => 'Last 15 days',
|
187 |
+
'last_thirty' => 'Last 30 days',
|
188 |
+
'last_ninety' => 'Last 90 days',
|
189 |
+
'last_year_days' => 'Last 365'
|
190 |
+
);
|
191 |
+
|
192 |
+
$this->start_end_dates = array( 'yesterday' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 24*60*60 ) ),
|
193 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) - 7*24*60*60 ) ) ),
|
194 |
+
'today' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ),
|
195 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
196 |
+
'last_seven' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 7*24*60*60 ) ),
|
197 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
198 |
+
'last_fifteen' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 15*24*60*60 ) ),
|
199 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
200 |
+
'last_thirty' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 30*24*60*60 ) ),
|
201 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
202 |
+
'last_ninety' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 90*24*60*60 ) ),
|
203 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
204 |
+
'last_year_days' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 365*24*60*60 ) ),
|
205 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) )
|
206 |
+
);
|
207 |
+
|
208 |
+
// Initialize settings
|
209 |
+
register_activation_hook ( __FILE__, array( &$this, 'wcal_activate' ) );
|
210 |
+
|
211 |
+
// WordPress Administration Menu
|
212 |
+
add_action ( 'admin_menu', array( &$this, 'wcal_admin_menu' ) );
|
213 |
+
|
214 |
+
// Actions to be done on cart update
|
215 |
+
add_action ( 'woocommerce_cart_updated', array( &$this, 'wcal_store_cart_timestamp' ) );
|
216 |
+
|
217 |
+
// delete added temp fields after order is placed
|
218 |
+
add_filter ( 'woocommerce_order_details_after_order_table', array( &$this, 'wcal_action_after_delivery_session' ) );
|
219 |
+
|
220 |
+
add_action ( 'admin_init', array( &$this, 'wcal_action_admin_init' ) );
|
221 |
+
|
222 |
+
// Update the options as per settings API
|
223 |
+
add_action ( 'admin_init', array( &$this, 'wcal_update_db_check' ) );
|
224 |
+
|
225 |
+
// Wordpress settings API
|
226 |
+
add_action( 'admin_init', array( &$this, 'wcal_initialize_plugin_options' ) );
|
227 |
+
|
228 |
+
// Language Translation
|
229 |
+
add_action ( 'init', array( &$this, 'wcal_update_po_file' ) );
|
230 |
+
|
231 |
+
// track links
|
232 |
+
add_filter( 'template_include', array( &$this, 'wcal_email_track_links' ), 99, 1 );
|
233 |
+
|
234 |
+
//It will used to unsubcribe the emails.
|
235 |
+
add_action( 'template_include', array( &$this, 'wcal_email_unsubscribe'),99, 1 );
|
236 |
+
|
237 |
+
add_action ( 'admin_enqueue_scripts', array( &$this, 'wcal_enqueue_scripts_js' ) );
|
238 |
+
add_action ( 'admin_enqueue_scripts', array( &$this, 'wcal_enqueue_scripts_css' ) );
|
239 |
+
|
240 |
+
if ( is_admin() ) {
|
241 |
+
// Load "admin-only" scripts here
|
242 |
+
add_action ( 'admin_head', array( &$this, 'wcal_action_send_preview' ) );
|
243 |
+
add_action ( 'wp_ajax_wcal_preview_email_sent', array( &$this, 'wcal_preview_email_sent' ) );
|
244 |
+
add_action ( 'wp_ajax_wcal_toggle_template_status', array( &$this, 'wcal_toggle_template_status' ) );
|
245 |
+
}
|
246 |
+
|
247 |
+
// Send Email on order recovery
|
248 |
+
add_action( 'woocommerce_order_status_pending_to_processing_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
249 |
+
add_action( 'woocommerce_order_status_pending_to_completed_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
250 |
+
add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
251 |
+
add_action( 'woocommerce_order_status_failed_to_processing_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
252 |
+
add_action( 'woocommerce_order_status_failed_to_completed_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
253 |
+
|
254 |
+
add_action('woocommerce_order_status_changed', array( &$this, 'wcal_email_admin_recovery_for_paypal' ), 10, 3);
|
255 |
+
|
256 |
+
add_action( 'admin_init', array( $this, 'wcal_preview_emails' ) );
|
257 |
+
add_action( 'init', array( $this, 'wcal_app_output_buffer') );
|
258 |
+
add_action( 'woocommerce_checkout_order_processed', array( &$this, 'wcal_order_placed' ), 10 , 1 );
|
259 |
+
add_filter( 'woocommerce_payment_complete_order_status', array( &$this, 'wcal_order_complete_action' ), 10 , 2 );
|
260 |
+
add_filter( 'admin_footer_text', array( $this, 'wcal_admin_footer_text' ), 1 );
|
261 |
+
|
262 |
+
add_action( 'admin_notices', array( 'Wcal_Admin_Notice', 'wcal_pro_notice' ) );
|
263 |
+
add_action( 'admin_init', array( 'Wcal_Admin_Notice', 'wcal_pro_notice_ignore' ) );
|
264 |
+
|
265 |
+
/**
|
266 |
+
* @since: 4.2
|
267 |
+
* Check if WC is enabled or not.
|
268 |
+
*/
|
269 |
+
add_action( 'admin_init', array( &$this, 'wcal_wc_check_compatibility' ) );
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* @since: 4.2
|
274 |
+
* Check if WC is active or not.
|
275 |
+
*/
|
276 |
+
public static function wcal_wc_check_ac_installed() {
|
277 |
+
|
278 |
+
if ( is_plugin_active( 'woocommerce/woocommerce.php' ) && class_exists( 'WooCommerce' ) ) {
|
279 |
+
return true;
|
280 |
+
} else {
|
281 |
+
return false;
|
282 |
+
}
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* @since: 4.2
|
287 |
+
* Ensure that the Abandoned cart lite get deactivated when WC is deactivated.
|
288 |
+
*/
|
289 |
+
public static function wcal_wc_check_compatibility() {
|
290 |
+
|
291 |
+
if ( ! self::wcal_wc_check_ac_installed() ) {
|
292 |
+
|
293 |
+
if ( is_plugin_active( plugin_basename( __FILE__ ) ) ) {
|
294 |
+
deactivate_plugins( plugin_basename( __FILE__ ) );
|
295 |
+
|
296 |
+
add_action( 'admin_notices', array( 'woocommerce_abandon_cart_lite', 'wcal_wc_disabled_notice' ) );
|
297 |
+
if ( isset( $_GET['activate'] ) ) {
|
298 |
+
unset( $_GET['activate'] );
|
299 |
+
}
|
300 |
+
|
301 |
+
}
|
302 |
+
|
303 |
+
}
|
304 |
+
}
|
305 |
+
/**
|
306 |
+
* @since: 4.2
|
307 |
+
* Display a notice in the admin Plugins page if the Abandoned cart lite is
|
308 |
+
* activated while WC is deactivated.
|
309 |
+
*/
|
310 |
+
public static function wcal_wc_disabled_notice() {
|
311 |
+
|
312 |
+
$class = 'notice notice-error is-dismissible';
|
313 |
+
$message = __( 'Abandoned Cart Lite for WooCommerce requires WooCommerce installed and activate.', 'woocommerce-ac' );
|
314 |
+
|
315 |
+
printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
|
316 |
+
}
|
317 |
+
|
318 |
+
public static function wcal_order_placed( $order_id ) {
|
319 |
+
if( session_id() === '' ) {
|
320 |
+
//session has not started
|
321 |
+
session_start();
|
322 |
+
}
|
323 |
+
|
324 |
+
/**
|
325 |
+
* When user comes from the abandoned cart reminder email this conditon will be executed.
|
326 |
+
* It will check the guest uers data in further 3 conditions.
|
327 |
+
* 1. When WC setting mandatory to become the logged in users. And places the order
|
328 |
+
* 2. When WC setting is non - mandatory to become the logged in users. And user choose to be the loggedin
|
329 |
+
* to the site And places the order
|
330 |
+
* 3. When user places the orde as guest user.
|
331 |
+
* It will consider the old cart of the customer as the recovered order and delete the unwanted new records.
|
332 |
+
*/
|
333 |
+
if ( isset( $_SESSION['email_sent_id'] ) && $_SESSION['email_sent_id'] !='' ) {
|
334 |
+
global $woocommerce, $wpdb;
|
335 |
+
|
336 |
+
$wcal_history_table_name = $wpdb->prefix . 'ac_abandoned_cart_history_lite';
|
337 |
+
$wcal_guest_table_name = $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite';
|
338 |
+
$wcal_sent_email_table_name = $wpdb->prefix . 'ac_sent_history_lite';
|
339 |
+
|
340 |
+
$email_sent_id = $_SESSION['email_sent_id'];
|
341 |
+
|
342 |
+
$get_ac_id_query = "SELECT abandoned_order_id FROM ". $wcal_sent_email_table_name ." WHERE id = %d";
|
343 |
+
$get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query, $email_sent_id ) );
|
344 |
+
|
345 |
+
$abandoned_order_id = '';
|
346 |
+
if ( count( $get_ac_id_results ) > 0 ) {
|
347 |
+
$abandoned_order_id = $get_ac_id_results[0]->abandoned_order_id;
|
348 |
+
}
|
349 |
+
|
350 |
+
$wcal_account_password_check = 'no';
|
351 |
+
|
352 |
+
/*if user becomes the registered user */
|
353 |
+
if ( isset( $_POST['account_password'] ) && $_POST['account_password'] != '' ) {
|
354 |
+
|
355 |
+
$abandoned_cart_id_new_user = '';
|
356 |
+
if ( isset( $_SESSION['abandoned_cart_id_lite'] ) && '' != $_SESSION['abandoned_cart_id_lite'] ) {
|
357 |
+
$abandoned_cart_id_new_user = $_SESSION['abandoned_cart_id_lite'];
|
358 |
+
}
|
359 |
+
|
360 |
+
$wcal_user_id_of_guest = '';
|
361 |
+
if ( isset( $_SESSION['user_id'] ) && '' != $_SESSION['user_id'] ) {
|
362 |
+
$wcal_user_id_of_guest = $_SESSION['user_id'];
|
363 |
+
}
|
364 |
+
|
365 |
+
/* delete the guest record. As it become the logged in user */
|
366 |
+
|
367 |
+
$get_ac_id_guest_results = array();
|
368 |
+
if ( isset( $wcal_user_id_of_guest ) && '' != $wcal_user_id_of_guest ) {
|
369 |
+
$get_ac_id_guest_query = "SELECT id FROM `" . $wcal_history_table_name ."` WHERE user_id = %d ORDER BY id DESC";
|
370 |
+
$get_ac_id_guest_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_guest_query, $wcal_user_id_of_guest ) );
|
371 |
+
}
|
372 |
+
|
373 |
+
if ( count ($get_ac_id_guest_results) > 1 ) {
|
374 |
+
$abandoned_order_id_of_guest = $get_ac_id_guest_results[0]->id;
|
375 |
+
$wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_order_id_of_guest ) );
|
376 |
+
}
|
377 |
+
if ( isset( $abandoned_cart_id_new_user ) && '' != $abandoned_cart_id_new_user ) {
|
378 |
+
/* it is the new registered users cart id */
|
379 |
+
$wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_cart_id_new_user ) );
|
380 |
+
}
|
381 |
+
|
382 |
+
$wcal_account_password_check = 'yes';
|
383 |
+
}
|
384 |
+
|
385 |
+
$wcap_create_account = 'no';
|
386 |
+
/*if user becomes the registred user */
|
387 |
+
if ( isset( $_POST['createaccount'] ) &&
|
388 |
+
$_POST['createaccount'] != '' &&
|
389 |
+
'no' == $wcal_account_password_check ) {
|
390 |
+
|
391 |
+
$abandoned_cart_id_new_user = '';
|
392 |
+
if ( isset ( $_SESSION['abandoned_cart_id_lite'] ) && '' != $_SESSION['abandoned_cart_id_lite'] ) {
|
393 |
+
$abandoned_cart_id_new_user = $_SESSION['abandoned_cart_id_lite'];
|
394 |
+
}
|
395 |
+
$wcal_user_id_of_guest = '';
|
396 |
+
if ( isset( $_SESSION['user_id'] ) && '' != $_SESSION['user_id'] ) {
|
397 |
+
$wcal_user_id_of_guest = $_SESSION['user_id'];
|
398 |
+
}
|
399 |
+
|
400 |
+
|
401 |
+
/* delete the guest record. As it become the logged in user */
|
402 |
+
$get_ac_id_guest_results = array();
|
403 |
+
if ( isset( $wcal_user_id_of_guest ) && '' != $wcal_user_id_of_guest ) {
|
404 |
+
$get_ac_id_guest_query = "SELECT id FROM `" . $wcal_history_table_name ."` WHERE user_id = %d ORDER BY id DESC";
|
405 |
+
$get_ac_id_guest_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_guest_query, $wcal_user_id_of_guest ) );
|
406 |
+
}
|
407 |
+
if ( count ($get_ac_id_guest_results) > 1 ){
|
408 |
+
$abandoned_order_id_of_guest = $get_ac_id_guest_results[0]->id;
|
409 |
+
$wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_order_id_of_guest ) );
|
410 |
+
}
|
411 |
+
|
412 |
+
/* it is the new registered users cart id */
|
413 |
+
if ( isset( $wcal_user_id_of_guest ) && '' != $wcal_user_id_of_guest ) {
|
414 |
+
$wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_cart_id_new_user ) );
|
415 |
+
}
|
416 |
+
|
417 |
+
$wcap_create_account = 'yes';
|
418 |
+
}
|
419 |
+
|
420 |
+
if ( 'no' == $wcal_account_password_check && 'no' == $wcap_create_account ) {
|
421 |
+
|
422 |
+
$wcal_user_id_of_guest = '';
|
423 |
+
if ( isset( $_SESSION['user_id'] ) && '' != $_SESSION['user_id'] ) {
|
424 |
+
$wcal_user_id_of_guest = $_SESSION['user_id'];
|
425 |
+
$get_ac_id_guest_query = "SELECT id FROM `" . $wcal_history_table_name ."` WHERE user_id = %d ORDER BY id DESC";
|
426 |
+
$get_ac_id_guest_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_guest_query, $wcal_user_id_of_guest ) );
|
427 |
+
|
428 |
+
if ( count ($get_ac_id_guest_results) > 1 ) {
|
429 |
+
$abandoned_order_id_of_guest = $get_ac_id_guest_results[0]->id;
|
430 |
+
$wpdb->delete( $wcal_history_table_name, array( 'id' => $abandoned_order_id_of_guest ) );
|
431 |
+
}
|
432 |
+
}
|
433 |
+
}
|
434 |
+
|
435 |
+
add_post_meta( $order_id , 'wcal_recover_order_placed_sent_id', $email_sent_id );
|
436 |
+
if ( isset( $abandoned_order_id ) && '' != $abandoned_order_id ) {
|
437 |
+
add_post_meta( $order_id , 'wcal_recover_order_placed', $abandoned_order_id );
|
438 |
+
}
|
439 |
+
|
440 |
+
}else if ( isset( $_SESSION['abandoned_cart_id_lite'] ) && $_SESSION['abandoned_cart_id_lite'] != '' ) {
|
441 |
+
|
442 |
+
/**
|
443 |
+
* In this codition we are cheking that if the order is placed before the cart cut off time then we
|
444 |
+
* will delete the abandond cart records.
|
445 |
+
* If the order is placed after the cart cutoff time then we will create the post meta with
|
446 |
+
* the abandoned cart id. So we will refer this abandoned cart id when order staus is changed
|
447 |
+
* while placing the order.
|
448 |
+
*/
|
449 |
+
if( session_id() === '' ){
|
450 |
+
//session has not started
|
451 |
+
session_start();
|
452 |
+
}
|
453 |
+
|
454 |
+
global $woocommerce, $wpdb;
|
455 |
+
|
456 |
+
$wcal_history_table_name = $wpdb->prefix . 'ac_abandoned_cart_history_lite';
|
457 |
+
$wcal_guest_table_name = $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite';
|
458 |
+
$wcal_sent_email_table_name = $wpdb->prefix . 'ac_sent_history_lite';
|
459 |
+
|
460 |
+
$current_time = current_time( 'timestamp' );
|
461 |
+
$wcal_cart_abandoned_time = '';
|
462 |
+
if ( isset( $_SESSION['abandoned_cart_id_lite'] ) && '' != $_SESSION['abandoned_cart_id_lite'] ) {
|
463 |
+
$wcal_abandoned_cart_id = $_SESSION['abandoned_cart_id_lite'];
|
464 |
+
|
465 |
+
$get_abandoned_cart_query = "SELECT abandoned_cart_time FROM `" . $wcal_history_table_name . "` WHERE id = %d ";
|
466 |
+
$get_abandoned_cart_results = $wpdb->get_results( $wpdb->prepare( $get_abandoned_cart_query, $wcal_abandoned_cart_id ) );
|
467 |
+
|
468 |
+
if ( count( $get_abandoned_cart_results ) > 0 ){
|
469 |
+
$wcal_cart_abandoned_time = $get_abandoned_cart_results[0]->abandoned_cart_time;
|
470 |
+
}
|
471 |
+
|
472 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
473 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
474 |
+
$compare_time = $current_time - $cut_off_time;
|
475 |
+
|
476 |
+
if ( $compare_time > $wcal_cart_abandoned_time ) {
|
477 |
+
/* cart is declared as adandoned */
|
478 |
+
add_post_meta( $order_id , 'wcal_recover_order_placed', $wcal_abandoned_cart_id );
|
479 |
+
}else {
|
480 |
+
/* cart order is placed within the cutoff time.
|
481 |
+
we will delete that abandoned cart */
|
482 |
+
|
483 |
+
/* if user becomes the registred user */
|
484 |
+
|
485 |
+
if ( isset( $_POST['account_password'] ) && $_POST['account_password'] != '' ) {
|
486 |
+
|
487 |
+
$abandoned_cart_id_new_user = $_SESSION['abandoned_cart_id_lite'];
|
488 |
+
$wcal_user_id_of_guest = $_SESSION['user_id'];
|
489 |
+
|
490 |
+
/* delete the guest record. As it become the logged in user */
|
491 |
+
|
492 |
+
$wpdb->delete( $wcal_history_table_name , array( 'user_id' => $wcal_user_id_of_guest ) );
|
493 |
+
$wpdb->delete( $wcal_guest_table_name , array( 'id' => $wcal_user_id_of_guest ) );
|
494 |
+
|
495 |
+
/* it is the new registered users cart id */
|
496 |
+
$wpdb->delete( $wcal_history_table_name , array( 'id' => $abandoned_cart_id_new_user ) );
|
497 |
+
}else {
|
498 |
+
|
499 |
+
/**
|
500 |
+
* It will delete the order from history table if the order is placed before any email sent to
|
501 |
+
* the user.
|
502 |
+
*/
|
503 |
+
$wpdb->delete( $wcal_history_table_name , array( 'id' => $wcap_abandoned_cart_id ) );
|
504 |
+
|
505 |
+
/* this user id is set for the guest uesrs. */
|
506 |
+
if ( isset( $_SESSION['user_id'] ) && $_SESSION['user_id'] != '' ) {
|
507 |
+
|
508 |
+
$wcal_user_id_of_guest = $_SESSION['user_id'];
|
509 |
+
$wpdb->delete( $wcal_guest_table_name, array( 'id' => $wcal_user_id_of_guest ) );
|
510 |
+
}
|
511 |
+
}
|
512 |
+
}
|
513 |
+
}
|
514 |
+
}
|
515 |
+
}
|
516 |
+
|
517 |
+
public function wcal_order_complete_action( $order_status, $order_id ) {
|
518 |
+
|
519 |
+
/**
|
520 |
+
* If the order status is not pending or failed then we will check the order and its respective abandoned
|
521 |
+
* cart data.
|
522 |
+
*/
|
523 |
+
if ( 'pending' != $order_status && 'failed' != $order_status ) {
|
524 |
+
global $woocommerce, $wpdb;
|
525 |
+
$order = new WC_Order( $order_id );
|
526 |
+
|
527 |
+
$get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
|
528 |
+
$get_sent_email_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed_sent_id', true );
|
529 |
+
|
530 |
+
$wcal_ac_table_name = $wpdb->prefix . "ac_abandoned_cart_history_lite";
|
531 |
+
$wcal_email_sent_history_table_name = $wpdb->prefix . "ac_sent_history_lite";
|
532 |
+
$wcal_guest_ac_table_name = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
|
533 |
+
|
534 |
+
/**
|
535 |
+
* Here, in this condition we are checking that if abadoned cart id has any record for the reminder
|
536 |
+
* email is sent or not.
|
537 |
+
* If the reminde email is sent to the abandoned cart id the mark that cart as a recovered.
|
538 |
+
*/
|
539 |
+
if ( isset( $get_sent_email_id_of_order ) && '' != $get_sent_email_id_of_order ) {
|
540 |
+
|
541 |
+
$query_order = "UPDATE $wcal_ac_table_name SET recovered_cart = '" . $order_id . "', cart_ignored = '1' WHERE id = '".$get_abandoned_id_of_order."' ";
|
542 |
+
$wpdb->query( $query_order );
|
543 |
+
|
544 |
+
$order->add_order_note( __( 'This order was abandoned & subsequently recovered.', 'woocommerce-ac' ) );
|
545 |
+
|
546 |
+
delete_post_meta( $order_id, 'wcal_recover_order_placed', $get_abandoned_id_of_order );
|
547 |
+
delete_post_meta( $order_id , 'wcal_recover_order_placed_sent_id', $get_sent_email_id_of_order );
|
548 |
+
} else if ( isset( $get_abandoned_id_of_order ) && '' != $get_abandoned_id_of_order ) {
|
549 |
+
|
550 |
+
/**
|
551 |
+
* If the recover email has not sent then we will delete the abandoned cart data.
|
552 |
+
*/
|
553 |
+
$get_abandoned_cart_user_id_query = "SELECT user_id FROM $wcal_ac_table_name WHERE id = %d ";
|
554 |
+
$get_abandoned_cart_user_id_results = $wpdb->get_results( $wpdb->prepare( $get_abandoned_cart_user_id_query, $get_abandoned_id_of_order ) );
|
555 |
+
|
556 |
+
$var = $wpdb->prepare( $get_abandoned_cart_user_id_query, $get_abandoned_id_of_order );
|
557 |
+
|
558 |
+
if ( count( $get_abandoned_cart_user_id_results ) > 0 ) {
|
559 |
+
$wcap_user_id = $get_abandoned_cart_user_id_results[0]->user_id;
|
560 |
+
|
561 |
+
if ( $wcap_user_id >= 63000000 ){
|
562 |
+
$wpdb->delete( $wcal_guest_ac_table_name , array( 'id' => $wcap_user_id ) );
|
563 |
+
}
|
564 |
+
|
565 |
+
$wpdb->delete( $wcal_ac_table_name , array( 'id' => $get_abandoned_id_of_order ) );
|
566 |
+
delete_post_meta( $order_id, 'wcap_recover_order_placed', $get_abandoned_id_of_order );
|
567 |
+
}
|
568 |
+
}
|
569 |
+
}
|
570 |
+
return $order_status;
|
571 |
+
}
|
572 |
+
|
573 |
+
/*-----------------------------------------------------------------------------------*/
|
574 |
+
/* Class Functions */
|
575 |
+
/*-----------------------------------------------------------------------------------*/
|
576 |
+
/**
|
577 |
+
* Preview email template
|
578 |
+
*
|
579 |
+
* @return string
|
580 |
+
*/
|
581 |
+
public function wcal_preview_emails() {
|
582 |
+
global $woocommerce;
|
583 |
+
if( isset( $_GET['wcal_preview_woocommerce_mail'] ) ) {
|
584 |
+
if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-ac' ) ) {
|
585 |
+
die( 'Security check' );
|
586 |
+
}
|
587 |
+
$message = '';
|
588 |
+
// create a new email
|
589 |
+
if( $woocommerce->version < '2.3' ) {
|
590 |
+
global $email_heading;
|
591 |
+
ob_start();
|
592 |
+
|
593 |
+
include( 'views/wcal-wc-email-template-preview.php' );
|
594 |
+
$mailer = WC()->mailer();
|
595 |
+
$message = ob_get_clean();
|
596 |
+
$email_heading = __( 'HTML Email Template', 'woocommerce-ac' );
|
597 |
+
$message = $mailer->wrap_message( $email_heading, $message );
|
598 |
+
} else {
|
599 |
+
// load the mailer class
|
600 |
+
$mailer = WC()->mailer();
|
601 |
+
// get the preview email subject
|
602 |
+
$email_heading = __( 'Abandoned cart Email Template', 'woocommerce-ac' );
|
603 |
+
// get the preview email content
|
604 |
+
ob_start();
|
605 |
+
include( 'views/wcal-wc-email-template-preview.php' );
|
606 |
+
$message = ob_get_clean();
|
607 |
+
// create a new email
|
608 |
+
$email = new WC_Email();
|
609 |
+
// wrap the content with the email template and then add styles
|
610 |
+
$message = $email->style_inline( $mailer->wrap_message( $email_heading, $message ) );
|
611 |
+
}
|
612 |
+
echo $message;
|
613 |
+
exit;
|
614 |
+
}
|
615 |
+
|
616 |
+
if ( isset( $_GET['wcal_preview_mail'] ) ) {
|
617 |
+
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-ac' ) ) {
|
618 |
+
die( 'Security check' );
|
619 |
+
}
|
620 |
+
// get the preview email content
|
621 |
+
ob_start();
|
622 |
+
include( 'views/wcal-email-template-preview.php' );
|
623 |
+
$message = ob_get_clean();
|
624 |
+
// print the preview email
|
625 |
+
echo $message;
|
626 |
+
exit;
|
627 |
+
}
|
628 |
+
}
|
629 |
+
|
630 |
+
// Language Translation
|
631 |
+
function wcal_update_po_file() {
|
632 |
+
$domain = 'woocommerce-ac';
|
633 |
+
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
|
634 |
+
if ( $loaded = load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '-' . $locale . '.mo' ) ) {
|
635 |
+
return $loaded;
|
636 |
+
} else {
|
637 |
+
load_plugin_textdomain( $domain, FALSE, basename( dirname( __FILE__ ) ) . '/i18n/languages/' );
|
638 |
+
}
|
639 |
+
}
|
640 |
+
|
641 |
+
/*-----------------------------------------------------------------------------------*/
|
642 |
+
/* Class Functions */
|
643 |
+
/*-----------------------------------------------------------------------------------*/
|
644 |
+
function wcal_activate() {
|
645 |
+
global $wpdb;
|
646 |
+
$wcap_collate = '';
|
647 |
+
if( $wpdb->has_cap( 'collation' ) ) {
|
648 |
+
$wcap_collate = $wpdb->get_charset_collate();
|
649 |
+
}
|
650 |
+
$table_name = $wpdb->prefix . "ac_email_templates_lite";
|
651 |
+
$sql = "CREATE TABLE IF NOT EXISTS $table_name (
|
652 |
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
653 |
+
`subject` text COLLATE utf8_unicode_ci NOT NULL,
|
654 |
+
`body` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
655 |
+
`is_active` enum('0','1') COLLATE utf8_unicode_ci NOT NULL,
|
656 |
+
`frequency` int(11) NOT NULL,
|
657 |
+
`day_or_hour` enum('Days','Hours') COLLATE utf8_unicode_ci NOT NULL,
|
658 |
+
`template_name` text COLLATE utf8_unicode_ci NOT NULL,
|
659 |
+
PRIMARY KEY (`id`)
|
660 |
+
) $wcap_collate AUTO_INCREMENT=1 ";
|
661 |
+
|
662 |
+
require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
663 |
+
dbDelta( $sql );
|
664 |
+
|
665 |
+
$table_name = $wpdb->prefix . "ac_email_templates_lite";
|
666 |
+
$check_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'is_wc_template' ";
|
667 |
+
$results = $wpdb->get_results( $check_template_table_query );
|
668 |
+
|
669 |
+
if ( count( $results ) == 0 ) {
|
670 |
+
$alter_template_table_query = "ALTER TABLE $table_name
|
671 |
+
ADD COLUMN `is_wc_template` enum('0','1') COLLATE utf8_unicode_ci NOT NULL AFTER `template_name`,
|
672 |
+
ADD COLUMN `default_template` int(11) NOT NULL AFTER `is_wc_template`";
|
673 |
+
|
674 |
+
$wpdb->get_results( $alter_template_table_query );
|
675 |
+
}
|
676 |
+
|
677 |
+
$sent_table_name = $wpdb->prefix . "ac_sent_history_lite";
|
678 |
+
|
679 |
+
$sql_query = "CREATE TABLE IF NOT EXISTS $sent_table_name (
|
680 |
+
`id` int(11) NOT NULL auto_increment,
|
681 |
+
`template_id` varchar(40) collate utf8_unicode_ci NOT NULL,
|
682 |
+
`abandoned_order_id` int(11) NOT NULL,
|
683 |
+
`sent_time` datetime NOT NULL,
|
684 |
+
`sent_email_id` text COLLATE utf8_unicode_ci NOT NULL,
|
685 |
+
PRIMARY KEY (`id`)
|
686 |
+
) $wcap_collate AUTO_INCREMENT=1 ";
|
687 |
+
|
688 |
+
require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
689 |
+
dbDelta ( $sql_query );
|
690 |
+
|
691 |
+
$ac_history_table_name = $wpdb->prefix . "ac_abandoned_cart_history_lite";
|
692 |
+
|
693 |
+
$history_query = "CREATE TABLE IF NOT EXISTS $ac_history_table_name (
|
694 |
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
695 |
+
`user_id` int(11) NOT NULL,
|
696 |
+
`abandoned_cart_info` text COLLATE utf8_unicode_ci NOT NULL,
|
697 |
+
`abandoned_cart_time` int(11) NOT NULL,
|
698 |
+
`cart_ignored` enum('0','1') COLLATE utf8_unicode_ci NOT NULL,
|
699 |
+
`recovered_cart` int(11) NOT NULL,
|
700 |
+
PRIMARY KEY (`id`)
|
701 |
+
) $wcap_collate";
|
702 |
+
|
703 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
704 |
+
dbDelta( $history_query );
|
705 |
+
// Default templates: function call to create default templates.
|
706 |
+
$check_table_empty = $wpdb->get_var( "SELECT COUNT(*) FROM `" . $wpdb->prefix . "ac_email_templates_lite`" );
|
707 |
+
|
708 |
+
if( !get_option( 'woocommerce_ac_default_templates_installed' ) ) {
|
709 |
+
if( 0 == $check_table_empty ) {
|
710 |
+
$default_template = new wcal_default_template_settings;
|
711 |
+
$default_template->wcal_create_default_templates();
|
712 |
+
update_option( 'woocommerce_ac_default_templates_installed', "yes" );
|
713 |
+
}
|
714 |
+
}
|
715 |
+
|
716 |
+
$guest_table = $wpdb->prefix."ac_guest_abandoned_cart_history_lite" ;
|
717 |
+
$query_guest_table = "SHOW TABLES LIKE '$guest_table' ";
|
718 |
+
$result_guest_table = $wpdb->get_results( $query_guest_table );
|
719 |
+
|
720 |
+
if ( count( $result_guest_table ) == 0 ) {
|
721 |
+
$ac_guest_history_table_name = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
|
722 |
+
$ac_guest_history_query = "CREATE TABLE IF NOT EXISTS $ac_guest_history_table_name (
|
723 |
+
`id` int(15) NOT NULL AUTO_INCREMENT,
|
724 |
+
`billing_first_name` text,
|
725 |
+
`billing_last_name` text,
|
726 |
+
`billing_company_name` text,
|
727 |
+
`billing_address_1` text,
|
728 |
+
`billing_address_2` text,
|
729 |
+
`billing_city` text,
|
730 |
+
`billing_county` text,
|
731 |
+
`billing_zipcode` text,
|
732 |
+
`email_id` text,
|
733 |
+
`phone` text,
|
734 |
+
`ship_to_billing` text,
|
735 |
+
`order_notes` text,
|
736 |
+
`shipping_first_name` text,
|
737 |
+
`shipping_last_name` text,
|
738 |
+
`shipping_company_name` text,
|
739 |
+
`shipping_address_1` text,
|
740 |
+
`shipping_address_2` text,
|
741 |
+
`shipping_city` text,
|
742 |
+
`shipping_county` text,
|
743 |
+
`shipping_zipcode` double,
|
744 |
+
`shipping_charges` double,
|
745 |
+
PRIMARY KEY (`id`)
|
746 |
+
) $wcap_collate AUTO_INCREMENT=63000000";
|
747 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php');
|
748 |
+
$wpdb->query( $ac_guest_history_query );
|
749 |
+
}
|
750 |
+
|
751 |
+
/**
|
752 |
+
* This is add for thos user who Install the plguin first time.
|
753 |
+
* So for them this option will be cheked.
|
754 |
+
*/
|
755 |
+
if( !get_option( 'ac_lite_track_guest_cart_from_cart_page' ) ) {
|
756 |
+
add_option( 'ac_lite_track_guest_cart_from_cart_page', 'on' );
|
757 |
+
}
|
758 |
+
if( !get_option( 'wcal_from_name' ) ) {
|
759 |
+
add_option( 'wcal_from_name', 'Admin' );
|
760 |
+
}
|
761 |
+
$wcal_get_admin_email = get_option( 'admin_email' );
|
762 |
+
if( !get_option( 'wcal_from_email' ) ) {
|
763 |
+
add_option( 'wcal_from_email', $wcal_get_admin_email );
|
764 |
+
}
|
765 |
+
|
766 |
+
if( !get_option( 'wcal_reply_email' ) ) {
|
767 |
+
add_option( 'wcal_reply_email', $wcal_get_admin_email );
|
768 |
+
}
|
769 |
+
|
770 |
+
if( !get_option( 'wcal_activate_time' ) ) {
|
771 |
+
add_option( 'wcal_activate_time', current_time( 'timestamp' ) );
|
772 |
+
}
|
773 |
+
}
|
774 |
+
|
775 |
+
/***************************************************************
|
776 |
+
* WP Settings API
|
777 |
+
**************************************************************/
|
778 |
+
function wcal_initialize_plugin_options() {
|
779 |
+
|
780 |
+
// First, we register a section. This is necessary since all future options must belong to a
|
781 |
+
add_settings_section(
|
782 |
+
'ac_lite_general_settings_section', // ID used to identify this section and with which to register options
|
783 |
+
__( 'Settings', 'woocommerce-ac' ), // Title to be displayed on the administration page
|
784 |
+
array($this, 'ac_lite_general_options_callback' ), // Callback used to render the description of the section
|
785 |
+
'woocommerce_ac_page' // Page on which to add this section of options
|
786 |
+
);
|
787 |
+
|
788 |
+
add_settings_field(
|
789 |
+
'ac_lite_cart_abandoned_time',
|
790 |
+
__( 'Cart abandoned cut-off time', 'woocommerce-ac' ),
|
791 |
+
array( $this, 'ac_lite_cart_abandoned_time_callback' ),
|
792 |
+
'woocommerce_ac_page',
|
793 |
+
'ac_lite_general_settings_section',
|
794 |
+
array( __( 'Consider cart abandoned after X minutes of item being added to cart & order not placed.', 'woocommerce-ac' ) )
|
795 |
+
);
|
796 |
+
|
797 |
+
add_settings_field(
|
798 |
+
'ac_lite_email_admin_on_recovery',
|
799 |
+
__( 'Email admin On Order Recovery', 'woocommerce-ac' ),
|
800 |
+
array( $this, 'ac_lite_email_admin_on_recovery' ),
|
801 |
+
'woocommerce_ac_page',
|
802 |
+
'ac_lite_general_settings_section',
|
803 |
+
array( __( 'Sends email to Admin if an Abandoned Cart Order is recovered.', 'woocommerce-ac' ) )
|
804 |
+
);
|
805 |
+
|
806 |
+
add_settings_field(
|
807 |
+
'ac_lite_track_guest_cart_from_cart_page',
|
808 |
+
__( 'Start tracking from Cart Page', 'woocommerce-ac' ),
|
809 |
+
array( $this, 'wcal_track_guest_cart_from_cart_page_callback' ),
|
810 |
+
'woocommerce_ac_page',
|
811 |
+
'ac_lite_general_settings_section',
|
812 |
+
array( __( 'Enable tracking of abandoned products & carts even if customer does not visit the checkout page or does not enter any details on the checkout page like Name or Email. Tracking will begin as soon as a visitor adds a product to their cart and visits the cart page.', 'woocommerce-ac' ) )
|
813 |
+
);
|
814 |
+
/*
|
815 |
+
* New section for the Adding the abandoned cart setting.
|
816 |
+
* Since @: 4.7
|
817 |
+
*/
|
818 |
+
|
819 |
+
add_settings_section(
|
820 |
+
'ac_email_settings_section', // ID used to identify this section and with which to register options
|
821 |
+
__( 'Settings for abandoned cart recovery emails', 'woocommerce-ac' ), // Title to be displayed on the administration page
|
822 |
+
array($this, 'wcal_email_callback' ),// Callback used to render the description of the section
|
823 |
+
'woocommerce_ac_email_page' // Page on which to add this section of options
|
824 |
+
);
|
825 |
+
|
826 |
+
add_settings_field(
|
827 |
+
'wcal_from_name',
|
828 |
+
__( '"From" Name', 'woocommerce-ac' ),
|
829 |
+
array( $this, 'wcal_from_name_callback' ),
|
830 |
+
'woocommerce_ac_email_page',
|
831 |
+
'ac_email_settings_section',
|
832 |
+
array( 'Enter the name that should appear in the email sent.', 'woocommerce-ac' )
|
833 |
+
);
|
834 |
+
|
835 |
+
add_settings_field(
|
836 |
+
'wcal_from_email',
|
837 |
+
__( '"From" Address', 'woocommerce-ac' ),
|
838 |
+
array( $this, 'wcal_from_email_callback' ),
|
839 |
+
'woocommerce_ac_email_page',
|
840 |
+
'ac_email_settings_section',
|
841 |
+
array( 'Email address from which the reminder emails should be sent.', 'woocommerce-ac' )
|
842 |
+
);
|
843 |
+
|
844 |
+
add_settings_field(
|
845 |
+
'wcal_reply_email',
|
846 |
+
__( 'Send Reply Emails to', 'woocommerce-ac' ),
|
847 |
+
array( $this, 'wcal_reply_email_callback' ),
|
848 |
+
'woocommerce_ac_email_page',
|
849 |
+
'ac_email_settings_section',
|
850 |
+
array( 'When a contact receives your email and clicks reply, which email address should that reply be sent to?', 'woocommerce-ac' )
|
851 |
+
);
|
852 |
+
|
853 |
+
// Finally, we register the fields with WordPress
|
854 |
+
register_setting(
|
855 |
+
'woocommerce_ac_settings',
|
856 |
+
'ac_lite_cart_abandoned_time',
|
857 |
+
array ( $this, 'ac_lite_cart_time_validation' )
|
858 |
+
);
|
859 |
+
|
860 |
+
register_setting(
|
861 |
+
'woocommerce_ac_settings',
|
862 |
+
'ac_lite_email_admin_on_recovery'
|
863 |
+
);
|
864 |
+
|
865 |
+
register_setting(
|
866 |
+
'woocommerce_ac_settings',
|
867 |
+
'ac_lite_track_guest_cart_from_cart_page'
|
868 |
+
);
|
869 |
+
|
870 |
+
register_setting(
|
871 |
+
'woocommerce_ac_email_settings',
|
872 |
+
'wcal_from_name'
|
873 |
+
);
|
874 |
+
register_setting(
|
875 |
+
'woocommerce_ac_email_settings',
|
876 |
+
'wcal_from_email'
|
877 |
+
);
|
878 |
+
register_setting(
|
879 |
+
'woocommerce_ac_email_settings',
|
880 |
+
'wcal_reply_email'
|
881 |
+
);
|
882 |
+
}
|
883 |
+
|
884 |
+
/***************************************************************
|
885 |
+
* WP Settings API callback for section
|
886 |
+
**************************************************************/
|
887 |
+
function ac_lite_general_options_callback() {
|
888 |
+
|
889 |
+
}
|
890 |
+
|
891 |
+
/***************************************************************
|
892 |
+
* WP Settings API callback for cart time field
|
893 |
+
**************************************************************/
|
894 |
+
function ac_lite_cart_abandoned_time_callback( $args ) {
|
895 |
+
// First, we read the option
|
896 |
+
$cart_abandoned_time = get_option( 'ac_lite_cart_abandoned_time' );
|
897 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
898 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
899 |
+
printf(
|
900 |
+
'<input type="text" id="ac_lite_cart_abandoned_time" name="ac_lite_cart_abandoned_time" value="%s" />',
|
901 |
+
isset( $cart_abandoned_time ) ? esc_attr( $cart_abandoned_time ) : ''
|
902 |
+
);
|
903 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
904 |
+
$html = '<label for="ac_lite_cart_abandoned_time"> ' . $args[0] . '</label>';
|
905 |
+
echo $html;
|
906 |
+
}
|
907 |
+
|
908 |
+
/***************************************************************
|
909 |
+
* WP Settings API cart time field validation
|
910 |
+
**************************************************************/
|
911 |
+
function ac_lite_cart_time_validation( $input ) {
|
912 |
+
$output = '';
|
913 |
+
if ( $input != '' && ( is_numeric( $input) && $input > 0 ) ) {
|
914 |
+
$output = stripslashes( $input) ;
|
915 |
+
} else {
|
916 |
+
add_settings_error( 'ac_lite_cart_abandoned_time', 'error found', __( 'Abandoned cart cut off time should be numeric and has to be greater than 0.', 'woocommerce-ac' ) );
|
917 |
+
}
|
918 |
+
return $output;
|
919 |
+
}
|
920 |
+
|
921 |
+
/***************************************************************
|
922 |
+
* WP Settings API callback for email admin on cart recovery field
|
923 |
+
**************************************************************/
|
924 |
+
function ac_lite_email_admin_on_recovery( $args ) {
|
925 |
+
// First, we read the option
|
926 |
+
$email_admin_on_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
|
927 |
+
|
928 |
+
// This condition added to avoid the notie displyed while Check box is unchecked.
|
929 |
+
if( isset( $email_admin_on_recovery ) && $email_admin_on_recovery == '' ) {
|
930 |
+
$email_admin_on_recovery = 'off';
|
931 |
+
}
|
932 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
933 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
934 |
+
$html='';
|
935 |
+
printf(
|
936 |
+
'<input type="checkbox" id="ac_lite_email_admin_on_recovery" name="ac_lite_email_admin_on_recovery" value="on"
|
937 |
+
' . checked('on', $email_admin_on_recovery, false).' />'
|
938 |
+
);
|
939 |
+
|
940 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
941 |
+
$html .= '<label for="ac_lite_email_admin_on_recovery"> ' . $args[0] . '</label>';
|
942 |
+
echo $html;
|
943 |
+
}
|
944 |
+
/***************************************************************
|
945 |
+
* @since : 2.7
|
946 |
+
* WP Settings API callback for capturing guest cart which do not reach the checkout page.
|
947 |
+
**************************************************************/
|
948 |
+
function wcal_track_guest_cart_from_cart_page_callback( $args ) {
|
949 |
+
// First, we read the option
|
950 |
+
$disable_guest_cart_from_cart_page = get_option( 'ac_lite_track_guest_cart_from_cart_page' );
|
951 |
+
|
952 |
+
// This condition added to avoid the notice displyed while Check box is unchecked.
|
953 |
+
if ( isset( $disable_guest_cart_from_cart_page ) && $disable_guest_cart_from_cart_page == '' ) {
|
954 |
+
$disable_guest_cart_from_cart_page = 'off';
|
955 |
+
}
|
956 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
957 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
958 |
+
$html = '';
|
959 |
+
|
960 |
+
printf(
|
961 |
+
'<input type="checkbox" id="ac_lite_track_guest_cart_from_cart_page" name="ac_lite_track_guest_cart_from_cart_page" value="on"
|
962 |
+
'.checked( 'on', $disable_guest_cart_from_cart_page, false ) . ' />' );
|
963 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
964 |
+
$html .= '<label for="ac_lite_track_guest_cart_from_cart_page"> ' . $args[0] . '</label>';
|
965 |
+
echo $html;
|
966 |
+
}
|
967 |
+
|
968 |
+
/***************************************************************
|
969 |
+
* WP Settings API callback for Abandoned cart email settings of the plugin
|
970 |
+
**************************************************************/
|
971 |
+
function wcal_email_callback () {
|
972 |
+
|
973 |
+
}
|
974 |
+
|
975 |
+
public static function wcal_from_name_callback( $args ) {
|
976 |
+
// First, we read the option
|
977 |
+
$wcal_from_name = get_option( 'wcal_from_name' );
|
978 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
979 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
980 |
+
printf(
|
981 |
+
'<input type="text" id="wcal_from_name" name="wcal_from_name" value="%s" />',
|
982 |
+
isset( $wcal_from_name ) ? esc_attr( $wcal_from_name ) : ''
|
983 |
+
);
|
984 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
985 |
+
$html = '<label for="wcal_from_name_label"> ' . $args[0] . '</label>';
|
986 |
+
echo $html;
|
987 |
+
}
|
988 |
+
|
989 |
+
public static function wcal_from_email_callback( $args ) {
|
990 |
+
// First, we read the option
|
991 |
+
$wcal_from_email = get_option( 'wcal_from_email' );
|
992 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
993 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
994 |
+
printf(
|
995 |
+
'<input type="text" id="wcal_from_email" name="wcal_from_email" value="%s" />',
|
996 |
+
isset( $wcal_from_email ) ? esc_attr( $wcal_from_email ) : ''
|
997 |
+
);
|
998 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
999 |
+
$html = '<label for="wcal_from_email_label"> ' . $args[0] . '</label>';
|
1000 |
+
echo $html;
|
1001 |
+
}
|
1002 |
+
|
1003 |
+
public static function wcal_reply_email_callback( $args ) {
|
1004 |
+
// First, we read the option
|
1005 |
+
$wcal_reply_email = get_option( 'wcal_reply_email' );
|
1006 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
1007 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
1008 |
+
printf(
|
1009 |
+
'<input type="text" id="wcal_reply_email" name="wcal_reply_email" value="%s" />',
|
1010 |
+
isset( $wcal_reply_email ) ? esc_attr( $wcal_reply_email ) : ''
|
1011 |
+
);
|
1012 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
1013 |
+
$html = '<label for="wcal_reply_email_label"> ' . $args[0] . '</label>';
|
1014 |
+
echo $html;
|
1015 |
+
}
|
1016 |
+
/**************************************************
|
1017 |
+
* This function is run when the plugin is upgraded
|
1018 |
+
*************************************************/
|
1019 |
+
function wcal_update_db_check() {
|
1020 |
+
global $wpdb;
|
1021 |
+
|
1022 |
+
if( get_option( 'ac_lite_alter_table_queries' ) != 'yes' ) {
|
1023 |
+
$ac_history_table_name = $wpdb->prefix."ac_abandoned_cart_history_lite";
|
1024 |
+
$check_table_query = "SHOW COLUMNS FROM $ac_history_table_name LIKE 'user_type'";
|
1025 |
+
$results = $wpdb->get_results( $check_table_query );
|
1026 |
+
|
1027 |
+
if ( count( $results ) == 0 ) {
|
1028 |
+
$alter_table_query = "ALTER TABLE $ac_history_table_name ADD `user_type` text AFTER `recovered_cart`";
|
1029 |
+
$wpdb->get_results( $alter_table_query );
|
1030 |
+
}
|
1031 |
+
|
1032 |
+
$table_name = $wpdb->prefix . "ac_email_templates_lite";
|
1033 |
+
$check_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'is_wc_template' ";
|
1034 |
+
$results = $wpdb->get_results( $check_template_table_query );
|
1035 |
+
|
1036 |
+
if ( count( $results ) == 0 ) {
|
1037 |
+
$alter_template_table_query = "ALTER TABLE $table_name
|
1038 |
+
ADD COLUMN `is_wc_template` enum('0','1') COLLATE utf8_unicode_ci NOT NULL AFTER `template_name`,
|
1039 |
+
ADD COLUMN `default_template` int(11) NOT NULL AFTER `is_wc_template`";
|
1040 |
+
$wpdb->get_results( $alter_template_table_query );
|
1041 |
+
}
|
1042 |
+
|
1043 |
+
$table_name = $wpdb->prefix . "ac_email_templates_lite";
|
1044 |
+
$check_email_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'wc_email_header' ";
|
1045 |
+
$results_email = $wpdb->get_results( $check_email_template_table_query );
|
1046 |
+
|
1047 |
+
if ( count( $results_email ) == 0 ) {
|
1048 |
+
$alter_email_template_table_query = "ALTER TABLE $table_name
|
1049 |
+
ADD COLUMN `wc_email_header` varchar(50) COLLATE utf8_unicode_ci NOT NULL AFTER `default_template`";
|
1050 |
+
$wpdb->get_results( $alter_email_template_table_query );
|
1051 |
+
}
|
1052 |
+
|
1053 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_abandoned_cart_history_lite';" ) ) {
|
1054 |
+
if ( ! $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_abandoned_cart_history_lite` LIKE 'unsubscribe_link';" ) ) {
|
1055 |
+
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_abandoned_cart_history_lite ADD `unsubscribe_link` enum('0','1') COLLATE utf8_unicode_ci NOT NULL AFTER `user_type`;" );
|
1056 |
+
}
|
1057 |
+
}
|
1058 |
+
|
1059 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_abandoned_cart_history_lite';" ) ) {
|
1060 |
+
if ( ! $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_abandoned_cart_history_lite` LIKE 'session_id';" ) ) {
|
1061 |
+
$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`;" );
|
1062 |
+
}
|
1063 |
+
}
|
1064 |
+
/**
|
1065 |
+
*
|
1066 |
+
* This is used to prevent guest users wrong Id. If guest users id is less then 63000000 then this code will ensure that we
|
1067 |
+
* will change the id of guest tables so it wont affect on the next guest users.
|
1068 |
+
*/
|
1069 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_guest_abandoned_cart_history_lite';" ) && 'yes' != get_option( 'wcal_guest_user_id_altered' ) ) {
|
1070 |
+
$last_id = $wpdb->get_var( "SELECT max(id) FROM `{$wpdb->prefix}ac_guest_abandoned_cart_history_lite`;" );
|
1071 |
+
if ( NULL != $last_id && $last_id <= 63000000 ) {
|
1072 |
+
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_guest_abandoned_cart_history_lite AUTO_INCREMENT = 63000000;" );
|
1073 |
+
update_option ( 'wcal_guest_user_id_altered', 'yes' );
|
1074 |
+
}
|
1075 |
+
}
|
1076 |
+
|
1077 |
+
/**
|
1078 |
+
* We have moved email templates fields in the setings section. SO to remove that fields column fro the db we need it.
|
1079 |
+
* For existing user we need to fill this setting with the first template.
|
1080 |
+
* @since 4.7
|
1081 |
+
*/
|
1082 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_email_templates_lite';" ) ) {
|
1083 |
+
if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'from_email';" ) ) {
|
1084 |
+
$get_email_template_query = "SELECT `from_email` FROM {$wpdb->prefix}ac_email_templates_lite WHERE `is_active` = '1' ORDER BY `id` ASC LIMIT 1";
|
1085 |
+
$get_email_template_result = $wpdb->get_results ($get_email_template_query);
|
1086 |
+
$wcal_from_email = '';
|
1087 |
+
if ( isset( $get_email_template_result ) && count ( $get_email_template_result ) > 0 ){
|
1088 |
+
$wcal_from_email = $get_email_template_result[0]->from_email;
|
1089 |
+
/* Store data in setings api*/
|
1090 |
+
update_option ( 'wcal_from_email', $wcal_from_email );
|
1091 |
+
/* Delete table from the Db*/
|
1092 |
+
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_email_templates_lite DROP COLUMN `from_email`;" );
|
1093 |
+
}
|
1094 |
+
}
|
1095 |
+
|
1096 |
+
if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'from_name';" ) ) {
|
1097 |
+
$get_email_template_from_name_query = "SELECT `from_name` FROM {$wpdb->prefix}ac_email_templates_lite WHERE `is_active` = '1' ORDER BY `id` ASC LIMIT 1";
|
1098 |
+
$get_email_template_from_name_result = $wpdb->get_results ($get_email_template_from_name_query);
|
1099 |
+
$wcal_from_name = '';
|
1100 |
+
if ( isset( $get_email_template_from_name_result ) && count ( $get_email_template_from_name_result ) > 0 ){
|
1101 |
+
$wcal_from_name = $get_email_template_from_name_result[0]->from_name;
|
1102 |
+
/* Store data in setings api*/
|
1103 |
+
add_option ( 'wcal_from_name', $wcal_from_name );
|
1104 |
+
/* Delete table from the Db*/
|
1105 |
+
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_email_templates_lite DROP COLUMN `from_name`;" );
|
1106 |
+
}
|
1107 |
+
}
|
1108 |
+
|
1109 |
+
if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'reply_email';" ) ) {
|
1110 |
+
$get_email_template_reply_email_query = "SELECT `reply_email` FROM {$wpdb->prefix}ac_email_templates_lite WHERE `is_active` = '1' ORDER BY `id` ASC LIMIT 1";
|
1111 |
+
$get_email_template_reply_email_result = $wpdb->get_results ($get_email_template_reply_email_query);
|
1112 |
+
$wcal_reply_email = '';
|
1113 |
+
if ( isset( $get_email_template_reply_email_result ) && count ( $get_email_template_reply_email_result ) > 0 ){
|
1114 |
+
$wcal_reply_email = $get_email_template_reply_email_result[0]->reply_email;
|
1115 |
+
/* Store data in setings api*/
|
1116 |
+
update_option ( 'wcal_reply_email', $wcal_reply_email );
|
1117 |
+
/* Delete table from the Db*/
|
1118 |
+
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_email_templates_lite DROP COLUMN `reply_email`;" );
|
1119 |
+
}
|
1120 |
+
}
|
1121 |
+
}
|
1122 |
+
|
1123 |
+
if ( !get_option( 'wcal_security_key' ) ){
|
1124 |
+
update_option( 'wcal_security_key', 'qJB0rGtIn5UB1xG03efyCp' );
|
1125 |
+
}
|
1126 |
+
|
1127 |
+
update_option( 'ac_lite_alter_table_queries', 'yes' );
|
1128 |
+
}
|
1129 |
+
|
1130 |
+
//get the option, if it is not set to individual then convert to individual records and delete the base record
|
1131 |
+
$ac_settings = get_option( 'ac_lite_settings_status' );
|
1132 |
+
if ( $ac_settings != 'INDIVIDUAL' ) {
|
1133 |
+
//fetch the existing settings and save them as inidividual to be used for the settings API
|
1134 |
+
$woocommerce_ac_settings = json_decode( get_option( 'woocommerce_ac_settings' ) );
|
1135 |
+
if( isset( $woocommerce_ac_settings[0]->cart_time ) ) {
|
1136 |
+
add_option( 'ac_lite_cart_abandoned_time', $woocommerce_ac_settings[0]->cart_time );
|
1137 |
+
} else {
|
1138 |
+
add_option( 'ac_lite_cart_abandoned_time', '10' );
|
1139 |
+
}
|
1140 |
+
|
1141 |
+
if( isset( $woocommerce_ac_settings[0]->email_admin ) ) {
|
1142 |
+
add_option( 'ac_lite_email_admin_on_recovery', $woocommerce_ac_settings[0]->email_admin );
|
1143 |
+
} else {
|
1144 |
+
add_option( 'ac_lite_email_admin_on_recovery', "" );
|
1145 |
+
}
|
1146 |
+
if( isset( $woocommerce_ac_settings[0]->disable_guest_cart_from_cart_page ) ) {
|
1147 |
+
add_option( 'ac_lite_track_guest_cart_from_cart_page', $woocommerce_ac_settings[0]->disable_guest_cart_from_cart_page );
|
1148 |
+
} else {
|
1149 |
+
add_option( 'ac_lite_track_guest_cart_from_cart_page', "" );
|
1150 |
+
}
|
1151 |
+
update_option( 'ac_lite_settings_status', 'INDIVIDUAL' );
|
1152 |
+
//Delete the main settings record
|
1153 |
+
delete_option( 'woocommerce_ac_settings' );
|
1154 |
+
}
|
1155 |
+
}
|
1156 |
+
|
1157 |
+
/**
|
1158 |
+
* Send email to admin when cart is recovered only via PayPal.
|
1159 |
+
* @since 2.9 version
|
1160 |
+
*/
|
1161 |
+
public static function wcal_email_admin_recovery_for_paypal( $order_id, $old, $new_status ) {
|
1162 |
+
if ( 'pending' == $old && 'processing' == $new_status ) {
|
1163 |
+
global $wpdb, $woocommerce;
|
1164 |
+
$user_id = get_current_user_id();
|
1165 |
+
$ac_email_admin_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
|
1166 |
+
$order = new WC_Order( $order_id );
|
1167 |
+
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
1168 |
+
$user_id = $order->get_user_id();
|
1169 |
+
} else {
|
1170 |
+
$user_id = $order->user_id;
|
1171 |
+
}
|
1172 |
+
|
1173 |
+
if( $ac_email_admin_recovery == 'on' ) {
|
1174 |
+
$recovered_email_sent = get_post_meta( $order_id, 'wcap_recovered_email_sent', true );
|
1175 |
+
$created_via = get_post_meta( $order_id, '_created_via', true );
|
1176 |
+
$wcal_check_order_is_recovered = woocommerce_abandon_cart_lite::wcal_check_order_is_recovered( $order_id );
|
1177 |
+
|
1178 |
+
if ( 'checkout' == $created_via && 'yes' != $recovered_email_sent && true === $wcal_check_order_is_recovered ) { // indicates cart is abandoned
|
1179 |
+
$order = new WC_Order( $order_id );
|
1180 |
+
$email_heading = __( 'New Customer Order - Recovered', 'woocommerce-ac' );
|
1181 |
+
$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
|
1182 |
+
$email_subject = "New Customer Order - Recovered";
|
1183 |
+
$user_email = get_option( 'admin_email' );
|
1184 |
+
$headers[] = "From: Admin <".$user_email.">";
|
1185 |
+
$headers[] = "Content-Type: text/html";
|
1186 |
+
// Buffer
|
1187 |
+
ob_start();
|
1188 |
+
// Get mail template
|
1189 |
+
wc_get_template( 'emails/admin-new-order.php', array(
|
1190 |
+
'order' => $order,
|
1191 |
+
'email_heading' => $email_heading,
|
1192 |
+
'sent_to_admin' => false,
|
1193 |
+
'plain_text' => false,
|
1194 |
+
'email' => true
|
1195 |
+
)
|
1196 |
+
);
|
1197 |
+
// Get contents
|
1198 |
+
$email_body = ob_get_clean();
|
1199 |
+
wc_mail( $user_email, $email_subject, $email_body, $headers );
|
1200 |
+
update_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
|
1201 |
+
}
|
1202 |
+
}
|
1203 |
+
}
|
1204 |
+
}
|
1205 |
+
|
1206 |
+
/**
|
1207 |
+
* Send email to admin when cart is recovered via any other payment gateway other than PayPal.
|
1208 |
+
* @since 2.3 version
|
1209 |
+
*/
|
1210 |
+
function wcal_email_admin_recovery ( $order_id ) {
|
1211 |
+
global $wpdb, $woocommerce;
|
1212 |
+
|
1213 |
+
$user_id = get_current_user_id();
|
1214 |
+
$ac_email_admin_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
|
1215 |
+
if( $ac_email_admin_recovery == 'on' ) {
|
1216 |
+
$order = new WC_Order( $order_id );
|
1217 |
+
|
1218 |
+
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
1219 |
+
$user_id = $order->get_user_id();
|
1220 |
+
}else{
|
1221 |
+
$user_id = $order->user_id;
|
1222 |
+
}
|
1223 |
+
$recovered_email_sent = get_post_meta( $order_id, 'wcap_recovered_email_sent', true );
|
1224 |
+
$created_via = get_post_meta( $order_id, '_created_via', true );
|
1225 |
+
$wcal_check_order_is_recovered = woocommerce_abandon_cart_lite::wcal_check_order_is_recovered( $order_id );
|
1226 |
+
if ( 'checkout' == $created_via && 'yes' != $recovered_email_sent && true === $wcal_check_order_is_recovered ) { // indicates cart is abandoned
|
1227 |
+
$email_heading = __( 'New Customer Order - Recovered', 'woocommerce-ac' );
|
1228 |
+
$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
|
1229 |
+
$email_subject = "New Customer Order - Recovered";
|
1230 |
+
$user_email = get_option( 'admin_email' );
|
1231 |
+
$headers[] = "From: Admin <".$user_email.">";
|
1232 |
+
$headers[] = "Content-Type: text/html";
|
1233 |
+
// Buffer
|
1234 |
+
ob_start();
|
1235 |
+
// Get mail template
|
1236 |
+
wc_get_template( 'emails/admin-new-order.php', array(
|
1237 |
+
'order' => $order,
|
1238 |
+
'email_heading' => $email_heading,
|
1239 |
+
'sent_to_admin' => false,
|
1240 |
+
'plain_text' => false,
|
1241 |
+
'email' => true
|
1242 |
+
) );
|
1243 |
+
// Get contents
|
1244 |
+
$email_body = ob_get_clean();
|
1245 |
+
|
1246 |
+
wc_mail( $user_email, $email_subject, $email_body, $headers );
|
1247 |
+
|
1248 |
+
update_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
|
1249 |
+
}
|
1250 |
+
}
|
1251 |
+
}
|
1252 |
+
|
1253 |
+
// For sending Recovery Email to Admin, we will check that order is recovered or not.
|
1254 |
+
function wcal_check_order_is_recovered( $wcal_order_id ) {
|
1255 |
+
global $wpdb;
|
1256 |
+
$wcal_recover_order_query = "SELECT `recovered_cart` FROM `wp_ac_abandoned_cart_history_lite` WHERE `recovered_cart` = %d";
|
1257 |
+
$wcal_recover_order_query_result = $wpdb->get_results( $wpdb->prepare( $wcal_recover_order_query, $wcal_order_id ) );
|
1258 |
+
if( count( $wcal_recover_order_query_result ) > 0 ) {
|
1259 |
+
return true;
|
1260 |
+
}
|
1261 |
+
return false;
|
1262 |
+
}
|
1263 |
+
|
1264 |
+
// Add a submenu page.
|
1265 |
+
function wcal_admin_menu() {
|
1266 |
+
$page = add_submenu_page ( 'woocommerce', __( 'Abandoned Carts', 'woocommerce-ac' ), __( 'Abandoned Carts', 'woocommerce-ac' ), 'manage_woocommerce', 'woocommerce_ac_page', array( &$this, 'wcal_menu_page' ) );
|
1267 |
+
}
|
1268 |
+
|
1269 |
+
// Capture the cart and insert the information of the cart into DataBase
|
1270 |
+
function wcal_store_cart_timestamp() {
|
1271 |
+
|
1272 |
+
if( session_id() === '' ){
|
1273 |
+
//session has not started
|
1274 |
+
session_start();
|
1275 |
+
}
|
1276 |
+
global $wpdb,$woocommerce;
|
1277 |
+
$current_time = current_time( 'timestamp' );
|
1278 |
+
$cut_off_time = get_option( 'ac_lite_cart_abandoned_time' );
|
1279 |
+
$track_guest_cart_from_cart_page = get_option( 'ac_lite_track_guest_cart_from_cart_page' );
|
1280 |
+
$cart_ignored = 0;
|
1281 |
+
$recovered_cart = 0;
|
1282 |
+
|
1283 |
+
$track_guest_user_cart_from_cart = "";
|
1284 |
+
if ( isset( $track_guest_cart_from_cart_page ) ) {
|
1285 |
+
$track_guest_user_cart_from_cart = $track_guest_cart_from_cart_page;
|
1286 |
+
}
|
1287 |
+
|
1288 |
+
if( isset( $cut_off_time ) ) {
|
1289 |
+
$cart_cut_off_time = intval( $cut_off_time ) * 60;
|
1290 |
+
} else {
|
1291 |
+
$cart_cut_off_time = 60 * 60;
|
1292 |
+
}
|
1293 |
+
$compare_time = $current_time - $cart_cut_off_time;
|
1294 |
+
|
1295 |
+
if ( is_user_logged_in() ) {
|
1296 |
+
$user_id = get_current_user_id();
|
1297 |
+
$query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1298 |
+
WHERE user_id = %d
|
1299 |
+
AND cart_ignored = %s
|
1300 |
+
AND recovered_cart = %d ";
|
1301 |
+
$results = $wpdb->get_results($wpdb->prepare( $query, $user_id, $cart_ignored, $recovered_cart ) );
|
1302 |
+
|
1303 |
+
if ( count($results) == 0 ) {
|
1304 |
+
$wcal_woocommerce_persistent_cart =version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
|
1305 |
+
|
1306 |
+
$cart_info = json_encode( get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true ) );
|
1307 |
+
$user_type = "REGISTERED";
|
1308 |
+
$insert_query = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1309 |
+
( user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type )
|
1310 |
+
VALUES ( %d, %s, %d, %s, %s )";
|
1311 |
+
$wpdb->query( $wpdb->prepare( $insert_query, $user_id, $cart_info,$current_time, $cart_ignored, $user_type ) );
|
1312 |
+
|
1313 |
+
$abandoned_cart_id = $wpdb->insert_id;
|
1314 |
+
$_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
|
1315 |
+
} elseif ( isset( $results[0]->abandoned_cart_time ) && $compare_time > $results[0]->abandoned_cart_time ) {
|
1316 |
+
|
1317 |
+
$wcal_woocommerce_persistent_cart = version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
|
1318 |
+
$updated_cart_info = json_encode( get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true ) );
|
1319 |
+
|
1320 |
+
if ( ! $this->wcal_compare_carts( $user_id, $results[0]->abandoned_cart_info ) ) {
|
1321 |
+
$updated_cart_ignored = 1;
|
1322 |
+
$query_ignored = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1323 |
+
SET cart_ignored = %s
|
1324 |
+
WHERE user_id = %d ";
|
1325 |
+
$wpdb->query( $wpdb->prepare( $query_ignored, $updated_cart_ignored, $user_id ) );
|
1326 |
+
|
1327 |
+
$user_type = "REGISTERED";
|
1328 |
+
$query_update = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1329 |
+
(user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type)
|
1330 |
+
VALUES (%d, %s, %d, %s, %s)";
|
1331 |
+
$wpdb->query( $wpdb->prepare( $query_update, $user_id, $updated_cart_info, $current_time, $cart_ignored, $user_type ) );
|
1332 |
+
|
1333 |
+
update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "yes" ) );
|
1334 |
+
|
1335 |
+
$abandoned_cart_id = $wpdb->insert_id;
|
1336 |
+
$_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
|
1337 |
+
} else {
|
1338 |
+
update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "no" ) );
|
1339 |
+
}
|
1340 |
+
} else {
|
1341 |
+
$wcal_woocommerce_persistent_cart =version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
|
1342 |
+
$updated_cart_info = json_encode( get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true ) );
|
1343 |
+
|
1344 |
+
$query_update = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1345 |
+
SET abandoned_cart_info = %s,
|
1346 |
+
abandoned_cart_time = %d
|
1347 |
+
WHERE user_id = %d
|
1348 |
+
AND cart_ignored = %s ";
|
1349 |
+
$wpdb->query( $wpdb->prepare( $query_update, $updated_cart_info, $current_time, $user_id, $cart_ignored ) );
|
1350 |
+
|
1351 |
+
$query_update = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE user_id ='" . $user_id . "' AND cart_ignored='0' ";
|
1352 |
+
$get_abandoned_record = $wpdb->get_results( $query_update );
|
1353 |
+
if ( count( $get_abandoned_record ) > 0 ) {
|
1354 |
+
$abandoned_cart_id = $get_abandoned_record[0]->id;
|
1355 |
+
$_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
|
1356 |
+
}
|
1357 |
+
}
|
1358 |
+
} else {
|
1359 |
+
//start here guest user
|
1360 |
+
if ( isset( $_SESSION['user_id'] ) ) {
|
1361 |
+
$user_id = $_SESSION['user_id'];
|
1362 |
+
} else {
|
1363 |
+
$user_id = "";
|
1364 |
+
}
|
1365 |
+
|
1366 |
+
$query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id = %d AND cart_ignored = '0' AND recovered_cart = '0' AND user_id != '0'";
|
1367 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query, $user_id ) );
|
1368 |
+
$cart = array();
|
1369 |
+
$get_cookie = WC()->session->get_session_cookie();
|
1370 |
+
if ( function_exists('WC') ) {
|
1371 |
+
$cart['cart'] = WC()->session->cart;
|
1372 |
+
} else {
|
1373 |
+
$cart['cart'] = $woocommerce->session->cart;
|
1374 |
+
}
|
1375 |
+
|
1376 |
+
$updated_cart_info = json_encode($cart);
|
1377 |
+
$updated_cart_info = addslashes ( $updated_cart_info );
|
1378 |
+
|
1379 |
+
if ( count($results) > 0 ) {
|
1380 |
+
if ( $compare_time > $results[0]->abandoned_cart_time ) {
|
1381 |
+
if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
|
1382 |
+
|
1383 |
+
$query_ignored = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1384 |
+
SET cart_ignored = '1'
|
1385 |
+
WHERE user_id ='".$user_id."'";
|
1386 |
+
$wpdb->query( $query_ignored );
|
1387 |
+
$user_type = 'GUEST';
|
1388 |
+
$query_update = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1389 |
+
(user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type)
|
1390 |
+
VALUES (%d, %s, %d, %s, %s)";
|
1391 |
+
$wpdb->query( $wpdb->prepare( $query_update, $user_id, $updated_cart_info, $current_time, $cart_ignored, $user_type ) );
|
1392 |
+
update_user_meta( $user_id, '_woocommerce_ac_modified_cart', md5("yes") );
|
1393 |
+
} else {
|
1394 |
+
update_user_meta( $user_id, '_woocommerce_ac_modified_cart', md5("no") );
|
1395 |
+
}
|
1396 |
+
} else {
|
1397 |
+
$query_update = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1398 |
+
SET abandoned_cart_info = '".$updated_cart_info."', abandoned_cart_time = '".$current_time."'
|
1399 |
+
WHERE user_id='".$user_id."' AND cart_ignored='0' ";
|
1400 |
+
$wpdb->query( $query_update );
|
1401 |
+
}
|
1402 |
+
} else {
|
1403 |
+
/**
|
1404 |
+
* Here we capture the guest cart from the cart page.
|
1405 |
+
* @since: 3.5
|
1406 |
+
*
|
1407 |
+
*/
|
1408 |
+
if ( $track_guest_user_cart_from_cart == "on" && $get_cookie[0] != '' ) {
|
1409 |
+
$query = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE session_id LIKE %s AND cart_ignored = '0' AND recovered_cart = '0' ";
|
1410 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query, $get_cookie[0] ) );
|
1411 |
+
if ( count( $results ) == 0 ) {
|
1412 |
+
$cart_info = $updated_cart_info;
|
1413 |
+
$blank_cart_info = '[]';
|
1414 |
+
if ( $blank_cart_info != $cart_info ) {
|
1415 |
+
$insert_query = "INSERT INTO `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
1416 |
+
( abandoned_cart_info , abandoned_cart_time , cart_ignored , recovered_cart, user_type, session_id )
|
1417 |
+
VALUES ( '" . $cart_info."' , '" . $current_time . "' , '0' , '0' , 'GUEST', '". $get_cookie[0] ."' )";
|
1418 |
+
$wpdb->query( $insert_query );
|
1419 |
+
}
|
1420 |
+
} elseif ( $compare_time > $results[0]->abandoned_cart_time ) {
|
1421 |
+
$blank_cart_info = '[]';
|
1422 |
+
if ( $blank_cart_info != $updated_cart_info ) {
|
1423 |
+
if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
|
1424 |
+
$query_ignored = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET cart_ignored = '1' WHERE session_id ='" . $get_cookie[0] . "'";
|
1425 |
+
$wpdb->query( $query_ignored );
|
1426 |
+
$query_update = "INSERT INTO `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
1427 |
+
( abandoned_cart_info, abandoned_cart_time, cart_ignored, recovered_cart, user_type, session_id )
|
1428 |
+
VALUES ( '" . $updated_cart_info . "', '" . $current_time . "', '0', '0', 'GUEST', '". $get_cookie[0] ."' )";
|
1429 |
+
$wpdb->query( $query_update );
|
1430 |
+
}
|
1431 |
+
}
|
1432 |
+
} else {
|
1433 |
+
$blank_cart_info = '[]';
|
1434 |
+
if ( $blank_cart_info != $updated_cart_info ) {
|
1435 |
+
if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
|
1436 |
+
$query_update = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET abandoned_cart_info = '" . $updated_cart_info . "', abandoned_cart_time = '" . $current_time . "' WHERE session_id ='" . $get_cookie[0] . "' AND cart_ignored='0' ";
|
1437 |
+
$wpdb->query( $query_update );
|
1438 |
+
}
|
1439 |
+
}
|
1440 |
+
}
|
1441 |
+
}
|
1442 |
+
}
|
1443 |
+
}
|
1444 |
+
}
|
1445 |
+
|
1446 |
+
function wcal_email_unsubscribe( $args ) {
|
1447 |
+
global $wpdb;
|
1448 |
+
|
1449 |
+
if ( isset( $_GET['wcal_track_unsubscribe'] ) && $_GET['wcal_track_unsubscribe'] == 'wcal_unsubscribe' ) {
|
1450 |
+
$encoded_email_id = rawurldecode( $_GET['validate'] );
|
1451 |
+
$validate_email_id_string = str_replace( " " , "+", $encoded_email_id );
|
1452 |
+
$validate_email_address_string = '';
|
1453 |
+
$validate_email_id_decode = 0;
|
1454 |
+
$cryptKey = get_option( 'wcal_security_key' );
|
1455 |
+
$validate_email_id_decode = Wcal_Aes_Ctr::decrypt( $validate_email_id_string, $cryptKey, 256 );
|
1456 |
+
if( isset( $_GET['track_email_id'] ) ) {
|
1457 |
+
$encoded_email_address = rawurldecode( $_GET['track_email_id'] );
|
1458 |
+
$validate_email_address_string = str_replace( " " , "+", $encoded_email_address );
|
1459 |
+
}
|
1460 |
+
$query_id = "SELECT * FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE id = %d ";
|
1461 |
+
$results_sent = $wpdb->get_results ( $wpdb->prepare( $query_id, $validate_email_id_decode ) );
|
1462 |
+
$email_address = '';
|
1463 |
+
if( isset( $results_sent[0] ) ) {
|
1464 |
+
$email_address = $results_sent[0]->sent_email_id;
|
1465 |
+
}
|
1466 |
+
if( $validate_email_address_string == hash( 'sha256', $email_address ) && '' != $email_address ) {
|
1467 |
+
$email_sent_id = $validate_email_id_decode;
|
1468 |
+
$get_ac_id_query = "SELECT abandoned_order_id FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE id = %d";
|
1469 |
+
$get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query , $email_sent_id ) );
|
1470 |
+
$user_id = 0;
|
1471 |
+
if( isset( $get_ac_id_results[0] ) ) {
|
1472 |
+
$get_user_id_query = "SELECT user_id FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE id = %d";
|
1473 |
+
$get_user_results = $wpdb->get_results( $wpdb->prepare( $get_user_id_query , $get_ac_id_results[0]->abandoned_order_id ) );
|
1474 |
+
}
|
1475 |
+
if( isset( $get_user_results[0] ) ) {
|
1476 |
+
$user_id = $get_user_results[0]->user_id;
|
1477 |
+
}
|
1478 |
+
|
1479 |
+
$unsubscribe_query = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
1480 |
+
SET unsubscribe_link = '1'
|
1481 |
+
WHERE user_id= %d AND cart_ignored='0' ";
|
1482 |
+
$wpdb->query( $wpdb->prepare( $unsubscribe_query , $user_id ) );
|
1483 |
+
echo "Unsubscribed Successfully";
|
1484 |
+
sleep( 2 );
|
1485 |
+
$url = get_option( 'siteurl' );
|
1486 |
+
?>
|
1487 |
+
<script>
|
1488 |
+
location.href = "<?php echo $url; ?>";
|
1489 |
+
</script>
|
1490 |
+
<?php
|
1491 |
+
}
|
1492 |
+
} else {
|
1493 |
+
return $args;
|
1494 |
+
}
|
1495 |
+
}
|
1496 |
+
|
1497 |
+
// It will track the URL of cart link from email
|
1498 |
+
function wcal_email_track_links( $template ) {
|
1499 |
+
global $woocommerce;
|
1500 |
+
$track_link = '';
|
1501 |
+
|
1502 |
+
if ( isset( $_GET['wcal_action'] ) ) {
|
1503 |
+
$track_link = $_GET['wcal_action'];
|
1504 |
+
}
|
1505 |
+
if ( $track_link == 'track_links' ) {
|
1506 |
+
if( session_id() === '' ) {
|
1507 |
+
//session has not started
|
1508 |
+
session_start();
|
1509 |
+
}
|
1510 |
+
global $wpdb;
|
1511 |
+
$validate_server_string = rawurldecode( $_GET ['validate'] );
|
1512 |
+
$validate_server_string = str_replace( " " , "+", $validate_server_string );
|
1513 |
+
$validate_encoded_string = $validate_server_string;
|
1514 |
+
$cryptKey = get_option( 'wcal_security_key' );
|
1515 |
+
$link_decode = Wcal_Aes_Ctr::decrypt( $validate_encoded_string, $cryptKey, 256 );
|
1516 |
+
$sent_email_id_pos = strpos( $link_decode, '&' );
|
1517 |
+
$email_sent_id = substr( $link_decode , 0, $sent_email_id_pos );
|
1518 |
+
$_SESSION['email_sent_id'] = $email_sent_id;
|
1519 |
+
$url_pos = strpos( $link_decode, '=' );
|
1520 |
+
$url_pos = $url_pos + 1;
|
1521 |
+
$url = substr( $link_decode, $url_pos );
|
1522 |
+
$get_ac_id_query = "SELECT abandoned_order_id FROM `".$wpdb->prefix."ac_sent_history_lite` WHERE id = %d";
|
1523 |
+
$get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query, $email_sent_id ) );
|
1524 |
+
$get_user_results = array();
|
1525 |
+
if ( count( $get_ac_id_results ) > 0 ) {
|
1526 |
+
$get_user_id_query = "SELECT user_id FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE id = %d";
|
1527 |
+
$get_user_results = $wpdb->get_results( $wpdb->prepare( $get_user_id_query, $get_ac_id_results[0]->abandoned_order_id ) );
|
1528 |
+
}
|
1529 |
+
$user_id = 0;
|
1530 |
+
if ( isset( $get_user_results ) && count( $get_user_results ) > 0 ) {
|
1531 |
+
$user_id = $get_user_results[0]->user_id;
|
1532 |
+
}
|
1533 |
+
if ( $user_id == 0 ) {
|
1534 |
+
echo "Link expired";
|
1535 |
+
exit;
|
1536 |
+
}
|
1537 |
+
$user = wp_set_current_user( $user_id );
|
1538 |
+
if ( $user_id >= "63000000" ) {
|
1539 |
+
$query_guest = "SELECT * from `". $wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d";
|
1540 |
+
$results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $user_id ) );
|
1541 |
+
$query_cart = "SELECT recovered_cart FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id = %d";
|
1542 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query_cart, $user_id ) );
|
1543 |
+
if ( $results_guest && $results[0]->recovered_cart == '0' ) {
|
1544 |
+
$_SESSION['guest_first_name'] = $results_guest[0]->billing_first_name;
|
1545 |
+
$_SESSION['guest_last_name'] = $results_guest[0]->billing_last_name;
|
1546 |
+
$_SESSION['guest_email'] = $results_guest[0]->email_id;
|
1547 |
+
$_SESSION['user_id'] = $user_id;
|
1548 |
+
} else {
|
1549 |
+
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
1550 |
+
wp_redirect( get_permalink( wc_get_page_id( 'shop' ) ) );
|
1551 |
+
} else {
|
1552 |
+
wp_redirect( get_permalink( woocommerce_get_page_id( 'shop' ) ) );
|
1553 |
+
}
|
1554 |
+
}
|
1555 |
+
}
|
1556 |
+
|
1557 |
+
if ( $user_id < "63000000" ) {
|
1558 |
+
$user_login = $user->data->user_login;
|
1559 |
+
wp_set_auth_cookie( $user_id );
|
1560 |
+
$my_temp = woocommerce_load_persistent_cart( $user_login, $user );
|
1561 |
+
do_action( 'wp_login', $user_login, $user );
|
1562 |
+
if ( isset( $sign_in ) && is_wp_error( $sign_in ) ) {
|
1563 |
+
echo $sign_in->get_error_message();
|
1564 |
+
exit;
|
1565 |
+
}
|
1566 |
+
} else
|
1567 |
+
$my_temp = $this->wcal_load_guest_persistent_cart( $user_id );
|
1568 |
+
|
1569 |
+
if ( $email_sent_id > 0 && is_numeric( $email_sent_id ) ) {
|
1570 |
+
header( "Location: $url" );
|
1571 |
+
}
|
1572 |
+
} else
|
1573 |
+
return $template;
|
1574 |
+
}
|
1575 |
+
|
1576 |
+
// load the information of the guest user
|
1577 |
+
function wcal_load_guest_persistent_cart() {
|
1578 |
+
if ( isset( $_SESSION['user_id'] ) && '' != $_SESSION['user_id'] ) {
|
1579 |
+
global $woocommerce;
|
1580 |
+
$saved_cart = json_decode( get_user_meta( $_SESSION['user_id'], '_woocommerce_persistent_cart',true ), true );
|
1581 |
+
$c = array();
|
1582 |
+
$cart_contents_total = $cart_contents_weight = $cart_contents_count = $cart_contents_tax = $total = $subtotal = $subtotal_ex_tax = $tax_total = 0;
|
1583 |
+
if ( count( $saved_cart ) > 0 ) {
|
1584 |
+
foreach ( $saved_cart as $key => $value ) {
|
1585 |
+
foreach ( $value as $a => $b ) {
|
1586 |
+
$c['product_id'] = $b['product_id'];
|
1587 |
+
$c['variation_id'] = $b['variation_id'];
|
1588 |
+
$c['variation'] = $b['variation'];
|
1589 |
+
$c['quantity'] = $b['quantity'];
|
1590 |
+
$product_id = $b['product_id'];
|
1591 |
+
$c['data'] = wc_get_product($product_id);
|
1592 |
+
$c['line_total'] = $b['line_total'];
|
1593 |
+
$c['line_tax'] = $cart_contents_tax;
|
1594 |
+
$c['line_subtotal'] = $b['line_subtotal'];
|
1595 |
+
$c['line_subtotal_tax'] = $cart_contents_tax;
|
1596 |
+
$value_new[ $a ] = $c;
|
1597 |
+
$cart_contents_total = $b['line_subtotal'] + $cart_contents_total;
|
1598 |
+
$cart_contents_count = $cart_contents_count + $b['quantity'];
|
1599 |
+
$total = $total + $b['line_total'];
|
1600 |
+
$subtotal = $subtotal + $b['line_subtotal'];
|
1601 |
+
$subtotal_ex_tax = $subtotal_ex_tax + $b['line_subtotal'];
|
1602 |
+
}
|
1603 |
+
$saved_cart_data[ $key ] = $value_new;
|
1604 |
+
$woocommerce_cart_hash = $a;
|
1605 |
+
}
|
1606 |
+
}
|
1607 |
+
|
1608 |
+
if( $saved_cart ) {
|
1609 |
+
if ( empty( $woocommerce->session->cart ) || ! is_array( $woocommerce->session->cart ) || sizeof( $woocommerce->session->cart ) == 0 ) {
|
1610 |
+
$woocommerce->session->cart = $saved_cart['cart'];
|
1611 |
+
$woocommerce->session->cart_contents_total = $cart_contents_total;
|
1612 |
+
$woocommerce->session->cart_contents_weight = $cart_contents_weight;
|
1613 |
+
$woocommerce->session->cart_contents_count = $cart_contents_count;
|
1614 |
+
$woocommerce->session->cart_contents_tax = $cart_contents_tax;
|
1615 |
+
$woocommerce->session->total = $total;
|
1616 |
+
$woocommerce->session->subtotal = $subtotal;
|
1617 |
+
$woocommerce->session->subtotal_ex_tax = $subtotal_ex_tax;
|
1618 |
+
$woocommerce->session->tax_total = $tax_total;
|
1619 |
+
$woocommerce->session->shipping_taxes = array();
|
1620 |
+
$woocommerce->session->taxes = array();
|
1621 |
+
$woocommerce->session->ac_customer = array();
|
1622 |
+
$woocommerce->cart->cart_contents = $saved_cart_data['cart'];
|
1623 |
+
$woocommerce->cart->cart_contents_total = $cart_contents_total;
|
1624 |
+
$woocommerce->cart->cart_contents_weight = $cart_contents_weight;
|
1625 |
+
$woocommerce->cart->cart_contents_count = $cart_contents_count;
|
1626 |
+
$woocommerce->cart->cart_contents_tax = $cart_contents_tax;
|
1627 |
+
$woocommerce->cart->total = $total;
|
1628 |
+
$woocommerce->cart->subtotal = $subtotal;
|
1629 |
+
$woocommerce->cart->subtotal_ex_tax = $subtotal_ex_tax;
|
1630 |
+
$woocommerce->cart->tax_total = $tax_total;
|
1631 |
+
}
|
1632 |
+
}
|
1633 |
+
}
|
1634 |
+
}
|
1635 |
+
|
1636 |
+
function wcal_compare_only_guest_carts( $new_cart, $last_abandoned_cart ) {
|
1637 |
+
$current_woo_cart = array();
|
1638 |
+
$current_woo_cart = json_decode( stripslashes( $new_cart ), true );
|
1639 |
+
$abandoned_cart_arr = array();
|
1640 |
+
$abandoned_cart_arr = json_decode( $last_abandoned_cart, true );
|
1641 |
+
$temp_variable = "";
|
1642 |
+
if ( isset( $current_woo_cart['cart'] ) && isset( $abandoned_cart_arr['cart'] ) ) {
|
1643 |
+
if ( count( $current_woo_cart['cart'] ) >= count( $abandoned_cart_arr['cart'] ) ) {
|
1644 |
+
//do nothing
|
1645 |
+
} else {
|
1646 |
+
$temp_variable = $current_woo_cart;
|
1647 |
+
$current_woo_cart = $abandoned_cart_arr;
|
1648 |
+
$abandoned_cart_arr = $temp_variable;
|
1649 |
+
}
|
1650 |
+
if ( is_array( $current_woo_cart ) || is_object( $current_woo_cart ) ) {
|
1651 |
+
foreach( $current_woo_cart as $key => $value ) {
|
1652 |
+
foreach( $value as $item_key => $item_value ) {
|
1653 |
+
$current_cart_product_id = $item_value['product_id'];
|
1654 |
+
$current_cart_variation_id = $item_value['variation_id'];
|
1655 |
+
$current_cart_quantity = $item_value['quantity'];
|
1656 |
+
|
1657 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['product_id'] ) ){
|
1658 |
+
$abandoned_cart_product_id = $abandoned_cart_arr[$key][$item_key]['product_id'];
|
1659 |
+
} else {
|
1660 |
+
$abandoned_cart_product_id = "";
|
1661 |
+
}
|
1662 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['variation_id'] ) ) {
|
1663 |
+
$abandoned_cart_variation_id = $abandoned_cart_arr[$key][$item_key]['variation_id'];
|
1664 |
+
} else {
|
1665 |
+
$abandoned_cart_variation_id = "";
|
1666 |
+
}
|
1667 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['quantity'] ) ) {
|
1668 |
+
$abandoned_cart_quantity = $abandoned_cart_arr[$key][$item_key]['quantity'];
|
1669 |
+
} else {
|
1670 |
+
$abandoned_cart_quantity = "";
|
1671 |
+
}
|
1672 |
+
if ( ( $current_cart_product_id != $abandoned_cart_product_id ) ||
|
1673 |
+
( $current_cart_variation_id != $abandoned_cart_variation_id ) ||
|
1674 |
+
( $current_cart_quantity != $abandoned_cart_quantity ) ) {
|
1675 |
+
return false;
|
1676 |
+
}
|
1677 |
+
}
|
1678 |
+
}
|
1679 |
+
}
|
1680 |
+
}
|
1681 |
+
return true;
|
1682 |
+
}
|
1683 |
+
|
1684 |
+
// Compare the existing cart with new cart
|
1685 |
+
function wcal_compare_carts( $user_id, $last_abandoned_cart ) {
|
1686 |
+
global $woocommerce;
|
1687 |
+
$current_woo_cart = array();
|
1688 |
+
$abandoned_cart_arr = array();
|
1689 |
+
$wcal_woocommerce_persistent_cart =version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
|
1690 |
+
$current_woo_cart = get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true );
|
1691 |
+
$abandoned_cart_arr = json_decode( $last_abandoned_cart, true );
|
1692 |
+
$temp_variable = "";
|
1693 |
+
if( isset( $current_woo_cart['cart'] ) && isset( $abandoned_cart_arr['cart'] ) ) {
|
1694 |
+
if ( count( $current_woo_cart['cart'] ) >= count( $abandoned_cart_arr['cart'] ) ) {
|
1695 |
+
//do nothing
|
1696 |
+
} else {
|
1697 |
+
$temp_variable = $current_woo_cart;
|
1698 |
+
$current_woo_cart = $abandoned_cart_arr;
|
1699 |
+
$abandoned_cart_arr = $temp_variable;
|
1700 |
+
}
|
1701 |
+
if ( is_array( $current_woo_cart ) && is_array( $abandoned_cart_arr ) ) {
|
1702 |
+
foreach ( $current_woo_cart as $key => $value ) {
|
1703 |
+
|
1704 |
+
foreach ( $value as $item_key => $item_value ) {
|
1705 |
+
$current_cart_product_id = $item_value['product_id'];
|
1706 |
+
$current_cart_variation_id = $item_value['variation_id'];
|
1707 |
+
$current_cart_quantity = $item_value['quantity'];
|
1708 |
+
|
1709 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['product_id'] ) ) {
|
1710 |
+
$abandoned_cart_product_id = $abandoned_cart_arr[$key][$item_key]['product_id'];
|
1711 |
+
} else {
|
1712 |
+
$abandoned_cart_product_id = "";
|
1713 |
+
}
|
1714 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['variation_id'] ) ) {
|
1715 |
+
$abandoned_cart_variation_id = $abandoned_cart_arr[$key][$item_key]['variation_id'];
|
1716 |
+
} else {
|
1717 |
+
$abandoned_cart_variation_id = "";
|
1718 |
+
}
|
1719 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['quantity'] ) ) {
|
1720 |
+
$abandoned_cart_quantity = $abandoned_cart_arr[$key][$item_key]['quantity'];
|
1721 |
+
} else {
|
1722 |
+
$abandoned_cart_quantity = "";
|
1723 |
+
}
|
1724 |
+
if ( ( $current_cart_product_id != $abandoned_cart_product_id ) ||
|
1725 |
+
( $current_cart_variation_id != $abandoned_cart_variation_id ) ||
|
1726 |
+
( $current_cart_quantity != $abandoned_cart_quantity ) )
|
1727 |
+
{
|
1728 |
+
return false;
|
1729 |
+
}
|
1730 |
+
}
|
1731 |
+
}
|
1732 |
+
}
|
1733 |
+
}
|
1734 |
+
return true;
|
1735 |
+
}
|
1736 |
+
|
1737 |
+
// function is call when order is recovered
|
1738 |
+
function wcal_action_after_delivery_session( $order ) {
|
1739 |
+
|
1740 |
+
if( session_id() === '' ){
|
1741 |
+
//session has not started
|
1742 |
+
session_start();
|
1743 |
+
}
|
1744 |
+
global $wpdb, $woocommerce;
|
1745 |
+
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
1746 |
+
$order_id = $order->get_id();
|
1747 |
+
}else{
|
1748 |
+
$order_id = $order->id;
|
1749 |
+
}
|
1750 |
+
$get_abandoned_id_of_order = '';
|
1751 |
+
$get_sent_email_id_of_order = '';
|
1752 |
+
$get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
|
1753 |
+
if( isset( $get_abandoned_id_of_order ) && $get_abandoned_id_of_order != '' ){
|
1754 |
+
$get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
|
1755 |
+
$get_sent_email_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed_sent_id', true );
|
1756 |
+
|
1757 |
+
$query_order = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET recovered_cart= '" . $order_id . "', cart_ignored = '1'
|
1758 |
+
WHERE id = '".$get_abandoned_id_of_order."' ";
|
1759 |
+
$wpdb->query( $query_order );
|
1760 |
+
|
1761 |
+
$order->add_order_note( __( 'This order was abandoned & subsequently recovered.', 'woocommerce-ac' ) );
|
1762 |
+
|
1763 |
+
delete_post_meta( $order_id, 'wcal_recover_order_placed', $get_abandoned_id_of_order );
|
1764 |
+
delete_post_meta( $order_id , 'wcal_recover_order_placed_sent_id', $get_sent_email_id_of_order );
|
1765 |
+
}
|
1766 |
+
$user_id = get_current_user_id();
|
1767 |
+
$sent_email = '';
|
1768 |
+
if( isset( $_SESSION['email_sent_id'] ) ){
|
1769 |
+
$sent_email = $_SESSION['email_sent_id'];
|
1770 |
+
}
|
1771 |
+
if( $user_id == "" ) {
|
1772 |
+
$user_id = $_SESSION['user_id'];
|
1773 |
+
// Set the session variables to blanks
|
1774 |
+
$_SESSION['guest_first_name'] = $_SESSION['guest_last_name'] = $_SESSION['guest_email'] = $_SESSION['user_id'] = "";
|
1775 |
+
}
|
1776 |
+
delete_user_meta( $user_id, '_woocommerce_ac_persistent_cart_time' );
|
1777 |
+
delete_user_meta( $user_id, '_woocommerce_ac_persistent_cart_temp_time' );
|
1778 |
+
// get all latest abandoned carts that were modified
|
1779 |
+
$cart_ignored = 0;
|
1780 |
+
$recovered_cart = 0;
|
1781 |
+
$query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1782 |
+
WHERE user_id = %d
|
1783 |
+
AND cart_ignored = %s
|
1784 |
+
AND recovered_cart = %d
|
1785 |
+
ORDER BY id DESC
|
1786 |
+
LIMIT 1";
|
1787 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query, $user_id, $cart_ignored, $recovered_cart ) );
|
1788 |
+
if ( count( $results ) > 0 ) {
|
1789 |
+
if ( get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true ) == md5( "yes" ) ||
|
1790 |
+
get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true ) == md5( "no" ) ) {
|
1791 |
+
|
1792 |
+
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
1793 |
+
$order_id = $order->get_id();
|
1794 |
+
}else{
|
1795 |
+
$order_id = $order->id;
|
1796 |
+
}
|
1797 |
+
$updated_cart_ignored = 1;
|
1798 |
+
$query_order = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1799 |
+
SET recovered_cart = %d,
|
1800 |
+
cart_ignored = %s
|
1801 |
+
WHERE id = %d ";
|
1802 |
+
$wpdb->query( $wpdb->prepare( $query_order, $order_id, $updated_cart_ignored, $results[0]->id ) );
|
1803 |
+
delete_user_meta( $user_id, '_woocommerce_ac_modified_cart' );
|
1804 |
+
delete_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
|
1805 |
+
} else {
|
1806 |
+
$delete_query = "DELETE FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1807 |
+
WHERE id= %d ";
|
1808 |
+
$wpdb->query( $wpdb->prepare( $delete_query, $results[0]->id ) );
|
1809 |
+
}
|
1810 |
+
} else {
|
1811 |
+
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
1812 |
+
|
1813 |
+
$email_id = $order->get_billing_email();
|
1814 |
+
}else{
|
1815 |
+
$email_id = $order->billing_email;
|
1816 |
+
}
|
1817 |
+
$query = "SELECT * FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE email_id = %s";
|
1818 |
+
$results_id = $wpdb->get_results( $wpdb->prepare( $query, $email_id ) );
|
1819 |
+
|
1820 |
+
if ( $results_id ) {
|
1821 |
+
$record_status = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1822 |
+
WHERE user_id = %d AND recovered_cart = '0'";
|
1823 |
+
$results_status = $wpdb->get_results( $wpdb->prepare( $record_status, $results_id[0]->id ) );
|
1824 |
+
|
1825 |
+
if ( $results_status ) {
|
1826 |
+
if ( get_user_meta( $results_id[0]->id, '_woocommerce_ac_modified_cart', true ) == md5("yes") ||
|
1827 |
+
get_user_meta( $results_id[0]->id, '_woocommerce_ac_modified_cart', true ) == md5("no") ) {
|
1828 |
+
|
1829 |
+
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
1830 |
+
$order_id = $order->get_id();
|
1831 |
+
}else{
|
1832 |
+
$order_id = $order->id;
|
1833 |
+
}
|
1834 |
+
$query_order = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1835 |
+
SET recovered_cart= '".$order_id."', cart_ignored = '1'
|
1836 |
+
WHERE id='".$results_status[0]->id."' ";
|
1837 |
+
$wpdb->query( $query_order );
|
1838 |
+
delete_user_meta( $results_id[0]->id, '_woocommerce_ac_modified_cart' );
|
1839 |
+
delete_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
|
1840 |
+
} else {
|
1841 |
+
$delete_guest = "DELETE FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = '".$results_id[0]->id."'";
|
1842 |
+
$wpdb->query( $delete_guest );
|
1843 |
+
|
1844 |
+
$delete_query = "DELETE FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id='".$results_id[0]->id."' ";
|
1845 |
+
$wpdb->query( $delete_query );
|
1846 |
+
}
|
1847 |
+
}
|
1848 |
+
}
|
1849 |
+
}
|
1850 |
+
}
|
1851 |
+
|
1852 |
+
function wcal_action_admin_init() {
|
1853 |
+
|
1854 |
+
// only hook up these filters if we're in the admin panel and the current user has permission
|
1855 |
+
// to edit posts and pages
|
1856 |
+
if ( !isset( $_GET['page'] ) || $_GET['page'] != "woocommerce_ac_page" ) {
|
1857 |
+
return;
|
1858 |
+
}
|
1859 |
+
if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) ) {
|
1860 |
+
return;
|
1861 |
+
}
|
1862 |
+
if ( get_user_option( 'rich_editing' ) == 'true' ) {
|
1863 |
+
remove_filter( 'the_excerpt', 'wpautop' );
|
1864 |
+
add_filter( 'tiny_mce_before_init', array( &$this, 'wcal_format_tiny_MCE' ) );
|
1865 |
+
add_filter( 'mce_buttons', array( &$this, 'wcal_filter_mce_button' ) );
|
1866 |
+
add_filter( 'mce_external_plugins', array( &$this, 'wcal_filter_mce_plugin' ) );
|
1867 |
+
}
|
1868 |
+
if ( isset( $_GET['page'] ) && 'woocommerce_ac_page' == $_GET['page'] ) {
|
1869 |
+
if( session_id() === '' ){
|
1870 |
+
//session has not started
|
1871 |
+
session_start();
|
1872 |
+
}
|
1873 |
+
}
|
1874 |
+
}
|
1875 |
+
|
1876 |
+
function wcal_filter_mce_button( $buttons ) {
|
1877 |
+
// add a separation before our button, here our button's id is "mygallery_button"
|
1878 |
+
array_push( $buttons, 'abandoncart', '|' );
|
1879 |
+
return $buttons;
|
1880 |
+
}
|
1881 |
+
|
1882 |
+
function wcal_filter_mce_plugin( $plugins ) {
|
1883 |
+
// this plugin file will work the magic of our button
|
1884 |
+
$plugins['abandoncart'] = plugin_dir_url( __FILE__ ) . 'assets/js/abandoncart_plugin_button.js';
|
1885 |
+
return $plugins;
|
1886 |
+
}
|
1887 |
+
|
1888 |
+
function wcal_display_tabs() {
|
1889 |
+
|
1890 |
+
if ( isset( $_GET['action'] ) ) {
|
1891 |
+
$action = $_GET['action'];
|
1892 |
+
} else {
|
1893 |
+
$action = "";
|
1894 |
+
$active_listcart = "";
|
1895 |
+
$active_emailtemplates = "";
|
1896 |
+
$active_settings = "";
|
1897 |
+
$active_stats = "";
|
1898 |
+
}
|
1899 |
+
if ( ( $action == 'listcart' || $action == 'orderdetails' ) || $action == '' ) {
|
1900 |
+
$active_listcart = "nav-tab-active";
|
1901 |
+
}
|
1902 |
+
if ( $action == 'emailtemplates' ) {
|
1903 |
+
$active_emailtemplates = "nav-tab-active";
|
1904 |
+
}
|
1905 |
+
if ( $action == 'emailsettings' ) {
|
1906 |
+
$active_settings = "nav-tab-active";
|
1907 |
+
}
|
1908 |
+
if ( $action == 'stats' ) {
|
1909 |
+
$active_stats = "nav-tab-active";
|
1910 |
+
}
|
1911 |
+
if ( $action == 'report' ) {
|
1912 |
+
$active_report = "nav-tab-active";
|
1913 |
+
}
|
1914 |
+
?>
|
1915 |
+
<div style="background-image: url('<?php echo plugins_url(); ?>/woocommerce-abandoned-cart/assets/images/ac_tab_icon.png') !important;" class="icon32"><br>
|
1916 |
+
</div>
|
1917 |
+
<h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
|
1918 |
+
<a href="admin.php?page=woocommerce_ac_page&action=listcart" class="nav-tab <?php if (isset($active_listcart)) echo $active_listcart; ?>"> <?php _e( 'Abandoned Orders', 'woocommerce-ac' );?> </a>
|
1919 |
+
<a href="admin.php?page=woocommerce_ac_page&action=emailtemplates" class="nav-tab <?php if (isset($active_emailtemplates)) echo $active_emailtemplates; ?>"> <?php _e( 'Email Templates', 'woocommerce-ac' );?> </a>
|
1920 |
+
<a href="admin.php?page=woocommerce_ac_page&action=emailsettings" class="nav-tab <?php if (isset($active_settings)) echo $active_settings; ?>"> <?php _e( 'Settings', 'woocommerce-ac' );?> </a>
|
1921 |
+
<a href="admin.php?page=woocommerce_ac_page&action=stats" class="nav-tab <?php if (isset($active_stats)) echo $active_stats; ?>"> <?php _e( 'Recovered Orders', 'woocommerce-ac' );?> </a>
|
1922 |
+
<a href="admin.php?page=woocommerce_ac_page&action=report" class="nav-tab <?php if( isset( $active_report ) ) echo $active_report; ?>"> <?php _e( 'Product Report', 'woocommerce-ac' );?> </a>
|
1923 |
+
</h2>
|
1924 |
+
<?php
|
1925 |
+
}
|
1926 |
+
|
1927 |
+
function wcal_enqueue_scripts_js( $hook ) {
|
1928 |
+
|
1929 |
+
if ( $hook != 'woocommerce_page_woocommerce_ac_page' ) {
|
1930 |
+
return;
|
1931 |
+
} else {
|
1932 |
+
wp_enqueue_script( 'jquery' );
|
1933 |
+
wp_enqueue_script(
|
1934 |
+
'jquery-ui-min',
|
1935 |
+
'//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js',
|
1936 |
+
'',
|
1937 |
+
'',
|
1938 |
+
false
|
1939 |
+
);
|
1940 |
+
wp_enqueue_script( 'jquery-ui-datepicker' );
|
1941 |
+
|
1942 |
+
wp_enqueue_script(
|
1943 |
+
'jquery-tip',
|
1944 |
+
plugins_url( '/assets/js/jquery.tipTip.minified.js', __FILE__ ),
|
1945 |
+
'',
|
1946 |
+
'',
|
1947 |
+
false
|
1948 |
+
);
|
1949 |
+
wp_register_script( 'woocommerce_admin', plugins_url() . '/woocommerce/assets/js/admin/woocommerce_admin.js', array( 'jquery', 'jquery-ui-widget', 'jquery-ui-core' ) );
|
1950 |
+
wp_enqueue_script( 'woocommerce_admin' );
|
1951 |
+
?>
|
1952 |
+
<script type="text/javascript" >
|
1953 |
+
function wcal_activate_email_template( template_id, active_state ) {
|
1954 |
+
location.href = 'admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=activate_template&id='+template_id+'&active_state='+active_state ;
|
1955 |
+
}
|
1956 |
+
</script>
|
1957 |
+
<?php
|
1958 |
+
$js_src = includes_url('js/tinymce/') . 'tinymce.min.js';
|
1959 |
+
wp_enqueue_script( 'tinyMce_ac',$js_src );
|
1960 |
+
wp_enqueue_script( 'ac_email_variables', plugins_url() . '/woocommerce-abandoned-cart/assets/js/abandoncart_plugin_button.js' );
|
1961 |
+
wp_enqueue_script( 'wcal_activate_template', plugins_url() . '/woocommerce-abandoned-cart/assets/js/wcal_template_activate.js' );
|
1962 |
+
}
|
1963 |
+
}
|
1964 |
+
|
1965 |
+
function wcal_format_tiny_MCE( $in ) {
|
1966 |
+
$in['force_root_block'] = false;
|
1967 |
+
$in['valid_children'] = '+body[style]';
|
1968 |
+
$in['remove_linebreaks'] = false;
|
1969 |
+
$in['gecko_spellcheck'] = false;
|
1970 |
+
$in['keep_styles'] = true;
|
1971 |
+
$in['accessibility_focus'] = true;
|
1972 |
+
$in['tabfocus_elements'] = 'major-publishing-actions';
|
1973 |
+
$in['media_strict'] = false;
|
1974 |
+
$in['paste_remove_styles'] = false;
|
1975 |
+
$in['paste_remove_spans'] = false;
|
1976 |
+
$in['paste_strip_class_attributes'] = 'none';
|
1977 |
+
$in['paste_text_use_dialog'] = true;
|
1978 |
+
$in['wpeditimage_disable_captions'] = true;
|
1979 |
+
$in['wpautop'] = false;
|
1980 |
+
$in['apply_source_formatting'] = true;
|
1981 |
+
$in['cleanup'] = true;
|
1982 |
+
$in['convert_newlines_to_brs'] = FALSE;
|
1983 |
+
$in['fullpage_default_xml_pi'] = false;
|
1984 |
+
$in['convert_urls'] = false;
|
1985 |
+
// Do not remove redundant BR tags
|
1986 |
+
$in['remove_redundant_brs'] = false;
|
1987 |
+
return $in;
|
1988 |
+
}
|
1989 |
+
|
1990 |
+
function wcal_enqueue_scripts_css( $hook ) {
|
1991 |
+
if ( $hook != 'woocommerce_page_woocommerce_ac_page' ) {
|
1992 |
+
return;
|
1993 |
+
} else {
|
1994 |
+
wp_enqueue_style( 'jquery-ui', "//ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" , '', '', false );
|
1995 |
+
wp_enqueue_style( 'woocommerce_admin_styles', plugins_url() . '/woocommerce/assets/css/admin.css' );
|
1996 |
+
wp_enqueue_style( 'jquery-ui-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
|
1997 |
+
wp_enqueue_style( 'abandoned-orders-list', plugins_url() . '/woocommerce-abandoned-cart/assets/css/view.abandoned.orders.style.css' );
|
1998 |
+
wp_enqueue_style( 'wcal_email_template', plugins_url() . '/woocommerce-abandoned-cart/assets/css/wcal_template_activate.css' );
|
1999 |
+
|
2000 |
+
}
|
2001 |
+
}
|
2002 |
+
//bulk action
|
2003 |
+
// to over come the wp redirect warning while deleting
|
2004 |
+
function wcal_app_output_buffer() {
|
2005 |
+
ob_start();
|
2006 |
+
}
|
2007 |
+
|
2008 |
+
/**
|
2009 |
+
* Abandon Cart Settings Page
|
2010 |
+
*/
|
2011 |
+
function wcal_menu_page() {
|
2012 |
+
|
2013 |
+
if ( is_user_logged_in() ) {
|
2014 |
+
global $wpdb;
|
2015 |
+
// Check the user capabilities
|
2016 |
+
if ( !current_user_can( 'manage_woocommerce' ) ) {
|
2017 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.', 'woocommerce-ac' ) );
|
2018 |
+
}
|
2019 |
+
?>
|
2020 |
+
<div class="wrap">
|
2021 |
+
<h2><?php _e( 'WooCommerce - Abandon Cart Lite', 'woocommerce-ac' ); ?></h2>
|
2022 |
+
<?php
|
2023 |
+
|
2024 |
+
if ( isset( $_GET['action'] ) ) {
|
2025 |
+
$action = $_GET['action'];
|
2026 |
+
} else {
|
2027 |
+
$action = "";
|
2028 |
+
}
|
2029 |
+
if ( isset( $_GET['mode'] ) ) {
|
2030 |
+
$mode = $_GET['mode'];
|
2031 |
+
} else {
|
2032 |
+
$mode = "";
|
2033 |
+
}
|
2034 |
+
$this->wcal_display_tabs();
|
2035 |
+
|
2036 |
+
/**
|
2037 |
+
* When we delete the item from the below drop down it is registred in action 2
|
2038 |
+
*/
|
2039 |
+
if ( isset( $_GET['action2'] ) ) {
|
2040 |
+
$action_two = $_GET['action2'];
|
2041 |
+
} else {
|
2042 |
+
$action_two = "";
|
2043 |
+
}
|
2044 |
+
// Detect when a bulk action is being triggered on abandoned orders page.
|
2045 |
+
if( 'wcal_delete' === $action || 'wcal_delete' === $action_two ) {
|
2046 |
+
$ids = isset( $_GET['abandoned_order_id'] ) ? $_GET['abandoned_order_id'] : false;
|
2047 |
+
if ( ! is_array( $ids ) ) {
|
2048 |
+
$ids = array( $ids );
|
2049 |
+
}
|
2050 |
+
foreach ( $ids as $id ) {
|
2051 |
+
$class = new wcal_delete_bulk_action_handler();
|
2052 |
+
$class->wcal_delete_bulk_action_handler_function( $id );
|
2053 |
+
}
|
2054 |
+
}
|
2055 |
+
//Detect when a bulk action is being triggered on temnplates page.
|
2056 |
+
if( 'wcal_delete_template' === $action || 'wcal_delete_template' === $action_two ) {
|
2057 |
+
$ids = isset( $_GET['template_id'] ) ? $_GET['template_id'] : false;
|
2058 |
+
if ( ! is_array( $ids ) ) {
|
2059 |
+
$ids = array( $ids );
|
2060 |
+
}
|
2061 |
+
foreach ( $ids as $id ) {
|
2062 |
+
$class = new wcal_delete_bulk_action_handler();
|
2063 |
+
$class->wcal_delete_template_bulk_action_handler_function( $id );
|
2064 |
+
}
|
2065 |
+
}
|
2066 |
+
|
2067 |
+
if ( isset( $_GET['wcal_deleted'] ) && 'YES' == $_GET['wcal_deleted'] ) { ?>
|
2068 |
+
<div id="message" class="updated fade">
|
2069 |
+
<p><strong><?php _e( 'The Abandoned cart has been successfully deleted.', 'woocommerce-ac' ); ?></strong></p>
|
2070 |
+
</div>
|
2071 |
+
<?php }
|
2072 |
+
if ( isset( $_GET ['wcal_template_deleted'] ) && 'YES' == $_GET['wcal_template_deleted'] ) { ?>
|
2073 |
+
<div id="message" class="updated fade">
|
2074 |
+
<p><strong><?php _e( 'The Template has been successfully deleted.', 'woocommerce-ac' ); ?></strong></p>
|
2075 |
+
</div>
|
2076 |
+
<?php }
|
2077 |
+
if ( $action == 'emailsettings' ) {
|
2078 |
+
// Save the field values
|
2079 |
+
?>
|
2080 |
+
<p><?php _e( 'Change settings for sending email notifications to Customers, to Admin etc.', 'woocommerce-ac' ); ?></p>
|
2081 |
+
<div id="content">
|
2082 |
+
<?php
|
2083 |
+
$wcal_general_settings_class = $wcal_email_setting = "";
|
2084 |
+
if ( isset( $_GET[ 'wcal_section' ] ) ) {
|
2085 |
+
$section = $_GET[ 'wcal_section' ];
|
2086 |
+
} else {
|
2087 |
+
$section = '';
|
2088 |
+
}
|
2089 |
+
if ( $section == 'wcal_general_settings' || $section == '' ) {
|
2090 |
+
$wcal_general_settings_class = "current";
|
2091 |
+
}
|
2092 |
+
if( $section == 'wcal_email_settings' ) {
|
2093 |
+
$wcal_email_setting = "current";
|
2094 |
+
}
|
2095 |
+
|
2096 |
+
?>
|
2097 |
+
<ul class="subsubsub" id="wcal_general_settings_list">
|
2098 |
+
<li>
|
2099 |
+
<a href="admin.php?page=woocommerce_ac_page&action=emailsettings&wcal_section=wcal_general_settings" class="<?php echo $wcal_general_settings_class; ?>"><?php _e( 'General Settings', 'woocommerce-ac' );?> </a> |
|
2100 |
+
</li>
|
2101 |
+
<li>
|
2102 |
+
<a href="admin.php?page=woocommerce_ac_page&action=emailsettings&wcal_section=wcal_email_settings" class="<?php echo $wcal_email_setting; ?>"><?php _e( 'Email Sending Settings', 'woocommerce-ac' );?> </a>
|
2103 |
+
</li>
|
2104 |
+
|
2105 |
+
</ul>
|
2106 |
+
<br class="clear">
|
2107 |
+
<?php
|
2108 |
+
if ( $section == 'wcal_general_settings' || $section == '' ) {
|
2109 |
+
?>
|
2110 |
+
<form method="post" action="options.php">
|
2111 |
+
<?php settings_fields( 'woocommerce_ac_settings' ); ?>
|
2112 |
+
<?php do_settings_sections( 'woocommerce_ac_page' ); ?>
|
2113 |
+
<?php settings_errors(); ?>
|
2114 |
+
<?php submit_button(); ?>
|
2115 |
+
</form>
|
2116 |
+
<?php
|
2117 |
+
} else if ( $section == 'wcal_email_settings' ) {
|
2118 |
+
?>
|
2119 |
+
<form method="post" action="options.php">
|
2120 |
+
<?php settings_fields ( 'woocommerce_ac_email_settings' ); ?>
|
2121 |
+
<?php do_settings_sections( 'woocommerce_ac_email_page' ); ?>
|
2122 |
+
<?php settings_errors(); ?>
|
2123 |
+
<?php submit_button(); ?>
|
2124 |
+
</form>
|
2125 |
+
<?php
|
2126 |
+
}
|
2127 |
+
?>
|
2128 |
+
</div>
|
2129 |
+
<?php
|
2130 |
+
} elseif ( $action == 'listcart' || '' == $action || '-1' == $action || '-1' == $action_two ) {
|
2131 |
+
?>
|
2132 |
+
<p> <?php _e( 'The list below shows all Abandoned Carts which have remained in cart for a time higher than the "Cart abandoned cut-off time" setting.', 'woocommerce-ac' );?> </p>
|
2133 |
+
<?php
|
2134 |
+
$get_all_abandoned_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_abandoned' );
|
2135 |
+
$get_registered_user_ac_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_registered' );
|
2136 |
+
$get_guest_user_ac_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_guest' );
|
2137 |
+
$get_visitor_user_ac_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_visitor' );
|
2138 |
+
|
2139 |
+
$wcal_user_reg_text = 'User';
|
2140 |
+
if ( $get_registered_user_ac_count > 1 ) {
|
2141 |
+
$wcal_user_reg_text = 'Users';
|
2142 |
+
}
|
2143 |
+
$wcal_user_gus_text = 'User';
|
2144 |
+
if ( $get_guest_user_ac_count > 1 ) {
|
2145 |
+
$wcal_user_gus_text = 'Users';
|
2146 |
+
}
|
2147 |
+
$wcal_all_abandoned_carts = $section = $wcal_all_registered = $wcal_all_guest = $wcal_all_visitor = "" ;
|
2148 |
+
|
2149 |
+
if ( isset( $_GET[ 'wcal_section' ] ) ) {
|
2150 |
+
$section = $_GET[ 'wcal_section' ];
|
2151 |
+
} else {
|
2152 |
+
$section = '';
|
2153 |
+
}
|
2154 |
+
if ( $section == 'wcal_all_abandoned' || $section == '' ) {
|
2155 |
+
$wcal_all_abandoned_carts = "current";
|
2156 |
+
}
|
2157 |
+
|
2158 |
+
if( $section == 'wcal_all_registered' ) {
|
2159 |
+
$wcal_all_registered = "current";
|
2160 |
+
$wcal_all_abandoned_carts = "";
|
2161 |
+
}
|
2162 |
+
if( $section == 'wcal_all_guest' ) {
|
2163 |
+
$wcal_all_guest = "current";
|
2164 |
+
$wcal_all_abandoned_carts = "";
|
2165 |
+
}
|
2166 |
+
|
2167 |
+
if( $section == 'wcal_all_visitor' ) {
|
2168 |
+
$wcal_all_visitor = "current";
|
2169 |
+
$wcal_all_abandoned_carts = "";
|
2170 |
+
}
|
2171 |
+
?>
|
2172 |
+
<ul class="subsubsub" id="wcal_recovered_orders_list">
|
2173 |
+
<li>
|
2174 |
+
<a href="admin.php?page=woocommerce_ac_page&action=listcart&wcal_section=wcal_all_abandoned" class="<?php echo $wcal_all_abandoned_carts; ?>"><?php _e( "All ", 'woocommerce-ac' ) ;?> <span class = "count" > <?php echo "( $get_all_abandoned_count )" ?> </span></a>
|
2175 |
+
</li>
|
2176 |
+
|
2177 |
+
<?php if ($get_registered_user_ac_count > 0 ) { ?>
|
2178 |
+
<li>
|
2179 |
+
| <a href="admin.php?page=woocommerce_ac_page&action=listcart&wcal_section=wcal_all_registered" class="<?php echo $wcal_all_registered; ?>"><?php _e( " Registered $wcal_user_reg_text ", 'woocommerce-ac' ) ;?> <span class = "count" > <?php echo "( $get_registered_user_ac_count )" ?> </span></a>
|
2180 |
+
</li>
|
2181 |
+
<?php } ?>
|
2182 |
+
|
2183 |
+
<?php if ($get_guest_user_ac_count > 0 ) { ?>
|
2184 |
+
<li>
|
2185 |
+
| <a href="admin.php?page=woocommerce_ac_page&action=listcart&wcal_section=wcal_all_guest" class="<?php echo $wcal_all_guest; ?>"><?php _e( " Guest $wcal_user_gus_text ", 'woocommerce-ac' ) ;?> <span class = "count" > <?php echo "( $get_guest_user_ac_count )" ?> </span></a>
|
2186 |
+
</li>
|
2187 |
+
<?php } ?>
|
2188 |
+
|
2189 |
+
<?php if ($get_visitor_user_ac_count > 0 ) { ?>
|
2190 |
+
<li>
|
2191 |
+
| <a href="admin.php?page=woocommerce_ac_page&action=listcart&wcal_section=wcal_all_visitor" class="<?php echo $wcal_all_visitor; ?>"><?php _e( " Carts without Customer Details ", 'woocommerce-ac' ) ;?> <span class = "count" > <?php echo "( $get_visitor_user_ac_count )" ?> </span></a>
|
2192 |
+
</li>
|
2193 |
+
<?php } ?>
|
2194 |
+
</ul>
|
2195 |
+
|
2196 |
+
<?php
|
2197 |
+
global $wpdb;
|
2198 |
+
include_once( 'includes/classes/class-wcal-abandoned-orders-table.php' );
|
2199 |
+
$wcal_abandoned_order_list = new WCAL_Abandoned_Orders_Table();
|
2200 |
+
$wcal_abandoned_order_list->wcal_abandoned_order_prepare_items();
|
2201 |
+
?>
|
2202 |
+
<div class="wrap">
|
2203 |
+
<form id="wcal-abandoned-orders" method="get" >
|
2204 |
+
<input type="hidden" name="page" value="woocommerce_ac_page" />
|
2205 |
+
<input type="hidden" name="action" value="listcart" />
|
2206 |
+
<?php $wcal_abandoned_order_list->display(); ?>
|
2207 |
+
</form>
|
2208 |
+
</div>
|
2209 |
+
<?php
|
2210 |
+
} elseif ( $action == 'emailtemplates' && ( $mode != 'edittemplate' && $mode != 'addnewtemplate' ) ) {
|
2211 |
+
?>
|
2212 |
+
<p> <?php _e( 'Add email templates at different intervals to maximize the possibility of recovering your abandoned carts.', 'woocommerce-ac' );?> </p>
|
2213 |
+
<?php
|
2214 |
+
// Save the field values
|
2215 |
+
$insert_template_successfuly = $update_template_successfuly = '';
|
2216 |
+
if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' ) {
|
2217 |
+
$woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
|
2218 |
+
$woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
|
2219 |
+
$woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
|
2220 |
+
$woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
|
2221 |
+
|
2222 |
+
$email_frequency = trim( $_POST['email_frequency'] );
|
2223 |
+
$day_or_hour = trim( $_POST['day_or_hour'] );
|
2224 |
+
$is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
|
2225 |
+
$default_value = 0 ;
|
2226 |
+
|
2227 |
+
$query = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
|
2228 |
+
(subject, body, frequency, day_or_hour, template_name, is_wc_template, default_template, wc_email_header )
|
2229 |
+
VALUES ( %s, %s, %d, %s, %s, %s, %d, %s )";
|
2230 |
+
|
2231 |
+
$insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query,
|
2232 |
+
$woocommerce_ac_email_subject,
|
2233 |
+
$woocommerce_ac_email_body,
|
2234 |
+
$email_frequency,
|
2235 |
+
$day_or_hour,
|
2236 |
+
$woocommerce_ac_template_name,
|
2237 |
+
$is_wc_template,
|
2238 |
+
$default_value,
|
2239 |
+
$woocommerce_ac_email_header )
|
2240 |
+
);
|
2241 |
+
}
|
2242 |
+
|
2243 |
+
if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' ) {
|
2244 |
+
|
2245 |
+
$updated_is_active = '0';
|
2246 |
+
|
2247 |
+
$email_frequency = trim( $_POST['email_frequency'] );
|
2248 |
+
$day_or_hour = trim( $_POST['day_or_hour'] );
|
2249 |
+
$is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
|
2250 |
+
|
2251 |
+
$woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
|
2252 |
+
$woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
|
2253 |
+
$woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
|
2254 |
+
$woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
|
2255 |
+
$id = trim( $_POST['id'] );
|
2256 |
+
|
2257 |
+
$check_query = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite`
|
2258 |
+
WHERE id = %d ";
|
2259 |
+
$check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $id ) );
|
2260 |
+
$default_value = '';
|
2261 |
+
|
2262 |
+
if ( count( $check_results ) > 0 ) {
|
2263 |
+
if ( isset( $check_results[0]->default_template ) && $check_results[0]->default_template == '1' ) {
|
2264 |
+
$default_value = '1';
|
2265 |
+
}
|
2266 |
+
}
|
2267 |
+
|
2268 |
+
$query_update_latest = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
|
2269 |
+
SET
|
2270 |
+
subject = %s,
|
2271 |
+
body = %s,
|
2272 |
+
frequency = %d,
|
2273 |
+
day_or_hour = %s,
|
2274 |
+
template_name = %s,
|
2275 |
+
is_wc_template = %s,
|
2276 |
+
default_template = %d,
|
2277 |
+
wc_email_header = %s
|
2278 |
+
WHERE id = %d ";
|
2279 |
+
|
2280 |
+
$update_template_successfuly = $wpdb->query( $wpdb->prepare( $query_update_latest,
|
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 |
+
$id )
|
2290 |
+
);
|
2291 |
+
|
2292 |
+
}
|
2293 |
+
|
2294 |
+
if ( $action == 'emailtemplates' && $mode == 'removetemplate' ) {
|
2295 |
+
$id_remove = $_GET['id'];
|
2296 |
+
$query_remove = "DELETE FROM `".$wpdb->prefix."ac_email_templates_lite` WHERE id= %d ";
|
2297 |
+
$wpdb->query( $wpdb->prepare( $query_remove, $id_remove ) );
|
2298 |
+
}
|
2299 |
+
|
2300 |
+
if ( $action == 'emailtemplates' && $mode == 'activate_template' ) {
|
2301 |
+
$template_id = $_GET['id'];
|
2302 |
+
$current_template_status = $_GET['active_state'];
|
2303 |
+
|
2304 |
+
if( "1" == $current_template_status ) {
|
2305 |
+
$active = "0";
|
2306 |
+
} else {
|
2307 |
+
$active = "1";
|
2308 |
+
|
2309 |
+
$query_update = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite` WHERE id ='" . $template_id . "'";
|
2310 |
+
$get_selected_template_result = $wpdb->get_results( $query_update );
|
2311 |
+
$email_frequncy = $get_selected_template_result[0]->frequency;
|
2312 |
+
$email_day_or_hour = $get_selected_template_result[0]->day_or_hour;
|
2313 |
+
|
2314 |
+
$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 . "' ";
|
2315 |
+
$wcap_updated = $wpdb->query( $query_update );
|
2316 |
+
}
|
2317 |
+
$query_update = "UPDATE `" . $wpdb->prefix . "ac_email_templates_lite`
|
2318 |
+
SET
|
2319 |
+
is_active = '" . $active . "'
|
2320 |
+
WHERE id = '" . $template_id . "' ";
|
2321 |
+
$wpdb->query( $query_update );
|
2322 |
+
|
2323 |
+
wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&action=emailtemplates' ) );
|
2324 |
+
}
|
2325 |
+
|
2326 |
+
if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' && ( isset( $insert_template_successfuly ) && $insert_template_successfuly != '' ) ) { ?>
|
2327 |
+
<div id="message" class="updated fade">
|
2328 |
+
<p>
|
2329 |
+
<strong>
|
2330 |
+
<?php _e( 'The Email Template has been successfully added.', 'woocommerce-ac' ); ?>
|
2331 |
+
</strong>
|
2332 |
+
</p>
|
2333 |
+
</div>
|
2334 |
+
<?php } else if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' && ( isset( $insert_template_successfuly ) && $insert_template_successfuly == '' ) ) {
|
2335 |
+
?>
|
2336 |
+
<div id="message" class="error fade">
|
2337 |
+
<p>
|
2338 |
+
<strong>
|
2339 |
+
<?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' ); ?>
|
2340 |
+
</strong>
|
2341 |
+
</p>
|
2342 |
+
</div>
|
2343 |
+
<?php
|
2344 |
+
}
|
2345 |
+
|
2346 |
+
if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' && isset($update_template_successfuly) && $update_template_successfuly >= 0 ) { ?>
|
2347 |
+
<div id="message" class="updated fade">
|
2348 |
+
<p>
|
2349 |
+
<strong>
|
2350 |
+
<?php _e( 'The Email Template has been successfully updated.', 'woocommerce-ac' ); ?>
|
2351 |
+
</strong>
|
2352 |
+
</p>
|
2353 |
+
</div>
|
2354 |
+
<?php } else if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' && isset($update_template_successfuly) && $update_template_successfuly === false ){
|
2355 |
+
?>
|
2356 |
+
<div id="message" class="error fade">
|
2357 |
+
<p>
|
2358 |
+
<strong>
|
2359 |
+
<?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' ); ?>
|
2360 |
+
</strong>
|
2361 |
+
</p>
|
2362 |
+
</div>
|
2363 |
+
<?php
|
2364 |
+
}
|
2365 |
+
?>
|
2366 |
+
<div class="tablenav">
|
2367 |
+
<p style="float:left;">
|
2368 |
+
<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' ); ?>
|
2369 |
+
</a>
|
2370 |
+
</p>
|
2371 |
+
|
2372 |
+
<?php
|
2373 |
+
/* From here you can do whatever you want with the data from the $result link. */
|
2374 |
+
include_once('includes/classes/class-wcal-templates-table.php');
|
2375 |
+
$wcal_template_list = new WCAL_Templates_Table();
|
2376 |
+
$wcal_template_list->wcal_templates_prepare_items();
|
2377 |
+
?>
|
2378 |
+
<div class="wrap">
|
2379 |
+
<form id="wcal-abandoned-templates" method="get" >
|
2380 |
+
<input type="hidden" name="page" value="woocommerce_ac_page" />
|
2381 |
+
<input type="hidden" name="action" value="emailtemplates" />
|
2382 |
+
<?php $wcal_template_list->display(); ?>
|
2383 |
+
</form>
|
2384 |
+
</div>
|
2385 |
+
</div>
|
2386 |
+
<?php
|
2387 |
+
} elseif ($action == 'stats' || $action == '') {
|
2388 |
+
?>
|
2389 |
+
<p>
|
2390 |
+
<script language='javascript'>
|
2391 |
+
jQuery( document ).ready( function() {
|
2392 |
+
jQuery( '#duration_select' ).change( function() {
|
2393 |
+
var group_name = jQuery( '#duration_select' ).val();
|
2394 |
+
var today = new Date();
|
2395 |
+
var start_date = "";
|
2396 |
+
var end_date = "";
|
2397 |
+
if ( group_name == "yesterday" ) {
|
2398 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 1 );
|
2399 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 1 );
|
2400 |
+
} else if ( group_name == "today") {
|
2401 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2402 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2403 |
+
} else if ( group_name == "last_seven" ) {
|
2404 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 7 );
|
2405 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2406 |
+
} else if ( group_name == "last_fifteen" ) {
|
2407 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 15 );
|
2408 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2409 |
+
} else if ( group_name == "last_thirty" ) {
|
2410 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 30 );
|
2411 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2412 |
+
} else if ( group_name == "last_ninety" ) {
|
2413 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 90 );
|
2414 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2415 |
+
} else if ( group_name == "last_year_days" ) {
|
2416 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 365 );
|
2417 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2418 |
+
}
|
2419 |
+
|
2420 |
+
var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
2421 |
+
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
2422 |
+
|
2423 |
+
var start_date_value = start_date.getDate() + " " + monthNames[start_date.getMonth()] + " " + start_date.getFullYear();
|
2424 |
+
var end_date_value = end_date.getDate() + " " + monthNames[end_date.getMonth()] + " " + end_date.getFullYear();
|
2425 |
+
|
2426 |
+
jQuery( '#start_date' ).val( start_date_value );
|
2427 |
+
jQuery( '#end_date' ).val( end_date_value );
|
2428 |
+
} );
|
2429 |
+
});
|
2430 |
+
</script>
|
2431 |
+
<?php
|
2432 |
+
|
2433 |
+
if ( isset( $_POST['duration_select'] ) ){
|
2434 |
+
$duration_range = $_POST['duration_select'];
|
2435 |
+
} else {
|
2436 |
+
$duration_range = "";
|
2437 |
+
}
|
2438 |
+
if ( $duration_range == "" ) {
|
2439 |
+
if ( isset( $_GET['duration_select'] ) ){
|
2440 |
+
$duration_range = $_GET['duration_select'];
|
2441 |
+
}
|
2442 |
+
}
|
2443 |
+
if ($duration_range == "") $duration_range = "last_seven";
|
2444 |
+
|
2445 |
+
_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');
|
2446 |
+
?>
|
2447 |
+
<div id="recovered_stats" class="postbox" style="display:block">
|
2448 |
+
<div class="inside">
|
2449 |
+
<form method="post" action="admin.php?page=woocommerce_ac_page&action=stats" id="ac_stats">
|
2450 |
+
<select id="duration_select" name="duration_select" >
|
2451 |
+
<?php
|
2452 |
+
foreach ( $this->duration_range_select as $key => $value ) {
|
2453 |
+
$sel = "";
|
2454 |
+
if ($key == $duration_range) {
|
2455 |
+
$sel = " selected ";
|
2456 |
+
}
|
2457 |
+
echo"<option value='$key' $sel> $value </option>";
|
2458 |
+
}
|
2459 |
+
$date_sett = $this->start_end_dates[ $duration_range ];
|
2460 |
+
?>
|
2461 |
+
</select>
|
2462 |
+
<script type="text/javascript">
|
2463 |
+
jQuery( document ).ready( function()
|
2464 |
+
{
|
2465 |
+
var formats = ["d.m.y", "d M yy","MM d, yy"];
|
2466 |
+
jQuery( "#start_date" ).datepicker( { dateFormat: formats[1] } );
|
2467 |
+
});
|
2468 |
+
|
2469 |
+
jQuery( document ).ready( function()
|
2470 |
+
{
|
2471 |
+
var formats = ["d.m.y", "d M yy","MM d, yy"];
|
2472 |
+
jQuery( "#end_date" ).datepicker( { dateFormat: formats[1] } );
|
2473 |
+
});
|
2474 |
+
</script>
|
2475 |
+
<?php
|
2476 |
+
include_once('includes/classes/class-wcal-recover-orders-table.php');
|
2477 |
+
$wcal_recover_orders_list = new WCAL_Recover_Orders_Table();
|
2478 |
+
$wcal_recover_orders_list->wcal_recovered_orders_prepare_items();
|
2479 |
+
|
2480 |
+
if ( isset( $_POST['start_date'] ) ) $start_date_range = $_POST['start_date'];
|
2481 |
+
else $start_date_range = "";
|
2482 |
+
|
2483 |
+
if ( $start_date_range == "" ) {
|
2484 |
+
$start_date_range = $date_sett['start_date'];
|
2485 |
+
}
|
2486 |
+
|
2487 |
+
if ( isset( $_POST['end_date'] ) ) $end_date_range = $_POST['end_date'];
|
2488 |
+
else $end_date_range = "";
|
2489 |
+
|
2490 |
+
if ( $end_date_range == "" ) {
|
2491 |
+
$end_date_range = $date_sett['end_date'];
|
2492 |
+
}
|
2493 |
+
?>
|
2494 |
+
<label class="start_label" for="start_day"> <?php _e( 'Start Date:', 'woocommerce-ac' ); ?> </label>
|
2495 |
+
<input type="text" id="start_date" name="start_date" readonly="readonly" value="<?php echo $start_date_range; ?>"/>
|
2496 |
+
<label class="end_label" for="end_day"> <?php _e( 'End Date:', 'woocommerce-ac' ); ?> </label>
|
2497 |
+
<input type="text" id="end_date" name="end_date" readonly="readonly" value="<?php echo $end_date_range; ?>"/>
|
2498 |
+
<input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e( 'Go', 'woocommerce-ac' ); ?>" />
|
2499 |
+
</form>
|
2500 |
+
</div>
|
2501 |
+
</div>
|
2502 |
+
<div id="recovered_stats" class="postbox" style="display:block">
|
2503 |
+
<div class="inside" >
|
2504 |
+
<p style="font-size: 15px"><?php _e( 'During the selected range ', 'woocommerce-ac' ); ?>
|
2505 |
+
<strong>
|
2506 |
+
<?php $count = $wcal_recover_orders_list->total_abandoned_cart_count;
|
2507 |
+
echo $count; ?>
|
2508 |
+
</strong>
|
2509 |
+
<?php _e( 'carts totaling', 'woocommerce-ac' ); ?>
|
2510 |
+
<strong>
|
2511 |
+
<?php $total_of_all_order = $wcal_recover_orders_list->total_order_amount;
|
2512 |
+
|
2513 |
+
echo $total_of_all_order; ?>
|
2514 |
+
</strong>
|
2515 |
+
<?php _e( ' were abandoned. We were able to recover', 'woocommerce-ac' ); ?>
|
2516 |
+
<strong>
|
2517 |
+
<?php
|
2518 |
+
$recovered_item = $wcal_recover_orders_list->recovered_item;
|
2519 |
+
|
2520 |
+
echo $recovered_item; ?>
|
2521 |
+
</strong>
|
2522 |
+
<?php _e( ' of them, which led to an extra', 'woocommerce-ac' ); ?>
|
2523 |
+
<strong>
|
2524 |
+
<?php
|
2525 |
+
$recovered_total = $wcal_recover_orders_list->total_recover_amount;
|
2526 |
+
echo wc_price( $recovered_total ); ?>
|
2527 |
+
</strong>
|
2528 |
+
</p>
|
2529 |
+
</div>
|
2530 |
+
</div>
|
2531 |
+
<div class="wrap">
|
2532 |
+
<form id="wcal-recover-orders" method="get" >
|
2533 |
+
<input type="hidden" name="page" value="woocommerce_ac_page" />
|
2534 |
+
<input type="hidden" name="action" value="stats" />
|
2535 |
+
<?php $wcal_recover_orders_list->display(); ?>
|
2536 |
+
</form>
|
2537 |
+
</div>
|
2538 |
+
<?php
|
2539 |
+
} elseif ( $action == 'orderdetails' ) {
|
2540 |
+
global $woocommerce;
|
2541 |
+
$ac_order_id = $_GET['id'];
|
2542 |
+
?>
|
2543 |
+
<p> </p>
|
2544 |
+
<div id="ac_order_details" class="postbox" style="display:block">
|
2545 |
+
<h3> <p> <?php _e( "Abandoned Order #$ac_order_id Details", "woocommerce-ac" ); ?> </p> </h3>
|
2546 |
+
<div class="inside">
|
2547 |
+
<table cellpadding="0" cellspacing="0" class="wp-list-table widefat fixed posts">
|
2548 |
+
<tr>
|
2549 |
+
<th> <?php _e( 'Item', 'woocommerce-ac' ); ?> </th>
|
2550 |
+
<th> <?php _e( 'Name', 'woocommerce-ac' ); ?> </th>
|
2551 |
+
<th> <?php _e( 'Quantity', 'woocommerce-ac' ); ?> </th>
|
2552 |
+
<th> <?php _e( 'Line Subtotal', 'woocommerce-ac' ); ?> </th>
|
2553 |
+
<th> <?php _e( 'Line Total', 'woocommerce-ac' ); ?> </th>
|
2554 |
+
</tr>
|
2555 |
+
<?php
|
2556 |
+
$query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE id = %d ";
|
2557 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query,$_GET['id'] ) );
|
2558 |
+
|
2559 |
+
$shipping_charges = 0;
|
2560 |
+
$currency_symbol = get_woocommerce_currency_symbol();
|
2561 |
+
$number_decimal = wc_get_price_decimals();
|
2562 |
+
if ( $results[0]->user_type == "GUEST" && "0" != $results[0]->user_id ) {
|
2563 |
+
$query_guest = "SELECT * FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d";
|
2564 |
+
$results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $results[0]->user_id ) );
|
2565 |
+
$user_email = $user_first_name = $user_last_name = $user_billing_postcode = $user_shipping_postcode = '';
|
2566 |
+
$shipping_charges = '';
|
2567 |
+
if ( count( $results_guest ) > 0 ) {
|
2568 |
+
$user_email = $results_guest[0]->email_id;
|
2569 |
+
$user_first_name = $results_guest[0]->billing_first_name;
|
2570 |
+
$user_last_name = $results_guest[0]->billing_last_name;
|
2571 |
+
$user_billing_postcode = $results_guest[0]->billing_zipcode;
|
2572 |
+
$user_shipping_postcode = $results_guest[0]->shipping_zipcode;
|
2573 |
+
$shipping_charges = $results_guest[0]->shipping_charges;
|
2574 |
+
}
|
2575 |
+
$user_billing_company = $user_billing_address_1 = $user_billing_address_2 = $user_billing_city = $user_billing_state = $user_billing_country = $user_billing_phone = "";
|
2576 |
+
$user_shipping_company = $user_shipping_address_1 = $user_shipping_address_2 = $user_shipping_city = $user_shipping_state = $user_shipping_country = "";
|
2577 |
+
} else if ( $results[0]->user_type == "GUEST" && $results[0]->user_id == "0" ) {
|
2578 |
+
$user_email = '';
|
2579 |
+
$user_first_name = "Visitor";
|
2580 |
+
$user_last_name = "";
|
2581 |
+
$user_billing_postcode = '';
|
2582 |
+
$user_shipping_postcode = '';
|
2583 |
+
$shipping_charges = '';
|
2584 |
+
$user_billing_phone = '';
|
2585 |
+
$user_billing_company = $user_billing_address_1 = $user_billing_address_2 = $user_billing_city = $user_billing_state = $user_billing_country = "";
|
2586 |
+
$user_shipping_company = $user_shipping_address_1 = $user_shipping_address_2 = $user_shipping_city = $user_shipping_state = $user_shipping_country = "";
|
2587 |
+
} else {
|
2588 |
+
$user_id = $results[0]->user_id;
|
2589 |
+
if ( isset( $results[0]->user_login ) ) {
|
2590 |
+
$user_login = $results[0]->user_login;
|
2591 |
+
}
|
2592 |
+
$user_email = get_user_meta( $results[0]->user_id, 'billing_email', true );
|
2593 |
+
if( "" == $user_email ) {
|
2594 |
+
$user_data = get_userdata( $results[0]->user_id );
|
2595 |
+
if ( isset( $user_data->user_email ) ) {
|
2596 |
+
$user_email = $user_data->user_email;
|
2597 |
+
} else {
|
2598 |
+
$user_email = '';
|
2599 |
+
}
|
2600 |
+
}
|
2601 |
+
|
2602 |
+
$user_first_name = "";
|
2603 |
+
$user_first_name_temp = get_user_meta( $user_id, 'billing_first_name', true );
|
2604 |
+
if( isset( $user_first_name_temp ) && "" == $user_first_name_temp ) {
|
2605 |
+
$user_data = get_userdata( $user_id );
|
2606 |
+
if ( isset( $user_data->first_name ) ) {
|
2607 |
+
$user_first_name = $user_data->first_name;
|
2608 |
+
} else {
|
2609 |
+
$user_first_name = '';
|
2610 |
+
}
|
2611 |
+
} else {
|
2612 |
+
$user_first_name = $user_first_name_temp;
|
2613 |
+
}
|
2614 |
+
$user_last_name = "";
|
2615 |
+
$user_last_name_temp = get_user_meta( $user_id, 'billing_last_name', true );
|
2616 |
+
if( isset( $user_last_name_temp ) && "" == $user_last_name_temp ) {
|
2617 |
+
$user_data = get_userdata( $user_id );
|
2618 |
+
if ( isset( $user_data->last_name ) ) {
|
2619 |
+
$user_last_name = $user_data->last_name;
|
2620 |
+
} else {
|
2621 |
+
$user_last_name = '';
|
2622 |
+
}
|
2623 |
+
} else {
|
2624 |
+
$user_last_name = $user_last_name_temp;
|
2625 |
+
}
|
2626 |
+
$user_billing_first_name = get_user_meta( $results[0]->user_id, 'billing_first_name' );
|
2627 |
+
$user_billing_last_name = get_user_meta( $results[0]->user_id, 'billing_last_name' );
|
2628 |
+
$user_billing_company_temp = get_user_meta( $results[0]->user_id, 'billing_company' );
|
2629 |
+
if ( isset( $user_billing_company_temp[0] ) ) {
|
2630 |
+
$user_billing_company = $user_billing_company_temp[0];
|
2631 |
+
} else {
|
2632 |
+
$user_billing_company = "";
|
2633 |
+
}
|
2634 |
+
$user_billing_address_1_temp = get_user_meta( $results[0]->user_id, 'billing_address_1' );
|
2635 |
+
if ( isset( $user_billing_address_1_temp[0] ) ) {
|
2636 |
+
$user_billing_address_1 = $user_billing_address_1_temp[0];
|
2637 |
+
} else {
|
2638 |
+
$user_billing_address_1 = "";
|
2639 |
+
}
|
2640 |
+
$user_billing_address_2_temp = get_user_meta( $results[0]->user_id, 'billing_address_2' );
|
2641 |
+
if ( isset( $user_billing_address_2_temp[0] ) ) {
|
2642 |
+
$user_billing_address_2 = $user_billing_address_2_temp[0];
|
2643 |
+
} else {
|
2644 |
+
$user_billing_address_2 = "";
|
2645 |
+
}
|
2646 |
+
$user_billing_city_temp = get_user_meta( $results[0]->user_id, 'billing_city' );
|
2647 |
+
if ( isset( $user_billing_city_temp[0] ) ) {
|
2648 |
+
$user_billing_city = $user_billing_city_temp[0];
|
2649 |
+
} else {
|
2650 |
+
$user_billing_city = "";
|
2651 |
+
}
|
2652 |
+
$user_billing_postcode_temp = get_user_meta( $results[0]->user_id, 'billing_postcode' );
|
2653 |
+
if ( isset( $user_billing_postcode_temp[0] ) ) {
|
2654 |
+
$user_billing_postcode = $user_billing_postcode_temp[0];
|
2655 |
+
} else {
|
2656 |
+
$user_billing_postcode = "";
|
2657 |
+
}
|
2658 |
+
$user_billing_state_temp = get_user_meta( $results[0]->user_id, 'billing_state' );
|
2659 |
+
if ( isset( $user_billing_state_temp[0] ) ) {
|
2660 |
+
$user_billing_state = $user_billing_state_temp[0];
|
2661 |
+
} else {
|
2662 |
+
$user_billing_state = "";
|
2663 |
+
}
|
2664 |
+
$user_billing_country_temp = get_user_meta( $results[0]->user_id, 'billing_country' );
|
2665 |
+
if ( isset( $user_billing_country_temp[0] ) ) {
|
2666 |
+
$user_billing_country = $user_billing_country_temp[0];
|
2667 |
+
} else {
|
2668 |
+
$user_billing_country = "";
|
2669 |
+
}
|
2670 |
+
$user_billing_phone_temp = get_user_meta( $results[0]->user_id, 'billing_phone' );
|
2671 |
+
if ( isset( $user_billing_phone_temp[0] ) ) {
|
2672 |
+
$user_billing_phone = $user_billing_phone_temp[0];
|
2673 |
+
} else {
|
2674 |
+
$user_billing_phone = "";
|
2675 |
+
}
|
2676 |
+
$user_shipping_first_name = get_user_meta( $results[0]->user_id, 'shipping_first_name' );
|
2677 |
+
$user_shipping_last_name = get_user_meta( $results[0]->user_id, 'shipping_last_name' );
|
2678 |
+
$user_shipping_company_temp = get_user_meta( $results[0]->user_id, 'shipping_company' );
|
2679 |
+
if ( isset( $user_shipping_company_temp[0] ) ) {
|
2680 |
+
$user_shipping_company = $user_shipping_company_temp[0];
|
2681 |
+
} else {
|
2682 |
+
$user_shipping_company = "";
|
2683 |
+
}
|
2684 |
+
$user_shipping_address_1_temp = get_user_meta( $results[0]->user_id, 'shipping_address_1' );
|
2685 |
+
if ( isset( $user_shipping_address_1_temp[0] ) ) {
|
2686 |
+
$user_shipping_address_1 = $user_shipping_address_1_temp[0];
|
2687 |
+
} else {
|
2688 |
+
$user_shipping_address_1 = "";
|
2689 |
+
}
|
2690 |
+
$user_shipping_address_2_temp = get_user_meta( $results[0]->user_id, 'shipping_address_2' );
|
2691 |
+
if ( isset( $user_shipping_address_2_temp[0] ) ) {
|
2692 |
+
$user_shipping_address_2 = $user_shipping_address_2_temp[0];
|
2693 |
+
} else {
|
2694 |
+
$user_shipping_address_2 = "";
|
2695 |
+
}
|
2696 |
+
$user_shipping_city_temp = get_user_meta( $results[0]->user_id, 'shipping_city' );
|
2697 |
+
if ( isset( $user_shipping_city_temp[0] ) ) {
|
2698 |
+
$user_shipping_city = $user_shipping_city_temp[0];
|
2699 |
+
} else {
|
2700 |
+
$user_shipping_city = "";
|
2701 |
+
}
|
2702 |
+
$user_shipping_postcode_temp = get_user_meta( $results[0]->user_id, 'shipping_postcode' );
|
2703 |
+
if ( isset( $user_shipping_postcode_temp[0] ) ) {
|
2704 |
+
$user_shipping_postcode = $user_shipping_postcode_temp[0];
|
2705 |
+
} else {
|
2706 |
+
$user_shipping_postcode = "";
|
2707 |
+
}
|
2708 |
+
$user_shipping_state_temp = get_user_meta( $results[0]->user_id, 'shipping_state' );
|
2709 |
+
if ( isset( $user_shipping_state_temp[0] ) ) {
|
2710 |
+
$user_shipping_state = $user_shipping_state_temp[0];
|
2711 |
+
} else {
|
2712 |
+
$user_shipping_state = "";
|
2713 |
+
}
|
2714 |
+
$user_shipping_country_temp = get_user_meta( $results[0]->user_id, 'shipping_country' );
|
2715 |
+
if ( isset( $user_shipping_country_temp[0] ) ) {
|
2716 |
+
$user_shipping_country = $user_shipping_country_temp[0];
|
2717 |
+
} else {
|
2718 |
+
$user_shipping_country = "";
|
2719 |
+
}
|
2720 |
+
}
|
2721 |
+
$cart_details = array();
|
2722 |
+
$cart_info = json_decode( $results[0]->abandoned_cart_info );
|
2723 |
+
$cart_details = (array) $cart_info->cart;
|
2724 |
+
$item_subtotal = $item_total = 0;
|
2725 |
+
|
2726 |
+
if ( is_array ( $cart_details ) && count( $cart_details ) > 0 ) {
|
2727 |
+
foreach ( $cart_details as $k => $v ) {
|
2728 |
+
$quantity_total = $v->quantity;
|
2729 |
+
$product_id = $v->product_id;
|
2730 |
+
$prod_name = get_post($product_id);
|
2731 |
+
$product_name = $prod_name->post_title;
|
2732 |
+
if ( isset( $v->variation_id ) && '' != $v->variation_id ){
|
2733 |
+
$variation_id = $v->variation_id;
|
2734 |
+
$variation = wc_get_product( $variation_id );
|
2735 |
+
$name = $variation->get_formatted_name() ;
|
2736 |
+
$explode_all = explode ( "–", $name );
|
2737 |
+
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
2738 |
+
$wcap_sku = '';
|
2739 |
+
if ( $variation->get_sku() ) {
|
2740 |
+
$wcap_sku = "SKU: " . $variation->get_sku() . "<br>";
|
2741 |
+
}
|
2742 |
+
$wcap_get_formatted_variation = wc_get_formatted_variation( $variation, true );
|
2743 |
+
|
2744 |
+
$add_product_name = $product_name . ' - ' . $wcap_sku . $wcap_get_formatted_variation;
|
2745 |
+
|
2746 |
+
$pro_name_variation = (array) $add_product_name;
|
2747 |
+
}else{
|
2748 |
+
$pro_name_variation = array_slice( $explode_all, 1, -1 );
|
2749 |
+
}
|
2750 |
+
$product_name_with_variable = '';
|
2751 |
+
$explode_many_varaition = array();
|
2752 |
+
foreach( $pro_name_variation as $pro_name_variation_key => $pro_name_variation_value ) {
|
2753 |
+
$explode_many_varaition = explode ( ",", $pro_name_variation_value );
|
2754 |
+
if( !empty( $explode_many_varaition ) ) {
|
2755 |
+
foreach( $explode_many_varaition as $explode_many_varaition_key => $explode_many_varaition_value ) {
|
2756 |
+
$product_name_with_variable = $product_name_with_variable . html_entity_decode ( $explode_many_varaition_value ) . "<br>";
|
2757 |
+
}
|
2758 |
+
} else {
|
2759 |
+
$product_name_with_variable = $product_name_with_variable . html_entity_decode ( $explode_many_varaition_value ) . "<br>";
|
2760 |
+
}
|
2761 |
+
}
|
2762 |
+
$product_name = $product_name_with_variable;
|
2763 |
+
}
|
2764 |
+
// Item subtotal is calculated as product total including taxes
|
2765 |
+
if ( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
|
2766 |
+
$item_subtotal = $item_subtotal + $v->line_total + $v->line_subtotal_tax;
|
2767 |
+
} else {
|
2768 |
+
$item_subtotal = $item_subtotal + $v->line_total;
|
2769 |
+
}
|
2770 |
+
// Line total
|
2771 |
+
$item_total = $item_subtotal;
|
2772 |
+
$item_subtotal = $item_subtotal / $quantity_total;
|
2773 |
+
$item_total = wc_price( $item_total );
|
2774 |
+
$item_subtotal = wc_price( $item_subtotal );
|
2775 |
+
$product = wc_get_product( $product_id );
|
2776 |
+
$prod_image = $product->get_image();
|
2777 |
+
?>
|
2778 |
+
<tr>
|
2779 |
+
<td> <?php echo $prod_image; ?></td>
|
2780 |
+
<td> <?php echo $product_name; ?></td>
|
2781 |
+
<td> <?php echo $quantity_total; ?></td>
|
2782 |
+
<td> <?php echo $item_subtotal; ?></td>
|
2783 |
+
<td> <?php echo $item_total; ?></td>
|
2784 |
+
</tr>
|
2785 |
+
<?php
|
2786 |
+
$item_subtotal = $item_total = 0;
|
2787 |
+
}
|
2788 |
+
}
|
2789 |
+
?>
|
2790 |
+
</table>
|
2791 |
+
</div>
|
2792 |
+
</div>
|
2793 |
+
<div id="ac_order_customer_details" class="postbox" style="display:block">
|
2794 |
+
<h3> <p> <?php _e( 'Customer Details' , 'woocommerce-ac' ); ?> </p> </h3>
|
2795 |
+
<div class="inside" style="height: 300px;" >
|
2796 |
+
<div id="order_data" class="panel">
|
2797 |
+
<div style="width:50%;float:left">
|
2798 |
+
<h3> <p> <?php _e( 'Billing Details' , 'woocommerce-ac' ); ?> </p> </h3>
|
2799 |
+
<p> <strong> <?php _e( 'Name:' , 'woocommerce-ac' ); ?> </strong>
|
2800 |
+
<?php echo $user_first_name." ".$user_last_name;?>
|
2801 |
+
</p>
|
2802 |
+
<p> <strong> <?php _e( 'Address:' , 'woocommerce-ac' ); ?> </strong>
|
2803 |
+
<?php echo $user_billing_company."</br>".
|
2804 |
+
$user_billing_address_1."</br>".
|
2805 |
+
$user_billing_address_2."</br>".
|
2806 |
+
$user_billing_city."</br>".
|
2807 |
+
$user_billing_postcode."</br>".
|
2808 |
+
$user_billing_state."</br>".
|
2809 |
+
$user_billing_country."</br>";
|
2810 |
+
?>
|
2811 |
+
</p>
|
2812 |
+
<p> <strong> <?php _e( 'Email:', 'woocommerce-ac' ); ?> </strong>
|
2813 |
+
<?php $user_mail_to = "mailto:".$user_email; ?>
|
2814 |
+
<a href=<?php echo $user_mail_to;?>><?php echo $user_email;?> </a>
|
2815 |
+
</p>
|
2816 |
+
<p> <strong> <?php _e( 'Phone:', 'woocommerce-ac' ); ?> </strong>
|
2817 |
+
<?php echo $user_billing_phone;?>
|
2818 |
+
</p>
|
2819 |
+
</div>
|
2820 |
+
<div style="width:50%;float:right">
|
2821 |
+
<h3> <p> <?php _e( 'Shipping Details', 'woocommerce-ac' ); ?> </p> </h3>
|
2822 |
+
<p> <strong> <?php _e( 'Address:', 'woocommerce-ac' ); ?> </strong>
|
2823 |
+
<?php
|
2824 |
+
if ( $user_shipping_company == '' &&
|
2825 |
+
$user_shipping_address_1 == '' &&
|
2826 |
+
$user_shipping_address_2 == '' &&
|
2827 |
+
$user_shipping_city == '' &&
|
2828 |
+
$user_shipping_postcode == '' &&
|
2829 |
+
$user_shipping_state == '' &&
|
2830 |
+
$user_shipping_country == '') {
|
2831 |
+
echo "Shipping Address same as Billing Address";
|
2832 |
+
} else { ?>
|
2833 |
+
<?php echo $user_shipping_company."</br>".
|
2834 |
+
$user_shipping_address_1."</br>".
|
2835 |
+
$user_shipping_address_2."</br>".
|
2836 |
+
$user_shipping_city."</br>".
|
2837 |
+
$user_shipping_postcode."</br>".
|
2838 |
+
$user_shipping_state."</br>".
|
2839 |
+
$user_shipping_country."</br>";
|
2840 |
+
?>
|
2841 |
+
<br><br>
|
2842 |
+
<strong> Shipping Charges: </strong>
|
2843 |
+
<?php if ( $shipping_charges != 0 ) echo $currency_symbol . $shipping_charges;?>
|
2844 |
+
</p>
|
2845 |
+
<?php }?>
|
2846 |
+
</div>
|
2847 |
+
</div>
|
2848 |
+
</div>
|
2849 |
+
</div>
|
2850 |
+
<?php } elseif ( $action == 'report' ) {
|
2851 |
+
include_once('includes/classes/class-wcal-product-report-table.php');
|
2852 |
+
$wcal_product_report_list = new WCAL_Product_Report_Table();
|
2853 |
+
$wcal_product_report_list->wcal_product_report_prepare_items();
|
2854 |
+
?>
|
2855 |
+
<div class="wrap">
|
2856 |
+
<form id="wcal-sent-emails" method="get" >
|
2857 |
+
<input type="hidden" name="page" value="woocommerce_ac_page" />
|
2858 |
+
<input type="hidden" name="action" value="report" />
|
2859 |
+
<?php $wcal_product_report_list->display(); ?>
|
2860 |
+
</form>
|
2861 |
+
</div>
|
2862 |
+
<?php }
|
2863 |
+
}
|
2864 |
+
echo( "</table>" );
|
2865 |
+
|
2866 |
+
if ( isset( $_GET['action'] ) ) {
|
2867 |
+
$action = $_GET['action'];
|
2868 |
+
}
|
2869 |
+
if ( isset( $_GET['mode'] ) ){
|
2870 |
+
$mode = $_GET['mode'];
|
2871 |
+
}
|
2872 |
+
if ( $action == 'emailtemplates' && ( $mode == 'addnewtemplate' || $mode == 'edittemplate' ) ) {
|
2873 |
+
if ( $mode=='edittemplate' ) {
|
2874 |
+
$results = array();
|
2875 |
+
if ( isset( $_GET['id'] ) ) {
|
2876 |
+
$edit_id = $_GET['id'];
|
2877 |
+
|
2878 |
+
$query = "SELECT wpet . * FROM `".$wpdb->prefix."ac_email_templates_lite` AS wpet WHERE id = %d ";
|
2879 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query, $edit_id ) );
|
2880 |
+
}
|
2881 |
+
}
|
2882 |
+
$active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
2883 |
+
?>
|
2884 |
+
<div id="content">
|
2885 |
+
<form method="post" action="admin.php?page=woocommerce_ac_page&action=emailtemplates" id="ac_settings">
|
2886 |
+
<input type="hidden" name="mode" value="<?php echo $mode;?>" />
|
2887 |
+
<?php
|
2888 |
+
$id_by = "";
|
2889 |
+
if ( isset( $_GET['id'] ) ) {
|
2890 |
+
$id_by = $_GET['id'];
|
2891 |
+
}
|
2892 |
+
?>
|
2893 |
+
<input type="hidden" name="id" value="<?php echo $id_by ;?>" />
|
2894 |
+
<?php
|
2895 |
+
$button_mode = "save";
|
2896 |
+
$display_message = "Add Email Template";
|
2897 |
+
if ( $mode == 'edittemplate' ) {
|
2898 |
+
$button_mode = "update";
|
2899 |
+
$display_message = "Edit Email Template";
|
2900 |
+
}
|
2901 |
+
print'<input type="hidden" name="ac_settings_frm" value="'.$button_mode.'">';?>
|
2902 |
+
<div id="poststuff">
|
2903 |
+
<div> <!-- <div class="postbox" > -->
|
2904 |
+
<h3 class="hndle"><?php _e( $display_message, 'woocommerce-ac' ); ?></h3>
|
2905 |
+
<div>
|
2906 |
+
<table class="form-table" id="addedit_template">
|
2907 |
+
<tr>
|
2908 |
+
<th>
|
2909 |
+
<label for="woocommerce_ac_template_name"><b><?php _e( 'Template Name:', 'woocommerce-ac');?></b></label>
|
2910 |
+
</th>
|
2911 |
+
<td>
|
2912 |
+
<?php
|
2913 |
+
$template_name = "";
|
2914 |
+
if( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->template_name ) ) {
|
2915 |
+
$template_name = $results[0]->template_name;
|
2916 |
+
}
|
2917 |
+
print'<input type="text" name="woocommerce_ac_template_name" id="woocommerce_ac_template_name" class="regular-text" value="'.$template_name.'">';?>
|
2918 |
+
<img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter a template name for reference', 'woocommerce-ac') ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" />
|
2919 |
+
</td>
|
2920 |
+
</tr>
|
2921 |
+
|
2922 |
+
<tr>
|
2923 |
+
<th>
|
2924 |
+
<label for="woocommerce_ac_email_subject"><b><?php _e( 'Subject:', 'woocommerce-ac' ); ?></b></label>
|
2925 |
+
</th>
|
2926 |
+
<td>
|
2927 |
+
<?php
|
2928 |
+
$subject_edit = "";
|
2929 |
+
if ( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->subject ) ) {
|
2930 |
+
$subject_edit= stripslashes ( $results[0]->subject );
|
2931 |
+
}
|
2932 |
+
print'<input type="text" name="woocommerce_ac_email_subject" id="woocommerce_ac_email_subject" class="regular-text" value="'.$subject_edit.'">';?>
|
2933 |
+
<img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter the subject that should appear in the email sent', 'woocommerce-ac') ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" />
|
2934 |
+
</td>
|
2935 |
+
</tr>
|
2936 |
+
|
2937 |
+
<tr>
|
2938 |
+
<th>
|
2939 |
+
<label for="woocommerce_ac_email_body"><b><?php _e( 'Email Body:', 'woocommerce-ac' ); ?></b></label>
|
2940 |
+
</th>
|
2941 |
+
<td>
|
2942 |
+
<?php
|
2943 |
+
$initial_data = "";
|
2944 |
+
if ( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->body ) ) {
|
2945 |
+
$initial_data = stripslashes( $results[0]->body );
|
2946 |
+
}
|
2947 |
+
|
2948 |
+
$initial_data = str_replace ( "My document title", "", $initial_data );
|
2949 |
+
wp_editor(
|
2950 |
+
$initial_data,
|
2951 |
+
'woocommerce_ac_email_body',
|
2952 |
+
array(
|
2953 |
+
'media_buttons' => true,
|
2954 |
+
'textarea_rows' => 15,
|
2955 |
+
'tabindex' => 4,
|
2956 |
+
'tinymce' => array(
|
2957 |
+
'theme_advanced_buttons1' => 'bold,italic,underline,|,bullist,numlist,blockquote,|,link,unlink,|,spellchecker,fullscreen,|,formatselect,styleselect'
|
2958 |
+
),
|
2959 |
+
)
|
2960 |
+
);
|
2961 |
+
|
2962 |
+
?>
|
2963 |
+
<?php echo stripslashes( get_option( 'woocommerce_ac_email_body' ) ); ?>
|
2964 |
+
<span class="description"><?php
|
2965 |
+
echo __( 'Message to be sent in the reminder email.', 'woocommerce-ac' );
|
2966 |
+
?></span>
|
2967 |
+
</td>
|
2968 |
+
</tr>
|
2969 |
+
|
2970 |
+
<tr>
|
2971 |
+
<th>
|
2972 |
+
<label for="is_wc_template"><b><?php _e( 'Use WooCommerce Template Style:', 'woocommerce-ac' ); ?></b></label>
|
2973 |
+
</th>
|
2974 |
+
<td>
|
2975 |
+
<?php
|
2976 |
+
$is_wc_template = "";
|
2977 |
+
if ( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->is_wc_template ) ) {
|
2978 |
+
$use_wc_template = $results[0]->is_wc_template;
|
2979 |
+
|
2980 |
+
if ( $use_wc_template == '1' ) {
|
2981 |
+
$is_wc_template = "checked";
|
2982 |
+
} else {
|
2983 |
+
$is_wc_template = "";
|
2984 |
+
}
|
2985 |
+
}
|
2986 |
+
print'<input type="checkbox" name="is_wc_template" id="is_wc_template" ' . $is_wc_template . '> </input>'; ?>
|
2987 |
+
<img class="help_tip" width="16" height="16" data-tip='<?php _e( 'Use WooCommerce default style template for abandoned cart reminder emails.', 'woocommerce' ) ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" /> <a target = '_blank' href= <?php echo wp_nonce_url( admin_url( '?wcal_preview_woocommerce_mail=true' ), 'woocommerce-ac' ) ; ?> >
|
2988 |
+
Click here to preview </a>how the email template will look with WooCommerce Template Style enabled. Alternatively, if this is unchecked, the template will appear as <a target = '_blank' href=<?php echo wp_nonce_url( admin_url( '?wcal_preview_mail=true' ), 'woocommerce-ac' ) ; ?>>shown here</a>. <br> <strong>Note: </strong>When this setting is enabled, then "Send From This Name:" & "Send From This Email Address:" will be overwritten with WooCommerce -> Settings -> Email -> Email Sender Options.
|
2989 |
+
</td>
|
2990 |
+
</tr>
|
2991 |
+
|
2992 |
+
<tr>
|
2993 |
+
<th>
|
2994 |
+
<label for="wcal_wc_email_header"><b><?php _e( 'Email Template Header Text: ', 'woocommerce-ac' ); ?></b></label>
|
2995 |
+
</th>
|
2996 |
+
<td>
|
2997 |
+
|
2998 |
+
<?php
|
2999 |
+
|
3000 |
+
$wcal_wc_email_header = "";
|
3001 |
+
if ( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->wc_email_header ) ) {
|
3002 |
+
$wcal_wc_email_header = $results[0]->wc_email_header;
|
3003 |
+
}
|
3004 |
+
if ( $wcal_wc_email_header == "" ) {
|
3005 |
+
$wcal_wc_email_header = "Abandoned cart reminder";
|
3006 |
+
}
|
3007 |
+
print'<input type="text" name="wcal_wc_email_header" id="wcal_wc_email_header" class="regular-text" value="' . $wcal_wc_email_header . '">'; ?>
|
3008 |
+
<img class="help_tip" width="16" height="16" data-tip='<?php _e( 'Enter the header which will appear in the abandoned WooCommerce email sent. This is only applicable when only used when "Use WooCommerce Template Style:" is checked.', 'woocommerce-ac' ) ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" />
|
3009 |
+
</td>
|
3010 |
+
</tr>
|
3011 |
+
|
3012 |
+
<tr>
|
3013 |
+
<th>
|
3014 |
+
<label for="woocommerce_ac_email_frequency"><b><?php _e( 'Send this email:', 'woocommerce-ac' ); ?></b></label>
|
3015 |
+
</th>
|
3016 |
+
<td>
|
3017 |
+
<select name="email_frequency" id="email_frequency">
|
3018 |
+
<?php
|
3019 |
+
$frequency_edit = "";
|
3020 |
+
if( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->frequency ) ) {
|
3021 |
+
$frequency_edit = $results[0]->frequency;
|
3022 |
+
}
|
3023 |
+
for ( $i = 1; $i < 4; $i++ ) {
|
3024 |
+
printf( "<option %s value='%s'>%s</option>\n",
|
3025 |
+
selected( $i, $frequency_edit, false ),
|
3026 |
+
esc_attr( $i ),
|
3027 |
+
$i
|
3028 |
+
);
|
3029 |
+
}
|
3030 |
+
?>
|
3031 |
+
</select>
|
3032 |
+
|
3033 |
+
<select name="day_or_hour" id="day_or_hour">
|
3034 |
+
<?php
|
3035 |
+
$days_or_hours_edit = "";
|
3036 |
+
if ( $mode == 'edittemplate' && count( $results ) > 0 && isset( $results[0]->day_or_hour ) )
|
3037 |
+
{
|
3038 |
+
$days_or_hours_edit = $results[0]->day_or_hour;
|
3039 |
+
}
|
3040 |
+
$days_or_hours = array(
|
3041 |
+
'Days' => 'Day(s)',
|
3042 |
+
'Hours' => 'Hour(s)'
|
3043 |
+
);
|
3044 |
+
foreach( $days_or_hours as $k => $v )
|
3045 |
+
{
|
3046 |
+
printf( "<option %s value='%s'>%s</option>\n",
|
3047 |
+
selected( $k, $days_or_hours_edit, false ),
|
3048 |
+
esc_attr( $k ),
|
3049 |
+
$v
|
3050 |
+
);
|
3051 |
+
}
|
3052 |
+
?>
|
3053 |
+
</select>
|
3054 |
+
<span class="description">
|
3055 |
+
<?php echo __( 'after cart is abandoned.', 'woocommerce-ac' ); ?>
|
3056 |
+
</span>
|
3057 |
+
</td>
|
3058 |
+
</tr>
|
3059 |
+
|
3060 |
+
<tr>
|
3061 |
+
<th>
|
3062 |
+
<label for="woocommerce_ac_email_preview"><b><?php _e( 'Send a test email to:', 'woocommerce-ac' ); ?></b></label>
|
3063 |
+
</th>
|
3064 |
+
<td>
|
3065 |
+
<input type="text" id="send_test_email" name="send_test_email" class="regular-text" >
|
3066 |
+
<input type="button" value="Send a test email" id="preview_email" onclick="javascript:void(0);">
|
3067 |
+
<img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter the email id to which the test email needs to be sent.', 'woocommerce-ac') ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" />
|
3068 |
+
<div id="preview_email_sent_msg" style="display:none;"></div>
|
3069 |
+
</td>
|
3070 |
+
</tr>
|
3071 |
+
</table>
|
3072 |
+
</div>
|
3073 |
+
</div>
|
3074 |
+
</div>
|
3075 |
+
<p class="submit">
|
3076 |
+
<?php
|
3077 |
+
$button_value = "Save Changes";
|
3078 |
+
if ( $mode == 'edittemplate' )
|
3079 |
+
{
|
3080 |
+
$button_value = "Update Changes";
|
3081 |
+
}?>
|
3082 |
+
<input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e( $button_value, 'woocommerce-ac' ); ?>" />
|
3083 |
+
</p>
|
3084 |
+
</form>
|
3085 |
+
</div>
|
3086 |
+
<?php
|
3087 |
+
}
|
3088 |
+
}
|
3089 |
+
|
3090 |
+
function wcal_admin_footer_text( $footer_text ) {
|
3091 |
+
|
3092 |
+
if ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] === 'woocommerce_ac_page' ) {
|
3093 |
+
$footer_text = sprintf( __( 'If you love <strong>Abandoned Cart Lite for WooCommerce</strong>, then please leave us a <a href="https://wordpress.org/support/plugin/woocommerce-abandoned-cart/reviews/?rate=5#new-post" target="_blank" class="ac-rating-link" data-rated="Thanks :)">★★★★★</a>
|
3094 |
+
rating. Thank you in advance. :)', 'woocommerce-ac' ) );
|
3095 |
+
wc_enqueue_js( "
|
3096 |
+
jQuery( 'a.ac-rating-link' ).click( function() {
|
3097 |
+
jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) );
|
3098 |
+
});
|
3099 |
+
" );
|
3100 |
+
}
|
3101 |
+
return $footer_text;
|
3102 |
+
}
|
3103 |
+
|
3104 |
+
function bubble_sort_function( $unsort_array, $order ) {
|
3105 |
+
$temp = array();
|
3106 |
+
foreach ( $unsort_array as $key => $value )
|
3107 |
+
$temp[ $key ] = $value; //concatenate something unique to make sure two equal weights don't overwrite each other
|
3108 |
+
asort( $temp, SORT_NUMERIC ); // or ksort($temp, SORT_NATURAL); see paragraph above to understand why
|
3109 |
+
|
3110 |
+
if( $order == 'desc' ) {
|
3111 |
+
$array = array_reverse( $temp, true );
|
3112 |
+
} else if( $order == 'asc' ) {
|
3113 |
+
$array = $temp;
|
3114 |
+
}
|
3115 |
+
unset( $temp );
|
3116 |
+
return $array;
|
3117 |
+
}
|
3118 |
+
|
3119 |
+
function wcal_action_send_preview() {
|
3120 |
+
?>
|
3121 |
+
<script type="text/javascript" >
|
3122 |
+
jQuery( document ).ready( function( $ )
|
3123 |
+
{
|
3124 |
+
$( "table#addedit_template input#preview_email" ).click( function()
|
3125 |
+
{
|
3126 |
+
var email_body = '';
|
3127 |
+
if ( jQuery("#wp-woocommerce_ac_email_body-wrap").hasClass( "tmce-active" ) ) {
|
3128 |
+
email_body = tinyMCE.get('woocommerce_ac_email_body').getContent();
|
3129 |
+
} else {
|
3130 |
+
email_body = jQuery('#woocommerce_ac_email_body').val();
|
3131 |
+
}
|
3132 |
+
var subject_email_preview = $( '#woocommerce_ac_email_subject' ).val();
|
3133 |
+
var body_email_preview = email_body;
|
3134 |
+
var send_email_id = $( '#send_test_email' ).val();
|
3135 |
+
var is_wc_template = document.getElementById( "is_wc_template" ).checked;
|
3136 |
+
var wc_template_header = $( '#wcal_wc_email_header' ).val() != '' ? $( '#wcal_wc_email_header' ).val() : 'Abandoned cart reminder';
|
3137 |
+
var data = {
|
3138 |
+
subject_email_preview: subject_email_preview,
|
3139 |
+
body_email_preview : body_email_preview,
|
3140 |
+
send_email_id : send_email_id,
|
3141 |
+
is_wc_template : is_wc_template,
|
3142 |
+
wc_template_header : wc_template_header,
|
3143 |
+
action : 'wcal_preview_email_sent'
|
3144 |
+
};
|
3145 |
+
|
3146 |
+
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
3147 |
+
$.post( ajaxurl, data, function( response ) {
|
3148 |
+
if ( 'not sent' == response ) {
|
3149 |
+
$( "#preview_email_sent_msg" ).html( "Test email is not sent as the Email body is empty." );
|
3150 |
+
$( "#preview_email_sent_msg" ).fadeIn();
|
3151 |
+
setTimeout( function(){$( "#preview_email_sent_msg" ).fadeOut();}, 4000 );
|
3152 |
+
} else {
|
3153 |
+
$( "#preview_email_sent_msg" ).html( "<img src='<?php echo plugins_url(); ?>/woocommerce-abandoned-cart/assets/images/check.jpg'> Email has been sent successfully." );
|
3154 |
+
$( "#preview_email_sent_msg" ).fadeIn();
|
3155 |
+
setTimeout( function(){$( "#preview_email_sent_msg" ).fadeOut();}, 3000 );
|
3156 |
+
}
|
3157 |
+
//alert('Got this from the server: ' + response);
|
3158 |
+
});
|
3159 |
+
});
|
3160 |
+
});
|
3161 |
+
</script>
|
3162 |
+
<?php
|
3163 |
+
}
|
3164 |
+
public static function wcal_toggle_template_status () {
|
3165 |
+
global $wpdb;
|
3166 |
+
$template_id = $_POST['wcal_template_id'];
|
3167 |
+
$current_template_status = $_POST['current_state'];
|
3168 |
+
|
3169 |
+
if( "on" == $current_template_status ) {
|
3170 |
+
$query_update = "SELECT * FROM `" . $wpdb->prefix . "ac_email_templates_lite` WHERE id ='" . $template_id . "'";
|
3171 |
+
$get_selected_template_result = $wpdb->get_results( $query_update );
|
3172 |
+
$email_frequncy = $get_selected_template_result[0]->frequency;
|
3173 |
+
$email_day_or_hour = $get_selected_template_result[0]->day_or_hour;
|
3174 |
+
$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 . "' ";
|
3175 |
+
$wcal_updated = $wpdb->query( $query_update );
|
3176 |
+
|
3177 |
+
if ( 1 == $wcal_updated ){
|
3178 |
+
$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 . "' ";
|
3179 |
+
$wcal_updated_get_id = $wpdb->get_results( $query_update_get_id );
|
3180 |
+
$wcal_all_ids = '';
|
3181 |
+
foreach ($wcal_updated_get_id as $wcal_updated_get_id_key => $wcal_updated_get_id_value ) {
|
3182 |
+
# code...
|
3183 |
+
if ( '' == $wcal_all_ids ){
|
3184 |
+
$wcal_all_ids = $wcal_updated_get_id_value->id;
|
3185 |
+
}else{
|
3186 |
+
$wcal_all_ids = $wcal_all_ids . ',' .$wcal_updated_get_id_value->id;
|
3187 |
+
}
|
3188 |
+
}
|
3189 |
+
echo 'wcal-template-updated:'. $wcal_all_ids ;
|
3190 |
+
}
|
3191 |
+
|
3192 |
+
$active = "1";
|
3193 |
+
} else {
|
3194 |
+
$active = "0";
|
3195 |
+
}
|
3196 |
+
$query_update = "UPDATE `" . $wpdb->prefix . "ac_email_templates_lite`
|
3197 |
+
SET
|
3198 |
+
is_active = '" . $active . "'
|
3199 |
+
WHERE id = '" . $template_id . "' ";
|
3200 |
+
$wpdb->query( $query_update );
|
3201 |
+
wp_die();
|
3202 |
+
|
3203 |
+
}
|
3204 |
+
// Send Test Email
|
3205 |
+
function wcal_preview_email_sent() {
|
3206 |
+
if ( '' != $_POST['body_email_preview'] ) {
|
3207 |
+
$from_email_name = get_option ( 'wcal_from_name' );
|
3208 |
+
$reply_name_preview = get_option ( 'wcal_from_email' );
|
3209 |
+
$from_email_preview = get_option ( 'wcal_reply_email' );
|
3210 |
+
$subject_email_preview = stripslashes ( $_POST['subject_email_preview'] );
|
3211 |
+
$subject_email_preview = convert_smilies ( $subject_email_preview );
|
3212 |
+
$body_email_preview = convert_smilies ( $_POST['body_email_preview'] );
|
3213 |
+
$is_wc_template = $_POST['is_wc_template'];
|
3214 |
+
$wc_template_header = stripslashes( $_POST['wc_template_header'] );
|
3215 |
+
$body_email_preview = str_replace( '{{customer.firstname}}', 'John', $body_email_preview );
|
3216 |
+
$body_email_preview = str_replace( '{{customer.lastname}}', 'Doe', $body_email_preview );
|
3217 |
+
$body_email_preview = str_replace( '{{customer.fullname}}', 'John'." ".'Doe', $body_email_preview );
|
3218 |
+
$current_time_stamp = current_time( 'timestamp' );
|
3219 |
+
$date_format = date_i18n( get_option( 'date_format' ), $current_time_stamp );
|
3220 |
+
$time_format = date_i18n( get_option( 'time_format' ), $current_time_stamp );
|
3221 |
+
$test_date = $date_format . ' ' . $time_format;
|
3222 |
+
$body_email_preview = str_replace( '{{cart.abandoned_date}}', $test_date, $body_email_preview );
|
3223 |
+
$cart_url = wc_get_page_permalink( 'cart' );
|
3224 |
+
$body_email_preview = str_replace( '{{cart.link}}', $cart_url, $body_email_preview );
|
3225 |
+
$body_email_preview = str_replace( '{{cart.unsubscribe}}', '<a href=#>unsubscribe</a>', $body_email_preview );
|
3226 |
+
$wcal_price = wc_price( '100' );
|
3227 |
+
$wcal_total_price = wc_price( '200' );
|
3228 |
+
if ( class_exists( 'WP_Better_Emails' ) ) {
|
3229 |
+
$headers = "From: " . $from_email_name . " <" . $from_email_preview . ">" . "\r\n";
|
3230 |
+
$headers .= "Content-Type: text/plain" . "\r\n";
|
3231 |
+
$headers .= "Reply-To: " . $reply_name_preview . " " . "\r\n";
|
3232 |
+
$var = '<table width = 100%>
|
3233 |
+
<tr> <td colspan="5"> <h3>'.__( "Your Shopping Cart", "woocommerce-ac" ).'</h3> </td></tr>
|
3234 |
+
<tr align="center">
|
3235 |
+
<th>'.__( "Item", "woocommerce-ac" ).'</th>
|
3236 |
+
<th>'.__( "Name", "woocommerce-ac" ).'</th>
|
3237 |
+
<th>'.__( "Quantity", "woocommerce-ac" ).'</th>
|
3238 |
+
<th>'.__( "Price", "woocommerce-ac" ).'</th>
|
3239 |
+
<th>'.__( "Line Subtotal", "woocommerce-ac" ).'</th>
|
3240 |
+
</tr>
|
3241 |
+
<tr align="center">
|
3242 |
+
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/shoes.jpg"/></td>
|
3243 |
+
<td>'.__( "Men\'\s Formal Shoes", "woocommerce-ac" ).'</td>
|
3244 |
+
<td>1</td>
|
3245 |
+
<td>' . $wcal_price . '</td>
|
3246 |
+
<td>' . $wcal_price . '</td>
|
3247 |
+
</tr>
|
3248 |
+
<tr align="center">
|
3249 |
+
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/handbag.jpg"/></td>
|
3250 |
+
<td>'.__( "Woman\'\s Hand Bags", "woocommerce-ac" ).'</td>
|
3251 |
+
<td>1</td>
|
3252 |
+
<td>' . $wcal_price . '</td>
|
3253 |
+
<td>' . $wcal_price . '</td>
|
3254 |
+
</tr>
|
3255 |
+
<tr align="center">
|
3256 |
+
<td></td>
|
3257 |
+
<td></td>
|
3258 |
+
<td></td>
|
3259 |
+
<td>'.__( "Cart Total:", "woocommerce-ac" ).'</td>
|
3260 |
+
<td>' . $wcal_total_price . '</td>
|
3261 |
+
</tr>
|
3262 |
+
</table>';
|
3263 |
+
} else {
|
3264 |
+
$headers = "From: " . $from_email_name . " <" . $from_email_preview . ">" . "\r\n";
|
3265 |
+
$headers .= "Content-Type: text/html" . "\r\n";
|
3266 |
+
$headers .= "Reply-To: " . $reply_name_preview . " " . "\r\n";
|
3267 |
+
$var = '<h3>'.__( "Your Shopping Cart", "woocommerce-ac" ).'</h3>
|
3268 |
+
<table border="0" cellpadding="10" cellspacing="0" class="templateDataTable">
|
3269 |
+
<tr align="center">
|
3270 |
+
<th>'.__( "Item", "woocommerce-ac" ).'</th>
|
3271 |
+
<th>'.__( "Name", "woocommerce-ac" ).'</th>
|
3272 |
+
<th>'.__( "Quantity", "woocommerce-ac" ).'</th>
|
3273 |
+
<th>'.__( "Price", "woocommerce-ac" ).'</th>
|
3274 |
+
<th>'.__( "Line Subtotal", "woocommerce-ac" ).'</th>
|
3275 |
+
</tr>
|
3276 |
+
<tr align="center">
|
3277 |
+
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/shoes.jpg"/></td>
|
3278 |
+
<td>'.__( "Men\'\s Formal Shoes", "woocommerce-ac" ).'</td>
|
3279 |
+
<td>1</td>
|
3280 |
+
<td>' . $wcal_price . '</td>
|
3281 |
+
<td>' . $wcal_price . '</td>
|
3282 |
+
</tr>
|
3283 |
+
<tr align="center">
|
3284 |
+
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/handbag.jpg"/></td>
|
3285 |
+
<td>'.__( "Woman\'\s Hand Bags", "woocommerce-ac" ).'</td>
|
3286 |
+
<td>1</td>
|
3287 |
+
<td>' . $wcal_price . '</td>
|
3288 |
+
<td>' . $wcal_price . '</td>
|
3289 |
+
</tr>
|
3290 |
+
<tr align="center">
|
3291 |
+
<td></td>
|
3292 |
+
<td></td>
|
3293 |
+
<td></td>
|
3294 |
+
<td>'.__( "Cart Total:", "woocommerce-ac" ).'</td>
|
3295 |
+
<td>' . $wcal_total_price . '</td>
|
3296 |
+
</tr>
|
3297 |
+
</table>';
|
3298 |
+
}
|
3299 |
+
$body_email_preview = str_replace( '{{products.cart}}', $var, $body_email_preview );
|
3300 |
+
if ( isset( $_POST['send_email_id'] ) ) {
|
3301 |
+
$to_email_preview = $_POST['send_email_id'];
|
3302 |
+
} else {
|
3303 |
+
$to_email_preview = "";
|
3304 |
+
}
|
3305 |
+
$user_email_from = get_option( 'admin_email' );
|
3306 |
+
$body_email_final_preview = stripslashes( $body_email_preview );
|
3307 |
+
|
3308 |
+
if ( isset( $is_wc_template ) && "true" == $is_wc_template ) {
|
3309 |
+
ob_start();
|
3310 |
+
// Get email heading
|
3311 |
+
wc_get_template( 'emails/email-header.php', array( 'email_heading' => $wc_template_header ) );
|
3312 |
+
$email_body_template_header = ob_get_clean();
|
3313 |
+
|
3314 |
+
ob_start();
|
3315 |
+
wc_get_template( 'emails/email-footer.php' );
|
3316 |
+
$email_body_template_footer = ob_get_clean();
|
3317 |
+
|
3318 |
+
$final_email_body = $email_body_template_header . $body_email_final_preview . $email_body_template_footer;
|
3319 |
+
|
3320 |
+
wc_mail( $to_email_preview, $subject_email_preview, $final_email_body , $headers );
|
3321 |
+
}
|
3322 |
+
else {
|
3323 |
+
wp_mail( $to_email_preview, $subject_email_preview, stripslashes( $body_email_preview ), $headers );
|
3324 |
+
}
|
3325 |
+
echo "email sent";
|
3326 |
+
die();
|
3327 |
+
} else {
|
3328 |
+
echo "not sent";
|
3329 |
+
die();
|
3330 |
+
}
|
3331 |
+
}
|
3332 |
+
}
|
3333 |
+
}
|
3334 |
+
$woocommerce_abandon_cart = new woocommerce_abandon_cart_lite();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3335 |
?>
|