Version Description
- Some warnings were displayed on Email Templates tab. These have been fixed.
Download this release
Release Info
Developer | ashokrane |
Plugin | Abandoned Cart Lite for WooCommerce |
Version | 2.5.1 |
Comparing to | |
See all releases |
Code changes from version 2.4 to 2.5.1
- cron/send_email.php +51 -8
- default-settings.php +56 -0
- images/spectre.jpg +0 -0
- js/abandoncart_plugin_button.js +6 -1
- readme.txt +22 -2
- views/wacp-email-template-preview.php +52 -0
- views/wacp-wc-email-template-preview.php +47 -0
- woocommerce-ac.php +592 -200
cron/send_email.php
CHANGED
@@ -25,9 +25,9 @@ require_once $path . 'wp-load.php';
|
|
25 |
|
26 |
public function __construct() {
|
27 |
|
28 |
-
$this->cart_settings_cron =
|
29 |
|
30 |
-
$this->cart_abandon_cut_off_time_cron = ( $this->cart_settings_cron
|
31 |
}
|
32 |
|
33 |
/*-----------------------------------------------------------------------------------*/
|
@@ -95,6 +95,7 @@ require_once $path . 'wp-load.php';
|
|
95 |
$query_records = "SELECT DISTINCT user_id FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE user_type = 'REGISTERED' AND cart_ignored = '0' AND recovered_cart = '0'";
|
96 |
$results_list = $wpdb->get_results( $query_records );
|
97 |
|
|
|
98 |
foreach ( $results_list as $key => $value ) {
|
99 |
$user_id = $value->user_id;
|
100 |
$query_email = '';
|
@@ -107,9 +108,11 @@ require_once $path . 'wp-load.php';
|
|
107 |
// non-multisite - regular table name
|
108 |
$query_email = "SELECT user_email FROM `".$wpdb->prefix."users` WHERE ID = %d";
|
109 |
}
|
110 |
-
|
|
|
111 |
$results_email = $wpdb->get_results( $wpdb->prepare( $query_email, $user_id ) );
|
112 |
|
|
|
113 |
$query_email_id = "SELECT post_id FROM `" . $wpdb->prefix . "postmeta` WHERE meta_key = '_billing_email' AND meta_value = %s";
|
114 |
$results_query_email = $wpdb->get_results( $wpdb->prepare( $query_email_id, $results_email[0]->user_email ) );
|
115 |
|
@@ -145,9 +148,9 @@ require_once $path . 'wp-load.php';
|
|
145 |
}
|
146 |
|
147 |
//Grab the cart abandoned cut-off time from database.
|
148 |
-
$cart_settings =
|
149 |
|
150 |
-
$cart_abandon_cut_off_time =
|
151 |
|
152 |
//Fetch all active templates present in the system
|
153 |
$query = "SELECT wpet . *
|
@@ -168,7 +171,7 @@ require_once $path . 'wp-load.php';
|
|
168 |
{
|
169 |
$time_to_send_template_after = $value->frequency * $hour_seconds;
|
170 |
}
|
171 |
-
|
172 |
$carts = $this->get_carts( $time_to_send_template_after, $cart_abandon_cut_off_time );
|
173 |
|
174 |
$email_frequency = $value->frequency;
|
@@ -178,6 +181,7 @@ require_once $path . 'wp-load.php';
|
|
178 |
$headers[] = "From: ".$value->from_name." <".$user_email_from.">"."\r\n";
|
179 |
$headers[] = "Content-Type: text/html"."\r\n";
|
180 |
$template_id = $value->id;
|
|
|
181 |
|
182 |
foreach ( $carts as $key => $value )
|
183 |
{
|
@@ -186,6 +190,15 @@ require_once $path . 'wp-load.php';
|
|
186 |
$query_guest = "SELECT billing_first_name, billing_last_name, email_id FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d";
|
187 |
$results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $value->user_id ) );
|
188 |
$value->user_email = $results_guest[0]->email_id;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
}
|
190 |
|
191 |
$cart_info_db_field = json_decode( $value->abandoned_cart_info );
|
@@ -218,6 +231,14 @@ require_once $path . 'wp-load.php';
|
|
218 |
$email_body = str_replace( "{{customer.fullname}}", get_user_meta( $value->user_id, 'first_name', true )." ".get_user_meta( $value->user_id, 'last_name', true ), $email_body );
|
219 |
}
|
220 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
$query_sent = "INSERT INTO `".$wpdb->prefix."ac_sent_history_lite` ( template_id, abandoned_order_id, sent_time, sent_email_id )
|
222 |
VALUES ( %s, %s, '".current_time( 'mysql' )."', %s )";
|
223 |
|
@@ -312,8 +333,30 @@ require_once $path . 'wp-load.php';
|
|
312 |
$user_email = $value->user_email;
|
313 |
|
314 |
$email_body_final = stripslashes( $email_body );
|
315 |
-
|
316 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
}
|
318 |
|
319 |
}
|
25 |
|
26 |
public function __construct() {
|
27 |
|
28 |
+
$this->cart_settings_cron = get_option( 'ac_lite_cart_abandoned_time' );
|
29 |
|
30 |
+
$this->cart_abandon_cut_off_time_cron = ( $this->cart_settings_cron ) * 60;
|
31 |
}
|
32 |
|
33 |
/*-----------------------------------------------------------------------------------*/
|
95 |
$query_records = "SELECT DISTINCT user_id FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE user_type = 'REGISTERED' AND cart_ignored = '0' AND recovered_cart = '0'";
|
96 |
$results_list = $wpdb->get_results( $query_records );
|
97 |
|
98 |
+
|
99 |
foreach ( $results_list as $key => $value ) {
|
100 |
$user_id = $value->user_id;
|
101 |
$query_email = '';
|
108 |
// non-multisite - regular table name
|
109 |
$query_email = "SELECT user_email FROM `".$wpdb->prefix."users` WHERE ID = %d";
|
110 |
}
|
111 |
+
|
112 |
+
|
113 |
$results_email = $wpdb->get_results( $wpdb->prepare( $query_email, $user_id ) );
|
114 |
|
115 |
+
|
116 |
$query_email_id = "SELECT post_id FROM `" . $wpdb->prefix . "postmeta` WHERE meta_key = '_billing_email' AND meta_value = %s";
|
117 |
$results_query_email = $wpdb->get_results( $wpdb->prepare( $query_email_id, $results_email[0]->user_email ) );
|
118 |
|
148 |
}
|
149 |
|
150 |
//Grab the cart abandoned cut-off time from database.
|
151 |
+
$cart_settings = get_option( 'ac_lite_cart_abandoned_time' );
|
152 |
|
153 |
+
$cart_abandon_cut_off_time = $cart_settings * 60;
|
154 |
|
155 |
//Fetch all active templates present in the system
|
156 |
$query = "SELECT wpet . *
|
171 |
{
|
172 |
$time_to_send_template_after = $value->frequency * $hour_seconds;
|
173 |
}
|
174 |
+
|
175 |
$carts = $this->get_carts( $time_to_send_template_after, $cart_abandon_cut_off_time );
|
176 |
|
177 |
$email_frequency = $value->frequency;
|
181 |
$headers[] = "From: ".$value->from_name." <".$user_email_from.">"."\r\n";
|
182 |
$headers[] = "Content-Type: text/html"."\r\n";
|
183 |
$template_id = $value->id;
|
184 |
+
$is_wc_template = $value->is_wc_template;
|
185 |
|
186 |
foreach ( $carts as $key => $value )
|
187 |
{
|
190 |
$query_guest = "SELECT billing_first_name, billing_last_name, email_id FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d";
|
191 |
$results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $value->user_id ) );
|
192 |
$value->user_email = $results_guest[0]->email_id;
|
193 |
+
}else{
|
194 |
+
|
195 |
+
$user_id = $value->user_id;
|
196 |
+
$key = 'billing_email';
|
197 |
+
$single = true;
|
198 |
+
$user_biiling_email = get_user_meta( $user_id, $key, $single );
|
199 |
+
if( isset( $user_biiling_email ) && $user_biiling_email != '' ){
|
200 |
+
$value->user_email = $user_biiling_email;
|
201 |
+
}
|
202 |
}
|
203 |
|
204 |
$cart_info_db_field = json_decode( $value->abandoned_cart_info );
|
231 |
$email_body = str_replace( "{{customer.fullname}}", get_user_meta( $value->user_id, 'first_name', true )." ".get_user_meta( $value->user_id, 'last_name', true ), $email_body );
|
232 |
}
|
233 |
|
234 |
+
$order_date = "";
|
235 |
+
|
236 |
+
if ( $cart_update_time != "" && $cart_update_time != 0 ) {
|
237 |
+
$order_date = date( 'd M, Y h:i A', $cart_update_time );
|
238 |
+
}
|
239 |
+
|
240 |
+
$email_body = str_replace( "{{cart.abandoned_date}}", $order_date, $email_body );
|
241 |
+
|
242 |
$query_sent = "INSERT INTO `".$wpdb->prefix."ac_sent_history_lite` ( template_id, abandoned_order_id, sent_time, sent_email_id )
|
243 |
VALUES ( %s, %s, '".current_time( 'mysql' )."', %s )";
|
244 |
|
333 |
$user_email = $value->user_email;
|
334 |
|
335 |
$email_body_final = stripslashes( $email_body );
|
336 |
+
|
337 |
+
if ( isset( $is_wc_template ) && "1" == $is_wc_template ){
|
338 |
+
|
339 |
+
ob_start();
|
340 |
+
|
341 |
+
$email_heading = __( 'Abandoned cart reminder', 'woocommerce' );
|
342 |
+
|
343 |
+
wc_get_template( 'emails/email-header.php', array( 'email_heading' => $email_heading ) );
|
344 |
+
|
345 |
+
$email_body_template_header = ob_get_clean();
|
346 |
+
|
347 |
+
ob_start();
|
348 |
+
|
349 |
+
wc_get_template( 'emails/email-footer.php' );
|
350 |
+
|
351 |
+
$email_body_template_footer = ob_get_clean();
|
352 |
+
|
353 |
+
$final_email_body = $email_body_template_header . $email_body_final . $email_body_template_footer;
|
354 |
+
|
355 |
+
wc_mail( $user_email, $email_subject, $final_email_body, $headers );
|
356 |
+
|
357 |
+
}else{
|
358 |
+
wp_mail( $user_email, $email_subject, __( $email_body_final, 'woocommerce-ac' ), $headers );
|
359 |
+
}
|
360 |
}
|
361 |
|
362 |
}
|
default-settings.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class default_template_settings {
|
3 |
+
/* This function will load default template while activating the plugin.
|
4 |
+
*
|
5 |
+
* @since: AFter 2.5 version
|
6 |
+
*/
|
7 |
+
function create_default_templates() {
|
8 |
+
global $wpdb;
|
9 |
+
|
10 |
+
$template_name_array = 'Initial';
|
11 |
+
$site_title = get_bloginfo( 'name' );
|
12 |
+
$site_url = get_option( 'siteurl' );
|
13 |
+
$template_subject_array = $site_title . ": Did you have checkout trouble?";
|
14 |
+
$active_post_array = 0;
|
15 |
+
$email_frequency_array = 1;
|
16 |
+
$day_or_hour_array = 'Hours';
|
17 |
+
$body_content_array = addslashes("<html>
|
18 |
+
<head>
|
19 |
+
<title>My document title</title>
|
20 |
+
</head>
|
21 |
+
<body>
|
22 |
+
<p> Hello {{customer.fullname}}, </p>
|
23 |
+
<p> </p>
|
24 |
+
<p> We\'re following up with you, because we noticed that on {{cart.abandoned_date}} you attempted to purchase the following products on $site_title. </p>
|
25 |
+
<p> </p>
|
26 |
+
<p> {{products.cart}} </p>
|
27 |
+
<p> </p>
|
28 |
+
<p> If you had any purchase troubles, could you please Contact to share them? </p>
|
29 |
+
<p> </p>
|
30 |
+
<p> Otherwise, how about giving us another chance? Shop <a href= $site_url >$site_title</a>. </p>
|
31 |
+
<hr></hr>
|
32 |
+
<p> <a href=$site_url>$site_title</a> appreciates your business. </p>
|
33 |
+
</body>
|
34 |
+
</html>");
|
35 |
+
|
36 |
+
$ac_from_name = 'Admin';
|
37 |
+
$is_wc_template = 1 ;
|
38 |
+
$default_template = 1;
|
39 |
+
|
40 |
+
$query = "INSERT INTO `" . $wpdb->prefix . "ac_email_templates_lite`
|
41 |
+
( subject, body, is_active, frequency, day_or_hour, template_name, from_name, is_wc_template, default_template )
|
42 |
+
VALUES ( '" . $template_subject_array . "',
|
43 |
+
'" . $body_content_array . "',
|
44 |
+
'" . $active_post_array . "',
|
45 |
+
'" . $email_frequency_array . "',
|
46 |
+
'" . $day_or_hour_array . "',
|
47 |
+
'" . $template_name_array . "',
|
48 |
+
'" . $ac_from_name . "',
|
49 |
+
'" . $is_wc_template . "',
|
50 |
+
'" . $default_template . "' )";
|
51 |
+
|
52 |
+
|
53 |
+
$wpdb->query( $query );
|
54 |
+
|
55 |
+
}
|
56 |
+
}
|
images/spectre.jpg
ADDED
Binary file
|
js/abandoncart_plugin_button.js
CHANGED
@@ -28,7 +28,12 @@
|
|
28 |
|
29 |
b.addSeparator();
|
30 |
|
31 |
-
a.addImmediate(b,"Cart Link", '{{cart.link}}');
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
});
|
34 |
return d
|
28 |
|
29 |
b.addSeparator();
|
30 |
|
31 |
+
a.addImmediate(b,"Cart Link", '{{cart.link}}');
|
32 |
+
|
33 |
+
b.addSeparator();
|
34 |
+
|
35 |
+
a.addImmediate(b,"Date when Cart was abandoned", '{{cart.abandoned_date}}');
|
36 |
+
|
37 |
|
38 |
});
|
39 |
return d
|
readme.txt
CHANGED
@@ -22,6 +22,8 @@ Abandoned Cart Lite plugin enables to do the following things:
|
|
22 |
<li>Identify the Abandoned Orders information, including the products that were abandoned</li>
|
23 |
<li>The plugin now captures abandoned guest carts. A guest user's cart will be captured on the Checkout page, if it is abandoned after entering the email address.</li>
|
24 |
<li>Track abandoned orders value v/s recovered orders value</li>
|
|
|
|
|
25 |
<li>Create unlimited email templates to be sent at intervals that you set - Intervals start from 1 hour after cart is abandoned</li>
|
26 |
<li>Add custom variables like Customer First Name, Customer Last name, Customer full name, Cart Link & Product Cart Information in the email template</li>
|
27 |
<li>Copy HTML from anywhere & create templates using the powerful Rich Text Editor</li>
|
@@ -35,7 +37,6 @@ Abandoned Cart PRO plugin enables to do the following additional things:
|
|
35 |
<li>Add custom variables like Customer Name, Product Information, Coupons, etc. in the email template</li>
|
36 |
<li>Embed Woocommerce coupons & also generate unique coupons in the emails being sent to customers</li>
|
37 |
<li>Track whether expired coupons are causing cart abandonment</li>
|
38 |
-
<li>Admin is notified by email when an order is recovered</li>
|
39 |
<li>Track emails sent, emails opened, links clicked for each template/email</li>
|
40 |
<li>Product report allows you to see which products are being abandoned & which are being recovered the most</li>
|
41 |
<li>Create unlimited email templates to be sent at intervals that you set - Intervals start from 1 minute after cart is abandoned</li>
|
@@ -43,7 +44,7 @@ Abandoned Cart PRO plugin enables to do the following additional things:
|
|
43 |
|
44 |
**Pro Version:**
|
45 |
|
46 |
-
**[WooCommerce Abandoned Cart Pro 2.4.
|
47 |
|
48 |
|
49 |
**Email Sending Setup:**
|
@@ -88,6 +89,25 @@ The documentation can be found **[here](https://www.tychesoftwares.com/woocommer
|
|
88 |
|
89 |
== Changelog ==
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
= 2.4 =
|
92 |
* Abandon Cart record was not being deleted for users, when they do not reach the order received page but the payment for the order is already done. Also user was receiving the abandoned cart notification for such orders. This has been fixed.
|
93 |
|
22 |
<li>Identify the Abandoned Orders information, including the products that were abandoned</li>
|
23 |
<li>The plugin now captures abandoned guest carts. A guest user's cart will be captured on the Checkout page, if it is abandoned after entering the email address.</li>
|
24 |
<li>Track abandoned orders value v/s recovered orders value</li>
|
25 |
+
<li>Admin is notified by email when an order is recovered</li>
|
26 |
+
<li>Works off-the-shelf as it comes with 1 default email template</li>
|
27 |
<li>Create unlimited email templates to be sent at intervals that you set - Intervals start from 1 hour after cart is abandoned</li>
|
28 |
<li>Add custom variables like Customer First Name, Customer Last name, Customer full name, Cart Link & Product Cart Information in the email template</li>
|
29 |
<li>Copy HTML from anywhere & create templates using the powerful Rich Text Editor</li>
|
37 |
<li>Add custom variables like Customer Name, Product Information, Coupons, etc. in the email template</li>
|
38 |
<li>Embed Woocommerce coupons & also generate unique coupons in the emails being sent to customers</li>
|
39 |
<li>Track whether expired coupons are causing cart abandonment</li>
|
|
|
40 |
<li>Track emails sent, emails opened, links clicked for each template/email</li>
|
41 |
<li>Product report allows you to see which products are being abandoned & which are being recovered the most</li>
|
42 |
<li>Create unlimited email templates to be sent at intervals that you set - Intervals start from 1 minute after cart is abandoned</li>
|
44 |
|
45 |
**Pro Version:**
|
46 |
|
47 |
+
**[WooCommerce Abandoned Cart Pro 2.4.7](http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro "WooCommerce Abandoned Cart Pro")** - The PRO version allows you to track products in abandoned carts, create unlimited email templates, track coupons, keep a track of sent emails & much more.
|
48 |
|
49 |
|
50 |
**Email Sending Setup:**
|
89 |
|
90 |
== Changelog ==
|
91 |
|
92 |
+
= 2.5.1 =
|
93 |
+
* Some warnings were displayed on Email Templates tab. These have been fixed.
|
94 |
+
|
95 |
+
= 2.5 =
|
96 |
+
|
97 |
+
* The Settings page for the plugin has been redone. We are now using the WordPress Settings API for all the options on that page.
|
98 |
+
* When the plugin is installed & activated for the first time, 1 default email template will also be created. The template will be inactive when the plugin is activated.
|
99 |
+
* A new setting is added on the Add/Edit Template page named as "Active". If this setting is checked, only then the abandoned cart reminder email will be sent to the customers. If this setting is unchecked, then the email template won't be sent to the customers, but still you can keep it in the plugin. By default, this is unchecked.
|
100 |
+
* A new setting is added on the Add/Edit Template page named as "Use WooCommerce Template Style". If this setting is checked then abandoned cart reminder email will use the WooCommerce style (header, footer, background, etc.) for the notifications. If it is not checked then the regular email will be sent to the customer as per the formatting that is set in the template editor.
|
101 |
+
For existing users, this setting will remain unchecked. For new users of the plugin, the setting will be enabled for the existing default email template that is provided with the plugin.
|
102 |
+
* Abandoned cart email notification will be sent to the client's billing address entered on checkout instead of on the email address added by the user while registering to the website. This applies only for logged in users.
|
103 |
+
* New shortcode "{{cart.abandoned_date}}" has been introduced in this version. It will display the date and time when the cart was abandoned in the abandoned cart email notification.
|
104 |
+
* When a customer places an order within the abandoned cart cut off time, then the order received page was displaying a warning. This has been fixed.
|
105 |
+
* Abandoned Orders tab was not sorting according to the "Date" column. Same way, Recovered Orders tab was not sorting according to "Created On" & "Recovered Date" column. This has been fixed.
|
106 |
+
* Some warnings were displayed on the Abandoned Orders, Recovered Orders and Product Report tab. These have been fixed.
|
107 |
+
* The 'mailto' link was not working on the Abandoned Order details page. This has been fixed.
|
108 |
+
* Tweak - Removed the background white color for the add / edit template page.
|
109 |
+
* Tweak - Abandoned Orders tab will display the user's billing address using which the cart was abandoned. This applies only for logged in users.
|
110 |
+
|
111 |
= 2.4 =
|
112 |
* Abandon Cart record was not being deleted for users, when they do not reach the order received page but the payment for the order is already done. Also user was receiving the abandoned cart notification for such orders. This has been fixed.
|
113 |
|
views/wacp-email-template-preview.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin View: Abadoned Cart reminder Email Template Preview
|
4 |
+
*/
|
5 |
+
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // Exit if accessed directly
|
8 |
+
}
|
9 |
+
|
10 |
+
?>
|
11 |
+
<html>
|
12 |
+
<head>
|
13 |
+
<title>My document title</title>
|
14 |
+
</head>
|
15 |
+
<body>
|
16 |
+
|
17 |
+
<p align="center"> Hello John Carter, </p>
|
18 |
+
<p> </p>
|
19 |
+
<p align="center"> We\'re following up with you, because we noticed that on 12-12-2015 you attempted to purchase the following products on <?php echo get_option( 'blogname' );?>. </p>
|
20 |
+
<p> </p>
|
21 |
+
<p>
|
22 |
+
|
23 |
+
<table border="0" cellspacing="5" align="center"><caption><b>Cart Details</b></caption>
|
24 |
+
<tbody>
|
25 |
+
<tr>
|
26 |
+
<th></th>
|
27 |
+
<th>Product</th>
|
28 |
+
<th>Price</th>
|
29 |
+
<th>Quantity</th>
|
30 |
+
<th>Total</th>
|
31 |
+
</tr>
|
32 |
+
<tr style="background-color:#f4f5f4;">
|
33 |
+
<td><img src = "<?php echo plugins_url();?>/woocommerce-abandoned-cart/images/spectre.jpg" height="40px" width="40px"></td><td>Spectre</td><td>$150</td><td>2</td><td>$300</td>
|
34 |
+
</tr>
|
35 |
+
<tr>
|
36 |
+
<td> </td>
|
37 |
+
<td> </td>
|
38 |
+
<td> </td>
|
39 |
+
<th>Cart Total:</th>
|
40 |
+
<td>$300</td>
|
41 |
+
</tr></tbody></table> </p>
|
42 |
+
<p> </p>
|
43 |
+
<p align="center"> If you had any purchase troubles, could you please Contact to share them? </p>
|
44 |
+
<p> </p>
|
45 |
+
<p align="center"> Otherwise, how about giving us another chance? Shop <a href="<?php echo get_option( 'siteurl' );?>"><?php echo get_option( 'blogname' );?></a>. </p>
|
46 |
+
<hr></hr>
|
47 |
+
<p align="center"> You may <a href="<?php echo get_option( 'siteurl' );?>">unsubscribe</a> to stop receiving these emails. </p>
|
48 |
+
<p> </p>
|
49 |
+
<p align="center"> <a href="<?php echo get_option( 'siteurl' );?>"><?php echo get_option( 'blogname' );?></a> appreciates your business. </p>
|
50 |
+
|
51 |
+
</body>
|
52 |
+
</html>
|
views/wacp-wc-email-template-preview.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin View: Abadoned Cart reminder Email Template Preview
|
4 |
+
*/
|
5 |
+
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // Exit if accessed directly
|
8 |
+
}
|
9 |
+
|
10 |
+
?>
|
11 |
+
<body>
|
12 |
+
|
13 |
+
<p > Hello John Carter, </p>
|
14 |
+
<p> </p>
|
15 |
+
<p > We\'re following up with you, because we noticed that on 12-12-2015 you attempted to purchase the following products on <?php echo get_option( 'blogname' );?>. </p>
|
16 |
+
<p> </p>
|
17 |
+
<p>
|
18 |
+
|
19 |
+
<table border="0" cellspacing="5" align="center"><caption><b>Cart Details</b></caption>
|
20 |
+
<tbody>
|
21 |
+
<tr>
|
22 |
+
<th></th>
|
23 |
+
<th>Product</th>
|
24 |
+
<th>Price</th>
|
25 |
+
<th>Quantity</th>
|
26 |
+
<th>Total</th>
|
27 |
+
</tr>
|
28 |
+
<tr style="background-color:#f4f5f4;">
|
29 |
+
<td><img src = "<?php echo plugins_url();?>/woocommerce-abandoned-cart/images/spectre.jpg" height="40px" width="40px"></td><td>Spectre</td><td>$150</td><td>2</td><td>$300</td>
|
30 |
+
</tr>
|
31 |
+
<tr>
|
32 |
+
<td> </td>
|
33 |
+
<td> </td>
|
34 |
+
<td> </td>
|
35 |
+
<th>Cart Total:</th>
|
36 |
+
<td>$300</td>
|
37 |
+
</tr></tbody></table> </p>
|
38 |
+
<p> </p>
|
39 |
+
<p > If you had any purchase troubles, could you please Contact to share them? </p>
|
40 |
+
<p> </p>
|
41 |
+
<p > Otherwise, how about giving us another chance? Shop <a href="<?php echo get_option( 'siteurl' );?>"><?php echo get_option( 'blogname' );?></a>. </p>
|
42 |
+
<hr></hr>
|
43 |
+
<p > You may <a href="<?php echo get_option( 'siteurl' );?>">unsubscribe</a> to stop receiving these emails. </p>
|
44 |
+
<p> </p>
|
45 |
+
<p > <a href="<?php echo get_option( 'siteurl' );?>"><?php echo get_option( 'blogname' );?></a> appreciates your business. </p>
|
46 |
+
|
47 |
+
</body>
|
woocommerce-ac.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WooCommerce Abandon Cart Lite Plugin
|
4 |
Plugin URI: http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro
|
5 |
Description: This plugin captures abandoned carts by logged-in users & emails them about it. <strong><a href="http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro">Click here to get the PRO Version.</a></strong>
|
6 |
-
Version: 2.
|
7 |
Author: Tyche Softwares
|
8 |
Author URI: http://www.tychesoftwares.com/
|
9 |
*/
|
@@ -16,6 +16,7 @@ if( session_id() === '' ){
|
|
16 |
register_uninstall_hook( __FILE__, 'woocommerce_ac_delete' );
|
17 |
|
18 |
include_once( "woocommerce_guest_ac.class.php" );
|
|
|
19 |
|
20 |
// Add a new interval of 5 minutes
|
21 |
add_filter( 'cron_schedules', 'woocommerce_ac_add_cron_schedule' );
|
@@ -91,8 +92,12 @@ function woocommerce_ac_delete(){
|
|
91 |
}
|
92 |
|
93 |
delete_option ( 'woocommerce_ac_email_body' );
|
94 |
-
delete_option
|
95 |
-
|
|
|
|
|
|
|
|
|
96 |
}
|
97 |
/**
|
98 |
* woocommerce_abandon_cart class
|
@@ -159,7 +164,12 @@ function woocommerce_ac_delete(){
|
|
159 |
add_filter ( 'woocommerce_order_details_after_order_table', array( &$this, 'action_after_delivery_session' ) );
|
160 |
|
161 |
add_action ( 'admin_init', array( &$this, 'action_admin_init' ) );
|
|
|
|
|
162 |
add_action ( 'admin_init', array( &$this, 'ac_lite_update_db_check' ) );
|
|
|
|
|
|
|
163 |
|
164 |
// Language Translation
|
165 |
add_action ( 'init', array( &$this, 'update_po_file' ) );
|
@@ -193,13 +203,80 @@ function woocommerce_ac_delete(){
|
|
193 |
add_action('woocommerce_order_status_pending_to_on-hold_notification', array(&$this, 'ac_email_admin_recovery'));
|
194 |
add_action('woocommerce_order_status_failed_to_processing_notification', array(&$this, 'ac_email_admin_recovery'));
|
195 |
add_action('woocommerce_order_status_failed_to_completed_notification', array(&$this, 'ac_email_admin_recovery'));
|
196 |
-
|
197 |
}
|
198 |
|
199 |
/*-----------------------------------------------------------------------------------*/
|
200 |
/* Class Functions */
|
201 |
/*-----------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
202 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
// Language Translation
|
204 |
function update_po_file() {
|
205 |
$domain = 'woocommerce-ac';
|
@@ -245,7 +322,20 @@ function woocommerce_ac_delete(){
|
|
245 |
|
246 |
require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
247 |
dbDelta( $sql );
|
248 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
$sent_table_name = $wpdb->prefix . "ac_sent_history_lite";
|
250 |
|
251 |
$sql_query = "CREATE TABLE IF NOT EXISTS $sent_table_name (
|
@@ -275,14 +365,134 @@ function woocommerce_ac_delete(){
|
|
275 |
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
276 |
dbDelta( $history_query );
|
277 |
|
278 |
-
|
279 |
-
$
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
}
|
285 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
function ac_lite_update_db_check() {
|
287 |
global $wpdb;
|
288 |
|
@@ -329,6 +539,17 @@ function woocommerce_ac_delete(){
|
|
329 |
$alter_table_query = "ALTER TABLE $ac_history_table_name ADD `user_type` text AFTER `recovered_cart`";
|
330 |
$wpdb->get_results( $alter_table_query );
|
331 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
|
333 |
$guest_table = $wpdb->prefix."ac_guest_abandoned_cart_history_lite" ;
|
334 |
$query_guest_table = "SHOW TABLES LIKE '$guest_table' ";
|
@@ -366,6 +587,28 @@ function woocommerce_ac_delete(){
|
|
366 |
$wpdb->query( $ac_guest_history_query );
|
367 |
}
|
368 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
369 |
}
|
370 |
|
371 |
/******
|
@@ -376,8 +619,10 @@ function woocommerce_ac_delete(){
|
|
376 |
function ac_email_admin_recovery ($order_id) {
|
377 |
|
378 |
$user_id = get_current_user_id();
|
379 |
-
|
380 |
-
|
|
|
|
|
381 |
if ( get_user_meta($user_id, '_woocommerce_ac_modified_cart', true) == md5("yes") || get_user_meta($user_id, '_woocommerce_ac_modified_cart', true) == md5("no") ){ // indicates cart is abandoned
|
382 |
$order = new WC_Order( $order_id );
|
383 |
|
@@ -423,13 +668,13 @@ function woocommerce_ac_delete(){
|
|
423 |
global $wpdb,$woocommerce;
|
424 |
|
425 |
$current_time = current_time( 'timestamp' );
|
426 |
-
$cut_off_time =
|
427 |
|
428 |
$cart_ignored = 0;
|
429 |
$recovered_cart = 0;
|
430 |
|
431 |
-
if( isset( $cut_off_time
|
432 |
-
$cart_cut_off_time = $cut_off_time
|
433 |
} else {
|
434 |
$cart_cut_off_time = 60 * 60;
|
435 |
}
|
@@ -741,9 +986,10 @@ function woocommerce_ac_delete(){
|
|
741 |
|
742 |
global $wpdb;
|
743 |
$user_id = get_current_user_id();
|
744 |
-
|
745 |
-
|
746 |
-
|
|
|
747 |
if ( $user_id == "" ) {
|
748 |
$user_id = $_SESSION['user_id'];
|
749 |
// Set the session variables to blanks
|
@@ -1028,96 +1274,18 @@ function woocommerce_ac_delete(){
|
|
1028 |
|
1029 |
if ( $action == 'emailsettings' ) {
|
1030 |
// Save the field values
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
?>
|
1044 |
-
|
1045 |
-
<?php if ( isset( $_POST[ 'ac_settings_frm' ] ) && $_POST[ 'ac_settings_frm' ] == 'save' ) { ?>
|
1046 |
-
<div id="message" class="updated fade"><p><strong><?php _e( 'Your settings have been saved.', 'woocommerce-ac' ); ?></strong></p></div>
|
1047 |
-
<?php } ?>
|
1048 |
-
|
1049 |
-
<?php
|
1050 |
-
|
1051 |
-
$enable_email_sett_arr = array();
|
1052 |
-
$enable_email_sett = get_option( 'woocommerce_ac_settings' );
|
1053 |
-
if ( $enable_email_sett != '' && $enable_email_sett != '{}' && $enable_email_sett != '[]' && $enable_email_sett != 'null' ) {
|
1054 |
-
$enable_email_sett_arr = json_decode( $enable_email_sett );
|
1055 |
-
}
|
1056 |
-
|
1057 |
-
?>
|
1058 |
-
<div id="content">
|
1059 |
-
<form method="post" action="" id="ac_settings">
|
1060 |
-
<input type="hidden" name="ac_settings_frm" value="save">
|
1061 |
-
<div id="poststuff">
|
1062 |
-
<div class="postbox">
|
1063 |
-
<h3 class="hndle"><?php _e( 'Settings', 'woocommerce-ac' ); ?></h3>
|
1064 |
-
<div>
|
1065 |
-
<table class="form-table">
|
1066 |
-
|
1067 |
-
<tr>
|
1068 |
-
<th>
|
1069 |
-
<label for="woocommerce_ac_email_frequency"><b><?php _e( 'Cart abandoned cut-off time', 'woocommerce-ac' ); ?></b></label>
|
1070 |
-
</th>
|
1071 |
-
<td>
|
1072 |
-
<?php
|
1073 |
-
|
1074 |
-
$cart_time = "";
|
1075 |
-
|
1076 |
-
if ( count( $enable_email_sett_arr ) > 0 ) {
|
1077 |
-
|
1078 |
-
if ( ( isset( $enable_email_sett_arr[0]->cart_time ) ) && ( $enable_email_sett_arr[0]->cart_time != '' || $enable_email_sett_arr[0]->cart_time != 'null' ) ) {
|
1079 |
-
|
1080 |
-
$cart_time = $enable_email_sett_arr[0]->cart_time;
|
1081 |
-
|
1082 |
-
} else {
|
1083 |
-
|
1084 |
-
$cart_time = 60;
|
1085 |
-
}
|
1086 |
-
} else {
|
1087 |
-
$cart_time = 60;
|
1088 |
-
}
|
1089 |
-
|
1090 |
-
?>
|
1091 |
-
<input type="text" name="cart_abandonment_time" id="cart_abandonment_time" size="5" value="<?php echo $cart_time; ?> "> <?php _e( 'minutes', 'woocommerce-ac' );?>
|
1092 |
-
<img class="help_tip" width="16" height="16" data-tip='<?php _e( 'Consider cart abandoned after X minutes of item being added to cart & order not placed', 'woocommerce-ac') ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" /></p>
|
1093 |
-
</td>
|
1094 |
-
</tr>
|
1095 |
-
|
1096 |
-
<tr>
|
1097 |
-
<th>
|
1098 |
-
<label for="woocommerce_ac_email_frequency"><b><?php _e( 'Email admin on order recovery', 'woocommerce-ac' ); ?></b></label>
|
1099 |
-
</th>
|
1100 |
-
<td>
|
1101 |
-
<?php
|
1102 |
-
$email_admin = "";
|
1103 |
-
|
1104 |
-
if (isset($enable_email_sett_arr[0]->email_admin) && $enable_email_sett_arr[0]->email_admin == 'on') {
|
1105 |
-
$email_admin = "checked";
|
1106 |
-
}
|
1107 |
-
print'<input type="checkbox" name="email_admin_on_conversion" '.$email_admin.'> ';?>
|
1108 |
-
<img class="help_tip" width="16" height="16" data-tip='<?php _e( 'Sends email to Admin if an Abandoned Cart Order is recoverd', 'woocommerce') ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" /></p>
|
1109 |
-
</td>
|
1110 |
-
</tr>
|
1111 |
-
|
1112 |
-
</table>
|
1113 |
-
</div>
|
1114 |
-
</div>
|
1115 |
-
</div>
|
1116 |
-
<p class="submit">
|
1117 |
-
<input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'woocommerce-ac' ); ?>" />
|
1118 |
-
</p>
|
1119 |
-
</form>
|
1120 |
-
</div>
|
1121 |
<?php
|
1122 |
} elseif ( $action == 'listcart' || $action == '' ) {
|
1123 |
?>
|
@@ -1161,9 +1329,10 @@ function woocommerce_ac_delete(){
|
|
1161 |
|
1162 |
//Query for limit paging
|
1163 |
$limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;
|
1164 |
-
|
|
|
1165 |
} else
|
1166 |
-
$limit = "";
|
1167 |
|
1168 |
?>
|
1169 |
|
@@ -1202,14 +1371,13 @@ function woocommerce_ac_delete(){
|
|
1202 |
FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac
|
1203 |
LEFT JOIN ".$wpdb->base_prefix."users AS wpu ON wpac.user_id = wpu.id
|
1204 |
WHERE recovered_cart = %d
|
1205 |
-
ORDER BY %
|
1206 |
-
|
1207 |
-
|
1208 |
-
$results = $wpdb->get_results( $wpdb->prepare( $query, $recoverd_cart, $order_by, $order ) );
|
1209 |
|
1210 |
/* From here you can do whatever you want with the data from the $result link. */
|
1211 |
|
1212 |
-
$ac_cutoff_time =
|
1213 |
|
1214 |
?>
|
1215 |
<table class='wp-list-table widefat fixed posts' cellspacing='0' id='cart_data'>
|
@@ -1237,7 +1405,7 @@ function woocommerce_ac_delete(){
|
|
1237 |
foreach ( $results as $key => $value ) {
|
1238 |
|
1239 |
if ( $value->user_type == "GUEST" ) {
|
1240 |
-
$query_guest = "SELECT * from `". $wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d";
|
1241 |
$results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $value->user_id ) );
|
1242 |
|
1243 |
}
|
@@ -1255,7 +1423,16 @@ function woocommerce_ac_delete(){
|
|
1255 |
if ( isset( $results_guest[0]->billing_last_name ) ) $user_last_name = $results_guest[0]->billing_last_name;
|
1256 |
else $user_last_name = "";
|
1257 |
} else {
|
1258 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1259 |
$user_first_name_temp = get_user_meta($value->user_id, 'first_name');
|
1260 |
if ( isset( $user_first_name_temp[0] )) $user_first_name = $user_first_name_temp[0];
|
1261 |
else $user_first_name = "";
|
@@ -1273,22 +1450,24 @@ function woocommerce_ac_delete(){
|
|
1273 |
$order_date = date( 'd M, Y h:i A', $cart_update_time );
|
1274 |
}
|
1275 |
|
1276 |
-
$ac_cutoff_time =
|
1277 |
-
if ( isset( $ac_cutoff_time
|
1278 |
-
$cut_off_time = $ac_cutoff_time
|
1279 |
} else {
|
1280 |
$cut_off_time = 60 * 60;
|
1281 |
}
|
|
|
1282 |
$current_time = current_time( 'timestamp' );
|
1283 |
$compare_time = $current_time - $cart_update_time;
|
1284 |
-
$cart_details = $cart_info->cart;
|
1285 |
|
1286 |
$line_total = 0;
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
|
|
|
|
1290 |
}
|
1291 |
-
|
1292 |
if( $value->cart_ignored == 0 && $value->recovered_cart == 0 ) {
|
1293 |
$ac_status = "Abandoned";
|
1294 |
}
|
@@ -1328,12 +1507,13 @@ function woocommerce_ac_delete(){
|
|
1328 |
$insert_template_successfuly = $update_template_successfuly = '';
|
1329 |
if ( isset( $_POST[ 'ac_settings_frm' ] ) && $_POST[ 'ac_settings_frm' ] == 'save' ) {
|
1330 |
|
1331 |
-
$active_post = 1;
|
1332 |
|
|
|
|
|
1333 |
|
1334 |
if ( $active_post == 1 ) {
|
1335 |
|
1336 |
-
$is_active = 1;
|
1337 |
$email_frequency = trim( $_POST[ 'email_frequency' ] );
|
1338 |
$day_or_hour = trim( $_POST[ 'day_or_hour' ] );
|
1339 |
|
@@ -1343,19 +1523,22 @@ function woocommerce_ac_delete(){
|
|
1343 |
AND day_or_hour = %s ";
|
1344 |
$check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $is_active, $email_frequency, $day_or_hour ) );
|
1345 |
|
1346 |
-
|
|
|
|
|
1347 |
if ( count( $check_results ) == 0 ) {
|
1348 |
|
1349 |
-
|
|
|
1350 |
$woocommerce_ac_email_subject = trim( $_POST[ 'woocommerce_ac_email_subject' ] );
|
1351 |
$woocommerce_ac_email_body = trim( $_POST[ 'woocommerce_ac_email_body' ] );
|
1352 |
$woocommerce_ac_template_name = trim( $_POST[ 'woocommerce_ac_template_name' ] );
|
1353 |
$woocommerce_ac_from_name = trim( $_POST[ 'woocommerce_ac_from_name' ] );
|
1354 |
|
1355 |
$query = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
|
1356 |
-
(subject, body, is_active, frequency, day_or_hour, template_name, from_name)
|
1357 |
-
VALUES ( %s, %s, %s, %d, %s, %s, %s )";
|
1358 |
-
|
1359 |
$insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query,
|
1360 |
$woocommerce_ac_email_subject,
|
1361 |
$woocommerce_ac_email_body,
|
@@ -1363,9 +1546,11 @@ function woocommerce_ac_delete(){
|
|
1363 |
$email_frequency,
|
1364 |
$day_or_hour,
|
1365 |
$woocommerce_ac_template_name,
|
1366 |
-
$woocommerce_ac_from_name
|
|
|
|
|
1367 |
);
|
1368 |
-
|
1369 |
}
|
1370 |
else {
|
1371 |
|
@@ -1377,14 +1562,15 @@ function woocommerce_ac_delete(){
|
|
1377 |
AND day_or_hour = %s ";
|
1378 |
$update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update, $update_is_active, $email_frequency, $day_or_hour ) );
|
1379 |
|
|
|
1380 |
$woocommerce_ac_email_subject = trim( $_POST[ 'woocommerce_ac_email_subject' ] );
|
1381 |
$woocommerce_ac_email_body = trim( $_POST[ 'woocommerce_ac_email_body' ] );
|
1382 |
$woocommerce_ac_template_name = trim( $_POST[ 'woocommerce_ac_template_name' ] );
|
1383 |
$woocommerce_ac_from_name = trim( $_POST[ 'woocommerce_ac_from_name' ] );
|
1384 |
|
1385 |
$query_insert_new = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
|
1386 |
-
(subject, body, is_active, frequency, day_or_hour, template_name, from_name)
|
1387 |
-
VALUES ( %s, %s, %s, %d, %s, %s, %s )";
|
1388 |
|
1389 |
$insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query_insert_new,
|
1390 |
$woocommerce_ac_email_subject,
|
@@ -1393,18 +1579,52 @@ function woocommerce_ac_delete(){
|
|
1393 |
$email_frequency,
|
1394 |
$day_or_hour,
|
1395 |
$woocommerce_ac_template_name,
|
1396 |
-
$woocommerce_ac_from_name
|
|
|
|
|
1397 |
);
|
1398 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1399 |
}
|
1400 |
}
|
1401 |
|
1402 |
if ( isset( $_POST[ 'ac_settings_frm' ] ) && $_POST[ 'ac_settings_frm' ] == 'update' )
|
1403 |
{
|
1404 |
-
|
|
|
|
|
1405 |
if ( $active == 1 )
|
1406 |
{
|
1407 |
-
$is_active = 1;
|
1408 |
$email_frequency = trim( $_POST[ 'email_frequency' ] );
|
1409 |
$day_or_hour = trim( $_POST[ 'day_or_hour' ] );
|
1410 |
$check_query = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite`
|
@@ -1413,6 +1633,12 @@ function woocommerce_ac_delete(){
|
|
1413 |
AND day_or_hour= %s ";
|
1414 |
$check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $is_active, $email_frequency, $day_or_hour ) );
|
1415 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1416 |
if (count($check_results) == 0 )
|
1417 |
{
|
1418 |
|
@@ -1430,7 +1656,9 @@ function woocommerce_ac_delete(){
|
|
1430 |
frequency = %d,
|
1431 |
day_or_hour = %s,
|
1432 |
template_name = %s,
|
1433 |
-
from_name = %s
|
|
|
|
|
1434 |
WHERE id = %d ";
|
1435 |
$update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update,
|
1436 |
$woocommerce_ac_email_subject,
|
@@ -1440,9 +1668,14 @@ function woocommerce_ac_delete(){
|
|
1440 |
$day_or_hour,
|
1441 |
$woocommerce_ac_template_name,
|
1442 |
$woocommerce_ac_from_name,
|
|
|
|
|
1443 |
$id )
|
1444 |
|
1445 |
);
|
|
|
|
|
|
|
1446 |
}
|
1447 |
else {
|
1448 |
|
@@ -1467,7 +1700,9 @@ function woocommerce_ac_delete(){
|
|
1467 |
frequency = %d,
|
1468 |
day_or_hour = %s,
|
1469 |
template_name = %s,
|
1470 |
-
from_name = %s
|
|
|
|
|
1471 |
WHERE id = %d ";
|
1472 |
$update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update_latest,
|
1473 |
$woocommerce_ac_email_subject,
|
@@ -1477,11 +1712,73 @@ function woocommerce_ac_delete(){
|
|
1477 |
$day_or_hour,
|
1478 |
$woocommerce_ac_template_name,
|
1479 |
$woocommerce_ac_from_name,
|
|
|
|
|
1480 |
$id )
|
1481 |
|
1482 |
);
|
1483 |
|
1484 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1485 |
}
|
1486 |
}
|
1487 |
|
@@ -1502,9 +1799,9 @@ function woocommerce_ac_delete(){
|
|
1502 |
}
|
1503 |
|
1504 |
|
1505 |
-
if ( isset( $_POST[ 'ac_settings_frm' ] ) && $_POST[ 'ac_settings_frm' ] == 'update' && isset($update_template_successfuly) && $update_template_successfuly
|
1506 |
<div id="message" class="updated fade"><p><strong><?php _e( 'The Email Template has been successfully updated.', 'woocommerce-ac' ); ?></strong></p></div>
|
1507 |
-
<?php } else if ( isset( $_POST[ 'ac_settings_frm' ] ) && $_POST[ 'ac_settings_frm' ] == 'update' && isset($update_template_successfuly) && $update_template_successfuly
|
1508 |
?>
|
1509 |
<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>
|
1510 |
<?php
|
@@ -1830,10 +2127,11 @@ function woocommerce_ac_delete(){
|
|
1830 |
$p->page = $_GET[ 'paging' ];
|
1831 |
}
|
1832 |
//Query for limit paging
|
1833 |
-
$
|
|
|
1834 |
}
|
1835 |
else
|
1836 |
-
$
|
1837 |
?>
|
1838 |
|
1839 |
<div class="tablenav">
|
@@ -1871,8 +2169,8 @@ function woocommerce_ac_delete(){
|
|
1871 |
WHERE abandoned_cart_time >= %d
|
1872 |
AND abandoned_cart_time <= %d
|
1873 |
AND recovered_cart > %d
|
1874 |
-
ORDER BY
|
1875 |
-
$ac_results = $wpdb->get_results( $wpdb->prepare( $query_ac, $start_date, $end_date, $recoverd_cart, $
|
1876 |
|
1877 |
$query_ac_carts = "SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history_lite
|
1878 |
WHERE abandoned_cart_time >= %d
|
@@ -1884,19 +2182,21 @@ function woocommerce_ac_delete(){
|
|
1884 |
{
|
1885 |
|
1886 |
{
|
|
|
1887 |
$count_carts += 1;
|
1888 |
|
1889 |
$cart_detail = json_decode( $value->abandoned_cart_info );
|
1890 |
-
$product_details = $cart_detail->cart;
|
1891 |
|
1892 |
-
$line_total = 0;
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
|
|
|
|
1896 |
}
|
1897 |
-
|
1898 |
$total_value += $line_total;
|
1899 |
-
|
1900 |
}
|
1901 |
$table_data = "";
|
1902 |
foreach ( $ac_results as $key => $value )
|
@@ -2003,8 +2303,14 @@ function woocommerce_ac_delete(){
|
|
2003 |
} else {
|
2004 |
$user_id = $results[0]->user_id;
|
2005 |
if ( isset( $results[0]->user_login ) ) $user_login = $results[0]->user_login;
|
|
|
2006 |
$user_email = get_user_meta( $results[0]->user_id, 'billing_email', true );
|
2007 |
|
|
|
|
|
|
|
|
|
|
|
2008 |
$user_first_name_temp = get_user_meta( $results[0]->user_id, 'first_name');
|
2009 |
if ( isset( $user_first_name_temp[0] ) ) $user_first_name = $user_first_name_temp[0];
|
2010 |
else $user_first_name = "";
|
@@ -2078,44 +2384,47 @@ function woocommerce_ac_delete(){
|
|
2078 |
$user_shipping_country_temp = get_user_meta( $results[0]->user_id, 'shipping_country' );
|
2079 |
if ( isset( $user_shipping_country_temp[0] ) ) $user_shipping_country = $user_shipping_country_temp[0];
|
2080 |
else $user_shipping_country = "";
|
2081 |
-
}
|
|
|
2082 |
$cart_info = json_decode( $results[0]->abandoned_cart_info );
|
2083 |
-
$cart_details = $cart_info->cart;
|
2084 |
$item_subtotal = $item_total = 0;
|
2085 |
|
2086 |
-
|
2087 |
-
$
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2097 |
}
|
2098 |
-
|
2099 |
-
// Line total
|
2100 |
-
$item_total = $item_subtotal;
|
2101 |
-
$item_subtotal = $item_subtotal / $quantity_total;
|
2102 |
-
$item_total = number_format( $item_total, 2 );
|
2103 |
-
$item_subtotal = number_format( $item_subtotal, 2 );
|
2104 |
-
$product = get_product( $product_id );
|
2105 |
-
$prod_image = $product->get_image();
|
2106 |
-
?>
|
2107 |
-
<tr>
|
2108 |
-
<td> <?php echo $prod_image; ?></td>
|
2109 |
-
<td> <?php echo $product->id; ?> </td>
|
2110 |
-
<td> <?php echo $product_name; ?></td>
|
2111 |
-
<td> <?php echo $quantity_total; ?></td>
|
2112 |
-
<td> <?php echo get_woocommerce_currency_symbol()." ".$item_subtotal; ?></td>
|
2113 |
-
<td> <?php echo get_woocommerce_currency_symbol()." ".$item_total; ?></td>
|
2114 |
-
</tr>
|
2115 |
-
|
2116 |
-
<?php
|
2117 |
-
$item_subtotal = $item_total = 0;
|
2118 |
-
}
|
2119 |
?>
|
2120 |
</table>
|
2121 |
</div>
|
@@ -2140,7 +2449,8 @@ function woocommerce_ac_delete(){
|
|
2140 |
?>
|
2141 |
</p>
|
2142 |
<p> <strong> <?php _e( 'Email:', 'woocommerce-ac' ); ?> </strong>
|
2143 |
-
|
|
|
2144 |
</p>
|
2145 |
<p> <strong> <?php _e( 'Phone:', 'woocommerce-ac' ); ?> </strong>
|
2146 |
<?php echo $user_billing_phone;?>
|
@@ -2252,9 +2562,9 @@ function woocommerce_ac_delete(){
|
|
2252 |
$order_date = date( 'd M, Y h:i A', $cart_update_time );
|
2253 |
}
|
2254 |
|
2255 |
-
$ac_cutoff_time =
|
2256 |
-
if ( isset( $ac_cutoff_time
|
2257 |
-
$cut_off_time = $ac_cutoff_time
|
2258 |
}
|
2259 |
$current_time = current_time( 'timestamp' );
|
2260 |
$compare_time = $current_time - $cart_update_time;
|
@@ -2404,7 +2714,7 @@ function woocommerce_ac_delete(){
|
|
2404 |
}
|
2405 |
print'<input type="hidden" name="ac_settings_frm" value="'.$button_mode.'">';?>
|
2406 |
<div id="poststuff">
|
2407 |
-
<div class="postbox">
|
2408 |
<h3 class="hndle"><?php _e( $display_message, 'woocommerce-ac' ); ?></h3>
|
2409 |
<div>
|
2410 |
<table class="form-table" id="addedit_template">
|
@@ -2481,7 +2791,65 @@ function woocommerce_ac_delete(){
|
|
2481 |
?></span>
|
2482 |
</td>
|
2483 |
</tr>
|
2484 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2485 |
<tr>
|
2486 |
<th>
|
2487 |
<label for="woocommerce_ac_email_frequency"><b><?php _e( 'Send this email:', 'woocommerce-ac' ); ?></b></label>
|
@@ -2665,12 +3033,14 @@ function woocommerce_ac_delete(){
|
|
2665 |
var from_name_preview = $( '#woocommerce_ac_from_name' ).val();
|
2666 |
var subject_email_preview = $( '#woocommerce_ac_email_subject' ).val();
|
2667 |
var body_email_preview = tinyMCE.activeEditor.getContent();
|
2668 |
-
var send_email_id = $( '#send_test_email' ).val();
|
|
|
2669 |
var data = {
|
2670 |
from_name_preview : from_name_preview,
|
2671 |
subject_email_preview: subject_email_preview,
|
2672 |
body_email_preview : body_email_preview,
|
2673 |
send_email_id : send_email_id,
|
|
|
2674 |
action : 'preview_email_sent'
|
2675 |
};
|
2676 |
|
@@ -2693,9 +3063,13 @@ function woocommerce_ac_delete(){
|
|
2693 |
$from_email_name = $_POST[ 'from_name_preview' ];
|
2694 |
$subject_email_preview = $_POST[ 'subject_email_preview' ];
|
2695 |
$body_email_preview = $_POST[ 'body_email_preview' ];
|
|
|
2696 |
$body_email_preview = str_replace( '{{customer.firstname}}', 'John', $body_email_preview );
|
2697 |
$body_email_preview = str_replace( '{{customer.lastname}}', 'Doe', $body_email_preview );
|
2698 |
$body_email_preview = str_replace( '{{customer.fullname}}', 'John'." ".'Doe', $body_email_preview );
|
|
|
|
|
|
|
2699 |
|
2700 |
$var = '<h3>'.__( "Your Shopping Cart", "woocommerce-ac" ).'</h3>
|
2701 |
<table border="0" cellpadding="10" cellspacing="0" class="templateDataTable">
|
@@ -2740,7 +3114,28 @@ function woocommerce_ac_delete(){
|
|
2740 |
$headers[] = "Content-Type: text/html"."\r\n";
|
2741 |
|
2742 |
$body_email_final_preview = stripslashes( $body_email_preview );
|
2743 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2744 |
|
2745 |
echo "email sent";
|
2746 |
|
@@ -2751,7 +3146,4 @@ function woocommerce_ac_delete(){
|
|
2751 |
}
|
2752 |
|
2753 |
$woocommerce_abandon_cart = new woocommerce_abandon_cart();
|
2754 |
-
|
2755 |
-
|
2756 |
-
|
2757 |
?>
|
3 |
Plugin Name: WooCommerce Abandon Cart Lite Plugin
|
4 |
Plugin URI: http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro
|
5 |
Description: This plugin captures abandoned carts by logged-in users & emails them about it. <strong><a href="http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro">Click here to get the PRO Version.</a></strong>
|
6 |
+
Version: 2.5.1
|
7 |
Author: Tyche Softwares
|
8 |
Author URI: http://www.tychesoftwares.com/
|
9 |
*/
|
16 |
register_uninstall_hook( __FILE__, 'woocommerce_ac_delete' );
|
17 |
|
18 |
include_once( "woocommerce_guest_ac.class.php" );
|
19 |
+
include_once( "default-settings.php" );
|
20 |
|
21 |
// Add a new interval of 5 minutes
|
22 |
add_filter( 'cron_schedules', 'woocommerce_ac_add_cron_schedule' );
|
92 |
}
|
93 |
|
94 |
delete_option ( 'woocommerce_ac_email_body' );
|
95 |
+
delete_option( 'ac_lite_cart_abandoned_time' );
|
96 |
+
delete_option( 'ac_lite_email_admin_on_recovery' );
|
97 |
+
delete_option( 'ac_lite_settings_status' );
|
98 |
+
delete_option( 'woocommerce_ac_default_templates_installed' );
|
99 |
+
|
100 |
+
|
101 |
}
|
102 |
/**
|
103 |
* woocommerce_abandon_cart class
|
164 |
add_filter ( 'woocommerce_order_details_after_order_table', array( &$this, 'action_after_delivery_session' ) );
|
165 |
|
166 |
add_action ( 'admin_init', array( &$this, 'action_admin_init' ) );
|
167 |
+
|
168 |
+
// Update the options as per settings API
|
169 |
add_action ( 'admin_init', array( &$this, 'ac_lite_update_db_check' ) );
|
170 |
+
|
171 |
+
// Wordpress settings API
|
172 |
+
add_action( 'admin_init', array( &$this, 'ac_lite_initialize_plugin_options' ) );
|
173 |
|
174 |
// Language Translation
|
175 |
add_action ( 'init', array( &$this, 'update_po_file' ) );
|
203 |
add_action('woocommerce_order_status_pending_to_on-hold_notification', array(&$this, 'ac_email_admin_recovery'));
|
204 |
add_action('woocommerce_order_status_failed_to_processing_notification', array(&$this, 'ac_email_admin_recovery'));
|
205 |
add_action('woocommerce_order_status_failed_to_completed_notification', array(&$this, 'ac_email_admin_recovery'));
|
206 |
+
add_action( 'admin_init', array( $this, 'wcap_preview_emails' ) );
|
207 |
}
|
208 |
|
209 |
/*-----------------------------------------------------------------------------------*/
|
210 |
/* Class Functions */
|
211 |
/*-----------------------------------------------------------------------------------*/
|
212 |
+
/**
|
213 |
+
* Preview email template
|
214 |
+
*
|
215 |
+
* @return string
|
216 |
+
*/
|
217 |
+
public function wcap_preview_emails() {
|
218 |
+
|
219 |
+
global $woocommerce;
|
220 |
+
|
221 |
+
if ( isset( $_GET['wacp_preview_woocommerce_mail'] ) ) {
|
222 |
+
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-ac') ) {
|
223 |
+
die( 'Security check' );
|
224 |
+
}
|
225 |
+
|
226 |
+
$message = '';
|
227 |
+
// create a new email
|
228 |
+
|
229 |
+
if ( $woocommerce->version < '2.3' ) {
|
230 |
+
global $email_heading;
|
231 |
+
|
232 |
+
ob_start();
|
233 |
+
|
234 |
+
include( 'views/wacp-wc-email-template-preview.php' );
|
235 |
+
|
236 |
+
$mailer = WC()->mailer();
|
237 |
+
$message = ob_get_clean();
|
238 |
+
$email_heading = __( 'HTML Email Template', 'woocommerce' );
|
239 |
+
|
240 |
+
$message = $mailer->wrap_message( $email_heading, $message );
|
241 |
+
}else{
|
242 |
+
|
243 |
+
// load the mailer class
|
244 |
+
$mailer = WC()->mailer();
|
245 |
+
|
246 |
+
// get the preview email subject
|
247 |
+
$email_heading = __( 'Abandoned cart Email Template', 'woocommerce-ac' );
|
248 |
+
|
249 |
+
// get the preview email content
|
250 |
+
ob_start();
|
251 |
+
include( 'views/wacp-wc-email-template-preview.php' );
|
252 |
+
$message = ob_get_clean();
|
253 |
+
|
254 |
+
// create a new email
|
255 |
+
$email = new WC_Email();
|
256 |
+
|
257 |
+
// wrap the content with the email template and then add styles
|
258 |
+
$message = $email->style_inline( $mailer->wrap_message( $email_heading, $message ) );
|
259 |
+
}
|
260 |
|
261 |
+
echo $message;
|
262 |
+
exit;
|
263 |
+
}
|
264 |
+
|
265 |
+
if ( isset( $_GET['wacp_preview_mail'] ) ) {
|
266 |
+
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-ac') ) {
|
267 |
+
die( 'Security check' );
|
268 |
+
}
|
269 |
+
|
270 |
+
// get the preview email content
|
271 |
+
ob_start();
|
272 |
+
include( 'views/wacp-email-template-preview.php' );
|
273 |
+
$message = ob_get_clean();
|
274 |
+
|
275 |
+
// print the preview email
|
276 |
+
echo $message;
|
277 |
+
exit;
|
278 |
+
}
|
279 |
+
}
|
280 |
// Language Translation
|
281 |
function update_po_file() {
|
282 |
$domain = 'woocommerce-ac';
|
322 |
|
323 |
require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
324 |
dbDelta( $sql );
|
325 |
+
|
326 |
+
|
327 |
+
$table_name = $wpdb->prefix . "ac_email_templates_lite";
|
328 |
+
$check_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'is_wc_template' ";
|
329 |
+
$results = $wpdb->get_results( $check_template_table_query );
|
330 |
+
|
331 |
+
if ( count( $results ) == 0 ) {
|
332 |
+
$alter_template_table_query = "ALTER TABLE $table_name
|
333 |
+
ADD COLUMN `is_wc_template` enum('0','1') COLLATE utf8_unicode_ci NOT NULL AFTER `from_name`,
|
334 |
+
ADD COLUMN `default_template` int(11) NOT NULL AFTER `is_wc_template`";
|
335 |
+
|
336 |
+
$wpdb->get_results( $alter_template_table_query );
|
337 |
+
}
|
338 |
+
|
339 |
$sent_table_name = $wpdb->prefix . "ac_sent_history_lite";
|
340 |
|
341 |
$sql_query = "CREATE TABLE IF NOT EXISTS $sent_table_name (
|
365 |
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
366 |
dbDelta( $history_query );
|
367 |
|
368 |
+
// Default templates: function call to create default templates.
|
369 |
+
$check_table_empty = $wpdb->get_var( "SELECT COUNT(*) FROM `" . $wpdb->prefix . "ac_email_templates_lite`" );
|
370 |
+
|
371 |
+
if( !get_option( 'woocommerce_ac_default_templates_installed' ) ) {
|
372 |
+
|
373 |
+
if( 0 == $check_table_empty ) {
|
374 |
+
$default_template = new default_template_settings;
|
375 |
+
$default_template->create_default_templates();
|
376 |
+
update_option( 'woocommerce_ac_default_templates_installed', "yes" );
|
377 |
+
}
|
378 |
+
}
|
379 |
+
}
|
380 |
+
|
381 |
+
|
382 |
+
/***************************************************************
|
383 |
+
* WP Settings API
|
384 |
+
**************************************************************/
|
385 |
+
function ac_lite_initialize_plugin_options() {
|
386 |
+
// First, we register a section. This is necessary since all future options must belong to a
|
387 |
+
add_settings_section(
|
388 |
+
'ac_lite_general_settings_section', // ID used to identify this section and with which to register options
|
389 |
+
__( 'Settings', 'woocommerce-ac' ), // Title to be displayed on the administration page
|
390 |
+
array($this, 'ac_lite_general_options_callback' ), // Callback used to render the description of the section
|
391 |
+
'woocommerce_ac_page' // Page on which to add this section of options
|
392 |
+
);
|
393 |
+
|
394 |
+
add_settings_field(
|
395 |
+
'ac_lite_cart_abandoned_time',
|
396 |
+
__( 'Cart abandoned cut-off time', 'woocommerce-ac' ),
|
397 |
+
array( $this, 'ac_lite_cart_abandoned_time_callback' ),
|
398 |
+
'woocommerce_ac_page',
|
399 |
+
'ac_lite_general_settings_section',
|
400 |
+
array( __( 'Consider cart abandoned after X minutes of item being added to cart & order not placed.', 'woocommerce-ac' ) )
|
401 |
+
);
|
402 |
+
|
403 |
+
add_settings_field(
|
404 |
+
'ac_lite_email_admin_on_recovery',
|
405 |
+
__( 'Email admin On Order Recovery', 'woocommerce-ac' ),
|
406 |
+
array( $this, 'ac_lite_email_admin_on_recovery' ),
|
407 |
+
'woocommerce_ac_page',
|
408 |
+
'ac_lite_general_settings_section',
|
409 |
+
array( __( 'Sends email to Admin if an Abandoned Cart Order is recovered.', 'woocommerce-ac' ) )
|
410 |
+
);
|
411 |
+
|
412 |
+
// Finally, we register the fields with WordPress
|
413 |
+
register_setting(
|
414 |
+
'woocommerce_ac_settings',
|
415 |
+
'ac_lite_cart_abandoned_time',
|
416 |
+
array ( $this, 'ac_lite_cart_time_validation' )
|
417 |
+
);
|
418 |
+
|
419 |
+
register_setting(
|
420 |
+
'woocommerce_ac_settings',
|
421 |
+
'ac_lite_email_admin_on_recovery'
|
422 |
+
);
|
423 |
+
|
424 |
+
}
|
425 |
+
|
426 |
+
/***************************************************************
|
427 |
+
* WP Settings API callback for section
|
428 |
+
**************************************************************/
|
429 |
+
function ac_lite_general_options_callback() {
|
430 |
+
|
431 |
}
|
432 |
|
433 |
+
/***************************************************************
|
434 |
+
* WP Settings API callback for cart time field
|
435 |
+
**************************************************************/
|
436 |
+
function ac_lite_cart_abandoned_time_callback($args) {
|
437 |
+
|
438 |
+
// First, we read the option
|
439 |
+
$cart_abandoned_time = get_option( 'ac_lite_cart_abandoned_time' );
|
440 |
+
|
441 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
442 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
443 |
+
printf(
|
444 |
+
'<input type="text" id="ac_lite_cart_abandoned_time" name="ac_lite_cart_abandoned_time" value="%s" />',
|
445 |
+
isset( $cart_abandoned_time ) ? esc_attr( $cart_abandoned_time ) : ''
|
446 |
+
);
|
447 |
+
|
448 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
449 |
+
$html = '<label for="ac_lite_cart_abandoned_time"> ' . $args[0] . '</label>';
|
450 |
+
echo $html;
|
451 |
+
}
|
452 |
+
|
453 |
+
/***************************************************************
|
454 |
+
* WP Settings API cart time field validation
|
455 |
+
**************************************************************/
|
456 |
+
function ac_lite_cart_time_validation( $input ) {
|
457 |
+
$output = '';
|
458 |
+
if ( $input == '' || is_numeric( $input) ) {
|
459 |
+
$output = stripslashes( $input) ;
|
460 |
+
} else {
|
461 |
+
add_settings_error( 'ac_lite_cart_abandoned_time', 'error found', __( 'Abandoned cart cut off time should be numeric.', 'woocommerce-ac' ) );
|
462 |
+
}
|
463 |
+
return $output;
|
464 |
+
}
|
465 |
+
|
466 |
+
/***************************************************************
|
467 |
+
* WP Settings API callback for email admin on cart recovery field
|
468 |
+
**************************************************************/
|
469 |
+
function ac_lite_email_admin_on_recovery( $args ) {
|
470 |
+
|
471 |
+
// First, we read the option
|
472 |
+
$email_admin_on_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
|
473 |
+
|
474 |
+
// This condition added to avoid the notie displyed while Check box is unchecked.
|
475 |
+
if ( isset( $email_admin_on_recovery ) && $email_admin_on_recovery == '' ) {
|
476 |
+
$email_admin_on_recovery = 'off';
|
477 |
+
}
|
478 |
+
|
479 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
480 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
481 |
+
$html='';
|
482 |
+
printf(
|
483 |
+
'<input type="checkbox" id="ac_lite_email_admin_on_recovery" name="ac_lite_email_admin_on_recovery" value="on"
|
484 |
+
' . checked('on', $email_admin_on_recovery, false).' />'
|
485 |
+
);
|
486 |
+
|
487 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
488 |
+
$html .= '<label for="ac_lite_email_admin_on_recovery"> ' . $args[0] . '</label>';
|
489 |
+
echo $html;
|
490 |
+
}
|
491 |
+
|
492 |
+
/**************************************************
|
493 |
+
* This function is run when the plugin is upgraded
|
494 |
+
*************************************************/
|
495 |
+
|
496 |
function ac_lite_update_db_check() {
|
497 |
global $wpdb;
|
498 |
|
539 |
$alter_table_query = "ALTER TABLE $ac_history_table_name ADD `user_type` text AFTER `recovered_cart`";
|
540 |
$wpdb->get_results( $alter_table_query );
|
541 |
}
|
542 |
+
|
543 |
+
$table_name = $wpdb->prefix . "ac_email_templates_lite";
|
544 |
+
$check_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'is_wc_template' ";
|
545 |
+
$results = $wpdb->get_results( $check_template_table_query );
|
546 |
+
|
547 |
+
if ( count( $results ) == 0 ) {
|
548 |
+
$alter_template_table_query = "ALTER TABLE $table_name
|
549 |
+
ADD COLUMN `is_wc_template` enum('0','1') COLLATE utf8_unicode_ci NOT NULL AFTER `from_name`,
|
550 |
+
ADD COLUMN `default_template` int(11) NOT NULL AFTER `is_wc_template`";
|
551 |
+
$wpdb->get_results( $alter_template_table_query );
|
552 |
+
}
|
553 |
|
554 |
$guest_table = $wpdb->prefix."ac_guest_abandoned_cart_history_lite" ;
|
555 |
$query_guest_table = "SHOW TABLES LIKE '$guest_table' ";
|
587 |
$wpdb->query( $ac_guest_history_query );
|
588 |
}
|
589 |
|
590 |
+
//get the option, if it is not set to individual then convert to individual records and delete the base record
|
591 |
+
$ac_settings = get_option( 'ac_lite_settings_status' );
|
592 |
+
if ( $ac_settings != 'INDIVIDUAL' ) {
|
593 |
+
//fetch the existing settings and save them as inidividual to be used for the settings API
|
594 |
+
$woocommerce_ac_settings = json_decode( get_option( 'woocommerce_ac_settings' ) );
|
595 |
+
if( isset($woocommerce_ac_settings[0]->cart_time) ){
|
596 |
+
add_option( 'ac_lite_cart_abandoned_time', $woocommerce_ac_settings[0]->cart_time );
|
597 |
+
}else{
|
598 |
+
add_option( 'ac_lite_cart_abandoned_time', '60' );
|
599 |
+
}
|
600 |
+
|
601 |
+
if( isset($woocommerce_ac_settings[0]->email_admin) ){
|
602 |
+
add_option( 'ac_lite_email_admin_on_recovery', $woocommerce_ac_settings[0]->email_admin );
|
603 |
+
}else{
|
604 |
+
add_option( 'ac_lite_email_admin_on_recovery', "" );
|
605 |
+
}
|
606 |
+
|
607 |
+
update_option( 'ac_lite_settings_status', 'INDIVIDUAL' );
|
608 |
+
//Delete the main settings record
|
609 |
+
delete_option( 'woocommerce_ac_settings' );
|
610 |
+
}
|
611 |
+
|
612 |
}
|
613 |
|
614 |
/******
|
619 |
function ac_email_admin_recovery ($order_id) {
|
620 |
|
621 |
$user_id = get_current_user_id();
|
622 |
+
|
623 |
+
$ac_email_admin_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
|
624 |
+
|
625 |
+
if( $ac_email_admin_recovery == 'on' ){
|
626 |
if ( get_user_meta($user_id, '_woocommerce_ac_modified_cart', true) == md5("yes") || get_user_meta($user_id, '_woocommerce_ac_modified_cart', true) == md5("no") ){ // indicates cart is abandoned
|
627 |
$order = new WC_Order( $order_id );
|
628 |
|
668 |
global $wpdb,$woocommerce;
|
669 |
|
670 |
$current_time = current_time( 'timestamp' );
|
671 |
+
$cut_off_time = get_option( 'ac_lite_cart_abandoned_time' );
|
672 |
|
673 |
$cart_ignored = 0;
|
674 |
$recovered_cart = 0;
|
675 |
|
676 |
+
if( isset( $cut_off_time ) ) {
|
677 |
+
$cart_cut_off_time = $cut_off_time * 60;
|
678 |
} else {
|
679 |
$cart_cut_off_time = 60 * 60;
|
680 |
}
|
986 |
|
987 |
global $wpdb;
|
988 |
$user_id = get_current_user_id();
|
989 |
+
$sent_email = '';
|
990 |
+
if ( isset( $_SESSION[ 'email_sent_id' ] ) ){
|
991 |
+
$sent_email = $_SESSION[ 'email_sent_id' ];
|
992 |
+
}
|
993 |
if ( $user_id == "" ) {
|
994 |
$user_id = $_SESSION['user_id'];
|
995 |
// Set the session variables to blanks
|
1274 |
|
1275 |
if ( $action == 'emailsettings' ) {
|
1276 |
// Save the field values
|
1277 |
+
?>
|
1278 |
+
<p><?php _e( 'Change settings for sending email notifications to Customers after X minute, to Admin.', 'woocommerce-ac' ); ?></p>
|
1279 |
+
<div id="content">
|
1280 |
+
|
1281 |
+
<form method="post" action="options.php">
|
1282 |
+
<?php settings_fields( 'woocommerce_ac_settings' ); ?>
|
1283 |
+
<?php do_settings_sections( 'woocommerce_ac_page' ); ?>
|
1284 |
+
<?php settings_errors(); ?>
|
1285 |
+
<?php submit_button(); ?>
|
1286 |
+
|
1287 |
+
</form>
|
1288 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1289 |
<?php
|
1290 |
} elseif ( $action == 'listcart' || $action == '' ) {
|
1291 |
?>
|
1329 |
|
1330 |
//Query for limit paging
|
1331 |
$limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;
|
1332 |
+
$limit_one = ($p->page - 1) * $p->limit;
|
1333 |
+
$limit_two = $p->limit;
|
1334 |
} else
|
1335 |
+
$limit = $limit_one = $limit_two = "";
|
1336 |
|
1337 |
?>
|
1338 |
|
1371 |
FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` AS wpac
|
1372 |
LEFT JOIN ".$wpdb->base_prefix."users AS wpu ON wpac.user_id = wpu.id
|
1373 |
WHERE recovered_cart = %d
|
1374 |
+
ORDER BY abandoned_cart_time $order LIMIT %d, %d ";
|
1375 |
+
|
1376 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query, $recoverd_cart, $limit_one, $limit_two ) );
|
|
|
1377 |
|
1378 |
/* From here you can do whatever you want with the data from the $result link. */
|
1379 |
|
1380 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
1381 |
|
1382 |
?>
|
1383 |
<table class='wp-list-table widefat fixed posts' cellspacing='0' id='cart_data'>
|
1405 |
foreach ( $results as $key => $value ) {
|
1406 |
|
1407 |
if ( $value->user_type == "GUEST" ) {
|
1408 |
+
$query_guest = "SELECT * from `". $wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d ORDER BY `id` DESC LIMIT 1";
|
1409 |
$results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $value->user_id ) );
|
1410 |
|
1411 |
}
|
1423 |
if ( isset( $results_guest[0]->billing_last_name ) ) $user_last_name = $results_guest[0]->billing_last_name;
|
1424 |
else $user_last_name = "";
|
1425 |
} else {
|
1426 |
+
$user_id = $value->user_id;
|
1427 |
+
$key = 'billing_email';
|
1428 |
+
$single = true;
|
1429 |
+
$user_billing_email = get_user_meta( $user_id, $key, $single );
|
1430 |
+
$user_email = '';
|
1431 |
+
if( isset($user_billing_email) && $user_billing_email !=''){
|
1432 |
+
$user_email = $user_billing_email;
|
1433 |
+
}else{
|
1434 |
+
$user_email = $value->user_email;
|
1435 |
+
}
|
1436 |
$user_first_name_temp = get_user_meta($value->user_id, 'first_name');
|
1437 |
if ( isset( $user_first_name_temp[0] )) $user_first_name = $user_first_name_temp[0];
|
1438 |
else $user_first_name = "";
|
1450 |
$order_date = date( 'd M, Y h:i A', $cart_update_time );
|
1451 |
}
|
1452 |
|
1453 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
1454 |
+
if ( isset( $ac_cutoff_time ) ) {
|
1455 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
1456 |
} else {
|
1457 |
$cut_off_time = 60 * 60;
|
1458 |
}
|
1459 |
+
$cart_details = array();
|
1460 |
$current_time = current_time( 'timestamp' );
|
1461 |
$compare_time = $current_time - $cart_update_time;
|
1462 |
+
$cart_details = (array) $cart_info->cart;
|
1463 |
|
1464 |
$line_total = 0;
|
1465 |
+
if ( is_array ( $cart_details ) && count($cart_details) > 0 ) {
|
1466 |
+
foreach ( $cart_details as $k => $v )
|
1467 |
+
{
|
1468 |
+
$line_total = $line_total + $v->line_total;
|
1469 |
+
}
|
1470 |
}
|
|
|
1471 |
if( $value->cart_ignored == 0 && $value->recovered_cart == 0 ) {
|
1472 |
$ac_status = "Abandoned";
|
1473 |
}
|
1507 |
$insert_template_successfuly = $update_template_successfuly = '';
|
1508 |
if ( isset( $_POST[ 'ac_settings_frm' ] ) && $_POST[ 'ac_settings_frm' ] == 'save' ) {
|
1509 |
|
|
|
1510 |
|
1511 |
+
$active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
1512 |
+
$is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1'; //It is fix
|
1513 |
|
1514 |
if ( $active_post == 1 ) {
|
1515 |
|
1516 |
+
$is_active = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
1517 |
$email_frequency = trim( $_POST[ 'email_frequency' ] );
|
1518 |
$day_or_hour = trim( $_POST[ 'day_or_hour' ] );
|
1519 |
|
1523 |
AND day_or_hour = %s ";
|
1524 |
$check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $is_active, $email_frequency, $day_or_hour ) );
|
1525 |
|
1526 |
+
$default_value = 0 ;
|
1527 |
+
|
1528 |
+
|
1529 |
if ( count( $check_results ) == 0 ) {
|
1530 |
|
1531 |
+
|
1532 |
+
$active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
1533 |
$woocommerce_ac_email_subject = trim( $_POST[ 'woocommerce_ac_email_subject' ] );
|
1534 |
$woocommerce_ac_email_body = trim( $_POST[ 'woocommerce_ac_email_body' ] );
|
1535 |
$woocommerce_ac_template_name = trim( $_POST[ 'woocommerce_ac_template_name' ] );
|
1536 |
$woocommerce_ac_from_name = trim( $_POST[ 'woocommerce_ac_from_name' ] );
|
1537 |
|
1538 |
$query = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
|
1539 |
+
(subject, body, is_active, frequency, day_or_hour, template_name, from_name, is_wc_template, default_template )
|
1540 |
+
VALUES ( %s, %s, %s, %d, %s, %s, %s, %s, %d )"; //It is fix
|
1541 |
+
|
1542 |
$insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query,
|
1543 |
$woocommerce_ac_email_subject,
|
1544 |
$woocommerce_ac_email_body,
|
1546 |
$email_frequency,
|
1547 |
$day_or_hour,
|
1548 |
$woocommerce_ac_template_name,
|
1549 |
+
$woocommerce_ac_from_name,
|
1550 |
+
$is_wc_template,
|
1551 |
+
$default_value ) //It is fix
|
1552 |
);
|
1553 |
+
|
1554 |
}
|
1555 |
else {
|
1556 |
|
1562 |
AND day_or_hour = %s ";
|
1563 |
$update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update, $update_is_active, $email_frequency, $day_or_hour ) );
|
1564 |
|
1565 |
+
|
1566 |
$woocommerce_ac_email_subject = trim( $_POST[ 'woocommerce_ac_email_subject' ] );
|
1567 |
$woocommerce_ac_email_body = trim( $_POST[ 'woocommerce_ac_email_body' ] );
|
1568 |
$woocommerce_ac_template_name = trim( $_POST[ 'woocommerce_ac_template_name' ] );
|
1569 |
$woocommerce_ac_from_name = trim( $_POST[ 'woocommerce_ac_from_name' ] );
|
1570 |
|
1571 |
$query_insert_new = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
|
1572 |
+
(subject, body, is_active, frequency, day_or_hour, template_name, from_name, is_wc_template, default_template)
|
1573 |
+
VALUES ( %s, %s, %s, %d, %s, %s, %s, %s, %d )";
|
1574 |
|
1575 |
$insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query_insert_new,
|
1576 |
$woocommerce_ac_email_subject,
|
1579 |
$email_frequency,
|
1580 |
$day_or_hour,
|
1581 |
$woocommerce_ac_template_name,
|
1582 |
+
$woocommerce_ac_from_name,
|
1583 |
+
$is_wc_template,
|
1584 |
+
$default_value )
|
1585 |
);
|
1586 |
}
|
1587 |
+
}else{
|
1588 |
+
|
1589 |
+
|
1590 |
+
$woocommerce_ac_email_subject = trim( $_POST[ 'woocommerce_ac_email_subject' ] );
|
1591 |
+
$woocommerce_ac_email_body = trim( $_POST[ 'woocommerce_ac_email_body' ] );
|
1592 |
+
$woocommerce_ac_template_name = trim( $_POST[ 'woocommerce_ac_template_name' ] );
|
1593 |
+
$woocommerce_ac_from_name = trim( $_POST[ 'woocommerce_ac_from_name' ] );
|
1594 |
+
$active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
1595 |
+
$email_frequency = trim( $_POST[ 'email_frequency' ] );
|
1596 |
+
$day_or_hour = trim( $_POST[ 'day_or_hour' ] );
|
1597 |
+
$is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
|
1598 |
+
$default_value = 0 ;
|
1599 |
+
|
1600 |
+
|
1601 |
+
$query = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
|
1602 |
+
(subject, body, is_active, frequency, day_or_hour, template_name, from_name, is_wc_template, default_template )
|
1603 |
+
VALUES ( %s, %s, %s, %d, %s, %s, %s, %s, %d )";
|
1604 |
+
|
1605 |
+
$insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query,
|
1606 |
+
$woocommerce_ac_email_subject,
|
1607 |
+
$woocommerce_ac_email_body,
|
1608 |
+
$active_post,
|
1609 |
+
$email_frequency,
|
1610 |
+
$day_or_hour,
|
1611 |
+
$woocommerce_ac_template_name,
|
1612 |
+
$woocommerce_ac_from_name,
|
1613 |
+
$is_wc_template,
|
1614 |
+
$default_value ) //It is fix
|
1615 |
+
);
|
1616 |
+
|
1617 |
}
|
1618 |
}
|
1619 |
|
1620 |
if ( isset( $_POST[ 'ac_settings_frm' ] ) && $_POST[ 'ac_settings_frm' ] == 'update' )
|
1621 |
{
|
1622 |
+
|
1623 |
+
$active = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
1624 |
+
$is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
|
1625 |
if ( $active == 1 )
|
1626 |
{
|
1627 |
+
$is_active = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
1628 |
$email_frequency = trim( $_POST[ 'email_frequency' ] );
|
1629 |
$day_or_hour = trim( $_POST[ 'day_or_hour' ] );
|
1630 |
$check_query = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite`
|
1633 |
AND day_or_hour= %s ";
|
1634 |
$check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $is_active, $email_frequency, $day_or_hour ) );
|
1635 |
|
1636 |
+
$default_value = '';
|
1637 |
+
foreach($check_results as $result_key => $result_value) {
|
1638 |
+
$default_value = ( empty( $result_value->default_template ) ) ? 0 : $result_value->default_template;
|
1639 |
+
|
1640 |
+
}
|
1641 |
+
|
1642 |
if (count($check_results) == 0 )
|
1643 |
{
|
1644 |
|
1656 |
frequency = %d,
|
1657 |
day_or_hour = %s,
|
1658 |
template_name = %s,
|
1659 |
+
from_name = %s,
|
1660 |
+
is_wc_template = %s,
|
1661 |
+
default_template = %d
|
1662 |
WHERE id = %d ";
|
1663 |
$update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update,
|
1664 |
$woocommerce_ac_email_subject,
|
1668 |
$day_or_hour,
|
1669 |
$woocommerce_ac_template_name,
|
1670 |
$woocommerce_ac_from_name,
|
1671 |
+
$is_wc_template,
|
1672 |
+
$default_value,
|
1673 |
$id )
|
1674 |
|
1675 |
);
|
1676 |
+
|
1677 |
+
|
1678 |
+
|
1679 |
}
|
1680 |
else {
|
1681 |
|
1700 |
frequency = %d,
|
1701 |
day_or_hour = %s,
|
1702 |
template_name = %s,
|
1703 |
+
from_name = %s,
|
1704 |
+
is_wc_template = %s,
|
1705 |
+
default_template = %d
|
1706 |
WHERE id = %d ";
|
1707 |
$update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update_latest,
|
1708 |
$woocommerce_ac_email_subject,
|
1712 |
$day_or_hour,
|
1713 |
$woocommerce_ac_template_name,
|
1714 |
$woocommerce_ac_from_name,
|
1715 |
+
$is_wc_template,
|
1716 |
+
$default_value,
|
1717 |
$id )
|
1718 |
|
1719 |
);
|
1720 |
|
1721 |
}
|
1722 |
+
}else{
|
1723 |
+
|
1724 |
+
$updated_is_active = '0';
|
1725 |
+
$is_active = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
1726 |
+
$email_frequency = trim( $_POST[ 'email_frequency' ] );
|
1727 |
+
$day_or_hour = trim( $_POST[ 'day_or_hour' ] );
|
1728 |
+
$is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
|
1729 |
+
|
1730 |
+
$query_update_new = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
|
1731 |
+
SET is_active = %s
|
1732 |
+
WHERE frequency = %d
|
1733 |
+
AND day_or_hour = %s ";
|
1734 |
+
$wpdb->query( $wpdb->prepare( $query_update_new, $updated_is_active, $email_frequency, $day_or_hour ) );
|
1735 |
+
|
1736 |
+
$woocommerce_ac_email_subject = trim( $_POST[ 'woocommerce_ac_email_subject' ] );
|
1737 |
+
$woocommerce_ac_email_body = trim( $_POST[ 'woocommerce_ac_email_body' ] );
|
1738 |
+
$woocommerce_ac_template_name = trim( $_POST[ 'woocommerce_ac_template_name' ] );
|
1739 |
+
$woocommerce_ac_from_name = trim( $_POST[ 'woocommerce_ac_from_name' ] );
|
1740 |
+
$id = trim( $_POST[ 'id' ] );
|
1741 |
+
|
1742 |
+
|
1743 |
+
$check_query = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite`
|
1744 |
+
WHERE is_active= %s
|
1745 |
+
AND frequency = %d
|
1746 |
+
AND day_or_hour= %s ";
|
1747 |
+
$check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $is_active, $email_frequency, $day_or_hour ) );
|
1748 |
+
|
1749 |
+
$default_value = '';
|
1750 |
+
foreach($check_results as $result_key => $result_value) {
|
1751 |
+
$default_value = ( empty( $result_value->default_template ) ) ? 0 : $result_value->default_template;
|
1752 |
+
|
1753 |
+
}
|
1754 |
+
|
1755 |
+
$query_update_latest = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
|
1756 |
+
SET
|
1757 |
+
subject = %s,
|
1758 |
+
body = %s,
|
1759 |
+
is_active = %s,
|
1760 |
+
frequency = %d,
|
1761 |
+
day_or_hour = %s,
|
1762 |
+
template_name = %s,
|
1763 |
+
from_name = %s,
|
1764 |
+
is_wc_template = %s,
|
1765 |
+
default_template = %d
|
1766 |
+
WHERE id = %d ";
|
1767 |
+
|
1768 |
+
$update_template_successfuly = $wpdb->query($wpdb->prepare( $query_update_latest,
|
1769 |
+
$woocommerce_ac_email_subject,
|
1770 |
+
$woocommerce_ac_email_body,
|
1771 |
+
$is_active,
|
1772 |
+
$email_frequency,
|
1773 |
+
$day_or_hour,
|
1774 |
+
$woocommerce_ac_template_name,
|
1775 |
+
$woocommerce_ac_from_name,
|
1776 |
+
$is_wc_template,
|
1777 |
+
$default_value,
|
1778 |
+
$id )
|
1779 |
+
|
1780 |
+
);
|
1781 |
+
|
1782 |
}
|
1783 |
}
|
1784 |
|
1799 |
}
|
1800 |
|
1801 |
|
1802 |
+
if ( isset( $_POST[ 'ac_settings_frm' ] ) && $_POST[ 'ac_settings_frm' ] == 'update' && isset($update_template_successfuly) && $update_template_successfuly >= 0 ) { ?>
|
1803 |
<div id="message" class="updated fade"><p><strong><?php _e( 'The Email Template has been successfully updated.', 'woocommerce-ac' ); ?></strong></p></div>
|
1804 |
+
<?php } else if ( isset( $_POST[ 'ac_settings_frm' ] ) && $_POST[ 'ac_settings_frm' ] == 'update' && isset($update_template_successfuly) && $update_template_successfuly === false ){
|
1805 |
?>
|
1806 |
<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>
|
1807 |
<?php
|
2127 |
$p->page = $_GET[ 'paging' ];
|
2128 |
}
|
2129 |
//Query for limit paging
|
2130 |
+
$limit_one = ($p->page - 1) * $p->limit ;
|
2131 |
+
$limit_two = $p->limit ;
|
2132 |
}
|
2133 |
else
|
2134 |
+
$limit_two = $limit_one = "";
|
2135 |
?>
|
2136 |
|
2137 |
<div class="tablenav">
|
2169 |
WHERE abandoned_cart_time >= %d
|
2170 |
AND abandoned_cart_time <= %d
|
2171 |
AND recovered_cart > %d
|
2172 |
+
ORDER BY $order_by $order LIMIT %d, %d";
|
2173 |
+
$ac_results = $wpdb->get_results( $wpdb->prepare( $query_ac, $start_date, $end_date, $recoverd_cart, $limit_one, $limit_two ) );
|
2174 |
|
2175 |
$query_ac_carts = "SELECT * FROM " . $wpdb->prefix . "ac_abandoned_cart_history_lite
|
2176 |
WHERE abandoned_cart_time >= %d
|
2182 |
{
|
2183 |
|
2184 |
{
|
2185 |
+
$product_details = array();
|
2186 |
$count_carts += 1;
|
2187 |
|
2188 |
$cart_detail = json_decode( $value->abandoned_cart_info );
|
2189 |
+
$product_details = (array) $cart_detail->cart;
|
2190 |
|
2191 |
+
$line_total = 0;
|
2192 |
+
if ( is_array( $product_details ) && count($product_details) > 0 ) {
|
2193 |
+
foreach ( $product_details as $k => $v )
|
2194 |
+
{
|
2195 |
+
$line_total = $line_total + $v->line_total;
|
2196 |
+
}
|
2197 |
}
|
|
|
2198 |
$total_value += $line_total;
|
2199 |
+
}
|
2200 |
}
|
2201 |
$table_data = "";
|
2202 |
foreach ( $ac_results as $key => $value )
|
2303 |
} else {
|
2304 |
$user_id = $results[0]->user_id;
|
2305 |
if ( isset( $results[0]->user_login ) ) $user_login = $results[0]->user_login;
|
2306 |
+
|
2307 |
$user_email = get_user_meta( $results[0]->user_id, 'billing_email', true );
|
2308 |
|
2309 |
+
if($user_email == ""){
|
2310 |
+
$user_data = get_userdata( $results[0]->user_id );
|
2311 |
+
$user_email = $user_data->user_email;
|
2312 |
+
}
|
2313 |
+
|
2314 |
$user_first_name_temp = get_user_meta( $results[0]->user_id, 'first_name');
|
2315 |
if ( isset( $user_first_name_temp[0] ) ) $user_first_name = $user_first_name_temp[0];
|
2316 |
else $user_first_name = "";
|
2384 |
$user_shipping_country_temp = get_user_meta( $results[0]->user_id, 'shipping_country' );
|
2385 |
if ( isset( $user_shipping_country_temp[0] ) ) $user_shipping_country = $user_shipping_country_temp[0];
|
2386 |
else $user_shipping_country = "";
|
2387 |
+
}
|
2388 |
+
$cart_details = array();
|
2389 |
$cart_info = json_decode( $results[0]->abandoned_cart_info );
|
2390 |
+
$cart_details = (array) $cart_info->cart;
|
2391 |
$item_subtotal = $item_total = 0;
|
2392 |
|
2393 |
+
if ( is_array ( $cart_details ) && count($cart_details) > 0 ) {
|
2394 |
+
foreach ( $cart_details as $k => $v ) {
|
2395 |
+
$quantity_total = $v->quantity;
|
2396 |
+
$product_id = $v->product_id;
|
2397 |
+
$prod_name = get_post($product_id);
|
2398 |
+
$product_name = $prod_name->post_title;
|
2399 |
+
|
2400 |
+
// Item subtotal is calculated as product total including taxes
|
2401 |
+
if ( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
|
2402 |
+
$item_subtotal = $item_subtotal + $v->line_total + $v->line_subtotal_tax;
|
2403 |
+
} else {
|
2404 |
+
$item_subtotal = $item_subtotal + $v->line_total;
|
2405 |
+
}
|
2406 |
+
|
2407 |
+
// Line total
|
2408 |
+
$item_total = $item_subtotal;
|
2409 |
+
$item_subtotal = $item_subtotal / $quantity_total;
|
2410 |
+
$item_total = number_format( $item_total, 2 );
|
2411 |
+
$item_subtotal = number_format( $item_subtotal, 2 );
|
2412 |
+
$product = get_product( $product_id );
|
2413 |
+
$prod_image = $product->get_image();
|
2414 |
+
?>
|
2415 |
+
<tr>
|
2416 |
+
<td> <?php echo $prod_image; ?></td>
|
2417 |
+
<td> <?php echo $product->id; ?> </td>
|
2418 |
+
<td> <?php echo $product_name; ?></td>
|
2419 |
+
<td> <?php echo $quantity_total; ?></td>
|
2420 |
+
<td> <?php echo get_woocommerce_currency_symbol()." ".$item_subtotal; ?></td>
|
2421 |
+
<td> <?php echo get_woocommerce_currency_symbol()." ".$item_total; ?></td>
|
2422 |
+
</tr>
|
2423 |
+
|
2424 |
+
<?php
|
2425 |
+
$item_subtotal = $item_total = 0;
|
2426 |
}
|
2427 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2428 |
?>
|
2429 |
</table>
|
2430 |
</div>
|
2449 |
?>
|
2450 |
</p>
|
2451 |
<p> <strong> <?php _e( 'Email:', 'woocommerce-ac' ); ?> </strong>
|
2452 |
+
<?php $user_mail_to = "mailto:".$user_email; ?>
|
2453 |
+
<a href=<?php echo $user_mail_to;?>><?php echo $user_email;?> </a>
|
2454 |
</p>
|
2455 |
<p> <strong> <?php _e( 'Phone:', 'woocommerce-ac' ); ?> </strong>
|
2456 |
<?php echo $user_billing_phone;?>
|
2562 |
$order_date = date( 'd M, Y h:i A', $cart_update_time );
|
2563 |
}
|
2564 |
|
2565 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
2566 |
+
if ( isset( $ac_cutoff_time ) ) {
|
2567 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
2568 |
}
|
2569 |
$current_time = current_time( 'timestamp' );
|
2570 |
$compare_time = $current_time - $cart_update_time;
|
2714 |
}
|
2715 |
print'<input type="hidden" name="ac_settings_frm" value="'.$button_mode.'">';?>
|
2716 |
<div id="poststuff">
|
2717 |
+
<div> <!-- <div class="postbox" > -->
|
2718 |
<h3 class="hndle"><?php _e( $display_message, 'woocommerce-ac' ); ?></h3>
|
2719 |
<div>
|
2720 |
<table class="form-table" id="addedit_template">
|
2791 |
?></span>
|
2792 |
</td>
|
2793 |
</tr>
|
2794 |
+
|
2795 |
+
<tr>
|
2796 |
+
<th>
|
2797 |
+
<label for="is_wc_template"><b><?php _e( 'Use WooCommerce Template Style:', 'woocommerce-ac' ); ?></b></label>
|
2798 |
+
</th>
|
2799 |
+
<td>
|
2800 |
+
|
2801 |
+
<?php
|
2802 |
+
$is_wc_template="";
|
2803 |
+
|
2804 |
+
if ( $mode == 'edittemplate' ) {
|
2805 |
+
$use_wc_template = $results[0]->is_wc_template;
|
2806 |
+
|
2807 |
+
if ( $use_wc_template == '1' ) {
|
2808 |
+
$is_wc_template = "checked";
|
2809 |
+
} else {
|
2810 |
+
$is_wc_template = "";
|
2811 |
+
}
|
2812 |
+
}
|
2813 |
+
print'<input type="checkbox" name="is_wc_template" id="is_wc_template" ' . $is_wc_template . '> </input>'; ?>
|
2814 |
+
<img class="help_tip" width="16" height="16" data-tip='<?php _e( 'Use WooCommerce default style template for abandoned cart reminder emails.', 'woocommerce' ) ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" /> <a target = '_blank' href= <?php echo wp_nonce_url( admin_url( '?wacp_preview_woocommerce_mail=true' ), 'woocommerce-ac' ) ; ?> >
|
2815 |
+
Click here to preview </a>how the email template will look with WooCommerce Template Style enabled. Alternatively, if this is unchecked, the template will appear as <a target = '_blank' href=<?php echo wp_nonce_url( admin_url( '?wacp_preview_mail=true' ), 'woocommerce-ac' ) ; ?>>shown here</a>.
|
2816 |
+
</p>
|
2817 |
+
</td>
|
2818 |
+
|
2819 |
+
</tr>
|
2820 |
+
|
2821 |
+
<tr>
|
2822 |
+
<th>
|
2823 |
+
<label for="is_active"><b><?php _e( 'Active:', 'woocommerce-ac' ); ?></b></label>
|
2824 |
+
</th>
|
2825 |
+
<td>
|
2826 |
+
|
2827 |
+
<?php
|
2828 |
+
$is_active_edit="";
|
2829 |
+
|
2830 |
+
if ( $mode == 'edittemplate' ) {
|
2831 |
+
$active_edit = $results[0]->is_active;
|
2832 |
+
|
2833 |
+
if ( $active_edit == '1' ) {
|
2834 |
+
$is_active_edit = "checked";
|
2835 |
+
} else {
|
2836 |
+
$is_active_edit = "";
|
2837 |
+
}
|
2838 |
+
}
|
2839 |
+
|
2840 |
+
if ( $mode == 'copytemplate' ) {
|
2841 |
+
$active_edit = $results_copy[0]->is_active;
|
2842 |
+
|
2843 |
+
if($active_edit == '1') {
|
2844 |
+
$is_active_edit = "checked";
|
2845 |
+
} else {
|
2846 |
+
$is_active_edit = "";
|
2847 |
+
}
|
2848 |
+
}
|
2849 |
+
print'<input type="checkbox" name="is_active" id="is_active" ' . $is_active_edit . '> </input>'; ?>
|
2850 |
+
<img class="help_tip" width="16" height="16" data-tip='<?php _e( 'Yes, This email should be sent to shoppers with abandoned carts', 'woocommerce' ) ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" /></p>
|
2851 |
+
</td>
|
2852 |
+
</tr>
|
2853 |
<tr>
|
2854 |
<th>
|
2855 |
<label for="woocommerce_ac_email_frequency"><b><?php _e( 'Send this email:', 'woocommerce-ac' ); ?></b></label>
|
3033 |
var from_name_preview = $( '#woocommerce_ac_from_name' ).val();
|
3034 |
var subject_email_preview = $( '#woocommerce_ac_email_subject' ).val();
|
3035 |
var body_email_preview = tinyMCE.activeEditor.getContent();
|
3036 |
+
var send_email_id = $( '#send_test_email' ).val();
|
3037 |
+
var is_wc_template = document.getElementById("is_wc_template").checked;
|
3038 |
var data = {
|
3039 |
from_name_preview : from_name_preview,
|
3040 |
subject_email_preview: subject_email_preview,
|
3041 |
body_email_preview : body_email_preview,
|
3042 |
send_email_id : send_email_id,
|
3043 |
+
is_wc_template : is_wc_template,
|
3044 |
action : 'preview_email_sent'
|
3045 |
};
|
3046 |
|
3063 |
$from_email_name = $_POST[ 'from_name_preview' ];
|
3064 |
$subject_email_preview = $_POST[ 'subject_email_preview' ];
|
3065 |
$body_email_preview = $_POST[ 'body_email_preview' ];
|
3066 |
+
$is_wc_template = $_POST['is_wc_template'];
|
3067 |
$body_email_preview = str_replace( '{{customer.firstname}}', 'John', $body_email_preview );
|
3068 |
$body_email_preview = str_replace( '{{customer.lastname}}', 'Doe', $body_email_preview );
|
3069 |
$body_email_preview = str_replace( '{{customer.fullname}}', 'John'." ".'Doe', $body_email_preview );
|
3070 |
+
$current_time_stamp = current_time( 'timestamp' );
|
3071 |
+
$test_date = date( 'd M, Y h:i A', $current_time_stamp );
|
3072 |
+
$body_email_preview = str_replace( '{{cart.abandoned_date}}', $test_date, $body_email_preview );
|
3073 |
|
3074 |
$var = '<h3>'.__( "Your Shopping Cart", "woocommerce-ac" ).'</h3>
|
3075 |
<table border="0" cellpadding="10" cellspacing="0" class="templateDataTable">
|
3114 |
$headers[] = "Content-Type: text/html"."\r\n";
|
3115 |
|
3116 |
$body_email_final_preview = stripslashes( $body_email_preview );
|
3117 |
+
if ( isset( $is_wc_template ) && "true" == $is_wc_template ){
|
3118 |
+
|
3119 |
+
$email_heading = __( 'Abandoned cart reminder', 'woocommerce-ac' );
|
3120 |
+
|
3121 |
+
ob_start();
|
3122 |
+
|
3123 |
+
wc_get_template( 'emails/email-header.php', array( 'email_heading' => $email_heading ) );
|
3124 |
+
|
3125 |
+
$email_body_template_header = ob_get_clean();
|
3126 |
+
|
3127 |
+
ob_start();
|
3128 |
+
|
3129 |
+
wc_get_template( 'emails/email-footer.php' );
|
3130 |
+
|
3131 |
+
$email_body_template_footer = ob_get_clean();
|
3132 |
+
|
3133 |
+
$final_email_body = $email_body_template_header . $body_email_final_preview . $email_body_template_footer;
|
3134 |
+
wc_mail( $to_email_preview, $subject_email_preview, $final_email_body , $headers );
|
3135 |
+
|
3136 |
+
}else{
|
3137 |
+
wp_mail( $to_email_preview, $subject_email_preview, stripslashes( $body_email_preview ), $headers );
|
3138 |
+
}
|
3139 |
|
3140 |
echo "email sent";
|
3141 |
|
3146 |
}
|
3147 |
|
3148 |
$woocommerce_abandon_cart = new woocommerce_abandon_cart();
|
|
|
|
|
|
|
3149 |
?>
|