Version Description
- Fix: WooCommerce Checkout Country
Download this release
Release Info
Developer | quadlayers |
Plugin | WooCommerce Direct Checkout |
Version | 2.4.1 |
Comparing to | |
See all releases |
Code changes from version 2.4.0 to 2.4.1
- includes/controller/checkout.php +0 -31
- includes/view/frontend/checkout.php +100 -7
- includes/view/frontend/general.php +1 -1
- readme.txt +4 -1
- woocommerce-direct-checkout.php +3 -3
includes/controller/checkout.php
CHANGED
@@ -223,37 +223,6 @@ class QLWCDC_Controller_Checkout {
|
|
223 |
}
|
224 |
}
|
225 |
|
226 |
-
function remove_checkout_fields($fields) {
|
227 |
-
|
228 |
-
if ($remove = get_option('qlwcdc_remove_checkout_fields', array())) {
|
229 |
-
foreach ($remove as $id => $key) {
|
230 |
-
// We need to remove both fields otherwise will be required
|
231 |
-
unset($fields['billing']['billing_' . $key]);
|
232 |
-
unset($fields['shipping']['shipping_' . $key]);
|
233 |
-
}
|
234 |
-
}
|
235 |
-
|
236 |
-
return $fields;
|
237 |
-
}
|
238 |
-
|
239 |
-
function remove_checkout_order_commens($return) {
|
240 |
-
|
241 |
-
if ('yes' === get_option('qlwcdc_remove_checkout_order_comments')) {
|
242 |
-
$return = false;
|
243 |
-
}
|
244 |
-
|
245 |
-
return $return;
|
246 |
-
}
|
247 |
-
|
248 |
-
function remove_checkout_shipping_address($val) {
|
249 |
-
|
250 |
-
if ('yes' === get_option('qlwcdc_remove_checkout_shipping_address')) {
|
251 |
-
$val = 'billing_only';
|
252 |
-
}
|
253 |
-
|
254 |
-
return $val;
|
255 |
-
}
|
256 |
-
|
257 |
}
|
258 |
|
259 |
QLWCDC_Controller_Checkout::instance();
|
223 |
}
|
224 |
}
|
225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
}
|
227 |
|
228 |
QLWCDC_Controller_Checkout::instance();
|
includes/view/frontend/checkout.php
CHANGED
@@ -1,11 +1,22 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class QLWCDC_Checkout
|
|
|
4 |
|
5 |
protected static $instance;
|
6 |
|
7 |
-
public function __construct()
|
|
|
8 |
add_filter('woocommerce_checkout_fields', array($this, 'remove_checkout_fields'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
add_filter('woocommerce_enable_order_notes_field', array($this, 'remove_checkout_order_commens'));
|
10 |
add_filter('option_woocommerce_ship_to_destination', array($this, 'remove_checkout_shipping_address'), 10, 3);
|
11 |
|
@@ -19,18 +30,24 @@ class QLWCDC_Checkout {
|
|
19 |
}
|
20 |
}
|
21 |
|
22 |
-
public static function instance()
|
|
|
23 |
if (!isset(self::$instance)) {
|
24 |
self::$instance = new self();
|
25 |
}
|
26 |
return self::$instance;
|
27 |
}
|
28 |
|
29 |
-
function remove_checkout_fields($fields)
|
|
|
30 |
|
31 |
if ($remove = get_option('qlwcdc_remove_checkout_fields', array())) {
|
|
|
32 |
foreach ($remove as $id => $key) {
|
33 |
// We need to remove both fields otherwise will be required
|
|
|
|
|
|
|
34 |
unset($fields['billing']['billing_' . $key]);
|
35 |
unset($fields['shipping']['shipping_' . $key]);
|
36 |
}
|
@@ -39,7 +56,83 @@ class QLWCDC_Checkout {
|
|
39 |
return $fields;
|
40 |
}
|
41 |
|
42 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
if ('yes' === get_option('qlwcdc_remove_checkout_order_comments')) {
|
45 |
$return = false;
|
@@ -48,7 +141,8 @@ class QLWCDC_Checkout {
|
|
48 |
return $return;
|
49 |
}
|
50 |
|
51 |
-
function remove_checkout_shipping_address($val)
|
|
|
52 |
|
53 |
if ('yes' === get_option('qlwcdc_remove_checkout_shipping_address')) {
|
54 |
$val = 'billing_only';
|
@@ -56,7 +150,6 @@ class QLWCDC_Checkout {
|
|
56 |
|
57 |
return $val;
|
58 |
}
|
59 |
-
|
60 |
}
|
61 |
|
62 |
QLWCDC_Checkout::instance();
|
1 |
<?php
|
2 |
|
3 |
+
class QLWCDC_Checkout
|
4 |
+
{
|
5 |
|
6 |
protected static $instance;
|
7 |
|
8 |
+
public function __construct()
|
9 |
+
{
|
10 |
add_filter('woocommerce_checkout_fields', array($this, 'remove_checkout_fields'));
|
11 |
+
|
12 |
+
//add_filter('woocommerce_form_field_args', array($this, 'country_hidden_field_args'), 10, 4);
|
13 |
+
|
14 |
+
//add_filter('woocommerce_form_field_country_hidden', array($this, 'country_hidden_field'), 10, 4);
|
15 |
+
|
16 |
+
add_filter('woocommerce_countries_allowed_countries', array($this, 'remove_allowed_countries'));
|
17 |
+
|
18 |
+
add_action('woocommerce_before_checkout_form', array($this, 'remove_country_css'));
|
19 |
+
|
20 |
add_filter('woocommerce_enable_order_notes_field', array($this, 'remove_checkout_order_commens'));
|
21 |
add_filter('option_woocommerce_ship_to_destination', array($this, 'remove_checkout_shipping_address'), 10, 3);
|
22 |
|
30 |
}
|
31 |
}
|
32 |
|
33 |
+
public static function instance()
|
34 |
+
{
|
35 |
if (!isset(self::$instance)) {
|
36 |
self::$instance = new self();
|
37 |
}
|
38 |
return self::$instance;
|
39 |
}
|
40 |
|
41 |
+
function remove_checkout_fields($fields)
|
42 |
+
{
|
43 |
|
44 |
if ($remove = get_option('qlwcdc_remove_checkout_fields', array())) {
|
45 |
+
|
46 |
foreach ($remove as $id => $key) {
|
47 |
// We need to remove both fields otherwise will be required
|
48 |
+
if ($key == 'country') {
|
49 |
+
continue;
|
50 |
+
}
|
51 |
unset($fields['billing']['billing_' . $key]);
|
52 |
unset($fields['shipping']['shipping_' . $key]);
|
53 |
}
|
56 |
return $fields;
|
57 |
}
|
58 |
|
59 |
+
/* function country_hidden_field_args($args, $key, $value = null)
|
60 |
+
{
|
61 |
+
|
62 |
+
$remove = get_option('qlwcdc_remove_checkout_fields', array());
|
63 |
+
|
64 |
+
if (in_array('country', (array) $remove)) {
|
65 |
+
if ($key == 'billing_country' || $key == 'shipping') {
|
66 |
+
$args['default'] = 'AR';
|
67 |
+
$args['required'] = false;
|
68 |
+
$args['type'] = 'country_hidden';
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
return $args;
|
73 |
+
}*/
|
74 |
+
|
75 |
+
/* function country_hidden_field($field = '', $key, $args, $value)
|
76 |
+
{
|
77 |
+
|
78 |
+
static $instance = 0;
|
79 |
+
|
80 |
+
if ($instance) {
|
81 |
+
return $field;
|
82 |
+
}
|
83 |
+
|
84 |
+
$instance++;
|
85 |
+
|
86 |
+
$value = WC()->countries->get_base_country();
|
87 |
+
//$countries = WC()->countries->get_allowed_countries();
|
88 |
+
|
89 |
+
//if (count($countries = WC()->countries->get_allowed_countries())) {
|
90 |
+
// $value = key($countries);
|
91 |
+
//}
|
92 |
+
|
93 |
+
$field .= '<input type="text" class="country_to_state" name="' . esc_attr($key) . '" id="' . esc_attr($args['id']) . '" value="' . esc_html($value) . '" ' . implode(' ', $args['custom_attributes']) . ' readonly="readonly" />';
|
94 |
+
|
95 |
+
return $field;
|
96 |
+
} */
|
97 |
+
|
98 |
+
function remove_allowed_countries($countries)
|
99 |
+
{
|
100 |
+
|
101 |
+
$remove = get_option('qlwcdc_remove_checkout_fields', array());
|
102 |
+
|
103 |
+
if (in_array('country', (array) $remove)) {
|
104 |
+
|
105 |
+
$base = WC()->countries->get_base_country();
|
106 |
+
|
107 |
+
if (isset($countries[$base])) {
|
108 |
+
|
109 |
+
$countries = array(
|
110 |
+
$base => $countries[$base]
|
111 |
+
);
|
112 |
+
}
|
113 |
+
}
|
114 |
+
|
115 |
+
return $countries;
|
116 |
+
}
|
117 |
+
|
118 |
+
public function remove_country_css()
|
119 |
+
{
|
120 |
+
|
121 |
+
$remove = get_option('qlwcdc_remove_checkout_fields', array());
|
122 |
+
|
123 |
+
if (in_array('country', (array) $remove)) {
|
124 |
+
?>
|
125 |
+
<style>
|
126 |
+
#billing_country_field {
|
127 |
+
display: none !important;
|
128 |
+
}
|
129 |
+
</style>
|
130 |
+
<?php
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
function remove_checkout_order_commens($return)
|
135 |
+
{
|
136 |
|
137 |
if ('yes' === get_option('qlwcdc_remove_checkout_order_comments')) {
|
138 |
$return = false;
|
141 |
return $return;
|
142 |
}
|
143 |
|
144 |
+
function remove_checkout_shipping_address($val)
|
145 |
+
{
|
146 |
|
147 |
if ('yes' === get_option('qlwcdc_remove_checkout_shipping_address')) {
|
148 |
$val = 'billing_only';
|
150 |
|
151 |
return $val;
|
152 |
}
|
|
|
153 |
}
|
154 |
|
155 |
QLWCDC_Checkout::instance();
|
includes/view/frontend/general.php
CHANGED
@@ -72,7 +72,7 @@ class QLWCDC_General
|
|
72 |
if (!is_admin() && !is_checkout() && 'no' !== get_option('qlwcdc_replace_cart_url', 'no')) {
|
73 |
|
74 |
// empty checkout redirect to custom/cart/shop
|
75 |
-
if (method_exists(
|
76 |
return get_permalink(wc_get_page_id('shop'));
|
77 |
}
|
78 |
|
72 |
if (!is_admin() && !is_checkout() && 'no' !== get_option('qlwcdc_replace_cart_url', 'no')) {
|
73 |
|
74 |
// empty checkout redirect to custom/cart/shop
|
75 |
+
if (method_exists(WC()->cart, 'is_empty') && WC()->cart->is_empty()) {
|
76 |
return get_permalink(wc_get_page_id('shop'));
|
77 |
}
|
78 |
|
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.6
|
6 |
Tested up to: 5.5.0
|
7 |
-
Stable tag: 2.4.
|
8 |
WC requires at least: 3.1.0
|
9 |
WC tested up to: 4.3.2
|
10 |
License: GPLv3
|
@@ -64,6 +64,9 @@ The premium version of WooCommerce Direct Checkot allows to include a quick purc
|
|
64 |
|
65 |
== Changelog ==
|
66 |
|
|
|
|
|
|
|
67 |
= 2.4.0 =
|
68 |
* Fix: WordPress 5.5 compatibility
|
69 |
|
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.6
|
6 |
Tested up to: 5.5.0
|
7 |
+
Stable tag: 2.4.1
|
8 |
WC requires at least: 3.1.0
|
9 |
WC tested up to: 4.3.2
|
10 |
License: GPLv3
|
64 |
|
65 |
== Changelog ==
|
66 |
|
67 |
+
= 2.4.1 =
|
68 |
+
* Fix: WooCommerce Checkout Country
|
69 |
+
|
70 |
= 2.4.0 =
|
71 |
* Fix: WordPress 5.5 compatibility
|
72 |
|
woocommerce-direct-checkout.php
CHANGED
@@ -4,13 +4,13 @@
|
|
4 |
* Plugin Name: Direct Checkout for WooCommerce
|
5 |
* Plugin URI: https://quadlayers.com/documentation/woocommerce-direct-checkout/
|
6 |
* Description: Simplifies the checkout process to improve your sales rate.
|
7 |
-
* Version: 2.4.
|
8 |
* Author: QuadLayers
|
9 |
* Author URI: https://quadlayers.com
|
10 |
* License: GPLv3
|
11 |
* Text Domain: woocommerce-direct-checkout
|
12 |
* WC requires at least: 3.1.0
|
13 |
-
* WC tested up to: 4.
|
14 |
*/
|
15 |
if (!defined('ABSPATH')) {
|
16 |
die('-1');
|
@@ -19,7 +19,7 @@ if (!defined('QLWCDC_PLUGIN_NAME')) {
|
|
19 |
define('QLWCDC_PLUGIN_NAME', 'Direct Checkout for WooCommerce');
|
20 |
}
|
21 |
if (!defined('QLWCDC_PLUGIN_VERSION')) {
|
22 |
-
define('QLWCDC_PLUGIN_VERSION', '2.4.
|
23 |
}
|
24 |
if (!defined('QLWCDC_PLUGIN_FILE')) {
|
25 |
define('QLWCDC_PLUGIN_FILE', __FILE__);
|
4 |
* Plugin Name: Direct Checkout for WooCommerce
|
5 |
* Plugin URI: https://quadlayers.com/documentation/woocommerce-direct-checkout/
|
6 |
* Description: Simplifies the checkout process to improve your sales rate.
|
7 |
+
* Version: 2.4.1
|
8 |
* Author: QuadLayers
|
9 |
* Author URI: https://quadlayers.com
|
10 |
* License: GPLv3
|
11 |
* Text Domain: woocommerce-direct-checkout
|
12 |
* WC requires at least: 3.1.0
|
13 |
+
* WC tested up to: 4.4.0
|
14 |
*/
|
15 |
if (!defined('ABSPATH')) {
|
16 |
die('-1');
|
19 |
define('QLWCDC_PLUGIN_NAME', 'Direct Checkout for WooCommerce');
|
20 |
}
|
21 |
if (!defined('QLWCDC_PLUGIN_VERSION')) {
|
22 |
+
define('QLWCDC_PLUGIN_VERSION', '2.4.1');
|
23 |
}
|
24 |
if (!defined('QLWCDC_PLUGIN_FILE')) {
|
25 |
define('QLWCDC_PLUGIN_FILE', __FILE__);
|