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