WooCommerce Direct Checkout - Version 1.0.7

Version Description

  • Updated PRO version download link
Download this release

Release Info

Developer terrytsang
Plugin Icon 128x128 WooCommerce Direct Checkout
Version 1.0.7
Comparing to
See all releases

Code changes from version 1.0.3 to 1.0.7

.project DELETED
@@ -1,11 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <projectDescription>
3
- <name>woocommerce-direct-checkout</name>
4
- <comment></comment>
5
- <projects>
6
- </projects>
7
- <buildSpec>
8
- </buildSpec>
9
- <natures>
10
- </natures>
11
- </projectDescription>
 
 
 
 
 
 
 
 
 
 
 
images/direct-checkout-pro-version.png ADDED
Binary file
readme.txt CHANGED
@@ -5,13 +5,13 @@ Plugin Name: WooCommerce Custom Direct Checkout
5
  Plugin URI: http://terrytsang.com/shop/shop/woocommerce-direct-checkout/
6
  Tags: woocommerce, custom fields, direct, checkout, e-commerce
7
  Requires at least: 2.7
8
- Tested up to: 3.5.2
9
- Stable tag: 1.0.3
10
- Version: 1.0.3
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
14
- You can skip shopping cart page and implement add to cart button redirect to checkout page or you can redirect to other existing page. This can lead to an immediate increase in sales.
15
 
16
  == Description ==
17
 
@@ -20,8 +20,8 @@ A WooCommerce plugin that aims to simplify the checkout process, leading to an i
20
  In WooCommerce Settings Panel, there will be a new submenu link called 'Direct Checkout' where you can:
21
 
22
  * Enabled / Disabled the direct checkout option
23
- * Change "Add to cart" to any text
24
- * Update "Redirect to Page" option (NEW)
25
 
26
  = Features =
27
 
@@ -32,9 +32,13 @@ In WooCommerce Settings Panel, there will be a new submenu link called 'Direct C
32
  * Do use POEdit and open 'wc-direct-checkout.pot' file and save the file as wc-direct-checkout-[language code].po, then put that into languages folder for this plugin.
33
  * Please uncheck the option "Enable AJAX add to cart buttons on archives" at WooCommerce > Settings > Catalog to make the rediection working without ajax.
34
 
 
 
 
35
  = Additional Plugins by Terry Tsang =
