@@ -25,25 +25,38 @@ public function __construct() {
2525 public function test_page ( $ attributes ) {
2626 $ attributes = shortcode_atts (
2727 array (
28- 'bookingid ' => 0 ,
28+ 'bookingid ' => 0 ,
29+ 'programmebookingid ' => 0 ,
2930 ),
3031 normalize_empty_atts ( $ attributes ),
3132 'test_page '
3233 );
3334
34- $ event_booking = EDUAPI ()->OData ->Bookings ->GetItem (
35- intval ( $ attributes ['bookingid ' ] ),
36- null ,
37- 'Customer($select=CustomerId;),ContactPerson($select=PersonId;),OrderRows ' ,
38- false
39- );
40- $ _customer = EDUAPI ()->OData ->Customers ->GetItem (
35+ if ( $ attributes ['bookingid ' ] > 0 ) {
36+ $ event_booking = EDUAPI ()->OData ->Bookings ->GetItem (
37+ $ attributes ['bookingid ' ],
38+ null ,
39+ 'Customer($select=CustomerId;),ContactPerson($select=PersonId;),OrderRows ' ,
40+ false
41+ );
42+ } elseif ( $ attributes ['programmebookingid ' ] > 0 ) {
43+ $ event_booking = EDUAPI ()->OData ->ProgrammeBookings ->GetItem (
44+ $ attributes ['programmebookingid ' ],
45+ null ,
46+ 'Customer($select=CustomerId;),ContactPerson($select=PersonId;),OrderRows ' ,
47+ false
48+ );
49+ }
50+
51+ EDU ()->write_debug ($ event_booking );
52+
53+ $ _customer = EDUAPI ()->OData ->Customers ->GetItem (
4154 $ event_booking ['Customer ' ]['CustomerId ' ],
4255 null ,
4356 null ,
4457 false
4558 );
46- $ _contact = EDUAPI ()->OData ->Persons ->GetItem (
59+ $ _contact = EDUAPI ()->OData ->Persons ->GetItem (
4760 $ event_booking ['ContactPerson ' ]['PersonId ' ],
4861 null ,
4962 null ,
@@ -67,7 +80,7 @@ public function intercept_booking( $ebi = null ) {
6780 return ;
6881 }
6982
70- if ( ! empty ( $ _POST ['act ' ] ) && 'bookCourse ' === $ _POST ['act ' ] ) {
83+ if ( ! empty ( $ _POST ['act ' ] ) && ( 'bookCourse ' === $ _POST ['act ' ] || ' bookProgramme ' === $ _POST [ ' act ' ] ) ) {
7184 $ ebi ->NoRedirect = true ;
7285 }
7386 }
@@ -178,22 +191,34 @@ public function create_checkout( $ebi = null ) {
178191
179192 $ current_url = esc_url ( "{$ _SERVER ['REQUEST_SCHEME ' ]}:// {$ _SERVER ['HTTP_HOST ' ]}{$ _SERVER ['REQUEST_URI ' ]}" );
180193
194+ $ booking_id = 0 ;
195+ $ programme_booking_id = 0 ;
196+
197+ if ( ! empty ( $ ebi ->EventBooking ['BookingId ' ] ) ) {
198+ $ booking_id = intval ( $ ebi ->EventBooking ['BookingId ' ] );
199+ }
200+
201+ if ( ! empty ( $ ebi ->EventBooking ['ProgrammeBookingId ' ] ) ) {
202+ $ programme_booking_id = intval ( $ ebi ->EventBooking ['ProgrammeBookingId ' ] );
203+ }
181204
182205 $ confirmation_url = add_query_arg (
183206 array (
184- 'klarna_order_id ' => '{checkout.order.id} ' ,
185- 'booking_id ' => $ ebi ->EventBooking ['BookingId ' ],
186- 'edu-valid-form ' => wp_create_nonce ( 'edu-booking-confirm ' ),
187- 'act ' => 'paymentCompleted '
207+ 'klarna_order_id ' => '{checkout.order.id} ' ,
208+ 'booking_id ' => $ booking_id ,
209+ 'programme_booking_id ' => $ programme_booking_id ,
210+ 'edu-valid-form ' => wp_create_nonce ( 'edu-booking-confirm ' ),
211+ 'act ' => 'paymentCompleted ' ,
188212 ),
189213 $ current_url
190214 );
191215
192216 $ push_url = add_query_arg (
193217 array (
194- 'klarna_order_id ' => '{checkout.order.id} ' ,
195- 'booking_id ' => $ ebi ->EventBooking ['BookingId ' ],
196- 'status ' => 'push ' ,
218+ 'klarna_order_id ' => '{checkout.order.id} ' ,
219+ 'booking_id ' => $ booking_id ,
220+ 'programme_booking_id ' => $ programme_booking_id ,
221+ 'status ' => 'push ' ,
197222 ),
198223 $ current_url
199224 );
@@ -267,15 +292,28 @@ public function process_paymentstatus() {
267292
268293 $ order ->fetch ();
269294
295+ $ booking_id = intval ( $ _GET ['booking_id ' ] );
296+ $ programme_booking_id = intval ( $ _GET ['programme_booking_id ' ] );
297+
298+
270299 if ( 'checkout_complete ' === $ order ['status ' ] ) {
271300
272301 $ patch_booking = new stdClass ();
273302 $ patch_booking ->Paid = true ;
274303
275- EDUAPI ()->REST ->Booking ->PatchBooking (
276- intval ( $ _GET ['booking_id ' ] ),
277- $ patch_booking
278- );
304+ if ( $ booking_id > 0 ) {
305+ EDUAPI ()->REST ->Booking ->PatchBooking (
306+ $ booking_id ,
307+ $ patch_booking
308+ );
309+ }
310+
311+ if ( $ programme_booking_id > 0 ) {
312+ EDUAPI ()->REST ->ProgrammeBooking ->PatchBooking (
313+ $ programme_booking_id ,
314+ $ patch_booking
315+ );
316+ }
279317
280318 $ update = array ();
281319 $ update ['status ' ] = 'created ' ;
0 commit comments