PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.38
Timetics – Appointment Booking Calendar & Scheduling v1.0.38
1.0.62 1.0.63 1.0.61 1.0.60 1.0.59 1.0.58 1.0.57 1.0.56 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 All 64 releases
← All changes | core/integrations/woocommerce/cart-api.php +4 -43 1.0.63 → 1.0.38 View file →
@@ -6,10 +6,8 @@
6 6 */
7 7
8 8 namespace Timetics\Core\Integrations\Woocommerce;
9 9
10 -defined( 'ABSPATH' ) || exit;
11 -
12 10 use Timetics\Base\Api;
13 11 use Timetics\Core\Appointments\Appointment;
14 12 use Timetics\Utils\Singleton;
15 13
@@ -67,54 +65,17 @@
67 65 public function set_up_woocommerce( $requst ) {
68 66 $data = json_decode( $requst->get_body(), true );
69 67
70 68 $booking_id = ! empty( $data['booking_id'] ) ? intval( $data['booking_id'] ) : 0;
71 - $token = ! empty( $data['security_token'] ) ? sanitize_text_field( $data['security_token'] ) : '';
69 + $meeting_id = ! empty( $data['meeting_id'] ) ? intval( $data['meeting_id'] ) : 0;
70 + $price = ! empty( $data['price'] ) ? intval( $data['price'] ) : 0;
72 71
73 - $booking = new \Timetics\Core\Bookings\Booking( $booking_id );
74 - // everything from the booking record itself once ownership is proven.
75 - if ( ! $booking_id || '' === $token || ! $booking->is_booking() ) {
76 - return new \WP_HTTP_Response(
77 - [
78 - 'success' => 0,
79 - 'status_code' => 404,
80 - 'message' => __( 'Invalid booking.', 'timetics' ),
81 - ],
82 - 404
83 - );
84 - }
85 -
86 - $stored = (string) $booking->get_security_token();
87 -
88 - if ( '' === $stored || ! hash_equals( $stored, $token ) ) {
89 - return new \WP_HTTP_Response(
90 - [
91 - 'success' => 0,
92 - 'status_code' => 403,
93 - 'message' => __( 'Invalid booking token.', 'timetics' ),
94 - ],
95 - 403
96 - );
97 - }
98 -
99 - $meeting_id = (int) $booking->get_appointment();
100 - $price = (int) $booking->get_total();
101 -
102 - // Hooks::add_product_to_cart() already ran on timetics_after_booking_create and
103 - // stored the meeting details ( date, time, duration, timezone, location ) in this
104 - // session. Keep them - overwriting the whole array would drop them before checkout.
105 - $session_data = WC()->session->get( 'timetics_data' );
106 -
107 - if ( ! is_array( $session_data ) || empty( $session_data['booking_id'] ) || (int) $session_data['booking_id'] !== $booking_id ) {
108 - $session_data = [];
109 - }
110 -
111 72 // Set session for timetics data for woocommerce.
112 - WC()->session->set( 'timetics_data', array_merge( $session_data, [
73 + WC()->session->set( 'timetics_data', [
113 74 'booking_id' => $booking_id,
114 75 'meeting_id' => $meeting_id,
115 76 'price' => $price,
116 - ] ) );
77 + ] );
117 78
118 79 // Remove all items from cart.
119 80 WC()->cart->empty_cart();
120 81