36
  * [Custom Checkout Options] (http://terrytsang.com/shop/shop/woocommerce-custom-checkout-options/)
37
  * [Social Buttons PRO] (http://terrytsang.com/shop/shop/woocommerce-social-buttons-pro/)
 
38
 
39
 
40
  == Installation ==
@@ -52,6 +56,23 @@ In WooCommerce Settings Panel, there will be a new submenu link called 'Direct C
52
 
53
  == Changelog ==
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  = 1.0.3 =
56
 
57
  * Updated reademe file for instruction and notes
5
  Plugin URI: http://terrytsang.com/shop/shop/woocommerce-direct-checkout/
6
  Tags: woocommerce, custom fields, direct, checkout, e-commerce
7
  Requires at least: 2.7
8
+ Tested up to: 3.9.1
9
+ Stable tag: 1.0.7
10
+ Version: 1.0.7
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
14
+ You can skip shopping cart page and implement add to cart button redirect to checkout page or you can redirect to other existing page.
15
 
16
  == Description ==
17
 
20
  In WooCommerce Settings Panel, there will be a new submenu link called 'Direct Checkout' where you can:
21
 
22
  * Enabled / Disabled the direct checkout option
23
+ * Change "Add to cart" to any text (Option to exclude external product)
24
+ * Update "Redirect to Page" option
25
 
26
  = Features =
27
 
32
  * Do use POEdit and open 'wc-direct-checkout.pot' file and save the file as wc-direct-checkout-[language code].po, then put that into languages folder for this plugin.
33
  * Please uncheck the option "Enable AJAX add to cart buttons on archives" at WooCommerce > Settings > Catalog to make the rediection working without ajax.
34
 
35
+ = GET PRO VERSION =
36
+ http://terrytsang.com/shop/shop/woocommerce-direct-checkout-pro/
37
+
38
  = Additional Plugins by Terry Tsang =
39
  * [Custom Checkout Options] (http://terrytsang.com/shop/shop/woocommerce-custom-checkout-options/)
40
  * [Social Buttons PRO] (http://terrytsang.com/shop/shop/woocommerce-social-buttons-pro/)
41
+ * [Extra Fee Options PRO] (http://terrytsang.com/shop/shop/woocommerce-extra-fee-option-pro/)
42
 
43
 
44
  == Installation ==
56
 
57
  == Changelog ==
58
 
59
+ = 1.0.7 =
60
+
61
+ * Updated PRO version download link
62
+
63
+ = 1.0.6 =
64
+
65
+ * Added 'Exclude external product' checkbox for Custom Add to Cart Text option
66
+
67
+ = 1.0.5 =
68
+
69
+ * Updated "Add to cart" filter with WooCommere v2.1.x
70
+ * Fixed table width problem for option settings page
71
+
72
+ = 1.0.4 =
73
+
74
+ * Added pro version link
75
+
76
  = 1.0.3 =
77
 
78
  * Updated reademe file for instruction and notes
screenshot-1.png CHANGED
Binary file
wc-direct-checkout.php CHANGED
@@ -1,295 +1,346 @@
1
- <?php
2
- /*
3
- Plugin Name: WooCommerce Direct Checkout
4
- Plugin URI: http://terrytsang.com/shop/shop/woocommerce-direct-checkout/
5
- Description: Allow you to implement direct checkout (skip cart page) for WooCommerce
6
- Version: 1.0.3
7
- Author: Terry Tsang
8
- Author URI: http://shop.terrytsang.com
9
- */
10
-
11
- /* Copyright 2012-2013 Terry Tsang (email: terrytsang811@gmail.com)
12
-
13
- This program is free software; you can redistribute it and/or modify
14
- it under the terms of the GNU General Public License as published by
15
- the Free Software Foundation; either version 2 of the License, or
16
- (at your option) any later version.
17
-
18
- This program is distributed in the hope that it will be useful,
19
- but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
- GNU General Public License for more details.
22
-
23
- You should have received a copy of the GNU General Public License
24
- along with this program; if not, write to the Free Software
25
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
- */
27
-
28
- // Define plugin name
29
- define('wc_plugin_name_direct_checkout', 'WooCommerce Direct Checkout');
30
-
31
- // Define plugin version
32
- define('wc_version_direct_checkout', '1.0.3');
33
-
34
-
35
- // Checks if the WooCommerce plugins is installed and active.
36
- if(in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))){
37
- if(!class_exists('WooCommerce_Direct_Checkout')){
38
- class WooCommerce_Direct_Checkout{
39
-
40
- public static $plugin_prefix;
41
- public static $plugin_url;
42
- public static $plugin_path;
43
- public static $plugin_basefile;
44
-
45
- /**
46
- * Gets things started by adding an action to initialize this plugin once
47
- * WooCommerce is known to be active and initialized
48
- */
49
- public function __construct(){
50
- load_plugin_textdomain('wc-direct-checkout', false, dirname(plugin_basename(__FILE__)) . '/languages/');
51
-
52
- WooCommerce_Direct_Checkout::$plugin_prefix = 'wc_direct_checkout_';
53
- WooCommerce_Direct_Checkout::$plugin_basefile = plugin_basename(__FILE__);
54
- WooCommerce_Direct_Checkout::$plugin_url = plugin_dir_url(WooCommerce_Direct_Checkout::$plugin_basefile);
55
- WooCommerce_Direct_Checkout::$plugin_path = trailingslashit(dirname(__FILE__));
56
-
57
- $this->textdomain = 'wc-direct-checkout';
58
-
59
- $this->options_direct_checkout = array(
60
- 'direct_checkout_enabled' => '',
61
- 'direct_checkout_cart_button_text' => '',
62
- 'direct_checkout_cart_redirect_url' => ''
63
- );
64
-
65
- $this->saved_options_direct_checkout = array();
66
-
67
- add_action('woocommerce_init', array(&$this, 'init'));
68
- }
69
-
70
- /**
71
- * Initialize extension when WooCommerce is active
72
- */
73
- public function init(){
74
-
75
- //add menu link for the plugin (backend)
76
- add_action( 'admin_menu', array( &$this, 'add_menu_direct_checkout' ) );
77
-
78
- if(get_option('direct_checkout_enabled'))
79
- {
80
- //unset all related options to disabled / not active
81
- update_option('woocommerce_cart_redirect_after_add', 'no');
82
- update_option('woocommerce_enable_ajax_add_to_cart', 'no');
83
-
84
- add_filter('add_to_cart_redirect', array( &$this, 'custom_add_to_cart_redirect') );
85
- add_filter('single_add_to_cart_text', array( &$this, 'custom_cart_button_text') );
86
- add_filter('add_to_cart_text', array( &$this, 'custom_cart_button_text') );
87
- }
88
- }
89
-
90
- /**
91
- * Set custom add to cart redirect
92
- */
93
- function custom_add_to_cart_redirect() {
94
- $direct_checkout_cart_redirect_url = get_option( 'direct_checkout_cart_redirect_url' );
95
-
96
- if($direct_checkout_cart_redirect_url != "")
97
- return $direct_checkout_cart_redirect_url; // Replace with the url of your choosing
98
- else
99
- return get_permalink(get_option('woocommerce_checkout_page_id'));
100
- }
101
-
102
- /**
103
- * Set custom add to cart text
104
- */
105
- function custom_cart_button_text() {
106
- $direct_checkout_cart_button_text = get_option( 'direct_checkout_cart_button_text' ) ? get_option( 'direct_checkout_cart_button_text' ) : "Add to cart";
107
-
108
- if($direct_checkout_cart_button_text && $direct_checkout_cart_button_text != "")
109
- return __($direct_checkout_cart_button_text, $this->textdomain);
110
-
111
- }
112
-
113
- /**
114
- * Add a menu link to the woocommerce section menu
115
- */
116
- function add_menu_direct_checkout() {
117
- $wc_page = 'woocommerce';
118
- $comparable_settings_page = add_submenu_page( $wc_page , __( 'Direct Checkout', $this->textdomain ), __( 'Direct Checkout', $this->textdomain ), 'manage_options', 'wc-direct-checkout', array(
119
- &$this,
120
- 'settings_page_direct_checkout'
121
- ));
122
- }
123
-
124
- /**
125
- * Create the settings page content
126
- */
127
- public function settings_page_direct_checkout() {
128
-
129
- // If form was submitted
130
- if ( isset( $_POST['submitted'] ) )
131
- {
132
- check_admin_referer( $this->textdomain );
133
-
134
- $this->saved_options_direct_checkout['direct_checkout_enabled'] = ! isset( $_POST['direct_checkout_enabled'] ) ? '1' : $_POST['direct_checkout_enabled'];
135
- $this->saved_options_direct_checkout['direct_checkout_cart_button_text'] = ! isset( $_POST['direct_checkout_cart_button_text'] ) ? 'Add to cart' : $_POST['direct_checkout_cart_button_text'];
136
- $this->saved_options_direct_checkout['direct_checkout_cart_redirect_url'] = ! isset( $_POST['direct_checkout_cart_redirect_url'] ) ? '' : $_POST['direct_checkout_cart_redirect_url'];
137
-
138
- foreach($this->options_direct_checkout as $field => $value)
139
- {
140
- $option_direct_checkout = get_option( $field );
141
-
142
- if($option_direct_checkout != $this->saved_options_direct_checkout[$field])
143
- update_option( $field, $this->saved_options_direct_checkout[$field] );
144
- }
145
-
146
- // Show message
147
- echo '<div id="message" class="updated fade"><p>' . __( 'You have saved WooCommerce Direct Checkout options.', $this->textdomain ) . '</p></div>';
148
- }
149
-
150
- $direct_checkout_enabled = get_option( 'direct_checkout_enabled' );
151
- $direct_checkout_cart_button_text = get_option( 'direct_checkout_cart_button_text' ) ? get_option( 'direct_checkout_cart_button_text' ) : 'Add to Cart';
152
- $direct_checkout_cart_redirect_url = get_option( 'direct_checkout_cart_redirect_url' );
153
-
154
- $checked_enabled = '';
155
-
156
- if($direct_checkout_enabled)
157
- $checked_enabled = 'checked="checked"';
158
-
159
- $actionurl = $_SERVER['REQUEST_URI'];
160
- $nonce = wp_create_nonce( $this->textdomain );
161
-
162
-
163
- // Configuration Page
164
-
165
- ?>
166
- <div id="icon-options-general" class="icon32"></div>
167
- <h3><?php _e( 'Direct Checkout Options', $this->textdomain); ?></h3>
168
-
169
-
170
- <table style="width:90%;padding:5px;border-collapse:separate;border-spacing:5px;vertical-align:top;">
171
- <tr>
172
- <td colspan="2">Checking out is the most important and key part of placing an order online, and many users end up abandoning their order at the end. This plugin will simplify the checkout process, leading to an immediate increase in sales.</td>
173
- </tr>
174
- <tr>
175
- <td style="width:70%;vertical-align:top;">
176
- <form action="<?php echo $actionurl; ?>" method="post">
177
- <table>
178
- <tbody>
179
- <tr>
180
- <td colspan="2">
181
- <table class="widefat fixed" cellspacing="2" cellpadding="5" border="0">
182
- <tr>
183
- <td width="25%"><?php _e( 'Enable', $this->textdomain ); ?></td>
184
- <td>
185
- <input class="checkbox" name="direct_checkout_enabled" id="direct_checkout_enabled" value="0" type="hidden">
186
- <input class="checkbox" name="direct_checkout_enabled" id="direct_checkout_enabled" value="1" type="checkbox" <?php echo $checked_enabled; ?> type="checkbox">
187
- </td>
188
- </tr>
189
- <tr>
190
- <td width="25%"><?php _e( 'Custom Add to Cart Text', $this->textdomain ); ?></td>
191
- <td>
192
- <input name="direct_checkout_cart_button_text" id="direct_checkout_cart_button_text" value="<?php echo $direct_checkout_cart_button_text; ?>" />
193
- </td>
194
- </tr>
195
- <tr>
196
- <td width="25%"><?php _e( 'Redirect to Page', $this->textdomain ); ?><br /><span style="color:#ccc;"><?php _e( '(Default will be checkout page if not set)', $this->textdomain ); ?></span></td>
197
- <td>
198
- <select name="direct_checkout_cart_redirect_url">
199
- <option value=""><?php echo esc_attr( __( 'Select page' ) ); ?></option>
200
- <?php
201
- $pages = get_pages();
202
- foreach ( $pages as $page ) {
203
- if($direct_checkout_cart_redirect_url == get_permalink( $page->ID ))
204
- $option = '<option value="' . get_permalink( $page->ID ) . '" selected="selected">';
205
- else
206
- $option = '<option value="' . get_permalink( $page->ID ) . '">';
207
- $option .= $page->post_title;
208
- $option .= '</option>';
209
- echo $option;
210
- }
211
- ?>
212
- </select>
213
- </td>
214
- </tr>
215
- </table>
216
- </td>
217
- </tr>
218
- <tr>
219
- <td colspan=2">
220
- <input class="button-primary" type="submit" name="Save" value="<?php _e('Save Options', $this->textdomain); ?>" id="submitbutton" />
221
- <input type="hidden" name="submitted" value="1" />
222
- <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php echo $nonce; ?>" />
223
- </td>
224
- </tr>
225
- </tbody>
226
- </table>
227
- </form>
228
-
229
- </td>
230
-
231
- <td width="30%" style="background:#ececec;padding:10px 5px;" valign="top">
232
- <p><b>WooCommerce Direct Checkout</b> is a FREE woocommerce plugin developed by <a href="http://shop.terrytsang.com" target="_blank" title="Terry Tsang - a PHP Developer and Wordpress Consultant">Terry Tsang</a>. This plugin aims to add direct checkout for WooCommerce.</p>
233
-
234
- <h3>Get More Plugins</h3>
235
-
236
- <p><a href="http://shop.terrytsang.com" target="_blank" title="Premium &amp; Free Extensions/Plugins for E-Commerce by Terry Tsang">Go to My Site</a> to get more free and premium extensions/plugins for your ecommerce sites.</p>
237
-
238
- <h3>Spreading the Word</h3>
239
-
240
- <ul style="list-style:dash">If you find this plugin helpful, you can:
241
- <li>- Write and review about it in your blog</li>
242
- <li>- Rate it on <a href="http://wordpress.org/extend/plugins/woocommerce-direct-checkout/" target="_blank">wordpress plugin page</a></li>
243
- <li>- Share on your social media<br />
244
- <a href="http://www.facebook.com/sharer.php?u=http://terrytsang.com/shop/shop/woocommerce-direct-checkout/&amp;t=WooCommerce Direct Checkout" title="Share this WooCommerce Direct Checkout on Facebook" target="_blank"><img src="http://terrytsang.com/shop/images/social_facebook.png" alt="Share this WooCommerce Direct Checkout plugin on Facebook"></a>
245
- <a href="https://twitter.com/intent/tweet?url=http%3A%2F%2Fterrytsang.com%2Fshop%2Fshop%2Fwoocommerce-direct-checkout%2F&text=WooCommerce Direct Checkout - &via=terrytsang811" target="_blank"><img src="http://terrytsang.com/shop/images/social_twitter.png" alt="Tweet about WooCommerce Direct Checkout plugin"></a>
246
- <a href="http://linkedin.com/shareArticle?mini=true&amp;url=http://terrytsang.com/shop/shop/woocommerce-direct-checkout/&amp;title=WooCommerce Direct Checkout plugin" title="Share this WooCommerce Direct Checkout plugin on LinkedIn" target="_blank"><img src="http://terrytsang.com/shop/images/social_linkedin.png" alt="Share this WooCommerce Direct Checkout plugin on LinkedIn"></a>
247
- </li>
248
- <li>- Or make a donation</li>
249
- </ul>
250
-
251
- <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LJWSJDBBLNK7W" target="_blank"><img src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" alt="" /></a>
252
-
253
- <h3>Thank you for your support!</h3>
254
- </td>
255
-
256
- </tr>
257
- </table>
258
-
259
-
260
- <br />
261
-
262
- <?php
263
- }
264
-
265
- /**
266
- * Get the setting options
267
- */
268
- function get_options() {
269
-
270
- foreach($this->options_direct_checkout as $field => $value)
271
- {
272
- $array_options[$field] = get_option( $field );
273
- }
274
-
275
- return $array_options;
276
- }
277
-
278
-
279
- }//end class
280
-
281
- }//if class does not exist
282
-
283
- $woocommerce_direct_checkout = new WooCommerce_Direct_Checkout();
284
- }
285
- else{
286
- add_action('admin_notices', 'wc_direct_checkout_error_notice');
287
- function wc_direct_checkout_error_notice(){
288
- global $current_screen;
289
- if($current_screen->parent_base == 'plugins'){
290
- echo '<div class="error"><p>'.__(wc_plugin_name_direct_checkout.' requires <a href="http://www.woothemes.com/woocommerce/" target="_blank">WooCommerce</a> to be activated in order to work. Please install and activate <a href="'.admin_url('plugin-install.php?tab=search&type=term&s=WooCommerce').'" target="_blank">WooCommerce</a> first.').'</p></div>';
291
- }
292
- }
293
- }
294
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  ?>
1
+ <?php
2
+ /*
3
+ Plugin Name: WooCommerce Direct Checkout
4
+ Plugin URI: http://terrytsang.com/shop/shop/woocommerce-direct-checkout/
5
+ Description: Allow you to implement direct checkout (skip cart page) for WooCommerce
6
+ Version: 1.0.7
7
+ Author: Terry Tsang
8
+ Author URI: http://shop.terrytsang.com
9
+ */
10
+
11
+ /* Copyright 2012-2014 Terry Tsang (email: terrytsang811@gmail.com)
12
+
13
+ This program is free software; you can redistribute it and/or modify
14
+ it under the terms of the GNU General Public License as published by
15
+ the Free Software Foundation; either version 2 of the License, or
16
+ (at your option) any later version.
17
+
18
+ This program is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ GNU General Public License for more details.
22
+
23
+ You should have received a copy of the GNU General Public License
24
+ along with this program; if not, write to the Free Software
25
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
+ */
27
+
28
+ // Define plugin name
29
+ define('wc_plugin_name_direct_checkout', 'WooCommerce Direct Checkout');
30
+
31
+ // Define plugin version
32
+ define('wc_version_direct_checkout', '1.0.7');
33
+
34
+
35
+ // Checks if the WooCommerce plugins is installed and active.
36
+ if(in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))){
37
+ if(!class_exists('WooCommerce_Direct_Checkout')){
38
+ class WooCommerce_Direct_Checkout{
39
+
40
+ public static $plugin_prefix;
41
+ public static $plugin_url;
42
+ public static $plugin_path;
43
+ public static $plugin_basefile;
44
+
45
+ /**
46
+ * Gets things started by adding an action to initialize this plugin once
47
+ * WooCommerce is known to be active and initialized
48
+ */
49
+ public function __construct(){
50
+ load_plugin_textdomain('wc-direct-checkout', false, dirname(plugin_basename(__FILE__)) . '/languages/');
51
+
52
+ WooCommerce_Direct_Checkout::$plugin_prefix = 'wc_direct_checkout_';
53
+ WooCommerce_Direct_Checkout::$plugin_basefile = plugin_basename(__FILE__);
54
+ WooCommerce_Direct_Checkout::$plugin_url = plugin_dir_url(WooCommerce_Direct_Checkout::$plugin_basefile);
55
+ WooCommerce_Direct_Checkout::$plugin_path = trailingslashit(dirname(__FILE__));
56
+
57
+ $this->textdomain = 'wc-direct-checkout';
58
+
59
+ $this->options_direct_checkout = array(
60
+ 'direct_checkout_enabled' => '',
61
+ 'direct_checkout_cart_button_text' => '',
62
+ 'direct_checkout_exclude_external' => '',
63
+ 'direct_checkout_cart_redirect_url' => ''
64
+ );
65
+
66
+ $this->saved_options_direct_checkout = array();
67
+
68
+ add_action('woocommerce_init', array(&$this, 'init'));
69
+ }
70
+
71
+ /**
72
+ * Initialize extension when WooCommerce is active
73
+ */
74
+ public function init(){
75
+
76
+ //add menu link for the plugin (backend)
77
+ add_action( 'admin_menu', array( &$this, 'add_menu_direct_checkout' ) );
78
+
79
+ if(get_option('direct_checkout_enabled'))
80
+ {
81
+ //unset all related options to disabled / not active
82
+ update_option('woocommerce_cart_redirect_after_add', 'no');
83
+ update_option('woocommerce_enable_ajax_add_to_cart', 'no');
84
+
85
+ add_filter('add_to_cart_redirect', array( &$this, 'custom_add_to_cart_redirect') );
86
+ add_filter('single_add_to_cart_text', array( &$this, 'custom_cart_button_text') );
87
+ add_filter('add_to_cart_text', array( &$this, 'custom_cart_button_text') );
88
+
89
+ add_filter('woocommerce_product_single_add_to_cart_text', array( &$this, 'custom_cart_button_text') );
90
+ add_filter('woocommerce_product_add_to_cart_text', array( &$this, 'custom_cart_button_text') );
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Set custom add to cart redirect
96
+ */
97
+ function custom_add_to_cart_redirect() {
98
+ $direct_checkout_cart_redirect_url = get_option( 'direct_checkout_cart_redirect_url' );
99
+
100
+ if($direct_checkout_cart_redirect_url != "")
101
+ return $direct_checkout_cart_redirect_url; // Replace with the url of your choosing
102
+ else
103
+ return get_permalink(get_option('woocommerce_checkout_page_id'));
104
+ }
105
+
106
+ /**
107
+ * Set custom add to cart text
108
+ */
109
+ function custom_cart_button_text() {
110
+ global $post;
111
+
112
+
113
+
114
+ $direct_checkout_cart_button_text = get_option( 'direct_checkout_cart_button_text' ) ? get_option( 'direct_checkout_cart_button_text' ) : "Add to cart";
115
+ $direct_checkout_exclude_external = get_option( 'direct_checkout_exclude_external' );
116
+
117
+ if($direct_checkout_exclude_external){
118
+
119
+ if( function_exists('get_product') ){
120
+ $product = get_product( $post->ID );
121
+
122
+ if( !$product->is_type( 'external' ) && $direct_checkout_cart_button_text && $direct_checkout_cart_button_text != ""){
123
+ return __($direct_checkout_cart_button_text, $this->textdomain);
124
+ } else {
125
+ $button_text = get_post_meta( $post->ID, '_button_text', true ) ? get_post_meta( $post->ID, '_button_text', true ) : 'Buy product';
126
+ return __($button_text, $this->textdomain);
127
+ }
128
+ }
129
+
130
+ } else {
131
+ if($direct_checkout_cart_button_text && $direct_checkout_cart_button_text != "")
132
+ return __($direct_checkout_cart_button_text, $this->textdomain);
133
+ }
134
+
135
+ }
136
+
137
+ /**
138
+ * Add a menu link to the woocommerce section menu
139
+ */
140
+ function add_menu_direct_checkout() {
141
+ $wc_page = 'woocommerce';
142
+ $comparable_settings_page = add_submenu_page( $wc_page , __( 'Direct Checkout', $this->textdomain ), __( 'Direct Checkout', $this->textdomain ), 'manage_options', 'wc-direct-checkout', array(
143
+ &$this,
144
+ 'settings_page_direct_checkout'
145
+ ));
146
+ }
147
+
148
+ /**
149
+ * Create the settings page content
150
+ */
151
+ public function settings_page_direct_checkout() {
152
+
153
+ // If form was submitted
154
+ if ( isset( $_POST['submitted'] ) )
155
+ {
156
+ check_admin_referer( $this->textdomain );
157
+
158
+ $this->saved_options_direct_checkout['direct_checkout_enabled'] = ! isset( $_POST['direct_checkout_enabled'] ) ? '1' : $_POST['direct_checkout_enabled'];
159
+ $this->saved_options_direct_checkout['direct_checkout_cart_button_text'] = ! isset( $_POST['direct_checkout_cart_button_text'] ) ? 'Add to cart' : $_POST['direct_checkout_cart_button_text'];
160
+ $this->saved_options_direct_checkout['direct_checkout_exclude_external'] = ! isset( $_POST['direct_checkout_exclude_external'] ) ? '1' : $_POST['direct_checkout_exclude_external'];
161
+ $this->saved_options_direct_checkout['direct_checkout_cart_redirect_url'] = ! isset( $_POST['direct_checkout_cart_redirect_url'] ) ? '' : $_POST['direct_checkout_cart_redirect_url'];
162
+
163
+ foreach($this->options_direct_checkout as $field => $value)
164
+ {
165
+ $option_direct_checkout = get_option( $field );
166
+
167
+ if($option_direct_checkout != $this->saved_options_direct_checkout[$field])
168
+ update_option( $field, $this->saved_options_direct_checkout[$field] );
169
+ }
170
+
171
+ // Show message
172
+ echo '<div id="message" class="updated fade"><p>' . __( 'You have saved WooCommerce Direct Checkout options.', $this->textdomain ) . '</p></div>';
173
+ }
174
+
175
+ $direct_checkout_enabled = get_option( 'direct_checkout_enabled' );
176
+ $direct_checkout_cart_button_text = get_option( 'direct_checkout_cart_button_text' ) ? get_option( 'direct_checkout_cart_button_text' ) : 'Add to Cart';
177
+ $direct_checkout_exclude_external = get_option( 'direct_checkout_exclude_external' );
178
+ $direct_checkout_cart_redirect_url = get_option( 'direct_checkout_cart_redirect_url' );
179
+
180
+ $checked_enabled = '';
181
+
182
+ if($direct_checkout_enabled)
183
+ $checked_enabled = 'checked="checked"';
184
+
185
+ if($direct_checkout_exclude_external)
186
+ $checked_enabled_exclude = 'checked="checked"';
187
+
188
+ $actionurl = $_SERVER['REQUEST_URI'];
189
+ $nonce = wp_create_nonce( $this->textdomain );
190
+
191
+
192
+ // Configuration Page
193
+
194
+ ?>
195
+ <div id="icon-options-general" class="icon32"></div>
196
+ <h3><?php _e( 'Direct Checkout Options', $this->textdomain); ?></h3>
197
+
198
+
199
+ <table style="width:90%;padding:5px;border-collapse:separate;border-spacing:5px;vertical-align:top;">
200
+ <tr>
201
+ <td colspan="2">Checking out is the most important and key part of placing an order online, and many users end up abandoning their order at the end. This plugin will simplify the checkout process, leading to an immediate increase in sales.</td>
202
+ </tr>
203
+ <tr>
204
+ <td width="70%" style="vertical-align:top;">
205
+ <form action="<?php echo $actionurl; ?>" method="post">
206
+ <table>
207
+ <tbody>
208
+ <tr>
209
+ <td colspan="2">
210
+ <table class="widefat fixed" cellspacing="2" cellpadding="5" border="0">
211
+ <tr>
212
+ <td width="25%"><?php _e( 'Enable', $this->textdomain ); ?></td>
213
+ <td>
214
+ <input class="checkbox" name="direct_checkout_enabled" id="direct_checkout_enabled" value="0" type="hidden">
215
+ <input class="checkbox" name="direct_checkout_enabled" id="direct_checkout_enabled" value="1" type="checkbox" <?php echo $checked_enabled; ?> type="checkbox">
216
+ </td>
217
+ </tr>
218
+ <tr>
219
+ <td width="25%"><?php _e( 'Custom Add to Cart Text', $this->textdomain ); ?></td>
220
+ <td>
221
+ <input name="direct_checkout_cart_button_text" id="direct_checkout_cart_button_text" value="<?php echo $direct_checkout_cart_button_text; ?>" />
222
+ <input class="checkbox" name="direct_checkout_exclude_external" id="direct_checkout_exclude_external" value="0" type="hidden">
223
+ <input class="checkbox" name="direct_checkout_exclude_external" id="direct_checkout_exclude_external" value="1" type="checkbox" <?php echo $checked_enabled_exclude; ?> type="checkbox">&nbsp;<i>Exclude External Product</i>
224
+ </td>
225
+ </tr>
226
+ <tr>
227
+ <td width="25%"><?php _e( 'Redirect to Page', $this->textdomain ); ?><br /><span style="color:#ccc;"><?php _e( '(Default will be checkout page if not set)', $this->textdomain ); ?></span></td>
228
+ <td>
229
+ <select name="direct_checkout_cart_redirect_url">
230
+ <option value=""><?php echo esc_attr( __( 'Select page' ) ); ?></option>
231
+ <?php
232
+ $pages = get_pages();
233
+ foreach ( $pages as $page ) {
234
+ if($direct_checkout_cart_redirect_url == get_permalink( $page->ID ))
235
+ $option = '<option value="' . get_permalink( $page->ID ) . '" selected="selected">';
236
+ else
237
+ $option = '<option value="' . get_permalink( $page->ID ) . '">';
238
+ $option .= $page->post_title;
239
+ $option .= '</option>';
240
+ echo $option;
241
+ }
242
+ ?>
243
+ </select>
244
+ </td>
245
+ </tr>
246
+ </table>
247
+ </td>
248
+ </tr>
249
+ <tr>
250
+ <td colspan=2">
251
+ <input class="button-primary" type="submit" name="Save" value="<?php _e('Save Options', $this->textdomain); ?>" id="submitbutton" />
252
+ <input type="hidden" name="submitted" value="1" />
253
+ <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php echo $nonce; ?>" />
254
+ </td>
255
+ </tr>
256
+ </tbody>
257
+ </table>
258
+ </form>
259
+
260
+ </td>
261
+
262
+ <td width="30%" style="background:#ececec;padding:10px 5px;" valign="top">
263
+ <div style="float:left;width:200px;">
264
+ <a href="https://twitter.com/terrytsang811" class="twitter-follow-button" data-show-count="false" data-lang="en">Follow @terrytsang811</a>
265
+ <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
266
+ </div>
267
+ <div>
268
+ <div id="fb-root"></div>
269
+ <script>(function(d, s, id) {
270
+ var js, fjs = d.getElementsByTagName(s)[0];
271
+ if (d.getElementById(id)) return;
272
+ js = d.createElement(s); js.id = id;
273
+ js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=354404357988395";
274
+ fjs.parentNode.insertBefore(js, fjs);
275
+ }(document, 'script', 'facebook-jssdk'));</script>
276
+ <div class="fb-like" data-href="http://wordpress.org/plugins/woocommerce-direct-checkout/" data-layout="button" data-action="like" data-show-faces="false" data-share="false"></div>
277
+ </div>
278
+ <p><b>WooCommerce Direct Checkout</b> is a FREE woocommerce plugin developed by <a href="http://shop.terrytsang.com" target="_blank" title="Terry Tsang - a PHP Developer and Wordpress Consultant">Terry Tsang</a>. This plugin aims to add direct checkout for WooCommerce.</p>
279
+
280
+ <?php
281
+ $get_pro_image = WooCommerce_Direct_Checkout::$plugin_url . '/images/direct-checkout-pro-version.png';
282
+ ?>
283
+ <div align="center"><a href="http://terrytsang.com/shop/shop/woocommerce-direct-checkout-pro/" target="_blank" title="WooCommerce Direct Checkout PRO"><img src="<?php echo $get_pro_image; ?>" border="0" /></a></div>
284
+
285
+ <h3>Get More Plugins</h3>
286
+
287
+ <p><a href="http://shop.terrytsang.com" target="_blank" title="Premium &amp; Free Extensions/Plugins for E-Commerce by Terry Tsang">Go to My Site</a> to get more free and premium extensions/plugins for your ecommerce sites.</p>
288
+
289
+ <h3>Spreading the Word</h3>
290
+
291
+ <ul style="list-style:dash">If you find this plugin helpful, you can:
292
+ <li>- Write and review about it in your blog</li>
293
+ <li>- Rate it on <a href="http://wordpress.org/extend/plugins/woocommerce-direct-checkout/" target="_blank">wordpress plugin page</a></li>
294
+ <li>- Share on your social media<br />
295
+ <a href="http://www.facebook.com/sharer.php?u=http://terrytsang.com/shop/shop/woocommerce-direct-checkout/&amp;t=WooCommerce Direct Checkout" title="Share this WooCommerce Direct Checkout on Facebook" target="_blank"><img src="http://terrytsang.com/shop/images/social_facebook.png" alt="Share this WooCommerce Direct Checkout plugin on Facebook"></a>
296
+ <a href="https://twitter.com/intent/tweet?url=http%3A%2F%2Fterrytsang.com%2Fshop%2Fshop%2Fwoocommerce-direct-checkout%2F&text=WooCommerce Direct Checkout - &via=terrytsang811" target="_blank"><img src="http://terrytsang.com/shop/images/social_twitter.png" alt="Tweet about WooCommerce Direct Checkout plugin"></a>
297
+ <a href="http://linkedin.com/shareArticle?mini=true&amp;url=http://terrytsang.com/shop/shop/woocommerce-direct-checkout/&amp;title=WooCommerce Direct Checkout plugin" title="Share this WooCommerce Direct Checkout plugin on LinkedIn" target="_blank"><img src="http://terrytsang.com/shop/images/social_linkedin.png" alt="Share this WooCommerce Direct Checkout plugin on LinkedIn"></a>
298
+ </li>
299
+ <li>- Or make a donation</li>
300
+ </ul>
301
+
302
+ <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LJWSJDBBLNK7W" target="_blank"><img src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" border="0" alt="" /></a>
303
+
304
+ <h3>Thank you for your support!</h3>
305
+ </td>
306
+
307
+ </tr>
308
+ </table>
309
+
310
+
311
+ <br />
312
+
313
+ <?php
314
+ }
315
+
316
+ /**
317
+ * Get the setting options
318
+ */
319
+ function get_options() {
320
+
321
+ foreach($this->options_direct_checkout as $field => $value)
322
+ {
323
+ $array_options[$field] = get_option( $field );
324
+ }
325
+
326
+ return $array_options;
327
+ }
328
+
329
+
330
+ }//end class
331
+
332
+ }//if class does not exist
333
+
334
+ $woocommerce_direct_checkout = new WooCommerce_Direct_Checkout();
335
+ }
336
+ else{
337
+ add_action('admin_notices', 'wc_direct_checkout_error_notice');
338
+ function wc_direct_checkout_error_notice(){
339
+ global $current_screen;
340
+ if($current_screen->parent_base == 'plugins'){
341
+ echo '<div class="error"><p>'.__(wc_plugin_name_direct_checkout.' requires <a href="http://www.woothemes.com/woocommerce/" target="_blank">WooCommerce</a> to be activated in order to work. Please install and activate <a href="'.admin_url('plugin-install.php?tab=search&type=term&s=WooCommerce').'" target="_blank">WooCommerce</a> first.').'</p></div>';
342
+ }
343
+ }
344
+ }
345
+
346
  ?>