| @@ -121,10 +121,8 @@ | ||
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | $cart = count( $carts ) ? $carts[0] : array(); |
| 125 | - // Session cart items always carry subtotal/total keys, set to 0 when none was stored. | |
| 126 | - $subtotal = ! empty( $item['subtotal'] ) ? $item['subtotal'] : ( $item['price'] ?? 0 ); | |
| 127 | 125 | $cart_item_data = array( |
| 128 | 126 | 'uuid' => $item['uuid'], |
| 129 | 127 | 'cart_id' => $cart->id, |
| 130 | 128 | 'team_member_id' => $item['team_member_id'], |
| @@ -132,10 +130,10 @@ | ||
| 132 | 130 | 'date' => $item['date'], |
| 133 | 131 | 'start_time' => $item['start_time'], |
| 134 | 132 | 'end_time' => $item['end_time'], |
| 135 | 133 | 'price' => $item['price'] ?? 0, |
| 136 | - 'subtotal' => $subtotal, | |
| 137 | - 'total' => ! empty( $item['total'] ) ? $item['total'] : $subtotal, | |
| 134 | + 'subtotal' => $item['subtotal'] ?? $item['price'], | |
| 135 | + 'total' => $item['total'] ?? $item['subtotal'], | |
| 138 | 136 | 'additional_duration_id' => booktics_sanitize_id_string( $item['additional_duration_id'] ?? '' ), |
| 139 | 137 | 'created_at' => current_time( 'mysql' ), |
| 140 | 138 | 'updated_at' => current_time( 'mysql' ), |
| 141 | 139 | ); |
| @@ -287,9 +285,10 @@ | ||
| 287 | 285 | * @return array Updated item data or empty array if item not found |
| 288 | 286 | */ |
| 289 | 287 | public function edit_cart_item( string $uuid, array $new_data ): array { |
| 290 | 288 | if ( ! is_user_logged_in() ) { |
| 291 | - $cart = Cart_Session::edit_item( $uuid, $new_data ); | |
| 289 | + Cart_Session::edit_item( $uuid, $new_data ); | |
| 290 | + $cart = Cart_Session::get(); | |
| 292 | 291 | foreach ( $cart['items'] as $item ) { |
| 293 | 292 | if ( $item['uuid'] === $uuid ) { |
| 294 | 293 | return $item; |
| 295 | 294 | } |