WooCommerce Checkout Manager - Version 5.5.7

Version Description

  • Fix: WooCommerce upload files checkout
Download this release

Release Info

Developer quadlayers
Plugin Icon 128x128 WooCommerce Checkout Manager
Version 5.5.7
Comparing to
See all releases

Code changes from version 5.5.6 to 5.5.7

assets/backend/css/admin.css CHANGED
@@ -1 +1 @@
1
- .select2-container{z-index:9999999}.select2-container .select2-selection--single,.select2-container .select2-selection--single .select2-selection__rendered,.select2-container .select2-selection--single .select2-selection__arrow{height:30px !important;line-height:30px !important}.wooccm-premium{opacity:0.5;pointer-events:none}.button.fileinput-button{position:relative;overflow:hidden !important}.button.fileinput-button input{position:absolute;top:0;right:0;margin:0;opacity:0;-ms-filter:'alpha(opacity=0)';font-size:200px;direction:ltr;cursor:pointer}table.wc_gateways>tbody>tr>td select{line-height:1 !important}table.wc_gateways>tbody>tr>td.label{font-weight:600}table.wooccm-enhanced-options{border:none;box-shadow:none}table.wooccm-enhanced-options>thead>th .woocommerce-help-tip{margin:-1px 0 0 0.25em}table.wooccm-enhanced-options>tbody>tr>td input.label{width:100%}table.wooccm-enhanced-options>tbody>tr>td select.add-price-type{margin:0 0 0 10px}table.wooccm-enhanced-options>tbody>tr>td input.check{margin:0 9px}table.wooccm-enhanced-options>tbody>tr>td.sort .wc-item-reorder-nav{width:auto}#wooccm_modal.processing{pointer-events:none}#wooccm_modal.processing:before{content:'';position:absolute;top:0;bottom:0;left:0;right:0;background-color:#ffffff;z-index:99999999;opacity:0.8}#wooccm_modal select{min-height:30px}#wooccm_modal .form-field .wrap{padding:0}#wooccm_modal .attachment-info .details,#wooccm_modal .attachment-info .settings{width:100%}#wooccm_modal .attachment-info .woocommerce_options_panel label,#wooccm_modal .attachment-info .woocommerce_options_panel legend{width:75px;margin:0 0 0 -90px;font-weight:600}#wooccm_modal .attachment-info .woocommerce_options_panel fieldset.form-field,#wooccm_modal .attachment-info .woocommerce_options_panel p.form-field{padding:0 20px 0 92px !important}#wooccm_modal .attachment-info .woocommerce_options_panel input[type=email],#wooccm_modal .attachment-info .woocommerce_options_panel input[type=number],#wooccm_modal .attachment-info .woocommerce_options_panel input[type=password],#wooccm_modal .attachment-info .woocommerce_options_panel input[type=text],#wooccm_modal .attachment-info .woocommerce_options_panel select,#wooccm_modal .attachment-info .woocommerce_options_panel .select2-container{width:100% !important}#wooccm_modal #woocommerce-product-data .woocommerce_options_panel{width:100%}#wooccm_modal #woocommerce-product-data .woocommerce_options_panel .premium{display:block;clear:both}#wooccm_modal #woocommerce-product-data .woocommerce_options_panel .woocommerce-help-tip{margin:0 0 0 0.5em}#wooccm_modal #woocommerce-product-data .woocommerce_options_panel .select2-container{width:50% !important;line-height:16px}#wooccm_modal #woocommerce-product-data .woocommerce_options_panel .select2-container .select2-selection{box-shadow:none;border-radius:3px;padding:0 24px 0 8px}#wooccm_modal #woocommerce-product-data .woocommerce_options_panel .select2-container .select2-selection--multiple{line-height:16px;min-height:30px}@media only screen and (max-width: 1280px){#wooccm_modal #woocommerce-product-data .woocommerce_options_panel .select2-container{width:80% !important}}#wooccm_modal #woocommerce-product-data .woocommerce_options_panel .select2-container--default .select2-selection--multiple .select2-selection__rendered li{margin:3px 3px 0 0}#wooccm_modal #woocommerce-product-data .woocommerce_options_panel .select2-container--default.select2-container--focus .select2-selection--multiple{border-color:#5b9dd9 !important;box-shadow:0 0 2px rgba(30,140,190,0.8) !important;outline:2px solid transparent !important}#wooccm-order-files .inside{margin:0;padding:0;background:#fefefe;display:block !important}#wooccm-order-files .handlediv,#wooccm-order-files .hndle{display:none}#wooccm-order-files .wooccm_upload_results{display:inline-block;margin:0 10px}#wooccm-order-files .wooccm_order_attachments_wrapper{margin:0;overflow-x:auto}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments{width:100%;background:#fff}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments thead th:first-child{padding-left:2em}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments thead th.sortable{cursor:pointer}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments .item{min-width:200px}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments thead th{text-align:left;padding:1em;font-weight:400;color:#999;background:#f8f8f8;user-select:none}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments tbody#order_line_items tr:first-child td{border-top:none}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments tbody tr:last-child td{border-bottom:1px solid #dfdfdf}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments td.thumb{text-align:left;width:38px;padding-bottom:1.5em}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments td.thumb .wc-order-item-thumbnail{width:38px;height:38px;border:2px solid #e8e8e8;background:#f8f8f8;color:#ccc;position:relative;font-size:21px;display:block;text-align:center}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments tbody th:first-child,#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments td:first-child{padding-left:2em}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments tbody th,#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments td{padding:1.5em 1em 1em;text-align:left;line-height:1.5em;vertical-align:top;border-bottom:1px solid #f8f8f8}#wooccm-order-files .wc-order-data-row{border-bottom:1px solid #dfdfdf;padding:1.5em 2em;background:#f8f8f8;line-height:2em;text-align:left}
1
+ .select2-container{z-index:9999999}.select2-container .select2-selection--single,.select2-container .select2-selection--single .select2-selection__rendered,.select2-container .select2-selection--single .select2-selection__arrow{height:30px !important;line-height:30px !important}.wooccm-premium{opacity:0.5;pointer-events:none}.button.fileinput-button{position:relative;overflow:hidden !important}.button.fileinput-button input{position:absolute;top:0;right:0;margin:0;opacity:0;-ms-filter:'alpha(opacity=0)';font-size:200px;direction:ltr;cursor:pointer}table.wc_gateways>tbody>tr>td select{line-height:1 !important}table.wc_gateways>tbody>tr>td.label{font-weight:600}table.wooccm-enhanced-options{border:none;box-shadow:none}table.wooccm-enhanced-options>thead>th .woocommerce-help-tip{margin:-1px 0 0 0.25em}table.wooccm-enhanced-options>tbody>tr>td input.label{width:100%}table.wooccm-enhanced-options>tbody>tr>td select.add-price-type{margin:0 0 0 10px}table.wooccm-enhanced-options>tbody>tr>td input.check{margin:0 9px}table.wooccm-enhanced-options>tbody>tr>td.sort .wc-item-reorder-nav{width:auto}#wooccm_modal.processing{pointer-events:none}#wooccm_modal.processing:before{content:'';position:absolute;top:0;bottom:0;left:0;right:0;background-color:#ffffff;z-index:99999999;opacity:0.8}#wooccm_modal select{min-height:30px}#wooccm_modal .form-field .wrap{padding:0}#wooccm_modal .attachment-info .details,#wooccm_modal .attachment-info .settings{width:100%}#wooccm_modal .attachment-info .woocommerce_options_panel label,#wooccm_modal .attachment-info .woocommerce_options_panel legend{width:75px;margin:0 0 0 -90px;font-weight:600}#wooccm_modal .attachment-info .woocommerce_options_panel fieldset.form-field,#wooccm_modal .attachment-info .woocommerce_options_panel p.form-field{padding:0 20px 0 92px !important}#wooccm_modal .attachment-info .woocommerce_options_panel input[type=email],#wooccm_modal .attachment-info .woocommerce_options_panel input[type=number],#wooccm_modal .attachment-info .woocommerce_options_panel input[type=password],#wooccm_modal .attachment-info .woocommerce_options_panel input[type=text],#wooccm_modal .attachment-info .woocommerce_options_panel select,#wooccm_modal .attachment-info .woocommerce_options_panel .select2-container{width:100% !important}#wooccm_modal #woocommerce-product-data .woocommerce_options_panel{width:100%}#wooccm_modal #woocommerce-product-data .woocommerce_options_panel .premium{display:block;clear:both}#wooccm_modal #woocommerce-product-data .woocommerce_options_panel .woocommerce-help-tip{margin:0 0 0 0.5em}#wooccm_modal #woocommerce-product-data .woocommerce_options_panel .select2-container{width:50% !important;line-height:16px}#wooccm_modal #woocommerce-product-data .woocommerce_options_panel .select2-container .select2-selection{box-shadow:none;border-radius:3px;padding:0 24px 0 8px}#wooccm_modal #woocommerce-product-data .woocommerce_options_panel .select2-container .select2-selection--multiple{line-height:16px;min-height:30px}@media only screen and (max-width: 1280px){#wooccm_modal #woocommerce-product-data .woocommerce_options_panel .select2-container{width:80% !important}}#wooccm_modal #woocommerce-product-data .woocommerce_options_panel .select2-container--default .select2-selection--multiple .select2-selection__rendered li{margin:3px 3px 0 0}#wooccm_modal #woocommerce-product-data .woocommerce_options_panel .select2-container--default.select2-container--focus .select2-selection--multiple{border-color:#5b9dd9 !important;box-shadow:0 0 2px rgba(30,140,190,0.8) !important;outline:2px solid transparent !important}#wooccm-order-files .inside{margin:0;padding:0;background:#fefefe;display:block !important}#wooccm-order-files .handlediv,#wooccm-order-files .hndle{display:none}#wooccm-order-files .wooccm_upload_results{display:inline-block;margin:0 10px}#wooccm-order-files .wooccm_order_attachments_wrapper{margin:0;overflow-x:auto}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments{width:100%;background:#fff}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments thead th:first-child{padding-left:2em}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments thead th.sortable{cursor:pointer}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments .item{min-width:200px}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments thead th{text-align:left;padding:1em;font-weight:400;color:#999;background:#f8f8f8;user-select:none}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments tbody#order_line_items tr:first-child td{border-top:none}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments tbody tr:last-child td{border-bottom:1px solid #dfdfdf}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments td.thumb{text-align:left;width:38px;padding-bottom:1.5em}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments td.thumb .wc-order-item-thumbnail{width:38px;height:38px;border:2px solid #e8e8e8;background:#f8f8f8;color:#ccc;position:relative;font-size:21px;display:block;text-align:center}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments tbody th:first-child,#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments td:first-child{padding-left:2em}#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments tbody th,#wooccm-order-files .wooccm_order_attachments_wrapper table.wooccm_order_attachments td{padding:1.5em 1em 1em;text-align:left;line-height:1.5em;vertical-align:top;border-bottom:1px solid #f8f8f8}#wooccm-order-files .wc-order-data-row{border-bottom:1px solid #dfdfdf;padding:1.5em 2em;background:#f8f8f8;line-height:2em;text-align:left}
assets/frontend/css/checkout.css CHANGED
@@ -1 +1 @@
1
- .woocommerce form .wooccm-clearfix:before,.woocommerce form .wooccm-clearfix:after{content:"";display:table}.woocommerce form .wooccm-clearfix:after{clear:both}.woocommerce form .wooccm-conditional-child{display:none}.woocommerce form .wooccm-type-hidden{display:none}.woocommerce form .wooccm-type-radio .woocommerce-radio-wrapper label{display:inline-block}.woocommerce form .wooccm-colorpicker-iris .iris-picker{display:none}.woocommerce form .wooccm-colorpicker-iris.active .iris-picker{display:block}.button.fileinput-button{position:relative;overflow:hidden !important}.button.fileinput-button input{position:absolute;top:0;right:0;margin:0;opacity:0;-ms-filter:"alpha(opacity=0)";font-size:200px;direction:ltr;cursor:pointer}.wooccm-file-list{margin:0 -5px;padding:0;display:flex;flex-wrap:wrap;align-items:center;justify-content:start}.wooccm-file-list .wooccm-file-file{display:flex;justify-content:center;align-items:stretch;box-sizing:border-box;padding:10px 5px 0 5px;width:25%;position:relative}.wooccm-file-list .wooccm-file-file .wooccm-file-list-delete{z-index:1;position:absolute;top:2px;right:-3px;width:16px;height:16px;background-color:#222;display:block;line-height:16px;text-align:center;color:#fefefe;font-weight:900;border-radius:50%;font-size:12px;cursor:pointer;font-family:code;text-decoration:none !important}.wooccm-file-list .wooccm-file-file .wooccm-file-list-container{width:100%;overflow:hidden}.wooccm-file-list .wooccm-file-file .wooccm-file-list-image-container{display:flex;justify-content:center;align-items:center;overflow:hidden;width:100%;padding-top:100%;position:relative;background:#eee}.wooccm-file-list .wooccm-file-file .wooccm-file-list-image-container>img{overflow:hidden;object-fit:cover;position:absolute;top:30%;bottom:auto;height:40%;opacity:0.8}.wooccm-file-list .wooccm-file-file .wooccm-file-list-image-container>img.image{top:0;bottom:0;left:0;right:0;max-height:100%;max-height:100%;height:100%;width:100%}.wooccm-file-list .ui-timepicker-table a{word-break:normal}.wooccm-file-list .ui-state-disabled,.wooccm-file-list .ui-widget-content .ui-state-disabled,.wooccm-file-list .ui-widget-header .ui-state-disabled{width:100%}
1
+ .woocommerce form .wooccm-clearfix:before,.woocommerce form .wooccm-clearfix:after{content:"";display:table}.woocommerce form .wooccm-clearfix:after{clear:both}.woocommerce form .wooccm-conditional-child{display:none}.woocommerce form .wooccm-type-hidden{display:none}.woocommerce form .wooccm-type-radio .woocommerce-radio-wrapper label{display:inline-block}.woocommerce form .wooccm-colorpicker-iris .iris-picker{display:none}.woocommerce form .wooccm-colorpicker-iris.active .iris-picker{display:block}.button.fileinput-button{position:relative;overflow:hidden !important}.button.fileinput-button input{position:absolute;top:0;right:0;margin:0;opacity:0;-ms-filter:"alpha(opacity=0)";font-size:200px;direction:ltr;cursor:pointer}.wooccm-file-list{margin:0 -5px;padding:0;display:flex;flex-wrap:wrap;align-items:center;justify-content:start}.wooccm-file-list .wooccm-file-file{display:flex;justify-content:center;align-items:stretch;box-sizing:border-box;padding:10px 5px 0 5px;width:25%;position:relative}.wooccm-file-list .wooccm-file-file .wooccm-file-list-delete{z-index:1;position:absolute;top:2px;right:-3px;width:16px;height:16px;background-color:#222;display:block;line-height:16px;text-align:center;color:#fefefe;font-weight:900;border-radius:50%;font-size:12px;cursor:pointer;font-family:code;text-decoration:none !important}.wooccm-file-list .wooccm-file-file .wooccm-file-list-container{width:100%;overflow:hidden}.wooccm-file-list .wooccm-file-file .wooccm-file-list-image-container{display:flex;justify-content:center;align-items:center;overflow:hidden;width:100%;padding-top:100%;position:relative;background:#eee}.wooccm-file-list .wooccm-file-file .wooccm-file-list-image-container>img{overflow:hidden;object-fit:cover;position:absolute;top:30%;bottom:auto;height:40%;opacity:0.8}.wooccm-file-list .wooccm-file-file .wooccm-file-list-image-container>img.image{top:0;bottom:0;left:0;right:0;max-height:100%;max-height:100%;height:100%;width:100%}.wooccm-file-list .ui-timepicker-table a{word-break:normal}.wooccm-file-list .ui-state-disabled,.wooccm-file-list .ui-widget-content .ui-state-disabled,.wooccm-file-list .ui-widget-header .ui-state-disabled{width:100%}
includes/class-wooccm-upload.php CHANGED
@@ -1,161 +1,162 @@
1
  <?php
2
 
3
- class WOOCCM_Upload
4
- {
5
-
6
- protected static $_instance;
7
-
8
- public function __construct()
9
- {
10
- add_action('wp_ajax_wooccm_order_attachment_update', array($this, 'ajax_delete_attachment'));
11
- add_action('wp_ajax_nopriv_wooccm_order_attachment_update', array($this, 'ajax_delete_attachment'));
12
-
13
- // Checkout
14
- // -----------------------------------------------------------------------
15
- add_action('wp_ajax_wooccm_checkout_attachment_upload', array($this, 'ajax_checkout_attachment_upload'));
16
- add_action('wp_ajax_nopriv_wooccm_checkout_attachment_upload', array($this, 'ajax_checkout_attachment_upload'));
17
- add_action('woocommerce_checkout_update_order_meta', array($this, 'update_attachment_ids'), 99);
18
- // }
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- public static function instance()
22
- {
23
- if (is_null(self::$_instance)) {
24
- self::$_instance = new self();
25
- }
26
- return self::$_instance;
27
- }
28
-
29
- protected function process_uploads($files, $key, $post_id = 0)
30
- {
31
-
32
- if (!function_exists('media_handle_upload')) {
33
- require_once(ABSPATH . 'wp-admin/includes/file.php');
34
- require_once(ABSPATH . 'wp-admin/includes/media.php');
35
- require_once(ABSPATH . 'wp-admin/includes/image.php');
36
- }
37
 
38
- $attachment_ids = array();
39
 
40
- add_filter('upload_dir', function ($param) {
41
- $param['path'] = sprintf('%s/wooccm_uploads', $param['basedir']);
42
- $param['url'] = sprintf('%s/wooccm_uploads', $param['baseurl']);
43
- return $param;
44
- }, 10);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
- foreach ($files['name'] as $id => $value) {
 
 
 
 
 
 
47
 
48
- if ($files['name'][$id]) {
49
 
50
- $_FILES[$key] = array(
51
- 'name' => $files['name'][$id],
52
- 'type' => $files['type'][$id],
53
- 'tmp_name' => $files['tmp_name'][$id],
54
- 'error' => $files['error'][$id],
55
- 'size' => $files['size'][$id]
56
- );
57
-
58
- if (!is_wp_error($attachment_id = media_handle_upload($key, $post_id))) {
59
- $attachment_ids[] = $attachment_id;
60
- } else {
61
- wc_add_notice($attachment_id->get_error_message(), 'error');
62
- wp_send_json_error($attachment_id->get_error_message());
63
- }
64
- }
65
- }
66
-
67
- return $attachment_ids;
68
- }
69
-
70
- public function ajax_delete_attachment()
71
- {
72
-
73
- if (!empty($_REQUEST) && check_admin_referer('wooccm_upload', 'nonce')) {
74
-
75
- $array1 = explode(',', sanitize_text_field(isset($_REQUEST['all_attachments_ids']) ? $_REQUEST['all_attachments_ids'] : ''));
76
- $array2 = explode(',', sanitize_text_field(isset($_REQUEST['delete_attachments_ids']) ? $_REQUEST['delete_attachments_ids'] : ''));
77
-
78
- if (empty($array1) || empty($array2)) {
79
- wp_send_json_error(esc_html__('No attachment selected.', 'woocommerce-checkout-manager'));
80
- }
81
-
82
- $attachment_ids = array_diff($array1, $array2);
83
-
84
- if (!empty($attachment_ids)) {
85
-
86
- foreach ($attachment_ids as $key => $attachtoremove) {
87
-
88
- // Check the Attachment exists...
89
- if (get_post_status($attachtoremove) == false)
90
- continue;
91
-
92
- // Check the Attachment is associated with an Order
93
- $post_parent = get_post_field('post_parent', $attachtoremove);
94
-
95
- if (empty($post_parent)) {
96
- continue;
97
- } else {
98
- if (get_post_type($post_parent) <> 'shop_order')
99
- continue;
100
- }
101
- wp_delete_attachment($attachtoremove);
102
- }
103
- }
104
-
105
- wp_send_json_success('Deleted successfully.', 'woocommerce-checkout-manager');
106
- }
107
- }
108
-
109
- public function ajax_checkout_attachment_upload()
110
- {
111
-
112
- if (check_admin_referer('wooccm_upload', 'nonce') && isset($_FILES['wooccm_checkout_attachment_upload'])) {
113
-
114
- $files = $_FILES['wooccm_checkout_attachment_upload'];
115
-
116
- if (empty($files)) {
117
- wc_add_notice(esc_html__('No uploads were recognised. Files were not uploaded.', 'woocommerce-checkout-manager'), 'error');
118
- wp_send_json_error();
119
- }
120
-
121
- if (count($attachment_ids = $this->process_uploads($files, 'wooccm_checkout_attachment_upload'))) {
122
- wp_send_json_success($attachment_ids);
123
- }
124
- wc_add_notice(esc_html__('Unknow error.', 'woocommerce-checkout-manager'), 'error');
125
- wp_send_json_error();
126
- }
127
- }
128
-
129
- public function update_attachment_ids($order_id = 0)
130
- {
131
-
132
- require_once(ABSPATH . 'wp-admin/includes/image.php');
133
-
134
- if (count($checkout = WC()->checkout->get_checkout_fields())) {
135
-
136
- foreach ($checkout as $field_type => $fields) {
137
-
138
- foreach ($fields as $key => $field) {
139
-
140
- if (isset($field['type']) && $field['type'] == 'file') {
141
-
142
- if ($attachments = get_post_meta($order_id, sprintf('_%s', $key), true)) {
143
-
144
- if ($attachments = (array) explode(',', $attachments)) {
145
-
146
- foreach ($attachments as $image_id) {
147
-
148
- wp_update_post(array('ID' => $image_id, 'post_parent' => $order_id));
149
-
150
- wp_update_attachment_metadata($image_id, wp_generate_attachment_metadata($image_id, get_attached_file($image_id)));
151
- }
152
- }
153
- }
154
- }
155
- }
156
- }
157
- }
158
- }
159
  }
160
 
161
  WOOCCM_Upload::instance();
1
  <?php
2
 
3
+ class WOOCCM_Upload {
4
+
5
+
6
+ protected static $_instance;
7
+
8
+ public function __construct() {
9
+ add_action( 'wp_ajax_wooccm_order_attachment_update', array( $this, 'ajax_delete_attachment' ) );
10
+ add_action( 'wp_ajax_nopriv_wooccm_order_attachment_update', array( $this, 'ajax_delete_attachment' ) );
11
+
12
+ // Checkout
13
+ // -----------------------------------------------------------------------
14
+ add_action( 'wp_ajax_wooccm_checkout_attachment_upload', array( $this, 'ajax_checkout_attachment_upload' ) );
15
+ add_action( 'wp_ajax_nopriv_wooccm_checkout_attachment_upload', array( $this, 'ajax_checkout_attachment_upload' ) );
16
+ add_action( 'woocommerce_checkout_update_order_meta', array( $this, 'update_attachment_ids' ), 99 );
17
+ // }
18
+ }
19
+
20
+ public static function instance() {
21
+ if ( is_null( self::$_instance ) ) {
22
+ self::$_instance = new self();
23
+ }
24
+ return self::$_instance;
25
+ }
26
+
27
+ protected function process_uploads( $files, $key, $post_id = 0 ) {
28
+ if ( ! function_exists( 'media_handle_upload' ) ) {
29
+ require_once ABSPATH . 'wp-admin/includes/file.php';
30
+ require_once ABSPATH . 'wp-admin/includes/media.php';
31
+ require_once ABSPATH . 'wp-admin/includes/image.php';
32
+ }
33
+
34
+ $attachment_ids = array();
35
+
36
+ add_filter(
37
+ 'upload_dir',
38
+ function ( $param ) {
39
+ $param['path'] = sprintf( '%s/wooccm_uploads', $param['basedir'] );
40
+ $param['url'] = sprintf( '%s/wooccm_uploads', $param['baseurl'] );
41
+ return $param;
42
+ },
43
+ 10
44
+ );
45
 
46
+ foreach ( $files['name'] as $id => $value ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
+ if ( $files['name'][ $id ] ) {
49
 
50
+ $_FILES[ $key ] = array(
51
+ 'name' => $files['name'][ $id ],
52
+ 'type' => $files['type'][ $id ],
53
+ 'tmp_name' => $files['tmp_name'][ $id ],
54
+ 'error' => $files['error'][ $id ],
55
+ 'size' => $files['size'][ $id ],
56
+ );
57
+
58
+ if ( ! is_wp_error( $attachment_id = media_handle_upload( $key, $post_id ) ) ) {
59
+ $attachment_ids[] = $attachment_id;
60
+ } else {
61
+ wc_add_notice( $attachment_id->get_error_message(), 'error' );
62
+ // wp_send_json_error( $attachment_id->get_error_message() );
63
+ }
64
+ }
65
+ }
66
+
67
+ return $attachment_ids;
68
+ }
69
+
70
+ public function ajax_delete_attachment() {
71
+ if ( ! empty( $_REQUEST ) && check_admin_referer( 'wooccm_upload', 'nonce' ) ) {
72
+
73
+ $array1 = explode( ',', sanitize_text_field( isset( $_REQUEST['all_attachments_ids'] ) ? $_REQUEST['all_attachments_ids'] : '' ) );
74
+ $array2 = explode( ',', sanitize_text_field( isset( $_REQUEST['delete_attachments_ids'] ) ? $_REQUEST['delete_attachments_ids'] : '' ) );
75
+
76
+ if ( empty( $array1 ) || empty( $array2 ) ) {
77
+ wp_send_json_error( esc_html__( 'No attachment selected.', 'woocommerce-checkout-manager' ) );
78
+ }
79
+
80
+ $attachment_ids = array_diff( $array1, $array2 );
81
+
82
+ if ( ! empty( $attachment_ids ) ) {
83
+
84
+ foreach ( $attachment_ids as $key => $attachtoremove ) {
85
+
86
+ // Check the Attachment exists...
87
+ if ( get_post_status( $attachtoremove ) == false ) {
88
+ continue;
89
+ }
90
+
91
+ // Check the Attachment is associated with an Order
92
+ $post_parent = get_post_field( 'post_parent', $attachtoremove );
93
+
94
+ if ( empty( $post_parent ) ) {
95
+ continue;
96
+ } else {
97
+ if ( get_post_type( $post_parent ) <> 'shop_order' ) {
98
+ continue;
99
+ }
100
+ }
101
+ wp_delete_attachment( $attachtoremove );
102
+ }
103
+ }
104
+
105
+ wp_send_json_success( 'Deleted successfully.', 'woocommerce-checkout-manager' );
106
+ }
107
+ }
108
+
109
+ public function ajax_checkout_attachment_upload() {
110
+ if ( check_admin_referer( 'wooccm_upload', 'nonce' ) && isset( $_FILES['wooccm_checkout_attachment_upload'] ) ) {
111
+
112
+ $files = $_FILES['wooccm_checkout_attachment_upload'];
113
+
114
+ if ( empty( $files ) ) {
115
+ wc_add_notice( esc_html__( 'No uploads were recognised. Files were not uploaded.', 'woocommerce-checkout-manager' ), 'error' );
116
+ wp_send_json_error();
117
+ }
118
+
119
+ if ( count( $attachment_ids = $this->process_uploads( $files, 'wooccm_checkout_attachment_upload' ) ) ) {
120
+ wp_send_json_success( $attachment_ids );
121
+ }
122
+ wc_add_notice( esc_html__( 'Unknow error.', 'woocommerce-checkout-manager' ), 'error' );
123
+ wp_send_json_error();
124
+ }
125
+ }
126
+
127
+ public function update_attachment_ids( $order_id = 0 ) {
128
+ require_once ABSPATH . 'wp-admin/includes/image.php';
129
+
130
+ if ( count( $checkout = WC()->checkout->get_checkout_fields() ) ) {
131
+
132
+ foreach ( $checkout as $field_type => $fields ) {
133
 
134
+ foreach ( $fields as $key => $field ) {
135
+
136
+ if ( isset( $field['type'] ) && $field['type'] == 'file' ) {
137
+
138
+ if ( $attachments = get_post_meta( $order_id, sprintf( '_%s', $key ), true ) ) {
139
+
140
+ if ( $attachments = (array) explode( ',', $attachments ) ) {
141
 
142
+ foreach ( $attachments as $image_id ) {
143
 
144
+ wp_update_post(
145
+ array(
146
+ 'ID' => $image_id,
147
+ 'post_parent' => $order_id,
148
+ )
149
+ );
150
+
151
+ wp_update_attachment_metadata( $image_id, wp_generate_attachment_metadata( $image_id, get_attached_file( $image_id ) ) );
152
+ }
153
+ }
154
+ }
155
+ }
156
+ }
157
+ }
158
+ }
159
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  }
161
 
162
  WOOCCM_Upload::instance();
includes/view/backend/pages/advanced.php CHANGED
@@ -1,12 +1,4 @@
1
- <?php include_once( 'parts/tabs.php' ); ?>
2
- <h1 class="screen-reader-text"><?php esc_html_e('Advanced', 'woocommerce-checkout-manager'); ?></h1>
3
- <h2><?php esc_html_e('Advanced settings', 'woocommerce-checkout-manager'); ?></h2>
4
- <!--<div id="<?php printf('wooccm_%s_settings-description', $current_section); ?>">
5
- <p><?php printf(esc_html__('Customize and manage the checkout %s fields.', 'woocommerce-checkout-manager'), $current_section); ?></p>
6
- </div>
7
- <?php if (current_user_can('manage_options')) : ?>
8
- <a href="<?php echo add_query_arg(array('action' => 'wooccm_nuke_options', '_wpnonce' => wp_create_nonce('wooccm_nuke_options'))); ?>" class="button button-secondary" data-confirm="<?php esc_html_e('This will permanently delete all WordPress Options associated with WooCommerce Checkout Manager. Are you sure you want to proceed?', 'woocommerce-checkout-manager'); ?>"><?php esc_html_e('Delete Options', 'woocommerce-checkout-manager'); ?></a>
9
- <a href="<?php echo add_query_arg(array('action' => 'wooccm_nuke_order_meta', '_wpnonce' => wp_create_nonce('wooccm_nuke_order_meta'))); ?>" class="button button-secondary" data-confirm="<?php esc_html_e('This will permanently delete all WordPress Post meta associated with that is linked to Orders. Are you sure you want to proceed?', 'woocommerce-checkout-manager'); ?>"><?php esc_html_e('Delete Orders Post meta', 'woocommerce-checkout-manager'); ?></a>
10
- <a href="<?php echo add_query_arg(array('action' => 'wooccm_nuke_user_meta', '_wpnonce' => wp_create_nonce('wooccm_nuke_user_meta'))); ?>" class="button button-secondary" data-confirm="<?php esc_html_e('This will permanently delete all WordPress Post meta associated with that is linked to Users. Are you sure you want to proceed?', 'woocommerce-checkout-manager'); ?>"><?php esc_html_e('Delete Users Post meta', 'woocommerce-checkout-manager'); ?></a>
11
- <?php endif; ?>-->
12
- <?php woocommerce_admin_fields($settings); ?>
1
+ <?php require_once 'parts/tabs.php'; ?>
2
+ <h1 class="screen-reader-text"><?php esc_html_e( 'Advanced', 'woocommerce-checkout-manager' ); ?></h1>
3
+ <h2><?php esc_html_e( 'Advanced settings', 'woocommerce-checkout-manager' ); ?></h2>
4
+ <?php woocommerce_admin_fields( $settings ); ?>
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -3,10 +3,10 @@ Contributors: quadlayers
3
  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.9
7
- Stable tag: 5.5.6
8
  WC requires at least: 3.1.0
9
- WC tested up to: 6.4
10
  License: GPLv3
11
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
12
 
@@ -107,6 +107,9 @@ Your Order data can be reviewed in each order within the default WooCommerce Ord
107
 
108
  == Changelog ==
109
 
 
 
 
110
  = 5.5.6 =
111
  * Fix: WooCommerce compatibility
112
 
3
  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: 6.0
7
+ Stable tag: 5.5.7
8
  WC requires at least: 3.1.0
9
+ WC tested up to: 6.5
10
  License: GPLv3
11
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
12
 
107
 
108
  == Changelog ==
109
 
110
+ = 5.5.7 =
111
+ * Fix: WooCommerce upload files checkout
112
+
113
  = 5.5.6 =
114
  * Fix: WooCommerce compatibility
115
 
templates/order/order-upload-files.php CHANGED
@@ -1,58 +1,61 @@
1
  <div class="wooccm_order_attachments_wrapper">
2
- <h2 class="woocommerce-order-details__title"><?php echo ($title = get_option('wooccm_order_upload_files_title', false)) ? esc_html($title) : esc_html__('Uploaded files', 'woocommerce-checkout-manager'); ?></h2>
3
- <table class="woocommerce_order_items shop_table">
4
- <thead>
5
- <tr>
6
- <th><?php esc_html_e('File', 'woocommerce-checkout-manager'); ?></th>
7
- <th><?php esc_html_e('Filename', 'woocommerce-checkout-manager'); ?></th>
8
- <th><?php esc_html_e('Dimensions', 'woocommerce-checkout-manager'); ?></th>
9
- <th><?php esc_html_e('Extension', ' woocommerce-checkout-manager'); ?></th>
10
- <th class="column-actions"><?php esc_html_e('Actions', 'woocommerce-checkout-manager'); ?></th>
11
- </tr>
12
- </thead>
13
- <tbody class="product_images">
14
- <?php
15
- if (!empty($attachments)) :
16
- foreach ($attachments as $attachment_id) :
17
- $image_attributes = wp_get_attachment_url($attachment_id);
18
- $image_attributes2 = wp_get_attachment_image_src($attachment_id);
19
- $filename = basename($image_attributes);
20
- $wp_filetype = wp_check_filetype($filename);
21
- ?>
22
- <tr class="image">
23
- <td><?php echo wp_get_attachment_link($attachment_id, '', false, false, wp_get_attachment_image($attachment_id, array(75, 75), false)); ?></td>
24
- <td><?php echo wp_get_attachment_link($attachment_id, '', false, false, preg_replace('/\.[^.]+$/', '', $filename)); ?></td>
25
- <td>
26
- <?php
27
- if ($image_attributes2[1] == '') {
28
- echo '-';
29
- } else {
30
- echo $image_attributes2[1] . ' x ' . $image_attributes2[2];
31
- }
32
- ?>
33
- </td>
34
- <td><?php echo strtoupper($wp_filetype['ext']); ?></td>
35
- <td class="column-actions">
36
- <!--<a href="<?php echo esc_url($image_attributes2[0]); ?>" target="_blank" class="button"><?php esc_html_e('Download', 'woocommerce-checkout-manager'); ?></a>-->
37
- <a class="button wooccm_delete_attachment" data-attachment_id="<?php echo esc_attr($attachment_id); ?>" data-tip="<?php esc_html_e('Delete', 'woocommerce-checkout-manager'); ?>"><?php esc_html_e('Delete', 'woocommerce-checkout-manager'); ?></a>
38
- </td>
39
- </tr>
40
- <?php endforeach; ?>
41
- <?php else: ?>
42
- <tr>
43
- <td colspan="6" style="text-align:left;"><?php esc_html_e('No files have been uploaded to this order.', 'woocommerce-checkout-manager'); ?></td>
44
- </tr>
45
- <?php endif; ?>
46
- </tbody>
47
- </table>
48
- <input type="hidden" id="delete_attachments_ids" name="delete_attachments_ids" value="<?php echo esc_attr(implode(',', $attachments)); ?>" />
49
- <input type="hidden" id="all_attachments_ids" name="all_attachments_ids" value="<?php echo esc_attr(implode(',', $attachments)); ?>" />
50
- <p class="order-upload">
51
- <a style="float: left; margin: 0 10px 0 0;" class="button alt fileinput-button">
52
- <span><?php esc_html_e('Upload Files', 'woocommerce-checkout-manager'); ?></span>
53
- <input data-order_id="<?php echo esc_attr($order->get_id()); ?>" type="file" name="wooccm_order_attachment_upload" id="wooccm_order_attachment_upload" multiple />
54
- </a>
55
- <input type="button" id="wooccm_order_attachment_update" class="button button-secondary" value="<?php esc_html_e('Save Changes', 'woocommerce-checkout-manager'); ?>" disabled="disabled">
56
- <span class="wooccm_upload_results"></span>
57
- </p>
58
- </div>
 
 
 
1
  <div class="wooccm_order_attachments_wrapper">
2
+ <h2 class="woocommerce-order-details__title">
3
+ <?php echo ( $title = get_option( 'wooccm_order_upload_files_title', false ) ) ? esc_html( $title ) : esc_html__( 'Uploaded files', 'woocommerce-checkout-manager' ); ?>
4
+ </h2>
5
+ <table class="woocommerce_order_items shop_table">
6
+ <thead>
7
+ <tr>
8
+ <th><?php esc_html_e( 'File', 'woocommerce-checkout-manager' ); ?></th>
9
+ <th><?php esc_html_e( 'Filename', 'woocommerce-checkout-manager' ); ?></th>
10
+ <th><?php esc_html_e( 'Dimensions', 'woocommerce-checkout-manager' ); ?></th>
11
+ <th><?php esc_html_e( 'Extension', ' woocommerce-checkout-manager' ); ?></th>
12
+ <th class="column-actions"><?php esc_html_e( 'Actions', 'woocommerce-checkout-manager' ); ?></th>
13
+ </tr>
14
+ </thead>
15
+ <tbody class="product_images">
16
+ <?php
17
+ if ( ! empty( $attachments ) ) :
18
+ foreach ( $attachments as $attachment_id ) :
19
+ $image_attributes = wp_get_attachment_url( $attachment_id );
20
+ $is_image = wp_attachment_is_image( $attachment_id );
21
+ $filename = basename( $image_attributes );
22
+ $wp_filetype = wp_check_filetype( $filename );
23
+ ?>
24
+ <tr class="image">
25
+ <td><?php echo wp_get_attachment_link( $attachment_id, '', false, false, wp_get_attachment_image( $attachment_id, array( 75, 75 ), false ) ); ?></td>
26
+ <td><?php echo wp_get_attachment_link( $attachment_id, '', false, false, preg_replace( '/\.[^.]+$/', '', $filename ) ); ?></td>
27
+ <td>
28
+ <?php
29
+ if ( $is_image ) {
30
+ $sizes = wp_get_attachment_image_src( $attachment_id );
31
+
32
+ echo $sizes[1] . 'x' . $sizes[2];
33
+ }
34
+ ?>
35
+ </td>
36
+ <td>
37
+ <?php echo strtoupper( $wp_filetype['ext'] ); ?>
38
+ </td>
39
+ <td class="column-actions">
40
+ <a class="button wooccm_delete_attachment" data-attachment_id="<?php echo esc_attr( $attachment_id ); ?>" data-tip="<?php esc_html_e( 'Delete', 'woocommerce-checkout-manager' ); ?>"><?php esc_html_e( 'Delete', 'woocommerce-checkout-manager' ); ?></a>
41
+ </td>
42
+ </tr>
43
+ <?php endforeach; ?>
44
+ <?php else : ?>
45
+ <tr>
46
+ <td colspan="6" style="text-align:left;"><?php esc_html_e( 'No files have been uploaded to this order.', 'woocommerce-checkout-manager' ); ?></td>
47
+ </tr>
48
+ <?php endif; ?>
49
+ </tbody>
50
+ </table>
51
+ <input type="hidden" id="delete_attachments_ids" name="delete_attachments_ids" value="<?php echo esc_attr( implode( ',', $attachments ) ); ?>" />
52
+ <input type="hidden" id="all_attachments_ids" name="all_attachments_ids" value="<?php echo esc_attr( implode( ',', $attachments ) ); ?>" />
53
+ <p class="order-upload">
54
+ <a style="float: left; margin: 0 10px 0 0;" class="button alt fileinput-button">
55
+ <span><?php esc_html_e( 'Upload Files', 'woocommerce-checkout-manager' ); ?></span>
56
+ <input data-order_id="<?php echo esc_attr( $order->get_id() ); ?>" type="file" name="wooccm_order_attachment_upload" id="wooccm_order_attachment_upload" multiple />
57
+ </a>
58
+ <input type="button" id="wooccm_order_attachment_update" class="button button-secondary" value="<?php esc_html_e( 'Save Changes', 'woocommerce-checkout-manager' ); ?>" disabled="disabled">
59
+ <span class="wooccm_upload_results"></span>
60
+ </p>
61
+ </div>
woocommerce-checkout-manager.php CHANGED
@@ -4,13 +4,13 @@
4
  * Plugin Name: Checkout Fields Manager for WooCommerce
5
  * Plugin URI: https://quadlayers.com/portfolio/woocommerce-checkout-manager/
6
  * Description: Manages WooCommerce Checkout, the advanced way.
7
- * Version: 5.5.6
8
  * Author: QuadLayers
9
  * Author URI: https://quadlayers.com
10
  * License: GPLv3
11
  * Text Domain: woocommerce-checkout-manager
12
  * WC requires at least: 3.1.0
13
- * WC tested up to: 6.4
14
  */
15
  if ( ! defined( 'ABSPATH' ) ) {
16
  die( '-1' );
@@ -20,7 +20,7 @@ if ( ! defined( 'WOOCCM_PLUGIN_NAME' ) ) {
20
  define( 'WOOCCM_PLUGIN_NAME', 'Checkout Fields Manager for WooCommerce' );
21
  }
22
  if ( ! defined( 'WOOCCM_PLUGIN_VERSION' ) ) {
23
- define( 'WOOCCM_PLUGIN_VERSION', '5.5.6' );
24
  }
25
  if ( ! defined( 'WOOCCM_PLUGIN_FILE' ) ) {
26
  define( 'WOOCCM_PLUGIN_FILE', __FILE__ );
4
  * Plugin Name: Checkout Fields Manager for WooCommerce
5
  * Plugin URI: https://quadlayers.com/portfolio/woocommerce-checkout-manager/
6
  * Description: Manages WooCommerce Checkout, the advanced way.
7
+ * Version: 5.5.7
8
  * Author: QuadLayers
9
  * Author URI: https://quadlayers.com
10
  * License: GPLv3
11
  * Text Domain: woocommerce-checkout-manager
12
  * WC requires at least: 3.1.0
13
+ * WC tested up to: 6.5
14
  */
15
  if ( ! defined( 'ABSPATH' ) ) {
16
  die( '-1' );
20
  define( 'WOOCCM_PLUGIN_NAME', 'Checkout Fields Manager for WooCommerce' );
21
  }
22
  if ( ! defined( 'WOOCCM_PLUGIN_VERSION' ) ) {
23
+ define( 'WOOCCM_PLUGIN_VERSION', '5.5.7' );
24
  }
25
  if ( ! defined( 'WOOCCM_PLUGIN_FILE' ) ) {
26
  define( 'WOOCCM_PLUGIN_FILE', __FILE__ );