WooCommerce Direct Checkout - Version 1.1.0

Version Description

Download this release

Release Info

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

Code changes from version 1.0.7 to 1.1.0

Files changed (6) hide show
  1. .project +11 -0
  2. readme.txt +23 -5
  3. screenshot-1.png +0 -0
  4. screenshot-3.png +0 -0
  5. wc-direct-checkout.php +317 -283
  6. wc-direct-checkout.pot +33 -8
.project ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
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>
readme.txt CHANGED
@@ -5,9 +5,9 @@ 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.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
 
@@ -20,6 +20,7 @@ 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 (Option to exclude external product)
24
  * Update "Redirect to Page" option
25
 
@@ -33,9 +34,13 @@ In WooCommerce Settings Panel, there will be a new submenu link called 'Direct C
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/)
@@ -56,6 +61,19 @@ http://terrytsang.com/shop/shop/woocommerce-direct-checkout-pro/
56
 
57
  == Changelog ==
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  = 1.0.7 =
60
 
61
  * Updated PRO version download link
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: 4.1
9
+ Stable tag: 1.0.10
10
+ Version: 1.0.10
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
 
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
+ * Add "Continue Shopping" button to product page
24
  * Change "Add to cart" to any text (Option to exclude external product)
25
  * Update "Redirect to Page" option
26
 
34
  * Please uncheck the option "Enable AJAX add to cart buttons on archives" at WooCommerce > Settings > Catalog to make the rediection working without ajax.
35
 
36
  = GET PRO VERSION =
