Version Description
(18.04.2019) =
- This is a minor update to the plugin to remove the unwanted abandoned carts created for some customers after updating to the 5.3.2 release.
Download this release
Release Info
Developer | Dhruvin |
Plugin | Abandoned Cart Lite for WooCommerce |
Version | 5.3.4 |
Comparing to | |
See all releases |
Code changes from version 5.3.2 to 5.3.4
- readme.txt +8 -0
- woocommerce-ac.php +3183 -3173
readme.txt
CHANGED
@@ -193,6 +193,14 @@ You can refer **[here](https://www.tychesoftwares.com/differences-between-pro-an
|
|
193 |
|
194 |
== Changelog ==
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
= 5.3.2 (16.04.2019) =
|
197 |
|
198 |
* Tweak - Optimizing SQL queries by escaping the parameters passed.
|
193 |
|
194 |
== Changelog ==
|
195 |
|
196 |
+
= 5.3.4 (18.04.2019) =
|
197 |
+
|
198 |
+
* This is a minor update to the plugin to remove the unwanted abandoned carts created for some customers after updating to the 5.3.2 release.
|
199 |
+
|
200 |
+
= 5.3.3 (18.04.2019) =
|
201 |
+
|
202 |
+
* We have reversed the changes of the previous release as it created an issue with some sites where carts that were abandoned a while back were receiving the abandoned cart email after the update.
|
203 |
+
|
204 |
= 5.3.2 (16.04.2019) =
|
205 |
|
206 |
* Tweak - Optimizing SQL queries by escaping the parameters passed.
|
woocommerce-ac.php
CHANGED
@@ -1,3174 +1,3184 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Plugin Name: Abandoned Cart Lite for WooCommerce
|
4 |
-
* Plugin URI: http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro
|
5 |
-
* Description: This plugin captures abandoned carts by logged-in users & emails them about it.
|
6 |
-
* <strong><a href="http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro">Click here to get the
|
7 |
-
* PRO Version.</a></strong>
|
8 |
-
* Version: 5.3.
|
9 |
-
* Author: Tyche Softwares
|
10 |
-
* Author URI: http://www.tychesoftwares.com/
|
11 |
-
* Text Domain: woocommerce-abandoned-cart
|
12 |
-
* Domain Path: /i18n/languages/
|
13 |
-
* Requires PHP: 5.6
|
14 |
-
* WC requires at least: 3.0.0
|
15 |
-
* WC tested up to: 3.
|
16 |
-
*
|
17 |
-
* @package Abandoned-Cart-Lite-for-WooCommerce
|
18 |
-
*/
|
19 |
-
|
20 |
-
require_once( "includes/wcal_class-guest.php" );
|
21 |
-
require_once( "includes/wcal_default-settings.php" );
|
22 |
-
require_once( "includes/wcal_actions.php" );
|
23 |
-
require_once( "includes/classes/class-wcal-aes.php" );
|
24 |
-
require_once( "includes/classes/class-wcal-aes-counter.php" );
|
25 |
-
require_once( "includes/wcal-common.php" );
|
26 |
-
|
27 |
-
require_once( "includes/wcal_admin_notice.php");
|
28 |
-
require_once( 'includes/wcal_data_tracking_message.php' );
|
29 |
-
require_once( 'includes/admin/wcal_privacy_erase.php' );
|
30 |
-
require_once( 'includes/admin/wcal_privacy_export.php' );
|
31 |
-
|
32 |
-
// Add a new interval of 15 minutes
|
33 |
-
add_filter( 'cron_schedules', 'wcal_add_cron_schedule' );
|
34 |
-
|
35 |
-
/**
|
36 |
-
* It will add a cron job for sending the Abandonend cart reminder emails.
|
37 |
-
* By default it will set 15 minutes of interval.
|
38 |
-
* @hook cron_schedules
|
39 |
-
* @param array $schedules
|
40 |
-
* @return array $schedules
|
41 |
-
* @since 1.3
|
42 |
-
* @package Abandoned-Cart-Lite-for-WooCommerce/Cron
|
43 |
-
*/
|
44 |
-
function wcal_add_cron_schedule( $schedules ) {
|
45 |
-
$schedules['15_minutes_lite'] = array(
|
46 |
-
'interval' => 900, // 15 minutes in seconds
|
47 |
-
'display' => __( 'Once Every Fifteen Minutes' ),
|
48 |
-
);
|
49 |
-
return $schedules;
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Schedule an action if it's not already scheduled.
|
54 |
-
* @since 1.3
|
55 |
-
* @package Abandoned-Cart-Lite-for-WooCommerce/Cron
|
56 |
-
*/
|
57 |
-
if ( ! wp_next_scheduled( 'woocommerce_ac_send_email_action' ) ) {
|
58 |
-
wp_schedule_event( time(), '15_minutes_lite', 'woocommerce_ac_send_email_action' );
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Schedule an action to delete old carts once a day
|
63 |
-
* @since 5.1
|
64 |
-
* @package Abandoned-Cart-Lite-for-WooCommerce/Cron
|
65 |
-
*/
|
66 |
-
if( ! wp_next_scheduled( 'wcal_clear_carts' ) ) {
|
67 |
-
wp_schedule_event( time(), 'daily', 'wcal_clear_carts' );
|
68 |
-
}
|
69 |
-
/**
|
70 |
-
* Hook into that action that'll fire every 15 minutes
|
71 |
-
*/
|
72 |
-
add_action( 'woocommerce_ac_send_email_action', 'wcal_send_email_cron' );
|
73 |
-
|
74 |
-
/**
|
75 |
-
* It will add the wcal_send_email.php file which is responsible for sending the abandoned cart reminde emails.
|
76 |
-
* @hook woocommerce_ac_send_email_action
|
77 |
-
* @since 1.3
|
78 |
-
* @package Abandoned-Cart-Lite-for-WooCommerce/Cron
|
79 |
-
*/
|
80 |
-
function wcal_send_email_cron() {
|
81 |
-
//require_once( ABSPATH.'wp-content/plugins/woocommerce-abandoned-cart/cron/send_email.php' );
|
82 |
-
$plugin_dir_path = plugin_dir_path( __FILE__ );
|
83 |
-
require_once( $plugin_dir_path . 'cron/wcal_send_email.php' );
|
84 |
-
}
|
85 |
-
/**
|
86 |
-
* woocommerce_abandon_cart_lite class
|
87 |
-
**/
|
88 |
-
if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
89 |
-
|
90 |
-
|
91 |
-
/**
|
92 |
-
* It will add the hooks, filters, menu and the variables and all the necessary actions for the plguins which will be used
|
93 |
-
* all over the plugin.
|
94 |
-
* @since 1.0
|
95 |
-
* @package Abandoned-Cart-Lite-for-WooCommerce/Core
|
96 |
-
*/
|
97 |
-
class woocommerce_abandon_cart_lite {
|
98 |
-
var $one_hour;
|
99 |
-
var $three_hours;
|
100 |
-
var $six_hours;
|
101 |
-
var $twelve_hours;
|
102 |
-
var $one_day;
|
103 |
-
var $one_week;
|
104 |
-
var $duration_range_select = array();
|
105 |
-
var $start_end_dates = array();
|
106 |
-
/**
|
107 |
-
* The constructor will add the hooks, filters and the variable which will be used all over the plugin.
|
108 |
-
* @since 1.0
|
109 |
-
*
|
110 |
-
*/
|
111 |
-
public function __construct() {
|
112 |
-
$this->one_hour = 60 * 60;
|
113 |
-
$this->three_hours = 3 * $this->one_hour;
|
114 |
-
$this->six_hours = 6 * $this->one_hour;
|
115 |
-
$this->twelve_hours = 12 * $this->one_hour;
|
116 |
-
$this->one_day = 24 * $this->one_hour;
|
117 |
-
$this->one_week = 7 * $this->one_day;
|
118 |
-
$this->duration_range_select = array( 'yesterday' => 'Yesterday',
|
119 |
-
'today' => 'Today',
|
120 |
-
'last_seven' => 'Last 7 days',
|
121 |
-
'last_fifteen' => 'Last 15 days',
|
122 |
-
'last_thirty' => 'Last 30 days',
|
123 |
-
'last_ninety' => 'Last 90 days',
|
124 |
-
'last_year_days' => 'Last 365'
|
125 |
-
);
|
126 |
-
|
127 |
-
$this->start_end_dates = array( 'yesterday' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 24*60*60 ) ),
|
128 |
-
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) - 7*24*60*60 ) ) ),
|
129 |
-
'today' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ),
|
130 |
-
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
131 |
-
'last_seven' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 7*24*60*60 ) ),
|
132 |
-
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
133 |
-
'last_fifteen' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 15*24*60*60 ) ),
|
134 |
-
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
135 |
-
'last_thirty' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 30*24*60*60 ) ),
|
136 |
-
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
137 |
-
'last_ninety' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 90*24*60*60 ) ),
|
138 |
-
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
139 |
-
'last_year_days' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 365*24*60*60 ) ),
|
140 |
-
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) )
|
141 |
-
);
|
142 |
-
|
143 |
-
// Initialize settings
|
144 |
-
register_activation_hook ( __FILE__, array( &$this, 'wcal_activate' ) );
|
145 |
-
|
146 |
-
// Background Processing for Cron
|
147 |
-
require_once( 'cron/wcal_send_email.php' );
|
148 |
-
require_once( 'includes/background-processes/wcal_process_base.php' );
|
149 |
-
|
150 |
-
// WordPress Administration Menu
|
151 |
-
add_action ( 'admin_menu', array( &$this, 'wcal_admin_menu' ) );
|
152 |
-
|
153 |
-
// Actions to be done on cart update
|
154 |
-
add_action ( 'woocommerce_cart_updated', array( &$this, 'wcal_store_cart_timestamp' ) );
|
155 |
-
|
156 |
-
add_action ( 'admin_init', array( &$this, 'wcal_action_admin_init' ) );
|
157 |
-
|
158 |
-
// Update the options as per settings API
|
159 |
-
add_action ( 'admin_init', array( &$this, 'wcal_update_db_check' ) );
|
160 |
-
|
161 |
-
// Wordpress settings API
|
162 |
-
add_action( 'admin_init', array( &$this, 'wcal_initialize_plugin_options' ) );
|
163 |
-
|
164 |
-
// Language Translation
|
165 |
-
add_action ( 'init', array( &$this, 'wcal_update_po_file' ) );
|
166 |
-
|
167 |
-
add_action ( 'init', array ( &$this, 'wcal_add_component_file') );
|
168 |
-
|
169 |
-
// track links
|
170 |
-
add_filter( 'template_include', array( &$this, 'wcal_email_track_links' ), 99, 1 );
|
171 |
-
|
172 |
-
//It will used to unsubcribe the emails.
|
173 |
-
add_action( 'template_include', array( &$this, 'wcal_email_unsubscribe'),99, 1 );
|
174 |
-
|
175 |
-
add_action ( 'admin_enqueue_scripts', array( &$this, 'wcal_enqueue_scripts_js' ) );
|
176 |
-
add_action ( 'admin_enqueue_scripts', array( &$this, 'wcal_enqueue_scripts_css' ) );
|
177 |
-
//delete abandoned order after X number of days
|
178 |
-
if ( class_exists( 'wcal_delete_bulk_action_handler' ) ) {
|
179 |
-
add_action( 'wcal_clear_carts', array( 'wcal_delete_bulk_action_handler', 'wcal_delete_abandoned_carts_after_x_days' ) );
|
180 |
-
}
|
181 |
-
|
182 |
-
if ( is_admin() ) {
|
183 |
-
// Load "admin-only" scripts here
|
184 |
-
add_action ( 'admin_head', array( &$this, 'wcal_action_send_preview' ) );
|
185 |
-
add_action ( 'wp_ajax_wcal_preview_email_sent', array( &$this, 'wcal_preview_email_sent' ) );
|
186 |
-
add_action ( 'wp_ajax_wcal_toggle_template_status', array( &$this, 'wcal_toggle_template_status' ) );
|
187 |
-
|
188 |
-
add_filter( 'ts_tracker_data', array( 'wcal_common', 'ts_add_plugin_tracking_data' ), 10, 1 );
|
189 |
-
add_filter( 'ts_tracker_opt_out_data', array( 'wcal_common', 'ts_get_data_for_opt_out' ), 10, 1 );
|
190 |
-
add_filter( 'ts_deativate_plugin_questions', array( &$this, 'wcal_deactivate_add_questions' ), 10, 1 );
|
191 |
-
}
|
192 |
-
|
193 |
-
// Plugin Settings link in WP->Plugins page
|
194 |
-
$plugin = plugin_basename( __FILE__ );
|
195 |
-
add_action( "plugin_action_links_$plugin", array( &$this, 'wcal_settings_link' ) );
|
196 |
-
|
197 |
-
add_action( 'admin_init', array( $this, 'wcal_preview_emails' ) );
|
198 |
-
add_action( 'init', array( $this, 'wcal_app_output_buffer') );
|
199 |
-
|
200 |
-
add_filter( 'admin_footer_text', array( $this, 'wcal_admin_footer_text' ), 1 );
|
201 |
-
|
202 |
-
add_action( 'admin_notices', array( 'Wcal_Admin_Notice', 'wcal_show_db_update_notice' ) );
|
203 |
-
|
204 |
-
include_once 'includes/frontend/wcal_frontend.php';
|
205 |
-
}
|
206 |
-
|
207 |
-
/**
|
208 |
-
* Add Settings link to WP->Plugins page
|
209 |
-
* @since 5.3.0
|
210 |
-
*/
|
211 |
-
public static function wcal_settings_link( $links ) {
|
212 |
-
$settings_link = '<a href="admin.php?page=woocommerce_ac_page&action=emailsettings">' . __( 'Settings', 'woocommerce-abandoned-cart' ) . '</a>';
|
213 |
-
array_push( $links, $settings_link );
|
214 |
-
return $links;
|
215 |
-
}
|
216 |
-
|
217 |
-
/**
|
218 |
-
* It will load the boilerplate components file. In this file we have included all boilerplate files.
|
219 |
-
* We need to inlcude this file after the init hook.
|
220 |
-
* @hook init
|
221 |
-
*/
|
222 |
-
public static function wcal_add_component_file () {
|
223 |
-
if ( is_admin() ) {
|
224 |
-
require_once( 'includes/wcal_all_component.php' );
|
225 |
-
|
226 |
-
}
|
227 |
-
}
|
228 |
-
/**
|
229 |
-
* It will add the Questions while admin deactivate the plugin.
|
230 |
-
* @hook ts_deativate_plugin_questions
|
231 |
-
* @param array $wcal_add_questions Blank array
|
232 |
-
* @return array $wcal_add_questions List of all questions.
|
233 |
-
*/
|
234 |
-
public static function wcal_deactivate_add_questions ( $wcal_add_questions ) {
|
235 |
-
|
236 |
-
$wcal_add_questions = array(
|
237 |
-
0 => array(
|
238 |
-
'id' => 4,
|
239 |
-
'text' => __( "Emails are not being sent to customers.", "woocommerce-abandoned-cart" ),
|
240 |
-
'input_type' => '',
|
241 |
-
'input_placeholder' => ''
|
242 |
-
),
|
243 |
-
1 => array(
|
244 |
-
'id' => 5,
|
245 |
-
'text' => __( "Capturing of cart and other information was not satisfactory.", "woocommerce-abandoned-cart" ),
|
246 |
-
'input_type' => '',
|
247 |
-
'input_placeholder' => ''
|
248 |
-
),
|
249 |
-
2 => array(
|
250 |
-
'id' => 6,
|
251 |
-
'text' => __( "I cannot see abandoned cart reminder emails records.", "woocommerce-abandoned-cart" ),
|
252 |
-
'input_type' => '',
|
253 |
-
'input_placeholder' => ''
|
254 |
-
),
|
255 |
-
3 => array(
|
256 |
-
'id' => 7,
|
257 |
-
'text' => __( "I want to upgrade the plugin to the PRO version.", "woocommerce-abandoned-cart" ),
|
258 |
-
'input_type' => '',
|
259 |
-
'input_placeholder' => ''
|
260 |
-
)
|
261 |
-
|
262 |
-
);
|
263 |
-
return $wcal_add_questions;
|
264 |
-
}
|
265 |
-
|
266 |
-
/**
|
267 |
-
* It will ganerate the preview email template.
|
268 |
-
* @hook admin_init
|
269 |
-
* @globals mixed $woocommerce
|
270 |
-
* @since 2.5
|
271 |
-
*/
|
272 |
-
public function wcal_preview_emails() {
|
273 |
-
global $woocommerce;
|
274 |
-
if ( isset( $_GET['wcal_preview_woocommerce_mail'] ) ) {
|
275 |
-
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-abandoned-cart' ) ) {
|
276 |
-
die( 'Security check' );
|
277 |
-
}
|
278 |
-
$message = '';
|
279 |
-
// create a new email
|
280 |
-
if ( $woocommerce->version < '2.3' ) {
|
281 |
-
global $email_heading;
|
282 |
-
ob_start();
|
283 |
-
|
284 |
-
include( 'views/wcal-wc-email-template-preview.php' );
|
285 |
-
$mailer = WC()->mailer();
|
286 |
-
$message = ob_get_clean();
|
287 |
-
$email_heading = __( 'HTML Email Template', 'woocommerce-abandoned-cart' );
|
288 |
-
$message = $mailer->wrap_message( $email_heading, $message );
|
289 |
-
} else {
|
290 |
-
// load the mailer class
|
291 |
-
$mailer = WC()->mailer();
|
292 |
-
// get the preview email subject
|
293 |
-
$email_heading = __( 'Abandoned cart Email Template', 'woocommerce-abandoned-cart' );
|
294 |
-
// get the preview email content
|
295 |
-
ob_start();
|
296 |
-
include( 'views/wcal-wc-email-template-preview.php' );
|
297 |
-
$message = ob_get_clean();
|
298 |
-
// create a new email
|
299 |
-
$email = new WC_Email();
|
300 |
-
// wrap the content with the email template and then add styles
|
301 |
-
$message = $email->style_inline( $mailer->wrap_message( $email_heading, $message ) );
|
302 |
-
}
|
303 |
-
echo $message;
|
304 |
-
exit;
|
305 |
-
}
|
306 |
-
|
307 |
-
if ( isset( $_GET['wcal_preview_mail'] ) ) {
|
308 |
-
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-abandoned-cart' ) ) {
|
309 |
-
die( 'Security check' );
|
310 |
-
}
|
311 |
-
// get the preview email content
|
312 |
-
ob_start();
|
313 |
-
include( 'views/wcal-email-template-preview.php' );
|
314 |
-
$message = ob_get_clean();
|
315 |
-
// print the preview email
|
316 |
-
echo $message;
|
317 |
-
exit;
|
318 |
-
}
|
319 |
-
}
|
320 |
-
|
321 |
-
/**
|
322 |
-
* In this version we have allowed customer to transalte the plugin string using .po and .pot file.
|
323 |
-
* @hook init
|
324 |
-
* @return $loaded
|
325 |
-
* @since 1.6
|
326 |
-
*/
|
327 |
-
function wcal_update_po_file() {
|
328 |
-
/*
|
329 |
-
* Due to the introduction of language packs through translate.wordpress.org, loading our textdomain is complex.
|
330 |
-
*
|
331 |
-
* In v4.7, our textdomain changed from "woocommerce-ac" to "woocommerce-abandoned-cart".
|
332 |
-
*/
|
333 |
-
$domain = 'woocommerce-abandoned-cart';
|
334 |
-
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
|
335 |
-
if ( $loaded = load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '-' . $locale . '.mo' ) ) {
|
336 |
-
return $loaded;
|
337 |
-
} else {
|
338 |
-
load_plugin_textdomain( $domain, FALSE, basename( dirname( __FILE__ ) ) . '/i18n/languages/' );
|
339 |
-
}
|
340 |
-
}
|
341 |
-
|
342 |
-
/**
|
343 |
-
* It will create the plugin tables & the options reqired for plugin.
|
344 |
-
* @hook register_activation_hook
|
345 |
-
* @globals mixed $wpdb
|
346 |
-
* @since 1.0
|
347 |
-
*/
|
348 |
-
function wcal_activate() {
|
349 |
-
global $wpdb;
|
350 |
-
$wcap_collate = '';
|
351 |
-
if ( $wpdb->has_cap( 'collation' ) ) {
|
352 |
-
$wcap_collate = $wpdb->get_charset_collate();
|
353 |
-
}
|
354 |
-
$table_name = $wpdb->prefix . "ac_email_templates_lite";
|
355 |
-
$sql = "CREATE TABLE IF NOT EXISTS $table_name (
|
356 |
-
`id` int(11) NOT NULL AUTO_INCREMENT,
|
357 |
-
`subject` text NOT NULL,
|
358 |
-
`body` mediumtext NOT NULL,
|
359 |
-
`is_active` enum('0','1') NOT NULL,
|
360 |
-
`frequency` int(11) NOT NULL,
|
361 |
-
`day_or_hour` enum('Days','Hours') NOT NULL,
|
362 |
-
`template_name` text NOT NULL,
|
363 |
-
`is_wc_template` enum('0','1') NOT NULL,
|
364 |
-
`default_template` int(11) NOT NULL,
|
365 |
-
`wc_email_header` varchar(50) NOT NULL,
|
366 |
-
PRIMARY KEY (`id`)
|
367 |
-
) $wcap_collate AUTO_INCREMENT=1 ";
|
368 |
-
|
369 |
-
require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
370 |
-
dbDelta( $sql );
|
371 |
-
|
372 |
-
// $table_name = $wpdb->prefix . "ac_email_templates_lite";
|
373 |
-
// $check_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'is_wc_template' ";
|
374 |
-
// $results = $wpdb->get_results( $check_template_table_query );
|
375 |
-
|
376 |
-
// if ( count( $results ) == 0 ) {
|
377 |
-
// $alter_template_table_query = "ALTER TABLE $table_name
|
378 |
-
// ADD COLUMN `is_wc_template` enum('0','1') COLLATE utf8mb4_unicode_ci NOT NULL AFTER `template_name`,
|
379 |
-
// ADD COLUMN `default_template` int(11) NOT NULL AFTER `is_wc_template`";
|
380 |
-
|
381 |
-
// $wpdb->get_results( $alter_template_table_query );
|
382 |
-
// }
|
383 |
-
|
384 |
-
$sent_table_name = $wpdb->prefix . "ac_sent_history_lite";
|
385 |
-
|
386 |
-
$sql_query = "CREATE TABLE IF NOT EXISTS $sent_table_name (
|
387 |
-
`id` int(11) NOT NULL auto_increment,
|
388 |
-
`template_id` varchar(40) collate utf8_unicode_ci NOT NULL,
|
389 |
-
`abandoned_order_id` int(11) NOT NULL,
|
390 |
-
`sent_time` datetime NOT NULL,
|
391 |
-
`sent_email_id` text COLLATE utf8_unicode_ci NOT NULL,
|
392 |
-
PRIMARY KEY (`id`)
|
393 |
-
) $wcap_collate AUTO_INCREMENT=1 ";
|
394 |
-
|
395 |
-
require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
396 |
-
dbDelta ( $sql_query );
|
397 |
-
|
398 |
-
$ac_history_table_name = $wpdb->prefix . "ac_abandoned_cart_history_lite";
|
399 |
-
|
400 |
-
$history_query = "CREATE TABLE IF NOT EXISTS $ac_history_table_name (
|
401 |
-
`id` int(11) NOT NULL AUTO_INCREMENT,
|
402 |
-
`user_id` int(11) NOT NULL,
|
403 |
-
`abandoned_cart_info` text COLLATE utf8_unicode_ci NOT NULL,
|
404 |
-
`abandoned_cart_time` int(11) NOT NULL,
|
405 |
-
`cart_ignored` enum('0','1') COLLATE utf8_unicode_ci NOT NULL,
|
406 |
-
`recovered_cart` int(11) NOT NULL,
|
407 |
-
`user_type` text,
|
408 |
-
`unsubscribe_link` enum('0','1') COLLATE utf8_unicode_ci NOT NULL,
|
409 |
-
`session_id` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
|
410 |
-
PRIMARY KEY (`id`)
|
411 |
-
) $wcap_collate";
|
412 |
-
|
413 |
-
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
414 |
-
dbDelta( $history_query );
|
415 |
-
// Default templates: function call to create default templates.
|
416 |
-
$check_table_empty = $wpdb->get_var( "SELECT COUNT(*) FROM `" . $wpdb->prefix . "ac_email_templates_lite`" );
|
417 |
-
|
418 |
-
if ( ! get_option( 'wcal_new_default_templates' ) ) {
|
419 |
-
if ( 0 == $check_table_empty ) {
|
420 |
-
$default_template = new wcal_default_template_settings;
|
421 |
-
$default_template->wcal_create_default_templates();
|
422 |
-
update_option( 'wcal_new_default_templates', "yes" );
|
423 |
-
}
|
424 |
-
}
|
425 |
-
|
426 |
-
$guest_table = $wpdb->prefix."ac_guest_abandoned_cart_history_lite" ;
|
427 |
-
$query_guest_table = "SHOW TABLES LIKE '$guest_table' ";
|
428 |
-
$result_guest_table = $wpdb->get_results( $query_guest_table );
|
429 |
-
|
430 |
-
if ( 0 == count( $result_guest_table ) ) {
|
431 |
-
$ac_guest_history_table_name = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
|
432 |
-
$ac_guest_history_query = "CREATE TABLE IF NOT EXISTS $ac_guest_history_table_name (
|
433 |
-
`id` int(15) NOT NULL AUTO_INCREMENT,
|
434 |
-
`billing_first_name` text,
|
435 |
-
`billing_last_name` text,
|
436 |
-
`billing_company_name` text,
|
437 |
-
`billing_address_1` text,
|
438 |
-
`billing_address_2` text,
|
439 |
-
`billing_city` text,
|
440 |
-
`billing_county` text,
|
441 |
-
`billing_zipcode` text,
|
442 |
-
`email_id` text,
|
443 |
-
`phone` text,
|
444 |
-
`ship_to_billing` text,
|
445 |
-
`order_notes` text,
|
446 |
-
`shipping_first_name` text,
|
447 |
-
`shipping_last_name` text,
|
448 |
-
`shipping_company_name` text,
|
449 |
-
`shipping_address_1` text,
|
450 |
-
`shipping_address_2` text,
|
451 |
-
`shipping_city` text,
|
452 |
-
`shipping_county` text,
|
453 |
-
`shipping_zipcode` double,
|
454 |
-
`shipping_charges` double,
|
455 |
-
PRIMARY KEY (`id`)
|
456 |
-
) $wcap_collate AUTO_INCREMENT=63000000";
|
457 |
-
require_once( ABSPATH . 'wp-admin/includes/upgrade.php');
|
458 |
-
$wpdb->query( $ac_guest_history_query );
|
459 |
-
}
|
460 |
-
|
461 |
-
/**
|
462 |
-
* This is add for thos user who Install the plguin first time.
|
463 |
-
* So for them this option will be cheked.
|
464 |
-
*/
|
465 |
-
if ( ! get_option( 'ac_lite_track_guest_cart_from_cart_page' ) ) {
|
466 |
-
add_option( 'ac_lite_track_guest_cart_from_cart_page', 'on' );
|
467 |
-
}
|
468 |
-
if ( ! get_option( 'wcal_from_name' ) ) {
|
469 |
-
add_option( 'wcal_from_name', 'Admin' );
|
470 |
-
}
|
471 |
-
$wcal_get_admin_email = get_option( 'admin_email' );
|
472 |
-
if ( ! get_option( 'wcal_from_email' ) ) {
|
473 |
-
add_option( 'wcal_from_email', $wcal_get_admin_email );
|
474 |
-
}
|
475 |
-
|
476 |
-
if ( ! get_option( 'wcal_reply_email' ) ) {
|
477 |
-
add_option( 'wcal_reply_email', $wcal_get_admin_email );
|
478 |
-
}
|
479 |
-
|
480 |
-
do_action( 'wcal_activate' );
|
481 |
-
}
|
482 |
-
|
483 |
-
/**
|
484 |
-
* It will add the section, field, & registres the plugin fields using Settings API.
|
485 |
-
* @hook admin_init
|
486 |
-
* @since 2.5
|
487 |
-
*/
|
488 |
-
function wcal_initialize_plugin_options() {
|
489 |
-
|
490 |
-
// First, we register a section. This is necessary since all future options must belong to a
|
491 |
-
add_settings_section(
|
492 |
-
'ac_lite_general_settings_section', // ID used to identify this section and with which to register options
|
493 |
-
__( 'Settings', 'woocommerce-abandoned-cart' ), // Title to be displayed on the administration page
|
494 |
-
array( $this, 'ac_lite_general_options_callback' ), // Callback used to render the description of the section
|
495 |
-
'woocommerce_ac_page' // Page on which to add this section of options
|
496 |
-
);
|
497 |
-
|
498 |
-
add_settings_field(
|
499 |
-
'ac_lite_cart_abandoned_time',
|
500 |
-
__( 'Cart abandoned cut-off time', 'woocommerce-abandoned-cart' ),
|
501 |
-
array( $this, 'ac_lite_cart_abandoned_time_callback' ),
|
502 |
-
'woocommerce_ac_page',
|
503 |
-
'ac_lite_general_settings_section',
|
504 |
-
array( __( 'Consider cart abandoned after X minutes of item being added to cart & order not placed.', 'woocommerce-abandoned-cart' ) )
|
505 |
-
);
|
506 |
-
|
507 |
-
add_settings_field(
|
508 |
-
'ac_lite_delete_abandoned_order_days',
|
509 |
-
__( 'Automatically Delete Abandoned Orders after X days', 'woocommerce-abandoned-cart' ),
|
510 |
-
array( $this, 'wcal_delete_abandoned_orders_days_callback' ),
|
511 |
-
'woocommerce_ac_page',
|
512 |
-
'ac_lite_general_settings_section',
|
513 |
-
array( __( 'Automatically delete abandoned cart orders after X days.', 'woocommerce-abandoned-cart' ) )
|
514 |
-
);
|
515 |
-
|
516 |
-
|
517 |
-
add_settings_field(
|
518 |
-
'ac_lite_email_admin_on_recovery',
|
519 |
-
__( 'Email admin On Order Recovery', 'woocommerce-abandoned-cart' ),
|
520 |
-
array( $this, 'ac_lite_email_admin_on_recovery' ),
|
521 |
-
'woocommerce_ac_page',
|
522 |
-
'ac_lite_general_settings_section',
|
523 |
-
array( __( 'Sends email to Admin if an Abandoned Cart Order is recovered.', 'woocommerce-abandoned-cart' ) )
|
524 |
-
);
|
525 |
-
|
526 |
-
|
527 |
-
add_settings_field(
|
528 |
-
'ac_lite_track_guest_cart_from_cart_page',
|
529 |
-
__( 'Start tracking from Cart Page', 'woocommerce-abandoned-cart' ),
|
530 |
-
array( $this, 'wcal_track_guest_cart_from_cart_page_callback' ),
|
531 |
-
'woocommerce_ac_page',
|
532 |
-
'ac_lite_general_settings_section',
|
533 |
-
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-abandoned-cart' ) )
|
534 |
-
);
|
535 |
-
|
536 |
-
add_settings_field(
|
537 |
-
'wcal_guest_cart_capture_msg',
|
538 |
-
__( 'Message to be displayed for Guest users when tracking their carts', 'woocommerce-abandoned-cart' ),
|
539 |
-
array( $this, 'wcal_guest_cart_capture_msg_callback' ),
|
540 |
-
'woocommerce_ac_page',
|
541 |
-
'ac_lite_general_settings_section',
|
542 |
-
array( __( '<br>In compliance with GDPR, add a message on the Checkout page to inform Guest users of how their data is being used.<br><i>For example: Your email address will help us support your shopping experience throughout the site. Please check our Privacy Policy to see how we use your personal data.</i>', 'woocommerce-abandoned-cart' ) )
|
543 |
-
);
|
544 |
-
|
545 |
-
add_settings_field(
|
546 |
-
'wcal_logged_cart_capture_msg',
|
547 |
-
__( 'Message to be displayed for registered users when tracking their carts.', 'woocommerce-abandoned-cart' ),
|
548 |
-
array( $this, 'wcal_logged_cart_capture_msg_callback' ),
|
549 |
-
'woocommerce_ac_page',
|
550 |
-
'ac_lite_general_settings_section',
|
551 |
-
array( __( '<br>In compliance with GDPR, add a message on the Shop & Product pages to inform Registered users of how their data is being used.<br><i>For example: Please check our Privacy Policy to see how we use your personal data.</i>', 'woocommerce-abandoned-cart' ) )
|
552 |
-
);
|
553 |
-
|
554 |
-
/**
|
555 |
-
* New section for the Adding the abandoned cart setting.
|
556 |
-
* @since 4.7
|
557 |
-
*/
|
558 |
-
|
559 |
-
add_settings_section(
|
560 |
-
'ac_email_settings_section', // ID used to identify this section and with which to register options
|
561 |
-
__( 'Settings for abandoned cart recovery emails', 'woocommerce-abandoned-cart' ), // Title to be displayed on the administration page
|
562 |
-
array( $this, 'wcal_email_callback' ), // Callback used to render the description of the section
|
563 |
-
'woocommerce_ac_email_page' // Page on which to add this section of options
|
564 |
-
);
|
565 |
-
|
566 |
-
add_settings_field(
|
567 |
-
'wcal_from_name',
|
568 |
-
__( '"From" Name', 'woocommerce-abandoned-cart' ),
|
569 |
-
array( $this, 'wcal_from_name_callback' ),
|
570 |
-
'woocommerce_ac_email_page',
|
571 |
-
'ac_email_settings_section',
|
572 |
-
array( 'Enter the name that should appear in the email sent.', 'woocommerce-abandoned-cart' )
|
573 |
-
);
|
574 |
-
|
575 |
-
add_settings_field(
|
576 |
-
'wcal_from_email',
|
577 |
-
__( '"From" Address', 'woocommerce-abandoned-cart' ),
|
578 |
-
array( $this, 'wcal_from_email_callback' ),
|
579 |
-
'woocommerce_ac_email_page',
|
580 |
-
'ac_email_settings_section',
|
581 |
-
array( 'Email address from which the reminder emails should be sent.', 'woocommerce-abandoned-cart' )
|
582 |
-
);
|
583 |
-
|
584 |
-
add_settings_field(
|
585 |
-
'wcal_reply_email',
|
586 |
-
__( 'Send Reply Emails to', 'woocommerce-abandoned-cart' ),
|
587 |
-
array( $this, 'wcal_reply_email_callback' ),
|
588 |
-
'woocommerce_ac_email_page',
|
589 |
-
'ac_email_settings_section',
|
590 |
-
array( 'When a contact receives your email and clicks reply, which email address should that reply be sent to?', 'woocommerce-abandoned-cart' )
|
591 |
-
);
|
592 |
-
|
593 |
-
// Finally, we register the fields with WordPress
|
594 |
-
register_setting(
|
595 |
-
'woocommerce_ac_settings',
|
596 |
-
'ac_lite_cart_abandoned_time',
|
597 |
-
array ( $this, 'ac_lite_cart_time_validation' )
|
598 |
-
);
|
599 |
-
|
600 |
-
register_setting(
|
601 |
-
'woocommerce_ac_settings',
|
602 |
-
'ac_lite_delete_abandoned_order_days',
|
603 |
-
array ( $this, 'wcal_delete_days_validation' )
|
604 |
-
);
|
605 |
-
|
606 |
-
register_setting(
|
607 |
-
'woocommerce_ac_settings',
|
608 |
-
'ac_lite_email_admin_on_recovery'
|
609 |
-
);
|
610 |
-
|
611 |
-
register_setting(
|
612 |
-
'woocommerce_ac_settings',
|
613 |
-
'ac_lite_track_guest_cart_from_cart_page'
|
614 |
-
);
|
615 |
-
|
616 |
-
register_setting(
|
617 |
-
'woocommerce_ac_settings',
|
618 |
-
'wcal_guest_cart_capture_msg'
|
619 |
-
);
|
620 |
-
|
621 |
-
register_setting(
|
622 |
-
'woocommerce_ac_settings',
|
623 |
-
'wcal_logged_cart_capture_msg'
|
624 |
-
);
|
625 |
-
|
626 |
-
register_setting(
|
627 |
-
'woocommerce_ac_email_settings',
|
628 |
-
'wcal_from_name'
|
629 |
-
);
|
630 |
-
register_setting(
|
631 |
-
'woocommerce_ac_email_settings',
|
632 |
-
'wcal_from_email'
|
633 |
-
);
|
634 |
-
register_setting(
|
635 |
-
'woocommerce_ac_email_settings',
|
636 |
-
'wcal_reply_email'
|
637 |
-
);
|
638 |
-
|
639 |
-
do_action ( "wcal_add_new_settings" );
|
640 |
-
}
|
641 |
-
|
642 |
-
/**
|
643 |
-
* Settings API callback for section "ac_lite_general_settings_section".
|
644 |
-
* @since 2.5
|
645 |
-
*/
|
646 |
-
function ac_lite_general_options_callback() {
|
647 |
-
|
648 |
-
}
|
649 |
-
|
650 |
-
/**
|
651 |
-
* Settings API callback for cart time field.
|
652 |
-
* @param array $args Arguments
|
653 |
-
* @since 2.5
|
654 |
-
*/
|
655 |
-
function ac_lite_cart_abandoned_time_callback( $args ) {
|
656 |
-
// First, we read the option
|
657 |
-
$cart_abandoned_time = get_option( 'ac_lite_cart_abandoned_time' );
|
658 |
-
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
659 |
-
// We also access the show_header element of the options collection in the call to the checked() helper function
|
660 |
-
printf(
|
661 |
-
'<input type="text" id="ac_lite_cart_abandoned_time" name="ac_lite_cart_abandoned_time" value="%s" />',
|
662 |
-
isset( $cart_abandoned_time ) ? esc_attr( $cart_abandoned_time ) : ''
|
663 |
-
);
|
664 |
-
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
665 |
-
$html = '<label for="ac_lite_cart_abandoned_time"> ' . $args[0] . '</label>';
|
666 |
-
echo $html;
|
667 |
-
}
|
668 |
-
|
669 |
-
/**
|
670 |
-
* Settings API cart time field validation.
|
671 |
-
* @param int | string $input
|
672 |
-
* @return int | string $output
|
673 |
-
* @since 2.5
|
674 |
-
*/
|
675 |
-
function ac_lite_cart_time_validation( $input ) {
|
676 |
-
$output = '';
|
677 |
-
if ( '' != $input && ( is_numeric( $input) && $input > 0 ) ) {
|
678 |
-
$output = stripslashes( $input) ;
|
679 |
-
} else {
|
680 |
-
add_settings_error( 'ac_lite_cart_abandoned_time', 'error found', __( 'Abandoned cart cut off time should be numeric and has to be greater than 0.', 'woocommerce-abandoned-cart' ) );
|
681 |
-
}
|
682 |
-
return $output;
|
683 |
-
}
|
684 |
-
|
685 |
-
/**
|
686 |
-
* Validation for automatically delete abandoned carts after X days.
|
687 |
-
* @param int | string $input input of the field Abandoned cart cut off time
|
688 |
-
* @return int | string $output Error message or the input value
|
689 |
-
* @since 5.0
|
690 |
-
*/
|
691 |
-
public static function wcal_delete_days_validation( $input ) {
|
692 |
-
$output = '';
|
693 |
-
if ( '' == $input || ( is_numeric( $input ) && $input > 0 ) ) {
|
694 |
-
$output = stripslashes( $input );
|
695 |
-
} else {
|
696 |
-
add_settings_error( 'ac_lite_delete_abandoned_order_days', 'error found', __( 'Automatically Delete Abandoned Orders after X days has to be greater than 0.', 'woocommerce-abandoned-cart' ) );
|
697 |
-
}
|
698 |
-
return $output;
|
699 |
-
}
|
700 |
-
|
701 |
-
/**
|
702 |
-
* Callback for deleting abandoned order after X days field.
|
703 |
-
* @param array $args Argument given while adding the field
|
704 |
-
* @since 5.0
|
705 |
-
*/
|
706 |
-
public static function wcal_delete_abandoned_orders_days_callback( $args ) {
|
707 |
-
// First, we read the option
|
708 |
-
$delete_abandoned_order_days = get_option( 'ac_lite_delete_abandoned_order_days' );
|
709 |
-
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
710 |
-
// We also access the show_header element of the options collection in the call to the checked() helper function
|
711 |
-
printf(
|
712 |
-
'<input type="text" id="ac_lite_delete_abandoned_order_days" name="ac_lite_delete_abandoned_order_days" value="%s" />',
|
713 |
-
isset( $delete_abandoned_order_days ) ? esc_attr( $delete_abandoned_order_days ) : ''
|
714 |
-
);
|
715 |
-
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
716 |
-
$html = '<label for="ac_lite_delete_abandoned_order_days"> ' . $args[0] . '</label>';
|
717 |
-
echo $html;
|
718 |
-
}
|
719 |
-
|
720 |
-
/**
|
721 |
-
* Settings API callback for email admin on cart recovery field.
|
722 |
-
* @param array $args Arguments
|
723 |
-
* @since 2.5
|
724 |
-
*/
|
725 |
-
function ac_lite_email_admin_on_recovery( $args ) {
|
726 |
-
// First, we read the option
|
727 |
-
$email_admin_on_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
|
728 |
-
|
729 |
-
// This condition added to avoid the notie displyed while Check box is unchecked.
|
730 |
-
if ( isset( $email_admin_on_recovery ) && '' == $email_admin_on_recovery ) {
|
731 |
-
$email_admin_on_recovery = 'off';
|
732 |
-
}
|
733 |
-
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
734 |
-
// We also access the show_header element of the options collection in the call to the checked() helper function
|
735 |
-
$html='';
|
736 |
-
printf(
|
737 |
-
'<input type="checkbox" id="ac_lite_email_admin_on_recovery" name="ac_lite_email_admin_on_recovery" value="on"
|
738 |
-
' . checked('on', $email_admin_on_recovery, false).' />'
|
739 |
-
);
|
740 |
-
|
741 |
-
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
742 |
-
$html .= '<label for="ac_lite_email_admin_on_recovery"> ' . $args[0] . '</label>';
|
743 |
-
echo $html;
|
744 |
-
}
|
745 |
-
/**
|
746 |
-
* Settings API callback for capturing guest cart which do not reach the checkout page.
|
747 |
-
* @param array $args Arguments
|
748 |
-
* @since 2.7
|
749 |
-
*/
|
750 |
-
function wcal_track_guest_cart_from_cart_page_callback( $args ) {
|
751 |
-
// First, we read the option
|
752 |
-
$disable_guest_cart_from_cart_page = get_option( 'ac_lite_track_guest_cart_from_cart_page' );
|
753 |
-
|
754 |
-
// This condition added to avoid the notice displyed while Check box is unchecked.
|
755 |
-
if ( isset( $disable_guest_cart_from_cart_page ) && '' == $disable_guest_cart_from_cart_page ) {
|
756 |
-
$disable_guest_cart_from_cart_page = 'off';
|
757 |
-
}
|
758 |
-
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
759 |
-
// We also access the show_header element of the options collection in the call to the checked() helper function
|
760 |
-
$html = '';
|
761 |
-
|
762 |
-
printf(
|
763 |
-
'<input type="checkbox" id="ac_lite_track_guest_cart_from_cart_page" name="ac_lite_track_guest_cart_from_cart_page" value="on"
|
764 |
-
'.checked( 'on', $disable_guest_cart_from_cart_page, false ) . ' />' );
|
765 |
-
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
766 |
-
$html .= '<label for="ac_lite_track_guest_cart_from_cart_page"> ' . $args[0] . '</label>';
|
767 |
-
echo $html;
|
768 |
-
}
|
769 |
-
|
770 |
-
/**
|
771 |
-
* Call back function for guest user cart capture message
|
772 |
-
* @param array $args Argument for adding field details
|
773 |
-
* @since 7.8
|
774 |
-
*/
|
775 |
-
public static function wcal_guest_cart_capture_msg_callback( $args ) {
|
776 |
-
|
777 |
-
$guest_msg = get_option( 'wcal_guest_cart_capture_msg' );
|
778 |
-
|
779 |
-
$html = "<textarea rows='4' cols='80' id='wcal_guest_cart_capture_msg' name='wcal_guest_cart_capture_msg'>$guest_msg</textarea>";
|
780 |
-
|
781 |
-
$html .= '<label for="wcal_guest_cart_capture_msg"> ' . $args[0] . '</label>';
|
782 |
-
echo $html;
|
783 |
-
}
|
784 |
-
|
785 |
-
/**
|
786 |
-
* Call back function for registered user cart capture message
|
787 |
-
* @param array $args Argument for adding field details
|
788 |
-
* @since 7.8
|
789 |
-
*/
|
790 |
-
public static function wcal_logged_cart_capture_msg_callback( $args ) {
|
791 |
-
|
792 |
-
$logged_msg = get_option( 'wcal_logged_cart_capture_msg' );
|
793 |
-
|
794 |
-
$html = "<input type='text' class='regular-text' id='wcal_logged_cart_capture_msg' name='wcal_logged_cart_capture_msg' value='$logged_msg' />";
|
795 |
-
|
796 |
-
$html .= '<label for="wcal_logged_cart_capture_msg"> ' . $args[0] . '</label>';
|
797 |
-
echo $html;
|
798 |
-
}
|
799 |
-
|
800 |
-
/**
|
801 |
-
* Settings API callback for Abandoned cart email settings of the plugin.
|
802 |
-
* @since 3.5
|
803 |
-
*/
|
804 |
-
function wcal_email_callback () {
|
805 |
-
|
806 |
-
}
|
807 |
-
|
808 |
-
/**
|
809 |
-
* Settings API callback for from name used in Abandoned cart email.
|
810 |
-
* @param array $args Arguments
|
811 |
-
* @since 3.5
|
812 |
-
*/
|
813 |
-
public static function wcal_from_name_callback( $args ) {
|
814 |
-
// First, we read the option
|
815 |
-
$wcal_from_name = get_option( 'wcal_from_name' );
|
816 |
-
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
817 |
-
// We also access the show_header element of the options collection in the call to the checked() helper function
|
818 |
-
printf(
|
819 |
-
'<input type="text" id="wcal_from_name" name="wcal_from_name" value="%s" />',
|
820 |
-
isset( $wcal_from_name ) ? esc_attr( $wcal_from_name ) : ''
|
821 |
-
);
|
822 |
-
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
823 |
-
$html = '<label for="wcal_from_name_label"> ' . $args[0] . '</label>';
|
824 |
-
echo $html;
|
825 |
-
}
|
826 |
-
|
827 |
-
/**
|
828 |
-
* Settings API callback for from email used in Abandoned cart email.
|
829 |
-
* @param array $args Arguments
|
830 |
-
* @since 3.5
|
831 |
-
*/
|
832 |
-
public static function wcal_from_email_callback( $args ) {
|
833 |
-
// First, we read the option
|
834 |
-
$wcal_from_email = get_option( 'wcal_from_email' );
|
835 |
-
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
836 |
-
// We also access the show_header element of the options collection in the call to the checked() helper function
|
837 |
-
printf(
|
838 |
-
'<input type="text" id="wcal_from_email" name="wcal_from_email" value="%s" />',
|
839 |
-
isset( $wcal_from_email ) ? esc_attr( $wcal_from_email ) : ''
|
840 |
-
);
|
841 |
-
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
842 |
-
$html = '<label for="wcal_from_email_label"> ' . $args[0] . '</label>';
|
843 |
-
echo $html;
|
844 |
-
}
|
845 |
-
|
846 |
-
/**
|
847 |
-
* Settings API callback for reply email used in Abandoned cart email.
|
848 |
-
* @param array $args Arguments
|
849 |
-
* @since 3.5
|
850 |
-
*/
|
851 |
-
public static function wcal_reply_email_callback( $args ) {
|
852 |
-
// First, we read the option
|
853 |
-
$wcal_reply_email = get_option( 'wcal_reply_email' );
|
854 |
-
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
855 |
-
// We also access the show_header element of the options collection in the call to the checked() helper function
|
856 |
-
printf(
|
857 |
-
'<input type="text" id="wcal_reply_email" name="wcal_reply_email" value="%s" />',
|
858 |
-
isset( $wcal_reply_email ) ? esc_attr( $wcal_reply_email ) : ''
|
859 |
-
);
|
860 |
-
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
861 |
-
$html = '<label for="wcal_reply_email_label"> ' . $args[0] . '</label>';
|
862 |
-
echo $html;
|
863 |
-
}
|
864 |
-
|
865 |
-
/**
|
866 |
-
* It will be executed when the plugin is upgraded.
|
867 |
-
* @hook admin_init
|
868 |
-
* @globals mixed $wpdb
|
869 |
-
* @since 1.0
|
870 |
-
*/
|
871 |
-
function wcal_update_db_check() {
|
872 |
-
global $wpdb;
|
873 |
-
|
874 |
-
$wcal_previous_version = get_option( 'wcal_previous_version' );
|
875 |
-
|
876 |
-
if ( $wcal_previous_version != wcal_common::wcal_get_version() ) {
|
877 |
-
update_option( 'wcal_previous_version', '5.3.
|
878 |
-
}
|
879 |
-
|
880 |
-
/**
|
881 |
-
* This is used to prevent guest users wrong Id. If guest users id is less then 63000000 then this code will
|
882 |
-
* ensure that we will change the id of guest tables so it wont affect on the next guest users.
|
883 |
-
*/
|
884 |
-
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_guest_abandoned_cart_history_lite';" ) && 'yes' != get_option( 'wcal_guest_user_id_altered' ) ) {
|
885 |
-
$last_id = $wpdb->get_var( "SELECT max(id) FROM `{$wpdb->prefix}ac_guest_abandoned_cart_history_lite`;" );
|
886 |
-
if ( NULL != $last_id && $last_id <= 63000000 ) {
|
887 |
-
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_guest_abandoned_cart_history_lite AUTO_INCREMENT = 63000000;" );
|
888 |
-
update_option ( 'wcal_guest_user_id_altered', 'yes' );
|
889 |
-
}
|
890 |
-
}
|
891 |
-
|
892 |
-
if( !get_option( 'wcal_new_default_templates' ) ) {
|
893 |
-
$default_template = new wcal_default_template_settings;
|
894 |
-
$default_template->wcal_create_default_templates();
|
895 |
-
add_option( 'wcal_new_default_templates', "yes" );
|
896 |
-
|
897 |
-
}
|
898 |
-
if ( 'yes' != get_option( 'ac_lite_alter_table_queries' ) ) {
|
899 |
-
$ac_history_table_name = $wpdb->prefix."ac_abandoned_cart_history_lite";
|
900 |
-
$check_table_query = "SHOW COLUMNS FROM $ac_history_table_name LIKE 'user_type'";
|
901 |
-
$results = $wpdb->get_results( $check_table_query );
|
902 |
-
|
903 |
-
if ( 0 == count( $results ) ) {
|
904 |
-
$alter_table_query = "ALTER TABLE $ac_history_table_name ADD `user_type` text AFTER `recovered_cart`";
|
905 |
-
$wpdb->get_results( $alter_table_query );
|
906 |
-
}
|
907 |
-
|
908 |
-
$table_name = $wpdb->prefix . "ac_email_templates_lite";
|
909 |
-
$check_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'is_wc_template' ";
|
910 |
-
$results = $wpdb->get_results( $check_template_table_query );
|
911 |
-
|
912 |
-
if ( 0 == count( $results ) ) {
|
913 |
-
$alter_template_table_query = "ALTER TABLE $table_name
|
914 |
-
ADD COLUMN `is_wc_template` enum('0','1') COLLATE utf8_unicode_ci NOT NULL AFTER `template_name`,
|
915 |
-
ADD COLUMN `default_template` int(11) NOT NULL AFTER `is_wc_template`";
|
916 |
-
$wpdb->get_results( $alter_template_table_query );
|
917 |
-
}
|
918 |
-
|
919 |
-
$table_name = $wpdb->prefix . "ac_email_templates_lite";
|
920 |
-
$check_email_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'wc_email_header' ";
|
921 |
-
$results_email = $wpdb->get_results( $check_email_template_table_query );
|
922 |
-
|
923 |
-
if ( 0 == count( $results_email ) ) {
|
924 |
-
$alter_email_template_table_query = "ALTER TABLE $table_name
|
925 |
-
ADD COLUMN `wc_email_header` varchar(50) NOT NULL AFTER `default_template`";
|
926 |
-
$wpdb->get_results( $alter_email_template_table_query );
|
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 'unsubscribe_link';" ) ) {
|
931 |
-
$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`;" );
|
932 |
-
}
|
933 |
-
}
|
934 |
-
|
935 |
-
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_abandoned_cart_history_lite';" ) ) {
|
936 |
-
if ( ! $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_abandoned_cart_history_lite` LIKE 'session_id';" ) ) {
|
937 |
-
$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`;" );
|
938 |
-
}
|
939 |
-
}
|
940 |
-
|
941 |
-
/**
|
942 |
-
* We have moved email templates fields in the setings section. SO to remove that fields column fro the db we need it.
|
943 |
-
* For existing user we need to fill this setting with the first template.
|
944 |
-
* @since 4.7
|
945 |
-
*/
|
946 |
-
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_email_templates_lite';" ) ) {
|
947 |
-
if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'from_email';" ) ) {
|
948 |
-
$get_email_template_query = "SELECT `from_email` FROM {$wpdb->prefix}ac_email_templates_lite WHERE `is_active` = '1' ORDER BY `id` ASC LIMIT 1";
|
949 |
-
$get_email_template_result = $wpdb->get_results ( $get_email_template_query );
|
950 |
-
$wcal_from_email = '';
|
951 |
-
if ( isset( $get_email_template_result ) && count ( $get_email_template_result ) > 0 ){
|
952 |
-
$wcal_from_email = $get_email_template_result[0]->from_email;
|
953 |
-
/* Store data in setings api*/
|
954 |
-
update_option ( 'wcal_from_email', $wcal_from_email );
|
955 |
-
/* Delete table from the Db*/
|
956 |
-
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_email_templates_lite DROP COLUMN `from_email`;" );
|
957 |
-
}
|
958 |
-
}
|
959 |
-
|
960 |
-
if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'from_name';" ) ) {
|
961 |
-
$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";
|
962 |
-
$get_email_template_from_name_result = $wpdb->get_results ( $get_email_template_from_name_query );
|
963 |
-
$wcal_from_name = '';
|
964 |
-
if ( isset( $get_email_template_from_name_result ) && count ( $get_email_template_from_name_result ) > 0 ){
|
965 |
-
$wcal_from_name = $get_email_template_from_name_result[0]->from_name;
|
966 |
-
/* Store data in setings api*/
|
967 |
-
add_option ( 'wcal_from_name', $wcal_from_name );
|
968 |
-
/* Delete table from the Db*/
|
969 |
-
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_email_templates_lite DROP COLUMN `from_name`;" );
|
970 |
-
}
|
971 |
-
}
|
972 |
-
|
973 |
-
if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'reply_email';" ) ) {
|
974 |
-
$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";
|
975 |
-
$get_email_template_reply_email_result = $wpdb->get_results ( $get_email_template_reply_email_query);
|
976 |
-
$wcal_reply_email = '';
|
977 |
-
if ( isset( $get_email_template_reply_email_result ) && count ( $get_email_template_reply_email_result ) > 0 ){
|
978 |
-
$wcal_reply_email = $get_email_template_reply_email_result[0]->reply_email;
|
979 |
-
/* Store data in setings api*/
|
980 |
-
update_option ( 'wcal_reply_email', $wcal_reply_email );
|
981 |
-
/* Delete table from the Db*/
|
982 |
-
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_email_templates_lite DROP COLUMN `reply_email`;" );
|
983 |
-
}
|
984 |
-
}
|
985 |
-
}
|
986 |
-
|
987 |
-
if ( ! get_option( 'wcal_security_key' ) ) {
|
988 |
-
update_option( 'wcal_security_key', 'qJB0rGtIn5UB1xG03efyCp' );
|
989 |
-
}
|
990 |
-
|
991 |
-
update_option( 'ac_lite_alter_table_queries', 'yes' );
|
992 |
-
}
|
993 |
-
|
994 |
-
//get the option, if it is not set to individual then convert to individual records and delete the base record
|
995 |
-
$ac_settings = get_option( 'ac_lite_settings_status' );
|
996 |
-
if ( 'INDIVIDUAL' != $ac_settings ) {
|
997 |
-
//fetch the existing settings and save them as inidividual to be used for the settings API
|
998 |
-
$woocommerce_ac_settings = json_decode( get_option( 'woocommerce_ac_settings' ) );
|
999 |
-
|
1000 |
-
if ( isset( $woocommerce_ac_settings[0]->cart_time ) ) {
|
1001 |
-
add_option( 'ac_lite_cart_abandoned_time', $woocommerce_ac_settings[0]->cart_time );
|
1002 |
-
} else {
|
1003 |
-
add_option( 'ac_lite_cart_abandoned_time', '10' );
|
1004 |
-
}
|
1005 |
-
|
1006 |
-
if ( isset( $woocommerce_ac_settings[0]->delete_order_days ) ) {
|
1007 |
-
add_option( 'ac_lite_delete_abandoned_order_days', $woocommerce_ac_settings[0]->delete_order_days );
|
1008 |
-
} else {
|
1009 |
-
add_option( 'ac_lite_delete_abandoned_order_days', "" );
|
1010 |
-
}
|
1011 |
-
|
1012 |
-
if ( isset( $woocommerce_ac_settings[0]->email_admin ) ) {
|
1013 |
-
add_option( 'ac_lite_email_admin_on_recovery', $woocommerce_ac_settings[0]->email_admin );
|
1014 |
-
} else {
|
1015 |
-
add_option( 'ac_lite_email_admin_on_recovery', "" );
|
1016 |
-
}
|
1017 |
-
|
1018 |
-
if ( isset( $woocommerce_ac_settings[0]->disable_guest_cart_from_cart_page ) ) {
|
1019 |
-
add_option( 'ac_lite_track_guest_cart_from_cart_page', $woocommerce_ac_settings[0]->disable_guest_cart_from_cart_page );
|
1020 |
-
} else {
|
1021 |
-
add_option( 'ac_lite_track_guest_cart_from_cart_page', "" );
|
1022 |
-
}
|
1023 |
-
|
1024 |
-
update_option( 'ac_lite_settings_status', 'INDIVIDUAL' );
|
1025 |
-
//Delete the main settings record
|
1026 |
-
delete_option( 'woocommerce_ac_settings' );
|
1027 |
-
}
|
1028 |
-
|
1029 |
-
if ( 'yes' != get_option( 'ac_lite_delete_redundant_queries' ) ) {
|
1030 |
-
$ac_history_table_name = $wpdb->prefix."ac_abandoned_cart_history_lite";
|
1031 |
-
|
1032 |
-
$wpdb->delete( $ac_history_table_name, array( 'abandoned_cart_info' => '{"cart":[]}' ) );
|
1033 |
-
|
1034 |
-
update_option( 'ac_lite_delete_redundant_queries', 'yes' );
|
1035 |
-
}
|
1036 |
-
|
1037 |
-
if ( 'yes' !== get_option( 'ac_lite_user_cleanup' ) ) {
|
1038 |
-
$query_cleanup = "UPDATE `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` SET
|
1039 |
-
billing_first_name = IF (billing_first_name LIKE '%<%', '', billing_first_name),
|
1040 |
-
billing_last_name = IF (billing_last_name LIKE '%<%', '', billing_last_name),
|
1041 |
-
billing_company_name = IF (billing_company_name LIKE '%<%', '', billing_company_name),
|
1042 |
-
billing_address_1 = IF (billing_address_1 LIKE '%<%', '', billing_address_1),
|
1043 |
-
billing_address_2 = IF (billing_address_2 LIKE '%<%', '', billing_address_2),
|
1044 |
-
billing_city = IF (billing_city LIKE '%<%', '', billing_city),
|
1045 |
-
billing_county = IF (billing_county LIKE '%<%', '', billing_county),
|
1046 |
-
billing_zipcode = IF (billing_zipcode LIKE '%<%', '', billing_zipcode),
|
1047 |
-
email_id = IF (email_id LIKE '%<%', '', email_id),
|
1048 |
-
phone = IF (phone LIKE '%<%', '', phone),
|
1049 |
-
ship_to_billing = IF (ship_to_billing LIKE '%<%', '', ship_to_billing),
|
1050 |
-
order_notes = IF (order_notes LIKE '%<%', '', order_notes),
|
1051 |
-
shipping_first_name = IF (shipping_first_name LIKE '%<%', '', shipping_first_name),
|
1052 |
-
shipping_last_name = IF (shipping_last_name LIKE '%<%', '', shipping_last_name),
|
1053 |
-
shipping_company_name = IF (shipping_company_name LIKE '%<%', '', shipping_company_name),
|
1054 |
-
shipping_address_1 = IF (shipping_address_1 LIKE '%<%', '', shipping_address_1),
|
1055 |
-
shipping_address_2 = IF (shipping_address_2 LIKE '%<%', '', shipping_address_2),
|
1056 |
-
shipping_city = IF (shipping_city LIKE '%<%', '', shipping_city),
|
1057 |
-
shipping_county = IF (shipping_county LIKE '%<%', '', shipping_county)";
|
1058 |
-
|
1059 |
-
$wpdb->query( $query_cleanup );
|
1060 |
-
|
1061 |
-
$email = 'woouser401a@mailinator.com';
|
1062 |
-
$exists = email_exists( $email );
|
1063 |
-
if ( $exists ) {
|
1064 |
-
wp_delete_user( esc_html( $exists ) );
|
1065 |
-
}
|
1066 |
-
|
1067 |
-
update_option( 'ac_lite_user_cleanup', 'yes' );
|
1068 |
-
}
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
*
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
$
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
if (
|
1118 |
-
$
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
$
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
$
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
$
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
$
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
$
|
1175 |
-
|
1176 |
-
$query_update
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
$
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
$
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
$
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
$wpdb->query( $
|
1260 |
-
}
|
1261 |
-
}
|
1262 |
-
}
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
$
|
1291 |
-
$
|
1292 |
-
$
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
$
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
$
|
1361 |
-
$
|
1362 |
-
$
|
1363 |
-
$
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
$
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
if (
|
1379 |
-
|
1380 |
-
|
1381 |
-
}
|
1382 |
-
$
|
1383 |
-
if ( $
|
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 |
-
$c['
|
1447 |
-
$c['
|
1448 |
-
$
|
1449 |
-
$
|
1450 |
-
$
|
1451 |
-
$
|
1452 |
-
$
|
1453 |
-
$
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
|
1459 |
-
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
$
|
1464 |
-
$
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
$woocommerce->session->
|
1471 |
-
$woocommerce->session->
|
1472 |
-
$woocommerce->session->
|
1473 |
-
$woocommerce->session->
|
1474 |
-
$woocommerce->
|
1475 |
-
$woocommerce->
|
1476 |
-
$woocommerce->
|
1477 |
-
$woocommerce->
|
1478 |
-
$woocommerce->
|
1479 |
-
$woocommerce->
|
1480 |
-
$woocommerce->
|
1481 |
-
$woocommerce->
|
1482 |
-
$woocommerce->cart->
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
$
|
1528 |
-
}
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
}
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
{
|
1593 |
-
|
1594 |
-
}
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
$active_emailtemplates = "
|
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 |
-
wp_enqueue_script( 'jquery
|
1718 |
-
wp_enqueue_script(
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
);
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
),
|
1746 |
-
'
|
1747 |
-
|
1748 |
-
|
1749 |
-
),
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
$in['
|
1788 |
-
$in['
|
1789 |
-
$in['
|
1790 |
-
$in['
|
1791 |
-
$in['
|
1792 |
-
$in['
|
1793 |
-
$in['
|
1794 |
-
$in['
|
1795 |
-
$in['
|
1796 |
-
$in['
|
1797 |
-
$in['
|
1798 |
-
|
1799 |
-
$in['
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
*
|
1842 |
-
*
|
1843 |
-
|
1844 |
-
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
if (
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
$
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
<div id="
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
if ( '
|
1942 |
-
$
|
1943 |
-
}
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
<?php
|
1969 |
-
<?php
|
1970 |
-
<?php
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
$
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
$
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
$
|
2009 |
-
}
|
2010 |
-
if ( '
|
2011 |
-
$
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
$
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
<?php
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
$
|
2074 |
-
|
2075 |
-
$
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
$
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
$
|
2102 |
-
|
2103 |
-
$
|
2104 |
-
|
2105 |
-
$
|
2106 |
-
|
2107 |
-
$
|
2108 |
-
$
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
$
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
$
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
|
2145 |
-
|
2146 |
-
|
2147 |
-
|
2148 |
-
|
2149 |
-
|
2150 |
-
|
2151 |
-
|
2152 |
-
|
2153 |
-
|
2154 |
-
|
2155 |
-
|
2156 |
-
|
2157 |
-
|
2158 |
-
|
2159 |
-
|
2160 |
-
|
2161 |
-
|
2162 |
-
|
2163 |
-
$
|
2164 |
-
|
2165 |
-
|
2166 |
-
|
2167 |
-
|
2168 |
-
|
2169 |
-
|
2170 |
-
|
2171 |
-
|
2172 |
-
|
2173 |
-
|
2174 |
-
|
2175 |
-
|
2176 |
-
|
2177 |
-
|
2178 |
-
|
2179 |
-
|
2180 |
-
|
2181 |
-
|
2182 |
-
|
2183 |
-
|
2184 |
-
|
2185 |
-
|
2186 |
-
|
2187 |
-
|
2188 |
-
|
2189 |
-
</
|
2190 |
-
</
|
2191 |
-
|
2192 |
-
|
2193 |
-
|
2194 |
-
|
2195 |
-
|
2196 |
-
|
2197 |
-
|
2198 |
-
|
2199 |
-
|
2200 |
-
|
2201 |
-
|
2202 |
-
|
2203 |
-
|
2204 |
-
|
2205 |
-
|
2206 |
-
|
2207 |
-
|
2208 |
-
|
2209 |
-
</
|
2210 |
-
</
|
2211 |
-
|
2212 |
-
|
2213 |
-
|
2214 |
-
|
2215 |
-
|
2216 |
-
|
2217 |
-
|
2218 |
-
|
2219 |
-
|
2220 |
-
|
2221 |
-
|
2222 |
-
|
2223 |
-
|
2224 |
-
|
2225 |
-
|
2226 |
-
|
2227 |
-
|
2228 |
-
|
2229 |
-
|
2230 |
-
|
2231 |
-
|
2232 |
-
|
2233 |
-
|
2234 |
-
|
2235 |
-
|
2236 |
-
|
2237 |
-
|
2238 |
-
|
2239 |
-
|
2240 |
-
|
2241 |
-
|
2242 |
-
|
2243 |
-
|
2244 |
-
|
2245 |
-
|
2246 |
-
|
2247 |
-
|
2248 |
-
|
2249 |
-
|
2250 |
-
|
2251 |
-
|
2252 |
-
|
2253 |
-
|
2254 |
-
|
2255 |
-
|
2256 |
-
|
2257 |
-
|
2258 |
-
|
2259 |
-
|
2260 |
-
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
|
2265 |
-
|
2266 |
-
|
2267 |
-
|
2268 |
-
|
2269 |
-
|
2270 |
-
|
2271 |
-
|
2272 |
-
|
2273 |
-
|
2274 |
-
|
2275 |
-
|
2276 |
-
|
2277 |
-
|
2278 |
-
|
2279 |
-
|
2280 |
-
|
2281 |
-
|
2282 |
-
|
2283 |
-
|
2284 |
-
|
2285 |
-
|
2286 |
-
|
2287 |
-
|
2288 |
-
|
2289 |
-
|
2290 |
-
|
2291 |
-
if ( ''
|
2292 |
-
|
2293 |
-
|
2294 |
-
|
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 |
-
|
2324 |
-
|
2325 |
-
|
2326 |
-
|
2327 |
-
|
2328 |
-
|
2329 |
-
|
2330 |
-
|
2331 |
-
|
2332 |
-
|
2333 |
-
|
2334 |
-
|
2335 |
-
|
2336 |
-
|
2337 |
-
|
2338 |
-
if ( $
|
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 |
-
$user_billing_company = $user_billing_address_1 = $user_billing_address_2 = $user_billing_city = $user_billing_state = $user_billing_country = "";
|
2420 |
-
$user_shipping_company = $user_shipping_address_1 = $user_shipping_address_2 = $user_shipping_city = $user_shipping_state = $user_shipping_country = "";
|
2421 |
-
} else {
|
2422 |
-
$
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
2426 |
-
$
|
2427 |
-
|
2428 |
-
|
2429 |
-
|
2430 |
-
|
2431 |
-
|
2432 |
-
|
2433 |
-
|
2434 |
-
|
2435 |
-
|
2436 |
-
$
|
2437 |
-
|
2438 |
-
|
2439 |
-
|
2440 |
-
|
2441 |
-
|
2442 |
-
|
2443 |
-
|
2444 |
-
|
2445 |
-
|
2446 |
-
|
2447 |
-
|
2448 |
-
$
|
2449 |
-
|
2450 |
-
|
2451 |
-
|
2452 |
-
|
2453 |
-
$
|
2454 |
-
}
|
2455 |
-
|
2456 |
-
|
2457 |
-
}
|
2458 |
-
|
2459 |
-
|
2460 |
-
|
2461 |
-
|
2462 |
-
|
2463 |
-
|
2464 |
-
|
2465 |
-
|
2466 |
-
|
2467 |
-
|
2468 |
-
|
2469 |
-
|
2470 |
-
$
|
2471 |
-
$
|
2472 |
-
|
2473 |
-
$
|
2474 |
-
|
2475 |
-
|
2476 |
-
|
2477 |
-
|
2478 |
-
|
2479 |
-
$
|
2480 |
-
$
|
2481 |
-
$
|
2482 |
-
|
2483 |
-
|
2484 |
-
|
2485 |
-
$
|
2486 |
-
}
|
2487 |
-
|
2488 |
-
|
2489 |
-
|
2490 |
-
|
2491 |
-
|
2492 |
-
|
2493 |
-
|
2494 |
-
|
2495 |
-
$
|
2496 |
-
}
|
2497 |
-
|
2498 |
-
|
2499 |
-
|
2500 |
-
|
2501 |
-
$
|
2502 |
-
}
|
2503 |
-
|
2504 |
-
|
2505 |
-
|
2506 |
-
|
2507 |
-
$
|
2508 |
-
}
|
2509 |
-
|
2510 |
-
|
2511 |
-
|
2512 |
-
|
2513 |
-
|
2514 |
-
|
2515 |
-
|
2516 |
-
|
2517 |
-
|
2518 |
-
|
2519 |
-
|
2520 |
-
}
|
2521 |
-
$
|
2522 |
-
$
|
2523 |
-
if ( isset( $
|
2524 |
-
$
|
2525 |
-
if ( isset( $woocommerce->countries->
|
2526 |
-
|
2527 |
-
|
2528 |
-
|
2529 |
-
|
2530 |
-
|
2531 |
-
|
2532 |
-
|
2533 |
-
|
2534 |
-
|
2535 |
-
|
2536 |
-
|
2537 |
-
|
2538 |
-
|
2539 |
-
|
2540 |
-
|
2541 |
-
|
2542 |
-
|
2543 |
-
|
2544 |
-
|
2545 |
-
|
2546 |
-
|
2547 |
-
|
2548 |
-
|
2549 |
-
|
2550 |
-
$
|
2551 |
-
|
2552 |
-
$
|
2553 |
-
|
2554 |
-
$
|
2555 |
-
|
2556 |
-
|
2557 |
-
|
2558 |
-
|
2559 |
-
|
2560 |
-
|
2561 |
-
|
2562 |
-
|
2563 |
-
|
2564 |
-
|
2565 |
-
|
2566 |
-
|
2567 |
-
|
2568 |
-
|
2569 |
-
|
2570 |
-
|
2571 |
-
|
2572 |
-
|
2573 |
-
|
2574 |
-
|
2575 |
-
|
2576 |
-
|
2577 |
-
|
2578 |
-
|
2579 |
-
|
2580 |
-
|
2581 |
-
|
2582 |
-
|
2583 |
-
|
2584 |
-
|
2585 |
-
|
2586 |
-
|
2587 |
-
|
2588 |
-
|
2589 |
-
|
2590 |
-
|
2591 |
-
|
2592 |
-
</p>
|
2593 |
-
<p> <strong> <?php _e( '
|
2594 |
-
<?php $
|
2595 |
-
|
2596 |
-
|
2597 |
-
|
2598 |
-
|
2599 |
-
|
2600 |
-
|
2601 |
-
|
2602 |
-
|
2603 |
-
<p> <strong> <?php _e( '
|
2604 |
-
<?php
|
2605 |
-
|
2606 |
-
|
2607 |
-
|
2608 |
-
|
2609 |
-
|
2610 |
-
|
2611 |
-
|
2612 |
-
|
2613 |
-
|
2614 |
-
<?php
|
2615 |
-
|
2616 |
-
|
2617 |
-
|
2618 |
-
|
2619 |
-
|
2620 |
-
|
2621 |
-
|
2622 |
-
|
2623 |
-
|
2624 |
-
|
2625 |
-
|
2626 |
-
|
2627 |
-
|
2628 |
-
|
2629 |
-
|
2630 |
-
|
2631 |
-
|
2632 |
-
|
2633 |
-
|
2634 |
-
|
2635 |
-
|
2636 |
-
|
2637 |
-
|
2638 |
-
|
2639 |
-
|
2640 |
-
|
2641 |
-
|
2642 |
-
|
2643 |
-
|
2644 |
-
|
2645 |
-
|
2646 |
-
|
2647 |
-
|
2648 |
-
|
2649 |
-
|
2650 |
-
|
2651 |
-
|
2652 |
-
|
2653 |
-
|
2654 |
-
|
2655 |
-
|
2656 |
-
|
2657 |
-
|
2658 |
-
|
2659 |
-
|
2660 |
-
|
2661 |
-
|
2662 |
-
|
2663 |
-
|
2664 |
-
|
2665 |
-
|
2666 |
-
|
2667 |
-
|
2668 |
-
$
|
2669 |
-
|
2670 |
-
|
2671 |
-
|
2672 |
-
|
2673 |
-
|
2674 |
-
|
2675 |
-
|
2676 |
-
|
2677 |
-
|
2678 |
-
|
2679 |
-
|
2680 |
-
|
2681 |
-
|
2682 |
-
|
2683 |
-
|
2684 |
-
|
2685 |
-
|
2686 |
-
|
2687 |
-
|
2688 |
-
|
2689 |
-
|
2690 |
-
|
2691 |
-
|
2692 |
-
|
2693 |
-
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
2697 |
-
|
2698 |
-
|
2699 |
-
|
2700 |
-
|
2701 |
-
|
2702 |
-
|
2703 |
-
|
2704 |
-
|
2705 |
-
|
2706 |
-
|
2707 |
-
|
2708 |
-
|
2709 |
-
|
2710 |
-
|
2711 |
-
|
2712 |
-
|
2713 |
-
|
2714 |
-
|
2715 |
-
|
2716 |
-
|
2717 |
-
|
2718 |
-
|
2719 |
-
|
2720 |
-
|
2721 |
-
|
2722 |
-
|
2723 |
-
|
2724 |
-
|
2725 |
-
|
2726 |
-
|
2727 |
-
|
2728 |
-
|
2729 |
-
|
2730 |
-
|
2731 |
-
|
2732 |
-
|
2733 |
-
|
2734 |
-
|
2735 |
-
|
2736 |
-
|
2737 |
-
|
2738 |
-
|
2739 |
-
|
2740 |
-
|
2741 |
-
|
2742 |
-
|
2743 |
-
|
2744 |
-
|
2745 |
-
|
2746 |
-
|
2747 |
-
|
2748 |
-
|
2749 |
-
|
2750 |
-
|
2751 |
-
|
2752 |
-
|
2753 |
-
|
2754 |
-
|
2755 |
-
|
2756 |
-
|
2757 |
-
|
2758 |
-
|
2759 |
-
|
2760 |
-
|
2761 |
-
|
2762 |
-
|
2763 |
-
|
2764 |
-
|
2765 |
-
|
2766 |
-
|
2767 |
-
|
2768 |
-
|
2769 |
-
</
|
2770 |
-
|
2771 |
-
|
2772 |
-
|
2773 |
-
|
2774 |
-
|
2775 |
-
|
2776 |
-
|
2777 |
-
|
2778 |
-
|
2779 |
-
|
2780 |
-
|
2781 |
-
|
2782 |
-
|
2783 |
-
|
2784 |
-
|
2785 |
-
|
2786 |
-
|
2787 |
-
|
2788 |
-
|
2789 |
-
|
2790 |
-
|
2791 |
-
|
2792 |
-
|
2793 |
-
|
2794 |
-
|
2795 |
-
|
2796 |
-
|
2797 |
-
|
2798 |
-
|
2799 |
-
|
2800 |
-
|
2801 |
-
|
2802 |
-
|
2803 |
-
|
2804 |
-
|
2805 |
-
|
2806 |
-
|
2807 |
-
|
2808 |
-
|
2809 |
-
|
2810 |
-
|
2811 |
-
|
2812 |
-
|
2813 |
-
|
2814 |
-
|
2815 |
-
|
2816 |
-
|
2817 |
-
|
2818 |
-
|
2819 |
-
|
2820 |
-
|
2821 |
-
|
2822 |
-
|
2823 |
-
|
2824 |
-
|
2825 |
-
|
2826 |
-
|
2827 |
-
|
2828 |
-
|
2829 |
-
|
2830 |
-
|
2831 |
-
|
2832 |
-
|
2833 |
-
|
2834 |
-
|
2835 |
-
|
2836 |
-
|
2837 |
-
|
2838 |
-
|
2839 |
-
|
2840 |
-
}
|
2841 |
-
|
2842 |
-
|
2843 |
-
|
2844 |
-
|
2845 |
-
|
2846 |
-
|
2847 |
-
|
2848 |
-
|
2849 |
-
|
2850 |
-
|
2851 |
-
|
2852 |
-
|
2853 |
-
|
2854 |
-
|
2855 |
-
|
2856 |
-
|
2857 |
-
|
2858 |
-
|
2859 |
-
|
2860 |
-
|
2861 |
-
|
2862 |
-
|
2863 |
-
|
2864 |
-
|
2865 |
-
|
2866 |
-
|
2867 |
-
|
2868 |
-
|
2869 |
-
|
2870 |
-
|
2871 |
-
|
2872 |
-
|
2873 |
-
|
2874 |
-
|
2875 |
-
|
2876 |
-
|
2877 |
-
|
2878 |
-
|
2879 |
-
|
2880 |
-
|
2881 |
-
|
2882 |
-
|
2883 |
-
|
2884 |
-
|
2885 |
-
</
|
2886 |
-
|
2887 |
-
|
2888 |
-
|
2889 |
-
|
2890 |
-
|
2891 |
-
|
2892 |
-
|
2893 |
-
|
2894 |
-
|
2895 |
-
|
2896 |
-
|
2897 |
-
|
2898 |
-
|
2899 |
-
|
2900 |
-
|
2901 |
-
|
2902 |
-
|
2903 |
-
|
2904 |
-
|
2905 |
-
|
2906 |
-
|
2907 |
-
|
2908 |
-
|
2909 |
-
|
2910 |
-
|
2911 |
-
|
2912 |
-
|
2913 |
-
|
2914 |
-
|
2915 |
-
|
2916 |
-
|
2917 |
-
|
2918 |
-
|
2919 |
-
|
2920 |
-
|
2921 |
-
|
2922 |
-
|
2923 |
-
|
2924 |
-
|
2925 |
-
|
2926 |
-
|
2927 |
-
|
2928 |
-
|
2929 |
-
|
2930 |
-
|
2931 |
-
|
2932 |
-
|
2933 |
-
|
2934 |
-
|
2935 |
-
|
2936 |
-
|
2937 |
-
|
2938 |
-
|
2939 |
-
|
2940 |
-
|
2941 |
-
|
2942 |
-
|
2943 |
-
|
2944 |
-
|
2945 |
-
|
2946 |
-
|
2947 |
-
|
2948 |
-
|
2949 |
-
|
2950 |
-
|
2951 |
-
|
2952 |
-
|
2953 |
-
|
2954 |
-
|
2955 |
-
|
2956 |
-
var
|
2957 |
-
|
2958 |
-
|
2959 |
-
|
2960 |
-
|
2961 |
-
|
2962 |
-
|
2963 |
-
|
2964 |
-
|
2965 |
-
|
2966 |
-
|
2967 |
-
|
2968 |
-
|
2969 |
-
|
2970 |
-
|
2971 |
-
|
2972 |
-
|
2973 |
-
|
2974 |
-
|
2975 |
-
|
2976 |
-
|
2977 |
-
|
2978 |
-
|
2979 |
-
|
2980 |
-
|
2981 |
-
|
2982 |
-
|
2983 |
-
|
2984 |
-
|
2985 |
-
|
2986 |
-
|
2987 |
-
|
2988 |
-
|
2989 |
-
|
2990 |
-
|
2991 |
-
|
2992 |
-
|
2993 |
-
|
2994 |
-
|
2995 |
-
|
2996 |
-
|
2997 |
-
|
2998 |
-
|
2999 |
-
|
3000 |
-
|
3001 |
-
|
3002 |
-
|
3003 |
-
|
3004 |
-
|
3005 |
-
|
3006 |
-
|
3007 |
-
|
3008 |
-
|
3009 |
-
|
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 |
-
$body_email_preview = str_replace( '{{
|
3061 |
-
$body_email_preview = str_replace( '{{
|
3062 |
-
$
|
3063 |
-
$
|
3064 |
-
|
3065 |
-
|
3066 |
-
|
3067 |
-
|
3068 |
-
|
3069 |
-
|
3070 |
-
|
3071 |
-
|
3072 |
-
|
3073 |
-
|
3074 |
-
|
3075 |
-
|
3076 |
-
|
3077 |
-
|
3078 |
-
|
3079 |
-
|
3080 |
-
|
3081 |
-
<
|
3082 |
-
<
|
3083 |
-
|
3084 |
-
|
3085 |
-
<
|
3086 |
-
|
3087 |
-
|
3088 |
-
<td
|
3089 |
-
<td>'
|
3090 |
-
|
3091 |
-
|
3092 |
-
<td
|
3093 |
-
|
3094 |
-
|
3095 |
-
<td
|
3096 |
-
<td>'
|
3097 |
-
|
3098 |
-
|
3099 |
-
|
3100 |
-
|
3101 |
-
|
3102 |
-
|
3103 |
-
|
3104 |
-
|
3105 |
-
|
3106 |
-
<
|
3107 |
-
|
3108 |
-
|
3109 |
-
|
3110 |
-
|
3111 |
-
|
3112 |
-
|
3113 |
-
|
3114 |
-
|
3115 |
-
|
3116 |
-
<
|
3117 |
-
<
|
3118 |
-
|
3119 |
-
|
3120 |
-
<
|
3121 |
-
|
3122 |
-
|
3123 |
-
<td
|
3124 |
-
<td>'
|
3125 |
-
|
3126 |
-
|
3127 |
-
<td
|
3128 |
-
|
3129 |
-
|
3130 |
-
<td
|
3131 |
-
<td>'
|
3132 |
-
|
3133 |
-
|
3134 |
-
|
3135 |
-
|
3136 |
-
|
3137 |
-
|
3138 |
-
|
3139 |
-
|
3140 |
-
|
3141 |
-
|
3142 |
-
|
3143 |
-
|
3144 |
-
|
3145 |
-
|
3146 |
-
|
3147 |
-
|
3148 |
-
|
3149 |
-
|
3150 |
-
|
3151 |
-
|
3152 |
-
|
3153 |
-
|
3154 |
-
|
3155 |
-
|
3156 |
-
|
3157 |
-
|
3158 |
-
|
3159 |
-
|
3160 |
-
|
3161 |
-
|
3162 |
-
|
3163 |
-
|
3164 |
-
|
3165 |
-
|
3166 |
-
|
3167 |
-
|
3168 |
-
|
3169 |
-
|
3170 |
-
|
3171 |
-
|
3172 |
-
|
3173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3174 |
?>
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Plugin Name: Abandoned Cart Lite for WooCommerce
|
4 |
+
* Plugin URI: http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro
|
5 |
+
* Description: This plugin captures abandoned carts by logged-in users & emails them about it.
|
6 |
+
* <strong><a href="http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro">Click here to get the
|
7 |
+
* PRO Version.</a></strong>
|
8 |
+
* Version: 5.3.4
|
9 |
+
* Author: Tyche Softwares
|
10 |
+
* Author URI: http://www.tychesoftwares.com/
|
11 |
+
* Text Domain: woocommerce-abandoned-cart
|
12 |
+
* Domain Path: /i18n/languages/
|
13 |
+
* Requires PHP: 5.6
|
14 |
+
* WC requires at least: 3.0.0
|
15 |
+
* WC tested up to: 3.6
|
16 |
+
*
|
17 |
+
* @package Abandoned-Cart-Lite-for-WooCommerce
|
18 |
+
*/
|
19 |
+
|
20 |
+
require_once( "includes/wcal_class-guest.php" );
|
21 |
+
require_once( "includes/wcal_default-settings.php" );
|
22 |
+
require_once( "includes/wcal_actions.php" );
|
23 |
+
require_once( "includes/classes/class-wcal-aes.php" );
|
24 |
+
require_once( "includes/classes/class-wcal-aes-counter.php" );
|
25 |
+
require_once( "includes/wcal-common.php" );
|
26 |
+
|
27 |
+
require_once( "includes/wcal_admin_notice.php");
|
28 |
+
require_once( 'includes/wcal_data_tracking_message.php' );
|
29 |
+
require_once( 'includes/admin/wcal_privacy_erase.php' );
|
30 |
+
require_once( 'includes/admin/wcal_privacy_export.php' );
|
31 |
+
|
32 |
+
// Add a new interval of 15 minutes
|
33 |
+
add_filter( 'cron_schedules', 'wcal_add_cron_schedule' );
|
34 |
+
|
35 |
+
/**
|
36 |
+
* It will add a cron job for sending the Abandonend cart reminder emails.
|
37 |
+
* By default it will set 15 minutes of interval.
|
38 |
+
* @hook cron_schedules
|
39 |
+
* @param array $schedules
|
40 |
+
* @return array $schedules
|
41 |
+
* @since 1.3
|
42 |
+
* @package Abandoned-Cart-Lite-for-WooCommerce/Cron
|
43 |
+
*/
|
44 |
+
function wcal_add_cron_schedule( $schedules ) {
|
45 |
+
$schedules['15_minutes_lite'] = array(
|
46 |
+
'interval' => 900, // 15 minutes in seconds
|
47 |
+
'display' => __( 'Once Every Fifteen Minutes' ),
|
48 |
+
);
|
49 |
+
return $schedules;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Schedule an action if it's not already scheduled.
|
54 |
+
* @since 1.3
|
55 |
+
* @package Abandoned-Cart-Lite-for-WooCommerce/Cron
|
56 |
+
*/
|
57 |
+
if ( ! wp_next_scheduled( 'woocommerce_ac_send_email_action' ) ) {
|
58 |
+
wp_schedule_event( time(), '15_minutes_lite', 'woocommerce_ac_send_email_action' );
|
59 |
+
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Schedule an action to delete old carts once a day
|
63 |
+
* @since 5.1
|
64 |
+
* @package Abandoned-Cart-Lite-for-WooCommerce/Cron
|
65 |
+
*/
|
66 |
+
if( ! wp_next_scheduled( 'wcal_clear_carts' ) ) {
|
67 |
+
wp_schedule_event( time(), 'daily', 'wcal_clear_carts' );
|
68 |
+
}
|
69 |
+
/**
|
70 |
+
* Hook into that action that'll fire every 15 minutes
|
71 |
+
*/
|
72 |
+
add_action( 'woocommerce_ac_send_email_action', 'wcal_send_email_cron' );
|
73 |
+
|
74 |
+
/**
|
75 |
+
* It will add the wcal_send_email.php file which is responsible for sending the abandoned cart reminde emails.
|
76 |
+
* @hook woocommerce_ac_send_email_action
|
77 |
+
* @since 1.3
|
78 |
+
* @package Abandoned-Cart-Lite-for-WooCommerce/Cron
|
79 |
+
*/
|
80 |
+
function wcal_send_email_cron() {
|
81 |
+
//require_once( ABSPATH.'wp-content/plugins/woocommerce-abandoned-cart/cron/send_email.php' );
|
82 |
+
$plugin_dir_path = plugin_dir_path( __FILE__ );
|
83 |
+
require_once( $plugin_dir_path . 'cron/wcal_send_email.php' );
|
84 |
+
}
|
85 |
+
/**
|
86 |
+
* woocommerce_abandon_cart_lite class
|
87 |
+
**/
|
88 |
+
if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
|
89 |
+
|
90 |
+
|
91 |
+
/**
|
92 |
+
* It will add the hooks, filters, menu and the variables and all the necessary actions for the plguins which will be used
|
93 |
+
* all over the plugin.
|
94 |
+
* @since 1.0
|
95 |
+
* @package Abandoned-Cart-Lite-for-WooCommerce/Core
|
96 |
+
*/
|
97 |
+
class woocommerce_abandon_cart_lite {
|
98 |
+
var $one_hour;
|
99 |
+
var $three_hours;
|
100 |
+
var $six_hours;
|
101 |
+
var $twelve_hours;
|
102 |
+
var $one_day;
|
103 |
+
var $one_week;
|
104 |
+
var $duration_range_select = array();
|
105 |
+
var $start_end_dates = array();
|
106 |
+
/**
|
107 |
+
* The constructor will add the hooks, filters and the variable which will be used all over the plugin.
|
108 |
+
* @since 1.0
|
109 |
+
*
|
110 |
+
*/
|
111 |
+
public function __construct() {
|
112 |
+
$this->one_hour = 60 * 60;
|
113 |
+
$this->three_hours = 3 * $this->one_hour;
|
114 |
+
$this->six_hours = 6 * $this->one_hour;
|
115 |
+
$this->twelve_hours = 12 * $this->one_hour;
|
116 |
+
$this->one_day = 24 * $this->one_hour;
|
117 |
+
$this->one_week = 7 * $this->one_day;
|
118 |
+
$this->duration_range_select = array( 'yesterday' => 'Yesterday',
|
119 |
+
'today' => 'Today',
|
120 |
+
'last_seven' => 'Last 7 days',
|
121 |
+
'last_fifteen' => 'Last 15 days',
|
122 |
+
'last_thirty' => 'Last 30 days',
|
123 |
+
'last_ninety' => 'Last 90 days',
|
124 |
+
'last_year_days' => 'Last 365'
|
125 |
+
);
|
126 |
+
|
127 |
+
$this->start_end_dates = array( 'yesterday' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 24*60*60 ) ),
|
128 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) - 7*24*60*60 ) ) ),
|
129 |
+
'today' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ),
|
130 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
131 |
+
'last_seven' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 7*24*60*60 ) ),
|
132 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
133 |
+
'last_fifteen' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 15*24*60*60 ) ),
|
134 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
135 |
+
'last_thirty' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 30*24*60*60 ) ),
|
136 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
137 |
+
'last_ninety' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 90*24*60*60 ) ),
|
138 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) ),
|
139 |
+
'last_year_days' => array( 'start_date' => date( "d M Y", ( current_time( 'timestamp' ) - 365*24*60*60 ) ),
|
140 |
+
'end_date' => date( "d M Y", ( current_time( 'timestamp' ) ) ) )
|
141 |
+
);
|
142 |
+
|
143 |
+
// Initialize settings
|
144 |
+
register_activation_hook ( __FILE__, array( &$this, 'wcal_activate' ) );
|
145 |
+
|
146 |
+
// Background Processing for Cron
|
147 |
+
require_once( 'cron/wcal_send_email.php' );
|
148 |
+
require_once( 'includes/background-processes/wcal_process_base.php' );
|
149 |
+
|
150 |
+
// WordPress Administration Menu
|
151 |
+
add_action ( 'admin_menu', array( &$this, 'wcal_admin_menu' ) );
|
152 |
+
|
153 |
+
// Actions to be done on cart update
|
154 |
+
add_action ( 'woocommerce_cart_updated', array( &$this, 'wcal_store_cart_timestamp' ) );
|
155 |
+
|
156 |
+
add_action ( 'admin_init', array( &$this, 'wcal_action_admin_init' ) );
|
157 |
+
|
158 |
+
// Update the options as per settings API
|
159 |
+
add_action ( 'admin_init', array( &$this, 'wcal_update_db_check' ) );
|
160 |
+
|
161 |
+
// Wordpress settings API
|
162 |
+
add_action( 'admin_init', array( &$this, 'wcal_initialize_plugin_options' ) );
|
163 |
+
|
164 |
+
// Language Translation
|
165 |
+
add_action ( 'init', array( &$this, 'wcal_update_po_file' ) );
|
166 |
+
|
167 |
+
add_action ( 'init', array ( &$this, 'wcal_add_component_file') );
|
168 |
+
|
169 |
+
// track links
|
170 |
+
add_filter( 'template_include', array( &$this, 'wcal_email_track_links' ), 99, 1 );
|
171 |
+
|
172 |
+
//It will used to unsubcribe the emails.
|
173 |
+
add_action( 'template_include', array( &$this, 'wcal_email_unsubscribe'),99, 1 );
|
174 |
+
|
175 |
+
add_action ( 'admin_enqueue_scripts', array( &$this, 'wcal_enqueue_scripts_js' ) );
|
176 |
+
add_action ( 'admin_enqueue_scripts', array( &$this, 'wcal_enqueue_scripts_css' ) );
|
177 |
+
//delete abandoned order after X number of days
|
178 |
+
if ( class_exists( 'wcal_delete_bulk_action_handler' ) ) {
|
179 |
+
add_action( 'wcal_clear_carts', array( 'wcal_delete_bulk_action_handler', 'wcal_delete_abandoned_carts_after_x_days' ) );
|
180 |
+
}
|
181 |
+
|
182 |
+
if ( is_admin() ) {
|
183 |
+
// Load "admin-only" scripts here
|
184 |
+
add_action ( 'admin_head', array( &$this, 'wcal_action_send_preview' ) );
|
185 |
+
add_action ( 'wp_ajax_wcal_preview_email_sent', array( &$this, 'wcal_preview_email_sent' ) );
|
186 |
+
add_action ( 'wp_ajax_wcal_toggle_template_status', array( &$this, 'wcal_toggle_template_status' ) );
|
187 |
+
|
188 |
+
add_filter( 'ts_tracker_data', array( 'wcal_common', 'ts_add_plugin_tracking_data' ), 10, 1 );
|
189 |
+
add_filter( 'ts_tracker_opt_out_data', array( 'wcal_common', 'ts_get_data_for_opt_out' ), 10, 1 );
|
190 |
+
add_filter( 'ts_deativate_plugin_questions', array( &$this, 'wcal_deactivate_add_questions' ), 10, 1 );
|
191 |
+
}
|
192 |
+
|
193 |
+
// Plugin Settings link in WP->Plugins page
|
194 |
+
$plugin = plugin_basename( __FILE__ );
|
195 |
+
add_action( "plugin_action_links_$plugin", array( &$this, 'wcal_settings_link' ) );
|
196 |
+
|
197 |
+
add_action( 'admin_init', array( $this, 'wcal_preview_emails' ) );
|
198 |
+
add_action( 'init', array( $this, 'wcal_app_output_buffer') );
|
199 |
+
|
200 |
+
add_filter( 'admin_footer_text', array( $this, 'wcal_admin_footer_text' ), 1 );
|
201 |
+
|
202 |
+
add_action( 'admin_notices', array( 'Wcal_Admin_Notice', 'wcal_show_db_update_notice' ) );
|
203 |
+
|
204 |
+
include_once 'includes/frontend/wcal_frontend.php';
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Add Settings link to WP->Plugins page
|
209 |
+
* @since 5.3.0
|
210 |
+
*/
|
211 |
+
public static function wcal_settings_link( $links ) {
|
212 |
+
$settings_link = '<a href="admin.php?page=woocommerce_ac_page&action=emailsettings">' . __( 'Settings', 'woocommerce-abandoned-cart' ) . '</a>';
|
213 |
+
array_push( $links, $settings_link );
|
214 |
+
return $links;
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* It will load the boilerplate components file. In this file we have included all boilerplate files.
|
219 |
+
* We need to inlcude this file after the init hook.
|
220 |
+
* @hook init
|
221 |
+
*/
|
222 |
+
public static function wcal_add_component_file () {
|
223 |
+
if ( is_admin() ) {
|
224 |
+
require_once( 'includes/wcal_all_component.php' );
|
225 |
+
|
226 |
+
}
|
227 |
+
}
|
228 |
+
/**
|
229 |
+
* It will add the Questions while admin deactivate the plugin.
|
230 |
+
* @hook ts_deativate_plugin_questions
|
231 |
+
* @param array $wcal_add_questions Blank array
|
232 |
+
* @return array $wcal_add_questions List of all questions.
|
233 |
+
*/
|
234 |
+
public static function wcal_deactivate_add_questions ( $wcal_add_questions ) {
|
235 |
+
|
236 |
+
$wcal_add_questions = array(
|
237 |
+
0 => array(
|
238 |
+
'id' => 4,
|
239 |
+
'text' => __( "Emails are not being sent to customers.", "woocommerce-abandoned-cart" ),
|
240 |
+
'input_type' => '',
|
241 |
+
'input_placeholder' => ''
|
242 |
+
),
|
243 |
+
1 => array(
|
244 |
+
'id' => 5,
|
245 |
+
'text' => __( "Capturing of cart and other information was not satisfactory.", "woocommerce-abandoned-cart" ),
|
246 |
+
'input_type' => '',
|
247 |
+
'input_placeholder' => ''
|
248 |
+
),
|
249 |
+
2 => array(
|
250 |
+
'id' => 6,
|
251 |
+
'text' => __( "I cannot see abandoned cart reminder emails records.", "woocommerce-abandoned-cart" ),
|
252 |
+
'input_type' => '',
|
253 |
+
'input_placeholder' => ''
|
254 |
+
),
|
255 |
+
3 => array(
|
256 |
+
'id' => 7,
|
257 |
+
'text' => __( "I want to upgrade the plugin to the PRO version.", "woocommerce-abandoned-cart" ),
|
258 |
+
'input_type' => '',
|
259 |
+
'input_placeholder' => ''
|
260 |
+
)
|
261 |
+
|
262 |
+
);
|
263 |
+
return $wcal_add_questions;
|
264 |
+
}
|
265 |
+
|
266 |
+
/**
|
267 |
+
* It will ganerate the preview email template.
|
268 |
+
* @hook admin_init
|
269 |
+
* @globals mixed $woocommerce
|
270 |
+
* @since 2.5
|
271 |
+
*/
|
272 |
+
public function wcal_preview_emails() {
|
273 |
+
global $woocommerce;
|
274 |
+
if ( isset( $_GET['wcal_preview_woocommerce_mail'] ) ) {
|
275 |
+
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-abandoned-cart' ) ) {
|
276 |
+
die( 'Security check' );
|
277 |
+
}
|
278 |
+
$message = '';
|
279 |
+
// create a new email
|
280 |
+
if ( $woocommerce->version < '2.3' ) {
|
281 |
+
global $email_heading;
|
282 |
+
ob_start();
|
283 |
+
|
284 |
+
include( 'views/wcal-wc-email-template-preview.php' );
|
285 |
+
$mailer = WC()->mailer();
|
286 |
+
$message = ob_get_clean();
|
287 |
+
$email_heading = __( 'HTML Email Template', 'woocommerce-abandoned-cart' );
|
288 |
+
$message = $mailer->wrap_message( $email_heading, $message );
|
289 |
+
} else {
|
290 |
+
// load the mailer class
|
291 |
+
$mailer = WC()->mailer();
|
292 |
+
// get the preview email subject
|
293 |
+
$email_heading = __( 'Abandoned cart Email Template', 'woocommerce-abandoned-cart' );
|
294 |
+
// get the preview email content
|
295 |
+
ob_start();
|
296 |
+
include( 'views/wcal-wc-email-template-preview.php' );
|
297 |
+
$message = ob_get_clean();
|
298 |
+
// create a new email
|
299 |
+
$email = new WC_Email();
|
300 |
+
// wrap the content with the email template and then add styles
|
301 |
+
$message = $email->style_inline( $mailer->wrap_message( $email_heading, $message ) );
|
302 |
+
}
|
303 |
+
echo $message;
|
304 |
+
exit;
|
305 |
+
}
|
306 |
+
|
307 |
+
if ( isset( $_GET['wcal_preview_mail'] ) ) {
|
308 |
+
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'woocommerce-abandoned-cart' ) ) {
|
309 |
+
die( 'Security check' );
|
310 |
+
}
|
311 |
+
// get the preview email content
|
312 |
+
ob_start();
|
313 |
+
include( 'views/wcal-email-template-preview.php' );
|
314 |
+
$message = ob_get_clean();
|
315 |
+
// print the preview email
|
316 |
+
echo $message;
|
317 |
+
exit;
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
/**
|
322 |
+
* In this version we have allowed customer to transalte the plugin string using .po and .pot file.
|
323 |
+
* @hook init
|
324 |
+
* @return $loaded
|
325 |
+
* @since 1.6
|
326 |
+
*/
|
327 |
+
function wcal_update_po_file() {
|
328 |
+
/*
|
329 |
+
* Due to the introduction of language packs through translate.wordpress.org, loading our textdomain is complex.
|
330 |
+
*
|
331 |
+
* In v4.7, our textdomain changed from "woocommerce-ac" to "woocommerce-abandoned-cart".
|
332 |
+
*/
|
333 |
+
$domain = 'woocommerce-abandoned-cart';
|
334 |
+
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
|
335 |
+
if ( $loaded = load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '-' . $locale . '.mo' ) ) {
|
336 |
+
return $loaded;
|
337 |
+
} else {
|
338 |
+
load_plugin_textdomain( $domain, FALSE, basename( dirname( __FILE__ ) ) . '/i18n/languages/' );
|
339 |
+
}
|
340 |
+
}
|
341 |
+
|
342 |
+
/**
|
343 |
+
* It will create the plugin tables & the options reqired for plugin.
|
344 |
+
* @hook register_activation_hook
|
345 |
+
* @globals mixed $wpdb
|
346 |
+
* @since 1.0
|
347 |
+
*/
|
348 |
+
function wcal_activate() {
|
349 |
+
global $wpdb;
|
350 |
+
$wcap_collate = '';
|
351 |
+
if ( $wpdb->has_cap( 'collation' ) ) {
|
352 |
+
$wcap_collate = $wpdb->get_charset_collate();
|
353 |
+
}
|
354 |
+
$table_name = $wpdb->prefix . "ac_email_templates_lite";
|
355 |
+
$sql = "CREATE TABLE IF NOT EXISTS $table_name (
|
356 |
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
357 |
+
`subject` text NOT NULL,
|
358 |
+
`body` mediumtext NOT NULL,
|
359 |
+
`is_active` enum('0','1') NOT NULL,
|
360 |
+
`frequency` int(11) NOT NULL,
|
361 |
+
`day_or_hour` enum('Days','Hours') NOT NULL,
|
362 |
+
`template_name` text NOT NULL,
|
363 |
+
`is_wc_template` enum('0','1') NOT NULL,
|
364 |
+
`default_template` int(11) NOT NULL,
|
365 |
+
`wc_email_header` varchar(50) NOT NULL,
|
366 |
+
PRIMARY KEY (`id`)
|
367 |
+
) $wcap_collate AUTO_INCREMENT=1 ";
|
368 |
+
|
369 |
+
require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
370 |
+
dbDelta( $sql );
|
371 |
+
|
372 |
+
// $table_name = $wpdb->prefix . "ac_email_templates_lite";
|
373 |
+
// $check_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'is_wc_template' ";
|
374 |
+
// $results = $wpdb->get_results( $check_template_table_query );
|
375 |
+
|
376 |
+
// if ( count( $results ) == 0 ) {
|
377 |
+
// $alter_template_table_query = "ALTER TABLE $table_name
|
378 |
+
// ADD COLUMN `is_wc_template` enum('0','1') COLLATE utf8mb4_unicode_ci NOT NULL AFTER `template_name`,
|
379 |
+
// ADD COLUMN `default_template` int(11) NOT NULL AFTER `is_wc_template`";
|
380 |
+
|
381 |
+
// $wpdb->get_results( $alter_template_table_query );
|
382 |
+
// }
|
383 |
+
|
384 |
+
$sent_table_name = $wpdb->prefix . "ac_sent_history_lite";
|
385 |
+
|
386 |
+
$sql_query = "CREATE TABLE IF NOT EXISTS $sent_table_name (
|
387 |
+
`id` int(11) NOT NULL auto_increment,
|
388 |
+
`template_id` varchar(40) collate utf8_unicode_ci NOT NULL,
|
389 |
+
`abandoned_order_id` int(11) NOT NULL,
|
390 |
+
`sent_time` datetime NOT NULL,
|
391 |
+
`sent_email_id` text COLLATE utf8_unicode_ci NOT NULL,
|
392 |
+
PRIMARY KEY (`id`)
|
393 |
+
) $wcap_collate AUTO_INCREMENT=1 ";
|
394 |
+
|
395 |
+
require_once ( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
396 |
+
dbDelta ( $sql_query );
|
397 |
+
|
398 |
+
$ac_history_table_name = $wpdb->prefix . "ac_abandoned_cart_history_lite";
|
399 |
+
|
400 |
+
$history_query = "CREATE TABLE IF NOT EXISTS $ac_history_table_name (
|
401 |
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
402 |
+
`user_id` int(11) NOT NULL,
|
403 |
+
`abandoned_cart_info` text COLLATE utf8_unicode_ci NOT NULL,
|
404 |
+
`abandoned_cart_time` int(11) NOT NULL,
|
405 |
+
`cart_ignored` enum('0','1') COLLATE utf8_unicode_ci NOT NULL,
|
406 |
+
`recovered_cart` int(11) NOT NULL,
|
407 |
+
`user_type` text,
|
408 |
+
`unsubscribe_link` enum('0','1') COLLATE utf8_unicode_ci NOT NULL,
|
409 |
+
`session_id` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
|
410 |
+
PRIMARY KEY (`id`)
|
411 |
+
) $wcap_collate";
|
412 |
+
|
413 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
414 |
+
dbDelta( $history_query );
|
415 |
+
// Default templates: function call to create default templates.
|
416 |
+
$check_table_empty = $wpdb->get_var( "SELECT COUNT(*) FROM `" . $wpdb->prefix . "ac_email_templates_lite`" );
|
417 |
+
|
418 |
+
if ( ! get_option( 'wcal_new_default_templates' ) ) {
|
419 |
+
if ( 0 == $check_table_empty ) {
|
420 |
+
$default_template = new wcal_default_template_settings;
|
421 |
+
$default_template->wcal_create_default_templates();
|
422 |
+
update_option( 'wcal_new_default_templates', "yes" );
|
423 |
+
}
|
424 |
+
}
|
425 |
+
|
426 |
+
$guest_table = $wpdb->prefix."ac_guest_abandoned_cart_history_lite" ;
|
427 |
+
$query_guest_table = "SHOW TABLES LIKE '$guest_table' ";
|
428 |
+
$result_guest_table = $wpdb->get_results( $query_guest_table );
|
429 |
+
|
430 |
+
if ( 0 == count( $result_guest_table ) ) {
|
431 |
+
$ac_guest_history_table_name = $wpdb->prefix . "ac_guest_abandoned_cart_history_lite";
|
432 |
+
$ac_guest_history_query = "CREATE TABLE IF NOT EXISTS $ac_guest_history_table_name (
|
433 |
+
`id` int(15) NOT NULL AUTO_INCREMENT,
|
434 |
+
`billing_first_name` text,
|
435 |
+
`billing_last_name` text,
|
436 |
+
`billing_company_name` text,
|
437 |
+
`billing_address_1` text,
|
438 |
+
`billing_address_2` text,
|
439 |
+
`billing_city` text,
|
440 |
+
`billing_county` text,
|
441 |
+
`billing_zipcode` text,
|
442 |
+
`email_id` text,
|
443 |
+
`phone` text,
|
444 |
+
`ship_to_billing` text,
|
445 |
+
`order_notes` text,
|
446 |
+
`shipping_first_name` text,
|
447 |
+
`shipping_last_name` text,
|
448 |
+
`shipping_company_name` text,
|
449 |
+
`shipping_address_1` text,
|
450 |
+
`shipping_address_2` text,
|
451 |
+
`shipping_city` text,
|
452 |
+
`shipping_county` text,
|
453 |
+
`shipping_zipcode` double,
|
454 |
+
`shipping_charges` double,
|
455 |
+
PRIMARY KEY (`id`)
|
456 |
+
) $wcap_collate AUTO_INCREMENT=63000000";
|
457 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php');
|
458 |
+
$wpdb->query( $ac_guest_history_query );
|
459 |
+
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* This is add for thos user who Install the plguin first time.
|
463 |
+
* So for them this option will be cheked.
|
464 |
+
*/
|
465 |
+
if ( ! get_option( 'ac_lite_track_guest_cart_from_cart_page' ) ) {
|
466 |
+
add_option( 'ac_lite_track_guest_cart_from_cart_page', 'on' );
|
467 |
+
}
|
468 |
+
if ( ! get_option( 'wcal_from_name' ) ) {
|
469 |
+
add_option( 'wcal_from_name', 'Admin' );
|
470 |
+
}
|
471 |
+
$wcal_get_admin_email = get_option( 'admin_email' );
|
472 |
+
if ( ! get_option( 'wcal_from_email' ) ) {
|
473 |
+
add_option( 'wcal_from_email', $wcal_get_admin_email );
|
474 |
+
}
|
475 |
+
|
476 |
+
if ( ! get_option( 'wcal_reply_email' ) ) {
|
477 |
+
add_option( 'wcal_reply_email', $wcal_get_admin_email );
|
478 |
+
}
|
479 |
+
|
480 |
+
do_action( 'wcal_activate' );
|
481 |
+
}
|
482 |
+
|
483 |
+
/**
|
484 |
+
* It will add the section, field, & registres the plugin fields using Settings API.
|
485 |
+
* @hook admin_init
|
486 |
+
* @since 2.5
|
487 |
+
*/
|
488 |
+
function wcal_initialize_plugin_options() {
|
489 |
+
|
490 |
+
// First, we register a section. This is necessary since all future options must belong to a
|
491 |
+
add_settings_section(
|
492 |
+
'ac_lite_general_settings_section', // ID used to identify this section and with which to register options
|
493 |
+
__( 'Settings', 'woocommerce-abandoned-cart' ), // Title to be displayed on the administration page
|
494 |
+
array( $this, 'ac_lite_general_options_callback' ), // Callback used to render the description of the section
|
495 |
+
'woocommerce_ac_page' // Page on which to add this section of options
|
496 |
+
);
|
497 |
+
|
498 |
+
add_settings_field(
|
499 |
+
'ac_lite_cart_abandoned_time',
|
500 |
+
__( 'Cart abandoned cut-off time', 'woocommerce-abandoned-cart' ),
|
501 |
+
array( $this, 'ac_lite_cart_abandoned_time_callback' ),
|
502 |
+
'woocommerce_ac_page',
|
503 |
+
'ac_lite_general_settings_section',
|
504 |
+
array( __( 'Consider cart abandoned after X minutes of item being added to cart & order not placed.', 'woocommerce-abandoned-cart' ) )
|
505 |
+
);
|
506 |
+
|
507 |
+
add_settings_field(
|
508 |
+
'ac_lite_delete_abandoned_order_days',
|
509 |
+
__( 'Automatically Delete Abandoned Orders after X days', 'woocommerce-abandoned-cart' ),
|
510 |
+
array( $this, 'wcal_delete_abandoned_orders_days_callback' ),
|
511 |
+
'woocommerce_ac_page',
|
512 |
+
'ac_lite_general_settings_section',
|
513 |
+
array( __( 'Automatically delete abandoned cart orders after X days.', 'woocommerce-abandoned-cart' ) )
|
514 |
+
);
|
515 |
+
|
516 |
+
|
517 |
+
add_settings_field(
|
518 |
+
'ac_lite_email_admin_on_recovery',
|
519 |
+
__( 'Email admin On Order Recovery', 'woocommerce-abandoned-cart' ),
|
520 |
+
array( $this, 'ac_lite_email_admin_on_recovery' ),
|
521 |
+
'woocommerce_ac_page',
|
522 |
+
'ac_lite_general_settings_section',
|
523 |
+
array( __( 'Sends email to Admin if an Abandoned Cart Order is recovered.', 'woocommerce-abandoned-cart' ) )
|
524 |
+
);
|
525 |
+
|
526 |
+
|
527 |
+
add_settings_field(
|
528 |
+
'ac_lite_track_guest_cart_from_cart_page',
|
529 |
+
__( 'Start tracking from Cart Page', 'woocommerce-abandoned-cart' ),
|
530 |
+
array( $this, 'wcal_track_guest_cart_from_cart_page_callback' ),
|
531 |
+
'woocommerce_ac_page',
|
532 |
+
'ac_lite_general_settings_section',
|
533 |
+
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-abandoned-cart' ) )
|
534 |
+
);
|
535 |
+
|
536 |
+
add_settings_field(
|
537 |
+
'wcal_guest_cart_capture_msg',
|
538 |
+
__( 'Message to be displayed for Guest users when tracking their carts', 'woocommerce-abandoned-cart' ),
|
539 |
+
array( $this, 'wcal_guest_cart_capture_msg_callback' ),
|
540 |
+
'woocommerce_ac_page',
|
541 |
+
'ac_lite_general_settings_section',
|
542 |
+
array( __( '<br>In compliance with GDPR, add a message on the Checkout page to inform Guest users of how their data is being used.<br><i>For example: Your email address will help us support your shopping experience throughout the site. Please check our Privacy Policy to see how we use your personal data.</i>', 'woocommerce-abandoned-cart' ) )
|
543 |
+
);
|
544 |
+
|
545 |
+
add_settings_field(
|
546 |
+
'wcal_logged_cart_capture_msg',
|
547 |
+
__( 'Message to be displayed for registered users when tracking their carts.', 'woocommerce-abandoned-cart' ),
|
548 |
+
array( $this, 'wcal_logged_cart_capture_msg_callback' ),
|
549 |
+
'woocommerce_ac_page',
|
550 |
+
'ac_lite_general_settings_section',
|
551 |
+
array( __( '<br>In compliance with GDPR, add a message on the Shop & Product pages to inform Registered users of how their data is being used.<br><i>For example: Please check our Privacy Policy to see how we use your personal data.</i>', 'woocommerce-abandoned-cart' ) )
|
552 |
+
);
|
553 |
+
|
554 |
+
/**
|
555 |
+
* New section for the Adding the abandoned cart setting.
|
556 |
+
* @since 4.7
|
557 |
+
*/
|
558 |
+
|
559 |
+
add_settings_section(
|
560 |
+
'ac_email_settings_section', // ID used to identify this section and with which to register options
|
561 |
+
__( 'Settings for abandoned cart recovery emails', 'woocommerce-abandoned-cart' ), // Title to be displayed on the administration page
|
562 |
+
array( $this, 'wcal_email_callback' ), // Callback used to render the description of the section
|
563 |
+
'woocommerce_ac_email_page' // Page on which to add this section of options
|
564 |
+
);
|
565 |
+
|
566 |
+
add_settings_field(
|
567 |
+
'wcal_from_name',
|
568 |
+
__( '"From" Name', 'woocommerce-abandoned-cart' ),
|
569 |
+
array( $this, 'wcal_from_name_callback' ),
|
570 |
+
'woocommerce_ac_email_page',
|
571 |
+
'ac_email_settings_section',
|
572 |
+
array( 'Enter the name that should appear in the email sent.', 'woocommerce-abandoned-cart' )
|
573 |
+
);
|
574 |
+
|
575 |
+
add_settings_field(
|
576 |
+
'wcal_from_email',
|
577 |
+
__( '"From" Address', 'woocommerce-abandoned-cart' ),
|
578 |
+
array( $this, 'wcal_from_email_callback' ),
|
579 |
+
'woocommerce_ac_email_page',
|
580 |
+
'ac_email_settings_section',
|
581 |
+
array( 'Email address from which the reminder emails should be sent.', 'woocommerce-abandoned-cart' )
|
582 |
+
);
|
583 |
+
|
584 |
+
add_settings_field(
|
585 |
+
'wcal_reply_email',
|
586 |
+
__( 'Send Reply Emails to', 'woocommerce-abandoned-cart' ),
|
587 |
+
array( $this, 'wcal_reply_email_callback' ),
|
588 |
+
'woocommerce_ac_email_page',
|
589 |
+
'ac_email_settings_section',
|
590 |
+
array( 'When a contact receives your email and clicks reply, which email address should that reply be sent to?', 'woocommerce-abandoned-cart' )
|
591 |
+
);
|
592 |
+
|
593 |
+
// Finally, we register the fields with WordPress
|
594 |
+
register_setting(
|
595 |
+
'woocommerce_ac_settings',
|
596 |
+
'ac_lite_cart_abandoned_time',
|
597 |
+
array ( $this, 'ac_lite_cart_time_validation' )
|
598 |
+
);
|
599 |
+
|
600 |
+
register_setting(
|
601 |
+
'woocommerce_ac_settings',
|
602 |
+
'ac_lite_delete_abandoned_order_days',
|
603 |
+
array ( $this, 'wcal_delete_days_validation' )
|
604 |
+
);
|
605 |
+
|
606 |
+
register_setting(
|
607 |
+
'woocommerce_ac_settings',
|
608 |
+
'ac_lite_email_admin_on_recovery'
|
609 |
+
);
|
610 |
+
|
611 |
+
register_setting(
|
612 |
+
'woocommerce_ac_settings',
|
613 |
+
'ac_lite_track_guest_cart_from_cart_page'
|
614 |
+
);
|
615 |
+
|
616 |
+
register_setting(
|
617 |
+
'woocommerce_ac_settings',
|
618 |
+
'wcal_guest_cart_capture_msg'
|
619 |
+
);
|
620 |
+
|
621 |
+
register_setting(
|
622 |
+
'woocommerce_ac_settings',
|
623 |
+
'wcal_logged_cart_capture_msg'
|
624 |
+
);
|
625 |
+
|
626 |
+
register_setting(
|
627 |
+
'woocommerce_ac_email_settings',
|
628 |
+
'wcal_from_name'
|
629 |
+
);
|
630 |
+
register_setting(
|
631 |
+
'woocommerce_ac_email_settings',
|
632 |
+
'wcal_from_email'
|
633 |
+
);
|
634 |
+
register_setting(
|
635 |
+
'woocommerce_ac_email_settings',
|
636 |
+
'wcal_reply_email'
|
637 |
+
);
|
638 |
+
|
639 |
+
do_action ( "wcal_add_new_settings" );
|
640 |
+
}
|
641 |
+
|
642 |
+
/**
|
643 |
+
* Settings API callback for section "ac_lite_general_settings_section".
|
644 |
+
* @since 2.5
|
645 |
+
*/
|
646 |
+
function ac_lite_general_options_callback() {
|
647 |
+
|
648 |
+
}
|
649 |
+
|
650 |
+
/**
|
651 |
+
* Settings API callback for cart time field.
|
652 |
+
* @param array $args Arguments
|
653 |
+
* @since 2.5
|
654 |
+
*/
|
655 |
+
function ac_lite_cart_abandoned_time_callback( $args ) {
|
656 |
+
// First, we read the option
|
657 |
+
$cart_abandoned_time = get_option( 'ac_lite_cart_abandoned_time' );
|
658 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
659 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
660 |
+
printf(
|
661 |
+
'<input type="text" id="ac_lite_cart_abandoned_time" name="ac_lite_cart_abandoned_time" value="%s" />',
|
662 |
+
isset( $cart_abandoned_time ) ? esc_attr( $cart_abandoned_time ) : ''
|
663 |
+
);
|
664 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
665 |
+
$html = '<label for="ac_lite_cart_abandoned_time"> ' . $args[0] . '</label>';
|
666 |
+
echo $html;
|
667 |
+
}
|
668 |
+
|
669 |
+
/**
|
670 |
+
* Settings API cart time field validation.
|
671 |
+
* @param int | string $input
|
672 |
+
* @return int | string $output
|
673 |
+
* @since 2.5
|
674 |
+
*/
|
675 |
+
function ac_lite_cart_time_validation( $input ) {
|
676 |
+
$output = '';
|
677 |
+
if ( '' != $input && ( is_numeric( $input) && $input > 0 ) ) {
|
678 |
+
$output = stripslashes( $input) ;
|
679 |
+
} else {
|
680 |
+
add_settings_error( 'ac_lite_cart_abandoned_time', 'error found', __( 'Abandoned cart cut off time should be numeric and has to be greater than 0.', 'woocommerce-abandoned-cart' ) );
|
681 |
+
}
|
682 |
+
return $output;
|
683 |
+
}
|
684 |
+
|
685 |
+
/**
|
686 |
+
* Validation for automatically delete abandoned carts after X days.
|
687 |
+
* @param int | string $input input of the field Abandoned cart cut off time
|
688 |
+
* @return int | string $output Error message or the input value
|
689 |
+
* @since 5.0
|
690 |
+
*/
|
691 |
+
public static function wcal_delete_days_validation( $input ) {
|
692 |
+
$output = '';
|
693 |
+
if ( '' == $input || ( is_numeric( $input ) && $input > 0 ) ) {
|
694 |
+
$output = stripslashes( $input );
|
695 |
+
} else {
|
696 |
+
add_settings_error( 'ac_lite_delete_abandoned_order_days', 'error found', __( 'Automatically Delete Abandoned Orders after X days has to be greater than 0.', 'woocommerce-abandoned-cart' ) );
|
697 |
+
}
|
698 |
+
return $output;
|
699 |
+
}
|
700 |
+
|
701 |
+
/**
|
702 |
+
* Callback for deleting abandoned order after X days field.
|
703 |
+
* @param array $args Argument given while adding the field
|
704 |
+
* @since 5.0
|
705 |
+
*/
|
706 |
+
public static function wcal_delete_abandoned_orders_days_callback( $args ) {
|
707 |
+
// First, we read the option
|
708 |
+
$delete_abandoned_order_days = get_option( 'ac_lite_delete_abandoned_order_days' );
|
709 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
710 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
711 |
+
printf(
|
712 |
+
'<input type="text" id="ac_lite_delete_abandoned_order_days" name="ac_lite_delete_abandoned_order_days" value="%s" />',
|
713 |
+
isset( $delete_abandoned_order_days ) ? esc_attr( $delete_abandoned_order_days ) : ''
|
714 |
+
);
|
715 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
716 |
+
$html = '<label for="ac_lite_delete_abandoned_order_days"> ' . $args[0] . '</label>';
|
717 |
+
echo $html;
|
718 |
+
}
|
719 |
+
|
720 |
+
/**
|
721 |
+
* Settings API callback for email admin on cart recovery field.
|
722 |
+
* @param array $args Arguments
|
723 |
+
* @since 2.5
|
724 |
+
*/
|
725 |
+
function ac_lite_email_admin_on_recovery( $args ) {
|
726 |
+
// First, we read the option
|
727 |
+
$email_admin_on_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
|
728 |
+
|
729 |
+
// This condition added to avoid the notie displyed while Check box is unchecked.
|
730 |
+
if ( isset( $email_admin_on_recovery ) && '' == $email_admin_on_recovery ) {
|
731 |
+
$email_admin_on_recovery = 'off';
|
732 |
+
}
|
733 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
734 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
735 |
+
$html='';
|
736 |
+
printf(
|
737 |
+
'<input type="checkbox" id="ac_lite_email_admin_on_recovery" name="ac_lite_email_admin_on_recovery" value="on"
|
738 |
+
' . checked('on', $email_admin_on_recovery, false).' />'
|
739 |
+
);
|
740 |
+
|
741 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
742 |
+
$html .= '<label for="ac_lite_email_admin_on_recovery"> ' . $args[0] . '</label>';
|
743 |
+
echo $html;
|
744 |
+
}
|
745 |
+
/**
|
746 |
+
* Settings API callback for capturing guest cart which do not reach the checkout page.
|
747 |
+
* @param array $args Arguments
|
748 |
+
* @since 2.7
|
749 |
+
*/
|
750 |
+
function wcal_track_guest_cart_from_cart_page_callback( $args ) {
|
751 |
+
// First, we read the option
|
752 |
+
$disable_guest_cart_from_cart_page = get_option( 'ac_lite_track_guest_cart_from_cart_page' );
|
753 |
+
|
754 |
+
// This condition added to avoid the notice displyed while Check box is unchecked.
|
755 |
+
if ( isset( $disable_guest_cart_from_cart_page ) && '' == $disable_guest_cart_from_cart_page ) {
|
756 |
+
$disable_guest_cart_from_cart_page = 'off';
|
757 |
+
}
|
758 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
759 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
760 |
+
$html = '';
|
761 |
+
|
762 |
+
printf(
|
763 |
+
'<input type="checkbox" id="ac_lite_track_guest_cart_from_cart_page" name="ac_lite_track_guest_cart_from_cart_page" value="on"
|
764 |
+
'.checked( 'on', $disable_guest_cart_from_cart_page, false ) . ' />' );
|
765 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
766 |
+
$html .= '<label for="ac_lite_track_guest_cart_from_cart_page"> ' . $args[0] . '</label>';
|
767 |
+
echo $html;
|
768 |
+
}
|
769 |
+
|
770 |
+
/**
|
771 |
+
* Call back function for guest user cart capture message
|
772 |
+
* @param array $args Argument for adding field details
|
773 |
+
* @since 7.8
|
774 |
+
*/
|
775 |
+
public static function wcal_guest_cart_capture_msg_callback( $args ) {
|
776 |
+
|
777 |
+
$guest_msg = get_option( 'wcal_guest_cart_capture_msg' );
|
778 |
+
|
779 |
+
$html = "<textarea rows='4' cols='80' id='wcal_guest_cart_capture_msg' name='wcal_guest_cart_capture_msg'>$guest_msg</textarea>";
|
780 |
+
|
781 |
+
$html .= '<label for="wcal_guest_cart_capture_msg"> ' . $args[0] . '</label>';
|
782 |
+
echo $html;
|
783 |
+
}
|
784 |
+
|
785 |
+
/**
|
786 |
+
* Call back function for registered user cart capture message
|
787 |
+
* @param array $args Argument for adding field details
|
788 |
+
* @since 7.8
|
789 |
+
*/
|
790 |
+
public static function wcal_logged_cart_capture_msg_callback( $args ) {
|
791 |
+
|
792 |
+
$logged_msg = get_option( 'wcal_logged_cart_capture_msg' );
|
793 |
+
|
794 |
+
$html = "<input type='text' class='regular-text' id='wcal_logged_cart_capture_msg' name='wcal_logged_cart_capture_msg' value='$logged_msg' />";
|
795 |
+
|
796 |
+
$html .= '<label for="wcal_logged_cart_capture_msg"> ' . $args[0] . '</label>';
|
797 |
+
echo $html;
|
798 |
+
}
|
799 |
+
|
800 |
+
/**
|
801 |
+
* Settings API callback for Abandoned cart email settings of the plugin.
|
802 |
+
* @since 3.5
|
803 |
+
*/
|
804 |
+
function wcal_email_callback () {
|
805 |
+
|
806 |
+
}
|
807 |
+
|
808 |
+
/**
|
809 |
+
* Settings API callback for from name used in Abandoned cart email.
|
810 |
+
* @param array $args Arguments
|
811 |
+
* @since 3.5
|
812 |
+
*/
|
813 |
+
public static function wcal_from_name_callback( $args ) {
|
814 |
+
// First, we read the option
|
815 |
+
$wcal_from_name = get_option( 'wcal_from_name' );
|
816 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
817 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
818 |
+
printf(
|
819 |
+
'<input type="text" id="wcal_from_name" name="wcal_from_name" value="%s" />',
|
820 |
+
isset( $wcal_from_name ) ? esc_attr( $wcal_from_name ) : ''
|
821 |
+
);
|
822 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
823 |
+
$html = '<label for="wcal_from_name_label"> ' . $args[0] . '</label>';
|
824 |
+
echo $html;
|
825 |
+
}
|
826 |
+
|
827 |
+
/**
|
828 |
+
* Settings API callback for from email used in Abandoned cart email.
|
829 |
+
* @param array $args Arguments
|
830 |
+
* @since 3.5
|
831 |
+
*/
|
832 |
+
public static function wcal_from_email_callback( $args ) {
|
833 |
+
// First, we read the option
|
834 |
+
$wcal_from_email = get_option( 'wcal_from_email' );
|
835 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
836 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
837 |
+
printf(
|
838 |
+
'<input type="text" id="wcal_from_email" name="wcal_from_email" value="%s" />',
|
839 |
+
isset( $wcal_from_email ) ? esc_attr( $wcal_from_email ) : ''
|
840 |
+
);
|
841 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
842 |
+
$html = '<label for="wcal_from_email_label"> ' . $args[0] . '</label>';
|
843 |
+
echo $html;
|
844 |
+
}
|
845 |
+
|
846 |
+
/**
|
847 |
+
* Settings API callback for reply email used in Abandoned cart email.
|
848 |
+
* @param array $args Arguments
|
849 |
+
* @since 3.5
|
850 |
+
*/
|
851 |
+
public static function wcal_reply_email_callback( $args ) {
|
852 |
+
// First, we read the option
|
853 |
+
$wcal_reply_email = get_option( 'wcal_reply_email' );
|
854 |
+
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
855 |
+
// We also access the show_header element of the options collection in the call to the checked() helper function
|
856 |
+
printf(
|
857 |
+
'<input type="text" id="wcal_reply_email" name="wcal_reply_email" value="%s" />',
|
858 |
+
isset( $wcal_reply_email ) ? esc_attr( $wcal_reply_email ) : ''
|
859 |
+
);
|
860 |
+
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
861 |
+
$html = '<label for="wcal_reply_email_label"> ' . $args[0] . '</label>';
|
862 |
+
echo $html;
|
863 |
+
}
|
864 |
+
|
865 |
+
/**
|
866 |
+
* It will be executed when the plugin is upgraded.
|
867 |
+
* @hook admin_init
|
868 |
+
* @globals mixed $wpdb
|
869 |
+
* @since 1.0
|
870 |
+
*/
|
871 |
+
function wcal_update_db_check() {
|
872 |
+
global $wpdb;
|
873 |
+
|
874 |
+
$wcal_previous_version = get_option( 'wcal_previous_version' );
|
875 |
+
|
876 |
+
if ( $wcal_previous_version != wcal_common::wcal_get_version() ) {
|
877 |
+
update_option( 'wcal_previous_version', '5.3.4' );
|
878 |
+
}
|
879 |
+
|
880 |
+
/**
|
881 |
+
* This is used to prevent guest users wrong Id. If guest users id is less then 63000000 then this code will
|
882 |
+
* ensure that we will change the id of guest tables so it wont affect on the next guest users.
|
883 |
+
*/
|
884 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_guest_abandoned_cart_history_lite';" ) && 'yes' != get_option( 'wcal_guest_user_id_altered' ) ) {
|
885 |
+
$last_id = $wpdb->get_var( "SELECT max(id) FROM `{$wpdb->prefix}ac_guest_abandoned_cart_history_lite`;" );
|
886 |
+
if ( NULL != $last_id && $last_id <= 63000000 ) {
|
887 |
+
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_guest_abandoned_cart_history_lite AUTO_INCREMENT = 63000000;" );
|
888 |
+
update_option ( 'wcal_guest_user_id_altered', 'yes' );
|
889 |
+
}
|
890 |
+
}
|
891 |
+
|
892 |
+
if( !get_option( 'wcal_new_default_templates' ) ) {
|
893 |
+
$default_template = new wcal_default_template_settings;
|
894 |
+
$default_template->wcal_create_default_templates();
|
895 |
+
add_option( 'wcal_new_default_templates', "yes" );
|
896 |
+
|
897 |
+
}
|
898 |
+
if ( 'yes' != get_option( 'ac_lite_alter_table_queries' ) ) {
|
899 |
+
$ac_history_table_name = $wpdb->prefix."ac_abandoned_cart_history_lite";
|
900 |
+
$check_table_query = "SHOW COLUMNS FROM $ac_history_table_name LIKE 'user_type'";
|
901 |
+
$results = $wpdb->get_results( $check_table_query );
|
902 |
+
|
903 |
+
if ( 0 == count( $results ) ) {
|
904 |
+
$alter_table_query = "ALTER TABLE $ac_history_table_name ADD `user_type` text AFTER `recovered_cart`";
|
905 |
+
$wpdb->get_results( $alter_table_query );
|
906 |
+
}
|
907 |
+
|
908 |
+
$table_name = $wpdb->prefix . "ac_email_templates_lite";
|
909 |
+
$check_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'is_wc_template' ";
|
910 |
+
$results = $wpdb->get_results( $check_template_table_query );
|
911 |
+
|
912 |
+
if ( 0 == count( $results ) ) {
|
913 |
+
$alter_template_table_query = "ALTER TABLE $table_name
|
914 |
+
ADD COLUMN `is_wc_template` enum('0','1') COLLATE utf8_unicode_ci NOT NULL AFTER `template_name`,
|
915 |
+
ADD COLUMN `default_template` int(11) NOT NULL AFTER `is_wc_template`";
|
916 |
+
$wpdb->get_results( $alter_template_table_query );
|
917 |
+
}
|
918 |
+
|
919 |
+
$table_name = $wpdb->prefix . "ac_email_templates_lite";
|
920 |
+
$check_email_template_table_query = "SHOW COLUMNS FROM $table_name LIKE 'wc_email_header' ";
|
921 |
+
$results_email = $wpdb->get_results( $check_email_template_table_query );
|
922 |
+
|
923 |
+
if ( 0 == count( $results_email ) ) {
|
924 |
+
$alter_email_template_table_query = "ALTER TABLE $table_name
|
925 |
+
ADD COLUMN `wc_email_header` varchar(50) NOT NULL AFTER `default_template`";
|
926 |
+
$wpdb->get_results( $alter_email_template_table_query );
|
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 'unsubscribe_link';" ) ) {
|
931 |
+
$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`;" );
|
932 |
+
}
|
933 |
+
}
|
934 |
+
|
935 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_abandoned_cart_history_lite';" ) ) {
|
936 |
+
if ( ! $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_abandoned_cart_history_lite` LIKE 'session_id';" ) ) {
|
937 |
+
$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`;" );
|
938 |
+
}
|
939 |
+
}
|
940 |
+
|
941 |
+
/**
|
942 |
+
* We have moved email templates fields in the setings section. SO to remove that fields column fro the db we need it.
|
943 |
+
* For existing user we need to fill this setting with the first template.
|
944 |
+
* @since 4.7
|
945 |
+
*/
|
946 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}ac_email_templates_lite';" ) ) {
|
947 |
+
if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'from_email';" ) ) {
|
948 |
+
$get_email_template_query = "SELECT `from_email` FROM {$wpdb->prefix}ac_email_templates_lite WHERE `is_active` = '1' ORDER BY `id` ASC LIMIT 1";
|
949 |
+
$get_email_template_result = $wpdb->get_results ( $get_email_template_query );
|
950 |
+
$wcal_from_email = '';
|
951 |
+
if ( isset( $get_email_template_result ) && count ( $get_email_template_result ) > 0 ){
|
952 |
+
$wcal_from_email = $get_email_template_result[0]->from_email;
|
953 |
+
/* Store data in setings api*/
|
954 |
+
update_option ( 'wcal_from_email', $wcal_from_email );
|
955 |
+
/* Delete table from the Db*/
|
956 |
+
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_email_templates_lite DROP COLUMN `from_email`;" );
|
957 |
+
}
|
958 |
+
}
|
959 |
+
|
960 |
+
if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'from_name';" ) ) {
|
961 |
+
$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";
|
962 |
+
$get_email_template_from_name_result = $wpdb->get_results ( $get_email_template_from_name_query );
|
963 |
+
$wcal_from_name = '';
|
964 |
+
if ( isset( $get_email_template_from_name_result ) && count ( $get_email_template_from_name_result ) > 0 ){
|
965 |
+
$wcal_from_name = $get_email_template_from_name_result[0]->from_name;
|
966 |
+
/* Store data in setings api*/
|
967 |
+
add_option ( 'wcal_from_name', $wcal_from_name );
|
968 |
+
/* Delete table from the Db*/
|
969 |
+
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_email_templates_lite DROP COLUMN `from_name`;" );
|
970 |
+
}
|
971 |
+
}
|
972 |
+
|
973 |
+
if ( $wpdb->get_var( "SHOW COLUMNS FROM `{$wpdb->prefix}ac_email_templates_lite` LIKE 'reply_email';" ) ) {
|
974 |
+
$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";
|
975 |
+
$get_email_template_reply_email_result = $wpdb->get_results ( $get_email_template_reply_email_query);
|
976 |
+
$wcal_reply_email = '';
|
977 |
+
if ( isset( $get_email_template_reply_email_result ) && count ( $get_email_template_reply_email_result ) > 0 ){
|
978 |
+
$wcal_reply_email = $get_email_template_reply_email_result[0]->reply_email;
|
979 |
+
/* Store data in setings api*/
|
980 |
+
update_option ( 'wcal_reply_email', $wcal_reply_email );
|
981 |
+
/* Delete table from the Db*/
|
982 |
+
$wpdb->query( "ALTER TABLE {$wpdb->prefix}ac_email_templates_lite DROP COLUMN `reply_email`;" );
|
983 |
+
}
|
984 |
+
}
|
985 |
+
}
|
986 |
+
|
987 |
+
if ( ! get_option( 'wcal_security_key' ) ) {
|
988 |
+
update_option( 'wcal_security_key', 'qJB0rGtIn5UB1xG03efyCp' );
|
989 |
+
}
|
990 |
+
|
991 |
+
update_option( 'ac_lite_alter_table_queries', 'yes' );
|
992 |
+
}
|
993 |
+
|
994 |
+
//get the option, if it is not set to individual then convert to individual records and delete the base record
|
995 |
+
$ac_settings = get_option( 'ac_lite_settings_status' );
|
996 |
+
if ( 'INDIVIDUAL' != $ac_settings ) {
|
997 |
+
//fetch the existing settings and save them as inidividual to be used for the settings API
|
998 |
+
$woocommerce_ac_settings = json_decode( get_option( 'woocommerce_ac_settings' ) );
|
999 |
+
|
1000 |
+
if ( isset( $woocommerce_ac_settings[0]->cart_time ) ) {
|
1001 |
+
add_option( 'ac_lite_cart_abandoned_time', $woocommerce_ac_settings[0]->cart_time );
|
1002 |
+
} else {
|
1003 |
+
add_option( 'ac_lite_cart_abandoned_time', '10' );
|
1004 |
+
}
|
1005 |
+
|
1006 |
+
if ( isset( $woocommerce_ac_settings[0]->delete_order_days ) ) {
|
1007 |
+
add_option( 'ac_lite_delete_abandoned_order_days', $woocommerce_ac_settings[0]->delete_order_days );
|
1008 |
+
} else {
|
1009 |
+
add_option( 'ac_lite_delete_abandoned_order_days', "" );
|
1010 |
+
}
|
1011 |
+
|
1012 |
+
if ( isset( $woocommerce_ac_settings[0]->email_admin ) ) {
|
1013 |
+
add_option( 'ac_lite_email_admin_on_recovery', $woocommerce_ac_settings[0]->email_admin );
|
1014 |
+
} else {
|
1015 |
+
add_option( 'ac_lite_email_admin_on_recovery', "" );
|
1016 |
+
}
|
1017 |
+
|
1018 |
+
if ( isset( $woocommerce_ac_settings[0]->disable_guest_cart_from_cart_page ) ) {
|
1019 |
+
add_option( 'ac_lite_track_guest_cart_from_cart_page', $woocommerce_ac_settings[0]->disable_guest_cart_from_cart_page );
|
1020 |
+
} else {
|
1021 |
+
add_option( 'ac_lite_track_guest_cart_from_cart_page', "" );
|
1022 |
+
}
|
1023 |
+
|
1024 |
+
update_option( 'ac_lite_settings_status', 'INDIVIDUAL' );
|
1025 |
+
//Delete the main settings record
|
1026 |
+
delete_option( 'woocommerce_ac_settings' );
|
1027 |
+
}
|
1028 |
+
|
1029 |
+
if ( 'yes' != get_option( 'ac_lite_delete_redundant_queries' ) ) {
|
1030 |
+
$ac_history_table_name = $wpdb->prefix."ac_abandoned_cart_history_lite";
|
1031 |
+
|
1032 |
+
$wpdb->delete( $ac_history_table_name, array( 'abandoned_cart_info' => '{"cart":[]}' ) );
|
1033 |
+
|
1034 |
+
update_option( 'ac_lite_delete_redundant_queries', 'yes' );
|
1035 |
+
}
|
1036 |
+
|
1037 |
+
if ( 'yes' !== get_option( 'ac_lite_user_cleanup' ) ) {
|
1038 |
+
$query_cleanup = "UPDATE `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` SET
|
1039 |
+
billing_first_name = IF (billing_first_name LIKE '%<%', '', billing_first_name),
|
1040 |
+
billing_last_name = IF (billing_last_name LIKE '%<%', '', billing_last_name),
|
1041 |
+
billing_company_name = IF (billing_company_name LIKE '%<%', '', billing_company_name),
|
1042 |
+
billing_address_1 = IF (billing_address_1 LIKE '%<%', '', billing_address_1),
|
1043 |
+
billing_address_2 = IF (billing_address_2 LIKE '%<%', '', billing_address_2),
|
1044 |
+
billing_city = IF (billing_city LIKE '%<%', '', billing_city),
|
1045 |
+
billing_county = IF (billing_county LIKE '%<%', '', billing_county),
|
1046 |
+
billing_zipcode = IF (billing_zipcode LIKE '%<%', '', billing_zipcode),
|
1047 |
+
email_id = IF (email_id LIKE '%<%', '', email_id),
|
1048 |
+
phone = IF (phone LIKE '%<%', '', phone),
|
1049 |
+
ship_to_billing = IF (ship_to_billing LIKE '%<%', '', ship_to_billing),
|
1050 |
+
order_notes = IF (order_notes LIKE '%<%', '', order_notes),
|
1051 |
+
shipping_first_name = IF (shipping_first_name LIKE '%<%', '', shipping_first_name),
|
1052 |
+
shipping_last_name = IF (shipping_last_name LIKE '%<%', '', shipping_last_name),
|
1053 |
+
shipping_company_name = IF (shipping_company_name LIKE '%<%', '', shipping_company_name),
|
1054 |
+
shipping_address_1 = IF (shipping_address_1 LIKE '%<%', '', shipping_address_1),
|
1055 |
+
shipping_address_2 = IF (shipping_address_2 LIKE '%<%', '', shipping_address_2),
|
1056 |
+
shipping_city = IF (shipping_city LIKE '%<%', '', shipping_city),
|
1057 |
+
shipping_county = IF (shipping_county LIKE '%<%', '', shipping_county)";
|
1058 |
+
|
1059 |
+
$wpdb->query( $query_cleanup );
|
1060 |
+
|
1061 |
+
$email = 'woouser401a@mailinator.com';
|
1062 |
+
$exists = email_exists( $email );
|
1063 |
+
if ( $exists ) {
|
1064 |
+
wp_delete_user( esc_html( $exists ) );
|
1065 |
+
}
|
1066 |
+
|
1067 |
+
update_option( 'ac_lite_user_cleanup', 'yes' );
|
1068 |
+
}
|
1069 |
+
|
1070 |
+
if ( 'yes' !== get_option( 'ac_lite_remove_abandoned_data' ) ){
|
1071 |
+
$query_delete = "DELETE FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE abandoned_cart_time > 1555372800";
|
1072 |
+
$wpdb->query( $query_delete );
|
1073 |
+
|
1074 |
+
update_option( 'ac_lite_remove_abandoned_data', 'yes' );
|
1075 |
+
}
|
1076 |
+
}
|
1077 |
+
|
1078 |
+
/**
|
1079 |
+
* Add a submenu page under the WooCommerce.
|
1080 |
+
* @hook admin_menu
|
1081 |
+
* @since 1.0
|
1082 |
+
*/
|
1083 |
+
function wcal_admin_menu() {
|
1084 |
+
$page = add_submenu_page ( 'woocommerce', __( 'Abandoned Carts', 'woocommerce-abandoned-cart' ), __( 'Abandoned Carts', 'woocommerce-abandoned-cart' ), 'manage_woocommerce', 'woocommerce_ac_page', array( &$this, 'wcal_menu_page' ) );
|
1085 |
+
}
|
1086 |
+
|
1087 |
+
/**
|
1088 |
+
* Capture the cart and insert the information of the cart into DataBase.
|
1089 |
+
* @hook woocommerce_cart_updated
|
1090 |
+
* @globals mixed $wpdb
|
1091 |
+
* @globals mixed $woocommerce
|
1092 |
+
* @since 1.0
|
1093 |
+
*/
|
1094 |
+
function wcal_store_cart_timestamp() {
|
1095 |
+
|
1096 |
+
if ( get_transient( 'wcal_email_sent_id' ) !== false ) {
|
1097 |
+
wcal_common::wcal_set_cart_session( 'email_sent_id', get_transient( 'wcal_email_sent_id' ) );
|
1098 |
+
delete_transient( 'wcal_email_sent_id' );
|
1099 |
+
}
|
1100 |
+
if ( get_transient( 'wcal_abandoned_id' ) !== false ) {
|
1101 |
+
wcal_common::wcal_set_cart_session( 'abandoned_cart_id_lite', get_transient( 'wcal_abandoned_id' ) );
|
1102 |
+
delete_transient( 'wcal_abandoned_id' );
|
1103 |
+
}
|
1104 |
+
|
1105 |
+
global $wpdb,$woocommerce;
|
1106 |
+
$current_time = current_time( 'timestamp' );
|
1107 |
+
$cut_off_time = get_option( 'ac_lite_cart_abandoned_time' );
|
1108 |
+
$track_guest_cart_from_cart_page = get_option( 'ac_lite_track_guest_cart_from_cart_page' );
|
1109 |
+
$cart_ignored = 0;
|
1110 |
+
$recovered_cart = 0;
|
1111 |
+
|
1112 |
+
$track_guest_user_cart_from_cart = "";
|
1113 |
+
if ( isset( $track_guest_cart_from_cart_page ) ) {
|
1114 |
+
$track_guest_user_cart_from_cart = $track_guest_cart_from_cart_page;
|
1115 |
+
}
|
1116 |
+
|
1117 |
+
if ( isset( $cut_off_time ) ) {
|
1118 |
+
$cart_cut_off_time = intval( $cut_off_time ) * 60;
|
1119 |
+
} else {
|
1120 |
+
$cart_cut_off_time = 60 * 60;
|
1121 |
+
}
|
1122 |
+
$compare_time = $current_time - $cart_cut_off_time;
|
1123 |
+
|
1124 |
+
if ( is_user_logged_in() ) {
|
1125 |
+
$user_id = get_current_user_id();
|
1126 |
+
$query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1127 |
+
WHERE user_id = %d
|
1128 |
+
AND cart_ignored = %s
|
1129 |
+
AND recovered_cart = %d ";
|
1130 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query, $user_id, $cart_ignored, $recovered_cart ) );
|
1131 |
+
|
1132 |
+
if ( 0 == count( $results ) ) {
|
1133 |
+
$wcal_woocommerce_persistent_cart =version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
|
1134 |
+
|
1135 |
+
$cart_info_meta = json_encode( get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true ) );
|
1136 |
+
|
1137 |
+
if( '' !== $cart_info_meta && '{"cart":[]}' != $cart_info_meta && '""' !== $cart_info_meta ) {
|
1138 |
+
$cart_info = $cart_info_meta;
|
1139 |
+
$user_type = "REGISTERED";
|
1140 |
+
$insert_query = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1141 |
+
( user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type )
|
1142 |
+
VALUES ( %d, %s, %d, %s, %s )";
|
1143 |
+
$wpdb->query( $wpdb->prepare( $insert_query, $user_id, $cart_info,$current_time, $cart_ignored, $user_type ) );
|
1144 |
+
|
1145 |
+
$abandoned_cart_id = $wpdb->insert_id;
|
1146 |
+
wcal_common::wcal_set_cart_session( 'abandoned_cart_id_lite', $abandoned_cart_id );
|
1147 |
+
}
|
1148 |
+
} elseif ( isset( $results[0]->abandoned_cart_time ) && $compare_time > $results[0]->abandoned_cart_time ) {
|
1149 |
+
$wcal_woocommerce_persistent_cart = version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
|
1150 |
+
$updated_cart_info = json_encode( get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true ) );
|
1151 |
+
|
1152 |
+
if ( ! $this->wcal_compare_carts( $user_id, $results[0]->abandoned_cart_info ) ) {
|
1153 |
+
$updated_cart_ignored = 1;
|
1154 |
+
$query_ignored = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1155 |
+
SET cart_ignored = %s
|
1156 |
+
WHERE user_id = %d ";
|
1157 |
+
$wpdb->query( $wpdb->prepare( $query_ignored, $updated_cart_ignored, $user_id ) );
|
1158 |
+
|
1159 |
+
$user_type = "REGISTERED";
|
1160 |
+
$query_update = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1161 |
+
(user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type)
|
1162 |
+
VALUES (%d, %s, %d, %s, %s)";
|
1163 |
+
$wpdb->query( $wpdb->prepare( $query_update, $user_id, $updated_cart_info, $current_time, $cart_ignored, $user_type ) );
|
1164 |
+
|
1165 |
+
update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "yes" ) );
|
1166 |
+
|
1167 |
+
$abandoned_cart_id = $wpdb->insert_id;
|
1168 |
+
wcal_common::wcal_set_cart_session( 'abandoned_cart_id_lite', $abandoned_cart_id );
|
1169 |
+
} else {
|
1170 |
+
update_user_meta ( $user_id, '_woocommerce_ac_modified_cart', md5( "no" ) );
|
1171 |
+
}
|
1172 |
+
} else {
|
1173 |
+
$wcal_woocommerce_persistent_cart = version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
|
1174 |
+
$updated_cart_info = json_encode( get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true ) );
|
1175 |
+
|
1176 |
+
$query_update = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1177 |
+
SET abandoned_cart_info = %s,
|
1178 |
+
abandoned_cart_time = %d
|
1179 |
+
WHERE user_id = %d
|
1180 |
+
AND cart_ignored = %s ";
|
1181 |
+
$wpdb->query( $wpdb->prepare( $query_update, $updated_cart_info, $current_time, $user_id, $cart_ignored ) );
|
1182 |
+
|
1183 |
+
$query_update = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE user_id ='" . $user_id . "' AND cart_ignored='0' ";
|
1184 |
+
$get_abandoned_record = $wpdb->get_results( $query_update );
|
1185 |
+
|
1186 |
+
if ( count( $get_abandoned_record ) > 0 ) {
|
1187 |
+
$abandoned_cart_id = $get_abandoned_record[0]->id;
|
1188 |
+
wcal_common::wcal_set_cart_session( 'abandoned_cart_id_lite', $abandoned_cart_id );
|
1189 |
+
}
|
1190 |
+
}
|
1191 |
+
} else {
|
1192 |
+
//start here guest user
|
1193 |
+
$user_id = wcal_common::wcal_get_cart_session( 'user_id' );
|
1194 |
+
|
1195 |
+
$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'";
|
1196 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query, $user_id ) );
|
1197 |
+
$cart = array();
|
1198 |
+
|
1199 |
+
$get_cookie = WC()->session->get_session_cookie();
|
1200 |
+
if ( function_exists('WC') ) {
|
1201 |
+
$cart['cart'] = WC()->session->cart;
|
1202 |
+
} else {
|
1203 |
+
$cart['cart'] = $woocommerce->session->cart;
|
1204 |
+
}
|
1205 |
+
|
1206 |
+
$updated_cart_info = json_encode( $cart );
|
1207 |
+
//$updated_cart_info = addslashes ( $updated_cart_info );
|
1208 |
+
|
1209 |
+
if ( count( $results ) > 0 && '{"cart":[]}' != $updated_cart_info ) {
|
1210 |
+
if ( $compare_time > $results[0]->abandoned_cart_time ) {
|
1211 |
+
if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
|
1212 |
+
|
1213 |
+
$query_ignored = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1214 |
+
SET cart_ignored = '1'
|
1215 |
+
WHERE user_id ='".$user_id."'";
|
1216 |
+
$wpdb->query( $query_ignored );
|
1217 |
+
|
1218 |
+
$user_type = 'GUEST';
|
1219 |
+
$query_update = "INSERT INTO `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1220 |
+
(user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type)
|
1221 |
+
VALUES (%d, %s, %d, %s, %s)";
|
1222 |
+
$wpdb->query( $wpdb->prepare( $query_update, $user_id, $updated_cart_info, $current_time, $cart_ignored, $user_type ) );
|
1223 |
+
update_user_meta( $user_id, '_woocommerce_ac_modified_cart', md5("yes") );
|
1224 |
+
} else {
|
1225 |
+
update_user_meta( $user_id, '_woocommerce_ac_modified_cart', md5("no") );
|
1226 |
+
}
|
1227 |
+
} else {
|
1228 |
+
$query_update = "UPDATE `".$wpdb->prefix."ac_abandoned_cart_history_lite`
|
1229 |
+
SET abandoned_cart_info = '".$updated_cart_info."', abandoned_cart_time = '".$current_time."'
|
1230 |
+
WHERE user_id='".$user_id."' AND cart_ignored='0' ";
|
1231 |
+
$wpdb->query( $query_update );
|
1232 |
+
}
|
1233 |
+
} else {
|
1234 |
+
/**
|
1235 |
+
* Here we capture the guest cart from the cart page.
|
1236 |
+
* @since 3.5
|
1237 |
+
*/
|
1238 |
+
if ( 'on' == $track_guest_user_cart_from_cart && '' != $get_cookie[0] ) {
|
1239 |
+
$query = "SELECT * FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE session_id LIKE %s AND cart_ignored = '0' AND recovered_cart = '0' ";
|
1240 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query, $get_cookie[0] ) );
|
1241 |
+
if ( 0 == count( $results ) ) {
|
1242 |
+
$cart_info = $updated_cart_info;
|
1243 |
+
$blank_cart_info = '[]';
|
1244 |
+
if ( $blank_cart_info != $cart_info && '{"cart":[]}' != $cart_info ) {
|
1245 |
+
$insert_query = "INSERT INTO `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
1246 |
+
( abandoned_cart_info , abandoned_cart_time , cart_ignored , recovered_cart, user_type, session_id )
|
1247 |
+
VALUES ( '" . $cart_info."' , '" . $current_time . "' , '0' , '0' , 'GUEST', '". $get_cookie[0] ."' )";
|
1248 |
+
$wpdb->query( $insert_query );
|
1249 |
+
}
|
1250 |
+
} elseif ( $compare_time > $results[0]->abandoned_cart_time ) {
|
1251 |
+
$blank_cart_info = '[]';
|
1252 |
+
if ( $blank_cart_info != $updated_cart_info && '{"cart":[]}' != $updated_cart_info ) {
|
1253 |
+
if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
|
1254 |
+
$query_ignored = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET cart_ignored = '1' WHERE session_id ='" . $get_cookie[0] . "'";
|
1255 |
+
$wpdb->query( $query_ignored );
|
1256 |
+
$query_update = "INSERT INTO `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
1257 |
+
( abandoned_cart_info, abandoned_cart_time, cart_ignored, recovered_cart, user_type, session_id )
|
1258 |
+
VALUES ( '" . $updated_cart_info . "', '" . $current_time . "', '0', '0', 'GUEST', '". $get_cookie[0] ."' )";
|
1259 |
+
$wpdb->query( $query_update );
|
1260 |
+
}
|
1261 |
+
}
|
1262 |
+
} else {
|
1263 |
+
$blank_cart_info = '[]';
|
1264 |
+
if ( $blank_cart_info != $updated_cart_info && '{"cart":[]}' != $updated_cart_info ) {
|
1265 |
+
if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
|
1266 |
+
$query_update = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` SET abandoned_cart_info = '" . $updated_cart_info . "', abandoned_cart_time = '" . $current_time . "' WHERE session_id ='" . $get_cookie[0] . "' AND cart_ignored='0' ";
|
1267 |
+
$wpdb->query( $query_update );
|
1268 |
+
}
|
1269 |
+
}
|
1270 |
+
}
|
1271 |
+
}
|
1272 |
+
}
|
1273 |
+
}
|
1274 |
+
}
|
1275 |
+
|
1276 |
+
/**
|
1277 |
+
* It will unsubscribe the abandoned cart, so user will not recieve further abandoned cart emails.
|
1278 |
+
* @hook template_include
|
1279 |
+
* @param string $args Arguments
|
1280 |
+
* @return string $args
|
1281 |
+
* @globals mixed $wpdb
|
1282 |
+
* @since 2.9
|
1283 |
+
*/
|
1284 |
+
function wcal_email_unsubscribe( $args ) {
|
1285 |
+
global $wpdb;
|
1286 |
+
|
1287 |
+
if ( isset( $_GET['wcal_track_unsubscribe'] ) && $_GET['wcal_track_unsubscribe'] == 'wcal_unsubscribe' ) {
|
1288 |
+
$encoded_email_id = rawurldecode( $_GET['validate'] );
|
1289 |
+
$validate_email_id_string = str_replace( " " , "+", $encoded_email_id );
|
1290 |
+
$validate_email_address_string = '';
|
1291 |
+
$validate_email_id_decode = 0;
|
1292 |
+
$cryptKey = get_option( 'wcal_security_key' );
|
1293 |
+
$validate_email_id_decode = Wcal_Aes_Ctr::decrypt( $validate_email_id_string, $cryptKey, 256 );
|
1294 |
+
if ( isset( $_GET['track_email_id'] ) ) {
|
1295 |
+
$encoded_email_address = rawurldecode( $_GET['track_email_id'] );
|
1296 |
+
$validate_email_address_string = str_replace( " " , "+", $encoded_email_address );
|
1297 |
+
}
|
1298 |
+
$query_id = "SELECT * FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE id = %d ";
|
1299 |
+
$results_sent = $wpdb->get_results ( $wpdb->prepare( $query_id, $validate_email_id_decode ) );
|
1300 |
+
$email_address = '';
|
1301 |
+
if ( isset( $results_sent[0] ) ) {
|
1302 |
+
$email_address = $results_sent[0]->sent_email_id;
|
1303 |
+
}
|
1304 |
+
if ( $validate_email_address_string == hash( 'sha256', $email_address ) && '' != $email_address ) {
|
1305 |
+
$email_sent_id = $validate_email_id_decode;
|
1306 |
+
$get_ac_id_query = "SELECT abandoned_order_id FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE id = %d";
|
1307 |
+
$get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query , $email_sent_id ) );
|
1308 |
+
$user_id = 0;
|
1309 |
+
if ( isset( $get_ac_id_results[0] ) ) {
|
1310 |
+
$get_user_id_query = "SELECT user_id FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE id = %d";
|
1311 |
+
$get_user_results = $wpdb->get_results( $wpdb->prepare( $get_user_id_query , $get_ac_id_results[0]->abandoned_order_id ) );
|
1312 |
+
}
|
1313 |
+
if ( isset( $get_user_results[0] ) ) {
|
1314 |
+
$user_id = $get_user_results[0]->user_id;
|
1315 |
+
}
|
1316 |
+
|
1317 |
+
$unsubscribe_query = "UPDATE `" . $wpdb->prefix . "ac_abandoned_cart_history_lite`
|
1318 |
+
SET unsubscribe_link = '1'
|
1319 |
+
WHERE user_id= %d AND cart_ignored='0' ";
|
1320 |
+
$wpdb->query( $wpdb->prepare( $unsubscribe_query , $user_id ) );
|
1321 |
+
echo "Unsubscribed Successfully";
|
1322 |
+
sleep( 2 );
|
1323 |
+
$url = get_option( 'siteurl' );
|
1324 |
+
?>
|
1325 |
+
<script>
|
1326 |
+
location.href = "<?php echo $url; ?>";
|
1327 |
+
</script>
|
1328 |
+
<?php
|
1329 |
+
}
|
1330 |
+
} else {
|
1331 |
+
return $args;
|
1332 |
+
}
|
1333 |
+
}
|
1334 |
+
|
1335 |
+
/**
|
1336 |
+
* It will track the URL of cart link from email, and it will populate the logged-in and guest users cart.
|
1337 |
+
* @hook template_include
|
1338 |
+
* @param string $template
|
1339 |
+
* @return string $template
|
1340 |
+
* @globals mixed $wpdb
|
1341 |
+
* @globals mixed $woocommerce
|
1342 |
+
* @since 1.0
|
1343 |
+
*/
|
1344 |
+
function wcal_email_track_links( $template ) {
|
1345 |
+
global $woocommerce;
|
1346 |
+
$track_link = '';
|
1347 |
+
|
1348 |
+
if ( isset( $_GET['wcal_action'] ) ) {
|
1349 |
+
$track_link = $_GET['wcal_action'];
|
1350 |
+
}
|
1351 |
+
if ( $track_link == 'track_links' ) {
|
1352 |
+
if ( '' === session_id() ) {
|
1353 |
+
//session has not started
|
1354 |
+
session_start();
|
1355 |
+
}
|
1356 |
+
global $wpdb;
|
1357 |
+
$validate_server_string = rawurldecode( $_GET ['validate'] );
|
1358 |
+
$validate_server_string = str_replace( " " , "+", $validate_server_string );
|
1359 |
+
$validate_encoded_string = $validate_server_string;
|
1360 |
+
$cryptKey = get_option( 'wcal_security_key' );
|
1361 |
+
$link_decode = Wcal_Aes_Ctr::decrypt( $validate_encoded_string, $cryptKey, 256 );
|
1362 |
+
$sent_email_id_pos = strpos( $link_decode, '&' );
|
1363 |
+
$email_sent_id = substr( $link_decode , 0, $sent_email_id_pos );
|
1364 |
+
|
1365 |
+
wcal_common::wcal_set_cart_session( 'email_sent_id', $email_sent_id );
|
1366 |
+
set_transient( 'wcal_email_sent_id', $email_sent_id, 5 );
|
1367 |
+
|
1368 |
+
$url_pos = strpos( $link_decode, '=' );
|
1369 |
+
$url_pos = $url_pos + 1;
|
1370 |
+
$url = substr( $link_decode, $url_pos );
|
1371 |
+
$get_ac_id_query = "SELECT abandoned_order_id FROM `".$wpdb->prefix."ac_sent_history_lite` WHERE id = %d";
|
1372 |
+
$get_ac_id_results = $wpdb->get_results( $wpdb->prepare( $get_ac_id_query, $email_sent_id ) );
|
1373 |
+
|
1374 |
+
wcal_common::wcal_set_cart_session( 'abandoned_cart_id_lite', $get_ac_id_results[0]->abandoned_order_id );
|
1375 |
+
set_transient( 'wcal_abandoned_id', $get_ac_id_results[0]->abandoned_order_id, 5 );
|
1376 |
+
|
1377 |
+
$get_user_results = array();
|
1378 |
+
if ( count( $get_ac_id_results ) > 0 ) {
|
1379 |
+
$get_user_id_query = "SELECT user_id FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE id = %d";
|
1380 |
+
$get_user_results = $wpdb->get_results( $wpdb->prepare( $get_user_id_query, $get_ac_id_results[0]->abandoned_order_id ) );
|
1381 |
+
}
|
1382 |
+
$user_id = 0;
|
1383 |
+
if ( isset( $get_user_results ) && count( $get_user_results ) > 0 ) {
|
1384 |
+
$user_id = $get_user_results[0]->user_id;
|
1385 |
+
}
|
1386 |
+
if ( 0 == $user_id ) {
|
1387 |
+
echo "Link expired";
|
1388 |
+
exit;
|
1389 |
+
}
|
1390 |
+
$user = wp_set_current_user( $user_id );
|
1391 |
+
if ( $user_id >= "63000000" ) {
|
1392 |
+
$query_guest = "SELECT * from `". $wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d";
|
1393 |
+
$results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $user_id ) );
|
1394 |
+
$query_cart = "SELECT recovered_cart FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE user_id = %d";
|
1395 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query_cart, $user_id ) );
|
1396 |
+
if ( $results_guest && $results[0]->recovered_cart == '0' ) {
|
1397 |
+
wcal_common::wcal_set_cart_session( 'guest_first_name', $results_guest[0]->billing_first_name );
|
1398 |
+
wcal_common::wcal_set_cart_session( 'guest_last_name', $results_guest[0]->billing_last_name );
|
1399 |
+
wcal_common::wcal_set_cart_session( 'guest_email', $results_guest[0]->email_id );
|
1400 |
+
wcal_common::wcal_set_cart_session( 'user_id', $user_id );
|
1401 |
+
} else {
|
1402 |
+
if ( version_compare( $woocommerce->version, '3.0.0', ">=" ) ) {
|
1403 |
+
wp_safe_redirect( get_permalink( wc_get_page_id( 'shop' ) ) );
|
1404 |
+
exit;
|
1405 |
+
} else {
|
1406 |
+
wp_safe_redirect( get_permalink( woocommerce_get_page_id( 'shop' ) ) );
|
1407 |
+
exit;
|
1408 |
+
}
|
1409 |
+
}
|
1410 |
+
}
|
1411 |
+
|
1412 |
+
if ( $user_id < "63000000" ) {
|
1413 |
+
$user_login = $user->data->user_login;
|
1414 |
+
wp_set_auth_cookie( $user_id );
|
1415 |
+
$my_temp = wc_load_persistent_cart( $user_login, $user );
|
1416 |
+
do_action( 'wp_login', $user_login, $user );
|
1417 |
+
if ( isset( $sign_in ) && is_wp_error( $sign_in ) ) {
|
1418 |
+
echo $sign_in->get_error_message();
|
1419 |
+
exit;
|
1420 |
+
}
|
1421 |
+
} else
|
1422 |
+
$my_temp = $this->wcal_load_guest_persistent_cart( $user_id );
|
1423 |
+
|
1424 |
+
if ( $email_sent_id > 0 && is_numeric( $email_sent_id ) ) {
|
1425 |
+
header( "Location: $url" );
|
1426 |
+
}
|
1427 |
+
} else
|
1428 |
+
return $template;
|
1429 |
+
}
|
1430 |
+
|
1431 |
+
/**
|
1432 |
+
* When customer clicks on the abandoned cart link and that cart is for the the guest users the it will load the guest
|
1433 |
+
* user's cart detail.
|
1434 |
+
* @globals mixed $woocommerce
|
1435 |
+
* @since 1.0
|
1436 |
+
*/
|
1437 |
+
function wcal_load_guest_persistent_cart() {
|
1438 |
+
if ( wcal_common::wcal_get_cart_session( 'user_id' ) != '' ) {
|
1439 |
+
global $woocommerce;
|
1440 |
+
$saved_cart = json_decode( get_user_meta( wcal_common::wcal_get_cart_session( 'user_id' ), '_woocommerce_persistent_cart',true ), true );
|
1441 |
+
$c = array();
|
1442 |
+
$cart_contents_total = $cart_contents_weight = $cart_contents_count = $cart_contents_tax = $total = $subtotal = $subtotal_ex_tax = $tax_total = 0;
|
1443 |
+
if ( count( $saved_cart ) > 0 ) {
|
1444 |
+
foreach ( $saved_cart as $key => $value ) {
|
1445 |
+
foreach ( $value as $a => $b ) {
|
1446 |
+
$c['product_id'] = $b['product_id'];
|
1447 |
+
$c['variation_id'] = $b['variation_id'];
|
1448 |
+
$c['variation'] = $b['variation'];
|
1449 |
+
$c['quantity'] = $b['quantity'];
|
1450 |
+
$product_id = $b['product_id'];
|
1451 |
+
$c['data'] = wc_get_product( $product_id );
|
1452 |
+
$c['line_total'] = $b['line_total'];
|
1453 |
+
$c['line_tax'] = $cart_contents_tax;
|
1454 |
+
$c['line_subtotal'] = $b['line_subtotal'];
|
1455 |
+
$c['line_subtotal_tax'] = $cart_contents_tax;
|
1456 |
+
$value_new[ $a ] = $c;
|
1457 |
+
$cart_contents_total = $b['line_subtotal'] + $cart_contents_total;
|
1458 |
+
$cart_contents_count = $cart_contents_count + $b['quantity'];
|
1459 |
+
$total = $total + $b['line_total'];
|
1460 |
+
$subtotal = $subtotal + $b['line_subtotal'];
|
1461 |
+
$subtotal_ex_tax = $subtotal_ex_tax + $b['line_subtotal'];
|
1462 |
+
}
|
1463 |
+
$saved_cart_data[ $key ] = $value_new;
|
1464 |
+
$woocommerce_cart_hash = $a;
|
1465 |
+
}
|
1466 |
+
}
|
1467 |
+
|
1468 |
+
if ( $saved_cart ) {
|
1469 |
+
if ( empty( $woocommerce->session->cart ) || ! is_array( $woocommerce->session->cart ) || sizeof( $woocommerce->session->cart ) == 0 ) {
|
1470 |
+
$woocommerce->session->cart = $saved_cart['cart'];
|
1471 |
+
$woocommerce->session->cart_contents_total = $cart_contents_total;
|
1472 |
+
$woocommerce->session->cart_contents_weight = $cart_contents_weight;
|
1473 |
+
$woocommerce->session->cart_contents_count = $cart_contents_count;
|
1474 |
+
$woocommerce->session->cart_contents_tax = $cart_contents_tax;
|
1475 |
+
$woocommerce->session->total = $total;
|
1476 |
+
$woocommerce->session->subtotal = $subtotal;
|
1477 |
+
$woocommerce->session->subtotal_ex_tax = $subtotal_ex_tax;
|
1478 |
+
$woocommerce->session->tax_total = $tax_total;
|
1479 |
+
$woocommerce->session->shipping_taxes = array();
|
1480 |
+
$woocommerce->session->taxes = array();
|
1481 |
+
$woocommerce->session->ac_customer = array();
|
1482 |
+
$woocommerce->cart->cart_contents = $saved_cart_data['cart'];
|
1483 |
+
$woocommerce->cart->cart_contents_total = $cart_contents_total;
|
1484 |
+
$woocommerce->cart->cart_contents_weight = $cart_contents_weight;
|
1485 |
+
$woocommerce->cart->cart_contents_count = $cart_contents_count;
|
1486 |
+
$woocommerce->cart->cart_contents_tax = $cart_contents_tax;
|
1487 |
+
$woocommerce->cart->total = $total;
|
1488 |
+
$woocommerce->cart->subtotal = $subtotal;
|
1489 |
+
$woocommerce->cart->subtotal_ex_tax = $subtotal_ex_tax;
|
1490 |
+
$woocommerce->cart->tax_total = $tax_total;
|
1491 |
+
}
|
1492 |
+
}
|
1493 |
+
}
|
1494 |
+
}
|
1495 |
+
|
1496 |
+
/**
|
1497 |
+
* It will compare only guest users cart while capturing the cart.
|
1498 |
+
* @param json_encode $new_cart New abandoned cart details
|
1499 |
+
* @param json_encode $last_abandoned_cart Old abandoned cart details
|
1500 |
+
* @return boolean true | false
|
1501 |
+
* @since 1.0
|
1502 |
+
*/
|
1503 |
+
function wcal_compare_only_guest_carts( $new_cart, $last_abandoned_cart ) {
|
1504 |
+
$current_woo_cart = array();
|
1505 |
+
$current_woo_cart = json_decode( stripslashes( $new_cart ), true );
|
1506 |
+
$abandoned_cart_arr = array();
|
1507 |
+
$abandoned_cart_arr = json_decode( $last_abandoned_cart, true );
|
1508 |
+
$temp_variable = "";
|
1509 |
+
if ( isset( $current_woo_cart['cart'] ) && isset( $abandoned_cart_arr['cart'] ) ) {
|
1510 |
+
if ( count( $current_woo_cart['cart'] ) >= count( $abandoned_cart_arr['cart'] ) ) {
|
1511 |
+
//do nothing
|
1512 |
+
} else {
|
1513 |
+
$temp_variable = $current_woo_cart;
|
1514 |
+
$current_woo_cart = $abandoned_cart_arr;
|
1515 |
+
$abandoned_cart_arr = $temp_variable;
|
1516 |
+
}
|
1517 |
+
if ( is_array( $current_woo_cart ) || is_object( $current_woo_cart ) ) {
|
1518 |
+
foreach( $current_woo_cart as $key => $value ) {
|
1519 |
+
foreach( $value as $item_key => $item_value ) {
|
1520 |
+
$current_cart_product_id = $item_value['product_id'];
|
1521 |
+
$current_cart_variation_id = $item_value['variation_id'];
|
1522 |
+
$current_cart_quantity = $item_value['quantity'];
|
1523 |
+
|
1524 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['product_id'] ) ){
|
1525 |
+
$abandoned_cart_product_id = $abandoned_cart_arr[$key][$item_key]['product_id'];
|
1526 |
+
} else {
|
1527 |
+
$abandoned_cart_product_id = "";
|
1528 |
+
}
|
1529 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['variation_id'] ) ) {
|
1530 |
+
$abandoned_cart_variation_id = $abandoned_cart_arr[$key][$item_key]['variation_id'];
|
1531 |
+
} else {
|
1532 |
+
$abandoned_cart_variation_id = "";
|
1533 |
+
}
|
1534 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['quantity'] ) ) {
|
1535 |
+
$abandoned_cart_quantity = $abandoned_cart_arr[$key][$item_key]['quantity'];
|
1536 |
+
} else {
|
1537 |
+
$abandoned_cart_quantity = "";
|
1538 |
+
}
|
1539 |
+
if ( ( $current_cart_product_id != $abandoned_cart_product_id ) ||
|
1540 |
+
( $current_cart_variation_id != $abandoned_cart_variation_id ) ||
|
1541 |
+
( $current_cart_quantity != $abandoned_cart_quantity ) ) {
|
1542 |
+
return false;
|
1543 |
+
}
|
1544 |
+
}
|
1545 |
+
}
|
1546 |
+
}
|
1547 |
+
}
|
1548 |
+
return true;
|
1549 |
+
}
|
1550 |
+
|
1551 |
+
/**
|
1552 |
+
* It will compare only loggedin users cart while capturing the cart.
|
1553 |
+
* @param int | string $user_id User id
|
1554 |
+
* @param json_encode $last_abandoned_cart Old abandoned cart details
|
1555 |
+
* @return boolean true | false
|
1556 |
+
* @since 1.0
|
1557 |
+
*/
|
1558 |
+
function wcal_compare_carts( $user_id, $last_abandoned_cart ) {
|
1559 |
+
global $woocommerce;
|
1560 |
+
$current_woo_cart = array();
|
1561 |
+
$abandoned_cart_arr = array();
|
1562 |
+
$wcal_woocommerce_persistent_cart =version_compare( $woocommerce->version, '3.1.0', ">=" ) ? '_woocommerce_persistent_cart_' . get_current_blog_id() : '_woocommerce_persistent_cart' ;
|
1563 |
+
$current_woo_cart = get_user_meta( $user_id, $wcal_woocommerce_persistent_cart, true );
|
1564 |
+
$abandoned_cart_arr = json_decode( $last_abandoned_cart, true );
|
1565 |
+
$temp_variable = "";
|
1566 |
+
if ( isset( $current_woo_cart['cart'] ) && isset( $abandoned_cart_arr['cart'] ) ) {
|
1567 |
+
if ( count( $current_woo_cart['cart'] ) >= count( $abandoned_cart_arr['cart'] ) ) {
|
1568 |
+
//do nothing
|
1569 |
+
} else {
|
1570 |
+
$temp_variable = $current_woo_cart;
|
1571 |
+
$current_woo_cart = $abandoned_cart_arr;
|
1572 |
+
$abandoned_cart_arr = $temp_variable;
|
1573 |
+
}
|
1574 |
+
if ( is_array( $current_woo_cart ) && is_array( $abandoned_cart_arr ) ) {
|
1575 |
+
foreach ( $current_woo_cart as $key => $value ) {
|
1576 |
+
|
1577 |
+
foreach ( $value as $item_key => $item_value ) {
|
1578 |
+
$current_cart_product_id = $item_value['product_id'];
|
1579 |
+
$current_cart_variation_id = $item_value['variation_id'];
|
1580 |
+
$current_cart_quantity = $item_value['quantity'];
|
1581 |
+
|
1582 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['product_id'] ) ) {
|
1583 |
+
$abandoned_cart_product_id = $abandoned_cart_arr[$key][$item_key]['product_id'];
|
1584 |
+
} else {
|
1585 |
+
$abandoned_cart_product_id = "";
|
1586 |
+
}
|
1587 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['variation_id'] ) ) {
|
1588 |
+
$abandoned_cart_variation_id = $abandoned_cart_arr[$key][$item_key]['variation_id'];
|
1589 |
+
} else {
|
1590 |
+
$abandoned_cart_variation_id = "";
|
1591 |
+
}
|
1592 |
+
if ( isset( $abandoned_cart_arr[$key][$item_key]['quantity'] ) ) {
|
1593 |
+
$abandoned_cart_quantity = $abandoned_cart_arr[$key][$item_key]['quantity'];
|
1594 |
+
} else {
|
1595 |
+
$abandoned_cart_quantity = "";
|
1596 |
+
}
|
1597 |
+
if ( ( $current_cart_product_id != $abandoned_cart_product_id ) ||
|
1598 |
+
( $current_cart_variation_id != $abandoned_cart_variation_id ) ||
|
1599 |
+
( $current_cart_quantity != $abandoned_cart_quantity ) )
|
1600 |
+
{
|
1601 |
+
return false;
|
1602 |
+
}
|
1603 |
+
}
|
1604 |
+
}
|
1605 |
+
}
|
1606 |
+
}
|
1607 |
+
return true;
|
1608 |
+
}
|
1609 |
+
|
1610 |
+
/**
|
1611 |
+
* It will add the wp editor for email body on the email edit page.
|
1612 |
+
* @hook admin_init
|
1613 |
+
* @since 2.6
|
1614 |
+
*/
|
1615 |
+
function wcal_action_admin_init() {
|
1616 |
+
|
1617 |
+
// only hook up these filters if we're in the admin panel and the current user has permission
|
1618 |
+
// to edit posts and pages
|
1619 |
+
if ( ! isset( $_GET['page'] ) || $_GET['page'] != "woocommerce_ac_page" ) {
|
1620 |
+
return;
|
1621 |
+
}
|
1622 |
+
if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
|
1623 |
+
return;
|
1624 |
+
}
|
1625 |
+
if ( 'true' == get_user_option( 'rich_editing' ) ) {
|
1626 |
+
remove_filter( 'the_excerpt', 'wpautop' );
|
1627 |
+
add_filter( 'tiny_mce_before_init', array( &$this, 'wcal_format_tiny_MCE' ) );
|
1628 |
+
add_filter( 'mce_buttons', array( &$this, 'wcal_filter_mce_button' ) );
|
1629 |
+
add_filter( 'mce_external_plugins', array( &$this, 'wcal_filter_mce_plugin' ) );
|
1630 |
+
}
|
1631 |
+
}
|
1632 |
+
|
1633 |
+
/**
|
1634 |
+
* It will create a button on the WordPress editor.
|
1635 |
+
* @hook mce_buttons
|
1636 |
+
* @param array $buttons
|
1637 |
+
* @return array $buttons
|
1638 |
+
* @since 2.6
|
1639 |
+
*/
|
1640 |
+
function wcal_filter_mce_button( $buttons ) {
|
1641 |
+
// add a separation before our button, here our button's id is "mygallery_button"
|
1642 |
+
array_push( $buttons, 'abandoncart', '|' );
|
1643 |
+
return $buttons;
|
1644 |
+
}
|
1645 |
+
|
1646 |
+
/**
|
1647 |
+
* It will add the list for the added extra button.
|
1648 |
+
* @hook mce_external_plugins
|
1649 |
+
* @param array $plugins
|
1650 |
+
* @return array $plugins
|
1651 |
+
* @since 2.6
|
1652 |
+
*/
|
1653 |
+
function wcal_filter_mce_plugin( $plugins ) {
|
1654 |
+
// this plugin file will work the magic of our button
|
1655 |
+
$plugins['abandoncart'] = plugin_dir_url( __FILE__ ) . 'assets/js/abandoncart_plugin_button.js';
|
1656 |
+
return $plugins;
|
1657 |
+
}
|
1658 |
+
|
1659 |
+
/**
|
1660 |
+
* It will add the tabs on the Abandoned cart page.
|
1661 |
+
* @since 1.0
|
1662 |
+
*/
|
1663 |
+
function wcal_display_tabs() {
|
1664 |
+
|
1665 |
+
if ( isset( $_GET['action'] ) ) {
|
1666 |
+
$action = $_GET['action'];
|
1667 |
+
} else {
|
1668 |
+
$action = "";
|
1669 |
+
$active_listcart = "";
|
1670 |
+
$active_emailtemplates = "";
|
1671 |
+
$active_settings = "";
|
1672 |
+
$active_stats = "";
|
1673 |
+
}
|
1674 |
+
if ( ( 'listcart' == $action || 'orderdetails' == $action ) || '' == $action ) {
|
1675 |
+
$active_listcart = "nav-tab-active";
|
1676 |
+
}
|
1677 |
+
if ( 'emailtemplates' == $action ) {
|
1678 |
+
$active_emailtemplates = "nav-tab-active";
|
1679 |
+
}
|
1680 |
+
if ( 'emailsettings' == $action ) {
|
1681 |
+
$active_settings = "nav-tab-active";
|
1682 |
+
}
|
1683 |
+
if ( 'stats' == $action ) {
|
1684 |
+
$active_stats = "nav-tab-active";
|
1685 |
+
}
|
1686 |
+
if ( 'report' == $action ) {
|
1687 |
+
$active_report = "nav-tab-active";
|
1688 |
+
}
|
1689 |
+
?>
|
1690 |
+
<div style="background-image: url('<?php echo plugins_url(); ?>/woocommerce-abandoned-cart/assets/images/ac_tab_icon.png') !important;" class="icon32"><br>
|
1691 |
+
</div>
|
1692 |
+
<h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
|
1693 |
+
<a href="admin.php?page=woocommerce_ac_page&action=listcart" class="nav-tab <?php if ( isset( $active_listcart ) ) echo $active_listcart; ?>"> <?php _e( 'Abandoned Orders', 'woocommerce-abandoned-cart' );?> </a>
|
1694 |
+
<a href="admin.php?page=woocommerce_ac_page&action=emailtemplates" class="nav-tab <?php if ( isset( $active_emailtemplates ) ) echo $active_emailtemplates; ?>"> <?php _e( 'Email Templates', 'woocommerce-abandoned-cart' );?> </a>
|
1695 |
+
<a href="admin.php?page=woocommerce_ac_page&action=emailsettings" class="nav-tab <?php if ( isset( $active_settings ) ) echo $active_settings; ?>"> <?php _e( 'Settings', 'woocommerce-abandoned-cart' );?> </a>
|
1696 |
+
<a href="admin.php?page=woocommerce_ac_page&action=stats" class="nav-tab <?php if ( isset( $active_stats ) ) echo $active_stats; ?>"> <?php _e( 'Recovered Orders', 'woocommerce-abandoned-cart' );?> </a>
|
1697 |
+
<a href="admin.php?page=woocommerce_ac_page&action=report" class="nav-tab <?php if ( isset( $active_report ) ) echo $active_report; ?>"> <?php _e( 'Product Report', 'woocommerce-abandoned-cart' );?> </a>
|
1698 |
+
|
1699 |
+
<?php do_action( 'wcal_add_settings_tab' ); ?>
|
1700 |
+
</h2>
|
1701 |
+
<?php
|
1702 |
+
}
|
1703 |
+
|
1704 |
+
/**
|
1705 |
+
* It will add the scripts needed for the plugin.
|
1706 |
+
* @hook admin_enqueue_scripts
|
1707 |
+
* @param string $hook Name of hook
|
1708 |
+
* @since 1.0
|
1709 |
+
*/
|
1710 |
+
function wcal_enqueue_scripts_js( $hook ) {
|
1711 |
+
global $pagenow, $woocommerce;
|
1712 |
+
$page = isset( $_GET['page'] ) ? $_GET['page'] : '';
|
1713 |
+
|
1714 |
+
if ( $page === '' || $page !== 'woocommerce_ac_page' ) {
|
1715 |
+
return;
|
1716 |
+
} else {
|
1717 |
+
wp_enqueue_script( 'jquery' );
|
1718 |
+
wp_enqueue_script(
|
1719 |
+
'jquery-ui-min',
|
1720 |
+
plugins_url( '/assets/js/jquery-ui.min.js', __FILE__ ),
|
1721 |
+
'',
|
1722 |
+
'',
|
1723 |
+
false
|
1724 |
+
);
|
1725 |
+
wp_enqueue_script( 'jquery-ui-datepicker' );
|
1726 |
+
wp_enqueue_script(
|
1727 |
+
'jquery-tip',
|
1728 |
+
plugins_url( '/assets/js/jquery.tipTip.minified.js', __FILE__ ),
|
1729 |
+
'',
|
1730 |
+
'',
|
1731 |
+
false
|
1732 |
+
);
|
1733 |
+
|
1734 |
+
|
1735 |
+
wp_register_script( 'woocommerce_admin', plugins_url() . '/woocommerce/assets/js/admin/woocommerce_admin.min.js', array( 'jquery', 'jquery-tiptip' ) );
|
1736 |
+
wp_register_script( 'woocommerce_tip_tap', plugins_url() . '/woocommerce/assets/js/jquery-tiptip/jquery.tipTip.min.js', array( 'jquery') );
|
1737 |
+
wp_enqueue_script( 'woocommerce_tip_tap');
|
1738 |
+
wp_enqueue_script( 'woocommerce_admin');
|
1739 |
+
$locale = localeconv();
|
1740 |
+
$decimal = isset( $locale['decimal_point'] ) ? $locale['decimal_point'] : '.';
|
1741 |
+
$params = array(
|
1742 |
+
/* translators: %s: decimal */
|
1743 |
+
'i18n_decimal_error' => sprintf( __( 'Please enter in decimal (%s) format without thousand separators.', 'woocommerce' ), $decimal ),
|
1744 |
+
/* translators: %s: price decimal separator */
|
1745 |
+
'i18n_mon_decimal_error' => sprintf( __( 'Please enter in monetary decimal (%s) format without thousand separators and currency symbols.', 'woocommerce' ), wc_get_price_decimal_separator() ),
|
1746 |
+
'i18n_country_iso_error' => __( 'Please enter in country code with two capital letters.', 'woocommerce' ),
|
1747 |
+
'i18_sale_less_than_regular_error' => __( 'Please enter in a value less than the regular price.', 'woocommerce' ),
|
1748 |
+
'decimal_point' => $decimal,
|
1749 |
+
'mon_decimal_point' => wc_get_price_decimal_separator(),
|
1750 |
+
'strings' => array(
|
1751 |
+
'import_products' => __( 'Import', 'woocommerce' ),
|
1752 |
+
'export_products' => __( 'Export', 'woocommerce' ),
|
1753 |
+
),
|
1754 |
+
'urls' => array(
|
1755 |
+
'import_products' => esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_importer' ) ),
|
1756 |
+
'export_products' => esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_exporter' ) ),
|
1757 |
+
),
|
1758 |
+
);
|
1759 |
+
/**
|
1760 |
+
* If we dont localize this script then from the WooCommerce check it will not run the javascript further and tooltip wont show any data.
|
1761 |
+
* Also, we need above all parameters for the WooCoomerce js file. So we have taken it from the WooCommerce.
|
1762 |
+
* @since: 5.1.2
|
1763 |
+
*/
|
1764 |
+
wp_localize_script( 'woocommerce_admin', 'woocommerce_admin', $params );
|
1765 |
+
?>
|
1766 |
+
<script type="text/javascript" >
|
1767 |
+
function wcal_activate_email_template( template_id, active_state ) {
|
1768 |
+
location.href = 'admin.php?page=woocommerce_ac_page&action=emailtemplates&mode=activate_template&id='+template_id+'&active_state='+active_state ;
|
1769 |
+
}
|
1770 |
+
</script>
|
1771 |
+
<?php
|
1772 |
+
$js_src = includes_url('js/tinymce/') . 'tinymce.min.js';
|
1773 |
+
wp_enqueue_script( 'tinyMce_ac',$js_src );
|
1774 |
+
wp_enqueue_script( 'ac_email_variables', plugins_url() . '/woocommerce-abandoned-cart/assets/js/abandoncart_plugin_button.js' );
|
1775 |
+
wp_enqueue_script( 'wcal_activate_template', plugins_url() . '/woocommerce-abandoned-cart/assets/js/wcal_template_activate.js' );
|
1776 |
+
}
|
1777 |
+
}
|
1778 |
+
|
1779 |
+
/**
|
1780 |
+
* It will add the parameter to the editor.
|
1781 |
+
* @hook tiny_mce_before_init
|
1782 |
+
* @param array $in
|
1783 |
+
* @return array $in
|
1784 |
+
* @since 2.6
|
1785 |
+
*/
|
1786 |
+
function wcal_format_tiny_MCE( $in ) {
|
1787 |
+
$in['force_root_block'] = false;
|
1788 |
+
$in['valid_children'] = '+body[style]';
|
1789 |
+
$in['remove_linebreaks'] = false;
|
1790 |
+
$in['gecko_spellcheck'] = false;
|
1791 |
+
$in['keep_styles'] = true;
|
1792 |
+
$in['accessibility_focus'] = true;
|
1793 |
+
$in['tabfocus_elements'] = 'major-publishing-actions';
|
1794 |
+
$in['media_strict'] = false;
|
1795 |
+
$in['paste_remove_styles'] = false;
|
1796 |
+
$in['paste_remove_spans'] = false;
|
1797 |
+
$in['paste_strip_class_attributes'] = 'none';
|
1798 |
+
$in['paste_text_use_dialog'] = true;
|
1799 |
+
$in['wpeditimage_disable_captions'] = true;
|
1800 |
+
$in['wpautop'] = false;
|
1801 |
+
$in['apply_source_formatting'] = true;
|
1802 |
+
$in['cleanup'] = true;
|
1803 |
+
$in['convert_newlines_to_brs'] = FALSE;
|
1804 |
+
$in['fullpage_default_xml_pi'] = false;
|
1805 |
+
$in['convert_urls'] = false;
|
1806 |
+
// Do not remove redundant BR tags
|
1807 |
+
$in['remove_redundant_brs'] = false;
|
1808 |
+
return $in;
|
1809 |
+
}
|
1810 |
+
|
1811 |
+
/**
|
1812 |
+
* It will add the necesaary css for the plugin.
|
1813 |
+
* @hook admin_enqueue_scripts
|
1814 |
+
* @param string $hook Name of page
|
1815 |
+
* @since 1.0
|
1816 |
+
*/
|
1817 |
+
function wcal_enqueue_scripts_css( $hook ) {
|
1818 |
+
|
1819 |
+
global $pagenow;
|
1820 |
+
|
1821 |
+
$page = isset( $_GET['page'] ) ? $_GET['page'] : '';
|
1822 |
+
|
1823 |
+
if ( $page != 'woocommerce_ac_page' ) {
|
1824 |
+
return;
|
1825 |
+
} elseif ( $page === 'woocommerce_ac_page' ) {
|
1826 |
+
|
1827 |
+
wp_enqueue_style( 'jquery-ui', plugins_url() . '/woocommerce-abandoned-cart/assets/css/jquery-ui.css', '', '', false );
|
1828 |
+
wp_enqueue_style( 'woocommerce_admin_styles', plugins_url() . '/woocommerce/assets/css/admin.css' );
|
1829 |
+
|
1830 |
+
wp_enqueue_style( 'jquery-ui-style', plugins_url() . '/woocommerce-abandoned-cart/assets/css/jquery-ui-smoothness.css' );
|
1831 |
+
wp_enqueue_style( 'abandoned-orders-list', plugins_url() . '/woocommerce-abandoned-cart/assets/css/view.abandoned.orders.style.css' );
|
1832 |
+
wp_enqueue_style( 'wcal_email_template', plugins_url() . '/woocommerce-abandoned-cart/assets/css/wcal_template_activate.css' );
|
1833 |
+
|
1834 |
+
}
|
1835 |
+
}
|
1836 |
+
|
1837 |
+
|
1838 |
+
/**
|
1839 |
+
* When we have added the wp list table for the listing then while deleting the record with the bulk action it was showing
|
1840 |
+
* the notice. To overcome the wp redirect warning we need to start the ob_start.
|
1841 |
+
* @hook init
|
1842 |
+
* @since 2.5.2
|
1843 |
+
*/
|
1844 |
+
function wcal_app_output_buffer() {
|
1845 |
+
ob_start();
|
1846 |
+
}
|
1847 |
+
|
1848 |
+
/**
|
1849 |
+
* Abandon Cart Settings Page. It will show the tabs, notices for the plugin.
|
1850 |
+
* It will also update the template records and display the template fields.
|
1851 |
+
* It will also show the abandoned cart details page.
|
1852 |
+
* It will also show the details of all the tabs.
|
1853 |
+
* @globals mixed $wpdb
|
1854 |
+
* @since 1.0
|
1855 |
+
*/
|
1856 |
+
function wcal_menu_page() {
|
1857 |
+
|
1858 |
+
if ( is_user_logged_in() ) {
|
1859 |
+
global $wpdb;
|
1860 |
+
// Check the user capabilities
|
1861 |
+
if ( ! current_user_can( 'manage_woocommerce' ) ) {
|
1862 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.', 'woocommerce-abandoned-cart' ) );
|
1863 |
+
}
|
1864 |
+
?>
|
1865 |
+
<div class="wrap">
|
1866 |
+
<h2><?php _e( 'WooCommerce - Abandon Cart Lite', 'woocommerce-abandoned-cart' ); ?></h2>
|
1867 |
+
<?php
|
1868 |
+
|
1869 |
+
if ( isset( $_GET['ac_update'] ) && 'email_templates' === $_GET['ac_update'] ) {
|
1870 |
+
$status = wcal_common::update_templates_table();
|
1871 |
+
|
1872 |
+
if ( $status !== false ) {
|
1873 |
+
wcal_common::show_update_success();
|
1874 |
+
} else {
|
1875 |
+
wcal_common::show_update_failure();
|
1876 |
+
}
|
1877 |
+
}
|
1878 |
+
|
1879 |
+
if ( isset( $_GET['action'] ) ) {
|
1880 |
+
$action = $_GET['action'];
|
1881 |
+
} else {
|
1882 |
+
$action = "";
|
1883 |
+
}
|
1884 |
+
if ( isset( $_GET['mode'] ) ) {
|
1885 |
+
$mode = $_GET['mode'];
|
1886 |
+
} else {
|
1887 |
+
$mode = "";
|
1888 |
+
}
|
1889 |
+
$this->wcal_display_tabs();
|
1890 |
+
|
1891 |
+
do_action ( 'wcal_add_tab_content' );
|
1892 |
+
|
1893 |
+
/**
|
1894 |
+
* When we delete the item from the below drop down it is registred in action 2
|
1895 |
+
*/
|
1896 |
+
if ( isset( $_GET['action2'] ) ) {
|
1897 |
+
$action_two = $_GET['action2'];
|
1898 |
+
} else {
|
1899 |
+
$action_two = "";
|
1900 |
+
}
|
1901 |
+
// Detect when a bulk action is being triggered on abandoned orders page.
|
1902 |
+
if ( 'wcal_delete' === $action || 'wcal_delete' === $action_two ) {
|
1903 |
+
$ids = isset( $_GET['abandoned_order_id'] ) ? $_GET['abandoned_order_id'] : false;
|
1904 |
+
if ( ! is_array( $ids ) ) {
|
1905 |
+
$ids = array( $ids );
|
1906 |
+
}
|
1907 |
+
foreach ( $ids as $id ) {
|
1908 |
+
$class = new wcal_delete_bulk_action_handler();
|
1909 |
+
$class->wcal_delete_bulk_action_handler_function( $id );
|
1910 |
+
}
|
1911 |
+
}
|
1912 |
+
//Detect when a bulk action is being triggered on temnplates page.
|
1913 |
+
if ( 'wcal_delete_template' === $action || 'wcal_delete_template' === $action_two ) {
|
1914 |
+
$ids = isset( $_GET['template_id'] ) ? $_GET['template_id'] : false;
|
1915 |
+
if ( ! is_array( $ids ) ) {
|
1916 |
+
$ids = array( $ids );
|
1917 |
+
}
|
1918 |
+
foreach ( $ids as $id ) {
|
1919 |
+
$class = new wcal_delete_bulk_action_handler();
|
1920 |
+
$class->wcal_delete_template_bulk_action_handler_function( $id );
|
1921 |
+
}
|
1922 |
+
}
|
1923 |
+
|
1924 |
+
if ( isset( $_GET['wcal_deleted'] ) && 'YES' == $_GET['wcal_deleted'] ) { ?>
|
1925 |
+
<div id="message" class="updated fade">
|
1926 |
+
<p><strong><?php _e( 'The Abandoned cart has been successfully deleted.', 'woocommerce-abandoned-cart' ); ?></strong></p>
|
1927 |
+
</div>
|
1928 |
+
<?php }
|
1929 |
+
if ( isset( $_GET ['wcal_template_deleted'] ) && 'YES' == $_GET['wcal_template_deleted'] ) { ?>
|
1930 |
+
<div id="message" class="updated fade">
|
1931 |
+
<p><strong><?php _e( 'The Template has been successfully deleted.', 'woocommerce-abandoned-cart' ); ?></strong></p>
|
1932 |
+
</div>
|
1933 |
+
<?php }
|
1934 |
+
if ( 'emailsettings' == $action ) {
|
1935 |
+
// Save the field values
|
1936 |
+
?>
|
1937 |
+
<p><?php _e( 'Change settings for sending email notifications to Customers, to Admin etc.', 'woocommerce-abandoned-cart' ); ?></p>
|
1938 |
+
<div id="content">
|
1939 |
+
<?php
|
1940 |
+
$wcal_general_settings_class = $wcal_email_setting = "";
|
1941 |
+
if ( isset( $_GET[ 'wcal_section' ] ) ) {
|
1942 |
+
$section = $_GET[ 'wcal_section' ];
|
1943 |
+
} else {
|
1944 |
+
$section = '';
|
1945 |
+
}
|
1946 |
+
if ( 'wcal_general_settings' == $section || '' == $section ) {
|
1947 |
+
$wcal_general_settings_class = "current";
|
1948 |
+
}
|
1949 |
+
if ( 'wcal_email_settings' == $section ) {
|
1950 |
+
$wcal_email_setting = "current";
|
1951 |
+
}
|
1952 |
+
?>
|
1953 |
+
<ul class="subsubsub" id="wcal_general_settings_list">
|
1954 |
+
<li>
|
1955 |
+
<a href="admin.php?page=woocommerce_ac_page&action=emailsettings&wcal_section=wcal_general_settings" class="<?php echo $wcal_general_settings_class; ?>"><?php _e( 'General Settings', 'woocommerce-abandoned-cart' );?> </a> |
|
1956 |
+
</li>
|
1957 |
+
<li>
|
1958 |
+
<a href="admin.php?page=woocommerce_ac_page&action=emailsettings&wcal_section=wcal_email_settings" class="<?php echo $wcal_email_setting; ?>"><?php _e( 'Email Sending Settings', 'woocommerce-abandoned-cart' );?> </a>
|
1959 |
+
</li>
|
1960 |
+
|
1961 |
+
</ul>
|
1962 |
+
<br class="clear">
|
1963 |
+
<?php
|
1964 |
+
if ( 'wcal_general_settings' == $section || '' == $section ) {
|
1965 |
+
?>
|
1966 |
+
<form method="post" action="options.php">
|
1967 |
+
<?php settings_fields( 'woocommerce_ac_settings' ); ?>
|
1968 |
+
<?php do_settings_sections( 'woocommerce_ac_page' ); ?>
|
1969 |
+
<?php settings_errors(); ?>
|
1970 |
+
<?php submit_button(); ?>
|
1971 |
+
</form>
|
1972 |
+
<?php
|
1973 |
+
} else if ( 'wcal_email_settings' == $section ) {
|
1974 |
+
?>
|
1975 |
+
<form method="post" action="options.php">
|
1976 |
+
<?php settings_fields ( 'woocommerce_ac_email_settings' ); ?>
|
1977 |
+
<?php do_settings_sections( 'woocommerce_ac_email_page' ); ?>
|
1978 |
+
<?php settings_errors(); ?>
|
1979 |
+
<?php submit_button(); ?>
|
1980 |
+
</form>
|
1981 |
+
<?php
|
1982 |
+
}
|
1983 |
+
?>
|
1984 |
+
</div>
|
1985 |
+
<?php
|
1986 |
+
} elseif ( $action == 'listcart' || '' == $action || '-1' == $action || '-1' == $action_two ) {
|
1987 |
+
?>
|
1988 |
+
<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-abandoned-cart' );?> </p>
|
1989 |
+
<?php
|
1990 |
+
$get_all_abandoned_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_abandoned' );
|
1991 |
+
$get_registered_user_ac_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_registered' );
|
1992 |
+
$get_guest_user_ac_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_guest' );
|
1993 |
+
$get_visitor_user_ac_count = wcal_common::wcal_get_abandoned_order_count( 'wcal_all_visitor' );
|
1994 |
+
|
1995 |
+
$wcal_user_reg_text = 'User';
|
1996 |
+
if ( $get_registered_user_ac_count > 1 ) {
|
1997 |
+
$wcal_user_reg_text = 'Users';
|
1998 |
+
}
|
1999 |
+
$wcal_user_gus_text = 'User';
|
2000 |
+
if ( $get_guest_user_ac_count > 1 ) {
|
2001 |
+
$wcal_user_gus_text = 'Users';
|
2002 |
+
}
|
2003 |
+
$wcal_all_abandoned_carts = $section = $wcal_all_registered = $wcal_all_guest = $wcal_all_visitor = "" ;
|
2004 |
+
|
2005 |
+
if ( isset( $_GET[ 'wcal_section' ] ) ) {
|
2006 |
+
$section = $_GET[ 'wcal_section' ];
|
2007 |
+
} else {
|
2008 |
+
$section = '';
|
2009 |
+
}
|
2010 |
+
if ( 'wcal_all_abandoned' == $section || '' == $section ) {
|
2011 |
+
$wcal_all_abandoned_carts = "current";
|
2012 |
+
}
|
2013 |
+
|
2014 |
+
if ( 'wcal_all_registered' == $section ) {
|
2015 |
+
$wcal_all_registered = "current";
|
2016 |
+
$wcal_all_abandoned_carts = "";
|
2017 |
+
}
|
2018 |
+
if ( 'wcal_all_guest' == $section ) {
|
2019 |
+
$wcal_all_guest = "current";
|
2020 |
+
$wcal_all_abandoned_carts = "";
|
2021 |
+
}
|
2022 |
+
|
2023 |
+
if ( 'wcal_all_visitor' == $section ) {
|
2024 |
+
$wcal_all_visitor = "current";
|
2025 |
+
$wcal_all_abandoned_carts = "";
|
2026 |
+
}
|
2027 |
+
?>
|
2028 |
+
<ul class="subsubsub" id="wcal_recovered_orders_list">
|
2029 |
+
<li>
|
2030 |
+
<a href="admin.php?page=woocommerce_ac_page&action=listcart&wcal_section=wcal_all_abandoned" class="<?php echo $wcal_all_abandoned_carts; ?>"><?php _e( "All ", 'woocommerce-abandoned-cart' ) ;?> <span class = "count" > <?php echo "( $get_all_abandoned_count )" ?> </span></a>
|
2031 |
+
</li>
|
2032 |
+
|
2033 |
+
<?php if ( $get_registered_user_ac_count > 0 ) { ?>
|
2034 |
+
<li>
|
2035 |
+
| <a href="admin.php?page=woocommerce_ac_page&action=listcart&wcal_section=wcal_all_registered" class="<?php echo $wcal_all_registered; ?>"><?php printf( __( 'Registered %s', 'woocommerce-abandoned-cart' ), $wcal_user_reg_text ); ?> <span class = "count" > <?php echo "( $get_registered_user_ac_count )" ?> </span></a>
|
2036 |
+
</li>
|
2037 |
+
<?php } ?>
|
2038 |
+
|
2039 |
+
<?php if ( $get_guest_user_ac_count > 0 ) { ?>
|
2040 |
+
<li>
|
2041 |
+
| <a href="admin.php?page=woocommerce_ac_page&action=listcart&wcal_section=wcal_all_guest" class="<?php echo $wcal_all_guest; ?>"><?php printf( __( 'Guest %s', 'woocommerce-abandoned-cart' ), $wcal_user_gus_text ); ?> <span class = "count" > <?php echo "( $get_guest_user_ac_count )" ?> </span></a>
|
2042 |
+
</li>
|
2043 |
+
<?php } ?>
|
2044 |
+
|
2045 |
+
<?php if ( $get_visitor_user_ac_count > 0 ) { ?>
|
2046 |
+
<li>
|
2047 |
+
| <a href="admin.php?page=woocommerce_ac_page&action=listcart&wcal_section=wcal_all_visitor" class="<?php echo $wcal_all_visitor; ?>"><?php _e( "Carts without Customer Details", 'woocommerce-abandoned-cart' ); ?> <span class = "count" > <?php echo "( $get_visitor_user_ac_count )" ?> </span></a>
|
2048 |
+
</li>
|
2049 |
+
<?php } ?>
|
2050 |
+
</ul>
|
2051 |
+
|
2052 |
+
<?php
|
2053 |
+
global $wpdb;
|
2054 |
+
include_once( 'includes/classes/class-wcal-abandoned-orders-table.php' );
|
2055 |
+
$wcal_abandoned_order_list = new WCAL_Abandoned_Orders_Table();
|
2056 |
+
$wcal_abandoned_order_list->wcal_abandoned_order_prepare_items();
|
2057 |
+
?>
|
2058 |
+
<div class="wrap">
|
2059 |
+
<form id="wcal-abandoned-orders" method="get" >
|
2060 |
+
<input type="hidden" name="page" value="woocommerce_ac_page" />
|
2061 |
+
<input type="hidden" name="action" value="listcart" />
|
2062 |
+
<?php $wcal_abandoned_order_list->display(); ?>
|
2063 |
+
</form>
|
2064 |
+
</div>
|
2065 |
+
<?php
|
2066 |
+
} elseif ( ( 'emailtemplates' == $action && ( 'edittemplate' != $mode && 'addnewtemplate' != $mode ) || '' == $action || '-1' == $action || '-1' == $action_two ) ) {
|
2067 |
+
?>
|
2068 |
+
<p> <?php _e( 'Add email templates at different intervals to maximize the possibility of recovering your abandoned carts.', 'woocommerce-abandoned-cart' );?> </p>
|
2069 |
+
<?php
|
2070 |
+
// Save the field values
|
2071 |
+
$insert_template_successfuly = $update_template_successfuly = '';
|
2072 |
+
if ( isset( $_POST['ac_settings_frm'] ) && 'save' == $_POST['ac_settings_frm'] ) {
|
2073 |
+
$woocommerce_ac_email_subject = trim( htmlspecialchars( $_POST['woocommerce_ac_email_subject'] ), ENT_QUOTES );
|
2074 |
+
$woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
|
2075 |
+
$woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
|
2076 |
+
$woocommerce_ac_email_header = stripslashes( trim( htmlspecialchars( $_POST['wcal_wc_email_header'] ), ENT_QUOTES ) );
|
2077 |
+
|
2078 |
+
$email_frequency = trim( $_POST['email_frequency'] );
|
2079 |
+
$day_or_hour = trim( $_POST['day_or_hour'] );
|
2080 |
+
$is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
|
2081 |
+
$default_value = 0 ;
|
2082 |
+
|
2083 |
+
$query = "INSERT INTO `".$wpdb->prefix."ac_email_templates_lite`
|
2084 |
+
(subject, body, frequency, day_or_hour, template_name, is_wc_template, default_template, wc_email_header )
|
2085 |
+
VALUES ( %s, %s, %d, %s, %s, %s, %d, %s )";
|
2086 |
+
|
2087 |
+
$insert_template_successfuly = $wpdb->query( $wpdb->prepare( $query,
|
2088 |
+
$woocommerce_ac_email_subject,
|
2089 |
+
$woocommerce_ac_email_body,
|
2090 |
+
$email_frequency,
|
2091 |
+
$day_or_hour,
|
2092 |
+
$woocommerce_ac_template_name,
|
2093 |
+
$is_wc_template,
|
2094 |
+
$default_value,
|
2095 |
+
$woocommerce_ac_email_header )
|
2096 |
+
);
|
2097 |
+
}
|
2098 |
+
|
2099 |
+
if ( isset( $_POST['ac_settings_frm'] ) && 'update' == $_POST['ac_settings_frm'] ) {
|
2100 |
+
|
2101 |
+
$updated_is_active = '0';
|
2102 |
+
|
2103 |
+
$email_frequency = trim( $_POST['email_frequency'] );
|
2104 |
+
$day_or_hour = trim( $_POST['day_or_hour'] );
|
2105 |
+
$is_wc_template = ( empty( $_POST['is_wc_template'] ) ) ? '0' : '1';
|
2106 |
+
|
2107 |
+
$woocommerce_ac_email_subject = trim( htmlspecialchars( $_POST['woocommerce_ac_email_subject'] ), ENT_QUOTES );
|
2108 |
+
$woocommerce_ac_email_body = trim( $_POST['woocommerce_ac_email_body'] );
|
2109 |
+
$woocommerce_ac_template_name = trim( $_POST['woocommerce_ac_template_name'] );
|
2110 |
+
$woocommerce_ac_email_header = stripslashes( trim( htmlspecialchars( $_POST['wcal_wc_email_header'] ), ENT_QUOTES ) );
|
2111 |
+
$id = trim( $_POST['id'] );
|
2112 |
+
|
2113 |
+
$check_query = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite`
|
2114 |
+
WHERE id = %d ";
|
2115 |
+
$check_results = $wpdb->get_results( $wpdb->prepare( $check_query, $id ) );
|
2116 |
+
$default_value = '';
|
2117 |
+
|
2118 |
+
if ( count( $check_results ) > 0 ) {
|
2119 |
+
if ( isset( $check_results[0]->default_template ) && $check_results[0]->default_template == '1' ) {
|
2120 |
+
$default_value = '1';
|
2121 |
+
}
|
2122 |
+
}
|
2123 |
+
|
2124 |
+
$query_update_latest = "UPDATE `".$wpdb->prefix."ac_email_templates_lite`
|
2125 |
+
SET
|
2126 |
+
subject = %s,
|
2127 |
+
body = %s,
|
2128 |
+
frequency = %d,
|
2129 |
+
day_or_hour = %s,
|
2130 |
+
template_name = %s,
|
2131 |
+
is_wc_template = %s,
|
2132 |
+
default_template = %d,
|
2133 |
+
wc_email_header = %s
|
2134 |
+
WHERE id = %d ";
|
2135 |
+
|
2136 |
+
$update_template_successfuly = $wpdb->query( $wpdb->prepare( $query_update_latest,
|
2137 |
+
$woocommerce_ac_email_subject,
|
2138 |
+
$woocommerce_ac_email_body,
|
2139 |
+
$email_frequency,
|
2140 |
+
$day_or_hour,
|
2141 |
+
$woocommerce_ac_template_name,
|
2142 |
+
$is_wc_template,
|
2143 |
+
$default_value,
|
2144 |
+
$woocommerce_ac_email_header,
|
2145 |
+
$id )
|
2146 |
+
);
|
2147 |
+
|
2148 |
+
}
|
2149 |
+
|
2150 |
+
if ( 'emailtemplates' == $action && 'removetemplate' == $mode ) {
|
2151 |
+
$id_remove = $_GET['id'];
|
2152 |
+
$query_remove = "DELETE FROM `".$wpdb->prefix."ac_email_templates_lite` WHERE id= %d ";
|
2153 |
+
$wpdb->query( $wpdb->prepare( $query_remove, $id_remove ) );
|
2154 |
+
}
|
2155 |
+
|
2156 |
+
if ( 'emailtemplates' == $action && 'activate_template' == $mode ) {
|
2157 |
+
$template_id = $_GET['id'];
|
2158 |
+
$current_template_status = $_GET['active_state'];
|
2159 |
+
|
2160 |
+
if ( "1" == $current_template_status ) {
|
2161 |
+
$active = "0";
|
2162 |
+
} else {
|
2163 |
+
$active = "1";
|
2164 |
+
|
2165 |
+
$query_update = "SELECT * FROM `".$wpdb->prefix."ac_email_templates_lite` WHERE id ='" . $template_id . "'";
|
2166 |
+
$get_selected_template_result = $wpdb->get_results( $query_update );
|
2167 |
+
|
2168 |
+
$email_frequncy = $get_selected_template_result[0]->frequency;
|
2169 |
+
$email_day_or_hour = $get_selected_template_result[0]->day_or_hour;
|
2170 |
+
|
2171 |
+
$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 . "' ";
|
2172 |
+
$wcap_updated = $wpdb->query( $query_update );
|
2173 |
+
}
|
2174 |
+
|
2175 |
+
$query_update = "UPDATE `" . $wpdb->prefix . "ac_email_templates_lite`
|
2176 |
+
SET
|
2177 |
+
is_active = '" . $active . "'
|
2178 |
+
WHERE id = '" . $template_id . "' ";
|
2179 |
+
$wpdb->query( $query_update );
|
2180 |
+
|
2181 |
+
wp_safe_redirect( admin_url( '/admin.php?page=woocommerce_ac_page&action=emailtemplates' ) );
|
2182 |
+
}
|
2183 |
+
|
2184 |
+
if ( isset( $_POST['ac_settings_frm'] ) && 'save' == $_POST['ac_settings_frm'] && ( isset( $insert_template_successfuly ) && $insert_template_successfuly != '' ) ) { ?>
|
2185 |
+
<div id="message" class="updated fade">
|
2186 |
+
<p>
|
2187 |
+
<strong>
|
2188 |
+
<?php _e( 'The Email Template has been successfully added. In order to start sending this email to your customers, please activate it.', 'woocommerce-abandoned-cart' ); ?>
|
2189 |
+
</strong>
|
2190 |
+
</p>
|
2191 |
+
</div>
|
2192 |
+
<?php } else if ( isset( $_POST['ac_settings_frm'] ) && 'save' == $_POST['ac_settings_frm'] && ( isset( $insert_template_successfuly ) && '' == $insert_template_successfuly ) ) {
|
2193 |
+
?>
|
2194 |
+
<div id="message" class="error fade">
|
2195 |
+
<p>
|
2196 |
+
<strong>
|
2197 |
+
<?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-abandoned-cart' ); ?>
|
2198 |
+
</strong>
|
2199 |
+
</p>
|
2200 |
+
</div>
|
2201 |
+
<?php
|
2202 |
+
}
|
2203 |
+
|
2204 |
+
if ( isset( $_POST['ac_settings_frm'] ) && 'update' == $_POST['ac_settings_frm'] && isset( $update_template_successfuly ) && $update_template_successfuly !== false ) { ?>
|
2205 |
+
<div id="message" class="updated fade">
|
2206 |
+
<p>
|
2207 |
+
<strong>
|
2208 |
+
<?php _e( 'The Email Template has been successfully updated.', 'woocommerce-abandoned-cart' ); ?>
|
2209 |
+
</strong>
|
2210 |
+
</p>
|
2211 |
+
</div>
|
2212 |
+
<?php } else if ( isset( $_POST['ac_settings_frm'] ) && $_POST['ac_settings_frm'] == 'update' && isset( $update_template_successfuly) && $update_template_successfuly === false ){
|
2213 |
+
?>
|
2214 |
+
<div id="message" class="error fade">
|
2215 |
+
<p>
|
2216 |
+
<strong>
|
2217 |
+
<?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-abandoned-cart' ); ?>
|
2218 |
+
</strong>
|
2219 |
+
</p>
|
2220 |
+
</div>
|
2221 |
+
<?php
|
2222 |
+
}
|
2223 |
+
?>
|
2224 |
+
<div class="tablenav">
|
2225 |
+
<p style="float:left;">
|
2226 |
+
<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-abandoned-cart' ); ?>
|
2227 |
+
</a>
|
2228 |
+
</p>
|
2229 |
+
|
2230 |
+
<?php
|
2231 |
+
/* From here you can do whatever you want with the data from the $result link. */
|
2232 |
+
include_once('includes/classes/class-wcal-templates-table.php');
|
2233 |
+
$wcal_template_list = new WCAL_Templates_Table();
|
2234 |
+
$wcal_template_list->wcal_templates_prepare_items();
|
2235 |
+
?>
|
2236 |
+
<div class="wrap">
|
2237 |
+
<form id="wcal-abandoned-templates" method="get" >
|
2238 |
+
<input type="hidden" name="page" value="woocommerce_ac_page" />
|
2239 |
+
<input type="hidden" name="action" value="emailtemplates" />
|
2240 |
+
<?php $wcal_template_list->display(); ?>
|
2241 |
+
</form>
|
2242 |
+
</div>
|
2243 |
+
</div>
|
2244 |
+
<?php
|
2245 |
+
} elseif ( 'stats' == $action || '' == $action ) {
|
2246 |
+
?>
|
2247 |
+
<p>
|
2248 |
+
<script language='javascript'>
|
2249 |
+
jQuery( document ).ready( function() {
|
2250 |
+
jQuery( '#duration_select' ).change( function() {
|
2251 |
+
var group_name = jQuery( '#duration_select' ).val();
|
2252 |
+
var today = new Date();
|
2253 |
+
var start_date = "";
|
2254 |
+
var end_date = "";
|
2255 |
+
if ( group_name == "yesterday" ) {
|
2256 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 1 );
|
2257 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 1 );
|
2258 |
+
} else if ( group_name == "today") {
|
2259 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2260 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2261 |
+
} else if ( group_name == "last_seven" ) {
|
2262 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 7 );
|
2263 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2264 |
+
} else if ( group_name == "last_fifteen" ) {
|
2265 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 15 );
|
2266 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2267 |
+
} else if ( group_name == "last_thirty" ) {
|
2268 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 30 );
|
2269 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2270 |
+
} else if ( group_name == "last_ninety" ) {
|
2271 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 90 );
|
2272 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2273 |
+
} else if ( group_name == "last_year_days" ) {
|
2274 |
+
start_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() - 365 );
|
2275 |
+
end_date = new Date( today.getFullYear(), today.getMonth(), today.getDate() );
|
2276 |
+
}
|
2277 |
+
|
2278 |
+
var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
2279 |
+
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
2280 |
+
|
2281 |
+
var start_date_value = start_date.getDate() + " " + monthNames[start_date.getMonth()] + " " + start_date.getFullYear();
|
2282 |
+
var end_date_value = end_date.getDate() + " " + monthNames[end_date.getMonth()] + " " + end_date.getFullYear();
|
2283 |
+
|
2284 |
+
jQuery( '#start_date' ).val( start_date_value );
|
2285 |
+
jQuery( '#end_date' ).val( end_date_value );
|
2286 |
+
} );
|
2287 |
+
});
|
2288 |
+
</script>
|
2289 |
+
<?php
|
2290 |
+
|
2291 |
+
if ( isset( $_POST['duration_select'] ) ){
|
2292 |
+
$duration_range = $_POST['duration_select'];
|
2293 |
+
} else {
|
2294 |
+
$duration_range = "";
|
2295 |
+
}
|
2296 |
+
if ( '' == $duration_range ) {
|
2297 |
+
if ( isset( $_GET['duration_select'] ) ){
|
2298 |
+
$duration_range = $_GET['duration_select'];
|
2299 |
+
}
|
2300 |
+
}
|
2301 |
+
if ( '' == $duration_range ) $duration_range = "last_seven";
|
2302 |
+
|
2303 |
+
_e( 'The Report below shows how many Abandoned Carts we were able to recover for you by sending automatic emails to encourage shoppers.', 'woocommerce-abandoned-cart');
|
2304 |
+
?>
|
2305 |
+
<div id="recovered_stats" class="postbox" style="display:block">
|
2306 |
+
<div class="inside">
|
2307 |
+
<form method="post" action="admin.php?page=woocommerce_ac_page&action=stats" id="ac_stats">
|
2308 |
+
<select id="duration_select" name="duration_select" >
|
2309 |
+
<?php
|
2310 |
+
foreach ( $this->duration_range_select as $key => $value ) {
|
2311 |
+
$sel = "";
|
2312 |
+
if ( $key == $duration_range ) {
|
2313 |
+
$sel = " selected ";
|
2314 |
+
}
|
2315 |
+
echo"<option value='$key' $sel> $value </option>";
|
2316 |
+
}
|
2317 |
+
$date_sett = $this->start_end_dates[ $duration_range ];
|
2318 |
+
?>
|
2319 |
+
</select>
|
2320 |
+
<script type="text/javascript">
|
2321 |
+
jQuery( document ).ready( function()
|
2322 |
+
{
|
2323 |
+
var formats = ["d.m.y", "d M yy","MM d, yy"];
|
2324 |
+
jQuery( "#start_date" ).datepicker( { dateFormat: formats[1] } );
|
2325 |
+
});
|
2326 |
+
|
2327 |
+
jQuery( document ).ready( function()
|
2328 |
+
{
|
2329 |
+
var formats = ["d.m.y", "d M yy","MM d, yy"];
|
2330 |
+
jQuery( "#end_date" ).datepicker( { dateFormat: formats[1] } );
|
2331 |
+
});
|
2332 |
+
</script>
|
2333 |
+
<?php
|
2334 |
+
include_once('includes/classes/class-wcal-recover-orders-table.php');
|
2335 |
+
$wcal_recover_orders_list = new WCAL_Recover_Orders_Table();
|
2336 |
+
$wcal_recover_orders_list->wcal_recovered_orders_prepare_items();
|
2337 |
+
|
2338 |
+
if ( isset( $_POST['start_date'] ) ) $start_date_range = $_POST['start_date'];
|
2339 |
+
else $start_date_range = "";
|
2340 |
+
|
2341 |
+
if ( $start_date_range == "" ) {
|
2342 |
+
$start_date_range = $date_sett['start_date'];
|
2343 |
+
}
|
2344 |
+
|
2345 |
+
if ( isset( $_POST['end_date'] ) ) $end_date_range = $_POST['end_date'];
|
2346 |
+
else $end_date_range = "";
|
2347 |
+
|
2348 |
+
if ( $end_date_range == "" ) {
|
2349 |
+
$end_date_range = $date_sett['end_date'];
|
2350 |
+
}
|
2351 |
+
?>
|
2352 |
+
<label class="start_label" for="start_day"> <?php _e( 'Start Date:', 'woocommerce-abandoned-cart' ); ?> </label>
|
2353 |
+
<input type="text" id="start_date" name="start_date" readonly="readonly" value="<?php echo $start_date_range; ?>"/>
|
2354 |
+
<label class="end_label" for="end_day"> <?php _e( 'End Date:', 'woocommerce-abandoned-cart' ); ?> </label>
|
2355 |
+
<input type="text" id="end_date" name="end_date" readonly="readonly" value="<?php echo $end_date_range; ?>"/>
|
2356 |
+
<input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e( 'Go', 'woocommerce-abandoned-cart' ); ?>" />
|
2357 |
+
</form>
|
2358 |
+
</div>
|
2359 |
+
</div>
|
2360 |
+
<div id="recovered_stats" class="postbox" style="display:block">
|
2361 |
+
<div class="inside" >
|
2362 |
+
<?php
|
2363 |
+
$count = $wcal_recover_orders_list->total_abandoned_cart_count;
|
2364 |
+
$total_of_all_order = $wcal_recover_orders_list->total_order_amount;
|
2365 |
+
$recovered_item = $wcal_recover_orders_list->recovered_item;
|
2366 |
+
$recovered_total = wc_price( $wcal_recover_orders_list->total_recover_amount );
|
2367 |
+
?>
|
2368 |
+
<p style="font-size: 15px;">
|
2369 |
+
<?php
|
2370 |
+
printf( __( 'During the selected range <strong>%d</strong> carts totaling <strong>%s</strong> were abandoned. We were able to recover <strong>%d</strong> of them, which led to an extra <strong>%s</strong>', 'woocommerce-abandoned-cart' ), $count, $total_of_all_order, $recovered_item, $recovered_total );
|
2371 |
+
?>
|
2372 |
+
</p>
|
2373 |
+
</div>
|
2374 |
+
</div>
|
2375 |
+
<div class="wrap">
|
2376 |
+
<form id="wcal-recover-orders" method="get" >
|
2377 |
+
<input type="hidden" name="page" value="woocommerce_ac_page" />
|
2378 |
+
<input type="hidden" name="action" value="stats" />
|
2379 |
+
<?php $wcal_recover_orders_list->display(); ?>
|
2380 |
+
</form>
|
2381 |
+
</div>
|
2382 |
+
<?php
|
2383 |
+
} elseif ( 'orderdetails' == $action ) {
|
2384 |
+
global $woocommerce;
|
2385 |
+
$ac_order_id = $_GET['id'];
|
2386 |
+
?>
|
2387 |
+
<p> </p>
|
2388 |
+
<div id="ac_order_details" class="postbox" style="display:block">
|
2389 |
+
<h3 class="details-title"> <p> <?php printf( __( 'Abandoned Order #%s Details', 'woocommerce-abandoned-cart' ), $ac_order_id); ?> </p> </h3>
|
2390 |
+
<div class="inside">
|
2391 |
+
<table cellpadding="0" cellspacing="0" class="wp-list-table widefat fixed posts">
|
2392 |
+
<tr>
|
2393 |
+
<th> <?php _e( 'Item', 'woocommerce-abandoned-cart' ); ?> </th>
|
2394 |
+
<th> <?php _e( 'Name', 'woocommerce-abandoned-cart' ); ?> </th>
|
2395 |
+
<th> <?php _e( 'Quantity', 'woocommerce-abandoned-cart' ); ?> </th>
|
2396 |
+
<th> <?php _e( 'Line Subtotal', 'woocommerce-abandoned-cart' ); ?> </th>
|
2397 |
+
<th> <?php _e( 'Line Total', 'woocommerce-abandoned-cart' ); ?> </th>
|
2398 |
+
</tr>
|
2399 |
+
<?php
|
2400 |
+
$query = "SELECT * FROM `".$wpdb->prefix."ac_abandoned_cart_history_lite` WHERE id = %d ";
|
2401 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query,$_GET['id'] ) );
|
2402 |
+
|
2403 |
+
$shipping_charges = 0;
|
2404 |
+
$currency_symbol = get_woocommerce_currency_symbol();
|
2405 |
+
$number_decimal = wc_get_price_decimals();
|
2406 |
+
if ( $results[0]->user_type == "GUEST" && "0" != $results[0]->user_id ) {
|
2407 |
+
$query_guest = "SELECT * FROM `".$wpdb->prefix."ac_guest_abandoned_cart_history_lite` WHERE id = %d";
|
2408 |
+
$results_guest = $wpdb->get_results( $wpdb->prepare( $query_guest, $results[0]->user_id ) );
|
2409 |
+
$user_email = $user_first_name = $user_last_name = $user_billing_postcode = $user_shipping_postcode = '';
|
2410 |
+
$shipping_charges = '';
|
2411 |
+
if ( count( $results_guest ) > 0 ) {
|
2412 |
+
$user_email = $results_guest[0]->email_id;
|
2413 |
+
$user_first_name = $results_guest[0]->billing_first_name;
|
2414 |
+
$user_last_name = $results_guest[0]->billing_last_name;
|
2415 |
+
$user_billing_postcode = $results_guest[0]->billing_zipcode;
|
2416 |
+
$user_shipping_postcode = $results_guest[0]->shipping_zipcode;
|
2417 |
+
$shipping_charges = $results_guest[0]->shipping_charges;
|
2418 |
+
}
|
2419 |
+
$user_billing_company = $user_billing_address_1 = $user_billing_address_2 = $user_billing_city = $user_billing_state = $user_billing_country = $user_billing_phone = "";
|
2420 |
+
$user_shipping_company = $user_shipping_address_1 = $user_shipping_address_2 = $user_shipping_city = $user_shipping_state = $user_shipping_country = "";
|
2421 |
+
} else if ( $results[0]->user_type == "GUEST" && $results[0]->user_id == "0" ) {
|
2422 |
+
$user_email = '';
|
2423 |
+
$user_first_name = "Visitor";
|
2424 |
+
$user_last_name = "";
|
2425 |
+
$user_billing_postcode = '';
|
2426 |
+
$user_shipping_postcode = '';
|
2427 |
+
$shipping_charges = '';
|
2428 |
+
$user_billing_phone = '';
|
2429 |
+
$user_billing_company = $user_billing_address_1 = $user_billing_address_2 = $user_billing_city = $user_billing_state = $user_billing_country = "";
|
2430 |
+
$user_shipping_company = $user_shipping_address_1 = $user_shipping_address_2 = $user_shipping_city = $user_shipping_state = $user_shipping_country = "";
|
2431 |
+
} else {
|
2432 |
+
$user_id = $results[0]->user_id;
|
2433 |
+
if ( isset( $results[0]->user_login ) ) {
|
2434 |
+
$user_login = $results[0]->user_login;
|
2435 |
+
}
|
2436 |
+
$user_email = get_user_meta( $results[0]->user_id, 'billing_email', true );
|
2437 |
+
if ( '' == $user_email ) {
|
2438 |
+
$user_data = get_userdata( $results[0]->user_id );
|
2439 |
+
if ( isset( $user_data->user_email ) ) {
|
2440 |
+
$user_email = $user_data->user_email;
|
2441 |
+
} else {
|
2442 |
+
$user_email = '';
|
2443 |
+
}
|
2444 |
+
}
|
2445 |
+
|
2446 |
+
$user_first_name = "";
|
2447 |
+
$user_first_name_temp = get_user_meta( $user_id, 'billing_first_name', true );
|
2448 |
+
if ( isset( $user_first_name_temp ) && '' == $user_first_name_temp ) {
|
2449 |
+
$user_data = get_userdata( $user_id );
|
2450 |
+
if ( isset( $user_data->first_name ) ) {
|
2451 |
+
$user_first_name = $user_data->first_name;
|
2452 |
+
} else {
|
2453 |
+
$user_first_name = '';
|
2454 |
+
}
|
2455 |
+
} else {
|
2456 |
+
$user_first_name = $user_first_name_temp;
|
2457 |
+
}
|
2458 |
+
$user_last_name = "";
|
2459 |
+
$user_last_name_temp = get_user_meta( $user_id, 'billing_last_name', true );
|
2460 |
+
if ( isset( $user_last_name_temp ) && "" == $user_last_name_temp ) {
|
2461 |
+
$user_data = get_userdata( $user_id );
|
2462 |
+
if ( isset( $user_data->last_name ) ) {
|
2463 |
+
$user_last_name = $user_data->last_name;
|
2464 |
+
} else {
|
2465 |
+
$user_last_name = '';
|
2466 |
+
}
|
2467 |
+
} else {
|
2468 |
+
$user_last_name = $user_last_name_temp;
|
2469 |
+
}
|
2470 |
+
$user_billing_first_name = get_user_meta( $results[0]->user_id, 'billing_first_name' );
|
2471 |
+
$user_billing_last_name = get_user_meta( $results[0]->user_id, 'billing_last_name' );
|
2472 |
+
|
2473 |
+
$user_billing_details = wcal_common::wcal_get_billing_details( $results[0]->user_id );
|
2474 |
+
|
2475 |
+
$user_billing_company = $user_billing_details[ 'billing_company' ];
|
2476 |
+
$user_billing_address_1 = $user_billing_details[ 'billing_address_1' ];
|
2477 |
+
$user_billing_address_2 = $user_billing_details[ 'billing_address_2' ];
|
2478 |
+
$user_billing_city = $user_billing_details[ 'billing_city' ];
|
2479 |
+
$user_billing_postcode = $user_billing_details[ 'billing_postcode' ] ;
|
2480 |
+
$user_billing_country = $user_billing_details[ 'billing_country' ];
|
2481 |
+
$user_billing_state = $user_billing_details[ 'billing_state' ];
|
2482 |
+
|
2483 |
+
$user_billing_phone_temp = get_user_meta( $results[0]->user_id, 'billing_phone' );
|
2484 |
+
if ( isset( $user_billing_phone_temp[0] ) ) {
|
2485 |
+
$user_billing_phone = $user_billing_phone_temp[0];
|
2486 |
+
} else {
|
2487 |
+
$user_billing_phone = "";
|
2488 |
+
}
|
2489 |
+
$user_shipping_first_name = get_user_meta( $results[0]->user_id, 'shipping_first_name' );
|
2490 |
+
$user_shipping_last_name = get_user_meta( $results[0]->user_id, 'shipping_last_name' );
|
2491 |
+
$user_shipping_company_temp = get_user_meta( $results[0]->user_id, 'shipping_company' );
|
2492 |
+
if ( isset( $user_shipping_company_temp[0] ) ) {
|
2493 |
+
$user_shipping_company = $user_shipping_company_temp[0];
|
2494 |
+
} else {
|
2495 |
+
$user_shipping_company = "";
|
2496 |
+
}
|
2497 |
+
$user_shipping_address_1_temp = get_user_meta( $results[0]->user_id, 'shipping_address_1' );
|
2498 |
+
if ( isset( $user_shipping_address_1_temp[0] ) ) {
|
2499 |
+
$user_shipping_address_1 = $user_shipping_address_1_temp[0];
|
2500 |
+
} else {
|
2501 |
+
$user_shipping_address_1 = "";
|
2502 |
+
}
|
2503 |
+
$user_shipping_address_2_temp = get_user_meta( $results[0]->user_id, 'shipping_address_2' );
|
2504 |
+
if ( isset( $user_shipping_address_2_temp[0] ) ) {
|
2505 |
+
$user_shipping_address_2 = $user_shipping_address_2_temp[0];
|
2506 |
+
} else {
|
2507 |
+
$user_shipping_address_2 = "";
|
2508 |
+
}
|
2509 |
+
$user_shipping_city_temp = get_user_meta( $results[0]->user_id, 'shipping_city' );
|
2510 |
+
if ( isset( $user_shipping_city_temp[0] ) ) {
|
2511 |
+
$user_shipping_city = $user_shipping_city_temp[0];
|
2512 |
+
} else {
|
2513 |
+
$user_shipping_city = "";
|
2514 |
+
}
|
2515 |
+
$user_shipping_postcode_temp = get_user_meta( $results[0]->user_id, 'shipping_postcode' );
|
2516 |
+
if ( isset( $user_shipping_postcode_temp[0] ) ) {
|
2517 |
+
$user_shipping_postcode = $user_shipping_postcode_temp[0];
|
2518 |
+
} else {
|
2519 |
+
$user_shipping_postcode = "";
|
2520 |
+
}
|
2521 |
+
$user_shipping_country_temp = get_user_meta( $results[0]->user_id, 'shipping_country' );
|
2522 |
+
$user_shipping_country = "";
|
2523 |
+
if ( isset( $user_shipping_country_temp[0] ) ) {
|
2524 |
+
$user_shipping_country = $user_shipping_country_temp[0];
|
2525 |
+
if ( isset( $woocommerce->countries->countries[ $user_shipping_country ] ) ) {
|
2526 |
+
$user_shipping_country = $woocommerce->countries->countries[ $user_shipping_country ];
|
2527 |
+
}else {
|
2528 |
+
$user_shipping_country = "";
|
2529 |
+
}
|
2530 |
+
}
|
2531 |
+
$user_shipping_state_temp = get_user_meta( $results[0]->user_id, 'shipping_state' );
|
2532 |
+
$user_shipping_state = "";
|
2533 |
+
if ( isset( $user_shipping_state_temp[0] ) ) {
|
2534 |
+
$user_shipping_state = $user_shipping_state_temp[0];
|
2535 |
+
if ( isset( $woocommerce->countries->states[ $user_shipping_country_temp[0] ][ $user_shipping_state ] ) ) {
|
2536 |
+
# code...
|
2537 |
+
$user_shipping_state = $woocommerce->countries->states[ $user_shipping_country_temp[0] ][ $user_shipping_state ];
|
2538 |
+
}
|
2539 |
+
}
|
2540 |
+
}
|
2541 |
+
|
2542 |
+
$cart_details = array();
|
2543 |
+
$cart_info = json_decode( $results[0]->abandoned_cart_info );
|
2544 |
+
$cart_details = (array) $cart_info->cart;
|
2545 |
+
$item_subtotal = $item_total = 0;
|
2546 |
+
|
2547 |
+
if ( is_array ( $cart_details ) && count( $cart_details ) > 0 ) {
|
2548 |
+
foreach ( $cart_details as $k => $v ) {
|
2549 |
+
|
2550 |
+
$item_details = wcal_common::wcal_get_cart_details( $v );
|
2551 |
+
|
2552 |
+
$product_id = $v->product_id;
|
2553 |
+
$product = wc_get_product( $product_id );
|
2554 |
+
if( ! $product ) { // product not found, exclude it from the cart display
|
2555 |
+
continue;
|
2556 |
+
}
|
2557 |
+
$prod_image = $product->get_image(array(200, 200));
|
2558 |
+
$product_page_url = get_permalink( $product_id );
|
2559 |
+
$product_name = $item_details[ 'product_name' ];
|
2560 |
+
$item_subtotal = $item_details[ 'item_total_formatted' ];
|
2561 |
+
$item_total = $item_details[ 'item_total' ];
|
2562 |
+
$quantity_total = $item_details[ 'qty' ];
|
2563 |
+
|
2564 |
+
$qty_item_text = 'item';
|
2565 |
+
if ( $quantity_total > 1 ) {
|
2566 |
+
$qty_item_text = 'items';
|
2567 |
+
}
|
2568 |
+
?>
|
2569 |
+
<tr>
|
2570 |
+
<td> <?php echo $prod_image; ?></td>
|
2571 |
+
<td> <?php echo '<a href="' . $product_page_url . '"> ' . $product_name . ' </a>'; ?> </td>
|
2572 |
+
<td> <?php echo $quantity_total; ?></td>
|
2573 |
+
<td> <?php echo $item_subtotal; ?></td>
|
2574 |
+
<td> <?php echo $item_total; ?></td>
|
2575 |
+
</tr>
|
2576 |
+
<?php
|
2577 |
+
$item_subtotal = $item_total = 0;
|
2578 |
+
}
|
2579 |
+
}
|
2580 |
+
?>
|
2581 |
+
</table>
|
2582 |
+
</div>
|
2583 |
+
</div>
|
2584 |
+
<div id="ac_order_customer_details" class="postbox" style="display:block">
|
2585 |
+
<h3 class="details-title"> <p> <?php _e( 'Customer Details' , 'woocommerce-abandoned-cart' ); ?> </p> </h3>
|
2586 |
+
<div class="inside" style="height: 300px;" >
|
2587 |
+
<div id="order_data" class="panel">
|
2588 |
+
<div style="width:50%;float:left">
|
2589 |
+
<h3> <p> <?php _e( 'Billing Details' , 'woocommerce-abandoned-cart' ); ?> </p> </h3>
|
2590 |
+
<p> <strong> <?php _e( 'Name:' , 'woocommerce-abandoned-cart' ); ?> </strong>
|
2591 |
+
<?php echo $user_first_name." ".$user_last_name;?>
|
2592 |
+
</p>
|
2593 |
+
<p> <strong> <?php _e( 'Address:' , 'woocommerce-abandoned-cart' ); ?> </strong>
|
2594 |
+
<?php echo $user_billing_company."</br>".
|
2595 |
+
$user_billing_address_1."</br>".
|
2596 |
+
$user_billing_address_2."</br>".
|
2597 |
+
$user_billing_city."</br>".
|
2598 |
+
$user_billing_postcode."</br>".
|
2599 |
+
$user_billing_state."</br>".
|
2600 |
+
$user_billing_country."</br>";
|
2601 |
+
?>
|
2602 |
+
</p>
|
2603 |
+
<p> <strong> <?php _e( 'Email:', 'woocommerce-abandoned-cart' ); ?> </strong>
|
2604 |
+
<?php $user_mail_to = "mailto:".$user_email; ?>
|
2605 |
+
<a href=<?php echo $user_mail_to;?>><?php echo $user_email;?> </a>
|
2606 |
+
</p>
|
2607 |
+
<p> <strong> <?php _e( 'Phone:', 'woocommerce-abandoned-cart' ); ?> </strong>
|
2608 |
+
<?php echo $user_billing_phone;?>
|
2609 |
+
</p>
|
2610 |
+
</div>
|
2611 |
+
<div style="width:50%;float:right">
|
2612 |
+
<h3> <p> <?php _e( 'Shipping Details', 'woocommerce-abandoned-cart' ); ?> </p> </h3>
|
2613 |
+
<p> <strong> <?php _e( 'Address:', 'woocommerce-abandoned-cart' ); ?> </strong>
|
2614 |
+
<?php
|
2615 |
+
if ( $user_shipping_company == '' &&
|
2616 |
+
$user_shipping_address_1 == '' &&
|
2617 |
+
$user_shipping_address_2 == '' &&
|
2618 |
+
$user_shipping_city == '' &&
|
2619 |
+
$user_shipping_postcode == '' &&
|
2620 |
+
$user_shipping_state == '' &&
|
2621 |
+
$user_shipping_country == '') {
|
2622 |
+
echo "Shipping Address same as Billing Address";
|
2623 |
+
} else { ?>
|
2624 |
+
<?php echo $user_shipping_company."</br>".
|
2625 |
+
$user_shipping_address_1."</br>".
|
2626 |
+
$user_shipping_address_2."</br>".
|
2627 |
+
$user_shipping_city."</br>".
|
2628 |
+
$user_shipping_postcode."</br>".
|
2629 |
+
$user_shipping_state."</br>".
|
2630 |
+
$user_shipping_country."</br>";
|
2631 |
+
?>
|
2632 |
+
<br><br>
|
2633 |
+
<strong><?php _e( 'Shipping Charges', 'woocommerce-abandoned-lite' ); ?>: </strong>
|
2634 |
+
<?php if ( $shipping_charges != 0 ) echo $currency_symbol . $shipping_charges;?>
|
2635 |
+
</p>
|
2636 |
+
<?php }?>
|
2637 |
+
</div>
|
2638 |
+
</div>
|
2639 |
+
</div>
|
2640 |
+
</div>
|
2641 |
+
<?php } elseif ( $action == 'report' ) {
|
2642 |
+
include_once('includes/classes/class-wcal-product-report-table.php');
|
2643 |
+
$wcal_product_report_list = new WCAL_Product_Report_Table();
|
2644 |
+
$wcal_product_report_list->wcal_product_report_prepare_items();
|
2645 |
+
?>
|
2646 |
+
<div class="wrap">
|
2647 |
+
<form id="wcal-sent-emails" method="get" >
|
2648 |
+
<input type="hidden" name="page" value="woocommerce_ac_page" />
|
2649 |
+
<input type="hidden" name="action" value="report" />
|
2650 |
+
<?php $wcal_product_report_list->display(); ?>
|
2651 |
+
</form>
|
2652 |
+
</div>
|
2653 |
+
<?php }
|
2654 |
+
}
|
2655 |
+
echo( "</table>" );
|
2656 |
+
|
2657 |
+
if ( isset( $_GET['action'] ) ) {
|
2658 |
+
$action = $_GET['action'];
|
2659 |
+
}
|
2660 |
+
if ( isset( $_GET['mode'] ) ) {
|
2661 |
+
$mode = $_GET['mode'];
|
2662 |
+
}
|
2663 |
+
if ( 'emailtemplates' == $action && ( 'addnewtemplate' == $mode || 'edittemplate' == $mode ) ) {
|
2664 |
+
if ( 'edittemplate' == $mode ) {
|
2665 |
+
$results = array();
|
2666 |
+
if ( isset( $_GET['id'] ) ) {
|
2667 |
+
$edit_id = $_GET['id'];
|
2668 |
+
$query = "SELECT wpet . * FROM `".$wpdb->prefix."ac_email_templates_lite` AS wpet WHERE id = %d ";
|
2669 |
+
$results = $wpdb->get_results( $wpdb->prepare( $query, $edit_id ) );
|
2670 |
+
}
|
2671 |
+
}
|
2672 |
+
$active_post = ( empty( $_POST['is_active'] ) ) ? '0' : '1';
|
2673 |
+
?>
|
2674 |
+
<div id="content">
|
2675 |
+
<form method="post" action="admin.php?page=woocommerce_ac_page&action=emailtemplates" id="ac_settings">
|
2676 |
+
<input type="hidden" name="mode" value="<?php echo $mode;?>" />
|
2677 |
+
<?php
|
2678 |
+
$id_by = "";
|
2679 |
+
if ( isset( $_GET['id'] ) ) {
|
2680 |
+
$id_by = $_GET['id'];
|
2681 |
+
}
|
2682 |
+
?>
|
2683 |
+
<input type="hidden" name="id" value="<?php echo $id_by ;?>" />
|
2684 |
+
<?php
|
2685 |
+
$button_mode = "save";
|
2686 |
+
$display_message = "Add Email Template";
|
2687 |
+
if ( 'edittemplate' == $mode ) {
|
2688 |
+
$button_mode = "update";
|
2689 |
+
$display_message = "Edit Email Template";
|
2690 |
+
}
|
2691 |
+
print'<input type="hidden" name="ac_settings_frm" value="'.$button_mode.'">';?>
|
2692 |
+
<div id="poststuff">
|
2693 |
+
<div> <!-- <div class="postbox" > -->
|
2694 |
+
<h3 class="hndle"><?php _e( $display_message, 'woocommerce-abandoned-cart' ); ?></h3>
|
2695 |
+
<div>
|
2696 |
+
<table class="form-table" id="addedit_template">
|
2697 |
+
<tr>
|
2698 |
+
<th>
|
2699 |
+
<label for="woocommerce_ac_template_name"><b><?php _e( 'Template Name:', 'woocommerce-abandoned-cart');?></b></label>
|
2700 |
+
</th>
|
2701 |
+
<td>
|
2702 |
+
<?php
|
2703 |
+
$template_name = "";
|
2704 |
+
if ( 'edittemplate' == $mode && count( $results ) > 0 && isset( $results[0]->template_name ) ) {
|
2705 |
+
$template_name = $results[0]->template_name;
|
2706 |
+
}
|
2707 |
+
print'<input type="text" name="woocommerce_ac_template_name" id="woocommerce_ac_template_name" class="regular-text" value="'.$template_name.'">';?>
|
2708 |
+
<img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter a template name for reference', 'woocommerce-abandoned-cart') ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" />
|
2709 |
+
</td>
|
2710 |
+
</tr>
|
2711 |
+
|
2712 |
+
<tr>
|
2713 |
+
<th>
|
2714 |
+
<label for="woocommerce_ac_email_subject"><b><?php _e( 'Subject:', 'woocommerce-abandoned-cart' ); ?></b></label>
|
2715 |
+
</th>
|
2716 |
+
<td>
|
2717 |
+
<?php
|
2718 |
+
$subject_edit = "";
|
2719 |
+
if ( 'edittemplate' == $mode && count( $results ) > 0 && isset( $results[0]->subject ) ) {
|
2720 |
+
$subject_edit= stripslashes ( $results[0]->subject );
|
2721 |
+
}
|
2722 |
+
print'<input type="text" name="woocommerce_ac_email_subject" id="woocommerce_ac_email_subject" class="regular-text" value="'.$subject_edit.'">';?>
|
2723 |
+
<img class="help_tip" width="16" height="16" data-tip='<?php _e('Enter the subject that should appear in the email sent', 'woocommerce-abandoned-cart') ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" />
|
2724 |
+
</td>
|
2725 |
+
</tr>
|
2726 |
+
|
2727 |
+
<tr>
|
2728 |
+
<th>
|
2729 |
+
<label for="woocommerce_ac_email_body"><b><?php _e( 'Email Body:', 'woocommerce-abandoned-cart' ); ?></b></label>
|
2730 |
+
</th>
|
2731 |
+
<td>
|
2732 |
+
<?php
|
2733 |
+
$initial_data = "";
|
2734 |
+
if ( 'edittemplate' == $mode && count( $results ) > 0 && isset( $results[0]->body ) ) {
|
2735 |
+
$initial_data = stripslashes( $results[0]->body );
|
2736 |
+
}
|
2737 |
+
|
2738 |
+
$initial_data = str_replace ( "My document title", "", $initial_data );
|
2739 |
+
wp_editor(
|
2740 |
+
$initial_data,
|
2741 |
+
'woocommerce_ac_email_body',
|
2742 |
+
array(
|
2743 |
+
'media_buttons' => true,
|
2744 |
+
'textarea_rows' => 15,
|
2745 |
+
'tabindex' => 4,
|
2746 |
+
'tinymce' => array(
|
2747 |
+
'theme_advanced_buttons1' => 'bold,italic,underline,|,bullist,numlist,blockquote,|,link,unlink,|,spellchecker,fullscreen,|,formatselect,styleselect'
|
2748 |
+
),
|
2749 |
+
)
|
2750 |
+
);
|
2751 |
+
|
2752 |
+
?>
|
2753 |
+
<?php echo stripslashes( get_option( 'woocommerce_ac_email_body' ) ); ?>
|
2754 |
+
<span class="description">
|
2755 |
+
<?php
|
2756 |
+
_e( 'Message to be sent in the reminder email.', 'woocommerce-abandoned-cart' );
|
2757 |
+
?>
|
2758 |
+
<img width="16" height="16" src="<?php echo plugins_url(); ?>/woocommerce-abandon-cart-pro/assets/images/information.png" onClick="wcal_show_help_tips()"/>
|
2759 |
+
</span>
|
2760 |
+
<span id="help_message" style="display:none">
|
2761 |
+
1. You can add customer & cart information in the template using this icon <img width="20" height="20" src="<?php echo plugins_url(); ?>/woocommerce-abandon-cart-pro/assets/images/ac_editor_icon.png" /> in top left of the editor.<br>
|
2762 |
+
2. The product information/cart contents table will be added in emails using the {{products.cart}} merge field.<br>
|
2763 |
+
3. Insert/Remove any of the new shortcodes that have been included for the default template.<br>
|
2764 |
+
4. Change the look and feel of the table by modifying the table style properties using CSS in "Text" mode. <br>
|
2765 |
+
5. Change the text color of the table rows by using the Toolbar of the editor. <br>
|
2766 |
+
|
2767 |
+
</span>
|
2768 |
+
</td>
|
2769 |
+
</tr>
|
2770 |
+
<script type="text/javascript">
|
2771 |
+
function wcal_show_help_tips() {
|
2772 |
+
if ( jQuery( '#help_message' ) . css( 'display' ) == 'none') {
|
2773 |
+
document.getElementById( "help_message" ).style.display = "block";
|
2774 |
+
}
|
2775 |
+
else {
|
2776 |
+
document.getElementById( "help_message" ) . style.display = "none";
|
2777 |
+
}
|
2778 |
+
}
|
2779 |
+
</script>
|
2780 |
+
|
2781 |
+
<tr>
|
2782 |
+
<th>
|
2783 |
+
<label for="is_wc_template"><b><?php _e( 'Use WooCommerce Template Style:', 'woocommerce-abandoned-cart' ); ?></b></label>
|
2784 |
+
</th>
|
2785 |
+
<td>
|
2786 |
+
<?php
|
2787 |
+
$is_wc_template = "";
|
2788 |
+
if ( 'edittemplate' == $mode && count( $results ) > 0 && isset( $results[0]->is_wc_template ) ) {
|
2789 |
+
$use_wc_template = $results[0]->is_wc_template;
|
2790 |
+
|
2791 |
+
if ( '1' == $use_wc_template ) {
|
2792 |
+
$is_wc_template = "checked";
|
2793 |
+
} else {
|
2794 |
+
$is_wc_template = "";
|
2795 |
+
}
|
2796 |
+
}
|
2797 |
+
print'<input type="checkbox" name="is_wc_template" id="is_wc_template" ' . $is_wc_template . '> </input>'; ?>
|
2798 |
+
<img class="help_tip" width="16" height="16" data-tip='<?php _e( 'Use WooCommerce default style template for abandoned cart reminder emails.', 'woocommerce' ) ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" /> <a target = '_blank' href= <?php echo wp_nonce_url( admin_url( '?wcal_preview_woocommerce_mail=true' ), 'woocommerce-abandoned-cart' ) ; ?> >
|
2799 |
+
Click here to preview </a>how the email template will look with WooCommerce Template Style enabled. Alternatively, if this is unchecked, the template will appear as <a target = '_blank' href=<?php echo wp_nonce_url( admin_url( '?wcal_preview_mail=true' ), 'woocommerce-abandoned-cart' ) ; ?>>shown here</a>. <br> <strong>Note: </strong>When this setting is enabled, then "Send From This Name:" & "Send From This Email Address:" will be overwritten with WooCommerce -> Settings -> Email -> Email Sender Options.
|
2800 |
+
</td>
|
2801 |
+
</tr>
|
2802 |
+
|
2803 |
+
<tr>
|
2804 |
+
<th>
|
2805 |
+
<label for="wcal_wc_email_header"><b><?php _e( 'Email Template Header Text: ', 'woocommerce-abandoned-cart' ); ?></b></label>
|
2806 |
+
</th>
|
2807 |
+
<td>
|
2808 |
+
|
2809 |
+
<?php
|
2810 |
+
|
2811 |
+
$wcal_wc_email_header = "";
|
2812 |
+
if ( 'edittemplate' == $mode && count( $results ) > 0 && isset( $results[0]->wc_email_header ) ) {
|
2813 |
+
$wcal_wc_email_header = $results[0]->wc_email_header;
|
2814 |
+
}
|
2815 |
+
if ( '' == $wcal_wc_email_header ) {
|
2816 |
+
$wcal_wc_email_header = "Abandoned cart reminder";
|
2817 |
+
}
|
2818 |
+
print'<input type="text" name="wcal_wc_email_header" id="wcal_wc_email_header" class="regular-text" value="' . $wcal_wc_email_header . '">'; ?>
|
2819 |
+
<img class="help_tip" width="16" height="16" data-tip='<?php _e( 'Enter the header which will appear in the abandoned WooCommerce email sent. This is only applicable when only used when "Use WooCommerce Template Style:" is checked.', 'woocommerce-abandoned-cart' ) ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" />
|
2820 |
+
</td>
|
2821 |
+
</tr>
|
2822 |
+
|
2823 |
+
<tr>
|
2824 |
+
<th>
|
2825 |
+
<label for="woocommerce_ac_email_frequency"><b><?php _e( 'Send this email:', 'woocommerce-abandoned-cart' ); ?></b></label>
|
2826 |
+
</th>
|
2827 |
+
<td>
|
2828 |
+
<select name="email_frequency" id="email_frequency">
|
2829 |
+
<?php
|
2830 |
+
$frequency_edit = "";
|
2831 |
+
if ( 'edittemplate' == $mode && count( $results ) > 0 && isset( $results[0]->frequency ) ) {
|
2832 |
+
$frequency_edit = $results[0]->frequency;
|
2833 |
+
}
|
2834 |
+
for ( $i = 1; $i < 4; $i++ ) {
|
2835 |
+
printf( "<option %s value='%s'>%s</option>\n",
|
2836 |
+
selected( $i, $frequency_edit, false ),
|
2837 |
+
esc_attr( $i ),
|
2838 |
+
$i
|
2839 |
+
);
|
2840 |
+
}
|
2841 |
+
?>
|
2842 |
+
</select>
|
2843 |
+
|
2844 |
+
<select name="day_or_hour" id="day_or_hour">
|
2845 |
+
<?php
|
2846 |
+
$days_or_hours_edit = "";
|
2847 |
+
if ( 'edittemplate' == $mode && count( $results ) > 0 && isset( $results[0]->day_or_hour ) )
|
2848 |
+
{
|
2849 |
+
$days_or_hours_edit = $results[0]->day_or_hour;
|
2850 |
+
}
|
2851 |
+
$days_or_hours = array(
|
2852 |
+
'Days' => 'Day(s)',
|
2853 |
+
'Hours' => 'Hour(s)'
|
2854 |
+
);
|
2855 |
+
foreach( $days_or_hours as $k => $v )
|
2856 |
+
{
|
2857 |
+
printf( "<option %s value='%s'>%s</option>\n",
|
2858 |
+
selected( $k, $days_or_hours_edit, false ),
|
2859 |
+
esc_attr( $k ),
|
2860 |
+
$v
|
2861 |
+
);
|
2862 |
+
}
|
2863 |
+
?>
|
2864 |
+
</select>
|
2865 |
+
<span class="description">
|
2866 |
+
<?php _e( 'after cart is abandoned.', 'woocommerce-abandoned-cart' ); ?>
|
2867 |
+
</span>
|
2868 |
+
</td>
|
2869 |
+
</tr>
|
2870 |
+
|
2871 |
+
<tr>
|
2872 |
+
<th>
|
2873 |
+
<label for="woocommerce_ac_email_preview"><b><?php _e( 'Send a test email to:', 'woocommerce-abandoned-cart' ); ?></b></label>
|
2874 |
+
</th>
|
2875 |
+
<td>
|
2876 |
+
<input type="text" id="send_test_email" name="send_test_email" class="regular-text" >
|
2877 |
+
<input type="button" value="Send a test email" id="preview_email" onclick="javascript:void(0);">
|
2878 |
+
<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-abandoned-cart') ?>' src="<?php echo plugins_url(); ?>/woocommerce/assets/images/help.png" />
|
2879 |
+
<div id="preview_email_sent_msg" style="display:none;"></div>
|
2880 |
+
</td>
|
2881 |
+
</tr>
|
2882 |
+
</table>
|
2883 |
+
</div>
|
2884 |
+
</div>
|
2885 |
+
</div>
|
2886 |
+
<p class="submit">
|
2887 |
+
<?php
|
2888 |
+
$button_value = "Save Changes";
|
2889 |
+
if ( 'edittemplate' == $mode ) {
|
2890 |
+
$button_value = "Update Changes";
|
2891 |
+
}
|
2892 |
+
?>
|
2893 |
+
<input type="submit" name="Submit" class="button-primary" value="<?php esc_attr_e( $button_value, 'woocommerce-abandoned-cart' ); ?>" />
|
2894 |
+
</p>
|
2895 |
+
</form>
|
2896 |
+
</div>
|
2897 |
+
<?php
|
2898 |
+
}
|
2899 |
+
}
|
2900 |
+
|
2901 |
+
/**
|
2902 |
+
* It will add the footer text for the plugin.
|
2903 |
+
* @hook admin_footer_text
|
2904 |
+
* @param string $footer_text Text
|
2905 |
+
* @return string $footer_text
|
2906 |
+
* @since 1.0
|
2907 |
+
*/
|
2908 |
+
function wcal_admin_footer_text( $footer_text ) {
|
2909 |
+
|
2910 |
+
if ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] === 'woocommerce_ac_page' ) {
|
2911 |
+
$footer_text = sprintf( __( 'If you love <strong>Abandoned Cart Lite for WooCommerce</strong>, then please leave us a <a href="https://wordpress.org/support/plugin/woocommerce-abandoned-cart/reviews/?rate=5#new-post" target="_blank" class="ac-rating-link" data-rated="Thanks :)">★★★★★</a>
|
2912 |
+
rating. Thank you in advance. :)', 'woocommerce-abandoned-cart' ) );
|
2913 |
+
wc_enqueue_js( "
|
2914 |
+
jQuery( 'a.ac-rating-link' ).click( function() {
|
2915 |
+
jQuery( this ).parent().text( jQuery( this ).data( 'rated' ) );
|
2916 |
+
});
|
2917 |
+
" );
|
2918 |
+
}
|
2919 |
+
return $footer_text;
|
2920 |
+
}
|
2921 |
+
|
2922 |
+
/**
|
2923 |
+
* It will sort the record for the product reports tab.
|
2924 |
+
* @param array $unsort_array Unsorted array
|
2925 |
+
* @param string $order Order details
|
2926 |
+
* @return array $array
|
2927 |
+
* @since 2.6
|
2928 |
+
*/
|
2929 |
+
function bubble_sort_function( $unsort_array, $order ) {
|
2930 |
+
$temp = array();
|
2931 |
+
foreach ( $unsort_array as $key => $value )
|
2932 |
+
$temp[ $key ] = $value; //concatenate something unique to make sure two equal weights don't overwrite each other
|
2933 |
+
asort( $temp, SORT_NUMERIC ); // or ksort( $temp, SORT_NATURAL ); see paragraph above to understand why
|
2934 |
+
|
2935 |
+
if ( 'desc' == $order ) {
|
2936 |
+
$array = array_reverse( $temp, true );
|
2937 |
+
} else if ( $order == 'asc' ) {
|
2938 |
+
$array = $temp;
|
2939 |
+
}
|
2940 |
+
unset( $temp );
|
2941 |
+
return $array;
|
2942 |
+
}
|
2943 |
+
|
2944 |
+
/**
|
2945 |
+
* It will be called when we send the test email from the email edit page.
|
2946 |
+
* @hook wp_ajax_wcal_preview_email_sent
|
2947 |
+
* @since 1.0
|
2948 |
+
*/
|
2949 |
+
function wcal_action_send_preview() {
|
2950 |
+
?>
|
2951 |
+
<script type="text/javascript" >
|
2952 |
+
jQuery( document ).ready( function( $ )
|
2953 |
+
{
|
2954 |
+
$( "table#addedit_template input#preview_email" ).click( function()
|
2955 |
+
{
|
2956 |
+
var email_body = '';
|
2957 |
+
if ( jQuery("#wp-woocommerce_ac_email_body-wrap").hasClass( "tmce-active" ) ) {
|
2958 |
+
email_body = tinyMCE.get('woocommerce_ac_email_body').getContent();
|
2959 |
+
} else {
|
2960 |
+
email_body = jQuery('#woocommerce_ac_email_body').val();
|
2961 |
+
}
|
2962 |
+
var subject_email_preview = $( '#woocommerce_ac_email_subject' ).val();
|
2963 |
+
var body_email_preview = email_body;
|
2964 |
+
var send_email_id = $( '#send_test_email' ).val();
|
2965 |
+
var is_wc_template = document.getElementById( "is_wc_template" ).checked;
|
2966 |
+
var wc_template_header = $( '#wcal_wc_email_header' ).val() != '' ? $( '#wcal_wc_email_header' ).val() : 'Abandoned cart reminder';
|
2967 |
+
var data = {
|
2968 |
+
subject_email_preview: subject_email_preview,
|
2969 |
+
body_email_preview : body_email_preview,
|
2970 |
+
send_email_id : send_email_id,
|
2971 |
+
is_wc_template : is_wc_template,
|
2972 |
+
wc_template_header : wc_template_header,
|
2973 |
+
action : 'wcal_preview_email_sent'
|
2974 |
+
};
|
2975 |
+
|
2976 |
+
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
|
2977 |
+
$.post( ajaxurl, data, function( response ) {
|
2978 |
+
if ( 'not sent' == response ) {
|
2979 |
+
$( "#preview_email_sent_msg" ).html( "Test email is not sent as the Email body is empty." );
|
2980 |
+
$( "#preview_email_sent_msg" ).fadeIn();
|
2981 |
+
setTimeout( function(){$( "#preview_email_sent_msg" ).fadeOut();}, 4000 );
|
2982 |
+
} else {
|
2983 |
+
$( "#preview_email_sent_msg" ).html( "<img src='<?php echo plugins_url(); ?>/woocommerce-abandoned-cart/assets/images/check.jpg'> Email has been sent successfully." );
|
2984 |
+
$( "#preview_email_sent_msg" ).fadeIn();
|
2985 |
+
setTimeout( function(){$( "#preview_email_sent_msg" ).fadeOut();}, 3000 );
|
2986 |
+
}
|
2987 |
+
//alert('Got this from the server: ' + response);
|
2988 |
+
});
|
2989 |
+
});
|
2990 |
+
});
|
2991 |
+
</script>
|
2992 |
+
<?php
|
2993 |
+
}
|
2994 |
+
|
2995 |
+
/**
|
2996 |
+
* It will update the template satus when we change the template active status from the email template list page.
|
2997 |
+
* @hook wp_ajax_wcal_toggle_template_status
|
2998 |
+
* @globals mixed $wpdb
|
2999 |
+
* @since 4.4
|
3000 |
+
*/
|
3001 |
+
public static function wcal_toggle_template_status () {
|
3002 |
+
global $wpdb;
|
3003 |
+
$template_id = $_POST['wcal_template_id'];
|
3004 |
+
$current_template_status = $_POST['current_state'];
|
3005 |
+
|
3006 |
+
if ( "on" == $current_template_status ) {
|
3007 |
+
$query_update = "SELECT * FROM `" . $wpdb->prefix . "ac_email_templates_lite` WHERE id ='" . $template_id . "'";
|
3008 |
+
$get_selected_template_result = $wpdb->get_results( $query_update );
|
3009 |
+
$email_frequncy = $get_selected_template_result[0]->frequency;
|
3010 |
+
$email_day_or_hour = $get_selected_template_result[0]->day_or_hour;
|
3011 |
+
$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 . "' ";
|
3012 |
+
$wcal_updated = $wpdb->query( $query_update );
|
3013 |
+
|
3014 |
+
if ( 1 == $wcal_updated ){
|
3015 |
+
$query_update_get_id = "SELECT id FROM `" . $wpdb->prefix . "ac_email_templates_lite` WHERE id != $template_id AND frequency='" . $email_frequncy . "' AND day_or_hour='" . $email_day_or_hour . "' ";
|
3016 |
+
$wcal_updated_get_id = $wpdb->get_results( $query_update_get_id );
|
3017 |
+
$wcal_all_ids = '';
|
3018 |
+
foreach ( $wcal_updated_get_id as $wcal_updated_get_id_key => $wcal_updated_get_id_value ) {
|
3019 |
+
# code...
|
3020 |
+
if ( '' == $wcal_all_ids ){
|
3021 |
+
$wcal_all_ids = $wcal_updated_get_id_value->id;
|
3022 |
+
} else {
|
3023 |
+
$wcal_all_ids = $wcal_all_ids . ',' . $wcal_updated_get_id_value->id;
|
3024 |
+
}
|
3025 |
+
}
|
3026 |
+
echo 'wcal-template-updated:'. $wcal_all_ids ;
|
3027 |
+
}
|
3028 |
+
|
3029 |
+
$active = "1";
|
3030 |
+
|
3031 |
+
update_option( 'wcal_template_' . $template_id . '_time', current_time( 'timestamp' ) );
|
3032 |
+
} else {
|
3033 |
+
$active = "0";
|
3034 |
+
}
|
3035 |
+
$query_update = "UPDATE `" . $wpdb->prefix . "ac_email_templates_lite`
|
3036 |
+
SET
|
3037 |
+
is_active = '" . $active . "'
|
3038 |
+
WHERE id = '" . $template_id . "' ";
|
3039 |
+
$wpdb->query( $query_update );
|
3040 |
+
|
3041 |
+
wp_die();
|
3042 |
+
}
|
3043 |
+
/**
|
3044 |
+
* It will replace the test email data with the static content.
|
3045 |
+
* @return string email sent | not sent
|
3046 |
+
* @since 1.0
|
3047 |
+
*/
|
3048 |
+
function wcal_preview_email_sent() {
|
3049 |
+
if ( '' != $_POST['body_email_preview'] ) {
|
3050 |
+
$from_email_name = get_option ( 'wcal_from_name' );
|
3051 |
+
$reply_name_preview = get_option ( 'wcal_from_email' );
|
3052 |
+
$from_email_preview = get_option ( 'wcal_reply_email' );
|
3053 |
+
$subject_email_preview = stripslashes ( $_POST['subject_email_preview'] );
|
3054 |
+
$subject_email_preview = convert_smilies ( $subject_email_preview );
|
3055 |
+
$subject_email_preview = str_replace( '{{customer.firstname}}', 'John', $subject_email_preview );
|
3056 |
+
$body_email_preview = convert_smilies ( $_POST['body_email_preview'] );
|
3057 |
+
$is_wc_template = $_POST['is_wc_template'];
|
3058 |
+
$wc_template_header = stripslashes( $_POST['wc_template_header'] );
|
3059 |
+
|
3060 |
+
$body_email_preview = str_replace( '{{customer.firstname}}', 'John', $body_email_preview );
|
3061 |
+
$body_email_preview = str_replace( '{{customer.firstname}}', 'John', $body_email_preview );
|
3062 |
+
$body_email_preview = str_replace( '{{customer.lastname}}', 'Doe', $body_email_preview );
|
3063 |
+
$body_email_preview = str_replace( '{{customer.fullname}}', 'John'." ".'Doe', $body_email_preview );
|
3064 |
+
$current_time_stamp = current_time( 'timestamp' );
|
3065 |
+
$date_format = date_i18n( get_option( 'date_format' ), $current_time_stamp );
|
3066 |
+
$time_format = date_i18n( get_option( 'time_format' ), $current_time_stamp );
|
3067 |
+
$test_date = $date_format . ' ' . $time_format;
|
3068 |
+
$body_email_preview = str_replace( '{{cart.abandoned_date}}', $test_date, $body_email_preview );
|
3069 |
+
$cart_url = wc_get_page_permalink( 'cart' );
|
3070 |
+
$body_email_preview = str_replace( '{{cart.link}}', $cart_url, $body_email_preview );
|
3071 |
+
$body_email_preview = str_replace( '{{cart.unsubscribe}}', '<a href=#>unsubscribe</a>', $body_email_preview );
|
3072 |
+
$wcal_price = wc_price( '100' );
|
3073 |
+
$wcal_total_price = wc_price( '200' );
|
3074 |
+
if ( class_exists( 'WP_Better_Emails' ) ) {
|
3075 |
+
$headers = "From: " . $from_email_name . " <" . $from_email_preview . ">" . "\r\n";
|
3076 |
+
$headers .= "Content-Type: text/plain" . "\r\n";
|
3077 |
+
$headers .= "Reply-To: " . $reply_name_preview . " " . "\r\n";
|
3078 |
+
$var = '<table width = 100%>
|
3079 |
+
<tr> <td colspan="5"> <h3>'.__( 'Your Shopping Cart', 'woocommerce-abandoned-cart' ).'</h3> </td></tr>
|
3080 |
+
<tr align="center">
|
3081 |
+
<th>'.__( 'Item', 'woocommerce-abandoned-cart' ).'</th>
|
3082 |
+
<th>'.__( 'Name', 'woocommerce-abandoned-cart' ).'</th>
|
3083 |
+
<th>'.__( 'Quantity', 'woocommerce-abandoned-cart' ).'</th>
|
3084 |
+
<th>'.__( 'Price', 'woocommerce-abandoned-cart' ).'</th>
|
3085 |
+
<th>'.__( 'Line Subtotal', 'woocommerce-abandoned-cart' ).'</th>
|
3086 |
+
</tr>
|
3087 |
+
<tr align="center">
|
3088 |
+
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/shoes.jpg"/></td>
|
3089 |
+
<td>'.__( "Men\'\s Formal Shoes", 'woocommerce-abandoned-cart' ).'</td>
|
3090 |
+
<td>1</td>
|
3091 |
+
<td>' . $wcal_price . '</td>
|
3092 |
+
<td>' . $wcal_price . '</td>
|
3093 |
+
</tr>
|
3094 |
+
<tr align="center">
|
3095 |
+
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/handbag.jpg"/></td>
|
3096 |
+
<td>'.__( "Woman\'\s Hand Bags", 'woocommerce-abandoned-cart' ).'</td>
|
3097 |
+
<td>1</td>
|
3098 |
+
<td>' . $wcal_price . '</td>
|
3099 |
+
<td>' . $wcal_price . '</td>
|
3100 |
+
</tr>
|
3101 |
+
<tr align="center">
|
3102 |
+
<td></td>
|
3103 |
+
<td></td>
|
3104 |
+
<td></td>
|
3105 |
+
<td>'.__( "Cart Total:", 'woocommerce-abandoned-cart' ).'</td>
|
3106 |
+
<td>' . $wcal_total_price . '</td>
|
3107 |
+
</tr>
|
3108 |
+
</table>';
|
3109 |
+
} else {
|
3110 |
+
$headers = "From: " . $from_email_name . " <" . $from_email_preview . ">" . "\r\n";
|
3111 |
+
$headers .= "Content-Type: text/html" . "\r\n";
|
3112 |
+
$headers .= "Reply-To: " . $reply_name_preview . " " . "\r\n";
|
3113 |
+
$var = '<h3>'.__( "Your Shopping Cart", 'woocommerce-abandoned-cart' ).'</h3>
|
3114 |
+
<table border="0" cellpadding="10" cellspacing="0" class="templateDataTable">
|
3115 |
+
<tr align="center">
|
3116 |
+
<th>'.__( "Item", 'woocommerce-abandoned-cart' ).'</th>
|
3117 |
+
<th>'.__( "Name", 'woocommerce-abandoned-cart' ).'</th>
|
3118 |
+
<th>'.__( "Quantity", 'woocommerce-abandoned-cart' ).'</th>
|
3119 |
+
<th>'.__( "Price", 'woocommerce-abandoned-cart' ).'</th>
|
3120 |
+
<th>'.__( "Line Subtotal", 'woocommerce-abandoned-cart' ).'</th>
|
3121 |
+
</tr>
|
3122 |
+
<tr align="center">
|
3123 |
+
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/shoes.jpg"/></td>
|
3124 |
+
<td>'.__( "Men\'\s Formal Shoes", 'woocommerce-abandoned-cart' ).'</td>
|
3125 |
+
<td>1</td>
|
3126 |
+
<td>' . $wcal_price . '</td>
|
3127 |
+
<td>' . $wcal_price . '</td>
|
3128 |
+
</tr>
|
3129 |
+
<tr align="center">
|
3130 |
+
<td><img class="demo_img" width="42" height="42" src="'.plugins_url().'/woocommerce-abandoned-cart/assets/images/handbag.jpg"/></td>
|
3131 |
+
<td>'.__( "Woman\'\s Hand Bags", 'woocommerce-abandoned-cart' ).'</td>
|
3132 |
+
<td>1</td>
|
3133 |
+
<td>' . $wcal_price . '</td>
|
3134 |
+
<td>' . $wcal_price . '</td>
|
3135 |
+
</tr>
|
3136 |
+
<tr align="center">
|
3137 |
+
<td></td>
|
3138 |
+
<td></td>
|
3139 |
+
<td></td>
|
3140 |
+
<td>'.__( "Cart Total:", 'woocommerce-abandoned-cart' ).'</td>
|
3141 |
+
<td>' . $wcal_total_price . '</td>
|
3142 |
+
</tr>
|
3143 |
+
</table>';
|
3144 |
+
}
|
3145 |
+
$body_email_preview = str_replace( '{{products.cart}}', $var, $body_email_preview );
|
3146 |
+
if ( isset( $_POST['send_email_id'] ) ) {
|
3147 |
+
$to_email_preview = $_POST['send_email_id'];
|
3148 |
+
} else {
|
3149 |
+
$to_email_preview = "";
|
3150 |
+
}
|
3151 |
+
$user_email_from = get_option( 'admin_email' );
|
3152 |
+
$body_email_final_preview = stripslashes( $body_email_preview );
|
3153 |
+
|
3154 |
+
if ( isset( $is_wc_template ) && 'true' == $is_wc_template ) {
|
3155 |
+
ob_start();
|
3156 |
+
// Get email heading
|
3157 |
+
wc_get_template( 'emails/email-header.php', array( 'email_heading' => $wc_template_header ) );
|
3158 |
+
$email_body_template_header = ob_get_clean();
|
3159 |
+
|
3160 |
+
ob_start();
|
3161 |
+
wc_get_template( 'emails/email-footer.php' );
|
3162 |
+
$email_body_template_footer = ob_get_clean();
|
3163 |
+
|
3164 |
+
$final_email_body = $email_body_template_header . $body_email_final_preview . $email_body_template_footer;
|
3165 |
+
|
3166 |
+
$site_title = get_bloginfo( 'name' );
|
3167 |
+
$email_body_template_footer = str_replace( '{site_title}', $site_title, $email_body_template_footer );
|
3168 |
+
|
3169 |
+
wc_mail( $to_email_preview, $subject_email_preview, $final_email_body , $headers );
|
3170 |
+
}
|
3171 |
+
else {
|
3172 |
+
wp_mail( $to_email_preview, $subject_email_preview, stripslashes( $body_email_preview ), $headers );
|
3173 |
+
}
|
3174 |
+
echo "email sent";
|
3175 |
+
die();
|
3176 |
+
} else {
|
3177 |
+
echo "not sent";
|
3178 |
+
die();
|
3179 |
+
}
|
3180 |
+
}
|
3181 |
+
}
|
3182 |
+
}
|
3183 |
+
$woocommerce_abandon_cart = new woocommerce_abandon_cart_lite();
|
3184 |
?>
|