PluginProbe ʕ •ᴥ•ʔ
PiWeb Delivery & Pickup Date Time for WooCommerce / 3.0.49.93
PiWeb Delivery & Pickup Date Time for WooCommerce v3.0.49.93
3.0.63 3.0.62 3.0.61 3.0.60 3.0.49.49 3.0.49.6 3.0.49.60 3.0.49.61 3.0.49.62 3.0.49.63 3.0.49.64 3.0.49.66 3.0.49.67 3.0.49.69 3.0.49.7 3.0.49.70 3.0.49.72 3.0.49.73 3.0.49.74 3.0.49.76 3.0.49.77 3.0.49.79 3.0.49.9 3.0.49.90 3.0.49.91 3.0.49.92 3.0.49.93 3.0.49.94 3.0.49.96 3.0.49.97 3.0.49.99 trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 2.9.17 3.0.47 3.0.49 3.0.49.1 3.0.49.10 3.0.49.11 3.0.49.12 3.0.49.13 3.0.49.16 3.0.49.17 3.0.49.19 3.0.49.2 3.0.49.20 3.0.49.21 3.0.49.22 3.0.49.23 3.0.49.24 3.0.49.26 3.0.49.27 3.0.49.29 3.0.49.3 3.0.49.30 3.0.49.31 3.0.49.32 3.0.49.33 3.0.49.34 3.0.49.36 3.0.49.37 3.0.49.39 3.0.49.4 3.0.49.40 3.0.49.41 3.0.49.42 3.0.49.43 3.0.49.44 3.0.49.46 3.0.49.47
pi-woocommerce-order-date-time-and-type / block / class-date-time-location-storage.php
pi-woocommerce-order-date-time-and-type / block Last commit date
date-time-location 4 months ago class-date-time-location-block-integration.php 4 months ago class-date-time-location-block.php 4 months ago class-date-time-location-storage.php 4 months ago
class-date-time-location-storage.php
74 lines
1 <?php
2 namespace PISOL\DTT\BLOCK;
3 if ( ! defined( 'ABSPATH' ) ) exit;
4
5 class DateTimeLocationStorage{
6
7 protected static $instance = null;
8
9 public static function get_instance( ) {
10 if ( is_null( self::$instance ) ) {
11 self::$instance = new self();
12 }
13 return self::$instance;
14 }
15
16 function __construct()
17 {
18 add_action( 'woocommerce_store_api_checkout_update_order_from_request', array( $this, 'update_block_order_meta' ), 10, 2 );
19 }
20
21
22
23 function update_block_order_meta($order, $request){
24
25 /**
26 * In latest woocommerce 6.8 update this function is getting called even when payment method is changed, but in that case other data is not being send so we need to check if that is the case or not
27 */
28 $json_params = $request->get_json_params();
29
30 if(count($json_params) == 1 && isset($json_params['payment_method'])){
31 return;
32 }
33
34 //error_log(print_r($request['body'],true));
35 $extensions = $request->get_param( 'extensions' );
36 $params = $extensions['pisol-dtt/date-time-location'] ?? array();
37
38 if(empty($params['pi_delivery_type'])){
39 $params['pi_delivery_type'] = 'non-deliverable';
40 }
41
42 if(isset($params['pickup_location_id'])){
43 $params['pickup_location'] = $params['pickup_location_id'];
44 }
45
46 if ( empty( $params ) ) {
47 return;
48 }
49
50 $errors = new \WP_Error();
51
52 // Perform validation checks and add errors to $errors object
53 \pi_dtt_validate::validateCheckout($params, $errors);
54
55 // Check if there are any errors in the $errors object
56 if ($errors->has_errors()) {
57 // Extract all error messages from WP_Error
58 $error_messages = $errors->get_error_messages();
59
60 // Option 1: Throw an exception for each error individually (not typically ideal)
61 $combined_error_message = implode("<br>", $error_messages);
62 throw new \WC_Data_Exception('invalid_checkout_data', $combined_error_message);
63 }
64
65 $order_id = $order->get_id();
66
67 \pi_dtt_order::storeDetailInOrder($order_id, $params);
68
69 $order->save();
70 }
71
72 }
73
74 DateTimeLocationStorage::get_instance();