Skip to content

Commit cc52128

Browse files
committed
Merge branch 'release/1.2.5'
2 parents 99e96df + 5da50ee commit cc52128

2 files changed

Lines changed: 200 additions & 2 deletions

File tree

conversion-tracking.php

Lines changed: 184 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
Plugin Name: WooCommerce Conversion Tracking
44
Plugin URI: https://wedevs.com/products/plugins/woocommerce-conversion-tracking/
55
Description: Adds various conversion tracking codes to cart, checkout, registration success and product page on WooCommerce
6-
Version: 1.2.4
6+
Version: 1.2.5
77
Author: Tareq Hasan
88
Author URI: https://tareq.co/
99
License: GPL2
10+
WC requires at least: 2.3
11+
WC tested up to: 3.2.6
1012
*/
1113

1214
/**
13-
* Copyright (c) 2016 Tareq Hasan (email: tareq@wedevs.com). All rights reserved.
15+
* Copyright (c) 2017 Tareq Hasan (email: tareq@wedevs.com). All rights reserved.
1416
*
1517
* Released under the GPL license
1618
* http://www.opensource.org/licenses/gpl-license.php
@@ -45,6 +47,13 @@
4547
*/
4648
class WeDevs_WC_Conversion_Tracking {
4749

50+
/**
51+
* Plugin version
52+
*
53+
* @var string
54+
*/
55+
public $version = '1.2.5';
56+
4857
/**
4958
* Constructor for the WeDevs_WC_Conversion_Tracking class
5059
*
@@ -56,12 +65,21 @@ class WeDevs_WC_Conversion_Tracking {
5665
*/
5766
public function __construct() {
5867

68+
$this->define_constants();
69+
70+
register_activation_hook( __FILE__, array( $this, 'activate' ) );
71+
5972
// Localize our plugin
6073
add_action( 'init', array( $this, 'localization_setup' ) );
6174
add_action( 'init', array( $this, 'init_tracker' ) );
6275

76+
add_action( 'admin_notices', array( $this, 'display_survey' ) );
77+
add_action( 'wp_ajax_wcv_dismiss_survey', array( $this, 'dismiss_survey' ) );
78+
6379
// register integration
6480
add_filter( 'woocommerce_integrations', array($this, 'register_integration') );
81+
82+
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'plugin_action_links' ) );
6583
}
6684

