Changeset 3807522
- Timestamp:
- 11/17/2026 01:51:58 PM (13 days ago)
- Location:
- recover-wc-abandoned-cart/trunk
- Files:
-
- 4 added
- 10 edited
-
admin/abandoned-list.php (modified) (13 diffs)
-
admin/cartemail.php (modified) (4 diffs)
-
admin/exitintent.php (modified) (3 diffs)
-
admin/productreport.php (added)
-
admin/register-settings.php (modified) (1 diff)
-
admin/templates.php (added)
-
css/style-admin.css (modified) (1 diff)
-
css/style.css (modified) (2 diffs)
-
includes (added)
-
includes/emails.php (added)
-
js/admin_custom.js (modified) (1 diff)
-
js/frontend.js (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
recover-wc-abandoned-cart.php (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
recover-wc-abandoned-cart/trunk/admin/abandoned-list.php
r3287435 r3807522 3 3 * abandoned menu. 4 4 */ 5 if ( ! defined( 'ABSPATH' ) ) exit; 5 6 if ( is_admin() ) { 6 7 add_action( 'admin_menu', 'racart_abandoned_cart', 100 ); … … 8 9 if ( ! function_exists ( 'racart_abandoned_cart' ) ) { 9 10 function racart_abandoned_cart() { 10 add_submenu_page( 'woocommerce', esc_html( "Abandoned carts" ), esc_html( 'Abandoned carts' ), 'manage_options', 'racart-abandonedcart', 'racart_abandoned_cart_callback' );11 add_submenu_page( 'woocommerce', esc_html( "Abandoned Carts" ), esc_html( 'Abandoned Carts' ), 'manage_options', 'racart-abandonedcart', 'racart_abandoned_cart_callback' ); 11 12 add_action( 'admin_init', 'racart_register_settings' ); 12 13 … … 19 20 global $wp_session; 20 21 global $product; 21 if ( ! function_exists ( ' sanitize' ) ) {22 function sanitize( $input ) {22 if ( ! function_exists ( 'racart_sanitize' ) ) { 23 function racart_sanitize( $input ) { 23 24 $new_input = array(); 24 25 foreach ( $input as $key => $val ) { … … 28 29 } 29 30 30 $racart_cartemail = $wpdb->prefix.'racart_cartemail';31 $racart_cartemail = esc_sql( $wpdb->prefix . 'racart_cartemail' ); 31 32 if ( sanitize_text_field( wp_unslash( isset( $_REQUEST['REQUEST_URI_nonce'] ) ) ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['REQUEST_URI_nonce'], 'REQUEST_URI_nonce_action' ) ) ) ) 32 33 { … … 59 60 $racart_exitintent = ""; 60 61 $racartactive_exitintent = ""; 61 if($tab =="settings"){ 62 $racart_cartemailpage = "none"; 63 $racart_productreport = "none"; 64 $racartactive_productreport = ""; 65 $racart_templates = "none"; 66 $racartactive_templates = ""; 67 if($tab =="templates"){ 68 $racart_templates = "block"; 69 $racartactive_templates = "racart_cartactive"; 70 $racart_abandoned_cart = "none"; 71 $racart_exitintent = "none"; 72 }else if($tab =="settings"){ 62 73 $racart_cartactive = "racart_cartactive"; 63 74 $racart_cartemailpage = "block"; … … 70 81 $racart_exitintent = "block"; 71 82 $racartactive_exitintent = "racart_cartactive"; 83 }else if($tab =="productreport"){ 84 $racartcartactive = ""; 85 $racart_cartemailpage = "none"; 86 $racart_abandoned_cart = "none"; 87 $racart_exitintent = "none"; 88 $racart_productreport = "block"; 89 $racartactive_productreport = "racart_cartactive"; 72 90 }elseif($tab==""){ 73 91 $racartcartactive = "racart_cartactive"; … … 80 98 <a href="<?php echo esc_url('https://www.sktthemes.org/themes/');?>" target="_blank"><img src="<?php echo esc_url(RACART_URI.'/images/browse-themes.png');?>"></a> 81 99 </div> 82 <h3><?php esc_html_e( "Abandoned carts",'recover-wc-abandoned-cart' );?></h3>100 <h3><?php esc_html_e( "Abandoned Carts",'recover-wc-abandoned-cart' );?></h3> 83 101 <div class="racart_cartmenu"> 84 <a href="<?php echo esc_url('admin.php?page=racart-abandonedcart');?>" class="<?php echo esc_attr($racartcartactive);?>"><?php esc_attr_e('Abandoned carts','recover-wc-abandoned-cart');?></a> 102 <a href="<?php echo esc_url('admin.php?page=racart-abandonedcart');?>" class="<?php echo esc_attr($racartcartactive);?>"><?php esc_attr_e('Abandoned Carts','recover-wc-abandoned-cart');?></a> 103 <a href="<?php echo esc_url('admin.php?page=racart-abandonedcart&tab=templates');?>" class="<?php echo esc_attr($racartactive_templates);?>"><?php esc_attr_e('Emails','recover-wc-abandoned-cart');?></a> 85 104 <a href="<?php echo esc_url('admin.php?page=racart-abandonedcart&tab=settings');?>" class="<?php echo esc_attr($racart_cartactive);?>"><?php esc_attr_e('Settings','recover-wc-abandoned-cart');?></a> 86 105 <a href="<?php echo esc_url('admin.php?page=racart-abandonedcart&tab=exitintent');?>" class="<?php echo esc_attr($racartactive_exitintent);?>"><?php esc_attr_e('Exit Intent','recover-wc-abandoned-cart');?></a> 106 <a href="<?php echo esc_url('admin.php?page=racart-abandonedcart&tab=productreport');?>" class="<?php echo esc_attr($racartactive_productreport);?>"><?php esc_attr_e('Product Report','recover-wc-abandoned-cart');?></a> 87 107 <a href="<?php echo esc_url('https://sktthemesdemo.net/documentation/recover-wc-abandoned-cart-doc');?>" target="_blank"><?php esc_attr_e('Documentation','recover-wc-abandoned-cart');?></a> 88 108 </div> … … 133 153 <th width="15%"><?php esc_html_e( "Product Name",'recover-wc-abandoned-cart' );?></th> 134 154 <th width="15%"><?php esc_html_e( "Cart Total",'recover-wc-abandoned-cart' );?></th> 135 <th width="1 0%" class="racart_srno_head"><?php esc_html_e( "Time",'recover-wc-abandoned-cart' );?></th>155 <th width="12%" class="racart_srno_head"><?php esc_html_e( "Time",'recover-wc-abandoned-cart' );?></th> 136 156 <th width="10%"><input type="checkbox" name="check_all" id="check_all" value=""/><?php esc_attr_e('Delete','recover-wc-abandoned-cart');?></th> 137 157 </tr> … … 140 160 <?php 141 161 $g =0; 162 $racart_modals = ''; 142 163 foreach ($get_cartemail as $getcartemail) { 143 164 $cart_contents = $getcartemail->cart_contents; 144 165 $date_time = $getcartemail->date_time; 145 $unserialize_cart_contents = unserialize($cart_contents); 146 $totalno_product = count($unserialize_cart_contents); 147 $email = $getcartemail->email; 166 $cart_ids = is_serialized( $cart_contents ) ? unserialize( $cart_contents, array( 'allowed_classes' => false ) ) : array(); 167 $cart_ids = is_array( $cart_ids ) ? array_filter( array_map( 'absint', $cart_ids ) ) : array(); 168 // Number of times the same ID appears = quantity 169 $cart_counts = array_count_values( $cart_ids ); 170 $email = $getcartemail->email; 148 171 149 172 $g++; … … 154 177 <div class="racart_srno"><?php echo esc_html( $g );?></div> 155 178 </td> 156 <td width="10%"><div class="racart_srno"><?php echo esc_html( $getcartemail->fname.' '.$getcartemail->lname);?></div></td>179 <td width="10%"><div class="racart_srno"><?php echo esc_html( trim( $getcartemail->fname.' '.$getcartemail->lname ) );?></div></td> 157 180 <td width="25%"><div class="racart_srno_email"><?php echo esc_html($getcartemail->email);?></div></td> 158 181 <td width="8%"><div class="racart_srno_name"><?php echo esc_html($getcartemail->phone);?></div></td> 159 182 <td width="5%" class="racart_srno_head"><div class="racart_srno_location"><?php echo esc_html($getcartemail->location);?></div></td> 160 183 <td width="15%"><div class="racart_srno_productname"> 161 <?php 162 for ( $i=0; $i <$totalno_product ; $i++ ) { 163 $get_productid = $unserialize_cart_contents[$i]; 164 $attachment_ids[0] = get_post_thumbnail_id( esc_html($get_productid) ); 165 $attachment = wp_get_attachment_image_src($attachment_ids[0], 'full' ); 166 ?> 167 <a href="post.php?post=<?php echo esc_html( $get_productid );?>&action=edit"><?php echo esc_html( get_the_title( $get_productid ) );?></a><br> 184 <?php if ( empty( $cart_counts ) ) { echo '—'; } ?> 185 <?php foreach ( $cart_counts as $get_productid => $item_qty ) { ?> 186 <a href="#" class="racart-view-cart" data-target="racart-cart-<?php echo esc_attr( $getcartemail->ID ); ?>"><?php echo esc_html( get_the_title( $get_productid ) ); ?><?php if ( $item_qty > 1 ) { echo esc_html( ' × ' . $item_qty ); } ?></a><br> 168 187 <?php } ?></div> 169 188 </td> 170 <td width="15%"><div class="racart_srno"><?php echo w c_price( $getcartemail->cart_total); ?></div></td>171 <td width="10%" class="racart_srno_head"><div class="racart_srno"><?php echo esc_html( racart_time_elapsed_string($date_time ) ); ?></div></td>189 <td width="15%"><div class="racart_srno"><?php echo wp_kses_post( wc_price( $getcartemail->cart_total ) ); ?></div></td> 190 <td width="10%" class="racart_srno_head"><div class="racart_srno"><?php echo esc_html( wp_date( 'F j, Y | g:i a', (int) $date_time ) ); ?></div></td> 172 191 <td width="10%"><div class="racart_srno"><input type="checkbox" name="selected_id[]" class="checkbox" value="<?php echo esc_html( $getcartemail->ID ); ?>"/> 173 192 <a href="<?php echo esc_url( 'admin.php?page=racart-abandonedcart&mode=delete&id='. esc_html( $getcartemail->ID ) ); ?>"><?php esc_attr_e( 'Delete', 'recover-wc-abandoned-cart' ); ?></a></div></td> 174 193 </tr> 194 <?php 195 // Hidden markup for this cart's view popup; JS shows it in an overlay 196 $price_args = array( 'currency' => $getcartemail->currency ); 197 $full_name = trim( $getcartemail->fname . ' ' . $getcartemail->lname ); 198 /* translators: %d: number of items in the cart */ 199 $items_label = sprintf( _n( '%d item', '%d items', count( $cart_ids ), 'recover-wc-abandoned-cart' ), count( $cart_ids ) ); 200 ob_start(); 201 ?> 202 <div class="racart-modal-source" id="racart-cart-<?php echo esc_attr( $getcartemail->ID ); ?>" style="display:none;"> 203 <div class="racart-modal-title"><?php echo esc_html( sprintf( 'Cart #%d', $getcartemail->ID ) ); ?> <span><?php esc_html_e( 'Abandoned', 'recover-wc-abandoned-cart' ); ?></span></div> 204 <table class="racart-modal-info"> 205 <thead><tr> 206 <th><?php esc_html_e( 'Email Address', 'recover-wc-abandoned-cart' ); ?></th> 207 <th><?php esc_html_e( 'Customer Details', 'recover-wc-abandoned-cart' ); ?></th> 208 <th><?php esc_html_e( 'Cart Total', 'recover-wc-abandoned-cart' ); ?></th> 209 <th><?php esc_html_e( 'Abandoned Date', 'recover-wc-abandoned-cart' ); ?></th> 210 </tr></thead> 211 <tbody><tr> 212 <td><?php echo esc_html( $getcartemail->email ); ?></td> 213 <td> 214 <?php echo esc_html( '' !== $full_name ? $full_name : '—' ); ?><br> 215 <?php if ( '' !== $getcartemail->phone ) { echo esc_html( $getcartemail->phone ) . '<br>'; } ?> 216 <?php echo esc_html( $getcartemail->location ); ?> 217 </td> 218 <td><?php echo wp_kses_post( wc_price( $getcartemail->cart_total, $price_args ) ); ?><br><?php echo esc_html( $items_label ); ?></td> 219 <td><?php echo esc_html( wp_date( 'F j, Y | g:i a', (int) $date_time ) ); ?></td> 220 </tr></tbody> 221 </table> 222 <table class="racart-modal-items"> 223 <thead><tr> 224 <th><?php esc_html_e( 'Item', 'recover-wc-abandoned-cart' ); ?></th> 225 <th><?php esc_html_e( 'Item Cost', 'recover-wc-abandoned-cart' ); ?></th> 226 <th><?php esc_html_e( 'Item Quantity', 'recover-wc-abandoned-cart' ); ?></th> 227 </tr></thead> 228 <tbody> 229 <?php foreach ( $cart_counts as $get_productid => $item_qty ) { 230 $item_product = wc_get_product( $get_productid ); 231 $item_name = $item_product ? $item_product->get_name() : get_the_title( $get_productid ); 232 $item_thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $get_productid ), 'thumbnail' ); 233 $item_img = $item_thumb ? $item_thumb[0] : wc_placeholder_img_src( 'thumbnail' ); 234 /* translators: %d: item quantity */ 235 $qty_label = sprintf( _n( '%d item', '%d items', $item_qty, 'recover-wc-abandoned-cart' ), $item_qty ); 236 ?> 237 <tr> 238 <td class="racart-modal-item"><img src="<?php echo esc_url( $item_img ); ?>" alt=""><span><?php echo esc_html( $item_name ); ?></span></td> 239 <td><?php echo $item_product ? wp_kses_post( wc_price( $item_product->get_price(), $price_args ) ) : '—'; ?></td> 240 <td><?php echo esc_html( $qty_label ); ?></td> 241 </tr> 242 <?php } ?> 243 </tbody> 244 </table> 245 </div> 246 <?php $racart_modals .= ob_get_clean(); ?> 175 247 <?php } } ?> 176 248 </tbody> … … 181 253 </table> 182 254 </form> 255 <?php echo $racart_modals; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- built from escaped parts above ?> 183 256 <?php }else{ ?> 184 257 <p><?php esc_html_e( "You don't have any saved Abandoned carts yet." ,'recover-wc-abandoned-cart');?></p> … … 186 259 <?php } ?> 187 260 </div> 261 <div class="racart_wccartemail_page racart_templates_page" style="display: <?php echo esc_attr( $racart_templates ); ?>;"> 262 <?php if ( 'templates' === $tab ) { racart_render_templates_tab(); } ?> 263 </div> 188 264 <div class="racart_wccartemail_page" style="display: <?php echo esc_html($racart_cartemailpage);?>;"> 189 265 <?php include_once( RACART_DIR .'/admin/cartemail.php' );?> … … 192 268 <?php include_once( RACART_DIR .'/admin/exitintent.php' );?> 193 269 </div> 270 <div class="racart_wccartemail_emailexit" style="display: <?php echo esc_html($racart_productreport);?>;"> 271 <?php include_once( RACART_DIR .'/admin/productreport.php' );?> 272 </div> 194 273 <?php } } ?> -
recover-wc-abandoned-cart/trunk/admin/cartemail.php
r3225629 r3807522 1 1 <?php 2 if ( ! defined( 'ABSPATH' ) ) exit; 2 3 global $current_user; 3 4 wp_get_current_user(); … … 7 8 <div class="racart_cart_mailer_form"> 8 9 <?php settings_fields( 'racart-settings-group' ); ?> 9 <?php do_settings_sections( 'racart-settings-group' ); ?>10 <?php do_settings_sections( 'racart-settings-group' ); ?> 10 11 <h4></h4> 11 12 <div class="racart_cart_email_form_setting"> … … 16 17 <input type="text" class="racart_cartadminemail" name="racart_adminemail" value="<?php echo esc_attr( get_option('racart_adminemail') ); ?>" placeholder="<?php esc_attr_e( 'Email Address', 'recover-wc-abandoned-cart' ); ?>"> 17 18 <div class="clear"></div> 18 <div class="racart_mail_message"><?php esc_attr_e( 'By default, notifications will be sent to WordPress admin email -', 'recover-wc-abandoned-cart' ); ?> <b><?php echo esc_html( $current_user->user_email); ?></b>.</div>19 <div class="racart_mail_message"><?php esc_attr_e( 'By default, notifications will be sent to WordPress admin email -', 'recover-wc-abandoned-cart' ); ?> <b><?php echo esc_html( get_option( 'admin_email' ) ); ?></b>.</div> 19 20 </div> 20 21 </div> … … 29 30 <option value="1" <?php if ( get_option('racart_setcron_email' ) == "1" ) { echo "selected";} ?>><?php echo esc_html__( 'Yes', 'recover-wc-abandoned-cart' ); ?></option> 30 31 </select> 31 </div> 32 </div> 33 <div class="clear"></div> 34 <div id="racart_cron_enable_disable"> 35 <div class="racart_cart_email_form_setting racart_radioset"> 36 <div class="racart_cart_email_label"> 37 <label><?php esc_attr_e( 'Select Sending Email Hour :', 'recover-wc-abandoned-cart' ); ?></label> 38 </div> 39 <input type="radio" name="email_hour" value="1" <?php if (get_option('email_hour')==1 OR ( get_option('email_hour') == '') ) { echo 'checked '; } ?>> 40 <label for="one_hr"><?php esc_attr_e('1 Hour','recover-wc-abandoned-cart');?></label> 41 <input type="radio" name="email_hour" value="24" <?php if ( get_option('email_hour' ) ==24 ) { echo 'checked '; } ?>> 42 <label for="tf_hour"><?php esc_attr_e( '24 Hour', 'recover-wc-abandoned-cart' ); ?></label> 43 </div> 44 <div class="racart_cart_email_form_setting"> 45 <div class="racart_cart_email_label"> 46 <label><?php esc_attr_e( 'Email Subject :', 'recover-wc-abandoned-cart' ); ?></label> 47 </div> 48 <input type="text" class="racart_cartadminemail" name="racart_onehr_email_subject" value="<?php echo esc_attr( get_option('racart_onehr_email_subject') ); ?>" placeholder="<?php esc_attr_e('Enter Email Subject','recover-wc-abandoned-cart');?>"> 49 </div> 50 <div class="clear"></div> 51 <div class="racart_cart_email_form_setting"> 52 <div class="racart_cart_email_label"> 53 <label><?php esc_attr_e('Email Message :','recover-wc-abandoned-cart');?></label> 54 </div> 55 <textarea name="racart_onehr_email_message" placeholder="<?php esc_attr_e('Enter Email Message','recover-wc-abandoned-cart');?>" cols="50" rows="8"><?php echo esc_attr( get_option('racart_onehr_email_message') ); ?></textarea> 32 <div class="racart_mail_message"> 33 <?php esc_html_e( 'Switch for the delayed / scheduled emails. Subject, message and timing are set per template in the Templates tab. Admin alerts ("Notify again whenever the cart contents change") are instant and work even when this is No.', 'recover-wc-abandoned-cart' ); ?> 34 <a href="<?php echo esc_url( admin_url( 'admin.php?page=racart-abandonedcart&tab=templates' ) ); ?>"><?php esc_html_e( 'Manage templates', 'recover-wc-abandoned-cart' ); ?></a> 35 </div> 56 36 </div> 57 37 </div> -
recover-wc-abandoned-cart/trunk/admin/exitintent.php
r3225629 r3807522 1 <?php 2 if ( ! defined( 'ABSPATH' ) ) exit; 3 ?> 1 4 <div class="racart_intentleft"> 2 5 <form method="post" action="options.php"> … … 31 34 <div class="racart_cart_email_form_setting"> 32 35 <div class="racart_cart_email_label"> 33 < input type="button" value="<?php esc_attr_e( 'Upload Logo ', 'recover-wc-abandoned-cart' ); ?>" class="button-primary" id="racart_upload_image"/>36 <label><?php esc_html_e( 'Popup Logo :', 'recover-wc-abandoned-cart' ); ?></label> 34 37 </div> 35 <input type="hidden" name="attachment_id" class="wp_attachment_id" value="" /> 36 <input type="hidden" name="attachment_idpath" class="attachment_idpath" value="<?php echo esc_attr( get_option( 'attachment_idpath' ) ); ?>" /> 37 <img src="<?php echo esc_url( get_option( 'attachment_idpath' ) ); ?>" class="image" style="display:block;margin-top:10px;"/> 38 <div class="racart_logo_field"> 39 <div class="racart_logo_buttons"> 40 <input type="button" value="<?php echo esc_attr( '' !== (string) get_option( 'attachment_idpath' ) ? __( 'Change Logo', 'recover-wc-abandoned-cart' ) : __( 'Upload Logo', 'recover-wc-abandoned-cart' ) ); ?>" class="button-primary" id="racart_upload_image"/> 41 <input type="button" value="<?php esc_attr_e( 'Remove Image', 'recover-wc-abandoned-cart' ); ?>" class="button" id="racart_remove_image" <?php echo '' === (string) get_option( 'attachment_idpath' ) ? 'style="display:none"' : ''; ?>/> 42 </div> 43 <input type="hidden" name="attachment_id" class="wp_attachment_id" value="" /> 44 <input type="hidden" name="attachment_idpath" class="attachment_idpath" value="<?php echo esc_attr( get_option( 'attachment_idpath' ) ); ?>" /> 45 <img src="<?php echo esc_url( get_option( 'attachment_idpath' ) ); ?>" class="image" style="display:<?php echo '' === (string) get_option( 'attachment_idpath' ) ? 'none' : 'block'; ?>;margin-top:10px;max-width:250px;height:auto;"/> 46 </div> 38 47 </div> 39 48 </div> … … 51 60 'use strict'; 52 61 $(function() { 53 $('#racart_upload_image').click(racart_open_custom_media_window); 54 function racart_open_custom_media_window() { 55 if (this.window === undefined) { 56 this.window = wp.media({ 57 title: 'Insert Image', 62 var txtUpload = <?php echo wp_json_encode( __( 'Upload Logo', 'recover-wc-abandoned-cart' ) ); ?>, 63 txtChange = <?php echo wp_json_encode( __( 'Change Logo', 'recover-wc-abandoned-cart' ) ); ?>, 64 $btn = $('#racart_upload_image'), 65 $rm = $('#racart_remove_image'), 66 $img = $('.racart_logo_field .image'), 67 $path = $('.attachment_idpath'), 68 frame; 69 // Button says "Change Logo" and "Remove Image" shows only while a logo is set 70 function sync() { 71 var has = $path.val() !== ''; 72 $btn.val(has ? txtChange : txtUpload); 73 $rm.toggle(has); 74 $img.toggle(has); 75 } 76 $btn.on('click', function(e) { 77 e.preventDefault(); 78 if (!frame) { 79 frame = wp.media({ 80 title: 'Select Logo', 58 81 library: {type: 'image'}, 59 82 multiple: false, 60 button: {text: ' Insert Image'}83 button: {text: 'Use this image'} 61 84 }); 62 var self = this;63 this.window.on('select', function() {64 var response = self.window.state().get('selection').first().toJSON();65 $('.wp_attachment_id').val(r esponse.id);66 $ ('.image').attr('src', response.sizes.thumbnail.url);67 $ ('.attachment_idpath').val(response.sizes.thumbnail.url);68 $('.image').show();85 frame.on('select', function() { 86 var r = frame.state().get('selection').first().toJSON(); 87 var url = (r.sizes && r.sizes.thumbnail) ? r.sizes.thumbnail.url : r.url; 88 $('.wp_attachment_id').val(r.id); 89 $path.val(url); 90 $img.attr('src', url); 91 sync(); 69 92 }); 70 93 } 71 this.window.open(); 72 return false; 73 } 94 frame.open(); 95 }); 96 $rm.on('click', function(e) { 97 e.preventDefault(); 98 $('.wp_attachment_id').val(''); 99 $path.val(''); 100 $img.attr('src', ''); 101 sync(); // click "Save Changes" to apply 102 }); 103 sync(); 74 104 }); 75 105 })( jQuery ); -
recover-wc-abandoned-cart/trunk/admin/register-settings.php
r3275807 r3807522 1 1 <?php 2 if ( ! defined( 'ABSPATH' ) ) exit; 2 3 if ( ! function_exists ( 'racart_register_settings' ) ) { 3 4 function racart_register_settings() { 4 5 register_setting( 'racart-settings-group', 'racart_adminemail', 'sanitize_text_field' ); 5 register_setting( 'racart-settings-group', 'racart_onehr_email_subject', 'sanitize_text_field' );6 register_setting( 'racart-settings-group', 'racart_onehr_email_message', 'sanitize_text_field' );7 6 register_setting( 'racart-settings-group', 'enable_exitintent', 'sanitize_text_field' ); 8 register_setting( 'racart-settings-group', 'email_hour', 'sanitize_text_field' );9 7 register_setting( 'racart-settings-group', 'racart_setcron_email', 'sanitize_text_field' ); 10 8 -
recover-wc-abandoned-cart/trunk/css/style-admin.css
r2421527 r3807522 126 126 .auto-fold #wpcontent {padding-right: 10px;} 127 127 } 128 /* Abandoned cart view popup */ 129 .racart-view-cart { text-decoration: underline; cursor: pointer; } 130 #racart-modal-overlay { display: none; position: fixed; inset: 0; z-index: 100001; background: rgba(0,0,0,.55); align-items: center; justify-content: center; padding: 20px; } 131 #racart-modal-overlay.racart-open { display: flex; } 132 .racart-modal { background: #fff; width: 100%; max-width: 760px; max-height: 90vh; display: flex; flex-direction: column; border-radius: 6px; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.35); } 133 .racart-modal-head { background: #4caf50; color: #fff; padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; font-size: 18px; } 134 .racart-modal-heading { font-weight: 600; } 135 .racart-modal-heading span { font-weight: 400; } 136 .racart-modal-x { background: none; border: 0; color: #fff; font-size: 28px; line-height: 1; cursor: pointer; } 137 .racart-modal-body { padding: 20px; overflow-y: auto; } 138 .racart-modal-foot { padding: 12px 20px; border-top: 1px solid #ddd; } 139 .racart-modal-body table { width: 100%; border-collapse: collapse; margin-bottom: 20px; font-size: 13px; } 140 .racart-modal-body th, .racart-modal-body td { border: 1px solid #ddd; padding: 10px 12px; text-align: left; vertical-align: top; } 141 .racart-modal-body thead th { background: #f6f7f7; } 142 .racart-modal-item img { width: 44px; height: 44px; object-fit: cover; border-radius: 3px; vertical-align: middle; margin-right: 10px; } 143 144 /* Product report */ 145 #racart_productreport_table { width: 100%; border-collapse: collapse; } 146 #racart_productreport_table td, #racart_productreport_table th { border: 1px solid #ddd; padding: 10px 12px; text-align: left; } 147 #racart_productreport_table th { background-color: #4CAF50; color: white; } 148 #racart_productreport_table tbody tr:nth-child(odd) { background-color: #f2f2f2; } 149 #racart_productreport_table tbody tr:hover { background-color: #ddd; } 150 .racart_report_count { text-align: right; margin: 0 0 8px; } 151 152 /* Templates tab */ 153 .racart_tpl_head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 12px; } 154 .racart_tpl_head h3 { margin-top: 0; } 155 .racart_tpl_bulk { margin-bottom: 12px; } 156 #racart_templates_table { width: 100%; border-collapse: collapse; } 157 #racart_templates_table th, #racart_templates_table td { border: 1px solid #ddd; padding: 10px 12px; text-align: left; vertical-align: middle; } 158 #racart_templates_table th { background-color: #4CAF50; color: #fff; } 159 #racart_templates_table tbody tr:nth-child(odd) { background-color: #f2f2f2; } 160 .racart_tpl_rowactions { font-size: 12px; margin-top: 4px; } 161 .racart-switch { position: relative; display: inline-block; width: 40px; height: 22px; } 162 .racart-switch input { opacity: 0; width: 0; height: 0; } 163 .racart-switch span { position: absolute; inset: 0; background: #ccc; border-radius: 22px; cursor: pointer; transition: background .2s; } 164 .racart-switch span:before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; } 165 .racart-switch input:checked + span { background: #4CAF50; } 166 .racart-switch input:checked + span:before { transform: translateX(18px); } 167 .racart_tpl_editor .form-table th { width: 160px; } 168 169 /* Exit intent: logo field sits in the same row layout as the other fields */ 170 .racart_logo_field { display: block; } 171 .racart_logo_field .racart_logo_buttons { display: flex; gap: 8px; align-items: center; } -
recover-wc-abandoned-cart/trunk/css/style.css
r2815162 r3807522 1 .racartlightbox {display: block;position: fixed;z-index: 9999;width: 100%;height: 100%;top: 0;left: 0;color:#333333;}1 .racartlightbox {display: none;position: fixed;z-index: 9999;width: 100%;height: 100%;top: 0;left: 0;color:#333333;} 2 2 .racartlightbox:after {content: '';display: table;clear: both;} 3 3 .racartlightbox .racart_box {width: -webkit-min-content;width: -moz-min-content;width: min-content;min-width:500px;margin: 11% auto;padding:20px;background-color:#FFF; border: 6px solid #ccc; border-radius: 8px; -moz-border-radius: 8px; -webkit-border-radius: 8px;} … … 6 6 .racartlightbox .racart_close {float:right;display:block;text-decoration:none;font-family:Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;font-size:22px;color:#858585;cursor: pointer;} 7 7 .racartlightbox .open {display: block;outline: none;} 8 .racartlightbox .racart_content img{margin:0 auto 1.618em !important;text-align: center;height: 150px;width: 150px; }9 .racartlightbox .racart_content h2{text-align: center !important;font-size: 20px !important;font-weight: bold !important;color: #000 !important;padding-top: 0px !important;padding-bottom: 5px !important; }10 .racartlightbox .racart_content p{text-align: center !important;font-size: 17px !important;color: #000 !important;}8 .racartlightbox .racart_content img{margin:0 auto 1.618em !important;text-align: center;height: 150px;width: 150px;display: block !important;} 9 .racartlightbox .racart_content h2{text-align: center !important;font-size: 20px !important;font-weight: bold !important;color: #000 !important;padding-top: 0px !important;padding-bottom: 5px !important;display: block !important;} 10 .racartlightbox .racart_content .popcontent{text-align: center !important;font-size: 17px !important;color: #000 !important;} -
recover-wc-abandoned-cart/trunk/js/admin_custom.js
r2408082 r3807522 57 57 }); 58 58 }); 59 /* Abandoned cart "view" popup (opens on product name click) */ 60 jQuery(function ($) { 61 var $overlay = null; 62 function build() { 63 if ($overlay) { return; } 64 $overlay = $( 65 '<div id="racart-modal-overlay">' + 66 '<div class="racart-modal" role="dialog" aria-modal="true">' + 67 '<div class="racart-modal-head"><span class="racart-modal-heading"></span>' + 68 '<button type="button" class="racart-modal-x" aria-label="Close">×</button></div>' + 69 '<div class="racart-modal-body"></div>' + 70 '<div class="racart-modal-foot"><button type="button" class="button racart-modal-close">Close</button></div>' + 71 '</div>' + 72 '</div>' 73 ).appendTo(document.body); 74 $overlay.on('click', function (e) { 75 if (e.target === this || $(e.target).is('.racart-modal-x, .racart-modal-close')) { closeModal(); } 76 }); 77 } 78 function closeModal() { if ($overlay) { $overlay.removeClass('racart-open'); } } 79 $(document).on('click', '.racart-view-cart', function (e) { 80 e.preventDefault(); 81 var $src = $('#' + $(this).data('target')); 82 if (!$src.length) { return; } 83 build(); 84 $overlay.find('.racart-modal-heading').html($src.find('.racart-modal-title').html()); 85 $overlay.find('.racart-modal-body').html($src.children().not('.racart-modal-title').clone()); 86 $overlay.addClass('racart-open'); 87 }); 88 $(document).on('keyup', function (e) { if (e.which === 27) { closeModal(); } }); 89 }); 90 91 /* Templates tab: on/off switch, select all, delete confirmation */ 92 jQuery(function ($) { 93 var $form = $('#racart_tpl_form'); 94 $(document).on('change', '.racart-tpl-toggle', function () { 95 var $cb = $(this); 96 $cb.prop('disabled', true); 97 $.post(window.ajaxurl, { 98 action: 'racart_toggle_template', 99 nonce: $form.data('nonce'), 100 id: $cb.data('id'), 101 active: $cb.is(':checked') ? 1 : 0 102 }).fail(function () { 103 $cb.prop('checked', !$cb.is(':checked')); 104 }).always(function () { 105 $cb.prop('disabled', false); 106 }); 107 }); 108 $('#racart_tpl_check_all').on('change', function () { 109 $('.racart-tpl-cb').prop('checked', this.checked); 110 }); 111 $(document).on('click', '.racart-confirm-delete', function () { 112 return window.confirm('Delete this template?'); 113 }); 114 $form.on('submit', function () { 115 var action = $form.find('select[name="bulk_action"]').val(); 116 if (!action || !$('.racart-tpl-cb:checked').length) { return false; } 117 return action !== 'delete' || window.confirm('Delete the selected templates?'); 118 }); 119 }); -
recover-wc-abandoned-cart/trunk/js/frontend.js
r2408082 r3807522 1 function skt_wccart_addEvent(obj, evt, fn) { 2 if (obj.addEventListener) { 3 obj.addEventListener(evt, fn, false); 4 }else if (obj.attachEvent) { 5 obj.attachEvent("on" + evt, fn); 1 /* 2 * Exit-intent popup: shown only when the visitor is about to leave the page 3 * (mouse leaves through the top edge of the browser). On mobile: fast scroll up. 4 */ 5 jQuery(function ($) { 6 var $box = $('.racartlightbox'); 7 if (!$box.length) { return; } 8 9 // The markup is repeated for every product on the shop page - keep only the first 10 $box.not(':first').remove(); 11 $box = $('.racartlightbox').first(); 12 13 // Never show on page load 14 $box.hide(); 15 16 // Do not show again if it was closed earlier (cookie, 1 day) 17 if ($.cookie('test') === 'Hmmm, cookie') { return; } 18 19 var armed = false, shown = false; 20 21 // Arm the trigger after 1 second (just enough to ignore accidental triggers right at load) 22 setTimeout(function () { armed = true; }, 1000); 23 24 function showPopup() { 25 if (!armed || shown) { return; } 26 shown = true; 27 $box.fadeIn(200); 6 28 } 7 } 8 document.addEventListener("mouseout", function(evt){ 9 var checktest = jQuery.cookie('test'); 10 if(checktest !=="Hmmm, cookie"){ 11 skt_wccart_addEvent(document, 'mouseout', function(evt) { 12 if (evt.toElement == null && evt.relatedTarget == null ) { 13 jQuery('.racartlightbox').css("display", "block"); 14 } 15 }); 16 } 17 }, false); 18 jQuery('.racart_close').click(function () { 19 jQuery.cookie('test', 'Hmmm, cookie', { expires: 1, path: '/' }); 20 jQuery('.racartlightbox').hide(); 21 var date = new Date(); 22 var check = date.setTime(date.getTime() + 48 * 60 * 60 * 1000); 23 jQuery.cookie('exit-intent-closed', false, { expires: date }); 24 setTimeout(function(){ 25 jQuery('.racartlightbox').remove(); 26 }, 100); 29 30 function closePopup() { 31 $.cookie('test', 'Hmmm, cookie', { expires: 1, path: '/' }); 32 var date = new Date(); 33 date.setTime(date.getTime() + 48 * 60 * 60 * 1000); 34 $.cookie('exit-intent-closed', false, { expires: date, path: '/' }); 35 $box.hide(); 36 setTimeout(function () { $('.racartlightbox').remove(); }, 100); 37 } 38 39 // Desktop: mouse left the window through the top edge. 40 // A fast mouse often reports its last point 2-10px below the edge (never exactly 0), so a plain 41 // "clientY <= 0" test misses many exits. We also remember where the pointer was just before 42 // it left: near the top and moving up means it is heading for the tabs / address bar. 43 var lastMouseY = 9999, movingUp = false; 44 document.addEventListener('mousemove', function (e) { 45 movingUp = e.clientY < lastMouseY; 46 lastMouseY = e.clientY; 47 }, { passive: true }); 48 function leftThroughTop(e) { 49 return e.clientY <= 10 || (lastMouseY <= 50 && movingUp); 50 } 51 document.documentElement.addEventListener('mouseleave', function (e) { 52 if (leftThroughTop(e)) { showPopup(); } 53 }); 54 document.addEventListener('mouseleave', function (e) { 55 if (leftThroughTop(e)) { showPopup(); } 56 }); 57 // Fallback for older browsers: mouseout with no target element 58 document.addEventListener('mouseout', function (e) { 59 if (!e.relatedTarget && leftThroughTop(e)) { showPopup(); } 60 }); 61 62 // Mobile: fast scroll up 63 var lastY = window.pageYOffset, lastT = Date.now(); 64 window.addEventListener('scroll', function () { 65 var y = window.pageYOffset, t = Date.now(); 66 var speed = (lastY - y) / Math.max(t - lastT, 1); 67 if ('ontouchstart' in window && speed > 1.5 && lastY - y > 80) { showPopup(); } 68 lastY = y; lastT = t; 69 }, { passive: true }); 70 71 // Close: X button, overlay click, Esc 72 $(document).on('click', '.racart_close', closePopup); 73 $(document).on('click', '.racartlightbox', function (e) { 74 if (e.target === this) { closePopup(); } 75 }); 76 $(document).on('keyup', function (e) { if (e.which === 27) { closePopup(); } }); 27 77 }); 28 jQuery(document).keyup(function(e) {29 if (e.which == 27) {30 jQuery.cookie('test', 'Hmmm, cookie', { expires: 1, path: '/' });31 jQuery('.racartlightbox').hide();32 var date = new Date();33 var check = date.setTime(date.getTime() + 48 * 60 * 60 * 1000);34 jQuery.cookie('exit-intent-closed', false, { expires: date });35 setTimeout(function(){36 jQuery('.racartlightbox').remove();37 }, 100);38 }39 }); -
recover-wc-abandoned-cart/trunk/readme.txt
r3287435 r3807522 2 2 Contributors: sonalsinha21 3 3 Tags: cart recovery, abandon cart, cart abandoned, woocommerce, recover woocommerce cart 4 Requires at least: 4.65 Requires PHP: 5.66 Tested up to: 6.8.17 Stable tag: 2. 54 Requires at least: 5.6 5 Requires PHP: 7.4 6 Tested up to: 7.1 7 Stable tag: 2.6 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 84 84 85 85 == Changelog == 86 = 2.6 = 87 * Added multiple email templates with configurable delays and recipient options (Customer/Admin). 88 * Added instant admin notifications email for cart updates. 89 * Added abandoned product reports. 90 * Fixed exit-intent popup issues. 91 * Added image change and remove options in exit-intent popup settings. 92 * Improved compatibility with WordPress 7.1. 93 86 94 = 2.5 = 87 95 * Resolved currency decimal issue. -
recover-wc-abandoned-cart/trunk/recover-wc-abandoned-cart.php
r3287435 r3807522 2 2 /*Plugin Name: Recover abandoned cart for WooCommerce 3 3 Description: Recover abandoned cart for WooCommerce easily. Increase sales by recovering your lost shopping cart by customers. 4 Version: 2. 54 Version: 2.6 5 5 Author: SKT Themes 6 6 Author URI: https://sktthemes.org/ … … 43 43 ) $charset_collate;"; 44 44 dbDelta( $sql_racart_cartemail ); 45 // Force the upgrade routine to run (adds the first_time column and the recovered table) 46 delete_option( 'racart_db_version' ); 47 racart_upgrade_db(); 45 48 } 46 49 } 47 50 register_activation_hook( __FILE__, 'racart_install_cart' ); 51 /* 52 * Database upgrade: runs once for existing installs as well. 53 * - racart_cartemail.first_time : time the cart was first captured (never updated) 54 * - racart_recovered : log of abandoned carts that were later turned into orders 55 */ 56 if ( ! function_exists( 'racart_upgrade_db' ) ) { 57 function racart_upgrade_db() { 58 global $wpdb; 59 $db_version = '5'; 60 if ( get_option( 'racart_db_version' ) === $db_version ) { 61 return; 62 } 63 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 64 $charset_collate = $wpdb->get_charset_collate(); 65 $racart_cartemail = esc_sql( $wpdb->prefix . 'racart_cartemail' ); 66 $table_exists = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $racart_cartemail ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching 67 if ( $table_exists ) { 68 $column = $wpdb->get_results( "SHOW COLUMNS FROM `$racart_cartemail` LIKE 'first_time'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared 69 if ( empty( $column ) ) { 70 $wpdb->query( "ALTER TABLE `$racart_cartemail` ADD COLUMN first_time varchar(255) NOT NULL DEFAULT ''" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared 71 } 72 } 73 $racart_recovered = $wpdb->prefix . 'racart_recovered'; 74 $sql_recovered = "CREATE TABLE $racart_recovered ( 75 ID bigint(20) NOT NULL AUTO_INCREMENT, 76 email varchar(255) NOT NULL DEFAULT '', 77 order_id bigint(20) NOT NULL DEFAULT 0, 78 items longtext NOT NULL, 79 currency varchar(20) NOT NULL DEFAULT '', 80 recovered_time bigint(20) NOT NULL DEFAULT 0, 81 PRIMARY KEY (ID) 82 ) $charset_collate;"; 83 dbDelta( $sql_recovered ); 84 // Log of every template email sent (also used for sent / open statistics) 85 $racart_email_log = $wpdb->prefix . 'racart_email_log'; 86 $sql_email_log = "CREATE TABLE $racart_email_log ( 87 ID bigint(20) NOT NULL AUTO_INCREMENT, 88 template_id bigint(20) NOT NULL DEFAULT 0, 89 cart_id bigint(20) NOT NULL DEFAULT 0, 90 email varchar(255) NOT NULL DEFAULT '', 91 status varchar(20) NOT NULL DEFAULT 'sent', 92 sent_time bigint(20) NOT NULL DEFAULT 0, 93 opened tinyint(1) NOT NULL DEFAULT 0, 94 clicked tinyint(1) NOT NULL DEFAULT 0, 95 converted tinyint(1) NOT NULL DEFAULT 0, 96 order_id bigint(20) NOT NULL DEFAULT 0, 97 state_hash varchar(32) NOT NULL DEFAULT '', 98 PRIMARY KEY (ID), 99 KEY cart_id (cart_id), 100 KEY template_id (template_id) 101 ) $charset_collate;"; 102 dbDelta( $sql_email_log ); 103 // Move the old single subject/message setting into the first template 104 if ( false === get_option( 'racart_email_templates' ) ) { 105 $old_subject = get_option( 'racart_onehr_email_subject' ); 106 $old_message = get_option( 'racart_onehr_email_message' ); 107 $templates = array(); 108 if ( '' !== (string) $old_subject || '' !== (string) $old_message ) { 109 $templates[1] = array( 110 'name' => __( 'Default', 'recover-wc-abandoned-cart' ), 111 'subject' => (string) $old_subject, 112 'message' => (string) $old_message, 113 'delay' => ( 24 === (int) get_option( 'email_hour' ) ) ? 24 : 1, 114 'unit' => 'hours', 115 'recipient' => 'admin', // the old setting always notified the admin 116 'active' => 1, 117 ); 118 } 119 update_option( 'racart_email_templates', $templates ); 120 } 121 update_option( 'racart_db_version', $db_version ); 122 } 123 } 124 add_action( 'plugins_loaded', 'racart_upgrade_db' ); 48 125 /* 49 126 * Deactivate plugin … … 62 139 if ( ! function_exists ( 'racart_admin_enqueue_cart' ) ) { 63 140 function racart_admin_enqueue_cart() { 64 wp_enqueue_style( 'racart-cutomcss', RACART_URI .'/css/style-admin.css', 'racart-cutom-css');65 wp_enqueue_script( 'my_custom_js', RACART_URI .'/js/admin_custom.js', array( 'jquery' ), ' 1.0', true );141 wp_enqueue_style( 'racart-cutomcss', RACART_URI .'/css/style-admin.css', array(), '2.7.1' ); 142 wp_enqueue_script( 'my_custom_js', RACART_URI .'/js/admin_custom.js', array( 'jquery' ), '2.7.1', true ); 66 143 } 67 144 } … … 72 149 if ( ! function_exists ( 'racart_enqueue_cart' ) ) { 73 150 function racart_enqueue_cart() { 74 wp_enqueue_style( 'racart-style', RACART_URI .'/css/style.css', 'racart-style-css');75 wp_enqueue_script( 'my_frontend_js', RACART_URI .'/js/frontend.js', array( 'jquery' ), ' 1.0', true );151 wp_enqueue_style( 'racart-style', RACART_URI .'/css/style.css', array(), '2.7.1' ); 152 wp_enqueue_script( 'my_frontend_js', RACART_URI .'/js/frontend.js', array( 'jquery' ), '2.7.1', true ); 76 153 wp_enqueue_script( 'my_cookie_js', RACART_URI .'/js/jquery.cookie.js', array( 'jquery' ), '1.0', true ); 77 load_plugin_textdomain( 'recover-wc-abandoned-cart', false, basename(dirname(__FILE__)).'/languages' );78 154 } 79 155 } … … 81 157 * Add custom field to the checkout page 82 158 */ 159 include_once( RACART_DIR . '/includes/emails.php' ); 160 include_once( RACART_DIR . '/admin/templates.php' ); 83 161 include_once( RACART_DIR . '/admin/abandoned-list.php' ); 84 162 include_once( RACART_DIR . '/admin/register-settings.php' ); … … 98 176 if ( get_option( 'attachment_idpath') !='' ) { 99 177 ?> 100 < img src="<?php echo esc_html( get_option( 'attachment_idpath' ) ); ?>">178 <center><img src="<?php echo esc_html( get_option( 'attachment_idpath' ) ); ?>">,</center> 101 179 <?php } 102 180 if ( get_option( 'racart_popup_title' ) !='' ) { ?> 103 181 <h2> <?php echo esc_html( get_option( 'racart_popup_title' ) );?></h2> 104 182 <?php } 105 if ( get_option( 'racart_popup_ title' ) !='' ) { ?>106 < p> <?php echo esc_html( get_option( 'racart_popup_content' ) );?></p>183 if ( get_option( 'racart_popup_content' ) !='' ) { ?> 184 <div class="popcontent"> <?php echo esc_html( get_option( 'racart_popup_content' ) );?></div> 107 185 <?php } ?> 108 186 </div> … … 129 207 if ( get_option('attachment_idpath') !='' ) { 130 208 ?> 131 < img src="<?php echo esc_html( get_option( 'attachment_idpath' ) ); ?>">209 <center><img src="<?php echo esc_html( get_option( 'attachment_idpath' ) ); ?>"></center> 132 210 <?php } 133 211 if ( get_option( 'racart_popup_title' ) !='' ) { ?> 134 212 <h2> <?php echo esc_html( get_option( 'racart_popup_title' ) );?></h2> 135 213 <?php } 136 if ( get_option('racart_popup_ title') !='' ) { ?>137 <p> <?php echo esc_html( get_option( 'racart_popup_content' ) );?></p>214 if ( get_option('racart_popup_content') !='' ) { ?> 215 <div class="popcontent"> <?php echo esc_html( get_option( 'racart_popup_content' ) );?></div> 138 216 <?php } ?> 139 217 </div> … … 163 241 if ( get_option('attachment_idpath' ) !='' ) { 164 242 ?> 165 < img src="<?php echo esc_html( get_option( 'attachment_idpath' ) ); ?>">243 <center><img src="<?php echo esc_html( get_option( 'attachment_idpath' ) ); ?>"></center> 166 244 <?php } 167 245 if ( get_option('racart_popup_title' ) !='' ) { ?> 168 246 <h2> <?php echo esc_html(get_option('racart_popup_title'));?></h2> 169 247 <?php } 170 if ( get_option('racart_popup_ title' ) !='') { ?>171 < p> <?php echo esc_html(get_option('racart_popup_content'));?></p>248 if ( get_option('racart_popup_content' ) !='') { ?> 249 <div class="popcontent"> <?php echo esc_html( get_option( 'racart_popup_content' ) );?></div> 172 250 <?php } ?> 173 251 </div> … … 196 274 global $wpdb; 197 275 if ( $order_id != '' ) { 198 $racart_cartemail = $wpdb->prefix . 'racart_cartemail';276 $racart_cartemail = esc_sql( $wpdb->prefix . 'racart_cartemail' ); 199 277 $order = wc_get_order( $order_id ); 200 278 $billing_email = $order->get_billing_email(); 279 // Order after clicking a recovery email link -> credit that email (works with any billing email) 280 $racart_cookie_done = racart_mark_converted_by_cookie( $order_id ); 201 281 ?> 202 282 <div id="racart_cartemailrefresh"></div> 203 283 <div id="racart_cartemailtime"> 204 284 <?php 205 $check_session_exit = $wpdb->get_row( "SELECT * FROM $racart_cartemail WHERE email='$billing_email'"); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared285 $check_session_exit = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $racart_cartemail WHERE email=%s", $billing_email ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared 206 286 $totalrow = $wpdb->num_rows; 207 287 if( $totalrow > 0 ) { 208 288 $cartrecovery_id = $check_session_exit->ID; 209 $wpdb->query( "DELETE FROM $racart_cartemail WHERE ID = '$cartrecovery_id'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared 289 // Credit the template email (if any) that was sent for this cart 290 if ( ! $racart_cookie_done ) { 291 racart_mark_converted( $cartrecovery_id, $order_id ); 292 } 293 // The cart counts as "recovered" when the order is placed a while after the cart was 294 // first captured (default 30 minutes, adjustable with the racart_recovery_threshold filter). 295 $first_time = ! empty( $check_session_exit->first_time ) ? (int) $check_session_exit->first_time : (int) $check_session_exit->date_time; 296 $threshold = (int) apply_filters( 'racart_recovery_threshold', 30 * MINUTE_IN_SECONDS ); 297 if ( $order && $first_time && ( time() - $first_time ) >= $threshold && ! $order->get_meta( '_racart_recovered_logged' ) ) { 298 $recovered_items = array(); 299 foreach ( $order->get_items() as $order_item ) { 300 $recovered_items[] = array( 301 'id' => (int) $order_item->get_product_id(), 302 'qty' => (int) $order_item->get_quantity(), 303 'total' => (float) $order_item->get_total(), 304 ); 305 } 306 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery 307 $wpdb->insert( $wpdb->prefix . 'racart_recovered', array( 308 'email' => $billing_email, 309 'order_id' => (int) $order_id, 310 'items' => wp_json_encode( $recovered_items ), 311 'currency' => $order->get_currency(), 312 'recovered_time' => time(), 313 ), array( '%s', '%d', '%s', '%s', '%d' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery 314 $order->update_meta_data( '_racart_recovered_logged', '1' ); 315 $order->save(); 316 } 317 $wpdb->delete( $racart_cartemail, array( 'ID' => $cartrecovery_id ), array( '%d' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared 210 318 } 211 319 ?> … … 252 360 } 253 361 add_action('racart_your_three_minute_action_hook', 'racart_cron_job_send_mail'); 254 if ( ! function_exists ( 'racart_cron_job_send_mail' ) ) {255 function racart_cron_job_send_mail() {256 global $wpdb;257 global $product;258 $racart_cartemail = $wpdb->prefix . 'racart_cartemail';259 global $current_user;260 wp_get_current_user();261 $current_time = time();262 $email_hour = esc_attr( get_option('email_hour') );263 if ( $email_hour == 24 ) {264 $count_sec = 3481000;265 $countsec = 3600*24;266 } else {267 $count_sec = 59000;268 $countsec = 3600;269 }270 if (get_option('racart_adminemail') == '') {271 $admin_email = $current_user->user_email;272 }else{273 $admin_email = esc_attr( get_option('racart_adminemail') );274 }275 $onehr_email_subject = esc_attr( get_option('racart_onehr_email_subject') );276 $onehr_email_message = esc_attr( get_option('racart_onehr_email_message') );277 $current_date = gmdate('y-m-d');278 $get_cartemail = $wpdb->get_results( "SELECT * FROM $racart_cartemail WHERE added_date='$current_date' ORDER BY ID DESC" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared279 $totalrow = $wpdb->num_rows;280 if ( $totalrow > 0 ) {281 foreach ( $get_cartemail as $getcartemail ) {282 $email = $getcartemail->email;283 $date_time = $getcartemail->date_time;284 $add_onehrtime = gmdate( "m/d/y G.i:s", $date_time+$countsec );285 if ( $add_onehrtime == $current_time ) {286 $to = $admin_email;287 $subject = $onehr_email_subject;288 $txt = $onehr_email_message;289 $headers = 'From: <'.$email.'>' . "\r\n";290 mail( $to,$subject,$txt,$headers );291 }292 }293 }294 }295 }296 362 add_action( 'wp_footer', 'racart_without_file',20 ); 297 363 if ( ! function_exists ( 'racart_without_file' ) ) { … … 311 377 foreach ( WC()->cart->get_cart() as $cart_item ) { 312 378 $product = $cart_item['data']; 313 $product_id = $cart_item['product_id']; 314 $qty = $cart_item['quantity']; 379 // Store the variation ID for variations, otherwise the product ID 380 $product_id = ! empty( $cart_item['variation_id'] ) ? (int) $cart_item['variation_id'] : (int) $cart_item['product_id']; 381 // Repeat the ID once per quantity (so the admin popup can show quantities) 382 $qty = min( max( 1, (int) $cart_item['quantity'] ), 99 ); 315 383 if ( !empty( $product ) ) { 316 $productid[] = $product_id; 384 for ( $q = 0; $q < $qty; $q++ ) { 385 $productid[] = $product_id; 386 } 317 387 } 318 388 } … … 320 390 if ( is_checkout() ) { 321 391 ?> 322 <script type="text/javascript" > 323 jQuery(document).ready(function($) { 324 var billingemail = jQuery('#billing_email').val(); 325 if(billingemail !=''){ 326 var fname = jQuery('#billing_first_name').val(); 327 var lname = jQuery('#billing_last_name').val(); 328 var billing_state = jQuery('#billing_state').val(); 329 var billing_city = jQuery('#billing_city').val(); 330 var billing_postcode = jQuery('#billing_postcode').val(); 331 var phone = jQuery('#billing_phone').val(); 332 var billing_email = jQuery('#billing_email').val(); 333 var currencycode = '<?php echo esc_html( $currency_code );?>'; 334 var cart_total = '<?php echo esc_html( $cart );?>'; 335 var productid = '<?php echo esc_html( $productid_array );?>'; 336 ajaxurl = '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>'; 337 var data = { 338 'action': 'racart_ineset_cartdetail', 339 'fname':fname,'lname':lname,'billing_state':billing_state,'billing_city':billing_city,'billing_postcode':billing_postcode,'phone':phone,'billing_email':billing_email,'currencycode':currencycode,'cart_total':cart_total,'productid':productid,'security': '<?php echo esc_attr( wp_create_nonce( 'racart_crop_insert_nonce' ) ); ?>' 340 }; 341 jQuery.ajax({ 342 url: ajaxurl, 343 type: 'POST', 344 data: data, 345 success: function (response) { 392 <script type="text/javascript"> 393 jQuery(function ($) { 394 var cfg = <?php echo wp_json_encode( array( 395 'ajaxurl' => admin_url( 'admin-ajax.php' ), 396 'currency' => $currency_code, 397 'cart_total' => $cart, 398 'productid' => $productid_array, 399 'security' => wp_create_nonce( 'racart_crop_insert_nonce' ), 400 ) ); ?>; 401 var timer = null, lastSent = ''; 402 403 function dom() { 404 for (var i = 0; i < arguments.length; i++) { 405 var $e = $(arguments[i]).first(); 406 var v = $e.length ? $.trim($e.val() || '') : ''; 407 if (v) { return v; } 408 } 409 return ''; 410 } 411 // Block checkout: read from the WooCommerce cart store (names/state are not always in the DOM) 412 function store() { 413 try { 414 if (window.wp && wp.data && wp.data.select) { 415 var st = wp.data.select('wc/store/cart'); 416 if (st && st.getCustomerData) { 417 var d = st.getCustomerData() || {}; 418 return { b: d.billingAddress || {}, s: d.shippingAddress || {} }; 346 419 } 347 }); 420 } 421 } catch (e) {} 422 return { b: {}, s: {} }; 423 } 424 function collect() { 425 var st = store(), b = st.b, s = st.s; 426 function pick(key, sels) { 427 return dom.apply(null, sels) || $.trim(b[key] || '') || $.trim(s[key] || ''); 348 428 } 349 jQuery("#billing_phone").blur(function(){ 350 var fname = jQuery('#billing_first_name').val(); 351 var lname = jQuery('#billing_last_name').val(); 352 var billing_state = jQuery('#billing_state').val(); 353 var billing_city = jQuery('#billing_city').val(); 354 var billing_postcode = jQuery('#billing_postcode').val(); 355 var phone = jQuery('#billing_phone').val(); 356 var billing_email = jQuery('#billing_email').val(); 357 var currencycode = '<?php echo esc_html( $currency_code );?>'; 358 var cart_total = '<?php echo esc_html( $cart );?>'; 359 var productid = '<?php echo esc_html( $productid_array );?>'; 360 ajaxurl = '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>'; 361 var data = { 362 'action': 'racart_ineset_cartdetail', 363 'fname':fname,'lname':lname,'billing_state':billing_state,'billing_city':billing_city,'billing_postcode':billing_postcode,'phone':phone,'billing_email':billing_email,'currencycode':currencycode,'cart_total':cart_total,'productid':productid,'security': '<?php echo esc_attr( wp_create_nonce( 'racart_crop_insert_nonce' ) ); ?>' 364 }; 365 jQuery.ajax({ 366 url: ajaxurl, 367 type: 'POST', 368 data: data, 369 success: function (response) { 370 } 371 }); 372 }); 373 jQuery("#billing_email").blur(function(){ 374 var fname = jQuery('#billing_first_name').val(); 375 var lname = jQuery('#billing_last_name').val(); 376 var billing_state = jQuery('#billing_state').val(); 377 var billing_city = jQuery('#billing_city').val(); 378 var billing_postcode = jQuery('#billing_postcode').val(); 379 var phone = jQuery('#billing_phone').val(); 380 var billing_email = jQuery('#billing_email').val(); 381 var currencycode = '<?php echo esc_html( $currency_code );?>'; 382 var cart_total = '<?php echo esc_html( $cart );?>'; 383 var productid = '<?php echo esc_html( $productid_array );?>'; 384 ajaxurl = '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>'; 385 var data = { 386 'action': 'racart_ineset_cartdetail', 387 'fname':fname,'lname':lname,'billing_state':billing_state,'billing_city':billing_city,'billing_postcode':billing_postcode,'phone':phone,'billing_email':billing_email,'currencycode':currencycode,'cart_total':cart_total,'productid':productid, 388 'security': '<?php echo esc_attr( wp_create_nonce( 'racart_crop_insert_nonce' ) ); ?>' 389 }; 390 jQuery.ajax({ 391 url: ajaxurl, 392 type: 'POST', 393 data: data, 394 success: function (response) { 395 } 396 }); 397 }); 398 }); 429 return { 430 fname: pick('first_name', ['#billing_first_name', '#billing-first_name', '#shipping_first_name', '#shipping-first_name']), 431 lname: pick('last_name', ['#billing_last_name', '#billing-last_name', '#shipping_last_name', '#shipping-last_name']), 432 billing_state: pick('state', ['#billing_state', '#billing-state', '#shipping_state', '#shipping-state']), 433 billing_city: pick('city', ['#billing_city', '#billing-city', '#shipping_city', '#shipping-city']), 434 billing_postcode: pick('postcode', ['#billing_postcode', '#billing-postcode', '#shipping_postcode', '#shipping-postcode']), 435 phone: pick('phone', ['#billing_phone', '#billing-phone', '#shipping_phone', '#shipping-phone']), 436 billing_email: pick('email', ['#billing_email', '#email']) 437 }; 438 } 439 function send() { 440 var d = collect(); 441 if (!/^\S+@\S+\.\S+$/.test(d.billing_email)) { return; } 442 d.action = 'racart_ineset_cartdetail'; 443 d.currencycode = cfg.currency; 444 d.cart_total = cfg.cart_total; 445 d.productid = cfg.productid; 446 d.security = cfg.security; 447 var sig = JSON.stringify(d); 448 if (sig === lastSent) { return; } 449 lastSent = sig; 450 $.post(cfg.ajaxurl, d); 451 } 452 function schedule() { 453 clearTimeout(timer); 454 timer = setTimeout(send, 800); 455 } 399 456 400 jQuery( window ).on( "load", function() { 401 setTimeout(function () { 402 var email = jQuery('#email').val(); 403 if(email !=''){ 404 var fname = jQuery('#billing-first_name').val(); 405 var lname = jQuery('#billing-last_name').val(); 406 var billing_state = jQuery('#components-form-token-input-1').val(); 407 var billing_city = jQuery('#billing-city').val(); 408 var billing_postcode = jQuery('#billing-postcode').val(); 409 var phone = jQuery('#billing-phone').val(); 410 var email = jQuery('#email').val(); 411 var currencycode = '<?php echo esc_html( $currency_code );?>'; 412 var cart_total = '<?php echo esc_html( $cart );?>'; 413 var productid = '<?php echo esc_html( $productid_array );?>'; 414 415 ajaxurl = '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>'; 416 var data = { 417 'action': 'racart_ineset_cartdetail', 418 'fname':fname,'lname':lname,'billing_state':billing_state,'billing_city':billing_city,'billing_postcode':billing_postcode,'phone':phone,'billing_email':email,'currencycode':currencycode,'cart_total':cart_total,'productid':productid,'security': '<?php echo esc_attr( wp_create_nonce( 'racart_crop_insert_nonce' ) ); ?>' 419 }; 420 jQuery.ajax({ 421 url: ajaxurl, 422 type: 'POST', 423 data: data, 424 success: function (response) { 425 } 426 }); 427 } 428 429 jQuery("#email").blur(function(){ 430 var fname = jQuery('#billing-first_name').val(); 431 var lname = jQuery('#billing-last_name').val(); 432 var billing_state = jQuery('#components-form-token-input-1').val(); 433 var billing_city = jQuery('#billing-city').val(); 434 var billing_postcode = jQuery('#billing-postcode').val(); 435 var phone = jQuery('#billing-phone').val(); 436 var email = jQuery('#email').val(); 437 var currencycode = '<?php echo esc_html( $currency_code );?>'; 438 var cart_total = '<?php echo esc_html( $cart );?>'; 439 var productid = '<?php echo esc_html( $productid_array );?>'; 440 441 ajaxurl = '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>'; 442 var data = { 443 'action': 'racart_ineset_cartdetail', 444 'fname':fname,'lname':lname,'billing_state':billing_state,'billing_city':billing_city,'billing_postcode':billing_postcode,'phone':phone,'billing_email':email,'currencycode':currencycode,'cart_total':cart_total,'productid':productid,'security': '<?php echo esc_attr( wp_create_nonce( 'racart_crop_insert_nonce' ) ); ?>' 445 }; 446 jQuery.ajax({ 447 url: ajaxurl, 448 type: 'POST', 449 data: data, 450 success: function (response) { 451 } 452 }); 453 }); 454 455 jQuery("#billing-phone").blur(function(){ 456 var fname = jQuery('#billing-first_name').val(); 457 var lname = jQuery('#billing-last_name').val(); 458 var billing_state = jQuery('#components-form-token-input-1').val(); 459 var billing_city = jQuery('#billing-city').val(); 460 var billing_postcode = jQuery('#billing-postcode').val(); 461 var phone = jQuery('#billing-phone').val(); 462 var email = jQuery('#email').val(); 463 var currencycode = '<?php echo esc_html( $currency_code );?>'; 464 var cart_total = '<?php echo esc_html( $cart );?>'; 465 var productid = '<?php echo esc_html( $productid_array );?>'; 466 467 ajaxurl = '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>'; 468 var data = { 469 'action': 'racart_ineset_cartdetail', 470 'fname':fname,'lname':lname,'billing_state':billing_state,'billing_city':billing_city,'billing_postcode':billing_postcode,'phone':phone,'billing_email':email,'currencycode':currencycode,'cart_total':cart_total,'productid':productid, 471 'security': '<?php echo esc_attr( wp_create_nonce( 'racart_crop_insert_nonce' ) ); ?>' 472 }; 473 jQuery.ajax({ 474 url: ajaxurl, 475 type: 'POST', 476 data: data, 477 success: function (response) { 478 } 479 }); 480 }); 481 }, 1000); 482 }); 457 // Classic and block checkout: on change/blur of any field (debounced) 458 $(document).on('change blur', 'form.checkout input, form.checkout select, .wc-block-checkout input, .wc-block-checkout select', schedule); 459 $(document.body).on('updated_checkout', schedule); 460 try { if (window.wp && wp.data && wp.data.subscribe) { wp.data.subscribe(schedule); } } catch (e) {} 461 // Also on page load (browser autofill / prefilled values) 462 setTimeout(send, 1500); 463 }); 483 464 </script> 484 465 <?php } } } … … 492 473 $added_date = gmdate('y-m-d'); 493 474 $date_time = time(); 494 $racart_cartemail = $wpdb->prefix.'racart_cartemail';475 $racart_cartemail = esc_sql( $wpdb->prefix . 'racart_cartemail' ); 495 476 if ( sanitize_text_field( wp_unslash( isset( $_POST['REQUEST_URI_nonce'] ) ) ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['REQUEST_URI_nonce'], 'REQUEST_URI_nonce_action' ) ) ) ) { 496 477 echo esc_html( '' ); … … 517 498 $cart_total = floatval( wp_unslash( isset( $_POST['cart_total'] ) ? $_POST['cart_total'] : '' ) ); 518 499 $cart_contents = sanitize_text_field( wp_unslash ( isset ( $_POST['productid'] ) ? $_POST['productid'] : '' ) ); 519 if ( ! preg_match( '/^[a-zA-Z\s]+$/', $fname ) || ! preg_match( '/^[a-zA-Z\s]+$/', $lname ) ) { 520 wp_send_json_error( [ 'message' => 'Invalid name format' ] ); 521 } 500 // Names can be empty (e.g. on email/phone blur) - never reject the capture because of a name. 501 // Digits/symbols are allowed (already sanitized; escaped on output). 502 $fname = mb_substr( $fname, 0, 100 ); 503 $lname = mb_substr( $lname, 0, 100 ); 522 504 if ( ! is_email( $email ) ) { 523 505 wp_send_json_error( [ 'message' => 'Invalid email' ] ); … … 529 511 wp_send_json_error( [ 'message' => 'Invalid currency code' ] ); 530 512 } 531 $check_session_exit = $wpdb->get_row( "SELECT * FROM $racart_cartemail WHERE email='$email'"); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared513 $check_session_exit = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $racart_cartemail WHERE email=%s", $email ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared 532 514 $totalrow = $wpdb->num_rows; 533 515 if ( $email ) { 534 516 if ( $totalrow > 0 ) { 535 517 $cartrecovery_id = $check_session_exit->ID; 536 $updatequery = $wpdb->query( "UPDATE $racart_cartemail SET fname='$fname',lname='$lname',email='$email',phone='$phone',location='$location',cart_contents='$cart_contents',cart_total='$cart_total',currency='$currencycode',date_time='$date_time',added_date='$added_date' WHERE ID ='$cartrecovery_id'" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQL.InterpolatedNotPrepared 518 $update = array( 519 'email' => $email, 520 'cart_contents' => $cart_contents, 521 'cart_total' => $cart_total, 522 'currency' => $currencycode, 523 'date_time' => $date_time, 524 'added_date' => $added_date, 525 ); 526 // Do not overwrite saved values with blank ones 527 if ( '' !== $fname ) { $update['fname'] = $fname; } 528 if ( '' !== $lname ) { $update['lname'] = $lname; } 529 if ( '' !== $phone ) { $update['phone'] = $phone; } 530 if ( '' !== $location ) { $update['location'] = $location; } 531 $wpdb->update( $racart_cartemail, $update, array( 'ID' => $cartrecovery_id ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery 537 532 } else { 538 533 $data = array( … … 547 542 'date_time' => $date_time, 548 543 'added_date' => $added_date, 544 // NOT NULL columns without defaults: insert fails silently in MySQL strict mode if omitted. 545 'session_cartrecovery' => '', 546 'recoverd_abandoned' => '', 547 'first_time' => $date_time, // first capture time, never updated 549 548 ); 550 $format = array( '%s','%s','%s','%s','%s','%s','%f','%s','%s','%s' );549 $format = array( '%s','%s','%s','%s','%s','%s','%f','%s','%s','%s','%s','%s','%s' ); 551 550 $result = $wpdb->insert( $racart_cartemail, $data, $format ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery 552 551 } 552 } 553 if ( $email ) { 554 racart_notify_admin_instantly( $email ); // admin change alert, sent right away (no cron) 553 555 } 554 556 wp_die();
Note:
See TracChangeset
for help on using the changeset viewer.