| @@ -98,14 +98,23 @@ | ||
| 98 | 98 | |
| 99 | 99 | $meeting_id = (int) $booking->get_appointment(); |
| 100 | 100 | $price = (int) $booking->get_total(); |
| 101 | 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 | + | |
| 102 | 111 | // Set session for timetics data for woocommerce. |
| 103 | - WC()->session->set( 'timetics_data', [ | |
| 112 | + WC()->session->set( 'timetics_data', array_merge( $session_data, [ | |
| 104 | 113 | 'booking_id' => $booking_id, |
| 105 | 114 | 'meeting_id' => $meeting_id, |
| 106 | 115 | 'price' => $price, |
| 107 | - ] ); | |
| 116 | + ] ) ); | |
| 108 | 117 | |
| 109 | 118 | // Remove all items from cart. |
| 110 | 119 | WC()->cart->empty_cart(); |
| 111 | 120 | |