Version Description
- 2020-08-13 =
- Fixed PHP sessions issues
Download this release
Release Info
Developer | wpdesk |
Plugin | Flexible Shipping for WooCommerce |
Version | 3.11.2 |
Comparing to | |
See all releases |
Code changes from version 3.11.1 to 3.11.2
- classes/class-flexible-shipping-plugin.php +4 -17
- classes/table-rate/bulk-actions.php +452 -440
- composer.lock +65 -11
- flexible-shipping.php +2 -2
- readme.txt +4 -1
- vendor/autoload.php +1 -1
- vendor/composer/autoload_classmap.php +3 -0
- vendor/composer/autoload_real.php +4 -4
- vendor/composer/autoload_static.php +8 -5
- vendor_prefixed/wpdesk/wpdesk-sessions/composer.json +52 -0
- vendor_prefixed/wpdesk/wpdesk-sessions/src/WPDesk/Sessions/Adapter/WooCommerceSession.php +46 -0
- vendor_prefixed/wpdesk/wpdesk-sessions/src/WPDesk/Sessions/Session.php +32 -0
- vendor_prefixed/wpdesk/wpdesk-sessions/src/WPDesk/Sessions/SessionFactory.php +33 -0
classes/class-flexible-shipping-plugin.php
CHANGED
@@ -14,6 +14,7 @@ use FSVendor\WPDesk\PluginBuilder\Plugin\HookableCollection;
|
|
14 |
use FSVendor\WPDesk\PluginBuilder\Plugin\HookableParent;
|
15 |
use FSVendor\WPDesk\PluginBuilder\Plugin\TemplateLoad;
|
16 |
use FSVendor\WPDesk\Pointer\PointersScripts;
|
|
|
17 |
use FSVendor\WPDesk\Tracker\Deactivation\PluginData;
|
18 |
use FSVendor\WPDesk\Tracker\Deactivation\TrackerFactory;
|
19 |
use FSVendor\WPDesk\View\Resolver\ChainResolver;
|
@@ -137,13 +138,15 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
137 |
require_once( __DIR__ . '/wp-wpdesk-fs-shipment/shipment/functions.php' );
|
138 |
require_once( __DIR__ . '/manifest/functions.php' );
|
139 |
|
|
|
|
|
140 |
new WPDesk_Flexible_Shipping_Shipment_CPT( $this );
|
141 |
|
142 |
new WPDesk_Flexible_Shipping_Shipping_Manifest_CPT( $this );
|
143 |
|
144 |
new WPDesk_Flexible_Shipping_Shipment_Ajax( $this );
|
145 |
|
146 |
-
new WPDesk_Flexible_Shipping_Bulk_Actions();
|
147 |
|
148 |
new WPDesk_Flexible_Shipping_Export( $this );
|
149 |
|
@@ -294,8 +297,6 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
294 |
|
295 |
add_filter( 'woocommerce_shipping_methods', array( $this, 'woocommerce_shipping_methods_filter' ), 10, 1 );
|
296 |
|
297 |
-
add_action( 'admin_init', array( $this, 'session_init' ) );
|
298 |
-
|
299 |
add_action( 'woocommerce_after_shipping_rate', array( $this, 'woocommerce_after_shipping_rate' ), 10, 2 );
|
300 |
|
301 |
add_action(
|
@@ -422,20 +423,6 @@ class Flexible_Shipping_Plugin extends AbstractPlugin implements HookableCollect
|
|
422 |
return $value;
|
423 |
}
|
424 |
|
425 |
-
/**
|
426 |
-
* Session init.
|
427 |
-
*/
|
428 |
-
public function session_init() {
|
429 |
-
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
430 |
-
return;
|
431 |
-
}
|
432 |
-
// @codingStandardsIgnoreStart
|
433 |
-
if ( ! session_id() ) {
|
434 |
-
session_start();
|
435 |
-
}
|
436 |
-
// @codingStandardsIgnoreEnd
|
437 |
-
}
|
438 |
-
|
439 |
/**
|
440 |
* Add flexible shipping order meta on checkout.
|
441 |
*
|
14 |
use FSVendor\WPDesk\PluginBuilder\Plugin\HookableParent;
|
15 |
use FSVendor\WPDesk\PluginBuilder\Plugin\TemplateLoad;
|
16 |
use FSVendor\WPDesk\Pointer\PointersScripts;
|
17 |
+
use FSVendor\WPDesk\Session\SessionFactory;
|
18 |
use FSVendor\WPDesk\Tracker\Deactivation\PluginData;
|
19 |
use FSVendor\WPDesk\Tracker\Deactivation\TrackerFactory;
|
20 |
use FSVendor\WPDesk\View\Resolver\ChainResolver;
|
138 |
require_once( __DIR__ . '/wp-wpdesk-fs-shipment/shipment/functions.php' );
|
139 |
require_once( __DIR__ . '/manifest/functions.php' );
|
140 |
|
141 |
+
$session_factory = new SessionFactory();
|
142 |
+
|
143 |
new WPDesk_Flexible_Shipping_Shipment_CPT( $this );
|
144 |
|
145 |
new WPDesk_Flexible_Shipping_Shipping_Manifest_CPT( $this );
|
146 |
|
147 |
new WPDesk_Flexible_Shipping_Shipment_Ajax( $this );
|
148 |
|
149 |
+
$this->add_hookable( new WPDesk_Flexible_Shipping_Bulk_Actions( $session_factory ) );
|
150 |
|
151 |
new WPDesk_Flexible_Shipping_Export( $this );
|
152 |
|
297 |
|
298 |
add_filter( 'woocommerce_shipping_methods', array( $this, 'woocommerce_shipping_methods_filter' ), 10, 1 );
|
299 |
|
|
|
|
|
300 |
add_action( 'woocommerce_after_shipping_rate', array( $this, 'woocommerce_after_shipping_rate' ), 10, 2 );
|
301 |
|
302 |
add_action(
|
423 |
return $value;
|
424 |
}
|
425 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
/**
|
427 |
* Add flexible shipping order meta on checkout.
|
428 |
*
|
classes/table-rate/bulk-actions.php
CHANGED
@@ -1,175 +1,99 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
$this->hooks();
|
10 |
-
}
|
11 |
|
12 |
-
|
|
|
|
|
|
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
$this,
|
17 |
-
'manage_shop_order_posts_custom_column'
|
18 |
-
), 11 );
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
$this,
|
23 |
-
'handle_bulk_actions_edit_shop_order'
|
24 |
-
), 10, 3 );
|
25 |
|
26 |
-
|
27 |
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
//add_filter( 'posts_clauses', array( $this, 'posts_clauses' ), 999, 2 );
|
32 |
|
33 |
-
|
34 |
|
35 |
-
|
36 |
|
37 |
-
|
38 |
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
52 |
}
|
53 |
-
|
54 |
-
|
55 |
-
global $pagenow;
|
56 |
-
global $wp_query;
|
57 |
-
global $wpdb;
|
58 |
-
$query = $wp_query;
|
59 |
-
$type = 'shop_order';
|
60 |
-
if ( isset( $_GET['post_type'] ) ) {
|
61 |
-
$type = sanitize_key( $_GET['post_type'] );
|
62 |
-
}
|
63 |
-
if ( isset( $query->query_vars['post_type'] ) && $query->query_vars['post_type'] == 'shop_order' ) {
|
64 |
-
if ( 'shop_order' == $type && is_admin() && 'edit.php' == $pagenow ) {
|
65 |
-
$integration = '';
|
66 |
-
if (isset($_GET['flexible_shipping_integration_filter'])) {
|
67 |
-
$integration = sanitize_key( $_GET['flexible_shipping_integration_filter'] );
|
68 |
-
}
|
69 |
-
$status = '';
|
70 |
-
if (isset($_GET['flexible_shipping_status_filter'])) {
|
71 |
-
$status = sanitize_key( $_GET['flexible_shipping_status_filter'] );
|
72 |
-
}
|
73 |
-
if ( $integration != '' || $status != '' ) {
|
74 |
-
$add_where_meta_integration = '';
|
75 |
-
$add_where_meta_status = '';
|
76 |
-
$add_where_shipment_integration = '';
|
77 |
-
$add_where_shipment_status = '';
|
78 |
-
$add_where = '';
|
79 |
-
if ( $integration != '' ) {
|
80 |
-
$add_where_meta_integration = " EXISTS ( SELECT 1 FROM {$wpdb->postmeta} fs_postmeta WHERE {$wpdb->posts}.ID = fs_postmeta.post_id AND fs_postmeta.meta_key = '_flexible_shipping_integration' AND fs_postmeta.meta_value = '$integration' ) ";
|
81 |
-
$add_where_shipment_integration = " EXISTS ( SELECT 1 FROM {$wpdb->posts} fs_posts, {$wpdb->postmeta} fs_postmeta WHERE {$wpdb->posts}.ID = fs_posts.post_parent AND fs_posts.ID = fs_postmeta.post_id AND fs_postmeta.meta_key = '_integration' AND fs_postmeta.meta_value = '$integration' ) ";
|
82 |
-
}
|
83 |
-
if ( $status != '' ) {
|
84 |
-
$add_where_meta_status = " EXISTS ( SELECT 1 FROM {$wpdb->postmeta} fs_postmeta WHERE {$wpdb->posts}.ID = fs_postmeta.post_id AND fs_postmeta.meta_key = '_flexible_shipping_status' AND fs_postmeta.meta_value = '$status' ) ";
|
85 |
-
$add_where_shipment_status = " EXISTS ( SELECT 1 FROM {$wpdb->posts} fs_posts WHERE {$wpdb->posts}.ID = fs_posts.post_parent AND fs_posts.post_status = 'fs-{$status}' ) ";
|
86 |
-
}
|
87 |
-
$add_where_meta = '';
|
88 |
-
if ( $add_where_meta_integration != '' ) {
|
89 |
-
$add_where_meta .= $add_where_meta_integration;
|
90 |
-
}
|
91 |
-
if ( $add_where_meta_status != '' ) {
|
92 |
-
if ( $add_where_meta != '' ) {
|
93 |
-
$add_where_meta .= ' AND ';
|
94 |
-
}
|
95 |
-
$add_where_meta .= $add_where_meta_status;
|
96 |
-
}
|
97 |
-
$add_where_shipment = '';
|
98 |
-
if ( $add_where_shipment_integration != '' ) {
|
99 |
-
$add_where_shipment .= $add_where_shipment_integration;
|
100 |
-
}
|
101 |
-
if ( $add_where_shipment_status != '' ) {
|
102 |
-
if ( $add_where_shipment != '' ) {
|
103 |
-
$add_where_shipment .= ' AND ';
|
104 |
-
}
|
105 |
-
$add_where_shipment .= $add_where_shipment_status;
|
106 |
-
}
|
107 |
-
$add_where_meta = ' ( ' . $add_where_meta . ' ) ';
|
108 |
-
$add_where_shipment = ' ( ' . $add_where_shipment . ' ) ';
|
109 |
-
$add_where = ' AND ( ' . $add_where_meta . ' OR ' . $add_where_shipment . ' ) ';
|
110 |
-
$where .= $add_where;
|
111 |
-
}
|
112 |
-
}
|
113 |
-
}
|
114 |
-
return $where;
|
115 |
-
}
|
116 |
-
|
117 |
-
public function parse_query( $query ) {
|
118 |
-
global $pagenow;
|
119 |
-
$type = 'shop_order';
|
120 |
-
if ( isset( $_GET['post_type'] ) ) {
|
121 |
-
$type = sanitize_key( $_GET['post_type'] );
|
122 |
-
}
|
123 |
-
if ( isset( $query->query_vars['post_type'] ) && $query->query_vars['post_type'] == 'shop_order' ) {
|
124 |
-
if ( 'shop_order' == $type && is_admin() && 'edit.php' == $pagenow ) {
|
125 |
-
$integration = '';
|
126 |
-
if ( isset( $_GET['flexible_shipping_integration_filter'] ) ) {
|
127 |
-
$integration = sanitize_key( $_GET['flexible_shipping_integration_filter'] );
|
128 |
-
}
|
129 |
-
$status = '';
|
130 |
-
if ( isset( $_GET['flexible_shipping_status_filter'] ) ) {
|
131 |
-
$status = sanitize_key( $_GET['flexible_shipping_status_filter'] );
|
132 |
-
}
|
133 |
-
if ( $integration != '' || $status != '' ) {
|
134 |
-
if ($integration != '') {
|
135 |
-
if (!isset($query->query_vars['meta_query'])) {
|
136 |
-
$query->query_vars['meta_query'] = array();
|
137 |
-
}
|
138 |
-
$meta_query = array();
|
139 |
-
$meta_query['key'] = '_flexible_shipping_integration';
|
140 |
-
$meta_query['value'] = $integration;
|
141 |
-
$query->query_vars['meta_query'][] = $meta_query;
|
142 |
-
}
|
143 |
-
/* */
|
144 |
-
if ($status != '') {
|
145 |
-
if (!isset($query->query_vars['meta_query'])) {
|
146 |
-
$query->query_vars['meta_query'] = array();
|
147 |
-
}
|
148 |
-
$meta_query = array();
|
149 |
-
$meta_query['key'] = '_flexible_shipping_status';
|
150 |
-
$meta_query['value'] = $status;
|
151 |
-
$query->query_vars['meta_query'][] = $meta_query;
|
152 |
-
}
|
153 |
-
}
|
154 |
-
}
|
155 |
-
}
|
156 |
-
}
|
157 |
-
|
158 |
-
public function restrict_manage_posts() {
|
159 |
-
|
160 |
-
if ( apply_filters( 'flexible_shipping_disable_order_filters', false ) ) {
|
161 |
-
return;
|
162 |
-
}
|
163 |
-
|
164 |
-
$integrations = apply_filters( 'flexible_shipping_integration_options', array() );
|
165 |
-
if ( count( $integrations ) == 0 ) {
|
166 |
-
return;
|
167 |
-
}
|
168 |
-
|
169 |
-
global $typenow;
|
170 |
-
if ( 'shop_order' == $typenow ){
|
171 |
-
$integrations = apply_filters( 'flexible_shipping_integration_options', array() );
|
172 |
-
$statuses = apply_filters( 'flexible_shipping_status', array() );
|
173 |
$integration = '';
|
174 |
if ( isset( $_GET['flexible_shipping_integration_filter'] ) ) {
|
175 |
$integration = sanitize_key( $_GET['flexible_shipping_integration_filter'] );
|
@@ -178,327 +102,415 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping_Bulk_Actions' ) ) {
|
|
178 |
if ( isset( $_GET['flexible_shipping_status_filter'] ) ) {
|
179 |
$status = sanitize_key( $_GET['flexible_shipping_status_filter'] );
|
180 |
}
|
181 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
}
|
183 |
}
|
184 |
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
);
|
195 |
-
$statuses = array(
|
196 |
-
'error' => __('Error', 'flexible-shipping'),
|
197 |
-
'new' => __('New shipment', 'flexible-shipping'),
|
198 |
-
'created' => __('Created', 'flexible-shipping'),
|
199 |
-
'confirmed' => __('Confirmed', 'flexible-shipping'),
|
200 |
-
'manifest' => __('Manifest created', 'flexible-shipping'),
|
201 |
-
);
|
202 |
-
$shippings = array();
|
203 |
-
$shipments = fs_get_order_shipments($post->ID);
|
204 |
-
foreach ($shipments as $shipment) {
|
205 |
-
/* @var $shipment WPDesk_Flexible_Shipping_Shipment|WPDesk_Flexible_Shipping_Shipment_Interface */
|
206 |
-
$shipping = array();
|
207 |
-
$shipping['order_id'] = $post->ID;
|
208 |
-
$shipping['integration'] = $shipment->get_integration();
|
209 |
-
$shipping['url'] = $shipment->get_order_metabox_url();
|
210 |
-
$shipping['error'] = $shipment->get_error_message();
|
211 |
-
$shipping['status'] = $shipment->get_status_for_shipping_column();
|
212 |
-
$shipping['tracking_number'] = $shipment->get_tracking_number();
|
213 |
-
$shipping['label_url'] = $shipment->get_label_url();
|
214 |
-
$shipping['tracking_url'] = $shipment->get_tracking_url();
|
215 |
-
$shipping['shipment'] = $shipment;
|
216 |
-
$shippings[] = $shipping;
|
217 |
-
}
|
218 |
-
$shippings = apply_filters( 'flexible_shipping_shipping_data', $shippings );
|
219 |
-
if (!session_id()) {
|
220 |
-
session_start();
|
221 |
-
}
|
222 |
-
foreach ($shippings as $shipping) {
|
223 |
-
if ($shipping['status'] == 'error') {
|
224 |
-
$statuses['error'] = $shipping['error'];
|
225 |
-
} else {
|
226 |
-
$statuses['error'] = __('Error', 'flexible-shipping');
|
227 |
-
}
|
228 |
-
include( 'views/html-column-shipping-shipping.php' );
|
229 |
-
}
|
230 |
-
$messages = array();
|
231 |
-
if (isset($_SESSION['flexible_shipping_bulk_send'])) {
|
232 |
-
$messages = $_SESSION['flexible_shipping_bulk_send'];
|
233 |
-
}
|
234 |
-
if (isset($messages[$post->ID])) {
|
235 |
-
unset($messages[$post->ID]);
|
236 |
-
}
|
237 |
-
$_SESSION['flexible_shipping_bulk_send'] = $messages;
|
238 |
-
}
|
239 |
}
|
240 |
|
241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
$integrations = apply_filters( 'flexible_shipping_integration_options', array() );
|
243 |
-
|
244 |
-
|
|
|
|
|
245 |
}
|
246 |
-
|
247 |
-
|
|
|
248 |
}
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
}
|
258 |
-
|
259 |
}
|
260 |
-
|
261 |
-
|
|
|
262 |
}
|
263 |
-
|
264 |
}
|
|
|
265 |
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
|
|
|
|
276 |
}
|
|
|
277 |
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
$
|
284 |
-
foreach ( $post_ids as $post_id ) {
|
285 |
-
$shipments = fs_get_order_shipments( $post_id );
|
286 |
-
$messages[$post_id] = array();
|
287 |
-
foreach ($shipments as $shipment) {
|
288 |
-
/* @var $shipment WPDesk_Flexible_Shipping_Shipment|WPDesk_Flexible_Shipping_Shipment_Interface */
|
289 |
-
try {
|
290 |
-
$shipment->set_sent_via_bulk();
|
291 |
-
$shipment->api_create();
|
292 |
-
$messages[$post_id][$shipment->get_id()] = array(
|
293 |
-
'status' => 'created',
|
294 |
-
'message' => __( 'Shipment created.', 'flexible-shipping' )
|
295 |
-
);
|
296 |
-
}
|
297 |
-
catch ( Exception $e ) {
|
298 |
-
$messages[$post_id][$shipment->get_id()] = array(
|
299 |
-
'status' => 'error',
|
300 |
-
'message' => $e->getMessage()
|
301 |
-
);
|
302 |
-
}
|
303 |
-
}
|
304 |
-
$messages[$post_id][] = apply_filters(
|
305 |
-
'flexible_shipping_bulk_send',
|
306 |
-
array( 'status' => 'none', 'message' => __( 'No action performed.', 'flexible-shipping' )
|
307 |
-
), $post_id );
|
308 |
-
}
|
309 |
-
if ( ! session_id() ) {
|
310 |
-
session_start();
|
311 |
-
}
|
312 |
-
$_SESSION['flexible_shipping_bulk_send'] = $messages;
|
313 |
-
$redirect_to = add_query_arg( 'bulk_flexible_shipping_send', count( $post_ids ), $redirect_to );
|
314 |
-
return $redirect_to;
|
315 |
}
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
if ( 0 === count( $labels ) ) {
|
322 |
-
$redirect_to = add_query_arg( 'bulk_flexible_shipping_labels', count( $post_ids ), $redirect_to );
|
323 |
-
$redirect_to = add_query_arg( 'bulk_flexible_shipping_no_labels_created', 1, $redirect_to );
|
324 |
-
return $redirect_to;
|
325 |
-
}
|
326 |
|
327 |
-
|
328 |
-
|
329 |
-
$labels_file_creator->create_labels_file();
|
330 |
-
$labels['tmp_file'] = $labels_file_creator->get_tmp_file_name();
|
331 |
-
$labels['client_file'] = $labels_file_creator->get_file_name();
|
332 |
-
} catch ( WPDesk_Flexible_Shipping_Unable_To_Create_Tmp_Zip_File_Exception $zip_file_exception ) {
|
333 |
-
$labels['error'] = __( 'Unable to create temporary zip archive for labels. Check temporary folder configuration on server.', 'flexible-shipping' );
|
334 |
-
} catch ( WPDesk_Flexible_Shipping_Unable_To_Create_Tmp_File_Exception $tmp_file_exception ) {
|
335 |
-
$labels['error'] = __( 'Unable to create temporary file for labels. Check temporary folder configuration on server.', 'flexible-shipping' );
|
336 |
-
}
|
337 |
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
|
343 |
-
|
|
|
344 |
|
345 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
346 |
}
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
$shipments = fs_get_order_shipments( $post_id );
|
351 |
-
foreach ( $shipments as $shipment ) {
|
352 |
-
/* @var $shipment WPDesk_Flexible_Shipping_Shipment|WPDesk_Flexible_Shipping_Shipment_Interface */
|
353 |
-
if ( $shipment->get_status() != 'fs-confirmed' || $shipment->get_meta( '_manifest', '' ) != '' ) {
|
354 |
-
continue;
|
355 |
-
}
|
356 |
-
try {
|
357 |
-
$integration = $shipment->get_integration();
|
358 |
-
$manifest_name = $integration;
|
359 |
-
if ( method_exists( $shipment, 'get_manifest_name' ) ) {
|
360 |
-
$manifest_name = $shipment->get_manifest_name();
|
361 |
-
}
|
362 |
-
$manifest = null;
|
363 |
-
if ( empty( $manifests[$manifest_name] ) ) {
|
364 |
-
if ( fs_manifest_integration_exists( $integration ) ) {
|
365 |
-
$manifest = fs_create_manifest( $integration );
|
366 |
-
}
|
367 |
-
}
|
368 |
-
else {
|
369 |
-
$manifest = $manifests[$manifest_name];
|
370 |
-
}
|
371 |
-
if ( $manifest != null ) {
|
372 |
-
$manifest->add_shipments( $shipment );
|
373 |
-
$manifest->save();
|
374 |
-
$shipment->update_status('fs-manifest' );
|
375 |
-
$shipment->save();
|
376 |
-
$manifests[$manifest_name] = $manifest;
|
377 |
-
}
|
378 |
-
}
|
379 |
-
catch ( Exception $e ) {
|
380 |
-
}
|
381 |
-
}
|
382 |
-
}
|
383 |
-
$messages = array();
|
384 |
-
$integrations = apply_filters( 'flexible_shipping_integration_options', array() );
|
385 |
-
foreach ( $manifests as $manifest ) {
|
386 |
-
try {
|
387 |
-
$manifest->generate();
|
388 |
-
$manifest->save();
|
389 |
-
$download_manifest_url = admin_url('edit.php?post_type=shipping_manifest&flexible_shipping_download_manifest=' . $manifest->get_id() . '&nonce=' . wp_create_nonce('flexible_shipping_download_manifest'));
|
390 |
-
$messages[] = array(
|
391 |
-
'type' => 'updated',
|
392 |
-
'message' => sprintf(
|
393 |
-
__( 'Created manifest: %s (%s). If download not start automatically click %shere%s.', 'flexible-shipping' ),
|
394 |
-
$manifest->get_number(),
|
395 |
-
$integrations[$manifest->get_integration()],
|
396 |
-
'<a class="shipping_manifest_download" target="_blank" href="' . $download_manifest_url . '">',
|
397 |
-
'</a>'
|
398 |
-
)
|
399 |
-
);
|
400 |
-
}
|
401 |
-
catch( Exception $e ) {
|
402 |
-
$messages[] = array(
|
403 |
-
'type' => 'error',
|
404 |
-
'message' => sprintf(
|
405 |
-
__( 'Manifest creation error: %s (%s).', 'flexible-shipping' ),
|
406 |
-
$e->getMessage(),
|
407 |
-
$integrations[$manifest->get_integration()]
|
408 |
-
)
|
409 |
-
);
|
410 |
-
fs_delete_manifest( $manifest );
|
411 |
-
}
|
412 |
-
}
|
413 |
-
if ( count( $messages ) == 0 ) {
|
414 |
-
$messages[] = array(
|
415 |
-
'type' => 'updated',
|
416 |
-
'message' => __( 'No manifests created.', 'flexible-shipping' )
|
417 |
-
);
|
418 |
-
}
|
419 |
-
$_SESSION['flexible_shipping_bulk_manifests'] = $messages;
|
420 |
-
$redirect_to = add_query_arg( 'bulk_flexible_shipping_manifests', count( $post_ids ), $redirect_to );
|
421 |
-
return $redirect_to;
|
422 |
-
}
|
423 |
return $redirect_to;
|
424 |
}
|
|
|
|
|
|
|
425 |
|
426 |
-
|
427 |
-
if (
|
428 |
-
$
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
);
|
433 |
}
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
if ( ! session_id() ) {
|
444 |
-
session_start();
|
445 |
}
|
446 |
-
|
447 |
-
|
448 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
449 |
}
|
450 |
-
|
451 |
-
|
452 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
453 |
} else {
|
454 |
-
$
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
);
|
|
|
|
|
|
|
459 |
}
|
|
|
|
|
460 |
}
|
461 |
}
|
462 |
}
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
481 |
}
|
482 |
|
483 |
-
|
484 |
-
|
485 |
-
*/
|
486 |
-
public function dispatch_labels_file_if_expected() {
|
487 |
-
if ( isset( $_GET['flexible_shipping_labels'] ) && isset( $_GET['tmp_file'] ) && isset( $_GET['nonce'] ) ) {
|
488 |
-
if ( wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['nonce'] ) ), 'flexible_shipping_labels' ) ) {
|
489 |
-
$file = trailingslashit( sys_get_temp_dir() ) . sanitize_text_field( wp_unslash( $_GET['flexible_shipping_labels'] ) );
|
490 |
-
$tmp_file = trailingslashit( sys_get_temp_dir() ) . sanitize_text_field( wp_unslash( $_GET['tmp_file'] ) );
|
491 |
-
|
492 |
-
if ( ! file_exists( $tmp_file ) ) {
|
493 |
-
die( 'This file was already downloaded! Please retry bulk action!' );
|
494 |
-
}
|
495 |
|
496 |
-
|
497 |
-
|
498 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
499 |
}
|
500 |
}
|
501 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
502 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
503 |
}
|
|
|
504 |
}
|
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* Bulk actions.
|
4 |
+
*
|
5 |
+
* @package Flexible Shipping
|
6 |
+
*/
|
7 |
+
|
8 |
+
use FSVendor\WPDesk\Notice\Notice;
|
9 |
+
use FSVendor\WPDesk\PluginBuilder\Plugin\Hookable;
|
10 |
+
use FSVendor\WPDesk\Session\Session;
|
11 |
+
use FSVendor\WPDesk\Session\SessionFactory;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Can handle bulk actions on shipments.
|
15 |
+
*/
|
16 |
+
class WPDesk_Flexible_Shipping_Bulk_Actions implements Hookable {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* .
|
20 |
+
*
|
21 |
+
* @var SessionFactory
|
22 |
+
*/
|
23 |
+
private $session_factory;
|
24 |
+
|
25 |
+
/**
|
26 |
+
* WPDesk_Flexible_Shipping_Bulk_Actions constructor.
|
27 |
+
*
|
28 |
+
* @param SessionFactory $session_factory .
|
29 |
+
*/
|
30 |
+
public function __construct( SessionFactory $session_factory ) {
|
31 |
+
$this->session_factory = $session_factory;
|
32 |
+
}
|
33 |
|
34 |
+
/**
|
35 |
+
* @return Session
|
36 |
+
*/
|
37 |
+
public function get_session() {
|
38 |
+
return $this->session_factory->get_woocommerce_session_adapter();
|
39 |
+
}
|
|
|
|
|
40 |
|
41 |
+
/**
|
42 |
+
* Hooks.
|
43 |
+
*/
|
44 |
+
public function hooks() {
|
45 |
|
46 |
+
add_filter( 'manage_edit-shop_order_columns', array( $this, 'manage_edit_shop_order_columns' ), 11 );
|
47 |
+
add_action( 'manage_shop_order_posts_custom_column', array( $this, 'manage_shop_order_posts_custom_column' ), 11 );
|
|
|
|
|
|
|
48 |
|
49 |
+
add_filter( 'bulk_actions-edit-shop_order', array( $this, 'bulk_actions_edit_shop_order' ) );
|
50 |
+
add_filter( 'handle_bulk_actions-edit-shop_order', array( $this, 'handle_bulk_actions_edit_shop_order' ), 10, 3 );
|
|
|
|
|
|
|
51 |
|
52 |
+
add_action( 'restrict_manage_posts', array( $this, 'restrict_manage_posts' ), 9999 );
|
53 |
|
54 |
+
add_filter( 'posts_where', array( $this, 'posts_where' ), 999 );
|
55 |
|
56 |
+
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
|
|
57 |
|
58 |
+
add_action( 'admin_init', array( $this, 'dispatch_labels_file_if_expected' ), 1 );
|
59 |
|
60 |
+
add_filter( 'flexible_shipping_status', array( $this, 'flexible_shipping_status' ) );
|
61 |
|
62 |
+
}
|
63 |
|
64 |
+
/**
|
65 |
+
* .
|
66 |
+
*
|
67 |
+
* @param array $statuses .
|
68 |
+
*
|
69 |
+
* @return mixed
|
70 |
+
*/
|
71 |
+
public function flexible_shipping_status( $statuses ) {
|
72 |
+
$statuses['new'] = __( 'New', 'flexible-shipping' );
|
73 |
+
$statuses['created'] = __( 'Created', 'flexible-shipping' );
|
74 |
+
$statuses['confirmed'] = __( 'Confirmed', 'flexible-shipping' );
|
75 |
+
$statuses['manifest'] = __( 'Manifest', 'flexible-shipping' );
|
76 |
+
$statuses['failed'] = __( 'Failed', 'flexible-shipping' );
|
77 |
+
|
78 |
+
return $statuses;
|
79 |
+
}
|
80 |
|
81 |
+
/**
|
82 |
+
* @param string $where .
|
83 |
+
*
|
84 |
+
* @return string
|
85 |
+
*/
|
86 |
+
public function posts_where( $where = '' ) {
|
87 |
+
global $pagenow;
|
88 |
+
global $wp_query;
|
89 |
+
global $wpdb;
|
90 |
+
$query = $wp_query;
|
91 |
+
$type = 'shop_order';
|
92 |
+
if ( isset( $_GET['post_type'] ) ) {
|
93 |
+
$type = sanitize_key( $_GET['post_type'] );
|
94 |
}
|
95 |
+
if ( isset( $query->query_vars['post_type'] ) && 'shop_order' === $query->query_vars['post_type'] ) {
|
96 |
+
if ( 'shop_order' == $type && is_admin() && 'edit.php' == $pagenow ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
$integration = '';
|
98 |
if ( isset( $_GET['flexible_shipping_integration_filter'] ) ) {
|
99 |
$integration = sanitize_key( $_GET['flexible_shipping_integration_filter'] );
|
102 |
if ( isset( $_GET['flexible_shipping_status_filter'] ) ) {
|
103 |
$status = sanitize_key( $_GET['flexible_shipping_status_filter'] );
|
104 |
}
|
105 |
+
if ( '' !== $integration || '' !== $status ) {
|
106 |
+
$add_where_meta_integration = '';
|
107 |
+
$add_where_meta_status = '';
|
108 |
+
$add_where_shipment_integration = '';
|
109 |
+
$add_where_shipment_status = '';
|
110 |
+
$add_where = '';
|
111 |
+
if ( '' !== $integration ) {
|
112 |
+
$add_where_meta_integration = " EXISTS ( SELECT 1 FROM {$wpdb->postmeta} fs_postmeta WHERE {$wpdb->posts}.ID = fs_postmeta.post_id AND fs_postmeta.meta_key = '_flexible_shipping_integration' AND fs_postmeta.meta_value = '$integration' ) ";
|
113 |
+
$add_where_shipment_integration = " EXISTS ( SELECT 1 FROM {$wpdb->posts} fs_posts, {$wpdb->postmeta} fs_postmeta WHERE {$wpdb->posts}.ID = fs_posts.post_parent AND fs_posts.ID = fs_postmeta.post_id AND fs_postmeta.meta_key = '_integration' AND fs_postmeta.meta_value = '$integration' ) ";
|
114 |
+
}
|
115 |
+
if ( '' !== $status ) {
|
116 |
+
$add_where_meta_status = " EXISTS ( SELECT 1 FROM {$wpdb->postmeta} fs_postmeta WHERE {$wpdb->posts}.ID = fs_postmeta.post_id AND fs_postmeta.meta_key = '_flexible_shipping_status' AND fs_postmeta.meta_value = '$status' ) ";
|
117 |
+
$add_where_shipment_status = " EXISTS ( SELECT 1 FROM {$wpdb->posts} fs_posts WHERE {$wpdb->posts}.ID = fs_posts.post_parent AND fs_posts.post_status = 'fs-{$status}' ) ";
|
118 |
+
}
|
119 |
+
$add_where_meta = '';
|
120 |
+
if ( '' !== $add_where_meta_integration ) {
|
121 |
+
$add_where_meta .= $add_where_meta_integration;
|
122 |
+
}
|
123 |
+
if ( '' !== $add_where_meta_status ) {
|
124 |
+
if ( '' !== $add_where_meta ) {
|
125 |
+
$add_where_meta .= ' AND ';
|
126 |
+
}
|
127 |
+
$add_where_meta .= $add_where_meta_status;
|
128 |
+
}
|
129 |
+
$add_where_shipment = '';
|
130 |
+
if ( '' !== $add_where_shipment_integration ) {
|
131 |
+
$add_where_shipment .= $add_where_shipment_integration;
|
132 |
+
}
|
133 |
+
if ( '' !== $add_where_shipment_status ) {
|
134 |
+
if ( '' !== $add_where_shipment ) {
|
135 |
+
$add_where_shipment .= ' AND ';
|
136 |
+
}
|
137 |
+
$add_where_shipment .= $add_where_shipment_status;
|
138 |
+
}
|
139 |
+
$add_where_meta = ' ( ' . $add_where_meta . ' ) ';
|
140 |
+
$add_where_shipment = ' ( ' . $add_where_shipment . ' ) ';
|
141 |
+
$add_where = ' AND ( ' . $add_where_meta . ' OR ' . $add_where_shipment . ' ) ';
|
142 |
+
$where .= $add_where;
|
143 |
+
}
|
144 |
}
|
145 |
}
|
146 |
|
147 |
+
return $where;
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* .
|
152 |
+
*/
|
153 |
+
public function restrict_manage_posts() {
|
154 |
+
if ( apply_filters( 'flexible_shipping_disable_order_filters', false ) ) {
|
155 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
}
|
157 |
|
158 |
+
$integrations = apply_filters( 'flexible_shipping_integration_options', array() );
|
159 |
+
if ( 0 === count( $integrations ) ) {
|
160 |
+
return;
|
161 |
+
}
|
162 |
+
|
163 |
+
global $typenow;
|
164 |
+
if ( 'shop_order' === $typenow ) {
|
165 |
$integrations = apply_filters( 'flexible_shipping_integration_options', array() );
|
166 |
+
$statuses = apply_filters( 'flexible_shipping_status', array() );
|
167 |
+
$integration = '';
|
168 |
+
if ( isset( $_GET['flexible_shipping_integration_filter'] ) ) {
|
169 |
+
$integration = sanitize_key( $_GET['flexible_shipping_integration_filter'] );
|
170 |
}
|
171 |
+
$status = '';
|
172 |
+
if ( isset( $_GET['flexible_shipping_status_filter'] ) ) {
|
173 |
+
$status = sanitize_key( $_GET['flexible_shipping_status_filter'] );
|
174 |
}
|
175 |
+
include( 'views/html-orders-filter-form.php' );
|
176 |
+
}
|
177 |
+
}
|
178 |
|
179 |
+
/**
|
180 |
+
* @param string $column .
|
181 |
+
*/
|
182 |
+
public function manage_shop_order_posts_custom_column( $column ) {
|
183 |
+
global $post;
|
184 |
+
if ( 'flexible_shipping' === $column ) {
|
185 |
+
$classes = array(
|
186 |
+
'error' => 'failed',
|
187 |
+
'new' => 'on-hold',
|
188 |
+
'created' => 'processing created',
|
189 |
+
'confirmed' => 'processing confirmed',
|
190 |
+
'manifest' => 'processing manifest',
|
191 |
+
);
|
192 |
+
$statuses = array(
|
193 |
+
'error' => __( 'Error', 'flexible-shipping' ),
|
194 |
+
'new' => __( 'New shipment', 'flexible-shipping' ),
|
195 |
+
'created' => __( 'Created', 'flexible-shipping' ),
|
196 |
+
'confirmed' => __( 'Confirmed', 'flexible-shipping' ),
|
197 |
+
'manifest' => __( 'Manifest created', 'flexible-shipping' ),
|
198 |
+
);
|
199 |
+
$shippings = array();
|
200 |
+
$shipments = fs_get_order_shipments( $post->ID );
|
201 |
+
foreach ( $shipments as $shipment ) {
|
202 |
+
/* @var $shipment WPDesk_Flexible_Shipping_Shipment|WPDesk_Flexible_Shipping_Shipment_Interface */
|
203 |
+
$shipping = array();
|
204 |
+
$shipping['order_id'] = $post->ID;
|
205 |
+
$shipping['integration'] = $shipment->get_integration();
|
206 |
+
$shipping['url'] = $shipment->get_order_metabox_url();
|
207 |
+
$shipping['error'] = $shipment->get_error_message();
|
208 |
+
$shipping['status'] = $shipment->get_status_for_shipping_column();
|
209 |
+
$shipping['tracking_number'] = $shipment->get_tracking_number();
|
210 |
+
$shipping['label_url'] = $shipment->get_label_url();
|
211 |
+
$shipping['tracking_url'] = $shipment->get_tracking_url();
|
212 |
+
$shipping['shipment'] = $shipment;
|
213 |
+
$shippings[] = $shipping;
|
214 |
+
}
|
215 |
+
$shippings = apply_filters( 'flexible_shipping_shipping_data', $shippings );
|
216 |
+
foreach ( $shippings as $shipping ) {
|
217 |
+
if ( 'error' === $shipping['status'] ) {
|
218 |
+
$statuses['error'] = $shipping['error'];
|
219 |
+
} else {
|
220 |
+
$statuses['error'] = __( 'Error', 'flexible-shipping' );
|
221 |
}
|
222 |
+
include( 'views/html-column-shipping-shipping.php' );
|
223 |
}
|
224 |
+
$messages = $this->get_session()->get( 'flexible_shipping_bulk_send', array() );
|
225 |
+
if ( isset( $messages[ $post->ID ] ) ) {
|
226 |
+
unset( $messages[ $post->ID ] );
|
227 |
}
|
228 |
+
$this->get_session()->set( 'flexible_shipping_bulk_send', $messages );
|
229 |
}
|
230 |
+
}
|
231 |
|
232 |
+
/**
|
233 |
+
* @param array $columns .
|
234 |
+
*
|
235 |
+
* @return array
|
236 |
+
*/
|
237 |
+
public function manage_edit_shop_order_columns( $columns ) {
|
238 |
+
$integrations = apply_filters( 'flexible_shipping_integration_options', array() );
|
239 |
+
if ( count( $integrations ) == 0 ) {
|
240 |
+
return $columns;
|
241 |
+
}
|
242 |
+
if ( isset( $columns['flexible_shipping'] ) ) {
|
243 |
+
return $columns;
|
244 |
}
|
245 |
+
$ret = array();
|
246 |
|
247 |
+
$col_added = false;
|
248 |
+
|
249 |
+
foreach ( $columns as $key => $column ) {
|
250 |
+
if ( ! $col_added && ( 'order_actions' === $key || 'wc_actions' === $key ) ) {
|
251 |
+
$ret['flexible_shipping'] = __( 'Shipping', 'flexible-shipping' );
|
252 |
+
$col_added = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
}
|
254 |
+
$ret[ $key ] = $column;
|
255 |
+
}
|
256 |
+
if ( ! $col_added ) {
|
257 |
+
$ret['flexible_shipping'] = __( 'Shipping', 'flexible-shipping' );
|
258 |
+
}
|
|
|
|
|
|
|
|
|
|
|
259 |
|
260 |
+
return $ret;
|
261 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
|
263 |
+
/**
|
264 |
+
* @param array $bulk_actions .
|
265 |
+
*
|
266 |
+
* @return mixed
|
267 |
+
*/
|
268 |
+
public function bulk_actions_edit_shop_order( $bulk_actions ) {
|
269 |
+
$integrations = apply_filters( 'flexible_shipping_integration_options', array() );
|
270 |
+
if ( count( $integrations ) ) {
|
271 |
+
$bulk_actions['flexible_shipping_send'] = __( 'Send shipment', 'flexible-shipping' );
|
272 |
+
$bulk_actions['flexible_shipping_labels'] = __( 'Get labels', 'flexible-shipping' );
|
273 |
+
if ( apply_filters( 'flexible_shipping_has_manifests', false ) ) {
|
274 |
+
$bulk_actions['flexible_shipping_manifest'] = __( 'Create shipping manifest', 'flexible-shipping' );
|
275 |
+
}
|
276 |
+
}
|
277 |
|
278 |
+
return $bulk_actions;
|
279 |
+
}
|
280 |
|
281 |
+
/**
|
282 |
+
* @param string $redirect_to .
|
283 |
+
* @param string $do_action .
|
284 |
+
* @param array $post_ids .
|
285 |
+
*
|
286 |
+
* @return bool|string
|
287 |
+
*/
|
288 |
+
public function handle_bulk_actions_edit_shop_order( $redirect_to, $do_action, $post_ids ) {
|
289 |
+
$redirect_to = remove_query_arg( 'bulk_flexible_shipping_send', $redirect_to );
|
290 |
+
$redirect_to = remove_query_arg( 'bulk_flexible_shipping_labels', $redirect_to );
|
291 |
+
$redirect_to = remove_query_arg( 'bulk_flexible_shipping_manifests', $redirect_to );
|
292 |
+
if ( 'flexible_shipping_send' === $do_action ) {
|
293 |
+
$messages = array();
|
294 |
+
foreach ( $post_ids as $post_id ) {
|
295 |
+
$shipments = fs_get_order_shipments( $post_id );
|
296 |
+
$messages[ $post_id ] = array();
|
297 |
+
foreach ( $shipments as $shipment ) {
|
298 |
+
/* @var $shipment WPDesk_Flexible_Shipping_Shipment|WPDesk_Flexible_Shipping_Shipment_Interface */
|
299 |
+
try {
|
300 |
+
$shipment->set_sent_via_bulk();
|
301 |
+
$shipment->api_create();
|
302 |
+
$messages[ $post_id ][ $shipment->get_id() ] = array(
|
303 |
+
'status' => 'created',
|
304 |
+
'message' => __( 'Shipment created.', 'flexible-shipping' ),
|
305 |
+
);
|
306 |
+
} catch ( Exception $e ) {
|
307 |
+
$messages[ $post_id ][ $shipment->get_id() ] = array(
|
308 |
+
'status' => 'error',
|
309 |
+
'message' => $e->getMessage(),
|
310 |
+
);
|
311 |
+
}
|
312 |
+
}
|
313 |
+
$messages[ $post_id ][] = apply_filters(
|
314 |
+
'flexible_shipping_bulk_send',
|
315 |
+
array(
|
316 |
+
'status' => 'none',
|
317 |
+
'message' => __( 'No action performed.', 'flexible-shipping' ),
|
318 |
+
),
|
319 |
+
$post_id
|
320 |
+
);
|
321 |
}
|
322 |
+
$this->get_session()->set( 'flexible_shipping_bulk_send', $messages );
|
323 |
+
$redirect_to = add_query_arg( 'bulk_flexible_shipping_send', count( $post_ids ), $redirect_to );
|
324 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
return $redirect_to;
|
326 |
}
|
327 |
+
if ( 'flexible_shipping_labels' === $do_action ) {
|
328 |
+
$labels_bulk_actions_handler = WPDesk_Flexible_Shipping_Labels_Bulk_Action_Handler::get_labels_bulk_actions_handler();
|
329 |
+
$labels_bulk_actions_handler->bulk_process_orders( $post_ids );
|
330 |
|
331 |
+
$labels = $labels_bulk_actions_handler->get_labels_for_shipments();
|
332 |
+
if ( 0 === count( $labels ) ) {
|
333 |
+
$redirect_to = add_query_arg( 'bulk_flexible_shipping_labels', count( $post_ids ), $redirect_to );
|
334 |
+
$redirect_to = add_query_arg( 'bulk_flexible_shipping_no_labels_created', 1, $redirect_to );
|
335 |
+
|
336 |
+
return $redirect_to;
|
|
|
337 |
}
|
338 |
+
|
339 |
+
try {
|
340 |
+
$labels_file_creator = new WPDesk_Flexible_Shipping_Labels_File_Creator( $labels );
|
341 |
+
$labels_file_creator->create_labels_file();
|
342 |
+
$labels['tmp_file'] = $labels_file_creator->get_tmp_file_name();
|
343 |
+
$labels['client_file'] = $labels_file_creator->get_file_name();
|
344 |
+
foreach ( $labels as $key => $label ) {
|
345 |
+
if ( is_array( $labels[ $key ] ) && isset( $labels[ $key ]['content'] ) ) {
|
346 |
+
unset( $labels[ $key ]['content'] );
|
|
|
|
|
347 |
}
|
348 |
+
}
|
349 |
+
} catch ( WPDesk_Flexible_Shipping_Unable_To_Create_Tmp_Zip_File_Exception $zip_file_exception ) {
|
350 |
+
$labels['error'] = __( 'Unable to create temporary zip archive for labels. Check temporary folder configuration on server.', 'flexible-shipping' );
|
351 |
+
} catch ( WPDesk_Flexible_Shipping_Unable_To_Create_Tmp_File_Exception $tmp_file_exception ) {
|
352 |
+
$labels['error'] = __( 'Unable to create temporary file for labels. Check temporary folder configuration on server.', 'flexible-shipping' );
|
353 |
+
}
|
354 |
+
|
355 |
+
$this->get_session()->set( 'flexible_shipping_bulk_labels', $labels );
|
356 |
+
|
357 |
+
$redirect_to = add_query_arg( 'bulk_flexible_shipping_labels', count( $post_ids ), $redirect_to );
|
358 |
+
|
359 |
+
return $redirect_to;
|
360 |
+
}
|
361 |
+
if ( 'flexible_shipping_manifest' === $do_action ) {
|
362 |
+
$manifests = array();
|
363 |
+
foreach ( $post_ids as $post_id ) {
|
364 |
+
$shipments = fs_get_order_shipments( $post_id );
|
365 |
+
foreach ( $shipments as $shipment ) {
|
366 |
+
/* @var $shipment WPDesk_Flexible_Shipping_Shipment|WPDesk_Flexible_Shipping_Shipment_Interface */
|
367 |
+
if ( $shipment->get_status() != 'fs-confirmed' || $shipment->get_meta( '_manifest', '' ) != '' ) {
|
368 |
+
continue;
|
369 |
}
|
370 |
+
try {
|
371 |
+
$integration = $shipment->get_integration();
|
372 |
+
$manifest_name = $integration;
|
373 |
+
if ( method_exists( $shipment, 'get_manifest_name' ) ) {
|
374 |
+
$manifest_name = $shipment->get_manifest_name();
|
375 |
+
}
|
376 |
+
$manifest = null;
|
377 |
+
if ( empty( $manifests[ $manifest_name ] ) ) {
|
378 |
+
if ( fs_manifest_integration_exists( $integration ) ) {
|
379 |
+
$manifest = fs_create_manifest( $integration );
|
380 |
+
}
|
381 |
} else {
|
382 |
+
$manifest = $manifests[ $manifest_name ];
|
383 |
+
}
|
384 |
+
if ( null !== $manifest ) {
|
385 |
+
$manifest->add_shipments( $shipment );
|
386 |
+
$manifest->save();
|
387 |
+
$shipment->update_status( 'fs-manifest' );
|
388 |
+
$shipment->save();
|
389 |
+
$manifests[ $manifest_name ] = $manifest;
|
390 |
}
|
391 |
+
} catch ( Exception $e ) { // phpcs:ignore
|
392 |
+
// Do nothing.
|
393 |
}
|
394 |
}
|
395 |
}
|
396 |
+
$messages = array();
|
397 |
+
$integrations = apply_filters( 'flexible_shipping_integration_options', array() );
|
398 |
+
foreach ( $manifests as $manifest ) {
|
399 |
+
try {
|
400 |
+
$manifest->generate();
|
401 |
+
$manifest->save();
|
402 |
+
$download_manifest_url = admin_url( 'edit.php?post_type=shipping_manifest&flexible_shipping_download_manifest=' . $manifest->get_id() . '&nonce=' . wp_create_nonce( 'flexible_shipping_download_manifest' ) );
|
403 |
+
$messages[] = array(
|
404 |
+
'type' => 'updated',
|
405 |
+
'message' => sprintf(
|
406 |
+
// Translators: manifests count and integration.
|
407 |
+
__( 'Created manifest: %s (%s). If download not start automatically click %shere%s.', 'flexible-shipping' ), // phpcs:ignore
|
408 |
+
$manifest->get_number(),
|
409 |
+
$integrations[ $manifest->get_integration() ],
|
410 |
+
'<a class="shipping_manifest_download" target="_blank" href="' . $download_manifest_url . '">',
|
411 |
+
'</a>'
|
412 |
+
),
|
413 |
+
);
|
414 |
+
} catch ( Exception $e ) {
|
415 |
+
$messages[] = array(
|
416 |
+
'type' => 'error',
|
417 |
+
'message' => sprintf(
|
418 |
+
__( 'Manifest creation error: %s (%s).', 'flexible-shipping' ), // phpcs:ignore
|
419 |
+
$e->getMessage(),
|
420 |
+
$integrations[ $manifest->get_integration() ]
|
421 |
+
),
|
422 |
+
);
|
423 |
+
fs_delete_manifest( $manifest );
|
424 |
+
}
|
425 |
+
}
|
426 |
+
if ( count( $messages ) == 0 ) {
|
427 |
+
$messages[] = array(
|
428 |
+
'type' => 'updated',
|
429 |
+
'message' => __( 'No manifests created.', 'flexible-shipping' ),
|
430 |
+
);
|
431 |
+
}
|
432 |
+
$this->get_session()->set( 'flexible_shipping_bulk_manifests', $messages );
|
433 |
+
|
434 |
+
$redirect_to = add_query_arg( 'bulk_flexible_shipping_manifests', count( $post_ids ), $redirect_to );
|
435 |
+
|
436 |
+
return $redirect_to;
|
437 |
}
|
438 |
|
439 |
+
return $redirect_to;
|
440 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
441 |
|
442 |
+
/**
|
443 |
+
* .
|
444 |
+
*/
|
445 |
+
public function admin_notices() {
|
446 |
+
if ( ! empty( $_REQUEST['bulk_flexible_shipping_send'] ) ) {
|
447 |
+
$bulk_flexible_shipping_send_count = intval( sanitize_text_field( wp_unslash( $_REQUEST['bulk_flexible_shipping_send'] ) ) );
|
448 |
+
new Notice(
|
449 |
+
sprintf( __( 'Bulk send shipment - processed orders: %d', 'flexible-shipping' ), $bulk_flexible_shipping_send_count ) // phpcs:ignore
|
450 |
+
);
|
451 |
+
}
|
452 |
+
if ( ! empty( $_REQUEST['bulk_flexible_shipping_labels'] ) ) {
|
453 |
+
$bulk_flexible_shipping_labels_count = intval( sanitize_text_field( wp_unslash( $_REQUEST['bulk_flexible_shipping_labels'] ) ) );
|
454 |
+
if ( ! empty( $_REQUEST['bulk_flexible_shipping_no_labels_created'] ) ) {
|
455 |
+
new Notice(
|
456 |
+
sprintf( __( 'Bulk labels - processed orders: %d. No labels for processed orders.', 'flexible-shipping' ) ) // phpcs:ignore
|
457 |
+
);
|
458 |
+
} else {
|
459 |
+
$labels = $this->get_session()->get( 'flexible_shipping_bulk_labels' );
|
460 |
+
if ( is_array( $labels ) ) {
|
461 |
+
if ( isset( $labels['error'] ) ) {
|
462 |
+
new Notice( $labels['error'], Notice::NOTICE_TYPE_ERROR, true, 20 );
|
463 |
+
} else {
|
464 |
+
$nonce = wp_create_nonce( 'flexible_shipping_labels' );
|
465 |
+
new Notice(
|
466 |
+
sprintf(
|
467 |
+
__( 'Bulk labels - processed orders: %d. If download not start automatically click %shere%s.', 'flexible-shipping' ), // phpcs:ignore
|
468 |
+
$bulk_flexible_shipping_labels_count,
|
469 |
+
'<a id="flexible_shipping_labels_url" target="_blank" href=' . admin_url( '?flexible_shipping_labels=' . basename( $labels['client_file'] ) . '&tmp_file=' . basename( $labels['tmp_file'] ) . '&nonce=' . $nonce ) . '>',
|
470 |
+
'</a>'
|
471 |
+
)
|
472 |
+
);
|
473 |
+
}
|
474 |
}
|
475 |
}
|
476 |
}
|
477 |
+
if ( ! empty( $_REQUEST['bulk_flexible_shipping_manifests'] ) ) {
|
478 |
+
$bulk_flexible_shipping_manifest_count = intval( sanitize_text_field( wp_unslash( $_REQUEST['bulk_flexible_shipping_manifests'] ) ) );
|
479 |
+
new Notice(
|
480 |
+
sprintf( __( 'Bulk shipping manifest - processed orders: %d', 'flexible-shipping' ), $bulk_flexible_shipping_manifest_count ) // phpcs:ignore
|
481 |
+
);
|
482 |
+
if ( $this->get_session()->get( 'flexible_shipping_bulk_manifests' ) ) {
|
483 |
+
$messages = $this->get_session()->get( 'flexible_shipping_bulk_manifests' );
|
484 |
+
foreach ( $messages as $message ) {
|
485 |
+
new Notice(
|
486 |
+
$message['message'],
|
487 |
+
$message['type']
|
488 |
+
);
|
489 |
+
}
|
490 |
+
$this->get_session()->set( 'flexible_shipping_bulk_manifests', null );
|
491 |
+
}
|
492 |
+
}
|
493 |
+
}
|
494 |
|
495 |
+
/**
|
496 |
+
* Dispatch labels file if requested.
|
497 |
+
*/
|
498 |
+
public function dispatch_labels_file_if_expected() {
|
499 |
+
if ( isset( $_GET['flexible_shipping_labels'] ) && isset( $_GET['tmp_file'] ) && isset( $_GET['nonce'] ) ) {
|
500 |
+
if ( wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['nonce'] ) ), 'flexible_shipping_labels' ) ) {
|
501 |
+
$file = trailingslashit( sys_get_temp_dir() ) . sanitize_text_field( wp_unslash( $_GET['flexible_shipping_labels'] ) );
|
502 |
+
$tmp_file = trailingslashit( sys_get_temp_dir() ) . sanitize_text_field( wp_unslash( $_GET['tmp_file'] ) );
|
503 |
+
|
504 |
+
if ( ! file_exists( $tmp_file ) ) {
|
505 |
+
die( 'This file was already downloaded! Please retry bulk action!' );
|
506 |
+
}
|
507 |
+
|
508 |
+
$labels_file_dispatcher = new WPDesk_Flexible_Shipping_Labels_File_Dispatcher();
|
509 |
+
$labels_file_dispatcher->dispatch_and_delete_labels_file( $file, $tmp_file );
|
510 |
+
die();
|
511 |
+
}
|
512 |
+
}
|
513 |
}
|
514 |
+
|
515 |
}
|
516 |
+
|
composer.lock
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
5 |
"This file is @generated automatically"
|
6 |
],
|
7 |
-
"content-hash": "
|
8 |
"packages": [
|
9 |
{
|
10 |
"name": "psr/log",
|
@@ -3582,6 +3582,7 @@
|
|
3582 |
"keywords": [
|
3583 |
"tokenizer"
|
3584 |
],
|
|
|
3585 |
"time": "2017-12-04T08:55:13+00:00"
|
3586 |
},
|
3587 |
{
|
@@ -4429,16 +4430,16 @@
|
|
4429 |
},
|
4430 |
{
|
4431 |
"name": "seld/jsonlint",
|
4432 |
-
"version": "1.8.
|
4433 |
"source": {
|
4434 |
"type": "git",
|
4435 |
"url": "https://github.com/Seldaek/jsonlint.git",
|
4436 |
-
"reference": "
|
4437 |
},
|
4438 |
"dist": {
|
4439 |
"type": "zip",
|
4440 |
-
"url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/
|
4441 |
-
"reference": "
|
4442 |
"shasum": ""
|
4443 |
},
|
4444 |
"require": {
|
@@ -4484,7 +4485,7 @@
|
|
4484 |
"type": "tidelift"
|
4485 |
}
|
4486 |
],
|
4487 |
-
"time": "2020-
|
4488 |
},
|
4489 |
{
|
4490 |
"name": "seld/phar-utils",
|
@@ -4532,16 +4533,16 @@
|
|
4532 |
},
|
4533 |
{
|
4534 |
"name": "squizlabs/php_codesniffer",
|
4535 |
-
"version": "3.5.
|
4536 |
"source": {
|
4537 |
"type": "git",
|
4538 |
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
4539 |
-
"reference": "
|
4540 |
},
|
4541 |
"dist": {
|
4542 |
"type": "zip",
|
4543 |
-
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/
|
4544 |
-
"reference": "
|
4545 |
"shasum": ""
|
4546 |
},
|
4547 |
"require": {
|
@@ -4579,7 +4580,7 @@
|
|
4579 |
"phpcs",
|
4580 |
"standards"
|
4581 |
],
|
4582 |
-
"time": "2020-
|
4583 |
},
|
4584 |
{
|
4585 |
"name": "symfony/browser-kit",
|
@@ -8816,6 +8817,59 @@
|
|
8816 |
],
|
8817 |
"time": "2020-07-20T12:34:07+00:00"
|
8818 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8819 |
{
|
8820 |
"name": "zordius/lightncandy",
|
8821 |
"version": "v1.2.4",
|
4 |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
5 |
"This file is @generated automatically"
|
6 |
],
|
7 |
+
"content-hash": "8f1c9a632624cbeff66cb8f8286f355d",
|
8 |
"packages": [
|
9 |
{
|
10 |
"name": "psr/log",
|
3582 |
"keywords": [
|
3583 |
"tokenizer"
|
3584 |
],
|
3585 |
+
"abandoned": true,
|
3586 |
"time": "2017-12-04T08:55:13+00:00"
|
3587 |
},
|
3588 |
{
|
4430 |
},
|
4431 |
{
|
4432 |
"name": "seld/jsonlint",
|
4433 |
+
"version": "1.8.1",
|
4434 |
"source": {
|
4435 |
"type": "git",
|
4436 |
"url": "https://github.com/Seldaek/jsonlint.git",
|
4437 |
+
"reference": "3d5eb71705adfa34bd34b993400622932b2f62fd"
|
4438 |
},
|
4439 |
"dist": {
|
4440 |
"type": "zip",
|
4441 |
+
"url": "https://api.github.com/repos/Seldaek/jsonlint/zipball/3d5eb71705adfa34bd34b993400622932b2f62fd",
|
4442 |
+
"reference": "3d5eb71705adfa34bd34b993400622932b2f62fd",
|
4443 |
"shasum": ""
|
4444 |
},
|
4445 |
"require": {
|
4485 |
"type": "tidelift"
|
4486 |
}
|
4487 |
],
|
4488 |
+
"time": "2020-08-13T09:07:59+00:00"
|
4489 |
},
|
4490 |
{
|
4491 |
"name": "seld/phar-utils",
|
4533 |
},
|
4534 |
{
|
4535 |
"name": "squizlabs/php_codesniffer",
|
4536 |
+
"version": "3.5.6",
|
4537 |
"source": {
|
4538 |
"type": "git",
|
4539 |
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
|
4540 |
+
"reference": "e97627871a7eab2f70e59166072a6b767d5834e0"
|
4541 |
},
|
4542 |
"dist": {
|
4543 |
"type": "zip",
|
4544 |
+
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/e97627871a7eab2f70e59166072a6b767d5834e0",
|
4545 |
+
"reference": "e97627871a7eab2f70e59166072a6b767d5834e0",
|
4546 |
"shasum": ""
|
4547 |
},
|
4548 |
"require": {
|
4580 |
"phpcs",
|
4581 |
"standards"
|
4582 |
],
|
4583 |
+
"time": "2020-08-10T04:50:15+00:00"
|
4584 |
},
|
4585 |
{
|
4586 |
"name": "symfony/browser-kit",
|
8817 |
],
|
8818 |
"time": "2020-07-20T12:34:07+00:00"
|
8819 |
},
|
8820 |
+
{
|
8821 |
+
"name": "wpdesk/wpdesk-sessions",
|
8822 |
+
"version": "1.0.0",
|
8823 |
+
"source": {
|
8824 |
+
"type": "git",
|
8825 |
+
"url": "https://gitlab.com/wpdesk/wpdesk-sessions.git",
|
8826 |
+
"reference": "34905cc498d8d696660a47fec990793e5663e534"
|
8827 |
+
},
|
8828 |
+
"dist": {
|
8829 |
+
"type": "zip",
|
8830 |
+
"url": "https://gitlab.com/api/v4/projects/wpdesk%2Fwpdesk-sessions/repository/archive.zip?sha=34905cc498d8d696660a47fec990793e5663e534",
|
8831 |
+
"reference": "34905cc498d8d696660a47fec990793e5663e534",
|
8832 |
+
"shasum": ""
|
8833 |
+
},
|
8834 |
+
"require": {
|
8835 |
+
"php": ">=5.6"
|
8836 |
+
},
|
8837 |
+
"require-dev": {
|
8838 |
+
"10up/wp_mock": "*",
|
8839 |
+
"mockery/mockery": "*",
|
8840 |
+
"phpunit/phpunit": "<7",
|
8841 |
+
"squizlabs/php_codesniffer": "^3.0.2",
|
8842 |
+
"wimg/php-compatibility": "^8",
|
8843 |
+
"wp-coding-standards/wpcs": "^0.14.1",
|
8844 |
+
"wpdesk/wp-builder": "^1.4",
|
8845 |
+
"wpdesk/wp-wpdesk-tracker": "^2.0"
|
8846 |
+
},
|
8847 |
+
"type": "library",
|
8848 |
+
"extra": {
|
8849 |
+
"text-domain": "wpdesk-sessions",
|
8850 |
+
"translations-folder": "lang",
|
8851 |
+
"po-files": {
|
8852 |
+
"pl_PL": "pl_PL.po"
|
8853 |
+
}
|
8854 |
+
},
|
8855 |
+
"autoload": {
|
8856 |
+
"psr-4": {
|
8857 |
+
"WPDesk\\Sessions\\": "src/WPDesk/Sessions/"
|
8858 |
+
}
|
8859 |
+
},
|
8860 |
+
"notification-url": "https://packagist.org/downloads/",
|
8861 |
+
"license": [
|
8862 |
+
"MIT"
|
8863 |
+
],
|
8864 |
+
"authors": [
|
8865 |
+
{
|
8866 |
+
"name": "Grzegorz",
|
8867 |
+
"email": "grzegorz@wpdesk.pl"
|
8868 |
+
}
|
8869 |
+
],
|
8870 |
+
"description": "DHL Express Shipping Service",
|
8871 |
+
"time": "2020-08-13T10:58:00+00:00"
|
8872 |
+
},
|
8873 |
{
|
8874 |
"name": "zordius/lightncandy",
|
8875 |
"version": "v1.2.4",
|
flexible-shipping.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Flexible Shipping
|
4 |
* Plugin URI: https://wordpress.org/plugins/flexible-shipping/
|
5 |
* Description: Create additional shipment methods in WooCommerce and enable pricing based on cart weight or total.
|
6 |
-
* Version: 3.11.
|
7 |
* Author: WP Desk
|
8 |
* Author URI: https://www.wpdesk.net/
|
9 |
* Text Domain: flexible-shipping
|
@@ -38,7 +38,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
38 |
} // Exit if accessed directly
|
39 |
|
40 |
/* THIS VARIABLE CAN BE CHANGED AUTOMATICALLY */
|
41 |
-
$plugin_version = '3.11.
|
42 |
|
43 |
$plugin_name = 'Flexible Shipping';
|
44 |
$product_id = 'Flexible Shipping';
|
3 |
* Plugin Name: Flexible Shipping
|
4 |
* Plugin URI: https://wordpress.org/plugins/flexible-shipping/
|
5 |
* Description: Create additional shipment methods in WooCommerce and enable pricing based on cart weight or total.
|
6 |
+
* Version: 3.11.2
|
7 |
* Author: WP Desk
|
8 |
* Author URI: https://www.wpdesk.net/
|
9 |
* Text Domain: flexible-shipping
|
38 |
} // Exit if accessed directly
|
39 |
|
40 |
/* THIS VARIABLE CAN BE CHANGED AUTOMATICALLY */
|
41 |
+
$plugin_version = '3.11.2';
|
42 |
|
43 |
$plugin_name = 'Flexible Shipping';
|
44 |
$product_id = 'Flexible Shipping';
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://flexibleshipping.com/table-rate/
|
|
4 |
Tags: table rate, table rate shipping, conditional shipping, shipping method, woocommerce shipping, flexible shipping, woocommerce table rate shipping, cart based shipping, weight shipping, weight based shipping, totals based shipping, order based shipping, shipping zones, shipping classes, shipping, free shipping, advanced shipping
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 5.5
|
7 |
-
Stable tag: 3.11.
|
8 |
Requires PHP: 5.6
|
9 |
License: GPLv3 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
@@ -163,6 +163,9 @@ If you are upgrading from the old Flexible Shipping version (1.3.2, woo-flexible
|
|
163 |
|
164 |
== Changelog ==
|
165 |
|
|
|
|
|
|
|
166 |
= 3.11.1 - 2020-08-11 =
|
167 |
* Modified New Table Interface test
|
168 |
* Added support for WordPress 5.5
|
4 |
Tags: table rate, table rate shipping, conditional shipping, shipping method, woocommerce shipping, flexible shipping, woocommerce table rate shipping, cart based shipping, weight shipping, weight based shipping, totals based shipping, order based shipping, shipping zones, shipping classes, shipping, free shipping, advanced shipping
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 5.5
|
7 |
+
Stable tag: 3.11.2
|
8 |
Requires PHP: 5.6
|
9 |
License: GPLv3 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
163 |
|
164 |
== Changelog ==
|
165 |
|
166 |
+
= 3.11.2 - 2020-08-13 =
|
167 |
+
* Fixed PHP sessions issues
|
168 |
+
|
169 |
= 3.11.1 - 2020-08-11 =
|
170 |
* Modified New Table Interface test
|
171 |
* Added support for WordPress 5.5
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInitae786d99e9c3c452c6a90fb4fd518625::getLoader();
|
vendor/composer/autoload_classmap.php
CHANGED
@@ -204,6 +204,9 @@ return array(
|
|
204 |
'FSVendor\\WPDesk\\Pointer\\PointerMessage' => $baseDir . '/vendor_prefixed/wpdesk/wp-pointer/src/WPDesk/Pointer/PointerMessage.php',
|
205 |
'FSVendor\\WPDesk\\Pointer\\PointerPosition' => $baseDir . '/vendor_prefixed/wpdesk/wp-pointer/src/WPDesk/Pointer/PointerPosition.php',
|
206 |
'FSVendor\\WPDesk\\Pointer\\PointersScripts' => $baseDir . '/vendor_prefixed/wpdesk/wp-pointer/src/WPDesk/Pointer/PointersScripts.php',
|
|
|
|
|
|
|
207 |
'FSVendor\\WPDesk\\Tracker\\Deactivation\\AjaxDeactivationDataHandler' => $baseDir . '/vendor_prefixed/wpdesk/wp-wpdesk-tracker-deactivation/src/WPDesk/Tracker/Deactivation/AjaxDeactivationDataHandler.php',
|
208 |
'FSVendor\\WPDesk\\Tracker\\Deactivation\\DeactivationContent' => $baseDir . '/vendor_prefixed/wpdesk/wp-wpdesk-tracker-deactivation/src/WPDesk/Tracker/Deactivation/DeactivationContent.php',
|
209 |
'FSVendor\\WPDesk\\Tracker\\Deactivation\\PluginData' => $baseDir . '/vendor_prefixed/wpdesk/wp-wpdesk-tracker-deactivation/src/WPDesk/Tracker/Deactivation/PluginData.php',
|
204 |
'FSVendor\\WPDesk\\Pointer\\PointerMessage' => $baseDir . '/vendor_prefixed/wpdesk/wp-pointer/src/WPDesk/Pointer/PointerMessage.php',
|
205 |
'FSVendor\\WPDesk\\Pointer\\PointerPosition' => $baseDir . '/vendor_prefixed/wpdesk/wp-pointer/src/WPDesk/Pointer/PointerPosition.php',
|
206 |
'FSVendor\\WPDesk\\Pointer\\PointersScripts' => $baseDir . '/vendor_prefixed/wpdesk/wp-pointer/src/WPDesk/Pointer/PointersScripts.php',
|
207 |
+
'FSVendor\\WPDesk\\Session\\Adapter\\WooCommerceSession' => $baseDir . '/vendor_prefixed/wpdesk/wpdesk-sessions/src/WPDesk/Sessions/Adapter/WooCommerceSession.php',
|
208 |
+
'FSVendor\\WPDesk\\Session\\Session' => $baseDir . '/vendor_prefixed/wpdesk/wpdesk-sessions/src/WPDesk/Sessions/Session.php',
|
209 |
+
'FSVendor\\WPDesk\\Session\\SessionFactory' => $baseDir . '/vendor_prefixed/wpdesk/wpdesk-sessions/src/WPDesk/Sessions/SessionFactory.php',
|
210 |
'FSVendor\\WPDesk\\Tracker\\Deactivation\\AjaxDeactivationDataHandler' => $baseDir . '/vendor_prefixed/wpdesk/wp-wpdesk-tracker-deactivation/src/WPDesk/Tracker/Deactivation/AjaxDeactivationDataHandler.php',
|
211 |
'FSVendor\\WPDesk\\Tracker\\Deactivation\\DeactivationContent' => $baseDir . '/vendor_prefixed/wpdesk/wp-wpdesk-tracker-deactivation/src/WPDesk/Tracker/Deactivation/DeactivationContent.php',
|
212 |
'FSVendor\\WPDesk\\Tracker\\Deactivation\\PluginData' => $baseDir . '/vendor_prefixed/wpdesk/wp-wpdesk-tracker-deactivation/src/WPDesk/Tracker/Deactivation/PluginData.php',
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit8ce38e4100319ccd3fb5977b8cd5e1cd
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
-
call_user_func(\Composer\Autoload\
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInitae786d99e9c3c452c6a90fb4fd518625
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInitae786d99e9c3c452c6a90fb4fd518625', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInitae786d99e9c3c452c6a90fb4fd518625', 'loadClassLoader'));
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInitae786d99e9c3c452c6a90fb4fd518625::getInitializer($loader));
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'W' =>
|
@@ -236,6 +236,9 @@ class ComposerStaticInit8ce38e4100319ccd3fb5977b8cd5e1cd
|
|
236 |
'FSVendor\\WPDesk\\Pointer\\PointerMessage' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-pointer/src/WPDesk/Pointer/PointerMessage.php',
|
237 |
'FSVendor\\WPDesk\\Pointer\\PointerPosition' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-pointer/src/WPDesk/Pointer/PointerPosition.php',
|
238 |
'FSVendor\\WPDesk\\Pointer\\PointersScripts' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-pointer/src/WPDesk/Pointer/PointersScripts.php',
|
|
|
|
|
|
|
239 |
'FSVendor\\WPDesk\\Tracker\\Deactivation\\AjaxDeactivationDataHandler' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-wpdesk-tracker-deactivation/src/WPDesk/Tracker/Deactivation/AjaxDeactivationDataHandler.php',
|
240 |
'FSVendor\\WPDesk\\Tracker\\Deactivation\\DeactivationContent' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-wpdesk-tracker-deactivation/src/WPDesk/Tracker/Deactivation/DeactivationContent.php',
|
241 |
'FSVendor\\WPDesk\\Tracker\\Deactivation\\PluginData' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-wpdesk-tracker-deactivation/src/WPDesk/Tracker/Deactivation/PluginData.php',
|
@@ -446,10 +449,10 @@ class ComposerStaticInit8ce38e4100319ccd3fb5977b8cd5e1cd
|
|
446 |
public static function getInitializer(ClassLoader $loader)
|
447 |
{
|
448 |
return \Closure::bind(function () use ($loader) {
|
449 |
-
$loader->prefixLengthsPsr4 =
|
450 |
-
$loader->prefixDirsPsr4 =
|
451 |
-
$loader->fallbackDirsPsr4 =
|
452 |
-
$loader->classMap =
|
453 |
|
454 |
}, null, ClassLoader::class);
|
455 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInitae786d99e9c3c452c6a90fb4fd518625
|
8 |
{
|
9 |
public static $prefixLengthsPsr4 = array (
|
10 |
'W' =>
|
236 |
'FSVendor\\WPDesk\\Pointer\\PointerMessage' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-pointer/src/WPDesk/Pointer/PointerMessage.php',
|
237 |
'FSVendor\\WPDesk\\Pointer\\PointerPosition' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-pointer/src/WPDesk/Pointer/PointerPosition.php',
|
238 |
'FSVendor\\WPDesk\\Pointer\\PointersScripts' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-pointer/src/WPDesk/Pointer/PointersScripts.php',
|
239 |
+
'FSVendor\\WPDesk\\Session\\Adapter\\WooCommerceSession' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wpdesk-sessions/src/WPDesk/Sessions/Adapter/WooCommerceSession.php',
|
240 |
+
'FSVendor\\WPDesk\\Session\\Session' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wpdesk-sessions/src/WPDesk/Sessions/Session.php',
|
241 |
+
'FSVendor\\WPDesk\\Session\\SessionFactory' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wpdesk-sessions/src/WPDesk/Sessions/SessionFactory.php',
|
242 |
'FSVendor\\WPDesk\\Tracker\\Deactivation\\AjaxDeactivationDataHandler' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-wpdesk-tracker-deactivation/src/WPDesk/Tracker/Deactivation/AjaxDeactivationDataHandler.php',
|
243 |
'FSVendor\\WPDesk\\Tracker\\Deactivation\\DeactivationContent' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-wpdesk-tracker-deactivation/src/WPDesk/Tracker/Deactivation/DeactivationContent.php',
|
244 |
'FSVendor\\WPDesk\\Tracker\\Deactivation\\PluginData' => __DIR__ . '/../..' . '/vendor_prefixed/wpdesk/wp-wpdesk-tracker-deactivation/src/WPDesk/Tracker/Deactivation/PluginData.php',
|
449 |
public static function getInitializer(ClassLoader $loader)
|
450 |
{
|
451 |
return \Closure::bind(function () use ($loader) {
|
452 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInitae786d99e9c3c452c6a90fb4fd518625::$prefixLengthsPsr4;
|
453 |
+
$loader->prefixDirsPsr4 = ComposerStaticInitae786d99e9c3c452c6a90fb4fd518625::$prefixDirsPsr4;
|
454 |
+
$loader->fallbackDirsPsr4 = ComposerStaticInitae786d99e9c3c452c6a90fb4fd518625::$fallbackDirsPsr4;
|
455 |
+
$loader->classMap = ComposerStaticInitae786d99e9c3c452c6a90fb4fd518625::$classMap;
|
456 |
|
457 |
}, null, ClassLoader::class);
|
458 |
}
|
vendor_prefixed/wpdesk/wpdesk-sessions/composer.json
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "wpdesk\/wpdesk-sessions",
|
3 |
+
"description": "DHL Express Shipping Service",
|
4 |
+
"license": "MIT",
|
5 |
+
"authors": [
|
6 |
+
{
|
7 |
+
"name": "Grzegorz",
|
8 |
+
"email": "grzegorz@wpdesk.pl"
|
9 |
+
}
|
10 |
+
],
|
11 |
+
"prefer-stable": true,
|
12 |
+
"minimum-stability": "stable",
|
13 |
+
"require": {
|
14 |
+
"php": ">=5.6"
|
15 |
+
},
|
16 |
+
"require-dev": {
|
17 |
+
"phpunit\/phpunit": "<7",
|
18 |
+
"wp-coding-standards\/wpcs": "^0.14.1",
|
19 |
+
"squizlabs\/php_codesniffer": "^3.0.2",
|
20 |
+
"mockery\/mockery": "*",
|
21 |
+
"10up\/wp_mock": "*",
|
22 |
+
"wimg\/php-compatibility": "^8",
|
23 |
+
"wpdesk\/wp-wpdesk-tracker": "^2.0",
|
24 |
+
"wpdesk\/wp-builder": "^1.4"
|
25 |
+
},
|
26 |
+
"autoload": {
|
27 |
+
"psr-4": {
|
28 |
+
"FSVendor\\WPDesk\\Sessions\\": "src\/WPDesk\/Sessions\/"
|
29 |
+
}
|
30 |
+
},
|
31 |
+
"autoload-dev": {
|
32 |
+
"classmap": [
|
33 |
+
"tests\/"
|
34 |
+
]
|
35 |
+
},
|
36 |
+
"extra": {
|
37 |
+
"text-domain": "wpdesk-sessions",
|
38 |
+
"translations-folder": "lang",
|
39 |
+
"po-files": {
|
40 |
+
"pl_PL": "pl_PL.po"
|
41 |
+
}
|
42 |
+
},
|
43 |
+
"scripts": {
|
44 |
+
"test": "echo composer is alive",
|
45 |
+
"phpcs": "phpcs",
|
46 |
+
"phpunit-unit": "phpunit --configuration phpunit-unit.xml --coverage-text --colors=never",
|
47 |
+
"phpunit-unit-fast": "phpunit --configuration phpunit-unit.xml --no-coverage",
|
48 |
+
"phpunit-integration": "phpunit --configuration phpunit-integration.xml --coverage-text --colors=never",
|
49 |
+
"phpunit-integration-fast": "phpunit --configuration phpunit-integration.xml --no-coverage",
|
50 |
+
"docs": "apigen generate"
|
51 |
+
}
|
52 |
+
}
|
vendor_prefixed/wpdesk/wpdesk-sessions/src/WPDesk/Sessions/Adapter/WooCommerceSession.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* WooCommerce Session Adapter.
|
5 |
+
* @package WPDesk\Session
|
6 |
+
*/
|
7 |
+
namespace FSVendor\WPDesk\Session\Adapter;
|
8 |
+
|
9 |
+
use FSVendor\WPDesk\Session\Session;
|
10 |
+
/**
|
11 |
+
* Can store session data in WooCommerce Session.
|
12 |
+
*/
|
13 |
+
class WooCommerceSession implements \FSVendor\WPDesk\Session\Session
|
14 |
+
{
|
15 |
+
/**
|
16 |
+
* @var \WC_Session
|
17 |
+
*/
|
18 |
+
private $wc_session_handler;
|
19 |
+
/**
|
20 |
+
* WooCommerceSessionHandler constructor.
|
21 |
+
*
|
22 |
+
* @param \WC_Session $wc_session_handler
|
23 |
+
*/
|
24 |
+
public function __construct(\WC_Session $wc_session_handler)
|
25 |
+
{
|
26 |
+
$this->wc_session_handler = $wc_session_handler;
|
27 |
+
}
|
28 |
+
/**
|
29 |
+
* @param string $key
|
30 |
+
* @param mixed $value
|
31 |
+
*/
|
32 |
+
public function set($key, $value)
|
33 |
+
{
|
34 |
+
$this->wc_session_handler->set($key, $value);
|
35 |
+
}
|
36 |
+
/**
|
37 |
+
* @param string $key
|
38 |
+
* @param mixed $default
|
39 |
+
*
|
40 |
+
* @return mixed
|
41 |
+
*/
|
42 |
+
public function get($key, $default = null)
|
43 |
+
{
|
44 |
+
return $this->wc_session_handler->get($key, $default);
|
45 |
+
}
|
46 |
+
}
|
vendor_prefixed/wpdesk/wpdesk-sessions/src/WPDesk/Sessions/Session.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Session interface.
|
5 |
+
* @package WPDesk\Session
|
6 |
+
*/
|
7 |
+
namespace FSVendor\WPDesk\Session;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Session that can store session data.
|
11 |
+
*/
|
12 |
+
interface Session
|
13 |
+
{
|
14 |
+
/**
|
15 |
+
* Sets session value with specified key.
|
16 |
+
*
|
17 |
+
* @param string $key
|
18 |
+
* @param mixed $value
|
19 |
+
*
|
20 |
+
* @return void
|
21 |
+
*/
|
22 |
+
public function set($key, $value);
|
23 |
+
/**
|
24 |
+
* Returns session value for specified key.
|
25 |
+
*
|
26 |
+
* @param string $key
|
27 |
+
* @param mixed $default
|
28 |
+
*
|
29 |
+
* @return mixed
|
30 |
+
*/
|
31 |
+
public function get($key, $default = null);
|
32 |
+
}
|
vendor_prefixed/wpdesk/wpdesk-sessions/src/WPDesk/Sessions/SessionFactory.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Session factory.
|
5 |
+
*
|
6 |
+
* @package WPDesk\Session
|
7 |
+
*/
|
8 |
+
namespace FSVendor\WPDesk\Session;
|
9 |
+
|
10 |
+
use FSVendor\WPDesk\Session\Adapter\WooCommerceSession;
|
11 |
+
/**
|
12 |
+
* Can create session adapters.
|
13 |
+
*/
|
14 |
+
class SessionFactory
|
15 |
+
{
|
16 |
+
/**
|
17 |
+
* @var WooCommerceSession
|
18 |
+
*/
|
19 |
+
private $woocommerce_session_adapter;
|
20 |
+
/**
|
21 |
+
* Creates WooCommerce session adapter.
|
22 |
+
*
|
23 |
+
* @return Session
|
24 |
+
*/
|
25 |
+
public function get_woocommerce_session_adapter()
|
26 |
+
{
|
27 |
+
if (null === $this->woocommerce_session_adapter) {
|
28 |
+
\WC()->initialize_session();
|
29 |
+
$this->woocommerce_session_adapter = new \FSVendor\WPDesk\Session\Adapter\WooCommerceSession(\WC()->session);
|
30 |
+
}
|
31 |
+
return $this->woocommerce_session_adapter;
|
32 |
+
}
|
33 |
+
}
|