6785
/**
@@ -80,6 +98,35 @@ public static function init() {
8098
return $instance;
8199
}
82100

101+
/**
102+
* Define the constants
103+
*
104+
* @since 1.2.5
105+
*
106+
* @return void
107+
*/
108+
public function define_constants() {
109+
define( 'WCCT_VERSION', $this->version );
110+
define( 'WCCT_FILE', __FILE__ );
111+
}
112+
113+
/**
114+
* Plugin activation routeis
115+
*
116+
* @since 1.2.5
117+
*
118+
* @return void
119+
*/
120+
public function activate() {
121+
$installed = get_option( 'wcct_installed' );
122+
123+
if ( ! $installed ) {
124+
update_option( 'wcct_installed', time() );
125+
}
126+
127+
update_option( 'wcct_version', WCCT_VERSION );
128+
}
129+
83130
/**
84131
* Initialize plugin for localization
85132
*
@@ -117,6 +164,141 @@ function register_integration( $interations ) {
117164
return $interations;
118165
}
119166

167+
/**
168+
* Dismiss the survey notice
169+
*
170+
* @return void
171+
*/
172+
public function dismiss_survey() {
173+
update_option( 'wcv_dismiss_survey', 'yes' );
174+
wp_send_json_success();
175+
}
176+
177+
/**
178+
* Is survey dimissed
179+
*
180+
* @return boolean
181+
*/
182+
public function survey_dimissed() {
183+
return get_option( 'wcv_dismiss_survey', 'no' ) == 'yes';
184+
}
185+
186+
/**
187+
* Display Survey Notice
188+
*
189+
* @return void
190+
*/
191+
public function display_survey() {
192+
193+
if ( ! current_user_can( 'manage_options' ) ) {
194+
return;
195+
}
196+
197+
if ( $this->survey_dimissed() ) {
198+
return;
199+
}
200+
?>
201+
<div class="notice notice-success wct-survey-notice">
202+
<div class="wct-notice-title">
203+
<p><strong>WooCommerce Conversion Tracking Survey</strong></p>
204+
205+
<p>Hey there, thanks for using WooCommerce Conversion Tracking. I would love to have your feedback.</p>
206+
207+
<p>
208+
To make the tracking better, I want to bring deep integrations to various services (e.g. Facebook, Twitter) to track conversions. So therefore I need to know which service you use and will implement the integrations of most used services first.
209+
</p>
210+
211+
<div class="wct-avatar-wrap">
212+
<div class="wct-avatar">
213+
<img src="http://2.gravatar.com/avatar/8584491809f902b86fae495a5830be83?s=128&d=mm&r=g" alt="Avatar of Tareq Hasan">
214+
</div>
215+
<div class="wct-user-details">
216+
Regards,<br>
217+
<strong>Tareq Hasan</strong><br>
218+
Developer
219+
</div>
220+
</div>
221+
</div>
222+
223+
<div class="wct-notice-actions">
224+
<a href="http://tareq.in/yn77Th" target="_blank" class="button button-primary">Take the Survey</a>
225+
<button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php _e( 'Dismiss this notice.' ); ?></span></button>
226+
</div>
227+
</div>
228+
229+
<style>
230+
.wct-survey-notice {
231+
display: flex;
232+
position: relative;
233+
}
234+
235+
.wct-survey-notice .wct-notice-title {
236+
width: calc(100% - 200px);
237+
}
238+
239+
.wct-survey-notice .wct-notice-actions {
240+
width: 200px;
241+
text-align: right;
242+
padding-right: 25px;
243+
padding-top: 70px;
244+
}
245+
246+
.wct-avatar-wrap {
247+
display: flex;
248+
margin: .5em 0;
249+
padding: 2px;
250+
}
251+
252+
.wct-avatar {
253+
width: 52px;
254+
height: 52px;
255+
margin-right: 15px;
256+
margin-top: 5px;
257+
}
258+
259+
.wct-user-details {
260+
width: calc(100% - 100px);
261+
}
262+
263+
.wct-avatar img {
264+
background: #888;
265+
border-radius: 50%;
266+
height: 100%;
267+
width: 100%;
268+
}
269+
</style>
270+
271+
<script type="text/javascript">
272+
jQuery(function($) {
273+
$('.wct-survey-notice').on('click', 'button', function(event) {
274+
event.preventDefault();
275+
276+
wp.ajax.send('wcv_dismiss_survey');
277+
278+
$(this).closest('.notice').slideUp(function() {
279+
$(this).remove();
280+
});
281+
});
282+
});
283+
</script>
284+
<?php
285+
}
286+
287+
/**
288+
* Plugin action links
289+
*
290+
* @param array $links
291+
*
292+
* @return array
293+
*/
294+
function plugin_action_links( $links ) {
295+
296+
$links[] = '<a href="https://wordpress.org/plugins/woocommerce-conversion-tracking/#installation" target="_blank">' . __( 'Installation', 'woocommerce-conversion-tracking' ) . '</a>';
297+
$links[] = '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=integration&section=wc_conv_tracking' ) . '">' . __( 'Settings', 'woocommerce-conversion-tracking' ) . '</a>';
298+
299+
return $links;
300+
}
301+
120302
}
121303

122304
// WeDevs_WC_Conversion_Tracking

readme.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ Extract the zip file and just drop the contents in the wp-content/plugins/ direc
3232
* PHP version 5.2.4 or greater
3333
* MySQL version 5.0 or greater
3434

35+
= Tracking Conversions =
36+
37+
If you need to track successful purchases, go to the settings and in the **Tags for Successful Order** box, place the JavaScript code you received from the services (e.g. Facebook, Twitter, AdWords) you want to use.
38+
39+
In the JavaScript snippet, there are places where you can use `order_number`, `order_total`, `order_subtotal`, `currency`, etc.
40+
41+
The plugin provides the following codes: <code>{customer_id}</code>, <code>{customer_email}</code>, <code>{customer_first_name}</code>, <code>{customer_last_name}</code>, <code>{order_number}</code>, <code>{order_total}</code>, <code>{order_subtotal}</code>, <code>{currency}</code>, <code>{payment_method}</code>.
42+
43+
Replace the script tag values with the suitable codes the plugin provides and finally insert the snippet in the boxes.
44+
3545
== Frequently Asked Questions ==
3646

3747
= Does it work with WooCommerce 2.x and 3.x? =
@@ -52,6 +62,12 @@ We put the JavaScript scripts provided by you in the page and it fires a convers
5262

5363
== Changelog ==
5464

65+
= Version 1.2.5 (28-December-2017) =
66+
67+
* Added plugin action links for Docs and Settings.
68+
* Added a survey for next version features.
69+
* Updated WooCommerce compatibility version tags.
70+
5571
= 1.2.4 - 01-Aug-2017 =
5672

5773
* [fix] The tracker option won't go away. Sorry!

0 commit comments

Comments
 (0)