Version Description
(04.07.2017) =
This version has 1 bug fix.
Bug Fixed - Logged-in user's carts were not captured with the WooCommerce version 3.1. This issue has been fixed.
Download this release
Release Info
Developer | bhavik.kiri |
Plugin | Abandoned Cart Lite for WooCommerce |
Version | 4.0 |
Comparing to | |
See all releases |
Code changes from version 3.9.3 to 4.0
- cron/wcal_send_email.php +4 -2
- includes/wcal_admin_notice.php +162 -0
- readme.txt +13 -1
- woocommerce-ac.php +2404 -2381
cron/wcal_send_email.php
CHANGED
@@ -96,7 +96,7 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
|
|
96 |
if( isset( $value->abandoned_cart_info ) ) {
|
97 |
$cart_info_db_field = json_decode( $value->abandoned_cart_info );
|
98 |
}
|
99 |
-
if( count( $cart_info_db_field->cart ) > 0 && $value->user_id != '0') {
|
100 |
$cart_update_time = $value->abandoned_cart_time;
|
101 |
$new_user = $this->wcal_check_sent_history( $value->user_id, $cart_update_time, $template_id, $value->id );
|
102 |
if ( $new_user == true ) {
|
@@ -418,7 +418,9 @@ if ( !class_exists( 'woocommerce_abandon_cart_cron' ) ) {
|
|
418 |
$query_email = "SELECT user_email FROM `".$wpdb->prefix."users` WHERE ID = %d";
|
419 |
}
|
420 |
$results_email = $wpdb->get_results( $wpdb->prepare( $query_email, $user_id ) );
|
421 |
-
|
|
|
|
|
422 |
}
|
423 |
$query_email_id = "SELECT post_id FROM `" . $wpdb->prefix . "postmeta` WHERE meta_key = '_billing_email' AND meta_value = %s";
|
424 |
$results_query_email = $wpdb->get_results( $wpdb->prepare( $query_email_id, $user_billing_email ) );
|
96 |
if( isset( $value->abandoned_cart_info ) ) {
|
97 |
$cart_info_db_field = json_decode( $value->abandoned_cart_info );
|
98 |
}
|
99 |
+
if( count( $cart_info_db_field->cart ) > 0 && isset( $value->user_id ) && $value->user_id != '0') {
|
100 |
$cart_update_time = $value->abandoned_cart_time;
|
101 |
$new_user = $this->wcal_check_sent_history( $value->user_id, $cart_update_time, $template_id, $value->id );
|
102 |
if ( $new_user == true ) {
|
418 |
$query_email = "SELECT user_email FROM `".$wpdb->prefix."users` WHERE ID = %d";
|
419 |
}
|
420 |
$results_email = $wpdb->get_results( $wpdb->prepare( $query_email, $user_id ) );
|
421 |
+
if( !empty( $results_email[0]->user_email ) ) {
|
422 |
+
$user_billing_email = $results_email[0]->user_email;
|
423 |
+
}
|
424 |
}
|
425 |
$query_email_id = "SELECT post_id FROM `" . $wpdb->prefix . "postmeta` WHERE meta_key = '_billing_email' AND meta_value = %s";
|
426 |
$results_query_email = $wpdb->get_results( $wpdb->prepare( $query_email_id, $user_billing_email ) );
|
includes/wcal_admin_notice.php
ADDED
@@ -0,0 +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 |
+
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Contributors: ashokrane, pinal.shah, bhavik.kiri, chetnapatel, tychesoftwares
|
|
4 |
Tags: abandon cart, cart recovery, increase woocommerce conversion rate , recover woocommerce cart, increase sales with woocommerce
|
5 |
Author URI: https://www.tychesoftwares.com/
|
6 |
Requires at least: 1.3
|
7 |
-
Tested up to: 4.
|
8 |
Stable tag: trunk
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -178,6 +178,12 @@ You can refer **[here](https://www.tychesoftwares.com/differences-between-pro-an
|
|
178 |
|
179 |
== Changelog ==
|
180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
= 3.9.3 (09.06.2017) =
|
182 |
|
183 |
* This version has 3 bugs fixes.
|
@@ -439,6 +445,12 @@ For existing users, this setting will remain unchecked. For new users of the plu
|
|
439 |
|
440 |
== Upgrade Notice ==
|
441 |
|
|
|
|
|
|
|
|
|
|
|
|
|
442 |
= 3.9.3 (09.06.2017) =
|
443 |
|
444 |
* This version has 3 bugs fixes.
|
4 |
Tags: abandon cart, cart recovery, increase woocommerce conversion rate , recover woocommerce cart, increase sales with woocommerce
|
5 |
Author URI: https://www.tychesoftwares.com/
|
6 |
Requires at least: 1.3
|
7 |
+
Tested up to: 4.8
|
8 |
Stable tag: trunk
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
178 |
|
179 |
== Changelog ==
|
180 |
|
181 |
+
= 4.0 (04.07.2017) =
|
182 |
+
|
183 |
+
* This version has 1 bug fix.
|
184 |
+
|
185 |
+
* Bug Fixed - Logged-in user's carts were not captured with the WooCommerce version 3.1. This issue has been fixed.
|
186 |
+
|
187 |
= 3.9.3 (09.06.2017) =
|
188 |
|
189 |
* This version has 3 bugs fixes.
|
445 |
|
446 |
== Upgrade Notice ==
|
447 |
|
448 |
+
= 4.0 (04.07.2017) =
|
449 |
+
|
450 |
+
* This version has 1 bug fix.
|
451 |
+
|
452 |
+
* Bug Fixed - Logged-in user's carts were not captured with the WooCommerce version 3.1. This issue has been fixed.
|
453 |
+
|
454 |
= 3.9.3 (09.06.2017) =
|
455 |
|
456 |
* This version has 3 bugs fixes.
|
woocommerce-ac.php
CHANGED
@@ -3,7 +3,7 @@
|
|
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:
|
7 |
Author: Tyche Softwares
|
8 |
Author URI: http://www.tychesoftwares.com/
|
9 |
Text Domain: woocommerce-ac
|
@@ -20,11 +20,12 @@ require_once( "includes/classes/class-wcal-aes.php" );
|
|
20 |
require_once( "includes/classes/class-wcal-aes-counter.php" );
|
21 |
require_once( "includes/wcal-common.php" );
|
22 |
require_once( "includes/wcal_ts_tracking.php");
|
|
|
23 |
|
24 |
// Add a new interval of 15 minutes
|
25 |
add_filter( 'cron_schedules', 'wcal_add_cron_schedule' );
|
26 |
|
27 |
-
function wcal_add_cron_schedule( $schedules ) {
|
28 |
$schedules['15_minutes_lite'] = array(
|
29 |
'interval' => 900, // 15 minutes in seconds
|
30 |
'display' => __( 'Once Every Fifteen Minutes' ),
|
@@ -61,558 +62,565 @@ function wcal_send_email_cron() {
|
|
61 |
require_once( $plugin_dir_path . 'cron/wcal_send_email.php' );
|
62 |
}
|
63 |
|
64 |
-
function woocommerce_ac_delete_lite() {
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
} else {
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
}
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
}
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
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 |
$this->start_end_dates = array( 'yesterday' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 24*60*60 ) ),
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
);
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
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 |
-
|
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 |
-
|
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 |
WHERE id = '".$get_abandoned_id_of_order."' ";
|
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 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
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 |
-
|
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 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
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 |
'woocommerce_ac_settings',
|
617 |
'ac_lite_cart_abandoned_time',
|
618 |
array ( $this, 'ac_lite_cart_time_validation' )
|
@@ -640,577 +648,581 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
640 |
'woocommerce_ac_email_settings',
|
641 |
'wcal_reply_email'
|
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 |
'.checked( 'on', $disable_guest_cart_from_cart_page, false ) . ' />' );
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
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 |
-
|
979 |
-
|
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 |
-
* Send email to admin when cart is recovered via any other payment gateway other than PayPal.
|
1036 |
-
* @since 2.3 version
|
1037 |
-
*/
|
1038 |
-
function wcal_email_admin_recovery ( $order_id ) {
|
1039 |
-
global $wpdb, $woocommerce;
|
1040 |
-
|
1041 |
-
$user_id = get_current_user_id();
|
1042 |
-
$ac_email_admin_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
|
1043 |
-
if( $ac_email_admin_recovery == 'on' ) {
|
1044 |
-
$order = new WC_Order( $order_id );
|
1045 |
-
|
1046 |
-
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
1047 |
-
$user_id = $order->get_user_id();
|
1048 |
-
}else{
|
1049 |
-
$user_id = $order->user_id;
|
1050 |
-
}
|
1051 |
-
$recovered_email_sent = get_post_meta( $order_id, 'wcap_recovered_email_sent', true );
|
1052 |
-
$check_abandoned_cart = get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true );
|
1053 |
-
$created_via = get_post_meta( $order_id, '_created_via', true );
|
1054 |
-
if ( 'checkout' == $created_via && 'yes' != $recovered_email_sent && ( $check_abandoned_cart == md5( "yes" ) || $check_abandoned_cart == md5( "no" ) ) ) { // indicates cart is abandoned
|
1055 |
-
$email_heading = __( 'New Customer Order - Recovered', 'woocommerce-ac' );
|
1056 |
-
$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
|
1057 |
-
$email_subject = "New Customer Order - Recovered";
|
1058 |
-
$user_email = get_option( 'admin_email' );
|
1059 |
-
$headers[] = "From: Admin <".$user_email.">";
|
1060 |
-
$headers[] = "Content-Type: text/html";
|
1061 |
-
// Buffer
|
1062 |
-
ob_start();
|
1063 |
-
// Get mail template
|
1064 |
-
wc_get_template( 'emails/admin-new-order.php', array(
|
1065 |
-
'order' => $order,
|
1066 |
-
'email_heading' => $email_heading,
|
1067 |
-
'sent_to_admin' => false,
|
1068 |
-
'plain_text' => false,
|
1069 |
-
'email' => true
|
1070 |
-
) );
|
1071 |
-
// Get contents
|
1072 |
-
$email_body = ob_get_clean();
|
1073 |
-
|
1074 |
-
wc_mail( $user_email, $email_subject, $email_body, $headers );
|
1075 |
-
|
1076 |
-
update_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
|
1077 |
-
}
|
1078 |
-
}
|
1079 |
-
}
|
1080 |
-
|
1081 |
-
// Add a submenu page.
|
1082 |
-
function wcal_admin_menu() {
|
1083 |
-
$page = add_submenu_page ( 'woocommerce', __( 'Abandoned Carts', 'woocommerce-ac' ), __( 'Abandoned Carts', 'woocommerce-ac' ), 'manage_woocommerce', 'woocommerce_ac_page', array( &$this, 'wcal_menu_page' ) );
|
1084 |
-
}
|
1085 |
-
|
1086 |
-
// Capture the cart and insert the information of the cart into DataBase
|
1087 |
-
function wcal_store_cart_timestamp() {
|
1088 |
-
|
1089 |
-
if( session_id() === '' ){
|
1090 |
-
//session has not started
|
1091 |
-
session_start();
|
1092 |
-
}
|
1093 |
-
global $wpdb,$woocommerce;
|
1094 |
-
$current_time = current_time( 'timestamp' );
|
1095 |
-
$cut_off_time = get_option( 'ac_lite_cart_abandoned_time' );
|
1096 |
-
$track_guest_cart_from_cart_page = get_option( 'ac_lite_track_guest_cart_from_cart_page' );
|
1097 |
-
$cart_ignored = 0;
|
1098 |
-
$recovered_cart = 0;
|
1099 |
-
|
1100 |
-
$track_guest_user_cart_from_cart = "";
|
1101 |
-
if ( isset( $track_guest_cart_from_cart_page ) ) {
|
1102 |
-
$track_guest_user_cart_from_cart = $track_guest_cart_from_cart_page;
|
1103 |
-
}
|
1104 |
-
|
1105 |
-
if( isset( $cut_off_time ) ) {
|
1106 |
-
$cart_cut_off_time = $cut_off_time * 60;
|
1107 |
-
} else {
|
1108 |
-
$cart_cut_off_time = 60 * 60;
|
1109 |
-
}
|
1110 |
-
$compare_time = $current_time - $cart_cut_off_time;
|
1111 |
-
|
1112 |
-
if ( is_user_logged_in() ) {
|
1113 |
-
$user_id = get_current_user_id();
|
1114 |
-
$query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1115 |
-
WHERE user_id = %d
|
1116 |
-
AND cart_ignored = %s
|
1117 |
-
AND recovered_cart = %d ";
|
1118 |
-
$results = $wpdb->get_results($wpdb->prepare( $query, $user_id, $cart_ignored, $recovered_cart ) );
|
1119 |
-
|
1120 |
-
if ( count($results) == 0 ) {
|
1121 |
-
$cart_info = json_encode( get_user_meta( $user_id, '_woocommerce_persistent_cart', true ) );
|
1122 |
-
$user_type = "REGISTERED";
|
1123 |
-
$insert_query = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1124 |
-
( user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type )
|
1125 |
-
VALUES ( %d, %s, %d, %s, %s )";
|
1126 |
-
$wpdb->query( $wpdb->prepare( $insert_query, $user_id, $cart_info,$current_time, $cart_ignored, $user_type ) );
|
1127 |
-
|
1128 |
-
$abandoned_cart_id = $wpdb->insert_id;
|
1129 |
-
$_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
|
1130 |
-
} elseif ( isset( $results[0]->abandoned_cart_time ) && $compare_time > $results[0]->abandoned_cart_time ) {
|
1131 |
-
$updated_cart_info = json_encode( get_user_meta( $user_id, '_woocommerce_persistent_cart', true ) );
|
1132 |
-
|
1133 |
-
if ( ! $this->wcal_compare_carts( $user_id, $results[0]->abandoned_cart_info ) ) {
|
1134 |
-
$updated_cart_ignored = 1;
|
1135 |
-
$query_ignored = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1136 |
-
SET cart_ignored = %s
|
1137 |
-
WHERE user_id = %d ";
|
1138 |
-
$wpdb->query( $wpdb->prepare( $query_ignored, $updated_cart_ignored, $user_id ) );
|
1139 |
-
|
1140 |
-
$user_type = "REGISTERED";
|
1141 |
-
$query_update = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1142 |
-
(user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type)
|
1143 |
-
VALUES (%d, %s, %d, %s, %s)";
|
1144 |
-
$wpdb->query( $wpdb->prepare( $query_update, $user_id, $updated_cart_info, $current_time, $cart_ignored, $user_type ) );
|
1145 |
-
|
1146 |
-
update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "yes" ) );
|
1147 |
-
|
1148 |
-
$abandoned_cart_id = $wpdb->insert_id;
|
1149 |
-
$_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
|
1150 |
-
} else {
|
1151 |
-
update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "no" ) );
|
1152 |
-
}
|
1153 |
-
} else {
|
1154 |
-
$updated_cart_info = json_encode( get_user_meta( $user_id, '_woocommerce_persistent_cart', true ) );
|
1155 |
-
|
1156 |
-
$query_update = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1157 |
-
SET abandoned_cart_info = %s,
|
1158 |
-
abandoned_cart_time = %d
|
1159 |
-
WHERE user_id = %d
|
1160 |
-
AND cart_ignored = %s ";
|
1161 |
-
$wpdb->query( $wpdb->prepare( $query_update, $updated_cart_info, $current_time, $user_id, $cart_ignored ) );
|
1162 |
-
|
1163 |
-
$query_update = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE user_id ='" . $user_id . "' AND cart_ignored='0' ";
|
1164 |
-
$get_abandoned_record = $wpdb->get_results( $query_update );
|
1165 |
-
$abandoned_cart_id = $get_abandoned_record[0]->id;
|
1166 |
-
|
1167 |
-
$_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
|
1168 |
-
}
|
1169 |
-
} else {
|
1170 |
-
//start here guest user
|
1171 |
-
if ( isset( $_SESSION['user_id'] ) ) {
|
1172 |
-
$user_id = $_SESSION['user_id'];
|
1173 |
-
} else {
|
1174 |
-
$user_id = "";
|
1175 |
-
}
|
1176 |
-
|
1177 |
-
$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'";
|
1178 |
-
$results = $wpdb->get_results( $wpdb->prepare( $query, $user_id ) );
|
1179 |
-
$cart = array();
|
1180 |
-
$get_cookie = WC()->session->get_session_cookie();
|
1181 |
-
if ( function_exists('WC') ) {
|
1182 |
$cart['cart'] = WC()->session->cart;
|
1183 |
} else {
|
1184 |
$cart['cart'] = $woocommerce->session->cart;
|
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 |
* @Since: 3.5
|
1216 |
* Here we capture the guest cart from the cart page.
|
@@ -1249,16 +1261,16 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
1249 |
}
|
1250 |
}
|
1251 |
}
|
1252 |
-
}
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
// Decrypt Function
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
|
1263 |
function wcal_email_unsubscribe( $args ) {
|
1264 |
global $wpdb;
|
@@ -1320,315 +1332,318 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
1320 |
return $args;
|
1321 |
}
|
1322 |
}
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
$validate_server_string = rawurldecode( $_GET ['validate'] );
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
$link_decode = base64_decode( $validate_encoded_string );
|
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 |
WHERE id = '".$get_abandoned_id_of_order."' ";
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
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 |
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
1633 |
|
1634 |
$email_id = $order->get_billing_email();
|
@@ -1640,7 +1655,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
1640 |
|
1641 |
if ( $results_id ) {
|
1642 |
$record_status = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1643 |
-
|
1644 |
$results_status = $wpdb->get_results( $wpdb->prepare( $record_status, $results_id[0]->id ) );
|
1645 |
|
1646 |
if ( $results_status ) {
|
@@ -1648,13 +1663,13 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
1648 |
get_user_meta( $results_id[0]->id, '_woocommerce_ac_modified_cart', true ) == md5("no") ) {
|
1649 |
|
1650 |
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
$query_order = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1656 |
-
|
1657 |
-
|
1658 |
$wpdb->query( $query_order );
|
1659 |
delete_user_meta( $results_id[0]->id, '_woocommerce_ac_modified_cart' );
|
1660 |
delete_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
|
@@ -1668,221 +1683,221 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
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 |
-
|
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 |
wp_enqueue_script(
|
1755 |
'jquery-ui-min',
|
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 |
if ( isset( $_GET['action'] ) ) {
|
1844 |
$action = $_GET['action'];
|
1845 |
} else {
|
1846 |
$action = "";
|
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 |
if ( isset( $_GET['wcal_deleted'] ) && 'YES' == $_GET['wcal_deleted'] ) { ?>
|
1887 |
<div id="message" class="updated fade">
|
1888 |
<p><strong><?php _e( 'The Abandoned cart has been successfully deleted.', 'woocommerce-ac' ); ?></strong></p>
|
@@ -1893,10 +1908,10 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
1893 |
<p><strong><?php _e( 'The Template has been successfully deleted.', 'woocommerce-ac' ); ?></strong></p>
|
1894 |
</div>
|
1895 |
<?php }
|
1896 |
-
|
1897 |
-
|
1898 |
?>
|
1899 |
-
|
1900 |
<div id="content">
|
1901 |
<?php
|
1902 |
$wcal_general_settings_class = $wcal_email_setting = "";
|
@@ -1926,11 +1941,11 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
1926 |
<?php
|
1927 |
if ( $section == 'wcal_general_settings' || $section == '' ) {
|
1928 |
?>
|
1929 |
-
|
1930 |
<?php settings_fields( 'woocommerce_ac_settings' ); ?>
|
1931 |
<?php do_settings_sections( 'woocommerce_ac_page' ); ?>
|
1932 |
-
|
1933 |
-
|
1934 |
</form>
|
1935 |
<?php
|
1936 |
} else if ( $section == 'wcal_email_settings' ) {
|
@@ -1944,17 +1959,17 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
1944 |
}
|
1945 |
?>
|
1946 |
</div>
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
|
1957 |
-
|
1958 |
if ( $get_registered_user_ac_count > 1){
|
1959 |
$wcal_user_reg_text = 'Users';
|
1960 |
}
|
@@ -2025,301 +2040,309 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
2025 |
</form>
|
2026 |
</div>
|
2027 |
<?php
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
AND frequency = %d
|
2045 |
AND day_or_hour = %s ";
|
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 |
AND day_or_hour = %s ";
|
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 |
SET
|
2293 |
is_active = '" . $active . "'
|
2294 |
WHERE id = '" . $template_id . "' ";
|
2295 |
-
|
2296 |
-
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
2301 |
-
|
2302 |
-
|
2303 |
-
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
|
2308 |
-
|
2309 |
-
|
2310 |
-
|
2311 |
-
|
2312 |
-
|
2313 |
-
|
2314 |
-
|
2315 |
-
|
2316 |
-
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
|
2321 |
-
|
2322 |
-
|
2323 |
include_once('includes/classes/class-wcal-templates-table.php');
|
2324 |
$wcal_template_list = new WCAL_Templates_Table();
|
2325 |
$wcal_template_list->wcal_templates_prepare_items();
|
@@ -2333,111 +2356,111 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
2333 |
</div>
|
2334 |
</div>
|
2335 |
<?php
|
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 |
include_once('includes/classes/class-wcal-recover-orders-table.php');
|
2442 |
$wcal_recover_orders_list = new WCAL_Recover_Orders_Table();
|
2443 |
$wcal_recover_orders_list->wcal_recovered_orders_prepare_items();
|
@@ -2501,8 +2524,8 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
2501 |
</form>
|
2502 |
</div>
|
2503 |
<?php
|
2504 |
-
|
2505 |
-
|
2506 |
$ac_order_id = $_GET['id'];
|
2507 |
?>
|
2508 |
<p> </p>
|
@@ -2684,15 +2707,15 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
2684 |
$name = $variation->get_formatted_name() ;
|
2685 |
$explode_all = explode ( "–", $name );
|
2686 |
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
2687 |
-
|
2688 |
-
|
2689 |
-
|
2690 |
-
|
2691 |
-
|
2692 |
-
|
2693 |
-
|
2694 |
}else{
|
2695 |
-
|
2696 |
}
|
2697 |
$product_name_with_variable = '';
|
2698 |
$explode_many_varaition = array();
|
@@ -2799,118 +2822,118 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
2799 |
$wcal_product_report_list = new WCAL_Product_Report_Table();
|
2800 |
$wcal_product_report_list->wcal_product_report_prepare_items();
|
2801 |
?>
|
2802 |
-
|
2803 |
-
|
2804 |
-
|
2805 |
-
|
2806 |
<?php $wcal_product_report_list->display(); ?>
|
2807 |
</form>
|
2808 |
</div>
|
2809 |
<?php }
|
2810 |
}
|
2811 |
echo( "</table>" );
|
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 |
-
|
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 |
<th>
|
2915 |
<label for="is_wc_template"><b><?php _e( 'Use WooCommerce Template Style:', 'woocommerce-ac' ); ?></b></label>
|
2916 |
</th>
|
@@ -2980,117 +3003,117 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
2980 |
</td>
|
2981 |
</tr>
|
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 |
-
|
3010 |
-
|
3011 |
-
|
3012 |
-
|
3013 |
-
|
3014 |
-
|
3015 |
-
|
3016 |
-
|
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 |
} else {
|
3088 |
$footer_text = __( 'Thank you for selling with Abandoned Cart Lite for WooCommerce.', 'woocommerce-ac' );
|
3089 |
}
|
3090 |
-
|
3091 |
-
|
3092 |
-
|
3093 |
-
|
3094 |
function bubble_sort_function( $unsort_array, $order ) {
|
3095 |
$temp = array();
|
3096 |
foreach ( $unsort_array as $key => $value )
|
@@ -3105,81 +3128,81 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
3105 |
unset( $temp );
|
3106 |
return $array;
|
3107 |
}
|
3108 |
-
|
3109 |
-
|
3110 |
-
|
3111 |
-
|
3112 |
-
|
3113 |
-
|
3114 |
-
|
3115 |
-
|
3116 |
-
|
3117 |
-
|
3118 |
email_body = tinyMCE.get('woocommerce_ac_email_body').getContent();
|
3119 |
} else {
|
3120 |
email_body = jQuery('#woocommerce_ac_email_body').val();
|
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 |
-
$time_format
|
3172 |
-
|
3173 |
-
|
3174 |
-
|
3175 |
-
|
3176 |
-
|
3177 |
-
|
3178 |
-
|
3179 |
-
|
3180 |
-
|
3181 |
-
|
3182 |
-
|
3183 |
<tr align="center">
|
3184 |
<th>'.__( "Item", "woocommerce-ac" ).'</th>
|
3185 |
<th>'.__( "Name", "woocommerce-ac" ).'</th>
|
@@ -3187,7 +3210,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
3187 |
<th>'.__( "Price", "woocommerce-ac" ).'</th>
|
3188 |
<th>'.__( "Line Subtotal", "woocommerce-ac" ).'</th>
|
3189 |
</tr>
|
3190 |
-
|
3191 |
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/shoes.jpg"/></td>
|
3192 |
<td>'.__( "Men\'\s Formal Shoes", "woocommerce-ac" ).'</td>
|
3193 |
<td>1</td>
|
@@ -3209,11 +3232,11 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
3209 |
<td>$200</td>
|
3210 |
</tr>
|
3211 |
</table>';
|
3212 |
-
|
3213 |
-
|
3214 |
-
|
3215 |
-
|
3216 |
-
|
3217 |
<table border="0" cellpadding="10" cellspacing="0" class="templateDataTable">
|
3218 |
<tr align="center">
|
3219 |
<th>'.__( "Item", "woocommerce-ac" ).'</th>
|
@@ -3222,7 +3245,7 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
3222 |
<th>'.__( "Price", "woocommerce-ac" ).'</th>
|
3223 |
<th>'.__( "Line Subtotal", "woocommerce-ac" ).'</th>
|
3224 |
</tr>
|
3225 |
-
|
3226 |
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/shoes.jpg"/></td>
|
3227 |
<td>'.__( "Men\'\s Formal Shoes", "woocommerce-ac" ).'</td>
|
3228 |
<td>1</td>
|
@@ -3244,41 +3267,41 @@ if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
|
3244 |
<td>$200</td>
|
3245 |
</tr>
|
3246 |
</table>';
|
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 |
-
|
3277 |
-
|
3278 |
-
|
3279 |
-
|
3280 |
-
}
|
3281 |
-
}
|
3282 |
-
}
|
3283 |
$woocommerce_abandon_cart = new woocommerce_abandon_cart_lite();
|
3284 |
?>
|
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.0
|
7 |
Author: Tyche Softwares
|
8 |
Author URI: http://www.tychesoftwares.com/
|
9 |
Text Domain: woocommerce-ac
|
20 |
require_once( "includes/classes/class-wcal-aes-counter.php" );
|
21 |
require_once( "includes/wcal-common.php" );
|
22 |
require_once( "includes/wcal_ts_tracking.php");
|
23 |
+
require_once( "includes/wcal_admin_notice.php");
|
24 |
|
25 |
// Add a new interval of 15 minutes
|
26 |
add_filter( 'cron_schedules', 'wcal_add_cron_schedule' );
|
27 |
|
28 |
+
function wcal_add_cron_schedule( $schedules ) {
|
29 |
$schedules['15_minutes_lite'] = array(
|
30 |
'interval' => 900, // 15 minutes in seconds
|
31 |
'display' => __( 'Once Every Fifteen Minutes' ),
|
62 |
require_once( $plugin_dir_path . 'cron/wcal_send_email.php' );
|
63 |
}
|
64 |
|
65 |
+
function woocommerce_ac_delete_lite() {
|
66 |
+
global $wpdb;
|
67 |
+
if ( ! is_multisite() ) {
|
68 |
+
$table_name_ac_abandoned_cart_history = $wpdb->prefix . "ac_abandoned_cart_history_lite";
|
69 |
+
$sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_abandoned_cart_history ;
|
70 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
71 |
+
$wpdb->get_results( $sql_ac_abandoned_cart_history );
|
72 |
|
73 |
+
$table_name_ac_email_templates = $wpdb->prefix . "ac_email_templates_lite";
|
74 |
+
$sql_ac_email_templates = "DROP TABLE " . $table_name_ac_email_templates ;
|
75 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
76 |
+
$wpdb->get_results( $sql_ac_email_templates );
|
77 |
|
78 |
+
$table_name_ac_sent_history = $wpdb->prefix . "ac_sent_history_lite";
|
79 |
+
$sql_ac_sent_history = "DROP TABLE " . $table_name_ac_sent_history ;
|
80 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
81 |
+
$wpdb->get_results( $sql_ac_sent_history );
|
82 |
+
|
83 |
+
$table_name_ac_guest_abandoned_cart_history = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
|
84 |
+
$sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_guest_abandoned_cart_history ;
|
85 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
86 |
+
$wpdb->get_results( $sql_ac_abandoned_cart_history );
|
87 |
+
|
88 |
+
$sql_table_user_meta_cart = "DELETE FROM `" . $wpdb->prefix . "usermeta` WHERE meta_key = '_woocommerce_persistent_cart'";
|
89 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
90 |
+
$wpdb->get_results( $sql_table_user_meta_cart );
|
91 |
+
|
92 |
+
$sql_table_user_meta_cart_modified = "DELETE FROM `" . $wpdb->prefix . "usermeta` WHERE meta_key = '_woocommerce_ac_modified_cart'";
|
93 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
94 |
+
$wpdb->get_results( $sql_table_user_meta_cart_modified );
|
95 |
+
} else {
|
96 |
+
$query = "SELECT blog_id FROM `".$wpdb->prefix."blogs`";
|
97 |
+
$results = $wpdb->get_results( $query );
|
98 |
+
|
99 |
+
foreach( $results as $key => $value ) {
|
100 |
+
$table_name_ac_abandoned_cart_history = $wpdb->prefix .$value->blog_id."_"."ac_abandoned_cart_history_lite";
|
101 |
+
$sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_abandoned_cart_history ;
|
102 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
103 |
+
$wpdb->get_results( $sql_ac_abandoned_cart_history );
|
104 |
+
|
105 |
+
$table_name_ac_email_templates = $wpdb->prefix .$value->blog_id."_"."ac_email_templates_lite";
|
106 |
+
$sql_ac_email_templates = "DROP TABLE " . $table_name_ac_email_templates ;
|
107 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
108 |
+
$wpdb->get_results( $sql_ac_email_templates );
|
109 |
+
|
110 |
+
$table_name_ac_sent_history = $wpdb->prefix .$value->blog_id."_"."ac_sent_history_lite";
|
111 |
+
$sql_ac_sent_history = "DROP TABLE " . $table_name_ac_sent_history ;
|
112 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
113 |
+
$wpdb->get_results( $sql_ac_sent_history );
|
114 |
+
|
115 |
+
$table_name_ac_guest_abandoned_cart_history = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
|
116 |
+
$sql_ac_abandoned_cart_history = "DROP TABLE " . $table_name_ac_guest_abandoned_cart_history ;
|
117 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
118 |
+
$wpdb->get_results( $sql_ac_abandoned_cart_history );
|
119 |
+
|
120 |
+
$sql_table_user_meta_cart = "DELETE FROM `" . $wpdb->prefix.$value->blog_id."_"."usermeta` WHERE meta_key = '_woocommerce_persistent_cart'";
|
121 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
122 |
+
$wpdb->get_results( $sql_table_user_meta_cart );
|
123 |
+
|
124 |
+
$sql_table_user_meta_cart_modified = "DELETE FROM `" . $wpdb->prefix.$value->blog_id."_"."usermeta` WHERE meta_key = '_woocommerce_ac_modified_cart'";
|
125 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
126 |
+
$wpdb->get_results( $sql_table_user_meta_cart_modified );
|
127 |
+
}
|
128 |
+
}
|
129 |
+
delete_option( 'woocommerce_ac_email_body' );
|
130 |
+
delete_option( 'ac_lite_cart_abandoned_time' );
|
131 |
+
delete_option( 'ac_lite_email_admin_on_recovery' );
|
132 |
+
delete_option( 'ac_lite_settings_status' );
|
133 |
+
delete_option( 'woocommerce_ac_default_templates_installed' );
|
134 |
+
delete_option( 'wcal_security_key' );
|
135 |
+
delete_option( 'ac_lite_track_guest_cart_from_cart_page' );
|
136 |
+
delete_option( 'wcal_from_name' );
|
137 |
+
delete_option( 'wcal_from_email' );
|
138 |
+
delete_option( 'wcal_reply_email' );
|
139 |
}
|
140 |
+
/**
|
141 |
+
* woocommerce_abandon_cart_lite class
|
142 |
+
**/
|
143 |
if( !class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
144 |
+
|
145 |
+
class woocommerce_abandon_cart_lite {
|
146 |
+
var $one_hour;
|
147 |
+
var $three_hours;
|
148 |
+
var $six_hours;
|
149 |
+
var $twelve_hours;
|
150 |
+
var $one_day;
|
151 |
+
var $one_week;
|
152 |
+
var $duration_range_select = array();
|
153 |
+
var $start_end_dates = array();
|
154 |
+
|
155 |
+
public function __construct() {
|
156 |
+
$this->one_hour = 60 * 60;
|
157 |
+
$this->three_hours = 3 * $this->one_hour;
|
158 |
+
$this->six_hours = 6 * $this->one_hour;
|
159 |
+
$this->twelve_hours = 12 * $this->one_hour;
|
160 |
+
$this->one_day = 24 * $this->one_hour;
|
161 |
+
$this->one_week = 7 * $this->one_day;
|
162 |
+
$this->duration_range_select = array( 'yesterday' => 'Yesterday',
|
163 |
+
'today' => 'Today',
|
164 |
+
'last_seven' => 'Last 7 days',
|
165 |
+
'last_fifteen' => 'Last 15 days',
|
166 |
+
'last_thirty' => 'Last 30 days',
|
167 |
+
'last_ninety' => 'Last 90 days',
|
168 |
+
'last_year_days' => 'Last 365'
|
169 |
+
);
|
170 |
+
|
171 |
$this->start_end_dates = array( 'yesterday' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 24*60*60 ) ),
|
172 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) - 7*24*60*60 ) ) ),
|
173 |
+
'today' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ),
|
174 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
175 |
+
'last_seven' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 7*24*60*60 ) ),
|
176 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
177 |
+
'last_fifteen' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 15*24*60*60 ) ),
|
178 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
179 |
+
'last_thirty' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 30*24*60*60 ) ),
|
180 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
181 |
+
'last_ninety' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 90*24*60*60 ) ),
|
182 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
183 |
+
'last_year_days' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 365*24*60*60 ) ),
|
184 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) )
|
185 |
);
|
186 |
+
|
187 |
+
// Initialize settings
|
188 |
+
register_activation_hook ( __FILE__, array( &$this, 'wcal_activate' ) );
|
189 |
+
|
190 |
+
// WordPress Administration Menu
|
191 |
+
add_action ( 'admin_menu', array( &$this, 'wcal_admin_menu' ) );
|
192 |
+
|
193 |
+
// Actions to be done on cart update
|
194 |
+
add_action ( 'woocommerce_cart_updated', array( &$this, 'wcal_store_cart_timestamp' ) );
|
195 |
+
|
196 |
+
// delete added temp fields after order is placed
|
197 |
+
add_filter ( 'woocommerce_order_details_after_order_table', array( &$this, 'wcal_action_after_delivery_session' ) );
|
198 |
+
|
199 |
+
add_action ( 'admin_init', array( &$this, 'wcal_action_admin_init' ) );
|
200 |
+
|
201 |
+
// Update the options as per settings API
|
202 |
+
add_action ( 'admin_init', array( &$this, 'wcal_update_db_check' ) );
|
203 |
|
204 |
+
// Wordpress settings API
|
205 |
+
add_action( 'admin_init', array( &$this, 'wcal_initialize_plugin_options' ) );
|
206 |
+
|
207 |
+
// Language Translation
|
208 |
+
add_action ( 'init', array( &$this, 'wcal_update_po_file' ) );
|
209 |
+
|
210 |
+
// track links
|
211 |
+
add_filter( 'template_include', array( &$this, 'wcal_email_track_links' ), 99, 1 );
|
212 |
+
|
213 |
+
//It will used to unsubcribe the emails.
|
214 |
+
add_action( 'template_include', array( &$this, 'wcal_email_unsubscribe'),99, 1 );
|
215 |
+
|
216 |
+
add_action ( 'admin_enqueue_scripts', array( &$this, 'wcal_enqueue_scripts_js' ) );
|
217 |
+
add_action ( 'admin_enqueue_scripts', array( &$this, 'wcal_enqueue_scripts_css' ) );
|
218 |
+
|
219 |
+
if ( is_admin() ) {
|
220 |
+
// Load "admin-only" scripts here
|
221 |
+
add_action ( 'admin_head', array( &$this, 'wcal_action_send_preview' ) );
|
222 |
+
add_action ( 'wp_ajax_wcal_preview_email_sent', array( &$this, 'wcal_preview_email_sent' ) );
|
223 |
+
}
|
224 |
+
|
225 |
+
// Send Email on order recovery
|
226 |
+
add_action( 'woocommerce_order_status_pending_to_processing_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
227 |
+
add_action( 'woocommerce_order_status_pending_to_completed_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
228 |
+
add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
229 |
+
add_action( 'woocommerce_order_status_failed_to_processing_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
230 |
+
add_action( 'woocommerce_order_status_failed_to_completed_notification', array( &$this, 'wcal_email_admin_recovery' ) );
|
231 |
+
|
232 |
+
add_action('woocommerce_order_status_changed', array( &$this, 'wcal_email_admin_recovery_for_paypal' ), 10, 3);
|
233 |
+
|
234 |
+
add_action( 'admin_init', array( $this, 'wcal_preview_emails' ) );
|
235 |
+
add_action( 'init', array( $this, 'wcal_app_output_buffer') );
|
236 |
+
add_action( 'admin_init', array( &$this, 'wcal_check_pro_activated' ) );
|
237 |
+
add_action( 'woocommerce_checkout_order_processed', array( &$this, 'wcal_order_placed' ), 10 , 1 );
|
238 |
+
add_filter( 'woocommerce_payment_complete_order_status', array( &$this , 'wcal_order_complete_action' ), 10 , 2 );
|
239 |
+
add_filter( 'admin_footer_text', array( $this, 'wcal_admin_footer_text' ), 1 );
|
240 |
+
|
241 |
+
add_action( 'admin_notices', array( 'Wcal_Admin_Notice', 'wcal_pro_notice' ) );
|
242 |
+
add_action( 'admin_init', array( 'Wcal_Admin_Notice', 'wcal_pro_notice_ignore' ) );
|
243 |
+
}
|
244 |
+
|
245 |
+
public static function wcal_order_placed( $order_id ) {
|
246 |
+
if( session_id() === '' ) {
|
247 |
+
//session has not started
|
248 |
+
session_start();
|
249 |
+
}
|
250 |
+
|
251 |
+
if ( isset( $_SESSION['email_sent_id'] ) && $_SESSION['email_sent_id'] !='' ) {
|
252 |
+
global $woocommerce, $wpdb;
|
253 |
+
$email_sent_id = $_SESSION['email_sent_id'];
|
254 |
+
$get_ac_id_query = "SELECT abandoned_order_id FROM `" . $wpdb->prefix."ac_sent_history_lite` WHERE id = %d";
|
255 |
+
$get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query, $email_sent_id ) );
|
256 |
+
$abandoned_order_id = $get_ac_id_results[0]->abandoned_order_id;
|
257 |
+
|
258 |
+
update_post_meta( $order_id , 'wcal_recover_order_placed', $abandoned_order_id );
|
259 |
+
update_post_meta( $order_id , 'wcal_recover_order_placed_sent_id', $email_sent_id );
|
260 |
+
} else if ( isset( $_SESSION['abandoned_cart_id_lite'] ) && $_SESSION['abandoned_cart_id_lite'] != '' &&
|
261 |
+
isset( $_POST['account_password'] ) && $_POST['account_password'] != '' ) {
|
262 |
+
|
263 |
+
global $woocommerce, $wpdb;
|
264 |
+
$results_sent = array();
|
265 |
+
$abandoned_cart_id_new_user = $_SESSION['abandoned_cart_id_lite'];
|
266 |
+
$wcap_user_id_of_guest = $_SESSION['user_id'];
|
267 |
+
/* delete the guest record. As it become the logged in user */
|
268 |
+
$table_name = $wpdb->prefix . 'ac_abandoned_cart_history_lite';
|
269 |
+
$wpdb->delete( $table_name , array( 'user_id' => $wcap_user_id_of_guest ) );
|
270 |
+
|
271 |
+
$table_name = $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite';
|
272 |
+
$wpdb->delete( $table_name , array( 'id' => $wcap_user_id_of_guest ) );
|
273 |
+
|
274 |
+
/* Check if for the logged in user we have sent any abandoned cart reminder email */
|
275 |
+
$get_email_sent_for_abandoned_id = "SELECT * FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE abandoned_order_id = %d ";
|
276 |
+
$results_sent = $wpdb->get_results( $wpdb->prepare( $get_email_sent_for_abandoned_id, $abandoned_cart_id_new_user ) );
|
277 |
+
|
278 |
+
if ( empty( $results_sent ) && count( $results_sent ) == 0 ) {
|
279 |
+
|
280 |
+
/*
|
281 |
+
* If logged in user place the order once it is displyed under the abandoned orders tab.
|
282 |
+
* But the email has been not sent to the user. And order is placed successfuly
|
283 |
+
* Then We are deleteing those order. But for those orders Recovered email has been set to the Admin.
|
284 |
+
* Below code ensure that admin recovery email wil not be sent for tose orders.
|
285 |
+
*/
|
286 |
+
$get_user_id_of_abandoned_cart = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history` WHERE id = %d ";
|
287 |
+
$get_results_of_user_id = $wpdb->get_results ( $wpdb->prepare( $get_user_id_of_abandoned_cart, $abandoned_cart_id_new_user ) );
|
288 |
+
$user_id = $get_results_of_user_id[0]->user_id;
|
289 |
+
|
290 |
+
delete_user_meta( $user_id, '_woocommerce_ac_modified_cart' );
|
291 |
+
/*
|
292 |
+
* It will delete the order from history table if the order is placed before any email sent to the user.
|
293 |
+
*
|
294 |
+
*/
|
295 |
+
$table_name = $wpdb->prefix . 'ac_abandoned_cart_history_lite';
|
296 |
+
$wpdb->delete( $table_name , array( 'id' => $abandoned_cart_id_new_user ) );
|
297 |
+
} else {
|
298 |
+
$email_sent_id = $results_sent[0]->id;
|
299 |
+
update_post_meta( $order_id , 'wcal_recover_order_placed', $abandoned_cart_id_new_user );
|
300 |
+
update_post_meta( $order_id , 'wcal_recover_order_placed_sent_id', $email_sent_id );
|
301 |
+
}
|
302 |
+
} else if ( isset( $_SESSION['abandoned_cart_id_lite'] ) && $_SESSION['abandoned_cart_id_lite'] !='' ) {
|
303 |
+
global $woocommerce, $wpdb;
|
304 |
+
$results_sent = array();
|
305 |
+
$abandoned_cart_id = $_SESSION['abandoned_cart_id_lite'];
|
306 |
+
$get_email_sent_for_abandoned_id = "SELECT * FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE abandoned_order_id = %d ";
|
307 |
+
$results_sent = $wpdb->get_results ( $wpdb->prepare( $get_email_sent_for_abandoned_id, $abandoned_cart_id ) );
|
308 |
+
if ( empty( $results_sent ) && count( $results_sent ) == 0 ) {
|
309 |
+
/*
|
310 |
+
* If logeged in user place the order once it isdisplyed under the abandoned orders tab.
|
311 |
+
* But the email has been not sent to the user. And order is placed successfuly
|
312 |
+
* Then We are deleteing those order. But for those orders Recovered email has been set to the Admin.
|
313 |
+
* Below code ensure that admin recovery email will not be sent for those orders.
|
314 |
+
*/
|
315 |
+
$get_user_id_of_abandoned_cart = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE id = %d ";
|
316 |
+
$get_results_of_user_id = $wpdb->get_results ( $wpdb->prepare( $get_user_id_of_abandoned_cart, $abandoned_cart_id ) );
|
317 |
+
$user_id = $get_results_of_user_id[0]->user_id;
|
318 |
+
delete_user_meta( $user_id, '_woocommerce_ac_modified_cart' );
|
319 |
+
/*
|
320 |
+
* It will delete the order from history table if the order is placed before any email sent to the user.
|
321 |
+
*
|
322 |
+
*/
|
323 |
+
$table_name = $wpdb->prefix . 'ac_abandoned_cart_history_lite';
|
324 |
+
$wpdb->delete( $table_name , array( 'id' => $abandoned_cart_id ) );
|
325 |
+
} else {
|
326 |
+
$email_sent_id = $results_sent[0]->id;
|
327 |
+
update_post_meta( $order_id , 'wcal_recover_order_placed', $abandoned_cart_id );
|
328 |
+
update_post_meta( $order_id , 'wcal_recover_order_placed_sent_id', $email_sent_id );
|
329 |
+
}
|
330 |
+
}
|
331 |
+
}
|
332 |
+
|
333 |
+
public function wcal_order_complete_action( $order_status, $order_id ) {
|
334 |
+
if ( 'failed' != $order_status ) {
|
335 |
+
global $woocommerce, $wpdb;
|
336 |
+
$order = new WC_Order( $order_id );
|
337 |
+
$get_abandoned_id_of_order = '';
|
338 |
+
$get_sent_email_id_of_order = '';
|
339 |
+
$get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
|
340 |
+
|
341 |
+
if ( isset( $get_abandoned_id_of_order ) && $get_abandoned_id_of_order != '' ){
|
342 |
+
$get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
|
343 |
+
$get_sent_email_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed_sent_id', true );
|
344 |
+
|
345 |
+
$query_order = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET recovered_cart= '" . $order_id . "', cart_ignored = '1'
|
346 |
WHERE id = '".$get_abandoned_id_of_order."' ";
|
347 |
+
$wpdb->query( $query_order );
|
348 |
+
|
349 |
+
$order->add_order_note( __( 'This order was abandoned & subsequently recovered.', 'woocommerce-ac' ) );
|
350 |
+
|
351 |
+
delete_post_meta( $order_id, 'wcal_recover_order_placed', $get_abandoned_id_of_order );
|
352 |
+
delete_post_meta( $order_id, 'wcal_recover_order_placed_sent_id', $get_sent_email_id_of_order );
|
353 |
+
delete_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
|
354 |
+
}
|
355 |
+
}
|
356 |
+
return $order_status;
|
357 |
+
}
|
358 |
+
|
359 |
+
/**
|
360 |
+
* Check If Pro is activated along with Lite version.
|
361 |
+
*/
|
362 |
+
public static function wcal_check_pro_activated() {
|
363 |
+
if( is_plugin_active( 'woocommerce-abandon-cart-pro/woocommerce-ac.php' ) && class_exists( 'woocommerce_abandon_cart' ) ) {
|
364 |
+
add_action( 'admin_notices', array( 'woocommerce_abandon_cart_lite', 'wcal_check_pro_notice' ) );
|
365 |
+
}
|
366 |
+
}
|
367 |
+
|
368 |
+
/**
|
369 |
+
* Display a notice in the admin Plugins page if the LITE version is
|
370 |
+
* activated with PRO version is activated.
|
371 |
+
*/
|
372 |
+
public static function wcal_check_pro_notice() {
|
373 |
+
$class = 'notice notice-error is-dismissible';
|
374 |
+
$message = __( 'The Lite & Pro version of Abandoned Cart plugin for WooCommerce (from Tyche Softwares) are active on your website. <br> In this case, the abandoned carts will be captured in both plugins & email reminders will also be sent from both plugins. <br> It is recommended that you deactivate the Lite version & keep the Pro version active.', 'woocommerce-ac' );
|
375 |
+
printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
|
376 |
+
}
|
377 |
+
|
378 |
+
/*-----------------------------------------------------------------------------------*/
|
379 |
+
/* Class Functions */
|
380 |
+
/*-----------------------------------------------------------------------------------*/
|
381 |
+
/**
|
382 |
+
* Preview email template
|
383 |
+
*
|
384 |
+
* @return string
|
385 |
+
*/
|
386 |
+
public function wcal_preview_emails() {
|
387 |
+
global $woocommerce;
|
388 |
+
if( isset( $_GET['wcal_preview_woocommerce_mail'] ) ) {
|
389 |
+
if( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-ac') ) {
|
390 |
+
die( 'Security check' );
|
391 |
+
}
|
392 |
+
$message = '';
|
393 |
+
// create a new email
|
394 |
+
if( $woocommerce->version < '2.3' ) {
|
395 |
+
global $email_heading;
|
396 |
+
ob_start();
|
397 |
+
|
398 |
+
include( 'views/wcal-wc-email-template-preview.php' );
|
399 |
+
$mailer = WC()->mailer();
|
400 |
+
$message = ob_get_clean();
|
401 |
+
$email_heading = __( 'HTML Email Template', 'woocommerce' );
|
402 |
+
$message = $mailer->wrap_message( $email_heading, $message );
|
403 |
+
} else {
|
404 |
+
// load the mailer class
|
405 |
+
$mailer = WC()->mailer();
|
406 |
+
// get the preview email subject
|
407 |
+
$email_heading = __( 'Abandoned cart Email Template', 'woocommerce-ac' );
|
408 |
+
// get the preview email content
|
409 |
+
ob_start();
|
410 |
+
include( 'views/wcal-wc-email-template-preview.php' );
|
411 |
+
$message = ob_get_clean();
|
412 |
+
// create a new email
|
413 |
+
$email = new WC_Email();
|
414 |
+
// wrap the content with the email template and then add styles
|
415 |
+
$message = $email->style_inline( $mailer->wrap_message( $email_heading, $message ) );
|
416 |
+
}
|
417 |
+
echo $message;
|
418 |
+
exit;
|
419 |
+
}
|
420 |
+
|
421 |
+
if ( isset( $_GET['wcal_preview_mail'] ) ) {
|
422 |
+
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-ac') ) {
|
423 |
+
die( 'Security check' );
|
424 |
+
}
|
425 |
+
// get the preview email content
|
426 |
+
ob_start();
|
427 |
+
include( 'views/wcal-email-template-preview.php' );
|
428 |
+
$message = ob_get_clean();
|
429 |
+
// print the preview email
|
430 |
+
echo $message;
|
431 |
+
exit;
|
432 |
+
}
|
433 |
+
}
|
434 |
+
// Language Translation
|
435 |
+
function wcal_update_po_file() {
|
436 |
+
$domain = 'woocommerce-ac';
|
437 |
+
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
|
438 |
+
if ( $loaded = load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '-' . $locale . '.mo' ) ) {
|
439 |
+
return $loaded;
|
440 |
+
} else {
|
441 |
+
load_plugin_textdomain( $domain, FALSE, basename( dirname( __FILE__ ) ) . '/i18n/languages/' );
|
442 |
+
}
|
443 |
+
}
|
444 |
+
|
445 |
+
/*-----------------------------------------------------------------------------------*/
|
446 |
+
/* Class Functions */
|
447 |
+
/*-----------------------------------------------------------------------------------*/
|
448 |
+
function wcal_activate() {
|
449 |
+
global $wpdb;
|
450 |
+
$wcap_collate = '';
|
451 |
+
if ( $wpdb->has_cap( 'collation' ) ) {
|
452 |
+
$wcap_collate = $wpdb->get_charset_collate();
|
453 |
+
}
|
454 |
+
$table_name = $wpdb->prefix . "ac_email_templates_lite";
|
455 |
+
$sql = "CREATE TABLE IF NOT EXISTS $table_name (
|
456 |
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
457 |
+
`subject` text COLLATE utf8_unicode_ci NOT NULL,
|
458 |
+
`body` mediumtext COLLATE utf8_unicode_ci NOT NULL,
|
459 |
+
`is_active` enum('0','1') COLLATE utf8_unicode_ci NOT NULL,
|
460 |
+
`frequency` int(11) NOT NULL,
|
461 |
+
`day_or_hour` enum('Days','Hours') COLLATE utf8_unicode_ci NOT NULL,
|
462 |
+
`template_name` text COLLATE utf8_unicode_ci NOT NULL,
|
463 |
+
PRIMARY KEY (`id`)
|
464 |
+
) $wcap_collate AUTO_INCREMENT=1 ";
|
465 |
+
|
466 |
+
require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
467 |
+
dbDelta( $sql );
|
468 |
+
|
469 |
+
$table_name = $wpdb->prefix . "ac_email_templates_lite";
|
470 |
+
$check_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'is_wc_template' ";
|
471 |
+
$results = $wpdb->get_results( $check_template_table_query );
|
472 |
+
|
473 |
+
if ( count( $results ) == 0 ) {
|
474 |
+
$alter_template_table_query = "ALTER TABLE $table_name
|
475 |
+
ADD COLUMN `is_wc_template` enum('0','1') COLLATE utf8_unicode_ci NOT NULL AFTER `template_name`,
|
476 |
+
ADD COLUMN `default_template` int(11) NOT NULL AFTER `is_wc_template`";
|
477 |
+
|
478 |
+
$wpdb->get_results( $alter_template_table_query );
|
479 |
+
}
|
480 |
+
|
481 |
+
$sent_table_name = $wpdb->prefix . "ac_sent_history_lite";
|
482 |
+
|
483 |
+
$sql_query = "CREATE TABLE IF NOT EXISTS $sent_table_name (
|
484 |
+
`id` int(11) NOT NULL auto_increment,
|
485 |
+
`template_id` varchar(40) collate utf8_unicode_ci NOT NULL,
|
486 |
+
`abandoned_order_id` int(11) NOT NULL,
|
487 |
+
`sent_time` datetime NOT NULL,
|
488 |
+
`sent_email_id` text COLLATE utf8_unicode_ci NOT NULL,
|
489 |
+
PRIMARY KEY (`id`)
|
490 |
+
) $wcap_collate AUTO_INCREMENT=1 ";
|
491 |
+
|
492 |
+
require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
493 |
+
dbDelta ( $sql_query );
|
494 |
+
|
495 |
+
$ac_history_table_name = $wpdb->prefix . "ac_abandoned_cart_history_lite";
|
496 |
+
|
497 |
+
$history_query = "CREATE TABLE IF NOT EXISTS $ac_history_table_name (
|
498 |
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
499 |
+
`user_id` int(11) NOT NULL,
|
500 |
+
`abandoned_cart_info` text COLLATE utf8_unicode_ci NOT NULL,
|
501 |
+
`abandoned_cart_time` int(11) NOT NULL,
|
502 |
+
`cart_ignored` enum('0','1') COLLATE utf8_unicode_ci NOT NULL,
|
503 |
+
`recovered_cart` int(11) NOT NULL,
|
504 |
+
PRIMARY KEY (`id`)
|
505 |
+
) $wcap_collate";
|
506 |
+
|
507 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
508 |
+
dbDelta( $history_query );
|
509 |
+
|
510 |
+
// Default templates: function call to create default templates.
|
511 |
+
$check_table_empty = $wpdb->get_var( "SELECT COUNT(*) FROM `" . $wpdb->prefix . "ac_email_templates_lite`" );
|
512 |
+
|
513 |
+
if( !get_option( 'woocommerce_ac_default_templates_installed' ) ) {
|
514 |
+
if( 0 == $check_table_empty ) {
|
515 |
+
$default_template = new wcal_default_template_settings;
|
516 |
+
$default_template->wcal_create_default_templates();
|
517 |
+
update_option( 'woocommerce_ac_default_templates_installed', "yes" );
|
518 |
+
}
|
519 |
+
}
|
520 |
+
/**
|
521 |
+
* This is add for thos user who Install the plguin first time.
|
522 |
+
* So for them this option will be cheked.
|
523 |
+
*/
|
524 |
+
if( !get_option( 'ac_lite_track_guest_cart_from_cart_page' ) ) {
|
525 |
+
add_option( 'ac_lite_track_guest_cart_from_cart_page', 'on' );
|
526 |
+
}
|
527 |
+
if( !get_option( 'wcal_from_name' ) ) {
|
528 |
+
add_option( 'wcal_from_name', 'Admin' );
|
529 |
+
}
|
530 |
+
$wcal_get_admin_email = get_option( 'admin_email' );
|
531 |
+
if( !get_option( 'wcal_from_email' ) ) {
|
532 |
+
add_option( 'wcal_from_email', $wcal_get_admin_email );
|
533 |
+
}
|
534 |
+
|
535 |
+
if( !get_option( 'wcal_reply_email' ) ) {
|
536 |
+
add_option( 'wcal_reply_email', $wcal_get_admin_email );
|
537 |
+
}
|
538 |
+
|
539 |
+
if( !get_option( 'wcal_activate_time' ) ) {
|
540 |
+
add_option( 'wcal_activate_time', current_time( 'timestamp' ) );
|
541 |
+
}
|
542 |
+
}
|
543 |
+
|
544 |
+
/***************************************************************
|
545 |
+
* WP Settings API
|
546 |
+
**************************************************************/
|
547 |
+
function wcal_initialize_plugin_options() {
|
548 |
+
// First, we register a section. This is necessary since all future options must belong to a
|
549 |
+
add_settings_section(
|
550 |
+
'ac_lite_general_settings_section', // ID used to identify this section and with which to register options
|
551 |
+
__( 'Settings', 'woocommerce-ac' ), // Title to be displayed on the administration page
|
552 |
+
array($this, 'ac_lite_general_options_callback' ), // Callback used to render the description of the section
|
553 |
+
'woocommerce_ac_page' // Page on which to add this section of options
|
554 |
+
);
|
555 |
+
|
556 |
+
add_settings_field(
|
557 |
+
'ac_lite_cart_abandoned_time',
|
558 |
+
__( 'Cart abandoned cut-off time', 'woocommerce-ac' ),
|
559 |
+
array( $this, 'ac_lite_cart_abandoned_time_callback' ),
|
560 |
+
'woocommerce_ac_page',
|
561 |
+
'ac_lite_general_settings_section',
|
562 |
+
array( __( 'Consider cart abandoned after X minutes of item being added to cart & order not placed.', 'woocommerce-ac' ) )
|
563 |
+
);
|
564 |
+
|
565 |
+
add_settings_field(
|
566 |
+
'ac_lite_email_admin_on_recovery',
|
567 |
+
__( 'Email admin On Order Recovery', 'woocommerce-ac' ),
|
568 |
+
array( $this, 'ac_lite_email_admin_on_recovery' ),
|
569 |
+
'woocommerce_ac_page',
|
570 |
+
'ac_lite_general_settings_section',
|
571 |
+
array( __( 'Sends email to Admin if an Abandoned Cart Order is recovered.', 'woocommerce-ac' ) )
|
572 |
+
);
|
573 |
+
|
574 |
+
add_settings_field(
|
575 |
+
'ac_lite_track_guest_cart_from_cart_page',
|
576 |
+
__( 'Enable tracking carts when customer doesn\'t enter details', 'woocommerce-ac' ),
|
577 |
+
array( $this, 'wcal_track_guest_cart_from_cart_page_callback' ),
|
578 |
+
'woocommerce_ac_page',
|
579 |
+
'ac_lite_general_settings_section',
|
580 |
+
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' ) )
|
581 |
+
);
|
582 |
+
/*
|
583 |
+
* New section for the Adding the abandoned cart setting.
|
584 |
+
* Since @: 4.7
|
585 |
+
*/
|
586 |
+
|
587 |
+
add_settings_section(
|
588 |
+
'ac_email_settings_section', // ID used to identify this section and with which to register options
|
589 |
+
__( 'Settings for abandoned cart recovery emails', 'woocommerce-ac' ), // Title to be displayed on the administration page
|
590 |
+
array($this, 'wcal_email_callback' ),// Callback used to render the description of the section
|
591 |
+
'woocommerce_ac_email_page' // Page on which to add this section of options
|
592 |
+
);
|
593 |
+
|
594 |
+
add_settings_field(
|
595 |
+
'wcal_from_name',
|
596 |
+
__( '"From" Name', 'woocommerce-ac' ),
|
597 |
+
array( $this, 'wcal_from_name_callback' ),
|
598 |
+
'woocommerce_ac_email_page',
|
599 |
+
'ac_email_settings_section',
|
600 |
+
array( 'Enter the name that should appear in the email sent.', 'woocommerce-ac' )
|
601 |
+
);
|
602 |
+
|
603 |
+
add_settings_field(
|
604 |
+
'wcal_from_email',
|
605 |
+
__( '"From" Address', 'woocommerce-ac' ),
|
606 |
+
array( $this, 'wcal_from_email_callback' ),
|
607 |
+
'woocommerce_ac_email_page',
|
608 |
+
'ac_email_settings_section',
|
609 |
+
array( 'Email address from which the reminder emails should be sent.', 'woocommerce-ac' )
|
610 |
+
);
|
611 |
+
|
612 |
+
add_settings_field(
|
613 |
+
'wcal_reply_email',
|
614 |
+
__( 'Send Reply Emails to', 'woocommerce-ac' ),
|
615 |
+
array( $this, 'wcal_reply_email_callback' ),
|
616 |
+
'woocommerce_ac_email_page',
|
617 |
+
'ac_email_settings_section',
|
618 |
+
array( 'When a contact receives your email and clicks reply, which email address should that reply be sent to?', 'woocommerce-ac' )
|
619 |
+
);
|
620 |
+
|
621 |
+
|
622 |
+
// Finally, we register the fields with WordPress
|
623 |
+
register_setting(
|
624 |
'woocommerce_ac_settings',
|
625 |
'ac_lite_cart_abandoned_time',
|
626 |
array ( $this, 'ac_lite_cart_time_validation' )
|
648 |
'woocommerce_ac_email_settings',
|
649 |
'wcal_reply_email'
|
650 |
);
|
651 |
+
}
|
652 |
+
|
653 |
+
/***************************************************************
|
654 |
+
* WP Settings API callback for section
|
655 |
+
**************************************************************/
|
656 |
+
function ac_lite_general_options_callback() {
|
657 |
+
|
658 |
+
}
|
659 |
+
|
660 |
+
/***************************************************************
|
661 |
+
* WP Settings API callback for cart time field
|
662 |
+
**************************************************************/
|
663 |
+
function ac_lite_cart_abandoned_time_callback( $args ) {
|
664 |
+
// First, we read the option
|
665 |
+
$cart_abandoned_time = get_option( 'ac_lite_cart_abandoned_time' );
|
666 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
667 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
668 |
+
printf(
|
669 |
+
'<input type="text" id="ac_lite_cart_abandoned_time" name="ac_lite_cart_abandoned_time" value="%s" />',
|
670 |
+
isset( $cart_abandoned_time ) ? esc_attr( $cart_abandoned_time ) : ''
|
671 |
+
);
|
672 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
673 |
+
$html = '<label for="ac_lite_cart_abandoned_time"> ' . $args[0] . '</label>';
|
674 |
+
echo $html;
|
675 |
+
}
|
676 |
+
|
677 |
+
/***************************************************************
|
678 |
+
* WP Settings API cart time field validation
|
679 |
+
**************************************************************/
|
680 |
+
function ac_lite_cart_time_validation( $input ) {
|
681 |
+
$output = '';
|
682 |
+
if ( $input != '' && ( is_numeric( $input) && $input > 0 ) ) {
|
683 |
+
$output = stripslashes( $input) ;
|
684 |
+
} else {
|
685 |
+
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' ) );
|
686 |
+
}
|
687 |
+
return $output;
|
688 |
+
}
|
689 |
+
|
690 |
+
/***************************************************************
|
691 |
+
* WP Settings API callback for email admin on cart recovery field
|
692 |
+
**************************************************************/
|
693 |
+
function ac_lite_email_admin_on_recovery( $args ) {
|
694 |
+
// First, we read the option
|
695 |
+
$email_admin_on_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
|
696 |
+
|
697 |
+
// This condition added to avoid the notie displyed while Check box is unchecked.
|
698 |
+
if( isset( $email_admin_on_recovery ) && $email_admin_on_recovery == '' ) {
|
699 |
+
$email_admin_on_recovery = 'off';
|
700 |
+
}
|
701 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
702 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
703 |
+
$html='';
|
704 |
+
printf(
|
705 |
+
'<input type="checkbox" id="ac_lite_email_admin_on_recovery" name="ac_lite_email_admin_on_recovery" value="on"
|
706 |
+
' . checked('on', $email_admin_on_recovery, false).' />'
|
707 |
+
);
|
708 |
+
|
709 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
710 |
+
$html .= '<label for="ac_lite_email_admin_on_recovery"> ' . $args[0] . '</label>';
|
711 |
+
echo $html;
|
712 |
+
}
|
713 |
+
/***************************************************************
|
714 |
+
* @since : 2.7
|
715 |
+
* WP Settings API callback for capturing guest cart which do not reach the checkout page.
|
716 |
+
**************************************************************/
|
717 |
+
function wcal_track_guest_cart_from_cart_page_callback( $args ) {
|
718 |
+
// First, we read the option
|
719 |
+
$disable_guest_cart_from_cart_page = get_option( 'ac_lite_track_guest_cart_from_cart_page' );
|
720 |
+
|
721 |
+
// This condition added to avoid the notice displyed while Check box is unchecked.
|
722 |
+
if ( isset( $disable_guest_cart_from_cart_page ) && $disable_guest_cart_from_cart_page == '' ) {
|
723 |
+
$disable_guest_cart_from_cart_page = 'off';
|
724 |
+
}
|
725 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
726 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
727 |
+
$html = '';
|
728 |
+
|
729 |
+
printf(
|
730 |
+
'<input type="checkbox" id="ac_lite_track_guest_cart_from_cart_page" name="ac_lite_track_guest_cart_from_cart_page" value="on"
|
731 |
'.checked( 'on', $disable_guest_cart_from_cart_page, false ) . ' />' );
|
732 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
733 |
+
$html .= '<label for="ac_lite_track_guest_cart_from_cart_page"> ' . $args[0] . '</label>';
|
734 |
+
echo $html;
|
735 |
+
}
|
736 |
+
|
737 |
+
/***************************************************************
|
738 |
+
* WP Settings API callback for Abandoned cart email settings of the plugin
|
739 |
+
**************************************************************/
|
740 |
+
function wcal_email_callback () {
|
741 |
+
|
742 |
+
}
|
743 |
+
|
744 |
+
public static function wcal_from_name_callback( $args ) {
|
745 |
+
// First, we read the option
|
746 |
+
$wcal_from_name = get_option( 'wcal_from_name' );
|
747 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
748 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
749 |
+
printf(
|
750 |
+
'<input type="text" id="wcal_from_name" name="wcal_from_name" value="%s" />',
|
751 |
+
isset( $wcal_from_name ) ? esc_attr( $wcal_from_name ) : ''
|
752 |
+
);
|
753 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
754 |
+
$html = '<label for="wcal_from_name_label"> ' . $args[0] . '</label>';
|
755 |
+
echo $html;
|
756 |
+
}
|
757 |
+
|
758 |
+
public static function wcal_from_email_callback( $args ) {
|
759 |
+
// First, we read the option
|
760 |
+
$wcal_from_email = get_option( 'wcal_from_email' );
|
761 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
762 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
763 |
+
printf(
|
764 |
+
'<input type="text" id="wcal_from_email" name="wcal_from_email" value="%s" />',
|
765 |
+
isset( $wcal_from_email ) ? esc_attr( $wcal_from_email ) : ''
|
766 |
+
);
|
767 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
768 |
+
$html = '<label for="wcal_from_email_label"> ' . $args[0] . '</label>';
|
769 |
+
echo $html;
|
770 |
+
}
|
771 |
+
|
772 |
+
public static function wcal_reply_email_callback( $args ) {
|
773 |
+
// First, we read the option
|
774 |
+
$wcal_reply_email = get_option( 'wcal_reply_email' );
|
775 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
776 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
777 |
+
printf(
|
778 |
+
'<input type="text" id="wcal_reply_email" name="wcal_reply_email" value="%s" />',
|
779 |
+
isset( $wcal_reply_email ) ? esc_attr( $wcal_reply_email ) : ''
|
780 |
+
);
|
781 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
782 |
+
$html = '<label for="wcal_reply_email_label"> ' . $args[0] . '</label>';
|
783 |
+
echo $html;
|
784 |
+
}
|
785 |
+
/**************************************************
|
786 |
+
* This function is run when the plugin is upgraded
|
787 |
+
*************************************************/
|
788 |
+
function wcal_update_db_check() {
|
789 |
+
global $wpdb;
|
790 |
+
$wcap_collate = '';
|
791 |
+
if ( $wpdb->has_cap( 'collation' ) ) {
|
792 |
+
$wcap_collate = $wpdb->get_charset_collate();
|
793 |
+
}
|
794 |
+
if( get_option( 'ac_lite_delete_alter_table_queries' ) != 'yes' ) {
|
795 |
+
update_option( 'ac_lite_alter_table_queries', '' );
|
796 |
+
update_option( 'ac_lite_delete_alter_table_queries', 'yes' );
|
797 |
+
}
|
798 |
+
if( get_option( 'ac_lite_alter_table_queries' ) != 'yes' ) {
|
799 |
+
if( $wpdb->get_var( "SHOW TABLES LIKE '" . $wpdb->prefix . "ac_email_templates'" ) === $wpdb->prefix . 'ac_email_templates' ) {
|
800 |
+
$old_table_name = $wpdb->prefix . "ac_email_templates";
|
801 |
+
$table_name = $wpdb->prefix . "ac_email_templates_lite";
|
802 |
+
|
803 |
+
$alter_ac_email_table_query = "ALTER TABLE $old_table_name
|
804 |
+
RENAME TO $table_name";
|
805 |
+
$wpdb->get_results ( $alter_ac_email_table_query );
|
806 |
+
}
|
807 |
+
|
808 |
+
if( $wpdb->get_var( "SHOW TABLES LIKE '" . $wpdb->prefix . "ac_sent_history'" ) === $wpdb->prefix . 'ac_sent_history' ) {
|
809 |
+
$old_sent_table_name = $wpdb->prefix . "ac_sent_history";
|
810 |
+
$sent_table_name = $wpdb->prefix . "ac_sent_history_lite";
|
811 |
+
$alter_ac_sent_history_table_query = "ALTER TABLE $old_sent_table_name
|
812 |
+
RENAME TO $sent_table_name";
|
813 |
+
$wpdb->get_results ( $alter_ac_sent_history_table_query );
|
814 |
+
}
|
815 |
+
|
816 |
+
if( $wpdb->get_var( "SHOW TABLES LIKE '" . $wpdb->prefix . "ac_abandoned_cart_history'" ) === $wpdb->prefix . 'ac_abandoned_cart_history' ) {
|
817 |
+
$old_ac_history_table_name = $wpdb->prefix . "ac_abandoned_cart_history";
|
818 |
+
$ac_history_table_name = $wpdb->prefix . "ac_abandoned_cart_history_lite";
|
819 |
+
|
820 |
+
$alter_ac_abandoned_cart_history_table_query = "ALTER TABLE $old_ac_history_table_name
|
821 |
+
RENAME TO $ac_history_table_name";
|
822 |
+
$wpdb->get_results ( $alter_ac_abandoned_cart_history_table_query );
|
823 |
+
}
|
824 |
+
update_option( 'ac_lite_alter_table_queries', 'yes' );
|
825 |
+
}
|
826 |
+
|
827 |
+
$ac_history_table_name = $wpdb->prefix."ac_abandoned_cart_history_lite";
|
828 |
+
$check_table_query = "SHOW COLUMNS FROM $ac_history_table_name LIKE 'user_type'";
|
829 |
+
$results = $wpdb->get_results( $check_table_query );
|
830 |
+
|
831 |
+
if ( count( $results ) == 0 ) {
|
832 |
+
$alter_table_query = "ALTER TABLE $ac_history_table_name ADD `user_type` text AFTER `recovered_cart`";
|
833 |
+
$wpdb->get_results( $alter_table_query );
|
834 |
+
}
|
835 |
+
|
836 |
+
$table_name = $wpdb->prefix . "ac_email_templates_lite";
|
837 |
+
$check_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'is_wc_template' ";
|
838 |
+
$results = $wpdb->get_results( $check_template_table_query );
|
839 |
+
|
840 |
+
if ( count( $results ) == 0 ) {
|
841 |
+
$alter_template_table_query = "ALTER TABLE $table_name
|
842 |
+
ADD COLUMN `is_wc_template` enum('0','1') COLLATE utf8_unicode_ci NOT NULL AFTER `template_name`,
|
843 |
+
ADD COLUMN `default_template` int(11) NOT NULL AFTER `is_wc_template`";
|
844 |
+
$wpdb->get_results( $alter_template_table_query );
|
845 |
+
}
|
846 |
+
|
847 |
+
|
848 |
+
$table_name = $wpdb->prefix . "ac_email_templates_lite";
|
849 |
+
$check_email_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'wc_email_header' ";
|
850 |
+
$results_email = $wpdb->get_results( $check_email_template_table_query );
|
851 |
+
|
852 |
+
if ( count( $results_email ) == 0 ) {
|
853 |
+
$alter_email_template_table_query = "ALTER TABLE $table_name
|
854 |
+
ADD COLUMN `wc_email_header` varchar(50) COLLATE utf8_unicode_ci NOT NULL AFTER `default_template`";
|
855 |
+
$wpdb->get_results( $alter_email_template_table_query );
|
856 |
+
}
|
857 |
+
|
858 |
+
$guest_table = $wpdb->prefix."ac_guest_abandoned_cart_history_lite" ;
|
859 |
+
$query_guest_table = "SHOW TABLES LIKE '$guest_table' ";
|
860 |
+
$result_guest_table = $wpdb->get_results( $query_guest_table );
|
861 |
+
|
862 |
+
if ( count( $result_guest_table ) == 0 ) {
|
863 |
+
|
864 |
+
$ac_guest_history_table_name = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
|
865 |
+
$ac_guest_history_query = "CREATE TABLE IF NOT EXISTS $ac_guest_history_table_name (
|
866 |
+
`id` int(15) NOT NULL AUTO_INCREMENT,
|
867 |
+
`billing_first_name` text,
|
868 |
+
`billing_last_name` text,
|
869 |
+
`billing_company_name` text,
|
870 |
+
`billing_address_1` text,
|
871 |
+
`billing_address_2` text,
|
872 |
+
`billing_city` text,
|
873 |
+
`billing_county` text,
|
874 |
+
`billing_zipcode` text,
|
875 |
+
`email_id` text,
|
876 |
+
`phone` text,
|
877 |
+
`ship_to_billing` text,
|
878 |
+
`order_notes` text,
|
879 |
+
`shipping_first_name` text,
|
880 |
+
`shipping_last_name` text,
|
881 |
+
`shipping_company_name` text,
|
882 |
+
`shipping_address_1` text,
|
883 |
+
`shipping_address_2` text,
|
884 |
+
`shipping_city` text,
|
885 |
+
`shipping_county` text,
|
886 |
+
`shipping_zipcode` double,
|
887 |
+
`shipping_charges` double,
|
888 |
+
PRIMARY KEY (`id`)
|
889 |
+
) $wcap_collate AUTO_INCREMENT=63000000";
|
890 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php');
|
891 |
+
$wpdb->query( $ac_guest_history_query );
|
892 |
+
}
|
893 |
+
//get the option, if it is not set to individual then convert to individual records and delete the base record
|
894 |
+
$ac_settings = get_option( 'ac_lite_settings_status' );
|
895 |
+
if ( $ac_settings != 'INDIVIDUAL' ) {
|
896 |
+
//fetch the existing settings and save them as inidividual to be used for the settings API
|
897 |
+
$woocommerce_ac_settings = json_decode( get_option( 'woocommerce_ac_settings' ) );
|
898 |
+
if( isset( $woocommerce_ac_settings[0]->cart_time ) ) {
|
899 |
+
add_option( 'ac_lite_cart_abandoned_time', $woocommerce_ac_settings[0]->cart_time );
|
900 |
+
} else {
|
901 |
+
add_option( 'ac_lite_cart_abandoned_time', '10' );
|
902 |
+
}
|
903 |
+
|
904 |
+
if( isset( $woocommerce_ac_settings[0]->email_admin ) ) {
|
905 |
+
add_option( 'ac_lite_email_admin_on_recovery', $woocommerce_ac_settings[0]->email_admin );
|
906 |
+
} else {
|
907 |
+
add_option( 'ac_lite_email_admin_on_recovery', "" );
|
908 |
+
}
|
909 |
+
|
910 |
+
if( isset( $woocommerce_ac_settings[0]->disable_guest_cart_from_cart_page ) ) {
|
911 |
+
add_option( 'ac_lite_track_guest_cart_from_cart_page', $woocommerce_ac_settings[0]->disable_guest_cart_from_cart_page );
|
912 |
+
} else {
|
913 |
+
add_option( 'ac_lite_track_guest_cart_from_cart_page', "" );
|
914 |
+
}
|
915 |
+
|
916 |
+
update_option( 'ac_lite_settings_status', 'INDIVIDUAL' );
|
917 |
+
//Delete the main settings record
|
918 |
+
delete_option( 'woocommerce_ac_settings' );
|
919 |
+
}
|
920 |
+
if ( !get_option( 'wcal_security_key' ) ){
|
921 |
+
update_option( 'wcal_security_key', 'qJB0rGtIn5UB1xG03efyCp' );
|
922 |
+
}
|
923 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_abandoned_cart_history_lite';" ) ) {
|
924 |
+
if ( ! $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_abandoned_cart_history_lite` LIKE 'unsubscribe_link';" ) ) {
|
925 |
+
$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`;" );
|
926 |
+
}
|
927 |
+
}
|
928 |
+
|
929 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_abandoned_cart_history_lite';" ) ) {
|
930 |
+
if ( ! $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_abandoned_cart_history_lite` LIKE 'session_id';" ) ) {
|
931 |
+
$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`;" );
|
932 |
+
}
|
933 |
+
}
|
934 |
+
/*
|
935 |
+
* This is used to prevent guest users wrong Id. If guest users id is less then 63000000 then this code will ensure that we will change the id of guest tables so it wont affect on the next guest users.
|
936 |
+
*/
|
937 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_guest_abandoned_cart_history_lite';" ) && 'yes' != get_option( 'wcal_guest_user_id_altered' ) ) {
|
938 |
+
$last_id = $wpdb->get_var( "SELECT max(id) FROM `{$wpdb->prefix}ac_guest_abandoned_cart_history_lite`;" );
|
939 |
+
if ( NULL != $last_id && $last_id <= 63000000 ) {
|
940 |
+
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_guest_abandoned_cart_history_lite AUTO_INCREMENT = 63000000;" );
|
941 |
+
update_option ( 'wcal_guest_user_id_altered', 'yes' );
|
942 |
+
}
|
943 |
+
}
|
944 |
+
|
945 |
+
/*
|
946 |
+
* Since 4.7
|
947 |
+
* We have moved email templates fields in the setings section. SO to remove that fields column fro the db we need it.
|
948 |
+
* For existing user we need to fill this setting with the first template.
|
949 |
+
*/
|
950 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_email_templates_lite';" ) ) {
|
951 |
+
if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'from_email';" ) ) {
|
952 |
+
$get_email_template_query = "SELECT `from_email` FROM {$wpdb->prefix}ac_email_templates_lite WHERE `is_active` = '1' ORDER BY `id` ASC LIMIT 1";
|
953 |
+
$get_email_template_result = $wpdb->get_results ($get_email_template_query);
|
954 |
+
$wcal_from_email = '';
|
955 |
+
if ( isset( $get_email_template_result ) && count ( $get_email_template_result ) > 0 ){
|
956 |
+
$wcal_from_email = $get_email_template_result[0]->from_email;
|
957 |
+
/* Store data in setings api*/
|
958 |
+
update_option ( 'wcal_from_email', $wcal_from_email );
|
959 |
+
/* Delete table from the Db*/
|
960 |
+
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_email_templates_lite DROP COLUMN `from_email`;" );
|
961 |
+
}
|
962 |
+
}
|
963 |
+
|
964 |
+
if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'from_name';" ) ) {
|
965 |
+
$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";
|
966 |
+
$get_email_template_from_name_result = $wpdb->get_results ($get_email_template_from_name_query);
|
967 |
+
$wcal_from_name = '';
|
968 |
+
if ( isset( $get_email_template_from_name_result ) && count ( $get_email_template_from_name_result ) > 0 ){
|
969 |
+
$wcal_from_name = $get_email_template_from_name_result[0]->from_name;
|
970 |
+
/* Store data in setings api*/
|
971 |
+
add_option ( 'wcal_from_name', $wcal_from_name );
|
972 |
+
/* Delete table from the Db*/
|
973 |
+
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_email_templates_lite DROP COLUMN `from_name`;" );
|
974 |
+
}
|
975 |
+
}
|
976 |
+
|
977 |
+
if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'reply_email';" ) ) {
|
978 |
+
$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";
|
979 |
+
$get_email_template_reply_email_result = $wpdb->get_results ($get_email_template_reply_email_query);
|
980 |
+
$wcal_reply_email = '';
|
981 |
+
if ( isset( $get_email_template_reply_email_result ) && count ( $get_email_template_reply_email_result ) > 0 ){
|
982 |
+
$wcal_reply_email = $get_email_template_reply_email_result[0]->reply_email;
|
983 |
+
/* Store data in setings api*/
|
984 |
+
update_option ( 'wcal_reply_email', $wcal_reply_email );
|
985 |
+
/* Delete table from the Db*/
|
986 |
+
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_email_templates_lite DROP COLUMN `reply_email`;" );
|
987 |
+
}
|
988 |
+
}
|
989 |
+
}
|
990 |
+
}
|
991 |
|
992 |
+
/******
|
993 |
+
* Send email to admin when cart is recovered only via PayPal.
|
994 |
+
* @since 2.9 version
|
995 |
+
*/
|
996 |
+
public static function wcal_email_admin_recovery_for_paypal ( $order_id, $old, $new_status ) {
|
997 |
+
if ( 'pending' == $old && 'processing' == $new_status ) {
|
998 |
+
global $wpdb, $woocommerce;
|
999 |
+
$user_id = get_current_user_id();
|
1000 |
+
$ac_email_admin_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
|
1001 |
+
$order = new WC_Order( $order_id );
|
1002 |
+
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
1003 |
+
$user_id = $order->get_user_id();
|
1004 |
+
}else{
|
1005 |
+
$user_id = $order->user_id;
|
1006 |
+
}
|
1007 |
+
|
1008 |
+
if( $ac_email_admin_recovery == 'on' ) {
|
1009 |
+
$recovered_email_sent = get_post_meta( $order_id, 'wcap_recovered_email_sent', true );
|
1010 |
+
$check_abandoned_cart = get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true );
|
1011 |
+
$created_via = get_post_meta ( $order_id, '_created_via', true );
|
1012 |
+
|
1013 |
+
// mention here why are we comparing both "yes" and "no" values
|
1014 |
+
if ( 'checkout' == $created_via && 'yes' != $recovered_email_sent && ( $check_abandoned_cart == md5( "yes" ) || $check_abandoned_cart == md5( "no" ) ) ) { // indicates cart is abandoned
|
1015 |
+
$order = new WC_Order( $order_id );
|
1016 |
+
$email_heading = __( 'New Customer Order - Recovered', 'woocommerce-ac' );
|
1017 |
+
$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
|
1018 |
+
$email_subject = "New Customer Order - Recovered";
|
1019 |
+
$user_email = get_option( 'admin_email' );
|
1020 |
+
$headers[] = "From: Admin <".$user_email.">";
|
1021 |
+
$headers[] = "Content-Type: text/html";
|
1022 |
+
// Buffer
|
1023 |
+
ob_start();
|
1024 |
+
// Get mail template
|
1025 |
+
wc_get_template( 'emails/admin-new-order.php', array(
|
1026 |
+
'order' => $order,
|
1027 |
+
'email_heading' => $email_heading,
|
1028 |
+
'sent_to_admin' => false,
|
1029 |
+
'plain_text' => false,
|
1030 |
+
'email' => true
|
1031 |
+
)
|
1032 |
+
);
|
1033 |
+
// Get contents
|
1034 |
+
$email_body = ob_get_clean();
|
1035 |
+
wc_mail( $user_email, $email_subject, $email_body, $headers );
|
1036 |
+
update_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
|
1037 |
+
}
|
1038 |
+
}
|
1039 |
+
}
|
1040 |
+
}
|
1041 |
+
|
1042 |
+
/******
|
1043 |
+
* Send email to admin when cart is recovered via any other payment gateway other than PayPal.
|
1044 |
+
* @since 2.3 version
|
1045 |
+
*/
|
1046 |
+
function wcal_email_admin_recovery ( $order_id ) {
|
1047 |
+
global $wpdb, $woocommerce;
|
1048 |
+
|
1049 |
+
$user_id = get_current_user_id();
|
1050 |
+
$ac_email_admin_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
|
1051 |
+
if( $ac_email_admin_recovery == 'on' ) {
|
1052 |
+
$order = new WC_Order( $order_id );
|
1053 |
+
|
1054 |
+
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
1055 |
+
$user_id = $order->get_user_id();
|
1056 |
+
}else{
|
1057 |
+
$user_id = $order->user_id;
|
1058 |
+
}
|
1059 |
+
$recovered_email_sent = get_post_meta( $order_id, 'wcap_recovered_email_sent', true );
|
1060 |
+
$check_abandoned_cart = get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true );
|
1061 |
+
$created_via = get_post_meta( $order_id, '_created_via', true );
|
1062 |
+
if ( 'checkout' == $created_via && 'yes' != $recovered_email_sent && ( $check_abandoned_cart == md5( "yes" ) || $check_abandoned_cart == md5( "no" ) ) ) { // indicates cart is abandoned
|
1063 |
+
$email_heading = __( 'New Customer Order - Recovered', 'woocommerce-ac' );
|
1064 |
+
$blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
|
1065 |
+
$email_subject = "New Customer Order - Recovered";
|
1066 |
+
$user_email = get_option( 'admin_email' );
|
1067 |
+
$headers[] = "From: Admin <".$user_email.">";
|
1068 |
+
$headers[] = "Content-Type: text/html";
|
1069 |
+
// Buffer
|
1070 |
+
ob_start();
|
1071 |
+
// Get mail template
|
1072 |
+
wc_get_template( 'emails/admin-new-order.php', array(
|
1073 |
+
'order' => $order,
|
1074 |
+
'email_heading' => $email_heading,
|
1075 |
+
'sent_to_admin' => false,
|
1076 |
+
'plain_text' => false,
|
1077 |
+
'email' => true
|
1078 |
+
) );
|
1079 |
+
// Get contents
|
1080 |
+
$email_body = ob_get_clean();
|
1081 |
+
|
1082 |
+
wc_mail( $user_email, $email_subject, $email_body, $headers );
|
1083 |
+
|
1084 |
+
update_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
|
1085 |
+
}
|
1086 |
+
}
|
1087 |
+
}
|
1088 |
+
|
1089 |
+
// Add a submenu page.
|
1090 |
+
function wcal_admin_menu() {
|
1091 |
+
$page = add_submenu_page ( 'woocommerce', __( 'Abandoned Carts', 'woocommerce-ac' ), __( 'Abandoned Carts', 'woocommerce-ac' ), 'manage_woocommerce', 'woocommerce_ac_page', array( &$this, 'wcal_menu_page' ) );
|
1092 |
+
}
|
1093 |
+
|
1094 |
+
// Capture the cart and insert the information of the cart into DataBase
|
1095 |
+
function wcal_store_cart_timestamp() {
|
1096 |
+
|
1097 |
+
if( session_id() === '' ){
|
1098 |
+
//session has not started
|
1099 |
+
session_start();
|
1100 |
+
}
|
1101 |
+
global $wpdb,$woocommerce;
|
1102 |
+
$current_time = current_time( 'timestamp' );
|
1103 |
+
$cut_off_time = get_option( 'ac_lite_cart_abandoned_time' );
|
1104 |
+
$track_guest_cart_from_cart_page = get_option( 'ac_lite_track_guest_cart_from_cart_page' );
|
1105 |
+
$cart_ignored = 0;
|
1106 |
+
$recovered_cart = 0;
|
1107 |
+
|
1108 |
+
$track_guest_user_cart_from_cart = "";
|
1109 |
+
if ( isset( $track_guest_cart_from_cart_page ) ) {
|
1110 |
+
$track_guest_user_cart_from_cart = $track_guest_cart_from_cart_page;
|
1111 |
+
}
|
1112 |
+
|
1113 |
+
if( isset( $cut_off_time ) ) {
|
1114 |
+
$cart_cut_off_time = $cut_off_time * 60;
|
1115 |
+
} else {
|
1116 |
+
$cart_cut_off_time = 60 * 60;
|
1117 |
+
}
|
1118 |
+
$compare_time = $current_time - $cart_cut_off_time;
|
1119 |
+
|
1120 |
+
if ( is_user_logged_in() ) {
|
1121 |
+
$user_id = get_current_user_id();
|
1122 |
+
$query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1123 |
+
WHERE user_id = %d
|
1124 |
+
AND cart_ignored = %s
|
1125 |
+
AND recovered_cart = %d ";
|
1126 |
+
$results = $wpdb->get_results($wpdb->prepare( $query, $user_id, $cart_ignored, $recovered_cart ) );
|
1127 |
+
|
1128 |
+
if ( count($results) == 0 ) {
|
1129 |
+
$wcal_woocommerce_persistent_cart =version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
|
1130 |
+
|
1131 |
+
$cart_info = json_encode( get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true ) );
|
1132 |
+
$user_type = "REGISTERED";
|
1133 |
+
$insert_query = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1134 |
+
( user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type )
|
1135 |
+
VALUES ( %d, %s, %d, %s, %s )";
|
1136 |
+
$wpdb->query( $wpdb->prepare( $insert_query, $user_id, $cart_info,$current_time, $cart_ignored, $user_type ) );
|
1137 |
+
|
1138 |
+
$abandoned_cart_id = $wpdb->insert_id;
|
1139 |
+
$_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
|
1140 |
+
} elseif ( isset( $results[0]->abandoned_cart_time ) && $compare_time > $results[0]->abandoned_cart_time ) {
|
1141 |
+
$wcal_woocommerce_persistent_cart =version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
|
1142 |
+
$updated_cart_info = json_encode( get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true ) );
|
1143 |
+
|
1144 |
+
if ( ! $this->wcal_compare_carts( $user_id, $results[0]->abandoned_cart_info ) ) {
|
1145 |
+
$updated_cart_ignored = 1;
|
1146 |
+
$query_ignored = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1147 |
+
SET cart_ignored = %s
|
1148 |
+
WHERE user_id = %d ";
|
1149 |
+
$wpdb->query( $wpdb->prepare( $query_ignored, $updated_cart_ignored, $user_id ) );
|
1150 |
+
|
1151 |
+
$user_type = "REGISTERED";
|
1152 |
+
$query_update = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1153 |
+
(user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type)
|
1154 |
+
VALUES (%d, %s, %d, %s, %s)";
|
1155 |
+
$wpdb->query( $wpdb->prepare( $query_update, $user_id, $updated_cart_info, $current_time, $cart_ignored, $user_type ) );
|
1156 |
+
|
1157 |
+
update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "yes" ) );
|
1158 |
+
|
1159 |
+
$abandoned_cart_id = $wpdb->insert_id;
|
1160 |
+
$_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
|
1161 |
+
} else {
|
1162 |
+
update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "no" ) );
|
1163 |
+
}
|
1164 |
+
} else {
|
1165 |
+
$wcal_woocommerce_persistent_cart =version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
|
1166 |
+
$updated_cart_info = json_encode( get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true ) );
|
1167 |
+
|
1168 |
+
$query_update = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1169 |
+
SET abandoned_cart_info = %s,
|
1170 |
+
abandoned_cart_time = %d
|
1171 |
+
WHERE user_id = %d
|
1172 |
+
AND cart_ignored = %s ";
|
1173 |
+
$wpdb->query( $wpdb->prepare( $query_update, $updated_cart_info, $current_time, $user_id, $cart_ignored ) );
|
1174 |
+
|
1175 |
+
$query_update = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE user_id ='" . $user_id . "' AND cart_ignored='0' ";
|
1176 |
+
$get_abandoned_record = $wpdb->get_results( $query_update );
|
1177 |
+
$abandoned_cart_id = $get_abandoned_record[0]->id;
|
1178 |
+
|
1179 |
+
$_SESSION['abandoned_cart_id_lite'] = $abandoned_cart_id;
|
1180 |
+
}
|
1181 |
+
} else {
|
1182 |
+
//start here guest user
|
1183 |
+
if ( isset( $_SESSION['user_id'] ) ) {
|
1184 |
+
$user_id = $_SESSION['user_id'];
|
1185 |
+
} else {
|
1186 |
+
$user_id = "";
|
1187 |
+
}
|
1188 |
+
|
1189 |
+
$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'";
|
1190 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query, $user_id ) );
|
1191 |
+
$cart = array();
|
1192 |
+
$get_cookie = WC()->session->get_session_cookie();
|
1193 |
+
if ( function_exists('WC') ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1194 |
$cart['cart'] = WC()->session->cart;
|
1195 |
} else {
|
1196 |
$cart['cart'] = $woocommerce->session->cart;
|
1197 |
}
|
1198 |
+
|
1199 |
+
$updated_cart_info = json_encode($cart);
|
1200 |
+
$updated_cart_info = addslashes ( $updated_cart_info );
|
1201 |
+
|
1202 |
+
if ( count($results) > 0 ) {
|
1203 |
+
if ( $compare_time > $results[0]->abandoned_cart_time ) {
|
1204 |
+
if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
|
1205 |
+
|
1206 |
+
$query_ignored = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1207 |
+
SET cart_ignored = '1'
|
1208 |
+
WHERE user_id ='".$user_id."'";
|
1209 |
+
$wpdb->query( $query_ignored );
|
1210 |
+
$user_type = 'GUEST';
|
1211 |
+
$query_update = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1212 |
+
(user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type)
|
1213 |
+
VALUES (%d, %s, %d, %s, %s)";
|
1214 |
+
$wpdb->query( $wpdb->prepare( $query_update, $user_id, $updated_cart_info, $current_time, $cart_ignored, $user_type ) );
|
1215 |
+
update_user_meta( $user_id, '_woocommerce_ac_modified_cart', md5("yes") );
|
1216 |
+
} else {
|
1217 |
+
update_user_meta( $user_id, '_woocommerce_ac_modified_cart', md5("no") );
|
1218 |
+
}
|
1219 |
+
} else {
|
1220 |
+
$query_update = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1221 |
+
SET abandoned_cart_info = '".$updated_cart_info."', abandoned_cart_time = '".$current_time."'
|
1222 |
+
WHERE user_id='".$user_id."' AND cart_ignored='0' ";
|
1223 |
+
$wpdb->query( $query_update );
|
1224 |
+
}
|
1225 |
+
} else {
|
1226 |
/***
|
1227 |
* @Since: 3.5
|
1228 |
* Here we capture the guest cart from the cart page.
|
1261 |
}
|
1262 |
}
|
1263 |
}
|
1264 |
+
}
|
1265 |
+
}
|
1266 |
+
}
|
1267 |
+
|
1268 |
// Decrypt Function
|
1269 |
+
function wcal_decrypt_validate( $validate ) {
|
1270 |
+
$cryptKey = get_option( 'wcal_security_key' );
|
1271 |
+
$validate_decoded = rtrim( mcrypt_decrypt( MCRYPT_RIJNDAEL_256, md5( $cryptKey ), base64_decode( $validate ), MCRYPT_MODE_CBC, md5( md5( $cryptKey ) ) ), "\0");
|
1272 |
+
return( $validate_decoded );
|
1273 |
+
}
|
1274 |
|
1275 |
function wcal_email_unsubscribe( $args ) {
|
1276 |
global $wpdb;
|
1332 |
return $args;
|
1333 |
}
|
1334 |
}
|
1335 |
+
|
1336 |
+
// It will track the URL of cart link from email
|
1337 |
+
function wcal_email_track_links( $template ) {
|
1338 |
+
global $woocommerce;
|
1339 |
+
$track_link = '';
|
1340 |
+
|
1341 |
+
if ( isset( $_GET['wcal_action'] ) ) {
|
1342 |
+
$track_link = $_GET['wcal_action'];
|
1343 |
+
}
|
1344 |
+
if ( $track_link == 'track_links' ) {
|
1345 |
+
if( session_id() === '' ) {
|
1346 |
+
//session has not started
|
1347 |
+
session_start();
|
1348 |
+
}
|
1349 |
+
global $wpdb;
|
1350 |
$validate_server_string = rawurldecode( $_GET ['validate'] );
|
1351 |
+
$validate_server_string = str_replace( " " , "+", $validate_server_string );
|
1352 |
+
$validate_encoded_string = $validate_server_string;
|
1353 |
+
$link_decode_test = base64_decode( $validate_encoded_string );
|
1354 |
+
// it will check if any old email have open the link
|
1355 |
+
if ( preg_match( '/&url=/', $link_decode_test ) ) {
|
1356 |
+
$link_decode = $link_decode_test;
|
1357 |
+
} else {
|
1358 |
+
if( function_exists( "mcrypt_encrypt" ) ) {
|
1359 |
+
$link_decode = $this->wcal_decrypt_validate( $validate_encoded_string );
|
1360 |
+
} else {
|
1361 |
$link_decode = base64_decode( $validate_encoded_string );
|
1362 |
}
|
1363 |
+
}
|
1364 |
+
if ( !preg_match( '/&url=/', $link_decode ) ) { // This will decrypt more security
|
1365 |
+
$cryptKey = get_option( 'wcal_security_key' );
|
1366 |
+
$link_decode = Wcal_Aes_Ctr::decrypt( $validate_encoded_string, $cryptKey, 256 );
|
1367 |
+
}
|
1368 |
+
$sent_email_id_pos = strpos( $link_decode, '&' );
|
1369 |
+
$email_sent_id = substr( $link_decode , 0, $sent_email_id_pos );
|
1370 |
+
$_SESSION['email_sent_id'] = $email_sent_id;
|
1371 |
+
$url_pos = strpos( $link_decode, '=' );
|
1372 |
+
$url_pos = $url_pos + 1;
|
1373 |
+
$url = substr( $link_decode, $url_pos );
|
1374 |
+
$get_ac_id_query = "SELECT abandoned_order_id FROM `".$wpdb->prefix."ac_sent_history_lite` WHERE id = %d";
|
1375 |
+
$get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query, $email_sent_id ) );
|
1376 |
+
$get_user_id_query = "SELECT user_id FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE id = %d";
|
1377 |
+
$get_user_results = $wpdb->get_results( $wpdb->prepare( $get_user_id_query, $get_ac_id_results[0]->abandoned_order_id ) );
|
1378 |
+
$user_id = 0;
|
1379 |
+
if ( isset( $get_user_results ) && count( $get_user_results ) > 0 ) {
|
1380 |
+
$user_id = $get_user_results[0]->user_id;
|
1381 |
+
}
|
1382 |
+
if ( $user_id == 0 ) {
|
1383 |
+
echo "Link expired";
|
1384 |
+
exit;
|
1385 |
+
}
|
1386 |
+
$user = wp_set_current_user( $user_id );
|
1387 |
+
if ( $user_id >= "63000000" ) {
|
1388 |
+
$query_guest = "SELECT * from `". $wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d";
|
1389 |
+
$results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $user_id ) );
|
1390 |
+
$query_cart = "SELECT recovered_cart FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id = %d";
|
1391 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query_cart, $user_id ) );
|
1392 |
+
if ( $results_guest && $results[0]->recovered_cart == '0' ) {
|
1393 |
+
$_SESSION['guest_first_name'] = $results_guest[0]->billing_first_name;
|
1394 |
+
$_SESSION['guest_last_name'] = $results_guest[0]->billing_last_name;
|
1395 |
+
$_SESSION['guest_email'] = $results_guest[0]->email_id;
|
1396 |
+
$_SESSION['user_id'] = $user_id;
|
1397 |
+
} else {
|
1398 |
+
wp_redirect( get_permalink( woocommerce_get_page_id( 'shop' ) ) );
|
1399 |
+
}
|
1400 |
+
}
|
1401 |
+
|
1402 |
+
if ( $user_id < "63000000" ) {
|
1403 |
+
$user_login = $user->data->user_login;
|
1404 |
+
wp_set_auth_cookie( $user_id );
|
1405 |
+
$my_temp = woocommerce_load_persistent_cart( $user_login, $user );
|
1406 |
+
do_action( 'wp_login', $user_login, $user );
|
1407 |
+
if ( isset( $sign_in ) && is_wp_error( $sign_in ) ) {
|
1408 |
+
echo $sign_in->get_error_message();
|
1409 |
+
exit;
|
1410 |
+
}
|
1411 |
+
} else
|
1412 |
+
$my_temp = $this->wcal_load_guest_persistent_cart( $user_id );
|
1413 |
+
|
1414 |
+
if ( $email_sent_id > 0 && is_numeric( $email_sent_id ) ) {
|
1415 |
+
header( "Location: $url" );
|
1416 |
+
}
|
1417 |
+
} else
|
1418 |
+
return $template;
|
1419 |
+
}
|
1420 |
+
|
1421 |
+
// load the information of the guest user
|
1422 |
+
function wcal_load_guest_persistent_cart() {
|
1423 |
+
global $woocommerce;
|
1424 |
+
$saved_cart = json_decode( get_user_meta( $_SESSION['user_id'], '_woocommerce_persistent_cart',true ), true );
|
1425 |
+
$c = array();
|
1426 |
+
$cart_contents_total = $cart_contents_weight = $cart_contents_count = $cart_contents_tax = $total = $subtotal = $subtotal_ex_tax = $tax_total = 0;
|
1427 |
+
|
1428 |
+
foreach ( $saved_cart as $key => $value ) {
|
1429 |
+
foreach ( $value as $a => $b ) {
|
1430 |
+
$c['product_id'] = $b['product_id'];
|
1431 |
+
$c['variation_id'] = $b['variation_id'];
|
1432 |
+
$c['variation'] = $b['variation'];
|
1433 |
+
$c['quantity'] = $b['quantity'];
|
1434 |
+
$product_id = $b['product_id'];
|
1435 |
+
$c['data'] = wc_get_product($product_id);
|
1436 |
+
$c['line_total'] = $b['line_total'];
|
1437 |
+
$c['line_tax'] = $cart_contents_tax;
|
1438 |
+
$c['line_subtotal'] = $b['line_subtotal'];
|
1439 |
+
$c['line_subtotal_tax'] = $cart_contents_tax;
|
1440 |
+
$value_new[ $a ] = $c;
|
1441 |
+
$cart_contents_total = $b['line_subtotal'] + $cart_contents_total;
|
1442 |
+
$cart_contents_count = $cart_contents_count + $b['quantity'];
|
1443 |
+
$total = $total + $b['line_total'];
|
1444 |
+
$subtotal = $subtotal + $b['line_subtotal'];
|
1445 |
+
$subtotal_ex_tax = $subtotal_ex_tax + $b['line_subtotal'];
|
1446 |
+
}
|
1447 |
+
$saved_cart_data[ $key ] = $value_new;
|
1448 |
+
$woocommerce_cart_hash = $a;
|
1449 |
+
}
|
1450 |
+
|
1451 |
+
if( $saved_cart ) {
|
1452 |
+
if ( empty( $woocommerce->session->cart ) || ! is_array( $woocommerce->session->cart ) || sizeof( $woocommerce->session->cart ) == 0 ) {
|
1453 |
+
$woocommerce->session->cart = $saved_cart['cart'];
|
1454 |
+
$woocommerce->session->cart_contents_total = $cart_contents_total;
|
1455 |
+
$woocommerce->session->cart_contents_weight = $cart_contents_weight;
|
1456 |
+
$woocommerce->session->cart_contents_count = $cart_contents_count;
|
1457 |
+
$woocommerce->session->cart_contents_tax = $cart_contents_tax;
|
1458 |
+
$woocommerce->session->total = $total;
|
1459 |
+
$woocommerce->session->subtotal = $subtotal;
|
1460 |
+
$woocommerce->session->subtotal_ex_tax = $subtotal_ex_tax;
|
1461 |
+
$woocommerce->session->tax_total = $tax_total;
|
1462 |
+
$woocommerce->session->shipping_taxes = array();
|
1463 |
+
$woocommerce->session->taxes = array();
|
1464 |
+
$woocommerce->session->ac_customer = array();
|
1465 |
+
$woocommerce->cart->cart_contents = $saved_cart_data['cart'];
|
1466 |
+
$woocommerce->cart->cart_contents_total = $cart_contents_total;
|
1467 |
+
$woocommerce->cart->cart_contents_weight = $cart_contents_weight;
|
1468 |
+
$woocommerce->cart->cart_contents_count = $cart_contents_count;
|
1469 |
+
$woocommerce->cart->cart_contents_tax = $cart_contents_tax;
|
1470 |
+
$woocommerce->cart->total = $total;
|
1471 |
+
$woocommerce->cart->subtotal = $subtotal;
|
1472 |
+
$woocommerce->cart->subtotal_ex_tax = $subtotal_ex_tax;
|
1473 |
+
$woocommerce->cart->tax_total = $tax_total;
|
1474 |
+
}
|
1475 |
+
}
|
1476 |
+
}
|
1477 |
+
|
1478 |
+
function wcal_compare_only_guest_carts( $new_cart, $last_abandoned_cart ) {
|
1479 |
+
$current_woo_cart = array();
|
1480 |
+
$current_woo_cart = json_decode( stripslashes( $new_cart ), true );
|
1481 |
+
$abandoned_cart_arr = array();
|
1482 |
+
$abandoned_cart_arr = json_decode( $last_abandoned_cart, true );
|
1483 |
+
$temp_variable = "";
|
1484 |
+
|
1485 |
+
if ( count( $current_woo_cart['cart'] ) >= count( $abandoned_cart_arr['cart'] ) ) {
|
1486 |
+
//do nothing
|
1487 |
+
} else {
|
1488 |
+
$temp_variable = $current_woo_cart;
|
1489 |
+
$current_woo_cart = $abandoned_cart_arr;
|
1490 |
+
$abandoned_cart_arr = $temp_variable;
|
1491 |
+
}
|
1492 |
+
if ( is_array( $current_woo_cart ) || is_object( $current_woo_cart ) ) {
|
1493 |
+
foreach( $current_woo_cart as $key => $value ) {
|
1494 |
+
foreach( $value as $item_key => $item_value ) {
|
1495 |
+
$current_cart_product_id = $item_value['product_id'];
|
1496 |
+
$current_cart_variation_id = $item_value['variation_id'];
|
1497 |
+
$current_cart_quantity = $item_value['quantity'];
|
1498 |
+
|
1499 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['product_id'] ) ){
|
1500 |
+
$abandoned_cart_product_id = $abandoned_cart_arr[$key][$item_key]['product_id'];
|
1501 |
+
} else {
|
1502 |
+
$abandoned_cart_product_id = "";
|
1503 |
+
}
|
1504 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['variation_id'] ) ) {
|
1505 |
+
$abandoned_cart_variation_id = $abandoned_cart_arr[$key][$item_key]['variation_id'];
|
1506 |
+
} else {
|
1507 |
+
$abandoned_cart_variation_id = "";
|
1508 |
+
}
|
1509 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['quantity'] ) ) {
|
1510 |
+
$abandoned_cart_quantity = $abandoned_cart_arr[$key][$item_key]['quantity'];
|
1511 |
+
} else {
|
1512 |
+
$abandoned_cart_quantity = "";
|
1513 |
+
}
|
1514 |
+
if ( ( $current_cart_product_id != $abandoned_cart_product_id ) ||
|
1515 |
+
( $current_cart_variation_id != $abandoned_cart_variation_id ) ||
|
1516 |
+
( $current_cart_quantity != $abandoned_cart_quantity ) ) {
|
1517 |
+
return false;
|
1518 |
+
}
|
1519 |
+
}
|
1520 |
+
}
|
1521 |
+
}
|
1522 |
+
return true;
|
1523 |
+
}
|
1524 |
|
1525 |
+
// Compare the existing cart with new cart
|
1526 |
+
function wcal_compare_carts( $user_id, $last_abandoned_cart ) {
|
1527 |
+
global $woocommerce;
|
1528 |
+
|
1529 |
+
$wcal_woocommerce_persistent_cart =version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
|
1530 |
+
$current_woo_cart = get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true );
|
1531 |
+
$abandoned_cart_arr = json_decode( $last_abandoned_cart, true );
|
1532 |
+
$temp_variable = "";
|
1533 |
+
if ( count( $current_woo_cart['cart'] ) >= count( $abandoned_cart_arr['cart'] ) ) {
|
1534 |
+
//do nothing
|
1535 |
+
} else {
|
1536 |
+
$temp_variable = $current_woo_cart;
|
1537 |
+
$current_woo_cart = $abandoned_cart_arr;
|
1538 |
+
$abandoned_cart_arr = $temp_variable;
|
1539 |
+
}
|
1540 |
+
foreach ( $current_woo_cart as $key => $value ) {
|
1541 |
+
|
1542 |
+
foreach ( $value as $item_key => $item_value ) {
|
1543 |
+
$current_cart_product_id = $item_value['product_id'];
|
1544 |
+
$current_cart_variation_id = $item_value['variation_id'];
|
1545 |
+
$current_cart_quantity = $item_value['quantity'];
|
1546 |
|
1547 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['product_id'] ) ) {
|
1548 |
+
$abandoned_cart_product_id = $abandoned_cart_arr[$key][$item_key]['product_id'];
|
1549 |
+
} else {
|
1550 |
+
$abandoned_cart_product_id = "";
|
1551 |
+
}
|
1552 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['variation_id'] ) ) {
|
1553 |
+
$abandoned_cart_variation_id = $abandoned_cart_arr[$key][$item_key]['variation_id'];
|
1554 |
+
} else {
|
1555 |
+
$abandoned_cart_variation_id = "";
|
1556 |
+
}
|
1557 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['quantity'] ) ) {
|
1558 |
+
$abandoned_cart_quantity = $abandoned_cart_arr[$key][$item_key]['quantity'];
|
1559 |
+
} else {
|
1560 |
+
$abandoned_cart_quantity = "";
|
1561 |
+
}
|
1562 |
+
if ( ( $current_cart_product_id != $abandoned_cart_product_id ) ||
|
1563 |
+
( $current_cart_variation_id != $abandoned_cart_variation_id ) ||
|
1564 |
+
( $current_cart_quantity != $abandoned_cart_quantity ) )
|
1565 |
+
{
|
1566 |
+
return false;
|
1567 |
+
}
|
1568 |
+
}
|
1569 |
+
}
|
1570 |
+
return true;
|
1571 |
+
}
|
1572 |
+
|
1573 |
+
// function is call when order is recovered
|
1574 |
+
function wcal_action_after_delivery_session( $order ) {
|
1575 |
+
|
1576 |
+
if( session_id() === '' ){
|
1577 |
+
//session has not started
|
1578 |
+
session_start();
|
1579 |
+
}
|
1580 |
+
global $wpdb, $woocommerce;
|
1581 |
+
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
1582 |
+
$order_id = $order->get_id();
|
1583 |
+
}else{
|
1584 |
+
$order_id = $order->id;
|
1585 |
+
}
|
1586 |
+
$get_abandoned_id_of_order = '';
|
1587 |
+
$get_sent_email_id_of_order = '';
|
1588 |
+
$get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
|
1589 |
+
if( isset( $get_abandoned_id_of_order ) && $get_abandoned_id_of_order != '' ){
|
1590 |
+
$get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
|
1591 |
+
$get_sent_email_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed_sent_id', true );
|
1592 |
+
|
1593 |
+
$query_order = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET recovered_cart= '" . $order_id . "', cart_ignored = '1'
|
1594 |
WHERE id = '".$get_abandoned_id_of_order."' ";
|
1595 |
+
$wpdb->query( $query_order );
|
1596 |
+
|
1597 |
+
$order->add_order_note( __( 'This order was abandoned & subsequently recovered.', 'woocommerce-ac' ) );
|
1598 |
+
|
1599 |
+
delete_post_meta( $order_id, 'wcal_recover_order_placed', $get_abandoned_id_of_order );
|
1600 |
+
delete_post_meta( $order_id , 'wcal_recover_order_placed_sent_id', $get_sent_email_id_of_order );
|
1601 |
+
}
|
1602 |
+
$user_id = get_current_user_id();
|
1603 |
+
$sent_email = '';
|
1604 |
+
if( isset( $_SESSION['email_sent_id'] ) ){
|
1605 |
+
$sent_email = $_SESSION['email_sent_id'];
|
1606 |
+
}
|
1607 |
+
if( $user_id == "" ) {
|
1608 |
+
$user_id = $_SESSION['user_id'];
|
1609 |
+
// Set the session variables to blanks
|
1610 |
+
$_SESSION['guest_first_name'] = $_SESSION['guest_last_name'] = $_SESSION['guest_email'] = $_SESSION['user_id'] = "";
|
1611 |
+
}
|
1612 |
+
delete_user_meta( $user_id, '_woocommerce_ac_persistent_cart_time' );
|
1613 |
+
delete_user_meta( $user_id, '_woocommerce_ac_persistent_cart_temp_time' );
|
1614 |
+
// get all latest abandoned carts that were modified
|
1615 |
+
$cart_ignored = 0;
|
1616 |
+
$recovered_cart = 0;
|
1617 |
+
$query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1618 |
+
WHERE user_id = %d
|
1619 |
+
AND cart_ignored = %s
|
1620 |
+
AND recovered_cart = %d
|
1621 |
+
ORDER BY id DESC
|
1622 |
+
LIMIT 1";
|
1623 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query, $user_id, $cart_ignored, $recovered_cart ) );
|
1624 |
+
if ( count( $results ) > 0 ) {
|
1625 |
+
if ( get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true ) == md5( "yes" ) ||
|
1626 |
+
get_user_meta( $user_id, '_woocommerce_ac_modified_cart', true ) == md5( "no" ) ) {
|
1627 |
+
|
1628 |
+
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
1629 |
+
$order_id = $order->get_id();
|
1630 |
+
}else{
|
1631 |
+
$order_id = $order->id;
|
1632 |
+
}
|
1633 |
+
$updated_cart_ignored = 1;
|
1634 |
+
$query_order = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1635 |
+
SET recovered_cart = %d,
|
1636 |
+
cart_ignored = %s
|
1637 |
+
WHERE id = %d ";
|
1638 |
+
$wpdb->query( $wpdb->prepare( $query_order, $order_id, $updated_cart_ignored, $results[0]->id ) );
|
1639 |
+
delete_user_meta( $user_id, '_woocommerce_ac_modified_cart' );
|
1640 |
+
delete_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
|
1641 |
+
} else {
|
1642 |
+
$delete_query = "DELETE FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1643 |
+
WHERE id= %d ";
|
1644 |
+
$wpdb->query( $wpdb->prepare( $delete_query, $results[0]->id ) );
|
1645 |
+
}
|
1646 |
+
} else {
|
1647 |
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
1648 |
|
1649 |
$email_id = $order->get_billing_email();
|
1655 |
|
1656 |
if ( $results_id ) {
|
1657 |
$record_status = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1658 |
+
WHERE user_id = %d AND recovered_cart = '0'";
|
1659 |
$results_status = $wpdb->get_results( $wpdb->prepare( $record_status, $results_id[0]->id ) );
|
1660 |
|
1661 |
if ( $results_status ) {
|
1663 |
get_user_meta( $results_id[0]->id, '_woocommerce_ac_modified_cart', true ) == md5("no") ) {
|
1664 |
|
1665 |
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
1666 |
+
$order_id = $order->get_id();
|
1667 |
+
}else{
|
1668 |
+
$order_id = $order->id;
|
1669 |
+
}
|
1670 |
$query_order = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1671 |
+
SET recovered_cart= '".$order_id."', cart_ignored = '1'
|
1672 |
+
WHERE id='".$results_status[0]->id."' ";
|
1673 |
$wpdb->query( $query_order );
|
1674 |
delete_user_meta( $results_id[0]->id, '_woocommerce_ac_modified_cart' );
|
1675 |
delete_post_meta( $order_id, 'wcap_recovered_email_sent', 'yes' );
|
1683 |
}
|
1684 |
}
|
1685 |
}
|
1686 |
+
}
|
1687 |
+
|
1688 |
+
function wcal_action_admin_init() {
|
1689 |
+
global $typenow;
|
1690 |
+
// only hook up these filters if we're in the admin panel and the current user has permission
|
1691 |
+
// to edit posts and pages
|
1692 |
+
if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) ) {
|
1693 |
+
return;
|
1694 |
+
}
|
1695 |
+
if ( !isset( $_GET['page'] ) || $_GET['page'] != "woocommerce_ac_page" ) {
|
1696 |
+
return;
|
1697 |
+
}
|
1698 |
+
if ( get_user_option( 'rich_editing' ) == 'true' ) {
|
1699 |
+
remove_filter( 'the_excerpt', 'wpautop' );
|
1700 |
+
add_filter( 'tiny_mce_before_init', array( &$this, 'wcal_format_tiny_MCE' ) );
|
1701 |
+
add_filter( 'mce_buttons', array( &$this, 'wcal_filter_mce_button' ) );
|
1702 |
+
add_filter( 'mce_external_plugins', array( &$this, 'wcal_filter_mce_plugin' ) );
|
1703 |
+
}
|
1704 |
+
if ( isset( $_GET['page'] ) && 'woocommerce_ac_page' == $_GET['page'] ) {
|
1705 |
+
if( session_id() === '' ){
|
1706 |
+
//session has not started
|
1707 |
+
session_start();
|
1708 |
+
}
|
1709 |
+
}
|
1710 |
+
}
|
1711 |
+
|
1712 |
+
function wcal_filter_mce_button( $buttons ) {
|
1713 |
+
// add a separation before our button, here our button's id is "mygallery_button"
|
1714 |
+
array_push( $buttons, 'abandoncart', '|' );
|
1715 |
+
return $buttons;
|
1716 |
+
}
|
1717 |
+
|
1718 |
+
function wcal_filter_mce_plugin( $plugins ) {
|
1719 |
+
// this plugin file will work the magic of our button
|
1720 |
+
$plugins['abandoncart'] = plugin_dir_url( __FILE__ ) . 'assets/js/abandoncart_plugin_button.js';
|
1721 |
+
return $plugins;
|
1722 |
+
}
|
1723 |
+
|
1724 |
+
function wcal_display_tabs() {
|
1725 |
+
|
1726 |
+
if ( isset( $_GET['action'] ) ) {
|
1727 |
+
$action = $_GET['action'];
|
1728 |
+
} else {
|
1729 |
+
$action = "";
|
1730 |
+
$active_listcart = "";
|
1731 |
+
$active_emailtemplates = "";
|
1732 |
+
$active_settings = "";
|
1733 |
+
$active_stats = "";
|
1734 |
+
}
|
1735 |
+
if ( ( $action == 'listcart' || $action == 'orderdetails' ) || $action == '' ) {
|
1736 |
+
$active_listcart = "nav-tab-active";
|
1737 |
+
}
|
1738 |
+
if ( $action == 'emailtemplates' ) {
|
1739 |
+
$active_emailtemplates = "nav-tab-active";
|
1740 |
+
}
|
1741 |
+
if ( $action == 'emailsettings' ) {
|
1742 |
+
$active_settings = "nav-tab-active";
|
1743 |
+
}
|
1744 |
+
if ( $action == 'stats' ) {
|
1745 |
+
$active_stats = "nav-tab-active";
|
1746 |
+
}
|
1747 |
+
if ( $action == 'report' ) {
|
1748 |
+
$active_report = "nav-tab-active";
|
1749 |
+
}
|
1750 |
+
?>
|
1751 |
+
<div style="background-image: url('<?php echo plugins_url(); ?>/woocommerce-abandoned-cart/assets/images/ac_tab_icon.png') !important;" class="icon32"><br>
|
1752 |
+
</div>
|
1753 |
+
<h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
|
1754 |
+
<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>
|
1755 |
+
<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>
|
1756 |
+
<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>
|
1757 |
+
<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>
|
1758 |
+
<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>
|
1759 |
+
</h2>
|
1760 |
+
<?php
|
1761 |
+
}
|
1762 |
+
|
1763 |
+
function wcal_enqueue_scripts_js( $hook ) {
|
1764 |
+
|
1765 |
+
if ( $hook != 'woocommerce_page_woocommerce_ac_page' ) {
|
1766 |
+
return;
|
1767 |
+
} else {
|
1768 |
+
wp_enqueue_script( 'jquery' );
|
1769 |
wp_enqueue_script(
|
1770 |
'jquery-ui-min',
|
1771 |
+
'//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js',
|
1772 |
+
'',
|
1773 |
+
'',
|
1774 |
+
false
|
1775 |
+
);
|
1776 |
+
wp_enqueue_script( 'jquery-ui-datepicker' );
|
1777 |
+
|
1778 |
+
wp_enqueue_script(
|
1779 |
+
'jquery-tip',
|
1780 |
+
plugins_url( '/assets/js/jquery.tipTip.minified.js', __FILE__ ),
|
1781 |
+
'',
|
1782 |
+
'',
|
1783 |
+
false
|
1784 |
+
);
|
1785 |
+
wp_register_script( 'woocommerce_admin', plugins_url() . '/woocommerce/assets/js/admin/woocommerce_admin.js', array( 'jquery', 'jquery-ui-widget', 'jquery-ui-core' ) );
|
1786 |
+
wp_enqueue_script( 'woocommerce_admin' );
|
1787 |
+
?>
|
1788 |
+
<script type="text/javascript" >
|
1789 |
+
function wcal_activate_email_template( template_id, active_state ) {
|
1790 |
+
location.href = 'admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=activate_template&id='+template_id+'&active_state='+active_state ;
|
1791 |
+
}
|
1792 |
+
</script>
|
1793 |
+
<?php
|
1794 |
+
$js_src = includes_url('js/tinymce/') . 'tinymce.min.js';
|
1795 |
+
wp_enqueue_script( 'tinyMce_ac',$js_src );
|
1796 |
+
wp_enqueue_script( 'ac_email_variables', plugins_url() . '/woocommerce-abandoned-cart/assets/js/abandoncart_plugin_button.js' );
|
1797 |
+
}
|
1798 |
+
}
|
1799 |
+
|
1800 |
+
function wcal_format_tiny_MCE( $in ) {
|
1801 |
+
$in['force_root_block'] = false;
|
1802 |
+
$in['valid_children'] = '+body[style]';
|
1803 |
+
$in['remove_linebreaks'] = false;
|
1804 |
+
$in['gecko_spellcheck'] = false;
|
1805 |
+
$in['keep_styles'] = true;
|
1806 |
+
$in['accessibility_focus'] = true;
|
1807 |
+
$in['tabfocus_elements'] = 'major-publishing-actions';
|
1808 |
+
$in['media_strict'] = false;
|
1809 |
+
$in['paste_remove_styles'] = false;
|
1810 |
+
$in['paste_remove_spans'] = false;
|
1811 |
+
$in['paste_strip_class_attributes'] = 'none';
|
1812 |
+
$in['paste_text_use_dialog'] = true;
|
1813 |
+
$in['wpeditimage_disable_captions'] = true;
|
1814 |
+
$in['wpautop'] = false;
|
1815 |
+
$in['apply_source_formatting'] = true;
|
1816 |
+
$in['cleanup'] = true;
|
1817 |
+
$in['convert_newlines_to_brs'] = FALSE;
|
1818 |
+
$in['fullpage_default_xml_pi'] = false;
|
1819 |
+
$in['convert_urls'] = false;
|
1820 |
+
// Do not remove redundant BR tags
|
1821 |
+
$in['remove_redundant_brs'] = false;
|
1822 |
+
return $in;
|
1823 |
+
}
|
1824 |
+
|
1825 |
+
function wcal_enqueue_scripts_css( $hook ) {
|
1826 |
+
if ( $hook != 'woocommerce_page_woocommerce_ac_page' ) {
|
1827 |
+
return;
|
1828 |
+
} else {
|
1829 |
+
wp_enqueue_style( 'jquery-ui', "//ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" , '', '', false );
|
1830 |
+
wp_enqueue_style( 'woocommerce_admin_styles', plugins_url() . '/woocommerce/assets/css/admin.css' );
|
1831 |
+
wp_enqueue_style( 'jquery-ui-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
|
1832 |
+
wp_enqueue_style( 'abandoned-orders-list', plugins_url() . '/woocommerce-abandoned-cart/assets/css/view.abandoned.orders.style.css' );
|
1833 |
+
|
1834 |
+
}
|
1835 |
+
}
|
1836 |
+
//bulk action
|
1837 |
+
// to over come the wp redirect warning while deleting
|
1838 |
+
function wcal_app_output_buffer() {
|
1839 |
+
ob_start();
|
1840 |
+
}
|
1841 |
+
|
1842 |
+
/**
|
1843 |
+
* Abandon Cart Settings Page
|
1844 |
+
*/
|
1845 |
+
function wcal_menu_page() {
|
1846 |
+
|
1847 |
+
if ( is_user_logged_in() ) {
|
1848 |
+
global $wpdb;
|
1849 |
+
// Check the user capabilities
|
1850 |
+
if ( !current_user_can( 'manage_woocommerce' ) ) {
|
1851 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.', 'woocommerce-ac' ) );
|
1852 |
+
}
|
1853 |
+
?>
|
1854 |
+
<div class="wrap">
|
1855 |
+
<h2><?php _e( 'WooCommerce - Abandon Cart Lite', 'woocommerce-ac' ); ?></h2>
|
1856 |
+
<?php
|
1857 |
+
|
1858 |
if ( isset( $_GET['action'] ) ) {
|
1859 |
$action = $_GET['action'];
|
1860 |
} else {
|
1861 |
$action = "";
|
1862 |
}
|
1863 |
+
if ( isset( $_GET['mode'] ) ) {
|
1864 |
+
$mode = $_GET['mode'];
|
1865 |
+
} else {
|
1866 |
+
$mode = "";
|
1867 |
+
}
|
1868 |
+
$this->wcal_display_tabs();
|
1869 |
+
|
1870 |
+
/**
|
1871 |
+
* When we delete the item from the below drop down it is registred in action 2
|
1872 |
+
*/
|
1873 |
+
if ( isset( $_GET['action2'] ) ) {
|
1874 |
+
$action_two = $_GET['action2'];
|
1875 |
+
} else {
|
1876 |
+
$action_two = "";
|
1877 |
+
}
|
1878 |
+
// Detect when a bulk action is being triggered on abandoned orders page.
|
1879 |
+
if( 'wcal_delete' === $action || 'wcal_delete' === $action_two ) {
|
1880 |
+
$ids = isset( $_GET['abandoned_order_id'] ) ? $_GET['abandoned_order_id'] : false;
|
1881 |
+
if ( ! is_array( $ids ) ) {
|
1882 |
+
$ids = array( $ids );
|
1883 |
+
}
|
1884 |
+
foreach ( $ids as $id ) {
|
1885 |
+
$class = new wcal_delete_bulk_action_handler();
|
1886 |
+
$class->wcal_delete_bulk_action_handler_function( $id );
|
1887 |
+
}
|
1888 |
+
}
|
1889 |
+
//Detect when a bulk action is being triggered on temnplates page.
|
1890 |
+
if( 'wcal_delete_template' === $action || 'wcal_delete_template' === $action_two ) {
|
1891 |
+
$ids = isset( $_GET['template_id'] ) ? $_GET['template_id'] : false;
|
1892 |
+
if ( ! is_array( $ids ) ) {
|
1893 |
+
$ids = array( $ids );
|
1894 |
+
}
|
1895 |
+
foreach ( $ids as $id ) {
|
1896 |
+
$class = new wcal_delete_bulk_action_handler();
|
1897 |
+
$class->wcal_delete_template_bulk_action_handler_function( $id );
|
1898 |
+
}
|
1899 |
+
}
|
1900 |
+
|
1901 |
if ( isset( $_GET['wcal_deleted'] ) && 'YES' == $_GET['wcal_deleted'] ) { ?>
|
1902 |
<div id="message" class="updated fade">
|
1903 |
<p><strong><?php _e( 'The Abandoned cart has been successfully deleted.', 'woocommerce-ac' ); ?></strong></p>
|
1908 |
<p><strong><?php _e( 'The Template has been successfully deleted.', 'woocommerce-ac' ); ?></strong></p>
|
1909 |
</div>
|
1910 |
<?php }
|
1911 |
+
if ( $action == 'emailsettings' ) {
|
1912 |
+
// Save the field values
|
1913 |
?>
|
1914 |
+
<p><?php _e( 'Change settings for sending email notifications to Customers, to Admin etc.', 'woocommerce-ac' ); ?></p>
|
1915 |
<div id="content">
|
1916 |
<?php
|
1917 |
$wcal_general_settings_class = $wcal_email_setting = "";
|
1941 |
<?php
|
1942 |
if ( $section == 'wcal_general_settings' || $section == '' ) {
|
1943 |
?>
|
1944 |
+
<form method="post" action="options.php">
|
1945 |
<?php settings_fields( 'woocommerce_ac_settings' ); ?>
|
1946 |
<?php do_settings_sections( 'woocommerce_ac_page' ); ?>
|
1947 |
+
<?php settings_errors(); ?>
|
1948 |
+
<?php submit_button(); ?>
|
1949 |
</form>
|
1950 |
<?php
|
1951 |
} else if ( $section == 'wcal_email_settings' ) {
|
1959 |
}
|
1960 |
?>
|
1961 |
</div>
|
1962 |
+
<?php
|
1963 |
+
} elseif ( $action == 'listcart' || '' == $action || '-1' == $action || '-1' == $action_two ) {
|
1964 |
+
?>
|
1965 |
+
<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>
|
1966 |
+
<?php
|
1967 |
+
$get_all_abandoned_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_abandoned' );
|
1968 |
+
$get_registered_user_ac_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_registered' );
|
1969 |
+
$get_guest_user_ac_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_guest' );
|
1970 |
+
$get_visitor_user_ac_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_visitor' );
|
1971 |
|
1972 |
+
$wcal_user_reg_text = 'User';
|
1973 |
if ( $get_registered_user_ac_count > 1){
|
1974 |
$wcal_user_reg_text = 'Users';
|
1975 |
}
|
2040 |
</form>
|
2041 |
</div>
|
2042 |
<?php
|
2043 |
+
} elseif ( $action == 'emailtemplates' && ( $mode != 'edittemplate' && $mode != 'addnewtemplate' ) ) {
|
2044 |
+
?>
|
2045 |
+
<p> <?php _e( 'Add email templates at different intervals to maximize the possibility of recovering your abandoned carts.', 'woocommerce-ac' );?> </p>
|
2046 |
+
<?php
|
2047 |
+
// Save the field values
|
2048 |
+
$insert_template_successfuly = $update_template_successfuly = '';
|
2049 |
+
if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' ) {
|
2050 |
+
$active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
2051 |
+
$is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
|
2052 |
+
if ( $active_post == 1 ) {
|
2053 |
+
$is_active = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
2054 |
+
$email_frequency = trim( $_POST['email_frequency'] );
|
2055 |
+
$day_or_hour = trim( $_POST['day_or_hour'] );
|
2056 |
+
|
2057 |
+
$check_query = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite`
|
2058 |
+
WHERE is_active = %s
|
2059 |
AND frequency = %d
|
2060 |
AND day_or_hour = %s ";
|
2061 |
+
$check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $is_active, $email_frequency, $day_or_hour ) );
|
2062 |
+
$default_value = 0 ;
|
2063 |
+
|
2064 |
+
if ( count( $check_results ) == 0 ) {
|
2065 |
+
$active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
2066 |
+
$woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
|
2067 |
+
$woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
|
2068 |
+
$woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
|
2069 |
+
|
2070 |
+
$woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
|
2071 |
+
$query = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
|
2072 |
+
(subject, body, is_active, frequency, day_or_hour, template_name, is_wc_template, default_template, wc_email_header )
|
2073 |
+
VALUES ( %s, %s, %s, %d, %s, %s, %s, %d, %s )";
|
2074 |
+
|
2075 |
+
$insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query,
|
2076 |
+
$woocommerce_ac_email_subject,
|
2077 |
+
$woocommerce_ac_email_body,
|
2078 |
+
$active_post,
|
2079 |
+
$email_frequency,
|
2080 |
+
$day_or_hour,
|
2081 |
+
$woocommerce_ac_template_name,
|
2082 |
+
$is_wc_template,
|
2083 |
+
$default_value,
|
2084 |
+
$woocommerce_ac_email_header)
|
2085 |
+
);
|
2086 |
+
} else {
|
2087 |
+
$update_is_active = 0;
|
2088 |
+
$query_update = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
|
2089 |
+
SET
|
2090 |
+
is_active = %s
|
2091 |
+
WHERE frequency = %d
|
2092 |
AND day_or_hour = %s ";
|
2093 |
+
$update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update, $update_is_active, $email_frequency, $day_or_hour ) );
|
2094 |
+
|
2095 |
+
$woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
|
2096 |
+
$woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
|
2097 |
+
$woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
|
2098 |
+
$woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
|
2099 |
+
$query_insert_new = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
|
2100 |
+
(subject, body, is_active, frequency, day_or_hour, template_name, is_wc_template, default_template, wc_email_header )
|
2101 |
+
VALUES ( %s, %s, %s, %d, %s, %s, %s, %d, %s )";
|
2102 |
+
|
2103 |
+
$insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query_insert_new,
|
2104 |
+
$woocommerce_ac_email_subject,
|
2105 |
+
$woocommerce_ac_email_body,
|
2106 |
+
$active_post,
|
2107 |
+
$email_frequency,
|
2108 |
+
$day_or_hour,
|
2109 |
+
$woocommerce_ac_template_name,
|
2110 |
+
$is_wc_template,
|
2111 |
+
$default_value,
|
2112 |
+
$woocommerce_ac_email_header )
|
2113 |
);
|
2114 |
+
}
|
2115 |
+
} else {
|
2116 |
+
$woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
|
2117 |
+
$woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
|
2118 |
+
$woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
|
2119 |
+
$woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
|
2120 |
+
$active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
2121 |
+
$email_frequency = trim( $_POST['email_frequency'] );
|
2122 |
+
$day_or_hour = trim( $_POST['day_or_hour'] );
|
2123 |
+
$is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
|
2124 |
+
$default_value = 0 ;
|
2125 |
+
|
2126 |
+
$query = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
|
2127 |
+
(subject, body, is_active, frequency, day_or_hour, template_name, is_wc_template, default_template, wc_email_header )
|
2128 |
+
VALUES ( %s, %s, %s, %d, %s, %s, %s, %d, %s )";
|
2129 |
+
|
2130 |
+
$insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query,
|
2131 |
+
$woocommerce_ac_email_subject,
|
2132 |
+
$woocommerce_ac_email_body,
|
2133 |
+
$active_post,
|
2134 |
+
$email_frequency,
|
2135 |
+
$day_or_hour,
|
2136 |
+
$woocommerce_ac_template_name,
|
2137 |
+
$is_wc_template,
|
2138 |
+
$default_value,
|
2139 |
+
$woocommerce_ac_email_header )
|
2140 |
+
);
|
2141 |
+
}
|
2142 |
+
}
|
2143 |
+
|
2144 |
+
if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' ) {
|
2145 |
+
$active = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
2146 |
+
$is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
|
2147 |
+
|
2148 |
+
if ( $active == 1 ) {
|
2149 |
+
$is_active = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
2150 |
+
$email_frequency = trim( $_POST['email_frequency'] );
|
2151 |
+
$day_or_hour = trim( $_POST['day_or_hour'] );
|
2152 |
+
$check_query = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite`
|
2153 |
+
WHERE is_active= %s
|
2154 |
+
AND frequency = %d
|
2155 |
+
AND day_or_hour= %s ";
|
2156 |
+
$check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $is_active, $email_frequency, $day_or_hour ) );
|
2157 |
+
$default_value = '';
|
2158 |
+
|
2159 |
+
foreach( $check_results as $result_key => $result_value ) {
|
2160 |
+
$default_value = ( empty( $result_value->default_template ) ) ? 0 : $result_value->default_template;
|
2161 |
+
}
|
2162 |
+
|
2163 |
+
if( count( $check_results ) == 0 ) {
|
2164 |
+
$woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
|
2165 |
+
$woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
|
2166 |
+
$woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
|
2167 |
+
$woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
|
2168 |
+
$id = trim( $_POST['id'] );
|
2169 |
+
|
2170 |
+
$query_update = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
|
2171 |
+
SET
|
2172 |
+
subject = %s,
|
2173 |
+
body = %s,
|
2174 |
+
is_active = %s,
|
2175 |
+
frequency = %d,
|
2176 |
+
day_or_hour = %s,
|
2177 |
+
template_name = %s,
|
2178 |
+
is_wc_template = %s,
|
2179 |
+
default_template = %d,
|
2180 |
+
wc_email_header = %s
|
2181 |
+
WHERE id = %d ";
|
2182 |
+
$update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update,
|
2183 |
+
$woocommerce_ac_email_subject,
|
2184 |
+
$woocommerce_ac_email_body,
|
2185 |
+
$active,
|
2186 |
+
$email_frequency,
|
2187 |
+
$day_or_hour,
|
2188 |
+
$woocommerce_ac_template_name,
|
2189 |
+
$is_wc_template,
|
2190 |
+
$default_value,
|
2191 |
+
$woocommerce_ac_email_header,
|
2192 |
+
$id )
|
2193 |
+
|
2194 |
+
);
|
2195 |
+
} else {
|
2196 |
+
$updated_is_active = 0;
|
2197 |
+
$query_update_new = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
|
2198 |
+
SET is_active = %s
|
2199 |
+
WHERE frequency = %d
|
2200 |
+
AND day_or_hour = %s ";
|
2201 |
+
$update_template_successfuly = $wpdb->query( $wpdb->prepare( $query_update_new, $updated_is_active, $email_frequency, $day_or_hour ) );
|
2202 |
+
$woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
|
2203 |
+
$woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
|
2204 |
+
$woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
|
2205 |
+
$woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
|
2206 |
+
$id = trim( $_POST['id'] );
|
2207 |
+
|
2208 |
+
$query_update_latest = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
|
2209 |
+
SET
|
2210 |
+
subject = %s,
|
2211 |
+
body = %s,
|
2212 |
+
is_active = %s,
|
2213 |
+
frequency = %d,
|
2214 |
+
day_or_hour = %s,
|
2215 |
+
template_name = %s,
|
2216 |
+
is_wc_template = %s,
|
2217 |
+
default_template = %d,
|
2218 |
+
wc_email_header = %s
|
2219 |
+
WHERE id = %d ";
|
2220 |
+
$update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update_latest,
|
2221 |
+
$woocommerce_ac_email_subject,
|
2222 |
+
$woocommerce_ac_email_body,
|
2223 |
+
$active,
|
2224 |
+
$email_frequency,
|
2225 |
+
$day_or_hour,
|
2226 |
+
$woocommerce_ac_template_name,
|
2227 |
+
$is_wc_template,
|
2228 |
+
$default_value,
|
2229 |
+
$woocommerce_ac_email_header,
|
2230 |
+
$id )
|
2231 |
+
|
2232 |
+
);
|
2233 |
+
}
|
2234 |
+
} else {
|
2235 |
+
$updated_is_active = '0';
|
2236 |
+
$is_active = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
2237 |
+
$email_frequency = trim( $_POST['email_frequency'] );
|
2238 |
+
$day_or_hour = trim( $_POST['day_or_hour'] );
|
2239 |
+
$is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
|
2240 |
+
|
2241 |
+
$query_update_new = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
|
2242 |
+
SET is_active = %s
|
2243 |
+
WHERE frequency = %d
|
2244 |
+
AND day_or_hour = %s ";
|
2245 |
+
$wpdb->query( $wpdb->prepare( $query_update_new, $updated_is_active, $email_frequency, $day_or_hour ) );
|
2246 |
+
|
2247 |
+
$woocommerce_ac_email_subject = trim( $_POST['woocommerce_ac_email_subject'] );
|
2248 |
+
$woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
|
2249 |
+
$woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
|
2250 |
+
$woocommerce_ac_email_header = trim( $_POST['wcal_wc_email_header'] );
|
2251 |
+
$id = trim( $_POST['id'] );
|
2252 |
+
$check_query = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite`
|
2253 |
+
WHERE is_active= %s
|
2254 |
+
AND frequency = %d
|
2255 |
+
AND day_or_hour= %s ";
|
2256 |
+
$check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $is_active, $email_frequency, $day_or_hour ) );
|
2257 |
+
$default_value = '';
|
2258 |
+
|
2259 |
+
foreach( $check_results as $result_key => $result_value ) {
|
2260 |
+
$default_value = ( empty( $result_value->default_template ) ) ? 0 : $result_value->default_template;
|
2261 |
+
}
|
2262 |
+
|
2263 |
+
$query_update_latest = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
|
2264 |
+
SET
|
2265 |
+
subject = %s,
|
2266 |
+
body = %s,
|
2267 |
+
is_active = %s,
|
2268 |
+
frequency = %d,
|
2269 |
+
day_or_hour = %s,
|
2270 |
+
template_name = %s,
|
2271 |
+
is_wc_template = %s,
|
2272 |
+
default_template = %d,
|
2273 |
+
wc_email_header = %s
|
2274 |
+
WHERE id = %d ";
|
2275 |
+
|
2276 |
+
$update_template_successfuly = $wpdb->query( $wpdb->prepare( $query_update_latest,
|
2277 |
+
$woocommerce_ac_email_subject,
|
2278 |
+
$woocommerce_ac_email_body,
|
2279 |
+
$is_active,
|
2280 |
+
$email_frequency,
|
2281 |
+
$day_or_hour,
|
2282 |
+
$woocommerce_ac_template_name,
|
2283 |
+
$is_wc_template,
|
2284 |
+
$default_value,
|
2285 |
+
$woocommerce_ac_email_header,
|
2286 |
+
$id )
|
2287 |
+
);
|
2288 |
+
}
|
2289 |
+
}
|
2290 |
+
|
2291 |
+
if ( $action == 'emailtemplates' && $mode == 'removetemplate' ) {
|
2292 |
+
$id_remove = $_GET['id'];
|
2293 |
+
$query_remove = "DELETE FROM `".$wpdb->prefix."ac_email_templates_lite` WHERE id= %d ";
|
2294 |
+
$wpdb->query( $wpdb->prepare( $query_remove, $id_remove ) );
|
2295 |
+
}
|
2296 |
+
|
2297 |
+
if ( $action == 'emailtemplates' && $mode == 'activate_template' ) {
|
2298 |
+
$template_id = $_GET['id'];
|
2299 |
+
$current_template_status = $_GET['active_state'];
|
2300 |
+
|
2301 |
+
if( "1" == $current_template_status ) {
|
2302 |
+
$active = "0";
|
2303 |
+
} else {
|
2304 |
+
$active = "1";
|
2305 |
+
|
2306 |
+
$query_update = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite` WHERE id ='" . $template_id . "'";
|
2307 |
+
$get_selected_template_result = $wpdb->get_results( $query_update );
|
2308 |
+
$email_frequncy = $get_selected_template_result[0]->frequency;
|
2309 |
+
$email_day_or_hour = $get_selected_template_result[0]->day_or_hour;
|
2310 |
+
|
2311 |
+
$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 . "' ";
|
2312 |
+
$wcap_updated = $wpdb->query( $query_update );
|
2313 |
+
}
|
2314 |
+
$query_update = "UPDATE `" . $wpdb->prefix . "ac_email_templates_lite`
|
2315 |
SET
|
2316 |
is_active = '" . $active . "'
|
2317 |
WHERE id = '" . $template_id . "' ";
|
2318 |
+
$wpdb->query( $query_update );
|
2319 |
+
|
2320 |
+
wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&action=emailtemplates' ) );
|
2321 |
+
}
|
2322 |
+
|
2323 |
+
if( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' && ( isset( $insert_template_successfuly ) && $insert_template_successfuly != '' ) ) { ?>
|
2324 |
+
<div id="message" class="updated fade"><p><strong><?php _e( 'The Email Template has been successfully added.', 'woocommerce-ac' ); ?></strong></p></div>
|
2325 |
+
<?php } else if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'save' && ( isset( $insert_template_successfuly ) && $insert_template_successfuly == '' ) ) {
|
2326 |
+
?>
|
2327 |
+
<div id="message" class="error fade"><p><strong><?php _e( ' There was a problem adding the email template. Please contact the plugin author via <a href= "https://wordpress.org/support/plugin/woocommerce-abandoned-cart">support forum</a>.', 'woocommerce-ac' ); ?></strong></p></div>
|
2328 |
+
<?php
|
2329 |
+
}
|
2330 |
|
2331 |
+
if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' && isset($update_template_successfuly) && $update_template_successfuly >= 0 ) { ?>
|
2332 |
+
<div id="message" class="updated fade"><p><strong><?php _e( 'The Email Template has been successfully updated.', 'woocommerce-ac' ); ?></strong></p></div>
|
2333 |
+
<?php } else if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' && isset($update_template_successfuly) && $update_template_successfuly === false ){
|
2334 |
+
?>
|
2335 |
+
<div id="message" class="error fade"><p><strong><?php _e( ' There was a problem updating the email template. Please contact the plugin author via <a href= "https://wordpress.org/support/plugin/woocommerce-abandoned-cart">support forum</a>.', 'woocommerce-ac' ); ?></strong></p></div>
|
2336 |
+
<?php
|
2337 |
+
}
|
2338 |
+
?>
|
2339 |
+
<div class="tablenav">
|
2340 |
+
<p style="float:left;">
|
2341 |
+
<a cursor: pointer; href="<?php echo "admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=addnewtemplate"; ?>" class="button-secondary"><?php _e( 'Add New Template', 'woocommerce-ac' ); ?></a>
|
2342 |
+
</p>
|
2343 |
+
|
2344 |
+
<?php
|
2345 |
+
/* From here you can do whatever you want with the data from the $result link. */
|
2346 |
include_once('includes/classes/class-wcal-templates-table.php');
|
2347 |
$wcal_template_list = new WCAL_Templates_Table();
|
2348 |
$wcal_template_list->wcal_templates_prepare_items();
|
2356 |
</div>
|
2357 |
</div>
|
2358 |
<?php
|
2359 |
+
} elseif ($action == 'stats' || $action == '') {
|
2360 |
+
?>
|
2361 |
+
<p>
|
2362 |
+
<script language='javascript'>
|
2363 |
+
jQuery( document ).ready( function()
|
2364 |
+
{
|
2365 |
+
jQuery( '#duration_select' ).change( function()
|
2366 |
+
{
|
2367 |
+
var group_name = jQuery( '#duration_select' ).val();
|
2368 |
+
var today = new Date();
|
2369 |
+
var start_date = "";
|
2370 |
+
var end_date = "";
|
2371 |
+
if ( group_name == "yesterday" )
|
2372 |
+
{
|
2373 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 1 );
|
2374 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 1 );
|
2375 |
+
}
|
2376 |
+
else if ( group_name == "today")
|
2377 |
+
{
|
2378 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2379 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2380 |
+
}
|
2381 |
+
else if ( group_name == "last_seven" )
|
2382 |
+
{
|
2383 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 7 );
|
2384 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2385 |
+
}
|
2386 |
+
else if ( group_name == "last_fifteen" )
|
2387 |
+
{
|
2388 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 15 );
|
2389 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2390 |
+
}
|
2391 |
+
else if ( group_name == "last_thirty" )
|
2392 |
+
{
|
2393 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 30 );
|
2394 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2395 |
+
}
|
2396 |
+
else if ( group_name == "last_ninety" )
|
2397 |
+
{
|
2398 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 90 );
|
2399 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2400 |
+
}
|
2401 |
+
else if ( group_name == "last_year_days" )
|
2402 |
+
{
|
2403 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 365 );
|
2404 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2405 |
+
}
|
2406 |
+
|
2407 |
+
var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
2408 |
+
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
2409 |
+
|
2410 |
+
var start_date_value = start_date.getDate() + " " + monthNames[start_date.getMonth()] + " " + start_date.getFullYear();
|
2411 |
+
var end_date_value = end_date.getDate() + " " + monthNames[end_date.getMonth()] + " " + end_date.getFullYear();
|
2412 |
+
|
2413 |
+
jQuery( '#start_date' ).val( start_date_value );
|
2414 |
+
jQuery( '#end_date' ).val( end_date_value );
|
2415 |
+
|
2416 |
+
});
|
2417 |
+
});
|
2418 |
+
</script>
|
2419 |
+
<?php
|
2420 |
+
|
2421 |
+
if ( isset( $_POST['duration_select'] ) ){
|
2422 |
+
$duration_range = $_POST['duration_select'];
|
2423 |
+
} else {
|
2424 |
+
$duration_range = "";
|
2425 |
+
}
|
2426 |
+
if ( $duration_range == "" ) {
|
2427 |
+
if ( isset( $_GET['duration_select'] ) ){
|
2428 |
+
$duration_range = $_GET['duration_select'];
|
2429 |
+
}
|
2430 |
+
}
|
2431 |
+
if ($duration_range == "") $duration_range = "last_seven";
|
2432 |
+
|
2433 |
+
_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');
|
2434 |
+
?>
|
2435 |
+
<div id="recovered_stats" class="postbox" style="display:block">
|
2436 |
+
<div class="inside">
|
2437 |
+
<form method="post" action="admin.php?page=woocommerce_ac_page&action=stats" id="ac_stats">
|
2438 |
+
<select id="duration_select" name="duration_select" >
|
2439 |
+
<?php
|
2440 |
+
foreach ( $this->duration_range_select as $key => $value ) {
|
2441 |
+
$sel = "";
|
2442 |
+
if ($key == $duration_range) {
|
2443 |
+
$sel = " selected ";
|
2444 |
+
}
|
2445 |
+
echo"<option value='$key' $sel> $value </option>";
|
2446 |
+
}
|
2447 |
+
$date_sett = $this->start_end_dates[ $duration_range ];
|
2448 |
+
?>
|
2449 |
+
</select>
|
2450 |
+
<script type="text/javascript">
|
2451 |
+
jQuery( document ).ready( function()
|
2452 |
+
{
|
2453 |
+
var formats = ["d.m.y", "d M yy","MM d, yy"];
|
2454 |
+
jQuery( "#start_date" ).datepicker( { dateFormat: formats[1] } );
|
2455 |
+
});
|
2456 |
+
|
2457 |
+
jQuery( document ).ready( function()
|
2458 |
+
{
|
2459 |
+
var formats = ["d.m.y", "d M yy","MM d, yy"];
|
2460 |
+
jQuery( "#end_date" ).datepicker( { dateFormat: formats[1] } );
|
2461 |
+
});
|
2462 |
+
</script>
|
2463 |
+
<?php
|
2464 |
include_once('includes/classes/class-wcal-recover-orders-table.php');
|
2465 |
$wcal_recover_orders_list = new WCAL_Recover_Orders_Table();
|
2466 |
$wcal_recover_orders_list->wcal_recovered_orders_prepare_items();
|
2524 |
</form>
|
2525 |
</div>
|
2526 |
<?php
|
2527 |
+
} elseif ( $action == 'orderdetails' ) {
|
2528 |
+
global $woocommerce;
|
2529 |
$ac_order_id = $_GET['id'];
|
2530 |
?>
|
2531 |
<p> </p>
|
2707 |
$name = $variation->get_formatted_name() ;
|
2708 |
$explode_all = explode ( "–", $name );
|
2709 |
if( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
2710 |
+
|
2711 |
+
$attributes = $explode_all[1];
|
2712 |
+
$explode_attributes = explode( "(#" , $attributes) ;
|
2713 |
+
if (isset($explode_attributes [0])){
|
2714 |
+
$add_product_name = $product_name . "," . $explode_attributes[0];
|
2715 |
+
$pro_name_variation = (array) $add_product_name;
|
2716 |
+
}
|
2717 |
}else{
|
2718 |
+
$pro_name_variation = array_slice( $explode_all, 1, -1 );
|
2719 |
}
|
2720 |
$product_name_with_variable = '';
|
2721 |
$explode_many_varaition = array();
|
2822 |
$wcal_product_report_list = new WCAL_Product_Report_Table();
|
2823 |
$wcal_product_report_list->wcal_product_report_prepare_items();
|
2824 |
?>
|
2825 |
+
<div class="wrap">
|
2826 |
+
<form id="wcal-sent-emails" method="get" >
|
2827 |
+
<input type="hidden" name="page" value="woocommerce_ac_page" />
|
2828 |
+
<input type="hidden" name="action" value="report" />
|
2829 |
<?php $wcal_product_report_list->display(); ?>
|
2830 |
</form>
|
2831 |
</div>
|
2832 |
<?php }
|
2833 |
}
|
2834 |
echo( "</table>" );
|
2835 |
+
|
2836 |
+
if ( isset( $_GET['action'] ) ) {
|
2837 |
+
$action = $_GET['action'];
|
2838 |
+
}
|
2839 |
+
if ( isset( $_GET['mode'] ) ){
|
2840 |
+
$mode = $_GET['mode'];
|
2841 |
+
}
|
2842 |
+
if ( $action == 'emailtemplates' && ( $mode == 'addnewtemplate' || $mode == 'edittemplate' ) ) {
|
2843 |
+
if ( $mode=='edittemplate' ) {
|
2844 |
+
$edit_id = $_GET['id'];
|
2845 |
+
$query = "SELECT wpet . * FROM `".$wpdb->prefix."ac_email_templates_lite` AS wpet WHERE id = %d ";
|
2846 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query, $edit_id ) );
|
2847 |
+
}
|
2848 |
+
$active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
2849 |
+
?>
|
2850 |
+
<div id="content">
|
2851 |
+
<form method="post" action="admin.php?page=woocommerce_ac_page&action=emailtemplates" id="ac_settings">
|
2852 |
+
<input type="hidden" name="mode" value="<?php echo $mode;?>" />
|
2853 |
+
<?php
|
2854 |
+
$id_by = "";
|
2855 |
+
if ( isset( $_GET['id'] ) ) {
|
2856 |
+
$id_by = $_GET['id'];
|
2857 |
+
}
|
2858 |
+
?>
|
2859 |
+
<input type="hidden" name="id" value="<?php echo $id_by ;?>" />
|
2860 |
+
<?php
|
2861 |
+
$button_mode = "save";
|
2862 |
+
$display_message = "Add Email Template";
|
2863 |
+
if ( $mode == 'edittemplate' ) {
|
2864 |
+
$button_mode = "update";
|
2865 |
+
$display_message = "Edit Email Template";
|
2866 |
+
}
|
2867 |
+
print'<input type="hidden" name="ac_settings_frm" value="'.$button_mode.'">';?>
|
2868 |
+
<div id="poststuff">
|
2869 |
+
<div> <!-- <div class="postbox" > -->
|
2870 |
+
<h3 class="hndle"><?php _e( $display_message, 'woocommerce-ac' ); ?></h3>
|
2871 |
+
<div>
|
2872 |
+
<table class="form-table" id="addedit_template">
|
2873 |
+
<tr>
|
2874 |
+
<th>
|
2875 |
+
<label for="woocommerce_ac_template_name"><b><?php _e( 'Template Name:', 'woocommerce-ac');?></b></label>
|
2876 |
+
</th>
|
2877 |
+
<td>
|
2878 |
+
<?php
|
2879 |
+
$template_name = "";
|
2880 |
+
if( $mode == 'edittemplate' ) {
|
2881 |
+
$template_name = $results[0]->template_name;
|
2882 |
+
}
|
2883 |
+
print'<input type="text" name="woocommerce_ac_template_name" id="woocommerce_ac_template_name" class="regular-text" value="'.$template_name.'">';?>
|
2884 |
+
<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" />
|
2885 |
+
</td>
|
2886 |
+
</tr>
|
2887 |
+
|
2888 |
+
<tr>
|
2889 |
+
<th>
|
2890 |
+
<label for="woocommerce_ac_email_subject"><b><?php _e( 'Subject:', 'woocommerce-ac' ); ?></b></label>
|
2891 |
+
</th>
|
2892 |
+
<td>
|
2893 |
+
<?php
|
2894 |
+
$subject_edit = "";
|
2895 |
+
if ( $mode == 'edittemplate' ) {
|
2896 |
+
$subject_edit= stripslashes ( $results[0]->subject );
|
2897 |
+
}
|
2898 |
+
print'<input type="text" name="woocommerce_ac_email_subject" id="woocommerce_ac_email_subject" class="regular-text" value="'.$subject_edit.'">';?>
|
2899 |
+
<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" />
|
2900 |
+
</td>
|
2901 |
+
</tr>
|
2902 |
|
2903 |
+
<tr>
|
2904 |
+
<th>
|
2905 |
+
<label for="woocommerce_ac_email_body"><b><?php _e( 'Email Body:', 'woocommerce-ac' ); ?></b></label>
|
2906 |
+
</th>
|
2907 |
+
<td>
|
2908 |
+
<?php
|
2909 |
+
$initial_data = "";
|
2910 |
+
if ( $mode == 'edittemplate' ) {
|
2911 |
+
$initial_data = stripslashes( $results[0]->body );
|
2912 |
+
}
|
2913 |
+
|
2914 |
+
$initial_data = str_replace ( "My document title", "", $initial_data );
|
2915 |
+
wp_editor(
|
2916 |
+
$initial_data,
|
2917 |
+
'woocommerce_ac_email_body',
|
2918 |
+
array(
|
2919 |
+
'media_buttons' => true,
|
2920 |
+
'textarea_rows' => 15,
|
2921 |
+
'tabindex' => 4,
|
2922 |
+
'tinymce' => array(
|
2923 |
+
'theme_advanced_buttons1' => 'bold,italic,underline,|,bullist,numlist,blockquote,|,link,unlink,|,spellchecker,fullscreen,|,formatselect,styleselect'
|
2924 |
+
),
|
2925 |
+
)
|
2926 |
+
);
|
2927 |
+
|
2928 |
+
?>
|
2929 |
+
<?php echo stripslashes( get_option( 'woocommerce_ac_email_body' ) ); ?>
|
2930 |
+
<span class="description"><?php
|
2931 |
+
echo __( 'Message to be sent in the reminder email.', 'woocommerce-ac' );
|
2932 |
+
?></span>
|
2933 |
+
</td>
|
2934 |
+
</tr>
|
2935 |
+
|
2936 |
+
<tr>
|
2937 |
<th>
|
2938 |
<label for="is_wc_template"><b><?php _e( 'Use WooCommerce Template Style:', 'woocommerce-ac' ); ?></b></label>
|
2939 |
</th>
|
3003 |
</td>
|
3004 |
</tr>
|
3005 |
|
3006 |
+
<tr>
|
3007 |
+
<th>
|
3008 |
+
<label for="woocommerce_ac_email_frequency"><b><?php _e( 'Send this email:', 'woocommerce-ac' ); ?></b></label>
|
3009 |
+
</th>
|
3010 |
+
<td>
|
3011 |
+
<select name="email_frequency" id="email_frequency">
|
3012 |
+
<?php
|
3013 |
+
$frequency_edit = "";
|
3014 |
+
if( $mode == 'edittemplate' ) {
|
3015 |
+
$frequency_edit = $results[0]->frequency;
|
3016 |
+
}
|
3017 |
+
for ( $i = 1; $i < 4; $i++ ) {
|
3018 |
+
printf( "<option %s value='%s'>%s</option>\n",
|
3019 |
+
selected( $i, $frequency_edit, false ),
|
3020 |
+
esc_attr( $i ),
|
3021 |
+
$i
|
3022 |
+
);
|
3023 |
+
}
|
3024 |
+
?>
|
3025 |
+
</select>
|
3026 |
|
3027 |
+
<select name="day_or_hour" id="day_or_hour">
|
3028 |
+
<?php
|
3029 |
+
$days_or_hours_edit = "";
|
3030 |
+
if ( $mode == 'edittemplate')
|
3031 |
+
{
|
3032 |
+
$days_or_hours_edit = $results[0]->day_or_hour;
|
3033 |
+
}
|
3034 |
+
$days_or_hours = array(
|
3035 |
+
'Days' => 'Day(s)',
|
3036 |
+
'Hours' => 'Hour(s)'
|
3037 |
+
);
|
3038 |
+
foreach( $days_or_hours as $k => $v )
|
3039 |
+
{
|
3040 |
+
printf( "<option %s value='%s'>%s</option>\n",
|
3041 |
+
selected( $k, $days_or_hours_edit, false ),
|
3042 |
+
esc_attr( $k ),
|
3043 |
+
$v
|
3044 |
+
);
|
3045 |
+
}
|
3046 |
+
?>
|
3047 |
+
</select>
|
3048 |
+
<span class="description">
|
3049 |
+
<?php echo __( 'after cart is abandoned.', 'woocommerce-ac' ); ?>
|
3050 |
+
</span>
|
3051 |
+
</td>
|
3052 |
+
</tr>
|
3053 |
+
|
3054 |
+
<tr>
|
3055 |
+
<th>
|
3056 |
+
<label for="woocommerce_ac_email_preview"><b><?php _e( 'Send a test email to:', 'woocommerce-ac' ); ?></b></label>
|
3057 |
+
</th>
|
3058 |
+
<td>
|
3059 |
+
<input type="text" id="send_test_email" name="send_test_email" class="regular-text" >
|
3060 |
+
<input type="button" value="Send a test email" id="preview_email" onclick="javascript:void(0);">
|
3061 |
+
<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" />
|
3062 |
+
<div id="preview_email_sent_msg" style="display:none;"></div>
|
3063 |
+
</td>
|
3064 |
+
</tr>
|
3065 |
+
</table>
|
3066 |
+
</div>
|
3067 |
+
</div>
|
3068 |
+
</div>
|
3069 |
+
<p class="submit">
|
3070 |
+
<?php
|
3071 |
+
$button_value = "Save Changes";
|
3072 |
+
if ( $mode == 'edittemplate' )
|
3073 |
+
{
|
3074 |
+
$button_value = "Update Changes";
|
3075 |
+
}?>
|
3076 |
+
<input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e( $button_value, 'woocommerce-ac' ); ?>" />
|
3077 |
+
</p>
|
3078 |
+
</form>
|
3079 |
+
</div>
|
3080 |
+
<?php
|
3081 |
+
}
|
3082 |
+
}
|
3083 |
+
function wcal_admin_footer_text( $footer_text ) {
|
3084 |
+
if ( ! current_user_can( 'manage_woocommerce' ) ) {
|
3085 |
+
return;
|
3086 |
+
}
|
3087 |
+
$current_screen = get_current_screen();
|
3088 |
+
$wc_pages = wc_get_screen_ids();
|
3089 |
+
// Set only wc pages
|
3090 |
+
$wc_pages = array_flip( $wc_pages );
|
3091 |
+
if ( isset( $wc_pages['profile'] ) ) {
|
3092 |
+
unset( $wc_pages['profile'] );
|
3093 |
+
}
|
3094 |
+
if ( isset( $wc_pages['user-edit'] ) ) {
|
3095 |
+
unset( $wc_pages['user-edit'] );
|
3096 |
+
}
|
3097 |
+
$wc_pages = array_flip( $wc_pages );
|
3098 |
+
$wc_pages[] = 'woocommerce_page_woocommerce_ac_page';
|
3099 |
+
// Check to make sure we're on a WooCommerce admin page
|
3100 |
+
if ( isset( $current_screen->id ) && apply_filters( 'woocommerce_display_admin_footer_text', in_array( $current_screen->id, $wc_pages ) ) ) {
|
3101 |
+
// Change the footer text
|
3102 |
+
if ( ! get_option( 'woocommerce_admin_footer_text_rated' ) ) {
|
3103 |
+
$footer_text = sprintf( __( 'If you like <strong>Abandoned Cart Lite for WooCommerce</strong> then please <a href="https://wordpress.org/support/plugin/woocommerce-abandoned-cart/reviews/">leave a review </a> for us and let us know how we are doing. A review will help us immensely.', 'woocommerce-ac' ) );
|
3104 |
+
wc_enqueue_js( "
|
3105 |
+
jQuery( 'a.wc-rating-link' ).click( function() {
|
3106 |
+
jQuery.post( '" . WC()->ajax_url() . "', { action: 'woocommerce_rated' } );
|
3107 |
+
jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) );
|
3108 |
+
});
|
3109 |
+
" );
|
3110 |
} else {
|
3111 |
$footer_text = __( 'Thank you for selling with Abandoned Cart Lite for WooCommerce.', 'woocommerce-ac' );
|
3112 |
}
|
3113 |
+
}
|
3114 |
+
return $footer_text;
|
3115 |
+
}
|
3116 |
+
|
3117 |
function bubble_sort_function( $unsort_array, $order ) {
|
3118 |
$temp = array();
|
3119 |
foreach ( $unsort_array as $key => $value )
|
3128 |
unset( $temp );
|
3129 |
return $array;
|
3130 |
}
|
3131 |
+
|
3132 |
+
function wcal_action_send_preview() {
|
3133 |
+
?>
|
3134 |
+
<script type="text/javascript" >
|
3135 |
+
jQuery( document ).ready( function( $ )
|
3136 |
+
{
|
3137 |
+
$( "table#addedit_template input#preview_email" ).click( function()
|
3138 |
+
{
|
3139 |
+
var email_body = '';
|
3140 |
+
if ( jQuery("#wp-woocommerce_ac_email_body-wrap").hasClass( "tmce-active" ) ) {
|
3141 |
email_body = tinyMCE.get('woocommerce_ac_email_body').getContent();
|
3142 |
} else {
|
3143 |
email_body = jQuery('#woocommerce_ac_email_body').val();
|
3144 |
}
|
3145 |
+
var subject_email_preview = $( '#woocommerce_ac_email_subject' ).val();
|
3146 |
+
var body_email_preview = email_body;
|
3147 |
+
var send_email_id = $( '#send_test_email' ).val();
|
3148 |
+
var is_wc_template = document.getElementById( "is_wc_template" ).checked;
|
3149 |
+
var wc_template_header = $( '#wcal_wc_email_header' ).val() != '' ? $( '#wcal_wc_email_header' ).val() : 'Abandoned cart reminder';
|
3150 |
+
var data = {
|
3151 |
+
subject_email_preview: subject_email_preview,
|
3152 |
+
body_email_preview : body_email_preview,
|
3153 |
+
send_email_id : send_email_id,
|
3154 |
+
is_wc_template : is_wc_template,
|
3155 |
+
wc_template_header : wc_template_header,
|
3156 |
+
action : 'wcal_preview_email_sent'
|
3157 |
+
};
|
3158 |
+
|
3159 |
+
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
3160 |
+
$.post( ajaxurl, data, function( response )
|
3161 |
+
{
|
3162 |
+
if ( 'not sent' == response ) {
|
3163 |
+
$( "#preview_email_sent_msg" ).html( "Test email is not sent as the Email body is empty." );
|
3164 |
+
$( "#preview_email_sent_msg" ).fadeIn();
|
3165 |
+
setTimeout( function(){$( "#preview_email_sent_msg" ).fadeOut();}, 4000 );
|
3166 |
+
} else {
|
3167 |
+
$( "#preview_email_sent_msg" ).html( "<img src='<?php echo plugins_url(); ?>/woocommerce-abandoned-cart/assets/images/check.jpg'> Email has been sent successfully." );
|
3168 |
+
$( "#preview_email_sent_msg" ).fadeIn();
|
3169 |
+
setTimeout( function(){$( "#preview_email_sent_msg" ).fadeOut();}, 3000 );
|
3170 |
+
}
|
3171 |
+
//alert('Got this from the server: ' + response);
|
3172 |
+
});
|
3173 |
+
});
|
3174 |
+
});
|
3175 |
+
</script>
|
3176 |
+
<?php
|
3177 |
+
}
|
3178 |
+
// Send Test Email
|
3179 |
+
function wcal_preview_email_sent() {
|
3180 |
+
if ( '' != $_POST['body_email_preview'] ) {
|
3181 |
+
$from_email_name = get_option ( 'wcal_from_name' );
|
3182 |
+
$reply_name_preview = get_option ( 'wcal_from_email' );
|
3183 |
+
$from_email_preview = get_option ( 'wcal_reply_email' );
|
3184 |
+
$subject_email_preview = stripslashes ( $_POST['subject_email_preview'] );
|
3185 |
+
$subject_email_preview = convert_smilies ( $subject_email_preview );
|
3186 |
+
$body_email_preview = convert_smilies ( $_POST['body_email_preview'] );
|
3187 |
+
$is_wc_template = $_POST['is_wc_template'];
|
3188 |
+
$wc_template_header = stripslashes( $_POST['wc_template_header'] );
|
3189 |
+
$body_email_preview = str_replace( '{{customer.firstname}}', 'John', $body_email_preview );
|
3190 |
+
$body_email_preview = str_replace( '{{customer.lastname}}', 'Doe', $body_email_preview );
|
3191 |
+
$body_email_preview = str_replace( '{{customer.fullname}}', 'John'." ".'Doe', $body_email_preview );
|
3192 |
+
$current_time_stamp = current_time( 'timestamp' );
|
3193 |
+
$date_format = date_i18n( get_option( 'date_format' ), $current_time_stamp );
|
3194 |
+
$time_format = date_i18n( get_option( 'time_format' ), $current_time_stamp );
|
3195 |
+
$test_date = $date_format . ' ' . $time_format;
|
3196 |
+
$body_email_preview = str_replace( '{{cart.abandoned_date}}', $test_date, $body_email_preview );
|
3197 |
+
$cart_url = wc_get_page_permalink( 'cart' );
|
3198 |
+
$body_email_preview = str_replace( '{{cart.link}}', $cart_url, $body_email_preview );
|
3199 |
+
$body_email_preview = str_replace( '{{cart.unsubscribe}}', '<a href=#>unsubscribe</a>', $body_email_preview );
|
3200 |
+
if ( class_exists( 'WP_Better_Emails' ) ) {
|
3201 |
+
$headers = "From: " . $from_email_name . " <" . $from_email_preview . ">" . "\r\n";
|
3202 |
+
$headers .= "Content-Type: text/plain" . "\r\n";
|
3203 |
+
$headers .= "Reply-To: " . $reply_name_preview . " " . "\r\n";
|
3204 |
+
$var = '<table width = 100%>
|
3205 |
+
<tr> <td colspan="5"> <h3>'.__( "Your Shopping Cart", "woocommerce-ac" ).'</h3> </td></tr>
|
3206 |
<tr align="center">
|
3207 |
<th>'.__( "Item", "woocommerce-ac" ).'</th>
|
3208 |
<th>'.__( "Name", "woocommerce-ac" ).'</th>
|
3210 |
<th>'.__( "Price", "woocommerce-ac" ).'</th>
|
3211 |
<th>'.__( "Line Subtotal", "woocommerce-ac" ).'</th>
|
3212 |
</tr>
|
3213 |
+
<tr align="center">
|
3214 |
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/shoes.jpg"/></td>
|
3215 |
<td>'.__( "Men\'\s Formal Shoes", "woocommerce-ac" ).'</td>
|
3216 |
<td>1</td>
|
3232 |
<td>$200</td>
|
3233 |
</tr>
|
3234 |
</table>';
|
3235 |
+
} else {
|
3236 |
+
$headers = "From: " . $from_email_name . " <" . $from_email_preview . ">" . "\r\n";
|
3237 |
+
$headers .= "Content-Type: text/html" . "\r\n";
|
3238 |
+
$headers .= "Reply-To: " . $reply_name_preview . " " . "\r\n";
|
3239 |
+
$var = '<h3>'.__( "Your Shopping Cart", "woocommerce-ac" ).'</h3>
|
3240 |
<table border="0" cellpadding="10" cellspacing="0" class="templateDataTable">
|
3241 |
<tr align="center">
|
3242 |
<th>'.__( "Item", "woocommerce-ac" ).'</th>
|
3245 |
<th>'.__( "Price", "woocommerce-ac" ).'</th>
|
3246 |
<th>'.__( "Line Subtotal", "woocommerce-ac" ).'</th>
|
3247 |
</tr>
|
3248 |
+
<tr align="center">
|
3249 |
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/shoes.jpg"/></td>
|
3250 |
<td>'.__( "Men\'\s Formal Shoes", "woocommerce-ac" ).'</td>
|
3251 |
<td>1</td>
|
3267 |
<td>$200</td>
|
3268 |
</tr>
|
3269 |
</table>';
|
3270 |
+
}
|
3271 |
+
$body_email_preview = str_replace( '{{products.cart}}', $var, $body_email_preview );
|
3272 |
+
if ( isset( $_POST['send_email_id'] ) ) {
|
3273 |
+
$to_email_preview = $_POST['send_email_id'];
|
3274 |
+
} else {
|
3275 |
+
$to_email_preview = "";
|
3276 |
+
}
|
3277 |
+
$user_email_from = get_option( 'admin_email' );
|
3278 |
+
$body_email_final_preview = stripslashes( $body_email_preview );
|
3279 |
+
|
3280 |
+
if ( isset( $is_wc_template ) && "true" == $is_wc_template ) {
|
3281 |
+
ob_start();
|
3282 |
+
// Get email heading
|
3283 |
+
wc_get_template( 'emails/email-header.php', array( 'email_heading' => $wc_template_header ) );
|
3284 |
+
$email_body_template_header = ob_get_clean();
|
3285 |
|
3286 |
+
ob_start();
|
3287 |
+
wc_get_template( 'emails/email-footer.php' );
|
3288 |
+
$email_body_template_footer = ob_get_clean();
|
3289 |
+
|
3290 |
+
$final_email_body = $email_body_template_header . $body_email_final_preview . $email_body_template_footer;
|
3291 |
+
|
3292 |
+
wc_mail( $to_email_preview, $subject_email_preview, $final_email_body , $headers );
|
3293 |
+
}
|
3294 |
+
else {
|
3295 |
+
wp_mail( $to_email_preview, $subject_email_preview, stripslashes( $body_email_preview ), $headers );
|
3296 |
+
}
|
3297 |
+
echo "email sent";
|
3298 |
+
die();
|
3299 |
+
} else {
|
3300 |
+
echo "not sent";
|
3301 |
+
die();
|
3302 |
+
}
|
3303 |
+
}
|
3304 |
+
}
|
3305 |
+
}
|
3306 |
$woocommerce_abandon_cart = new woocommerce_abandon_cart_lite();
|
3307 |
?>
|