|
49 | 49 | return; |
50 | 50 | } |
51 | 51 |
|
| 52 | + $prices = array(); |
| 53 | + |
| 54 | + if ( ! empty( $selected_course['PriceNames'] ) ) { |
| 55 | + foreach ( $selected_course['PriceNames'] as $pn ) { |
| 56 | + $prices[ (string) $pn['PriceNameId'] ] = $pn; |
| 57 | + } |
| 58 | + } |
| 59 | + |
52 | 60 | $org_name = trim( ! empty( $organization['LegalName'] ) ? $organization['LegalName'] : $organization['OrganisationName'] ); |
53 | 61 |
|
54 | | - $events = null; |
| 62 | + $events = []; |
| 63 | + |
| 64 | + $offers = []; |
| 65 | + |
| 66 | + foreach ( $prices as $priceNameId => $priceName ) { |
| 67 | + $offers[] = [ |
| 68 | + '@type' => 'Offer', |
| 69 | + 'price' => $priceName['Price'], |
| 70 | + 'category' => $priceName['Price'] == 0 ? 'Free' : 'Paid', |
| 71 | + 'priceCurrency' => EDU()->get_option( 'eduadmin-currency', 'SEK' ), |
| 72 | + 'name' => $priceName['PriceNameDescription'], |
| 73 | + ]; |
| 74 | + } |
55 | 75 |
|
56 | 76 | foreach ( $selected_course['Events'] as $event ) { |
57 | 77 | $_event = [ |
|
63 | 83 | $_event['courseMode'] = "online"; |
64 | 84 | $_event['location'] = "Online"; |
65 | 85 | $_event['description'] = 'On-demand'; |
| 86 | + |
| 87 | + if ( $event['OnDemandAccessDays'] == null && $selected_course['OnDemandAccessDays'] != null ) { |
| 88 | + $event['OnDemandAccessDays'] = $selected_course['OnDemandAccessDays']; |
| 89 | + } |
| 90 | + |
| 91 | + if ( $event['OnDemandAccessDays'] > 0 ) { |
| 92 | + $_event['courseSchedule'] = [ |
| 93 | + '@type' => 'Schedule', |
| 94 | + 'repeatFrequency' => 'Daily', |
| 95 | + 'repeatCount' => $event['OnDemandAccessDays'], |
| 96 | + ]; |
| 97 | + } else { |
| 98 | + $_event['courseSchedule'] = [ |
| 99 | + '@type' => 'Schedule', |
| 100 | + 'duration' => 'P1D', |
| 101 | + 'repeatFrequency' => 'Yearly', |
| 102 | + 'repeatCount' => 99, |
| 103 | + ]; |
| 104 | + } |
66 | 105 | } else { |
67 | 106 | $_event['location'] = $event['City']; |
68 | 107 | $_event['startDate'] = $event['StartDate']; |
69 | 108 | $_event['endDate'] = $event['EndDate']; |
| 109 | + |
| 110 | + $_event['courseSchedule'] = [ |
| 111 | + '@type' => 'Schedule', |
| 112 | + 'startDate' => $event['StartDate'], |
| 113 | + 'endDate' => $event['EndDate'], |
| 114 | + ]; |
70 | 115 | } |
71 | 116 |
|
72 | 117 | if ( ! empty( $event['MaxParticipantNumber'] ) && $event['MaxParticipantNumber'] > 0 ) { |
|
93 | 138 | 'image' => $organization['LogoUrl'], |
94 | 139 | ], |
95 | 140 | 'hasCourseInstance' => $events, |
| 141 | + 'offers' => $offers, |
96 | 142 | ]; |
97 | 143 |
|
98 | 144 | echo '<script type="application/ld+json"> |
|
0 commit comments