Reputation: 1
I want to some changes in existing bookly plugin file but no effected to original one but when i have try to override plugin template and put into the wordpress theme directory but its not work.
This is my plugin file which I have made some changes but I dont know how to override in my theme directory.
plugins/bookly-responsive-appointment-booking-tool/backend/components/dialogs/appointment/edit/Ajax.php
And i have put this directory like this
wp-content/themes/themify-ultra-child/bookly-responsive-appointment-booking-tool/backend/components/dialogs/appointment/edit/Ajax.php
public static function getDataForAppointmentForm()
{
$type = self::parameter( 'type', false ) == 'package'
? Lib\Entities\Service::TYPE_PACKAGE
: Lib\Entities\Service::TYPE_SIMPLE;
$statuses = Lib\Proxy\CustomStatuses::prepareAllStatuses( array(
Lib\Entities\CustomerAppointment::STATUS_PENDING,
Lib\Entities\CustomerAppointment::STATUS_APPROVED,
Lib\Entities\CustomerAppointment::STATUS_CANCELLED,
Lib\Entities\CustomerAppointment::STATUS_REJECTED,
Lib\Entities\CustomerAppointment::STATUS_WAITLISTED,
Lib\Entities\CustomerAppointment::STATUS_DONE,
) );
$status_items = array();
foreach ( $statuses as $status ) {
$status_items[ $status ] = Lib\Entities\CustomerAppointment::statusToString( $status );
}
$result = array(
'staff' => array(),
'customers' => array(),
'start_time' => array(),
'end_time' => array(),
'app_start_time' => null, // Appointment start time which may not be in the list of start times.
'app_end_time' => null, // Appointment end time which may not be in the list of end times.
'week_days' => array(),
'time_interval' => Lib\Config::getTimeSlotLength(),
'status' => array(
'items' => $status_items,
),
'extras_consider_duration' => (int) Lib\Proxy\ServiceExtras::considerDuration( true ),
'extras_multiply_nop' => (int) get_option( 'bookly_service_extras_multiply_nop', 1 ),
);
// Staff list.
$staff = Lib\Entities\Staff::query()->findOne();
$staff_members = $staff ? Lib\Config::proActive() ? Lib\Utils\Common::isCurrentUserSupervisor() ? Lib\Entities\Staff::query()->sortBy( 'position' )->find() : Lib\Entities\Staff::query()->where( 'wp_user_id', get_current_user_id() )->find() : array( $staff ) : array();
$postfix_archived = sprintf( ' (%s)', __( 'Archived', 'bookly' ) );
$max_duration = 0;
$has_categories = (bool) Lib\Entities\Category::query()->findOne();
foreach ( $staff_members as $staff_member ) {
$services = array();
if ( $type == Lib\Entities\Service::TYPE_SIMPLE ) {
$services = Proxy\Pro::addCustomService( $services );
}
foreach ( $staff_member->getStaffServices( $type ) as $staff_service ) {
$sub_services = $staff_service->service->getSubServices();
if ( $type == Lib\Entities\Service::TYPE_SIMPLE || ! empty( $sub_services ) ) {
if ( $staff_service->getLocationId() === null || Lib\Proxy\Locations::prepareStaffLocationId( $staff_service->getLocationId(), $staff_service->getStaffId() ) == $staff_service->getLocationId() ) {
if ( ! in_array( $staff_service->service->getId(), array_map( function ( $service ) { return $service['id']; }, $services ) ) ) {
$category = Lib\Entities\Category::find( Lib\Entities\Service::find( $staff_service->getServiceId() )->getCategoryId() );
$services[] = array(
'id' => $staff_service->service->getId(),
'title' => sprintf(
'%s (%s)',
$staff_service->service->getTitle(),
Lib\Utils\DateTime::secondsToInterval( $staff_service->service->getDuration() )
),
'category' => $category ? $category->getName() : ( $has_categories ? __( 'Uncategorized', 'bookly' ) : ''),
'duration' => $staff_service->service->getDuration(),
'units_min' => $staff_service->service->getUnitsMin(),
'units_max' => $staff_service->service->getUnitsMax(),
'locations' => array(
( $staff_service->getLocationId() ?: 0 ) => array(
'capacity_min' => Lib\Config::groupBookingActive() ? $staff_service->getCapacityMin() : 1,
'capacity_max' => Lib\Config::groupBookingActive() ? $staff_service->getCapacityMax() : 1,
),
),
);
$max_duration = max( $max_duration, $staff_service->service->getUnitsMax() * $staff_service->service->getDuration() );
} else {
array_walk( $services, function ( &$item ) use ( $staff_service ) {
if ( $item['id'] == $staff_service->service->getId() ) {
$item['locations'][ $staff_service->getLocationId() ?: 0 ] = array(
'capacity_min' => Lib\Config::groupBookingActive() ? $staff_service->getCapacityMin() : 1,
'capacity_max' => Lib\Config::groupBookingActive() ? $staff_service->getCapacityMax() : 1,
);
}
} );
}
}
}
}
$locations = array();
foreach ( (array) Lib\Proxy\Locations::findByStaffId( $staff_member->getId() ) as $location ) {
$locations[] = array(
'id' => $location->getId(),
'name' => $location->getName(),
);
}
$result['staff'][] = array(
'id' => $staff_member->getId(),
'full_name' => $staff_member->getFullName() . ( $staff_member->getVisibility() == 'archive' ? $postfix_archived : '' ),
'archived' => $staff_member->getVisibility() == 'archive',
'services' => $services,
'locations' => $locations,
'category' => Lib\Proxy\Pro::getStaffCategoryName( $staff_member->getCategoryId() ),
);
}
/** @var Lib\Entities\Customer $customer */
// Customers list.
foreach ( Lib\Entities\Customer::query()->sortBy( 'full_name' )->find() as $customer ) {
$name = $customer->getFullName();
if ( $customer->getEmail() != '' || $customer->getPhone() != '' ) {
// $name .= ' (' . trim( $customer->getEmail() . ', ' . $customer->getPhone(), ', ' ) . ')';
// $name .= ' (sdsfd)';
// echo '<pre>',print_r($customer->getCity()),'</pre>';
$name .= ' ('.trim($customer->getStreet().', ' .$customer->getPostcode()).')';
}
$result['customers'][] = array(
'id' => $customer->getId(),
'name' => $name,
'status' => Lib\Proxy\CustomerGroups::prepareDefaultAppointmentStatus( get_option( 'bookly_gen_default_appointment_status' ), $customer->getGroupId() ),
'custom_fields' => array(),
'timezone' => Lib\Proxy\Pro::getLastCustomerTimezone( $customer->getId() ),
'number_of_persons' => 1,
);
}
// Time list.
$ts_length = Lib\Config::getTimeSlotLength();
$time_start = 0;
$time_end = max( $max_duration + DAY_IN_SECONDS, DAY_IN_SECONDS * 2 );
// Run the loop.
while ( $time_start <= $time_end ) {
$slot = array(
'value' => Lib\Utils\DateTime::buildTimeString( $time_start, false ),
'title' => Lib\Utils\DateTime::formatTime( $time_start ),
);
if ( $time_start < DAY_IN_SECONDS ) {
$result['start_time'][] = $slot;
}
$result['end_time'][] = $slot;
$time_start += $ts_length;
}
$days_times = Lib\Config::getDaysAndTimes();
$weekdays = array( 1 => 'sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat', );
foreach ( $days_times['days'] as $index => $abbrev ) {
$result['week_days'][] = $weekdays[ $index ];
}
if ( $type == Lib\Entities\Service::TYPE_PACKAGE ) {
$result = Proxy\Shared::prepareDataForPackage( $result );
}
wp_send_json( $result );
}
Does not override the plugin in theme folder.
Upvotes: 0
Views: 2041
Reputation: 1333
Even one year after this question, Bookly still doesn't allow customizations (like almost everyone do in Wordpress Development).
As an example, you can try to search every use of important functions used to this propose like do_action
, and you'll not find more than 20 results, which is extremely low for a plugin of this size - and most occurrences are related to wpml_register_single_string
hook.
A topic opened a few months ago also says this, answered by Bookly.
Upvotes: 0