AmeliaBookingButtonRendererTrait.php
2 months ago
AmeliaBookingModule.php
7 months ago
AmeliaCatalogBookingModule.php
1 month ago
AmeliaCatalogModule.php
7 months ago
AmeliaCustomerPanelModule.php
7 months ago
AmeliaEmployeePanelModule.php
7 months ago
AmeliaEventsCalendarModule.php
1 month ago
AmeliaEventsListBookingButtonModule.php
2 months ago
AmeliaEventsListModule.php
1 month ago
AmeliaEventsModule.php
7 months ago
AmeliaSearchModule.php
7 months ago
AmeliaStepBookingButtonModule.php
2 months ago
AmeliaStepBookingModule.php
1 month ago
ModuleMetadata.php
1 month ago
SharedShortcodeModule.php
1 month ago
index.php
1 month ago
AmeliaCatalogBookingModule.php
88 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Divi5Amelia; |
| 4 | |
| 5 | use ET\Builder\Packages\ModuleLibrary\ModuleRegistration; |
| 6 | |
| 7 | /** |
| 8 | * Class that handle "Amelia Catalog Booking" module output in frontend. |
| 9 | */ |
| 10 | class AmeliaCatalogBookingModule extends SharedShortcodeModule |
| 11 | { |
| 12 | /** |
| 13 | * Register module. |
| 14 | */ |
| 15 | public function load() |
| 16 | { |
| 17 | add_action('init', [AmeliaCatalogBookingModule::class, 'registerModule']); |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * Register module. |
| 22 | */ |
| 23 | public static function registerModule() |
| 24 | { |
| 25 | $module_json_folder_path = dirname(__DIR__, 1) . '/visual-builder/src/modules/CatalogBooking'; |
| 26 | |
| 27 | ModuleRegistration::register_module( |
| 28 | $module_json_folder_path, |
| 29 | [ |
| 30 | 'render_callback' => [AmeliaCatalogBookingModule::class, 'renderCallback'], |
| 31 | ] |
| 32 | ); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Render module HTML output. |
| 37 | */ |
| 38 | public static function renderCallback($attrs, $content, $block, $elements) |
| 39 | { |
| 40 | $shortcode = '[ameliacatalogbooking'; |
| 41 | |
| 42 | $type_value = $attrs['type']['innerContent']['desktop']['value'] ?? '0'; |
| 43 | if ($type_value !== null && $type_value !== '0') { |
| 44 | $shortcode .= ' show=' . $type_value; |
| 45 | } |
| 46 | |
| 47 | $shortcode .= self::getSharedShortcodeString($attrs); |
| 48 | |
| 49 | $catalog_view = $attrs['catalog_view']['innerContent']['desktop']['value'] ?? '0'; |
| 50 | |
| 51 | if ($catalog_view !== '0') { |
| 52 | $category = $attrs['categories_catalog']['innerContent']['desktop']['value'] ?? []; |
| 53 | $service = $attrs['services_catalog']['innerContent']['desktop']['value'] ?? []; |
| 54 | $package = $attrs['packages_catalog']['innerContent']['desktop']['value'] ?? []; |
| 55 | |
| 56 | if ($category && count($category) > 0 && $catalog_view === 'category') { |
| 57 | $shortcode .= ' category=' . implode(',', $category); |
| 58 | } elseif ($service && count($service) > 0 && $catalog_view === 'service') { |
| 59 | $shortcode .= ' service=' . implode(',', $service); |
| 60 | } elseif ($package && count($package) > 0 && $catalog_view === 'package') { |
| 61 | $shortcode .= ' package=' . implode(',', $package); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | $filter_params = $attrs['filter_params']['innerContent']['desktop']['value'] ?? false; |
| 66 | if ($filter_params === 'on') { |
| 67 | $employee = $attrs['employees']['innerContent']['desktop']['value'] ?? []; |
| 68 | $location = $attrs['locations']['innerContent']['desktop']['value'] ?? []; |
| 69 | |
| 70 | if ($employee && count($employee) > 0) { |
| 71 | $shortcode .= ' employee=' . implode(',', $employee); |
| 72 | } |
| 73 | if ($location && count($location) > 0) { |
| 74 | $shortcode .= ' location=' . implode(',', $location); |
| 75 | } |
| 76 | |
| 77 | $skip_categories = $attrs['skip_categories']['innerContent']['desktop']['value'] ?? false; |
| 78 | if ($skip_categories === 'on') { |
| 79 | $shortcode .= ' categories_hidden=1'; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | $shortcode .= ']'; |
| 84 | |
| 85 | return do_shortcode($shortcode); |
| 86 | } |
| 87 | } |
| 88 |