Version Description
- Fix: billing & shipping duplicated in order
- Fix: php compatbility
Download this release
Release Info
| Developer | quadlayers |
| Plugin | |
| Version | 5.1.0 |
| Comparing to | |
| See all releases | |
Code changes from version 5.0.9 to 5.1.0
includes/controller/class-wooccm-field-billing.php
CHANGED
|
@@ -1,125 +1,123 @@
|
|
| 1 |
<?php
|
| 2 |
|
| 3 |
-
class WOOCCM_Field_Controller_Billing extends WOOCCM_Field_Controller
|
| 4 |
-
{
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
| 10 |
-
{
|
| 11 |
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
| 25 |
}
|
| 26 |
-
return self::$_instance;
|
| 27 |
-
}
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
{
|
| 34 |
|
| 35 |
-
|
| 36 |
|
| 37 |
-
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
| 50 |
}
|
| 51 |
-
}
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
?>
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
}
|
| 60 |
|
| 61 |
-
|
| 62 |
-
|
| 63 |
|
| 64 |
-
|
| 65 |
-
{
|
| 66 |
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
|
| 71 |
-
|
| 72 |
-
|
| 73 |
|
| 74 |
-
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
|
| 98 |
-
|
| 99 |
-
|
| 100 |
|
| 101 |
-
|
| 102 |
-
|
| 103 |
|
| 104 |
-
|
| 105 |
return $shipping_fields;
|
| 106 |
-
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
|
| 111 |
-
|
| 112 |
|
| 113 |
if (in_array($field['name'], $defaults)) {
|
| 114 |
-
|
| 115 |
}
|
| 116 |
|
| 117 |
if (in_array($field['name'], $template)) {
|
| 118 |
-
|
| 119 |
}
|
| 120 |
|
| 121 |
if (!isset($field['type']) || $field['type'] != 'textarea') {
|
| 122 |
-
|
| 123 |
}
|
| 124 |
|
| 125 |
$shipping_fields[$field['name']] = $field;
|
|
@@ -129,40 +127,40 @@ class WOOCCM_Field_Controller_Billing extends WOOCCM_Field_Controller
|
|
| 129 |
$shipping_fields[$field['name']]['value'] = null;
|
| 130 |
$shipping_fields[$field['name']]['class'] = join(' ', $field['class']);
|
| 131 |
//$shipping_fields[$field['name']]['wrapper_class'] = 'wooccm-premium';
|
| 132 |
-
|
| 133 |
|
| 134 |
|
| 135 |
-
|
| 136 |
-
|
| 137 |
|
| 138 |
-
|
| 139 |
-
|
| 140 |
|
| 141 |
-
|
| 142 |
|
| 143 |
$defaults = WOOCCM()->billing->get_defaults();
|
| 144 |
|
| 145 |
foreach ($fields as $field_id => $field) {
|
| 146 |
|
| 147 |
-
|
| 148 |
|
| 149 |
-
|
| 150 |
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
<?php
|
| 161 |
-
}
|
| 162 |
-
}
|
| 163 |
}
|
| 164 |
-
|
| 165 |
-
|
|
|
|
|
|
|
| 166 |
}
|
| 167 |
|
| 168 |
WOOCCM_Field_Controller_Billing::instance();
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
class WOOCCM_Field_Controller_Billing extends WOOCCM_Field_Controller {
|
|
|
|
| 4 |
|
| 5 |
+
protected static $_instance;
|
| 6 |
+
public $billing;
|
| 7 |
|
| 8 |
+
public function __construct() {
|
|
|
|
| 9 |
|
| 10 |
+
include_once(WOOCCM_PLUGIN_DIR . 'includes/model/class-wooccm-field-billing.php');
|
| 11 |
|
| 12 |
+
add_action('wooccm_sections_header', array($this, 'add_header'));
|
| 13 |
+
add_action('woocommerce_sections_' . WOOCCM_PREFIX, array($this, 'add_section'), 99);
|
| 14 |
+
add_filter('woocommerce_admin_billing_fields', array($this, 'add_admin_billing_fields'));
|
| 15 |
+
//add_filter('woocommerce_admin_shipping_fields', array($this, 'add_admin_shipping_fields'));
|
| 16 |
+
// add_action('woocommerce_admin_order_data_after_billing_address', array($this, 'add_order_data'));
|
| 17 |
+
}
|
| 18 |
|
| 19 |
+
public static function instance() {
|
| 20 |
+
if (is_null(self::$_instance)) {
|
| 21 |
+
self::$_instance = new self();
|
| 22 |
+
}
|
| 23 |
+
return self::$_instance;
|
| 24 |
}
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
// Admin
|
| 27 |
+
// ---------------------------------------------------------------------------
|
| 28 |
|
| 29 |
+
public function add_section() {
|
|
|
|
| 30 |
|
| 31 |
+
global $current_section, $wp_roles, $wp_locale;
|
| 32 |
|
| 33 |
+
if ('billing' == $current_section) {
|
| 34 |
|
| 35 |
+
$fields = WOOCCM()->billing->get_fields();
|
| 36 |
+
$defaults = WOOCCM()->billing->get_defaults();
|
| 37 |
+
$types = WOOCCM()->billing->get_types();
|
| 38 |
+
$conditionals = WOOCCM()->billing->get_conditional_types();
|
| 39 |
+
$option = WOOCCM()->billing->get_option_types();
|
| 40 |
+
$multiple = WOOCCM()->billing->get_multiple_types();
|
| 41 |
+
$template = WOOCCM()->billing->get_template_types();
|
| 42 |
+
$disabled = WOOCCM()->billing->get_disabled_types();
|
| 43 |
+
$product_categories = $this->get_product_categories();
|
| 44 |
+
|
| 45 |
+
include_once(WOOCCM_PLUGIN_DIR . 'includes/view/backend/pages/billing.php');
|
| 46 |
+
}
|
| 47 |
}
|
|
|
|
| 48 |
|
| 49 |
+
public function add_header() {
|
| 50 |
+
global $current_section;
|
| 51 |
+
?>
|
| 52 |
+
<li><a href="<?php echo admin_url('admin.php?page=wc-settings&tab=wooccm§ion=billing'); ?>" class="<?php echo ($current_section == 'billing' ? 'current' : ''); ?>"><?php esc_html_e('Billing', 'woocommerce-checkout-manager'); ?></a> | </li>
|
| 53 |
+
<?php
|
| 54 |
+
}
|
|
|
|
| 55 |
|
| 56 |
+
// Admin Order
|
| 57 |
+
// ---------------------------------------------------------------------------
|
| 58 |
|
| 59 |
+
function add_admin_billing_fields($billing_fields) {
|
|
|
|
| 60 |
|
| 61 |
+
if (!$fields = WOOCCM()->billing->get_fields()) {
|
| 62 |
+
return $billing_fields;
|
| 63 |
+
}
|
| 64 |
|
| 65 |
+
//$defaults = WOOCCM()->billing->get_defaults();
|
| 66 |
+
$template = WOOCCM()->billing->get_template_types();
|
| 67 |
|
| 68 |
+
foreach ($fields as $field_id => $field) {
|
| 69 |
|
| 70 |
+
if (!isset($field['name'])) {
|
| 71 |
+
continue;
|
| 72 |
+
}
|
| 73 |
|
| 74 |
+
if (isset($billing_fields[$field['name']])) {
|
| 75 |
+
continue;
|
| 76 |
+
}
|
| 77 |
|
| 78 |
+
if (in_array($field['name'], $template)) {
|
| 79 |
+
continue;
|
| 80 |
+
}
|
| 81 |
|
| 82 |
+
if (!isset($field['type']) || $field['type'] != 'textarea') {
|
| 83 |
+
$field['type'] = 'text';
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
$billing_fields[$field['name']] = $field;
|
| 87 |
+
$billing_fields[$field['name']]['id'] = sprintf('_%s', (string) $field['key']);
|
| 88 |
+
$billing_fields[$field['name']]['label'] = $field['label'];
|
| 89 |
+
$billing_fields[$field['name']]['name'] = $field['key'];
|
| 90 |
+
$billing_fields[$field['name']]['value'] = null;
|
| 91 |
+
$billing_fields[$field['name']]['class'] = join(' ', $field['class']);
|
| 92 |
+
//$billing_fields[$field['name']]['wrapper_class'] = 'wooccm-premium';
|
| 93 |
+
}
|
| 94 |
|
| 95 |
|
| 96 |
+
return $billing_fields;
|
| 97 |
+
}
|
| 98 |
|
| 99 |
+
/* function add_admin_shipping_fields($shipping_fields)
|
| 100 |
+
{
|
| 101 |
|
| 102 |
+
if (!$fields = WOOCCM()->shipping->get_fields()) {
|
| 103 |
return $shipping_fields;
|
| 104 |
+
}
|
| 105 |
|
| 106 |
+
$defaults = WOOCCM()->shipping->get_defaults();
|
| 107 |
+
$template = WOOCCM()->shipping->get_template_types();
|
| 108 |
|
| 109 |
+
foreach ($fields as $field_id => $field) {
|
| 110 |
|
| 111 |
if (in_array($field['name'], $defaults)) {
|
| 112 |
+
continue;
|
| 113 |
}
|
| 114 |
|
| 115 |
if (in_array($field['name'], $template)) {
|
| 116 |
+
continue;
|
| 117 |
}
|
| 118 |
|
| 119 |
if (!isset($field['type']) || $field['type'] != 'textarea') {
|
| 120 |
+
$field['type'] = 'text';
|
| 121 |
}
|
| 122 |
|
| 123 |
$shipping_fields[$field['name']] = $field;
|
| 127 |
$shipping_fields[$field['name']]['value'] = null;
|
| 128 |
$shipping_fields[$field['name']]['class'] = join(' ', $field['class']);
|
| 129 |
//$shipping_fields[$field['name']]['wrapper_class'] = 'wooccm-premium';
|
| 130 |
+
}
|
| 131 |
|
| 132 |
|
| 133 |
+
return $shipping_fields;
|
| 134 |
+
} */
|
| 135 |
|
| 136 |
+
/* function add_order_data($order)
|
| 137 |
+
{
|
| 138 |
|
| 139 |
+
if ($fields = WOOCCM()->billing->get_fields()) {
|
| 140 |
|
| 141 |
$defaults = WOOCCM()->billing->get_defaults();
|
| 142 |
|
| 143 |
foreach ($fields as $field_id => $field) {
|
| 144 |
|
| 145 |
+
if (!in_array($field['name'], $defaults)) {
|
| 146 |
|
| 147 |
+
$key = sprintf('_%s', $field['key']);
|
| 148 |
|
| 149 |
+
if ($value = get_post_meta($order->get_id(), $key, true)) {
|
| 150 |
+
?>
|
| 151 |
+
<p id="<?php echo esc_attr($field['key']); ?>" class="form-field form-field-wide form-field-type-<?php echo esc_attr($field['type']); ?>">
|
| 152 |
+
<strong title="<?php echo esc_attr(sprintf(__('ID: %s | Field Type: %s', 'woocommerce-checkout-manager'), $key, __('Generic', 'woocommerce-checkout-manager'))); ?>">
|
| 153 |
+
<?php echo esc_attr(trim($field['label'])); ?>:
|
| 154 |
+
</strong>
|
| 155 |
+
<br />
|
| 156 |
+
<?php echo esc_html($value); ?>
|
| 157 |
+
</p>
|
| 158 |
+
<?php
|
|
|
|
|
|
|
| 159 |
}
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
}
|
| 163 |
+
} */
|
| 164 |
}
|
| 165 |
|
| 166 |
WOOCCM_Field_Controller_Billing::instance();
|
includes/controller/class-wooccm-field-shipping.php
CHANGED
|
@@ -64,12 +64,16 @@ class WOOCCM_Field_Controller_Shipping extends WOOCCM_Field_Controller
|
|
| 64 |
return $shipping_fields;
|
| 65 |
}
|
| 66 |
|
| 67 |
-
|
| 68 |
$template = WOOCCM()->shipping->get_template_types();
|
| 69 |
|
| 70 |
foreach ($fields as $field_id => $field) {
|
| 71 |
|
| 72 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
continue;
|
| 74 |
}
|
| 75 |
|
| 64 |
return $shipping_fields;
|
| 65 |
}
|
| 66 |
|
| 67 |
+
//$defaults = WOOCCM()->shipping->get_defaults();
|
| 68 |
$template = WOOCCM()->shipping->get_template_types();
|
| 69 |
|
| 70 |
foreach ($fields as $field_id => $field) {
|
| 71 |
|
| 72 |
+
if (!isset($field['name'])) {
|
| 73 |
+
continue;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
if (isset($shipping_fields[$field['name']])) {
|
| 77 |
continue;
|
| 78 |
}
|
| 79 |
|
includes/model/class-wooccm-field.php
CHANGED
|
@@ -295,8 +295,6 @@ class WOOCCM_Field extends WOOCCM_Model
|
|
| 295 |
//reorder array based on ids
|
| 296 |
ksort($fields);
|
| 297 |
|
| 298 |
-
error_log(json_encode($fields, JSON_PRETTY_PRINT));
|
| 299 |
-
|
| 300 |
if ($this->save_items($fields)) {
|
| 301 |
return $fields;
|
| 302 |
}
|
| 295 |
//reorder array based on ids
|
| 296 |
ksort($fields);
|
| 297 |
|
|
|
|
|
|
|
| 298 |
if ($this->save_items($fields)) {
|
| 299 |
return $fields;
|
| 300 |
}
|
includes/model/class-wooccm-model.php
CHANGED
|
@@ -17,7 +17,7 @@ class WOOCCM_Model
|
|
| 17 |
|
| 18 |
$items = $this->get_items();
|
| 19 |
|
| 20 |
-
if (
|
| 21 |
return max(array_keys($items)) + 1;
|
| 22 |
}
|
| 23 |
|
|
@@ -86,7 +86,7 @@ class WOOCCM_Model
|
|
| 86 |
{
|
| 87 |
$items = $this->get_items();
|
| 88 |
if ($items) {
|
| 89 |
-
if (
|
| 90 |
unset($items[$id]);
|
| 91 |
return $this->save($items);
|
| 92 |
}
|
|
@@ -99,7 +99,7 @@ class WOOCCM_Model
|
|
| 99 |
|
| 100 |
$items = $this->get();
|
| 101 |
//make sure each item has all values
|
| 102 |
-
if (
|
| 103 |
foreach ($items as $id => $item) {
|
| 104 |
$items[$id] = array_replace_recursive($this->get_args(), $item);
|
| 105 |
}
|
|
@@ -110,7 +110,7 @@ class WOOCCM_Model
|
|
| 110 |
protected function save_items($items)
|
| 111 |
{
|
| 112 |
|
| 113 |
-
if (
|
| 114 |
foreach ($items as $id => $item) {
|
| 115 |
|
| 116 |
if (!isset($item['id'])) {
|
|
@@ -147,8 +147,6 @@ class WOOCCM_Model
|
|
| 147 |
}
|
| 148 |
|
| 149 |
if (!isset($this->cache[$this->table])) {
|
| 150 |
-
// $this->cache[$this->table] = $this->sanitize_data(get_option($this->table, array()));
|
| 151 |
-
//error_log(json_encode($this->get_defaults(), JSON_PRETTY_PRINT));
|
| 152 |
$this->cache[$this->table] = get_option($this->table, $this->get_defaults());
|
| 153 |
}
|
| 154 |
|
| 17 |
|
| 18 |
$items = $this->get_items();
|
| 19 |
|
| 20 |
+
if (is_array($items)) {
|
| 21 |
return max(array_keys($items)) + 1;
|
| 22 |
}
|
| 23 |
|
| 86 |
{
|
| 87 |
$items = $this->get_items();
|
| 88 |
if ($items) {
|
| 89 |
+
if (is_array($items) > 0) {
|
| 90 |
unset($items[$id]);
|
| 91 |
return $this->save($items);
|
| 92 |
}
|
| 99 |
|
| 100 |
$items = $this->get();
|
| 101 |
//make sure each item has all values
|
| 102 |
+
if (is_array($items)) {
|
| 103 |
foreach ($items as $id => $item) {
|
| 104 |
$items[$id] = array_replace_recursive($this->get_args(), $item);
|
| 105 |
}
|
| 110 |
protected function save_items($items)
|
| 111 |
{
|
| 112 |
|
| 113 |
+
if (is_array($items)) {
|
| 114 |
foreach ($items as $id => $item) {
|
| 115 |
|
| 116 |
if (!isset($item['id'])) {
|
| 147 |
}
|
| 148 |
|
| 149 |
if (!isset($this->cache[$this->table])) {
|
|
|
|
|
|
|
| 150 |
$this->cache[$this->table] = get_option($this->table, $this->get_defaults());
|
| 151 |
}
|
| 152 |
|
readme.txt
CHANGED
|
@@ -4,7 +4,7 @@ Donate link: https://quadlayers.com/
|
|
| 4 |
Tags: woocommerce, woocommerce checkout, field manager, checkout editor, checkout field, shipping field, billing field, order field, additional field
|
| 5 |
Requires at least: 3.4
|
| 6 |
Tested up to: 5.4.2
|
| 7 |
-
Stable tag: 5.0
|
| 8 |
WC requires at least: 3.1.0
|
| 9 |
WC tested up to: 4.2.0
|
| 10 |
License: GPLv2 or later
|
|
@@ -107,6 +107,10 @@ Your Order data can be reviewed in each order within the default WooCommerce Ord
|
|
| 107 |
|
| 108 |
== Changelog ==
|
| 109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
= 5.0.9 =
|
| 111 |
* Fix: woocommerce checkout manager edit billing & shipping
|
| 112 |
|
| 4 |
Tags: woocommerce, woocommerce checkout, field manager, checkout editor, checkout field, shipping field, billing field, order field, additional field
|
| 5 |
Requires at least: 3.4
|
| 6 |
Tested up to: 5.4.2
|
| 7 |
+
Stable tag: 5.1.0
|
| 8 |
WC requires at least: 3.1.0
|
| 9 |
WC tested up to: 4.2.0
|
| 10 |
License: GPLv2 or later
|
| 107 |
|
| 108 |
== Changelog ==
|
| 109 |
|
| 110 |
+
= 5.1.0 =
|
| 111 |
+
* Fix: billing & shipping duplicated in order
|
| 112 |
+
* Fix: php compatbility
|
| 113 |
+
|
| 114 |
= 5.0.9 =
|
| 115 |
* Fix: woocommerce checkout manager edit billing & shipping
|
| 116 |
|
woocommerce-checkout-manager.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
/**
|
| 4 |
* Plugin Name: WooCommerce Checkout Manager
|
| 5 |
* Description: Manages WooCommerce Checkout, the advanced way.
|
| 6 |
-
* Version: 5.0
|
| 7 |
* Author: QuadLayers
|
| 8 |
* Author URI: https://www.quadlayers.com
|
| 9 |
* Copyright: 2019 QuadLayers (https://www.quadlayers.com)
|
|
@@ -19,7 +19,7 @@ if (!defined('WOOCCM_PLUGIN_NAME')) {
|
|
| 19 |
define('WOOCCM_PLUGIN_NAME', 'WooCommerce Checkout Manager');
|
| 20 |
}
|
| 21 |
if (!defined('WOOCCM_PLUGIN_VERSION')) {
|
| 22 |
-
define('WOOCCM_PLUGIN_VERSION', '5.0
|
| 23 |
}
|
| 24 |
if (!defined('WOOCCM_PLUGIN_FILE')) {
|
| 25 |
define('WOOCCM_PLUGIN_FILE', __FILE__);
|
| 3 |
/**
|
| 4 |
* Plugin Name: WooCommerce Checkout Manager
|
| 5 |
* Description: Manages WooCommerce Checkout, the advanced way.
|
| 6 |
+
* Version: 5.1.0
|
| 7 |
* Author: QuadLayers
|
| 8 |
* Author URI: https://www.quadlayers.com
|
| 9 |
* Copyright: 2019 QuadLayers (https://www.quadlayers.com)
|
| 19 |
define('WOOCCM_PLUGIN_NAME', 'WooCommerce Checkout Manager');
|
| 20 |
}
|
| 21 |
if (!defined('WOOCCM_PLUGIN_VERSION')) {
|
| 22 |
+
define('WOOCCM_PLUGIN_VERSION', '5.1.0');
|
| 23 |
}
|
| 24 |
if (!defined('WOOCCM_PLUGIN_FILE')) {
|
| 25 |
define('WOOCCM_PLUGIN_FILE', __FILE__);
|