37
+ [WooCommerce Direct Checkout PRO](http://terrytsang.com/shop/shop/woocommerce-direct-checkout-pro/)
38
 
39
+ * Added Additional Button Options (beside Add to Cart button)
40
+ * Per Product Basis Settings
41
+ * more features…
42
+
43
+ = Popular Plugins by Terry Tsang =
44
  * [Custom Checkout Options] (http://terrytsang.com/shop/shop/woocommerce-custom-checkout-options/)
45
  * [Social Buttons PRO] (http://terrytsang.com/shop/shop/woocommerce-social-buttons-pro/)
46
  * [Extra Fee Options PRO] (http://terrytsang.com/shop/shop/woocommerce-extra-fee-option-pro/)
61
 
62
  == Changelog ==
63
 
64
+ = 1.0.10 =
65
+
66
+ * Removed WooCommerce installation checking
67
+
68
+ = 1.0.9 =
69
+
70
+ * Fixed narrow form layout bugs
71
+
72
+ = 1.0.8 =
73
+
74
+ * Add Continue Shopping button at product page
75
+ * Fixed missing variable warning
76
+
77
  = 1.0.7 =
78
 
79
  * Updated PRO version download link
screenshot-1.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file
wc-direct-checkout.php CHANGED
@@ -3,7 +3,7 @@
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
  */
@@ -29,318 +29,352 @@ Author URI: http://shop.terrytsang.com
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
  ?>
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.10
7
  Author: Terry Tsang
8
  Author URI: http://shop.terrytsang.com
9
  */
29
  define('wc_plugin_name_direct_checkout', 'WooCommerce Direct Checkout');
30
 
31
  // Define plugin version
32
+ define('wc_version_direct_checkout', '1.0.10');
33
 
34
 
 
 
 
 
35
 
36
+ if(!class_exists('WooCommerce_Direct_Checkout')){
37
+ class WooCommerce_Direct_Checkout{
 
 
38
 
39
+ public static $plugin_prefix;
40
+ public static $plugin_url;
41
+ public static $plugin_path;
42
+ public static $plugin_basefile;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
+ /**
45
+ * Gets things started by adding an action to initialize this plugin once
46
+ * WooCommerce is known to be active and initialized
47
+ */
48
+ public function __construct(){
49
+ load_plugin_textdomain('wc-direct-checkout', false, dirname(plugin_basename(__FILE__)) . '/languages/');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
+ WooCommerce_Direct_Checkout::$plugin_prefix = 'wc_direct_checkout_';
52
+ WooCommerce_Direct_Checkout::$plugin_basefile = plugin_basename(__FILE__);
53
+ WooCommerce_Direct_Checkout::$plugin_url = plugin_dir_url(WooCommerce_Direct_Checkout::$plugin_basefile);
54
+ WooCommerce_Direct_Checkout::$plugin_path = trailingslashit(dirname(__FILE__));
 
 
 
 
 
 
 
55
 
56
+ $this->textdomain = 'wc-direct-checkout';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
+ $this->options_direct_checkout = array(
59
+ 'direct_checkout_enabled' => '',
60
+ 'direct_checkout_cart_button_text' => '',
61
+ 'direct_checkout_exclude_external' => '',
62
+ 'direct_checkout_cart_redirect_url' => '',
63
+ 'direct_checkout_continue_enabled' => ''
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('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
+ add_filter('woocommerce_product_single_add_to_cart_text', array( &$this, 'custom_cart_button_text') );
89
+ add_filter('woocommerce_product_add_to_cart_text', array( &$this, 'custom_cart_button_text') );
90
+
91
+ add_filter('woocommerce_add_to_cart_redirect', array( &$this, 'custom_add_to_cart_redirect') );
92
+
93
+ if(get_option('direct_checkout_continue_enabled'))
94
+ add_action( 'woocommerce_after_add_to_cart_button', array( &$this, 'direct_checkout_continue_button') );
95
+
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Set custom add to cart redirect
101
+ */
102
+ function custom_add_to_cart_redirect() {
103
+ $direct_checkout_cart_redirect_url = get_option( 'direct_checkout_cart_redirect_url' );
104
 
105
+ if($direct_checkout_cart_redirect_url != "")
106
+ return $direct_checkout_cart_redirect_url; // Replace with the url of your choosing
107
+ else
108
+ return get_permalink(get_option('woocommerce_checkout_page_id'));
109
+ }
110
+
111
+ /**
112
+ * Set continue shopping button for single product
113
+ */
114
+ function direct_checkout_continue_button() {
115
+ global $woocommerce, $post, $product;
116
+ global $wp_query;
117
+
118
+ $postID = $wp_query->post->ID;
119
 
120
+ $direct_checkout_continue_enabled = get_option( 'direct_checkout_continue_enabled' );
121
+ $single_product_title = strip_tags($post->post_title);
122
+
123
+ if($direct_checkout_continue_enabled == "1"){
124
+ $additional_button_text = __( 'Continue Shopping', $this->textdomain );
125
+ $additional_button_url = get_permalink(get_option('woocommerce_shop_page_id'));
126
+ }
127
+
128
+ $target_blank = $direct_checkout_continue_enabled ? '' : ' target="_blank"';
129
 
130
+ if( $direct_checkout_continue_enabled ){
131
+ $html_button = '<a href="'.$additional_button_url.'" title="'.$single_product_title.'" style="margin: 5px 0;" class="button alt"'.$target_blank.'>'.$additional_button_text.'</a>';
132
+ echo $html_button;
133
+ }
134
+ }
135
+
136
+ /**
137
+ * Set custom add to cart text
138
+ */
139
+ function custom_cart_button_text() {
140
+ global $post;
141
 
 
 
142
 
143
 
144
+ $direct_checkout_cart_button_text = get_option( 'direct_checkout_cart_button_text' ) ? get_option( 'direct_checkout_cart_button_text' ) : "Add to cart";
145
+ $direct_checkout_exclude_external = get_option( 'direct_checkout_exclude_external' );
146
 
147
+ if($direct_checkout_exclude_external){
 
 
 
148
 
149
+ if( function_exists('get_product') ){
150
+ $product = get_product( $post->ID );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
 
152
+ if( !$product->is_type( 'external' ) && $direct_checkout_cart_button_text && $direct_checkout_cart_button_text != ""){
153
+ return __($direct_checkout_cart_button_text, $this->textdomain);
154
+ } else {
155
+ $button_text = get_post_meta( $post->ID, '_button_text', true ) ? get_post_meta( $post->ID, '_button_text', true ) : 'Buy product';
156
+ return __($button_text, $this->textdomain);
157
+ }
158
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
 
160
+ } else {
161
+ if($direct_checkout_cart_button_text && $direct_checkout_cart_button_text != "")
162
+ return __($direct_checkout_cart_button_text, $this->textdomain);
163
  }
164
+
165
+ }
166
+
167
+ /**
168
+ * Add a menu link to the woocommerce section menu
169
+ */
170
+ function add_menu_direct_checkout() {
171
+ $wc_page = 'woocommerce';
172
+ $comparable_settings_page = add_submenu_page( $wc_page , __( 'Direct Checkout', $this->textdomain ), __( 'Direct Checkout', $this->textdomain ), 'manage_options', 'wc-direct-checkout', array(
173
+ &$this,
174
+ 'settings_page_direct_checkout'
175
+ ));
176
+ }
177
+
178
+ /**
179
+ * Create the settings page content
180
+ */
181
+ public function settings_page_direct_checkout() {
182
+
183
+ // If form was submitted
184
+ if ( isset( $_POST['submitted'] ) )
185
+ {
186
+ check_admin_referer( $this->textdomain );
187
+
188
+ $this->saved_options_direct_checkout['direct_checkout_enabled'] = ! isset( $_POST['direct_checkout_enabled'] ) ? '1' : $_POST['direct_checkout_enabled'];
189
+ $this->saved_options_direct_checkout['direct_checkout_continue_enabled'] = ! isset( $_POST['direct_checkout_continue_enabled'] ) ? '1' : $_POST['direct_checkout_continue_enabled'];
190
+ $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'];
191
+ $this->saved_options_direct_checkout['direct_checkout_exclude_external'] = ! isset( $_POST['direct_checkout_exclude_external'] ) ? '1' : $_POST['direct_checkout_exclude_external'];
192
+ $this->saved_options_direct_checkout['direct_checkout_cart_redirect_url'] = ! isset( $_POST['direct_checkout_cart_redirect_url'] ) ? '' : $_POST['direct_checkout_cart_redirect_url'];
193
+
194
  foreach($this->options_direct_checkout as $field => $value)
195
  {
196
+ $option_direct_checkout = get_option( $field );
197
+
198
+ if($option_direct_checkout != $this->saved_options_direct_checkout[$field])
199
+ update_option( $field, $this->saved_options_direct_checkout[$field] );
200
  }
201
 
202
+ // Show message
203
+ echo '<div id="message" class="updated fade"><p>' . __( 'You have saved WooCommerce Direct Checkout options.', $this->textdomain ) . '</p></div>';
204
  }
205
+
206
+ $direct_checkout_enabled = get_option( 'direct_checkout_enabled' );
207
+ $direct_checkout_continue_enabled = get_option( 'direct_checkout_continue_enabled' );
208
+ $direct_checkout_cart_button_text = get_option( 'direct_checkout_cart_button_text' ) ? get_option( 'direct_checkout_cart_button_text' ) : 'Add to Cart';
209
+ $direct_checkout_exclude_external = get_option( 'direct_checkout_exclude_external' );
210
+ $direct_checkout_cart_redirect_url = get_option( 'direct_checkout_cart_redirect_url' );
211
+
212
+ $checked_enabled = '';
213
+ $checked_enabled_exclude = '';
214
+ $checked_continue_enabled = '';
215
+
216
+ if($direct_checkout_enabled)
217
+ $checked_enabled = 'checked="checked"';
218
+
219
+ if($direct_checkout_exclude_external)
220
+ $checked_enabled_exclude = 'checked="checked"';
221
 
222
+ if($direct_checkout_continue_enabled)
223
+ $checked_continue_enabled = 'checked="checked"';
224
+
225
+ $actionurl = $_SERVER['REQUEST_URI'];
226
+ $nonce = wp_create_nonce( $this->textdomain );
227
+
228
+
229
+ // Configuration Page
230
+
231
+ ?>
232
+ <div id="icon-options-general" class="icon32"></div>
233
+ <h3><?php _e( 'Direct Checkout Options', $this->textdomain); ?></h3>
234
+
235
+
236
+ <table style="width:90%;padding:5px;border-collapse:separate;border-spacing:5px;vertical-align:top;">
237
+ <tr>
238
+ <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>
239
+ </tr>
240
+ <tr>
241
+ <td width="70%" style="vertical-align:top;">
242
+ <form action="<?php echo $actionurl; ?>" method="post">
243
+ <table>
244
+ <tbody>
245
+ <tr>
246
+ <td colspan="2">
247
+ <table class="widefat auto" cellspacing="2" cellpadding="5" border="0">
248
+ <tr>
249
+ <td width="30%"><?php _e( 'Enable', $this->textdomain ); ?></td>
250
+ <td>
251
+ <input class="checkbox" name="direct_checkout_enabled" id="direct_checkout_enabled" value="0" type="hidden">
252
+ <input class="checkbox" name="direct_checkout_enabled" id="direct_checkout_enabled" value="1" type="checkbox" <?php echo $checked_enabled; ?>>
253
+ </td>
254
+ </tr>
255
+ <tr>
256
+ <td width="30%"><?php _e( 'Add Continue Shopping Button', $this->textdomain ); ?></td>
257
+ <td>
258
+ <input class="checkbox" name="direct_checkout_continue_enabled" id="direct_checkout_continue_enabled" value="0" type="hidden">
259
+ <input class="checkbox" name="direct_checkout_continue_enabled" id="direct_checkout_continue_enabled" value="1" type="checkbox" <?php echo $checked_continue_enabled; ?>>
260
+ </td>
261
+ </tr>
262
+ <tr>
263
+ <td width="30%"><?php _e( 'Custom Add to Cart Text', $this->textdomain ); ?></td>
264
+ <td>
265
+ <input name="direct_checkout_cart_button_text" id="direct_checkout_cart_button_text" value="<?php echo $direct_checkout_cart_button_text; ?>" />
266
+ <input class="checkbox" name="direct_checkout_exclude_external" id="direct_checkout_exclude_external" value="0" type="hidden">
267
+ <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>
268
+ </td>
269
+ </tr>
270
+ <tr>
271
+ <td width="30%"><?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>
272
+ <td>
273
+ <select name="direct_checkout_cart_redirect_url">
274
+ <option value=""><?php echo esc_attr( __( 'Select page' ) ); ?></option>
275
+ <?php
276
+ $pages = get_pages();
277
+ foreach ( $pages as $page ) {
278
+ if($direct_checkout_cart_redirect_url == get_permalink( $page->ID ))
279
+ $option = '<option value="' . get_permalink( $page->ID ) . '" selected="selected">';
280
+ else
281
+ $option = '<option value="' . get_permalink( $page->ID ) . '">';
282
+ $option .= $page->post_title;
283
+ $option .= '</option>';
284
+ echo $option;
285
+ }
286
+ ?>
287
+ </select>
288
+ </td>
289
+ </tr>
290
+ </table>
291
+ </td>
292
+ </tr>
293
+ <tr>
294
+ <td colspan=2">
295
+ <input class="button-primary" type="submit" name="Save" value="<?php _e('Save Options', $this->textdomain); ?>" id="submitbutton" />
296
+ <input type="hidden" name="submitted" value="1" />
297
+ <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php echo $nonce; ?>" />
298
+ </td>
299
+ </tr>
300
+ </tbody>
301
+ </table>
302
+ </form>
303
+
304
+ </td>
305
 
306
+ <td width="30%" style="background:#ececec;padding:10px 5px;" valign="top">
307
+ <div style="float:left;width:200px;">
308
+ <a href="https://twitter.com/terrytsang811" class="twitter-follow-button" data-show-count="false" data-lang="en">Follow @terrytsang811</a>
309
+ <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>
310
+ </div>
311
+ <div>
312
+ <div id="fb-root"></div>
313
+ <script>(function(d, s, id) {
314
+ var js, fjs = d.getElementsByTagName(s)[0];
315
+ if (d.getElementById(id)) return;
316
+ js = d.createElement(s); js.id = id;
317
+ js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=354404357988395";
318
+ fjs.parentNode.insertBefore(js, fjs);
319
+ }(document, 'script', 'facebook-jssdk'));</script>
320
+ <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>
321
+ </div>
322
+ <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>
323
+
324
+ <?php
325
+ $get_pro_image = WooCommerce_Direct_Checkout::$plugin_url . '/images/direct-checkout-pro-version.png';
326
+ ?>
327
+ <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>
328
+ <div aling="center"><i>PRO version additional features: Individual product override settings and additional button option.</i></div>
329
+
330
+ <h3>Get More Plugins</h3>
331
 
332
+ <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>
333
+
334
+ <h3>Spreading the Word</h3>
335
+
336
+ <ul style="list-style:none">If you find this plugin helpful, you can:
337
+ <li>- Write and review about it in your blog</li>
338
+ <li>- Rate it on <a href="http://wordpress.org/extend/plugins/woocommerce-direct-checkout/" target="_blank">wordpress plugin page</a></li>
339
+ <li>- Share on your social media<br />
340
+ <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>
341
+ <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>
342
+ <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>
343
+ </li>
344
+ <li>- Or make a donation</li>
345
+ </ul>
346
+
347
+ <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>
348
+
349
+ <h3>Thank you for your support!</h3>
350
+ </td>
351
+
352
+ </tr>
353
+ </table>
354
+
355
+
356
+ <br />
357
+
358
+ <?php
359
  }
360
+
361
+ /**
362
+ * Get the setting options
363
+ */
364
+ function get_options() {
365
+
366
+ foreach($this->options_direct_checkout as $field => $value)
367
+ {
368
+ $array_options[$field] = get_option( $field );
369
+ }
370
+
371
+ return $array_options;
372
+ }
373
+
374
+
375
+ }//end class
376
+
377
+ }//if class does not exist
378
 
379
+ $woocommerce_direct_checkout = new WooCommerce_Direct_Checkout();
380
  ?>
wc-direct-checkout.pot CHANGED
@@ -1,9 +1,9 @@
1
  msgid ""
2
  msgstr ""
3
- "Project-Id-Version: WooCommerce Direct Checkout v1.0.0\n"
4
  "Report-Msgid-Bugs-To: \n"
5
  "POT-Creation-Date: \n"
6
- "PO-Revision-Date: 2013-07-10 15:54:14+0000\n"
7
  "Last-Translator: admin <terrytsang811@gmail.com>\n"
8
  "Language-Team: \n"
9
  "MIME-Version: 1.0\n"
@@ -19,33 +19,58 @@ msgstr ""
19
  "X-Poedit-SearchPath-0: .\n"
20
  "X-Textdomain-Support: yes"
21
 
22
- #: wc-direct-checkout.php:113
23
  #@ wc-direct-checkout
24
  msgid "Direct Checkout"
25
  msgstr ""
26
 
27
- #: wc-direct-checkout.php:141
28
  #@ wc-direct-checkout
29
  msgid "You have saved WooCommerce Direct Checkout options."
30
  msgstr ""
31
 
32
- #: wc-direct-checkout.php:161
33
  #@ wc-direct-checkout
34
  msgid "Direct Checkout Options"
35
  msgstr ""
36
 
37
- #: wc-direct-checkout.php:177
38
  #@ wc-direct-checkout
39
  msgid "Enable"
40
  msgstr ""
41
 
42
- #: wc-direct-checkout.php:184
43
  #@ wc-direct-checkout
44
  msgid "Custom Add to Cart Text"
45
  msgstr ""
46
 
47
- #: wc-direct-checkout.php:194
48
  #@ wc-direct-checkout
49
  msgid "Save Options"
50
  msgstr ""
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  msgid ""
2
  msgstr ""
3
+ "Project-Id-Version: WooCommerce Direct Checkout v1.0.8\n"
4
  "Report-Msgid-Bugs-To: \n"
5
  "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: 2014-07-07 17:40:21+0000\n"
7
  "Last-Translator: admin <terrytsang811@gmail.com>\n"
8
  "Language-Team: \n"
9
  "MIME-Version: 1.0\n"
19
  "X-Poedit-SearchPath-0: .\n"
20
  "X-Textdomain-Support: yes"
21
 
22
+ #: wc-direct-checkout.php:173
23
  #@ wc-direct-checkout
24
  msgid "Direct Checkout"
25
  msgstr ""
26
 
27
+ #: wc-direct-checkout.php:204
28
  #@ wc-direct-checkout
29
  msgid "You have saved WooCommerce Direct Checkout options."
30
  msgstr ""
31
 
32
+ #: wc-direct-checkout.php:234
33
  #@ wc-direct-checkout
34
  msgid "Direct Checkout Options"
35
  msgstr ""
36
 
37
+ #: wc-direct-checkout.php:250
38
  #@ wc-direct-checkout
39
  msgid "Enable"
40
  msgstr ""
41
 
42
+ #: wc-direct-checkout.php:264
43
  #@ wc-direct-checkout
44
  msgid "Custom Add to Cart Text"
45
  msgstr ""
46
 
47
+ #: wc-direct-checkout.php:296
48
  #@ wc-direct-checkout
49
  msgid "Save Options"
50
  msgstr ""
51
 
52
+ #: wc-direct-checkout.php:125
53
+ #@ wc-direct-checkout
54
+ msgid "Continue Shopping"
55
+ msgstr ""
56
+
57
+ #: wc-direct-checkout.php:257
58
+ #@ wc-direct-checkout
59
+ msgid "Add Continue Shopping Button"
60
+ msgstr ""
61
+
62
+ #: wc-direct-checkout.php:272
63
+ #@ wc-direct-checkout
64
+ msgid "Redirect to Page"
65
+ msgstr ""
66
+
67
+ #: wc-direct-checkout.php:272
68
+ #@ wc-direct-checkout
69
+ msgid "(Default will be checkout page if not set)"
70
+ msgstr ""
71
+
72
+ #: wc-direct-checkout.php:275
73
+ #@ default
74
+ msgid "Select page"
75
+ msgstr ""
76
+