WooCommerce Direct Checkout - Version 2.2.9

Version Description

  • Fix: WooCommerce Ajax add to cart grouped products
Download this release

Release Info

Developer quadlayers
Plugin Icon 128x128 WooCommerce Direct Checkout
Version 2.2.9
Comparing to
See all releases

Code changes from version 2.2.8 to 2.2.9

includes/backend.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class QLWCDC_Backend {
4
+
5
+ protected static $_instance;
6
+
7
+ public function __construct() {
8
+ $this->init();
9
+ }
10
+
11
+ public static function instance() {
12
+ if (is_null(self::$_instance)) {
13
+ self::$_instance = new self();
14
+ }
15
+ return self::$_instance;
16
+ }
17
+
18
+ private function init() {
19
+ add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 99);
20
+ add_filter('woocommerce_settings_tabs_array', array($this, 'add_tab'), 50);
21
+ add_action('admin_menu', array(&$this, 'add_menu'));
22
+ add_action('admin_footer', array($this, 'remove_premium'));
23
+ }
24
+
25
+ public function enqueue_scripts() {
26
+
27
+ QLWCDC::instance()->register_scripts();
28
+
29
+ wp_enqueue_script(QLWCDC_PREFIX . '-admin');
30
+ }
31
+
32
+ public function add_tab($settings_tabs) {
33
+ $settings_tabs[QLWCDC_PREFIX] = esc_html__('Direct Checkout', 'woocommerce-direct-checkout');
34
+ return $settings_tabs;
35
+ }
36
+
37
+ public function add_menu() {
38
+ add_submenu_page('woocommerce', esc_html__('Direct Checkout', 'woocommerce-direct-checkout'), esc_html__('Direct Checkout', 'woocommerce-direct-checkout'), 'manage_woocommerce', admin_url('admin.php?page=wc-settings&tab=' . sanitize_title(QLWCDC_PREFIX)));
39
+ }
40
+
41
+ public function remove_premium() {
42
+ ?>
43
+ <script>
44
+ (function ($) {
45
+ 'use strict';
46
+ $(window).on('load', function (e) {
47
+ $('#qlwcdc_options').css({'opacity': '0.5', 'pointer-events': 'none'});
48
+ $('label[for=qlwcdc_add_product_ajax]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
49
+ $('label[for=qlwcdc_add_checkout_cart]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
50
+ $('label[for=qlwcdc_add_checkout_cart_fields]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
51
+ $('label[for=qlwcdc_add_checkout_cart_class]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
52
+ $('label[for=qlwcdc_remove_checkout_columns]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
53
+ $('label[for=qlwcdc_remove_checkout_coupon_form]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
54
+ $('label[for=qlwcdc_remove_order_details_address]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
55
+ $('label[for=qlwcdc_add_product_quick_purchase]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
56
+ $('label[for=qlwcdc_add_product_quick_purchase_to]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
57
+ $('label[for=qlwcdc_add_product_quick_purchase_qty]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
58
+ $('label[for=qlwcdc_add_product_quick_purchase_class]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
59
+ $('label[for=qlwcdc_add_product_quick_purchase_text]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
60
+ $('label[for=qlwcdc_add_product_default_attributes]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
61
+ $('label[for=qlwcdc_add_archive_quick_view]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
62
+ });
63
+ }(jQuery));
64
+ </script>
65
+ <?php
66
+
67
+ }
68
+
69
+ }
70
+
71
+ QLWCDC_Backend::instance();
includes/frontend.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class QLWCDC_Frontend {
4
+
5
+ protected static $_instance;
6
+
7
+ public function __construct() {
8
+ $this->init();
9
+ }
10
+
11
+ public static function instance() {
12
+ if (is_null(self::$_instance)) {
13
+ self::$_instance = new self();
14
+ }
15
+ return self::$_instance;
16
+ }
17
+
18
+ private function init() {
19
+ add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 99);
20
+ }
21
+
22
+ public function enqueue_scripts() {
23
+
24
+ QLWCDC::instance()->register_scripts();
25
+
26
+ wp_enqueue_style(QLWCDC_PREFIX);
27
+ wp_enqueue_script(QLWCDC_PREFIX);
28
+ }
29
+
30
+ }
31
+
32
+ QLWCDC_Frontend::instance();
includes/install.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class QLWCDC_Install {
4
+
5
+ protected static $_instance;
6
+
7
+ public function __construct() {
8
+ register_activation_hook(QLWCDC_PLUGIN_FILE, array(__CLASS__, 'activation'));
9
+ register_deactivation_hook(QLWCDC_PLUGIN_FILE, array(__CLASS__, 'deactivation'));
10
+ self::import_old_settings();
11
+ }
12
+
13
+ public static function instance() {
14
+ if (is_null(self::$_instance)) {
15
+ self::$_instance = new self();
16
+ }
17
+ return self::$_instance;
18
+ }
19
+
20
+ public static function activation() {
21
+ self::add_transient();
22
+ self::add_settings();
23
+ }
24
+
25
+ public static function deactivation() {
26
+
27
+ }
28
+
29
+ private static function add_transient() {
30
+ set_transient('qlwcdc-first-rating', true, MONTH_IN_SECONDS);
31
+ }
32
+
33
+ private static function add_settings() {
34
+ if ('yes' === get_option('woocommerce_cart_redirect_after_add')) {
35
+ add_option('qlwcdc_add_to_cart', 'redirect');
36
+ add_option('qlwcdc_add_to_cart_redirect_page', 'cart');
37
+ }
38
+ }
39
+
40
+ public static function import_old_settings() {
41
+
42
+ global $wpdb;
43
+
44
+ if (!get_option('qlwcdc_wcd_imported2')) {
45
+
46
+ if (get_option('direct_checkout_pro_enabled', get_option('direct_checkout_enabled'))) {
47
+
48
+ $url = get_option('direct_checkout_pro_cart_redirect_url', get_option('direct_checkout_cart_redirect_url'));
49
+
50
+ if ($url === wc_get_cart_url()) {
51
+ $val = 'cart';
52
+ } elseif (filter_var($url, FILTER_VALIDATE_URL) !== false && $url != wc_get_checkout_url()) {
53
+ $val = 'url';
54
+ } else {
55
+ $val = 'checkout';
56
+ }
57
+
58
+ /* add_option('qlwcdc_add_product_cart', 'redirect');
59
+ add_option('qlwcdc_add_product_cart_redirect_page', $val);
60
+ add_option('qlwcdc_add_product_cart_redirect_url', $url);
61
+
62
+ add_option('qlwcdc_add_archive_cart', 'redirect');
63
+ add_option('qlwcdc_add_archive_cart_redirect_page', $val);
64
+ add_option('qlwcdc_add_archive_cart_redirect_url', $url); */
65
+
66
+ add_option('qlwcdc_add_to_cart', 'redirect');
67
+ add_option('qlwcdc_add_to_cart_redirect_page', $val);
68
+ add_option('qlwcdc_add_to_cart_redirect_url', $url);
69
+ }
70
+
71
+ if ($text = get_option('direct_checkout_cart_button_text', get_option('direct_checkout_cart_button_text'))) {
72
+ add_option('qlwcdc_add_product_text', 'yes');
73
+ add_option('qlwcdc_add_product_text_content', $text);
74
+ add_option('qlwcdc_add_archive_text', 'yes');
75
+ add_option('qlwcdc_add_archive_text_content', $text);
76
+ add_option('qlwcdc_add_archive_text_in', array(
77
+ 'simple',
78
+ 'grouped',
79
+ 'virtual',
80
+ 'variable',
81
+ 'downloadable'
82
+ ));
83
+ }
84
+
85
+ if (count($keys = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s", '_direct_checkout_pro_enabled')))) {
86
+ foreach ($keys as $key) {
87
+ if ($key->meta_value == 'yes') {
88
+ if ($text = get_post_meta($key->post_id, '_direct_checkout_pro_cart_button_text', true)) {
89
+ add_post_meta($key->post_id, 'qlwcdc_add_product_text', 'yes', true);
90
+ add_post_meta($key->post_id, 'qlwcdc_add_product_text_content', $text, true);
91
+ }
92
+ }
93
+ }
94
+ }
95
+
96
+ delete_option('qlwcdc_wcd_imported');
97
+ update_option('qlwcdc_wcd_imported2', true);
98
+ }
99
+ }
100
+
101
+ }
102
+
103
+ QLWCDC_Install::instance();
includes/notices.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class QLWCDC_Notices {
4
+
5
+ protected static $_instance;
6
+
7
+ public function __construct() {
8
+ $this->init();
9
+ }
10
+
11
+ public static function instance() {
12
+ if (is_null(self::$_instance)) {
13
+ self::$_instance = new self();
14
+ }
15
+ return self::$_instance;
16
+ }
17
+
18
+ private function init() {
19
+ add_action('wp_ajax_qlwcdc_dismiss_notice', array($this, 'ajax_dismiss_notice'));
20
+ add_action('admin_notices', array($this, 'add_notices'));
21
+ add_filter('plugin_action_links_' . plugin_basename(QLWCDC_PLUGIN_FILE), array($this, 'add_action_links'));
22
+ }
23
+
24
+ public function ajax_dismiss_notice() {
25
+
26
+ if (check_admin_referer('qlwcdc_dismiss_notice', 'nonce') && isset($_REQUEST['notice_id'])) {
27
+
28
+ $notice_id = sanitize_key($_REQUEST['notice_id']);
29
+
30
+ update_user_meta(get_current_user_id(), $notice_id, true);
31
+
32
+ wp_send_json($notice_id);
33
+ }
34
+
35
+ wp_die();
36
+ }
37
+
38
+ public function add_notices() {
39
+
40
+ if (!get_transient('qlwcdc-first-rating') && !get_user_meta(get_current_user_id(), 'qlwcdc-user-rating', true)) {
41
+ ?>
42
+ <div id="qlwcdc-admin-rating" class="qlwcdc-notice notice is-dismissible" data-notice_id="qlwcdc-user-rating">
43
+ <div class="notice-container" style="padding-top: 10px; padding-bottom: 10px; display: flex; justify-content: left; align-items: center;">
44
+ <div class="notice-image">
45
+ <img style="border-radius:50%;max-width: 90px;" src="<?php echo plugins_url('/assets/backend/img/logo.jpg', QLWCDC_PLUGIN_FILE); ?>" alt="<?php echo esc_html(QLWCDC_PLUGIN_NAME); ?>>">
46
+ </div>
47
+ <div class="notice-content" style="margin-left: 15px;">
48
+ <p>
49
+ <?php printf(esc_html__('Hello! Thank you for choosing the %s plugin!', 'woocommerce-direct-checkout'), QLWCDC_PLUGIN_NAME); ?>
50
+ <br/>
51
+ <?php esc_html_e('Could you please give it a 5-star rating on WordPress? We know its a big favor, but we\'ve worked very much and very hard to release this great product. Your feedback will boost our motivation and help us promote and continue to improve this product.', 'woocommerce-direct-checkout'); ?>
52
+ </p>
53
+ <a href="<?php echo esc_url(QLWCDC_REVIEW_URL); ?>" class="button-primary" target="_blank">
54
+ <?php esc_html_e('Yes, of course!', 'woocommerce-direct-checkout'); ?>
55
+ </a>
56
+ <a href="<?php echo esc_url(QLWCDC_SUPPORT_URL); ?>" class="button-secondary" target="_blank">
57
+ <?php esc_html_e('Report a bug', 'woocommerce-direct-checkout'); ?>
58
+ </a>
59
+ </div>
60
+ </div>
61
+ </div>
62
+ <script>
63
+ (function ($) {
64
+ $('.qlwcdc-notice').on('click', '.notice-dismiss', function (e) {
65
+ e.preventDefault();
66
+ var notice_id = $(e.delegateTarget).data('notice_id');
67
+ $.ajax({
68
+ type: 'POST',
69
+ url: ajaxurl,
70
+ data: {
71
+ notice_id: notice_id,
72
+ action: 'qlwcdc_dismiss_notice',
73
+ nonce: '<?php echo wp_create_nonce('qlwcdc_dismiss_notice'); ?>'
74
+ },
75
+ success: function (response) {
76
+ console.log(response);
77
+ },
78
+ });
79
+ });
80
+ })(jQuery);
81
+ </script>
82
+ <?php
83
+ }
84
+ }
85
+
86
+ public function add_action_links($links) {
87
+
88
+ $links[] = '<a target="_blank" href="' . QLWCDC_PURCHASE_URL . '">' . esc_html__('Premium', 'woocommerce-direct-checkout') . '</a>';
89
+ $links[] = '<a href="' . admin_url('admin.php?page=wc-settings&tab=' . sanitize_title(QLWCDC_PREFIX)) . '">' . esc_html__('Settings', 'woocommerce-direct-checkout') . '</a>';
90
+
91
+ return $links;
92
+ }
93
+
94
+ }
95
+
96
+ QLWCDC_Notices::instance();
includes/products.php CHANGED
@@ -155,7 +155,7 @@ if (!class_exists('QLWCDC_Products')) {
155
  'yes' => esc_html__('Yes', 'woocommerce-direct-checkout'),
156
  'no' => esc_html__('No', 'woocommerce-direct-checkout'),
157
  ),
158
- 'value' => $this->get_product_option($thepostid, 'qlwcdc_add_product_text', 'no'),
159
  ),
160
  array(
161
  'label' => esc_html__('Replace Add to cart text content', 'woocommerce-direct-checkout'),
@@ -164,7 +164,7 @@ if (!class_exists('QLWCDC_Products')) {
164
  'id' => 'qlwcdc_add_product_text_content',
165
  'type' => 'text',
166
  'placeholder' => get_option('qlwcdc_add_product_text_content'),
167
- 'value' => $this->get_product_option($thepostid, 'qlwcdc_add_product_text_content'),
168
  ),
169
  'start_group',
170
  'end_group',
@@ -179,7 +179,7 @@ if (!class_exists('QLWCDC_Products')) {
179
  'yes' => esc_html__('Yes', 'woocommerce-direct-checkout'),
180
  'no' => esc_html__('No', 'woocommerce-direct-checkout'),
181
  ),
182
- 'value' => $this->get_product_option($thepostid, 'qlwcdc_add_product_quick_purchase', 'no')
183
  ),
184
  array(
185
  'label' => esc_html__('Add quick purchase class', 'woocommerce-direct-checkout'),
@@ -188,7 +188,7 @@ if (!class_exists('QLWCDC_Products')) {
188
  'id' => 'qlwcdc_add_product_quick_purchase_class',
189
  'type' => 'text',
190
  'placeholder' => get_option('qlwcdc_add_product_quick_purchase_class'),
191
- 'value' => $this->get_product_option($thepostid, 'qlwcdc_add_product_quick_purchase_class'),
192
  ),
193
  array(
194
  'label' => esc_html__('Add quick purchase text', 'woocommerce-direct-checkout'),
@@ -197,7 +197,7 @@ if (!class_exists('QLWCDC_Products')) {
197
  'id' => 'qlwcdc_add_product_quick_purchase_text',
198
  'type' => 'text',
199
  'placeholder' => get_option('qlwcdc_add_product_quick_purchase_text'),
200
- 'value' => $this->get_product_option($thepostid, 'qlwcdc_add_product_quick_purchase_text'),
201
  ),
202
  array(
203
  'label' => esc_html__('Redirect quick purchase to', 'woocommerce-direct-checkout'),
@@ -209,7 +209,7 @@ if (!class_exists('QLWCDC_Products')) {
209
  'cart' => esc_html__('Cart', 'woocommerce-direct-checkout'),
210
  'checkout' => esc_html__('Checkout', 'woocommerce-direct-checkout'),
211
  ),
212
- 'value' => $this->get_product_option($thepostid, 'qlwcdc_add_product_quick_purchase_to', 'checkout'),
213
  ),
214
  'end_group',
215
  );
@@ -267,8 +267,8 @@ if (!class_exists('QLWCDC_Products')) {
267
 
268
  function add_product_text($text, $product) {
269
 
270
- if ('yes' === $this->get_product_option($product->get_id(), 'qlwcdc_add_product_text')) {
271
- $text = esc_html__($this->get_product_option($product->get_id(), 'qlwcdc_add_product_text_content'), $text);
272
  }
273
 
274
  return $text;
155
  'yes' => esc_html__('Yes', 'woocommerce-direct-checkout'),
156
  'no' => esc_html__('No', 'woocommerce-direct-checkout'),
157
  ),
158
+ 'value' => QLWCDC::instance()->get_product_option($thepostid, 'qlwcdc_add_product_text', 'no'),
159
  ),
160
  array(
161
  'label' => esc_html__('Replace Add to cart text content', 'woocommerce-direct-checkout'),
164
  'id' => 'qlwcdc_add_product_text_content',
165
  'type' => 'text',
166
  'placeholder' => get_option('qlwcdc_add_product_text_content'),
167
+ 'value' => QLWCDC::instance()->get_product_option($thepostid, 'qlwcdc_add_product_text_content'),
168
  ),
169
  'start_group',
170
  'end_group',
179
  'yes' => esc_html__('Yes', 'woocommerce-direct-checkout'),
180
  'no' => esc_html__('No', 'woocommerce-direct-checkout'),
181
  ),
182
+ 'value' => QLWCDC::instance()->get_product_option($thepostid, 'qlwcdc_add_product_quick_purchase', 'no')
183
  ),
184
  array(
185
  'label' => esc_html__('Add quick purchase class', 'woocommerce-direct-checkout'),
188
  'id' => 'qlwcdc_add_product_quick_purchase_class',
189
  'type' => 'text',
190
  'placeholder' => get_option('qlwcdc_add_product_quick_purchase_class'),
191
+ 'value' => QLWCDC::instance()->get_product_option($thepostid, 'qlwcdc_add_product_quick_purchase_class'),
192
  ),
193
  array(
194
  'label' => esc_html__('Add quick purchase text', 'woocommerce-direct-checkout'),
197
  'id' => 'qlwcdc_add_product_quick_purchase_text',
198
  'type' => 'text',
199
  'placeholder' => get_option('qlwcdc_add_product_quick_purchase_text'),
200
+ 'value' => QLWCDC::instance()->get_product_option($thepostid, 'qlwcdc_add_product_quick_purchase_text'),
201
  ),
202
  array(
203
  'label' => esc_html__('Redirect quick purchase to', 'woocommerce-direct-checkout'),
209
  'cart' => esc_html__('Cart', 'woocommerce-direct-checkout'),
210
  'checkout' => esc_html__('Checkout', 'woocommerce-direct-checkout'),
211
  ),
212
+ 'value' => QLWCDC::instance()->get_product_option($thepostid, 'qlwcdc_add_product_quick_purchase_to', 'checkout'),
213
  ),
214
  'end_group',
215
  );
267
 
268
  function add_product_text($text, $product) {
269
 
270
+ if ('yes' === QLWCDC::instance()->get_product_option($product->get_id(), 'qlwcdc_add_product_text')) {
271
+ $text = esc_html__(QLWCDC::instance()->get_product_option($product->get_id(), 'qlwcdc_add_product_text_content'), $text);
272
  }
273
 
274
  return $text;
includes/qlwcdc.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class QLWCDC {
4
+
5
+ protected static $instance;
6
+
7
+ public function __construct() {
8
+
9
+ include_once(QLWCDC_PLUGIN_DIR . '/includes/install.php');
10
+ include_once(QLWCDC_PLUGIN_DIR . '/includes/notices.php');
11
+
12
+ add_action('plugins_loaded', array($this, 'includes'));
13
+
14
+ load_plugin_textdomain('woocommerce-direct-checkout', false, QLWCDC_PLUGIN_DIR . '/languages/');
15
+ }
16
+
17
+ public static function instance() {
18
+ if (!isset(self::$instance)) {
19
+ self::$instance = new self();
20
+ }
21
+ return self::$instance;
22
+ }
23
+
24
+ public function includes() {
25
+ include_once(QLWCDC_PLUGIN_DIR . 'includes/backend.php');
26
+ include_once(QLWCDC_PLUGIN_DIR . 'includes/frontend.php');
27
+ include_once(QLWCDC_PLUGIN_DIR . 'includes/general.php');
28
+ include_once(QLWCDC_PLUGIN_DIR . 'includes/archives.php');
29
+ include_once(QLWCDC_PLUGIN_DIR . 'includes/products.php');
30
+ include_once(QLWCDC_PLUGIN_DIR . 'includes/checkout.php');
31
+ include_once(QLWCDC_PLUGIN_DIR . 'includes/premium.php');
32
+ include_once(QLWCDC_PLUGIN_DIR . 'includes/suggestions.php');
33
+ }
34
+
35
+ public function register_scripts() {
36
+
37
+ wp_register_script(QLWCDC_PREFIX . '-admin', plugins_url('/assets/backend/qlwcdc' . QLWCDC::instance()->is_min() . '-admin.js', QLWCDC_PLUGIN_FILE), array('jquery'), QLWCDC_PLUGIN_VERSION, true);
38
+
39
+ wp_register_style(QLWCDC_PREFIX, plugins_url('/assets/frontend/qlwcdc' . QLWCDC::instance()->is_min() . '.css', QLWCDC_PLUGIN_FILE), array(), QLWCDC_PLUGIN_VERSION, 'all');
40
+
41
+ wp_register_script(QLWCDC_PREFIX, plugins_url('/assets/frontend/qlwcdc' . QLWCDC::instance()->is_min() . '.js', QLWCDC_PLUGIN_FILE), array('jquery', 'wc-add-to-cart-variation'), QLWCDC_PLUGIN_VERSION, true);
42
+
43
+ wp_localize_script(QLWCDC_PREFIX, QLWCDC_PREFIX, array(
44
+ 'nonce' => wp_create_nonce(QLWCDC_PREFIX),
45
+ 'delay' => 200,
46
+ 'timeout' => null)
47
+ );
48
+ }
49
+
50
+ public function is_min() {
51
+ if (!defined('SCRIPT_DEBUG') || !SCRIPT_DEBUG) {
52
+ return '.min';
53
+ }
54
+ }
55
+
56
+ public function get_product_option($product_id = null, $meta_key = null, $default = null) {
57
+
58
+ if (!$meta_key) {
59
+ return null;
60
+ }
61
+
62
+ if ($product_id && metadata_exists('post', $product_id, $meta_key)) {
63
+
64
+ if ($value = get_post_meta($product_id, $meta_key, true)) {
65
+ return $value;
66
+ }
67
+ }
68
+
69
+ return get_option($meta_key, $default);
70
+ }
71
+
72
+ }
73
+
74
+ QLWCDC::instance();
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://quadlayers.com/portfolio/woocommerce-direct-checkout/
4
  Tags: woocommerce, woocommerce ajax, woocommerce ajax cart, add to cart, woocommerce direct checkout, woocommerce quick buy, woocommerce remove checkout fields, woocommerce ajax single products, woocommerce one page checkout
5
  Requires at least: 4.8
6
  Tested up to: 5.2.2
7
- Stable tag: 2.2.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -53,6 +53,9 @@ The premium version of WooCommerce Direct Checkot allows to include a quick purc
53
 
54
  == Changelog ==
55
 
 
 
 
56
  = 2.2.8 =
57
  * Fix: suggestions plugins update
58
  * Fix: WooCommerce Direct Checkout products variations quick purchase
4
  Tags: woocommerce, woocommerce ajax, woocommerce ajax cart, add to cart, woocommerce direct checkout, woocommerce quick buy, woocommerce remove checkout fields, woocommerce ajax single products, woocommerce one page checkout
5
  Requires at least: 4.8
6
  Tested up to: 5.2.2
7
+ Stable tag: 2.2.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
53
 
54
  == Changelog ==
55
 
56
+ = 2.2.9 =
57
+ * Fix: WooCommerce Ajax add to cart grouped products
58
+
59
  = 2.2.8 =
60
  * Fix: suggestions plugins update
61
  * Fix: WooCommerce Direct Checkout products variations quick purchase
woocommerce-direct-checkout.php CHANGED
@@ -1,8 +1,9 @@
1
  <?php
 
2
  /**
3
  * Plugin Name: WooCommerce Direct Checkout
4
  * Description: Simplifies the checkout process to improve your sales rate.
5
- * Version: 2.2.8
6
  * Author: QuadLayers
7
  * Author URI: https://www.quadlayers.com
8
  * Copyright: 2019 QuadLayers (https://www.quadlayers.com)
@@ -15,7 +16,7 @@ if (!defined('QLWCDC_PLUGIN_NAME')) {
15
  define('QLWCDC_PLUGIN_NAME', 'WooCommerce Direct Checkout');
16
  }
17
  if (!defined('QLWCDC_PLUGIN_VERSION')) {
18
- define('QLWCDC_PLUGIN_VERSION', '2.2.8');
19
  }
20
  if (!defined('QLWCDC_PLUGIN_FILE')) {
21
  define('QLWCDC_PLUGIN_FILE', __FILE__);
@@ -52,339 +53,7 @@ if (!defined('QLWCDC_GROUP_URL')) {
52
  }
53
 
54
  if (!class_exists('QLWCDC')) {
55
-
56
- class QLWCDC {
57
-
58
- protected static $instance;
59
-
60
- function ajax_dismiss_notice() {
61
-
62
- if (check_admin_referer('qlwcdc_dismiss_notice', 'nonce') && isset($_REQUEST['notice_id'])) {
63
-
64
- $notice_id = sanitize_key($_REQUEST['notice_id']);
65
-
66
- update_user_meta(get_current_user_id(), $notice_id, true);
67
-
68
- wp_send_json($notice_id);
69
- }
70
-
71
- wp_die();
72
- }
73
-
74
- function add_notices() {
75
-
76
- if (!get_transient('qlwcdc-first-rating') && !get_user_meta(get_current_user_id(), 'qlwcdc-user-rating', true)) {
77
- ?>
78
- <div id="qlwcdc-admin-rating" class="qlwcdc-notice notice is-dismissible" data-notice_id="qlwcdc-user-rating">
79
- <div class="notice-container" style="padding-top: 10px; padding-bottom: 10px; display: flex; justify-content: left; align-items: center;">
80
- <div class="notice-image">
81
- <img style="border-radius:50%;max-width: 90px;" src="<?php echo plugins_url('/assets/backend/img/logo.jpg', QLWCDC_PLUGIN_FILE); ?>" alt="<?php echo esc_html(QLWCDC_PLUGIN_NAME); ?>>">
82
- </div>
83
- <div class="notice-content" style="margin-left: 15px;">
84
- <p>
85
- <?php printf(esc_html__('Hello! Thank you for choosing the %s plugin!', 'woocommerce-direct-checkout'), QLWCDC_PLUGIN_NAME); ?>
86
- <br/>
87
- <?php esc_html_e('Could you please give it a 5-star rating on WordPress? We know its a big favor, but we\'ve worked very much and very hard to release this great product. Your feedback will boost our motivation and help us promote and continue to improve this product.', 'woocommerce-direct-checkout'); ?>
88
- </p>
89
- <a href="<?php echo esc_url(QLWCDC_REVIEW_URL); ?>" class="button-primary" target="_blank">
90
- <?php esc_html_e('Yes, of course!', 'woocommerce-direct-checkout'); ?>
91
- </a>
92
- <a href="<?php echo esc_url(QLWCDC_SUPPORT_URL); ?>" class="button-secondary" target="_blank">
93
- <?php esc_html_e('Report a bug', 'woocommerce-direct-checkout'); ?>
94
- </a>
95
- </div>
96
- </div>
97
- </div>
98
- <script>
99
- (function ($) {
100
- $('.qlwcdc-notice').on('click', '.notice-dismiss', function (e) {
101
- e.preventDefault();
102
- var notice_id = $(e.delegateTarget).data('notice_id');
103
- $.ajax({
104
- type: 'POST',
105
- url: ajaxurl,
106
- data: {
107
- notice_id: notice_id,
108
- action: 'qlwcdc_dismiss_notice',
109
- nonce: '<?php echo wp_create_nonce('qlwcdc_dismiss_notice'); ?>'
110
- },
111
- success: function (response) {
112
- console.log(response);
113
- },
114
- });
115
- });
116
- })(jQuery);
117
- </script>
118
- <?php
119
- }
120
- }
121
-
122
- public static function is_min() {
123
- if (!defined('SCRIPT_DEBUG') || !SCRIPT_DEBUG) {
124
- //return '.min';
125
- }
126
- }
127
-
128
- function get_product_option($product_id = null, $meta_key = null, $default = null) {
129
-
130
- if (!$meta_key) {
131
- return null;
132
- }
133
-
134
- if ($product_id && metadata_exists('post', $product_id, $meta_key)) {
135
-
136
- if ($value = get_post_meta($product_id, $meta_key, true)) {
137
- return $value;
138
- }
139
- }
140
-
141
- return get_option($meta_key, $default);
142
- }
143
-
144
- function add_action_links($links) {
145
-
146
- $links[] = '<a target="_blank" href="' . QLWCDC_PURCHASE_URL . '">' . esc_html__('Premium', 'woocommerce-direct-checkout') . '</a>';
147
- $links[] = '<a href="' . admin_url('admin.php?page=wc-settings&tab=' . sanitize_title(QLWCDC_PREFIX)) . '">' . esc_html__('Settings', 'woocommerce-direct-checkout') . '</a>';
148
-
149
- return $links;
150
- }
151
-
152
- // function add_sections($sections = array()) {
153
- //
154
- // global $current_section;
155
- //
156
- // $sections = apply_filters('qlwcdc_add_sections', array());
157
- //
158
- // echo '<ul class="subsubsub">';
159
- //
160
- // $array_keys = array_keys($sections);
161
- //
162
- // foreach ($sections as $id => $label) {
163
- // echo '<li><a href="' . admin_url('admin.php?page=wc-settings&tab=qlwcdc&section=' . sanitize_title($id)) . '" class="' . ( $current_section == $id ? 'current' : '' ) . '">' . $label . '</a> | </li>';
164
- // }
165
- //
166
- // echo '<li><a target="_blank" href="' . QLWCDC_DOCUMENTATION_URL . '">' . esc_html__('Documentation', 'woocommerce-direct-checkout') . '</a> ' . ( end($array_keys) == $id ? '' : '|' ) . ' </li>';
167
- //
168
- // echo '</ul><br class="clear" />';
169
- // }
170
-
171
- function add_tab($settings_tabs) {
172
- $settings_tabs[QLWCDC_PREFIX] = esc_html__('Direct Checkout', 'woocommerce-direct-checkout');
173
- return $settings_tabs;
174
- }
175
- //
176
- // function add_settings() {
177
- // woocommerce_admin_fields($this->get_settings());
178
- // }
179
- //
180
- // function save_settings() {
181
- // woocommerce_update_options($this->get_settings());
182
- // }
183
- //
184
- // function get_settings() {
185
- //
186
- // $fields = apply_filters('qlwcdc_add_fields', array());
187
- //
188
- // return $fields;
189
- // }
190
-
191
- function register_scripts() {
192
-
193
- wp_register_script(QLWCDC_PREFIX . '-admin', plugins_url('/assets/backend/qlwcdc' . self::is_min() . '-admin.js', QLWCDC_PLUGIN_FILE), array('jquery'), QLWCDC_PLUGIN_VERSION, true);
194
-
195
- wp_register_style(QLWCDC_PREFIX, plugins_url('/assets/frontend/qlwcdc' . self::is_min() . '.css', QLWCDC_PLUGIN_FILE), array(), QLWCDC_PLUGIN_VERSION, 'all');
196
-
197
- wp_register_script(QLWCDC_PREFIX, plugins_url('/assets/frontend/qlwcdc' . self::is_min() . '.js', QLWCDC_PLUGIN_FILE), array('jquery', 'wc-add-to-cart-variation'), QLWCDC_PLUGIN_VERSION, true);
198
-
199
- wp_localize_script(QLWCDC_PREFIX, QLWCDC_PREFIX, array(
200
- 'nonce' => wp_create_nonce(QLWCDC_PREFIX),
201
- 'delay' => 200,
202
- 'timeout' => null)
203
- );
204
- }
205
-
206
- function enqueue_frontend_scripts() {
207
-
208
- $this->register_scripts();
209
-
210
- wp_enqueue_style(QLWCDC_PREFIX);
211
- wp_enqueue_script(QLWCDC_PREFIX);
212
- }
213
-
214
- function enqueue_admin_scripts() {
215
-
216
- $this->register_scripts();
217
-
218
- wp_enqueue_script(QLWCDC_PREFIX . '-admin');
219
- }
220
-
221
- function remove_premium() {
222
- ?>
223
- <script>
224
- (function ($) {
225
- 'use strict';
226
- $(window).on('load', function (e) {
227
- $('#qlwcdc_options').css({'opacity': '0.5', 'pointer-events': 'none'});
228
- $('label[for=qlwcdc_add_product_ajax]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
229
- $('label[for=qlwcdc_add_checkout_cart]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
230
- $('label[for=qlwcdc_add_checkout_cart_fields]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
231
- $('label[for=qlwcdc_add_checkout_cart_class]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
232
- $('label[for=qlwcdc_remove_checkout_columns]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
233
- $('label[for=qlwcdc_remove_checkout_coupon_form]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
234
- $('label[for=qlwcdc_remove_order_details_address]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
235
- $('label[for=qlwcdc_add_product_quick_purchase]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
236
- $('label[for=qlwcdc_add_product_quick_purchase_to]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
237
- $('label[for=qlwcdc_add_product_quick_purchase_qty]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
238
- $('label[for=qlwcdc_add_product_quick_purchase_class]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
239
- $('label[for=qlwcdc_add_product_quick_purchase_text]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
240
- $('label[for=qlwcdc_add_product_default_attributes]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
241
- $('label[for=qlwcdc_add_archive_quick_view]').closest('tr').addClass('qlwcdc-premium-field').css({'opacity': '0.5', 'pointer-events': 'none'});
242
- });
243
- }(jQuery));
244
- </script>
245
- <?php
246
- }
247
-
248
- function enqueue_footer_scripts() {
249
- ?>
250
- <script>
251
- </script>
252
- <?php
253
- }
254
-
255
- function add_menu_page() {
256
- add_submenu_page('woocommerce', esc_html__('Direct Checkout', 'woocommerce-direct-checkout'), esc_html__('Direct Checkout', 'woocommerce-direct-checkout'), 'manage_woocommerce', admin_url('admin.php?page=wc-settings&tab=' . sanitize_title(QLWCDC_PREFIX)));
257
- }
258
-
259
- /* function woocommerce_cart_redirect_after_add($val) {
260
- return 'no';
261
- } */
262
-
263
- function languages() {
264
- load_plugin_textdomain('woocommerce-direct-checkout', false, dirname(plugin_basename(__FILE__)) . '/languages/');
265
- }
266
-
267
- function includes() {
268
- require_once('includes/general.php');
269
- require_once('includes/archives.php');
270
- require_once('includes/products.php');
271
- require_once('includes/checkout.php');
272
- //require_once('includes/purchase.php');
273
- require_once('includes/premium.php');
274
- require_once('includes/suggestions.php');
275
- }
276
-
277
- function init() {
278
- add_action('wp_ajax_qlwcdc_dismiss_notice', array($this, 'ajax_dismiss_notice'));
279
- add_action('wp_enqueue_scripts', array($this, 'enqueue_frontend_scripts'), 99);
280
- add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 99);
281
- add_action('admin_notices', array($this, 'add_notices'));
282
- add_action('admin_menu', array(&$this, 'add_menu_page'));
283
- add_action('admin_footer', array($this, 'remove_premium'));
284
- //add_action('admin_footer', array($this, 'enqueue_footer_scripts'));
285
- add_filter('woocommerce_settings_tabs_array', array($this, 'add_tab'), 50);
286
- // add_filter('woocommerce_sections_qlwcdc', array($this, 'add_sections'));
287
- // add_action('woocommerce_sections_qlwcdc', array($this, 'add_settings'));
288
- // add_action('woocommerce_settings_save_qlwcdc', array($this, 'save_settings'));
289
- //add_filter('option_woocommerce_cart_redirect_after_add', array($this, 'woocommerce_cart_redirect_after_add'));
290
- add_filter('plugin_action_links_' . plugin_basename(QLWCDC_PLUGIN_FILE), array($this, 'add_action_links'));
291
- }
292
-
293
- public static function do_import() {
294
-
295
- global $wpdb;
296
-
297
- if (!get_option('qlwcdc_wcd_imported2')) {
298
-
299
- if (get_option('direct_checkout_pro_enabled', get_option('direct_checkout_enabled'))) {
300
-
301
- $url = get_option('direct_checkout_pro_cart_redirect_url', get_option('direct_checkout_cart_redirect_url'));
302
-
303
- if ($url === wc_get_cart_url()) {
304
- $val = 'cart';
305
- } elseif (filter_var($url, FILTER_VALIDATE_URL) !== false && $url != wc_get_checkout_url()) {
306
- $val = 'url';
307
- } else {
308
- $val = 'checkout';
309
- }
310
-
311
- /* add_option('qlwcdc_add_product_cart', 'redirect');
312
- add_option('qlwcdc_add_product_cart_redirect_page', $val);
313
- add_option('qlwcdc_add_product_cart_redirect_url', $url);
314
-
315
- add_option('qlwcdc_add_archive_cart', 'redirect');
316
- add_option('qlwcdc_add_archive_cart_redirect_page', $val);
317
- add_option('qlwcdc_add_archive_cart_redirect_url', $url); */
318
-
319
- add_option('qlwcdc_add_to_cart', 'redirect');
320
- add_option('qlwcdc_add_to_cart_redirect_page', $val);
321
- add_option('qlwcdc_add_to_cart_redirect_url', $url);
322
- }
323
-
324
- if ($text = get_option('direct_checkout_cart_button_text', get_option('direct_checkout_cart_button_text'))) {
325
- add_option('qlwcdc_add_product_text', 'yes');
326
- add_option('qlwcdc_add_product_text_content', $text);
327
- add_option('qlwcdc_add_archive_text', 'yes');
328
- add_option('qlwcdc_add_archive_text_content', $text);
329
- add_option('qlwcdc_add_archive_text_in', array(
330
- 'simple',
331
- 'grouped',
332
- 'virtual',
333
- 'variable',
334
- 'downloadable'
335
- ));
336
- }
337
-
338
- if (count($keys = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->postmeta} WHERE meta_key = %s", '_direct_checkout_pro_enabled')))) {
339
- foreach ($keys as $key) {
340
- if ($key->meta_value == 'yes') {
341
- if ($text = get_post_meta($key->post_id, '_direct_checkout_pro_cart_button_text', true)) {
342
- add_post_meta($key->post_id, 'qlwcdc_add_product_text', 'yes', true);
343
- add_post_meta($key->post_id, 'qlwcdc_add_product_text_content', $text, true);
344
- }
345
- }
346
- }
347
- }
348
-
349
- delete_option('qlwcdc_wcd_imported');
350
- update_option('qlwcdc_wcd_imported2', true);
351
- }
352
- }
353
-
354
- public static function do_activation() {
355
-
356
- set_transient('qlwcdc-first-rating', true, MONTH_IN_SECONDS);
357
-
358
- if ('yes' === get_option('woocommerce_cart_redirect_after_add')) {
359
- add_option('qlwcdc_add_to_cart', 'redirect');
360
- add_option('qlwcdc_add_to_cart_redirect_page', 'cart');
361
- /* add_option('qlwcdc_add_product_cart', 'redirect');
362
- add_option('qlwcdc_add_product_cart_redirect_page', 'cart');
363
- add_option('qlwcdc_add_archive_cart', 'redirect');
364
- add_option('qlwcdc_add_archive_cart_redirect_page', 'cart'); */
365
- }
366
-
367
- /* if ('yes' === get_option('woocommerce_enable_ajax_add_to_cart')) {
368
- add_option('qlwcdc_add_archive_cart', 'ajax');
369
- } */
370
- }
371
-
372
- public static function instance() {
373
- if (!isset(self::$instance)) {
374
- self::$instance = new self();
375
- self::$instance->init();
376
- self::$instance->includes();
377
- self::$instance->languages();
378
- }
379
- return self::$instance;
380
- }
381
-
382
- }
383
-
384
- add_action('wp_loaded', array('QLWCDC', 'do_import'));
385
- add_action('plugins_loaded', array('QLWCDC', 'instance'));
386
-
387
- register_activation_hook(QLWCDC_PLUGIN_FILE, array('QLWCDC', 'do_activation'));
388
  }
389
 
390
 
1
  <?php
2
+
3
  /**
4
  * Plugin Name: WooCommerce Direct Checkout
5
  * Description: Simplifies the checkout process to improve your sales rate.
6
+ * Version: 2.2.9
7
  * Author: QuadLayers
8
  * Author URI: https://www.quadlayers.com
9
  * Copyright: 2019 QuadLayers (https://www.quadlayers.com)
16
  define('QLWCDC_PLUGIN_NAME', 'WooCommerce Direct Checkout');
17
  }
18
  if (!defined('QLWCDC_PLUGIN_VERSION')) {
19
+ define('QLWCDC_PLUGIN_VERSION', '2.2.9');
20
  }
21
  if (!defined('QLWCDC_PLUGIN_FILE')) {
22
  define('QLWCDC_PLUGIN_FILE', __FILE__);
53
  }
54
 
55
  if (!class_exists('QLWCDC')) {
56
+ include_once(QLWCDC_PLUGIN_DIR . 'includes/qlwcdc.php');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
58
 
59