Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/booktics/assets/build/js/dashboard.asset.php
+++ b/booktics/assets/build/js/dashboard.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '31232ace3730e0548cc9');
+<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '6512114e7a014e25ba9f');
--- a/booktics/assets/build/js/frontend.asset.php
+++ b/booktics/assets/build/js/frontend.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '3012e51cd697a9a4fa14');
+<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'bddc7e6bc11191766cc4');
--- a/booktics/assets/build/js/packages.asset.php
+++ b/booktics/assets/build/js/packages.asset.php
@@ -1 +1 @@
-<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '060d0dae1df9570130cd');
+<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'cc4f01da396dd4a6122e');
--- a/booktics/base/abstracts/booktics-database.php
+++ b/booktics/base/abstracts/booktics-database.php
@@ -32,6 +32,30 @@
}
/**
+ * Validate a SQL identifier (column name) against a strict allow-list.
+ *
+ * Only plain identifiers ([A-Za-z0-9_]) are permitted. Since column names
+ * cannot be parameterized by wpdb::prepare(), any value used as a column
+ * name must be validated here to prevent SQL injection when the array keys
+ * originate from user-controlled request bodies.
+ *
+ * @param string $identifier
+ *
+ * @return string The validated identifier, wrapped in backticks.
+ *
+ * @throws RuntimeException When the identifier is not a plain column name.
+ */
+ private function sanitize_identifier( string $identifier ): string {
+ if ( ! preg_match( '/^[a-zA-Z0-9_]+$/', $identifier ) ) {
+ throw new RuntimeException(
+ sprintf( esc_html__( 'Invalid database column identifier: %s', 'booktics' ), esc_html( $identifier ) )
+ );
+ }
+
+ return "`{$identifier}`";
+ }
+
+ /**
* Begin database transaction
*
* @return void
@@ -72,7 +96,7 @@
$values = array();
foreach ( $where as $key => $value ) {
- $conditions[] = "$key = %s";
+ $conditions[] = $this->sanitize_identifier( $key ) . ' = %s';
$values[] = $value;
}
@@ -107,6 +131,7 @@
$table = booktics_get_table_name( $table );
$columns = array_keys( $records[0] );
+ $safe_columns = array_map( array( $this, 'sanitize_identifier' ), $columns );
$placeholders = array_fill( 0, count( $columns ), '%s' );
$placeholder_string = '(' . implode( ',', $placeholders ) . ')';
@@ -120,7 +145,7 @@
}
}
- $column_string = implode( ',', $columns );
+ $column_string = implode( ',', $safe_columns );
$placeholders_string = implode( ',', $placeholders_groups );
$sql = "INSERT INTO $table ($column_string) VALUES $placeholders_string";
@@ -146,7 +171,15 @@
*/
public function select( string $table, array $where = array(), array $columns = array( '*' ) ) {
$table = booktics_get_table_name( $table );
- $columns_s = implode( ', ', $columns );
+ $columns_s = implode(
+ ', ',
+ array_map(
+ function ( $column ) {
+ return '*' === $column ? '*' : $this->sanitize_identifier( $column );
+ },
+ $columns
+ )
+ );
$sql = "SELECT $columns_s FROM $table";
$values = array();
@@ -154,7 +187,7 @@
$conditions = array();
foreach ( $where as $key => $value ) {
- $conditions[] = "$key = %s";
+ $conditions[] = $this->sanitize_identifier( $key ) . ' = %s';
$values[] = $value;
}
@@ -202,12 +235,12 @@
$values = array();
foreach ( $data as $key => $value ) {
- $set_values[] = "$key = %s";
+ $set_values[] = $this->sanitize_identifier( $key ) . ' = %s';
$values[] = $value;
}
foreach ( $where as $key => $value ) {
- $where_conditions[] = "$key = %s";
+ $where_conditions[] = $this->sanitize_identifier( $key ) . ' = %s';
$values[] = $value;
}
--- a/booktics/base/activate.php
+++ b/booktics/base/activate.php
@@ -26,6 +26,7 @@
if ( function_exists( 'booktics_update_option' ) ) {
booktics_update_option( 'appointment_status', 'pending' );
booktics_update_option( 'appointment_statuses_for_blocked_slot', array( 'pending', 'approved' ) );
+ booktics_update_option( 'pending_reservation_timeout', 10 );
}
}
}
--- a/booktics/base/models/appointment-model.php
+++ b/booktics/base/models/appointment-model.php
@@ -195,6 +195,37 @@
}
/**
+ * Get all appointments attached to an order
+ *
+ * @param int $order_id Order ID
+ *
+ * @return array<static>
+ */
+ public function get_appointments_by_order_id( $order_id ) {
+ $args = array(
+ 'post_type' => $this->get_post_type(),
+ 'post_status' => static::$accepted_statuses,
+ 'posts_per_page' => - 1,
+ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Meta query is necessary for filtering appointments by order.
+ 'meta_query' => array(
+ array(
+ 'key' => 'order_id',
+ 'value' => $order_id,
+ 'compare' => '=',
+ ),
+ ),
+ );
+
+ $query = new WP_Query( $args );
+
+ return array_map(
+ function ( $post ) {
+ return new static( $post );
+ }, $query->posts
+ );
+ }
+
+ /**
* Get appointments count by team member ID
*
* @param int $team_member_id Team member ID
--- a/booktics/base/providers/global-service-provider.php
+++ b/booktics/base/providers/global-service-provider.php
@@ -28,6 +28,10 @@
use BookticsTeam_MemberTeam_Member_Service_Provider;
use BookticsExtensionsModule_Service_Provider;
use BookticsModuleFluentCrmFluentCRM_Service_Provider;
+use BookticsModulePabblyPabbly_Service_Provider;
+use BookticsModuleZapierZapier_Service_Provider;
+use BookticsModuleZohoZoho_Service_Provider;
+use BookticsModuleMailpoetMailpoet_Service_Provider;
use BookticsModuleGoogle_CalendarGoogle_Service_Provider;
use BookticsAdd_To_CalendarAdd_To_Calendar_Service_Provider;
@@ -67,6 +71,10 @@
'extension' => Extension_Service_Provider::class,
'module' => Module_Service_Provider::class,
'fluentcrm' => FluentCRM_Service_Provider::class,
+ 'zapier' => Zapier_Service_Provider::class,
+ 'zoho' => Zoho_Service_Provider::class,
+ 'mailpoet' => Mailpoet_Service_Provider::class,
+ 'pabbly' => Pabbly_Service_Provider::class,
'stripe' => Stripe_Service_Provider::class,
'google-calendar' => Google_Service_Provider::class,
);
@@ -142,6 +150,10 @@
$module_services = array(
'google-calendar',
'fluentcrm',
+ 'zapier',
+ 'zoho',
+ 'mailpoet',
+ 'pabbly',
'stripe',
);
--- a/booktics/booktics.php
+++ b/booktics/booktics.php
@@ -4,7 +4,7 @@
* Plugin Name: Booktics - Booking Calendar for Appointments and Service Businesses
* Plugin URI: https://arraytics.com/booktics/
* Description: Schedule, Appointment and Seat Booking plugin.
- * Version: 1.0.22
+ * Version: 1.0.23
* Requires at least: 5.2
* Requires PHP: 7.4
* Author: Arraytics
@@ -30,7 +30,7 @@
* @package Booktics
* @category Core
* @author Arraytics
- * @version 1.0.22
+ * @version 1.0.23
*/
use BookticsBooktics;
@@ -47,7 +47,7 @@
define( 'BOOKTICS_PLUGIN_NAME', "Booktics");
defined( 'BOOKTICS_FILE' ) || define( 'BOOKTICS_FILE', __FILE__ );
defined( 'BOOKTICS_DIR' ) || define( 'BOOKTICS_DIR', __DIR__ );
-defined( 'BOOKTICS_VERSION' ) || define( 'BOOKTICS_VERSION', '1.0.22' );
+defined( 'BOOKTICS_VERSION' ) || define( 'BOOKTICS_VERSION', '1.0.23' );
global $booktics_container;
--- a/booktics/core/appointment/controllers/appointment-controller.php
+++ b/booktics/core/appointment/controllers/appointment-controller.php
@@ -868,7 +868,9 @@
$this->send_cancel_email( $result );
- do_action( 'booktics_after_appointment_cancelled', $result );
+ // Note: booktics_after_appointment_cancelled is fired inside
+ // Appointment_Service::cancel(), the single choke point every cancel
+ // path routes through, so it is intentionally not re-fired here.
return $this->response( $result, __( 'Successfully cancelled appointment', 'booktics' ) );
}
--- a/booktics/core/appointment/services/appointment-service.php
+++ b/booktics/core/appointment/services/appointment-service.php
@@ -83,6 +83,12 @@
return;
}
+ $order_status = self::map_appointment_status_to_order_status( $new_status );
+
+ if ( null === $order_status ) {
+ return;
+ }
+
$db = new Booktics_Database();
$order_model = new Order_Model( $db );
$order = $order_model->find( array( 'id' => $order_id ) );
@@ -91,7 +97,71 @@
return;
}
- $order_model->update( $order_id, array( 'status' => $new_status ) );
+ // One order can hold several appointments (cart / group bookings), so it is
+ // only canceled or completed once every appointment on it reached that state.
+ if ( in_array( $order_status, array( 'canceled', 'completed' ), true )
+ && ! self::all_order_appointments_have_status( $order_id, $order_status, $appointment->id ) ) {
+ return;
+ }
+
+ if ( $order->status === $order_status ) {
+ return;
+ }
+
+ // payment_status is intentionally not touched here: it is owned by the payment
+ // flow (gateway callbacks / manual payment update), not by the appointment status.
+ $order_model->update( $order_id, array( 'status' => $order_status ) );
+ }
+
+ /**
+ * Map an appointment status onto the order status domain.
+ *
+ * Appointment statuses (pending, approved, canceled, completed, ...) and order
+ * statuses (open, canceled, completed) are separate domains. Writing an appointment
+ * status straight into the order row leaves the order with a value its own UI
+ * cannot represent.
+ *
+ * @param string $appointment_status Appointment status.
+ *
+ * @return string|null Mapped order status, or null when the status has no mapping.
+ */
+ private static function map_appointment_status_to_order_status( string $appointment_status ) {
+ $map = array(
+ 'pending' => 'open',
+ 'active' => 'open',
+ 'approved' => 'open',
+ 'not_now' => 'open',
+ 'canceled' => 'canceled',
+ 'cancelled' => 'canceled',
+ 'completed' => 'completed',
+ );
+
+ return $map[ $appointment_status ] ?? null;
+ }
+
+ /**
+ * Check whether every appointment on an order maps to the given order status.
+ *
+ * @param int $order_id Order ID.
+ * @param string $order_status Target order status.
+ * @param int $current_appointment_id Appointment being updated (already known to match).
+ *
+ * @return bool
+ */
+ private static function all_order_appointments_have_status( $order_id, string $order_status, $current_appointment_id ): bool {
+ $appointments = ( new Appointment_Model() )->get_appointments_by_order_id( $order_id );
+
+ foreach ( $appointments as $sibling ) {
+ if ( (int) $sibling->id === (int) $current_appointment_id ) {
+ continue;
+ }
+
+ if ( self::map_appointment_status_to_order_status( (string) $sibling->status ) !== $order_status ) {
+ return false;
+ }
+ }
+
+ return true;
}
/**
@@ -197,7 +267,18 @@
// Update associated order status to canceled
self::sync_order_status( $appointment, 'canceled' );
- // Optionally fire hooks here
+ /**
+ * Fires after an appointment is canceled.
+ *
+ * Lets integrations (e.g. Google Calendar sync) react to a cancellation
+ * so external state is kept in sync. This is the single choke point for
+ * every cancel path — abandoned-booking cleanup, failed online payment,
+ * refunds and manual cancels all route through here.
+ *
+ * @param BookticsModelsAppointment_Model $appointment The canceled appointment.
+ */
+ do_action( 'booktics_after_appointment_cancelled', $appointment );
+
return $appointment;
}
}
--- a/booktics/core/assets/localize.php
+++ b/booktics/core/assets/localize.php
@@ -35,12 +35,34 @@
'currency_list' => booktics_get_currencies(),
'bookticsPro' => class_exists('BookticsPro'),
'user_role' => (array) $user_roles,
+ 'doc_links' => self::get_doc_links(),
];
return apply_filters( 'booktics_admin_localize', $data );
}
/**
+ * Build a slug => doc_link map from the module registry.
+ *
+ * Single source of truth for documentation URLs: both the addon card
+ * (PHP `doc_link`) and the React configure modals read from this list,
+ * so a doc URL is only ever defined once in booktics_modules_list().
+ *
+ * @return array<string, string>
+ */
+ private static function get_doc_links() {
+ $doc_links = [];
+
+ foreach ( booktics_modules_list() as $module ) {
+ if ( ! empty( $module['slug'] ) && ! empty( $module['doc_link'] ) ) {
+ $doc_links[ $module['slug'] ] = $module['doc_link'];
+ }
+ }
+
+ return $doc_links;
+ }
+
+ /**
* Get frontend localize data
*
* @return array Collection localize data
--- a/booktics/core/cart/cart-manager.php
+++ b/booktics/core/cart/cart-manager.php
@@ -310,8 +310,32 @@
return array();
}
- $cart_item_data = array_merge( $new_data, array( 'updated_at' => current_time( 'mysql' ) ) );
- $cart_item_data = apply_filters( 'booktics_pro_cart_db', $cart_item_data, $new_data );
+ // Only allow known, editable columns from client input. This prevents
+ // arbitrary request-body keys from reaching the SQL UPDATE clause
+ // the list via the filter below.
+ $allowed_columns = apply_filters(
+ 'booktics_cart_item_editable_columns',
+ array(
+ 'date',
+ 'start_time',
+ 'end_time',
+ 'service_id',
+ 'team_member_id',
+ 'price',
+ 'subtotal',
+ 'total',
+ 'additional_duration_id',
+ 'extra_services',
+ 'group_booking',
+ 'time_format',
+ 'location_id',
+ )
+ );
+
+ $cart_item_data = array_intersect_key( $new_data, array_flip( $allowed_columns ) );
+ $cart_item_data['uuid'] = $uuid;
+ $cart_item_data['updated_at'] = current_time( 'mysql' );
+ $cart_item_data = apply_filters( 'booktics_pro_cart_db', $cart_item_data, $new_data );
$this->db->update(
$this->cart_items_table, $cart_item_data,
array(
--- a/booktics/core/cart/cart-session.php
+++ b/booktics/core/cart/cart-session.php
@@ -18,21 +18,59 @@
const SESSION_KEY = 'booktics_cart';
/**
+ * Start a PHP session when one is not running yet.
+ *
+ * Sessions are started lazily instead of on every request so that a session
+ * is never opened after output has already been flushed, which triggers a
+ * "Session cannot be started after headers have already been sent" warning.
+ *
+ * @return bool True when $_SESSION is usable.
+ */
+ private static function maybe_start_session(): bool {
+ if ( PHP_SESSION_ACTIVE === session_status() ) {
+ return true;
+ }
+
+ if ( PHP_SESSION_DISABLED === session_status() ) {
+ return false;
+ }
+
+ if ( headers_sent() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
+ return false;
+ }
+
+ return session_start();
+ }
+
+ /**
+ * Get an empty cart structure
+ *
+ * @return array{items: array, total: float, coupon: string}
+ */
+ private static function empty_cart(): array {
+ return array(
+ 'items' => array(),
+ 'total' => 0.00,
+ 'coupon' => '',
+ );
+ }
+
+ /**
* Get cart data from session
*
* @return array{items: array, total: float}
*/
public static function get() {
+ if ( ! self::maybe_start_session() ) {
+ return self::empty_cart();
+ }
+
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitized via sanitize_session_data() on next line.
$raw_data = ! empty( $_SESSION[ self::SESSION_KEY ] ) ? wp_unslash( $_SESSION[ self::SESSION_KEY ] ) : null;
$session_data = self::sanitize_session_data( $raw_data );
if ( ! is_array( $session_data ) ) {
- return array(
- 'items' => array(),
- 'total' => 0.00,
- 'coupon' => '',
- );
+ return self::empty_cart();
}
return $session_data;
@@ -91,6 +129,10 @@
* @return void
*/
public static function set( array $cart ) {
+ if ( ! self::maybe_start_session() ) {
+ return;
+ }
+
$_SESSION[ self::SESSION_KEY ] = $cart;
}
@@ -100,6 +142,10 @@
* @return void
*/
public static function clear() {
+ if ( ! self::maybe_start_session() ) {
+ return;
+ }
+
unset( $_SESSION[ self::SESSION_KEY ] );
}
--- a/booktics/core/cart/controllers/cart-controller.php
+++ b/booktics/core/cart/controllers/cart-controller.php
@@ -299,6 +299,10 @@
// Add UUID to validated data
$validated['uuid'] = $uuid;
+ // Calculate end time from start time and total duration
+ $total_duration_min = $this->calculate_total_duration( $validated );
+ $validated['end_time'] = $this->get_endtime_from_starttime( $validated['start_time'], $total_duration_min );
+
// Update the cart item
$updated_item = $this->cart_manager->edit_cart_item( $uuid, $validated );
--- a/booktics/core/extensions/controllers/module-controller.php
+++ b/booktics/core/extensions/controllers/module-controller.php
@@ -185,7 +185,7 @@
);
}
- if ( 'module' == $extension['type'] ) {
+ if ( in_array( $extension['type'], array( 'module', 'integration' ), true ) ) {
$result = $this->extensions->update($name, $status);
if (false === $result) {
@@ -280,6 +280,22 @@
case 'fluentcrm':
booktics_update_option('enable_fluentcrm', $is_enabled);
break;
+
+ case 'pabbly':
+ booktics_update_option('enable_pabbly', $is_enabled);
+ break;
+
+ case 'zapier':
+ booktics_update_option('enable_zapier', $is_enabled);
+ break;
+
+ case 'zoho':
+ booktics_update_option('enable_zoho', $is_enabled);
+ break;
+
+ case 'mailpoet':
+ booktics_update_option('enable_mailpoet', $is_enabled);
+ break;
}
}
}
--- a/booktics/core/extensions/module-service-provider.php
+++ b/booktics/core/extensions/module-service-provider.php
@@ -5,7 +5,7 @@
use BookticsProvidersBase_Service_Provider;
use BookticsExtensionsControllersModule_Controller;
class Module_Service_Provider extends Base_Service_Provider {
-
+
protected $services = array(
Module_Controller::class,
);
--- a/booktics/core/extensions/plugin-manager.php
+++ b/booktics/core/extensions/plugin-manager.php
@@ -328,23 +328,6 @@
'doc_link' => 'https://docs.arraytics.com/docs/timetics/getting-started/',
'download_link' => 'https://downloads.wordpress.org/plugin/timetics.latest-stable.zip',
),
- 'poptics' => array(
- 'name' => 'poptics',
- 'slug' => 'poptics',
- 'type' => 'plugin',
- 'upgrade' => false,
- 'upgrade_link' => '',
- 'status' => 'off',
- 'is_pro' => false,
- 'title' => __( 'Poptics', 'booktics' ),
- 'description' => __( 'Discover the ultimate popup mix with Poptics Popup Builder to boost your lead generation and sales conversions.', 'booktics' ),
- 'icon' => Extension_Icon::get( 'poptics' ),
- 'notice' => '',
- 'demo_link' => 'https://demo.aethonic.com/popticsadmin/',
- 'settings_link' => '',
- 'doc_link' => 'https://docs.aethonic.com/docs/getting-started/intro/',
- 'download_link' => 'https://downloads.wordpress.org/plugin/poptics.latest-stable.zip',
- ),
'aisentic' => array(
'name' => 'aisentic',
'slug' => 'aisentic',
@@ -354,7 +337,7 @@
'status' => 'off',
'is_pro' => false,
'title' => __( 'Aisentic', 'booktics' ),
- 'description' => __( 'AI assistant for WordPress — automate content, replies and on-site tasks without leaving your dashboard.', 'booktics' ),
+ 'description' => __( 'Your AI assistant for Booktics. Manage bookings, analyze schedules, and automate routine tasks using plain English.', 'booktics' ),
'icon' => '<svg width="155" height="35.838" viewBox="0 0 155 35.838" fill="none" xmlns="http://www.w3.org/2000/svg"><path width="40" height="40" rx="7.018" fill="#6443f9" d="M6.288 0H29.55A6.288 6.288 0 0 1 35.838 6.288V29.55A6.288 6.288 0 0 1 29.55 35.838H6.288A6.288 6.288 0 0 1 0 29.55V6.288A6.288 6.288 0 0 1 6.288 0z"/><path d="M17.919 3.772c0.609 0 1.193 0.244 1.623 0.676a2.303 2.303 0 0 1 0.216 3c-0.296 0.395 -0.71 0.685 -1.184 0.824v3.397h6.561c1.044 0 2.045 0.417 2.784 1.158a3.942 3.942 0 0 1 1.153 2.791v0.731h0.553a1.975 1.975 0 0 1 1.968 1.974v4.605c0 0.524 -0.207 1.026 -0.576 1.397a1.971 1.971 0 0 1 -1.392 0.578h-0.553v3.216a3.942 3.942 0 0 1 -1.153 2.792 3.942 3.942 0 0 1 -2.784 1.157h-14.434a3.942 3.942 0 0 1 -2.784 -1.157 3.942 3.942 0 0 1 -1.153 -2.791v-3.217h-0.553a1.971 1.971 0 0 1 -1.392 -0.578 1.971 1.971 0 0 1 -0.576 -1.396v-4.605c0 -0.524 0.207 -1.026 0.576 -1.396a1.971 1.971 0 0 1 1.392 -0.579h0.553v-0.731c0 -1.047 0.416 -2.052 1.153 -2.791a3.942 3.942 0 0 1 2.784 -1.158h6.561v-3.396a2.294 2.294 0 0 1 -1.64 -2.197c0 -0.61 0.242 -1.196 0.673 -1.628A2.294 2.294 0 0 1 17.919 3.772m-3.638 21.497a0.655 0.655 0 0 0 -0.908 0.787 0.663 0.663 0 0 0 0.31 0.384 9.291 9.291 0 0 0 8.472 0 0.659 0.659 0 0 0 -0.599 -1.171 8.028 8.028 0 0 1 -7.273 0m-0.627 -8.337a2.294 2.294 0 0 0 -1.623 0.675 2.308 2.308 0 0 0 0 3.258 2.294 2.294 0 0 0 3.92 -1.629c0 -0.611 -0.242 -1.197 -0.672 -1.629a2.294 2.294 0 0 0 -1.623 -0.675m8.529 0a2.294 2.294 0 0 0 -2.122 1.422 2.308 2.308 0 0 0 1.243 3.01 2.294 2.294 0 0 0 2.502 -0.499 2.308 2.308 0 0 0 0 -3.258 2.294 2.294 0 0 0 -1.624 -0.675" fill="#fff"/><path d="M148.257 29.181c-4.408 0 -7.453 -3.172 -7.453 -7.58 0 -4.407 3.044 -7.546 7.453 -7.546 2.569 0 4.661 1.141 5.929 2.949l-2.822 2.188c-0.507 -0.602 -1.395 -1.395 -3.012 -1.395 -2.188 0 -3.679 1.617 -3.679 3.805s1.491 3.805 3.679 3.805c1.617 0 2.474 -0.666 3.012 -1.331l2.822 2.123c-1.269 1.84 -3.361 2.982 -5.929 2.982m-14.589 -0.285v-13.69a0.896 0.896 0 0 1 0.896 -0.896h2.202a0.896 0.896 0 0 1 0.896 0.898l-0.03 13.688z" fill="#08002b"/><path d="M135.793 7.841a0.251 0.251 0 0 1 0.237 0.165l0.173 0.468c0.236 0.636 0.331 0.879 0.507 1.055s0.418 0.271 1.055 0.507l0.468 0.173a0.251 0.251 0 0 1 0 0.473l-0.468 0.173c-0.636 0.236 -0.879 0.332 -1.055 0.507s-0.271 0.418 -0.507 1.055l-0.173 0.469a0.252 0.252 0 0 1 -0.473 0l-0.173 -0.469c-0.236 -0.636 -0.332 -0.878 -0.507 -1.055 -0.176 -0.176 -0.418 -0.271 -1.055 -0.507l-0.469 -0.173a0.252 0.252 0 0 1 0 -0.473l0.469 -0.173c0.636 -0.236 0.879 -0.332 1.055 -0.507s0.271 -0.418 0.507 -1.055l0.173 -0.468a0.251 0.251 0 0 1 0.237 -0.165m-3.058 -1.344a0.251 0.251 0 0 1 0.237 0.165l0.074 0.201c0.106 0.285 0.136 0.352 0.184 0.4 0.048 0.048 0.116 0.079 0.4 0.185l0.201 0.073a0.253 0.253 0 0 1 0 0.473l-0.201 0.074c-0.285 0.106 -0.352 0.136 -0.4 0.184 -0.047 0.048 -0.078 0.116 -0.184 0.4l-0.074 0.201a0.252 0.252 0 0 1 -0.472 0l-0.074 -0.201c-0.106 -0.285 -0.136 -0.352 -0.185 -0.4s-0.115 -0.078 -0.4 -0.184l-0.201 -0.074a0.251 0.251 0 0 1 0 -0.473l0.201 -0.073c0.285 -0.106 0.352 -0.136 0.4 -0.185 0.048 -0.047 0.079 -0.115 0.185 -0.4l0.074 -0.201a0.251 0.251 0 0 1 0.236 -0.165" fill="#6443f9"/><path d="M127.903 28.895c-2.917 0 -4.281 -1.521 -4.281 -4.217v-7.356h-1.902V14.308h1.902v-3.575a0.896 0.896 0 0 1 0.896 -0.896h2.172a0.896 0.896 0 0 1 0.896 0.896v3.575h3.108v3.012h-3.108v6.722c0 1.713 1.046 1.776 1.967 1.776h0.983v3.076zm-22.202 0v-13.69a0.896 0.896 0 0 1 0.896 -0.896h2.172a0.896 0.896 0 0 1 0.896 0.896v0.499c1.11 -1.205 2.664 -1.617 4.091 -1.617 2.631 0 5.676 1.426 5.676 5.898v8.91h-3.964v-8.308c0 -2.569 -1.807 -3.172 -2.917 -3.172 -1.141 0 -2.886 0.603 -2.886 3.172v8.308zm-9.81 0.317c-4.472 0 -7.42 -3.266 -7.42 -7.61s2.854 -7.579 7.262 -7.579c4.344 0 7.008 3.234 7.008 7.58v1.078h-10.465c0.381 1.966 1.807 3.139 3.615 3.139 1.934 0 2.949 -0.887 3.457 -1.554l2.695 1.967c-1.269 1.838 -3.488 2.98 -6.152 2.98m-3.552 -9.037h6.691c-0.349 -1.713 -1.427 -3.013 -3.298 -3.013 -1.808 0 -3.013 1.174 -3.393 3.013M80.38 29.34c-3.584 0 -5.803 -1.744 -6.532 -3.519L76.541 24.012c0.349 0.824 2.061 2.157 3.9 2.157 1.364 0 2.093 -0.412 2.093 -1.364 0 -1.174 -1.871 -1.49 -3.012 -1.871s-5.042 -1.3 -5.042 -4.503c0 -3.107 2.726 -4.439 5.866 -4.439 3.172 0 5.295 1.491 6.025 3.076l-2.569 1.649c-0.444 -0.697 -2.029 -1.711 -3.584 -1.711 -1.299 0 -1.871 0.507 -1.871 1.236 0 1.174 1.808 1.49 2.949 1.871s5.105 1.395 5.105 4.534c0 3.076 -2.283 4.693 -6.025 4.693m-11.352 -17.185c-1.079 0 -2.189 -0.824 -2.189 -2.219 0 -1.364 1.111 -2.093 2.188 -2.093 1.046 0 2.189 0.729 2.189 2.093 0 1.395 -1.142 2.219 -2.188 2.219m-1.998 16.744V14.31h3.996l-0.032 14.586zM44.798 28.895 52.942 8.843a0.896 0.896 0 0 1 0.831 -0.559h1.9a0.896 0.896 0 0 1 0.831 0.56l8.113 20.051h-4.344l-1.332 -3.393h-8.467l-1.331 3.393zm7.167 -7.134h5.517l-2.76 -7.008z" fill="#08002b"/></svg>',
'notice' => '',
'demo_link' => '',
@@ -371,7 +354,7 @@
'status' => 'off',
'is_pro' => false,
'title' => __( 'Optiontics', 'booktics' ),
- 'description' => __( 'Product add-ons / extras for food items — let customers pick toppings, sizes and other paid options along with the products.', 'booktics' ),
+ 'description' => __( 'Offer paid add-ons and extra options with every booking — services, extras, packages, or custom upgrades.', 'booktics' ),
'icon' => '<svg width="150px" height="40px" viewBox="0 0 155 27.5" fill="none" xmlns="http://www.w3.org/2000/svg"><path width="36" height="42" rx="5" fill="#F6F3FF" d="M3.125 0H19.375A3.125 3.125 0 0 1 22.5 3.125V23.125A3.125 3.125 0 0 1 19.375 26.25H3.125A3.125 3.125 0 0 1 0 23.125V3.125A3.125 3.125 0 0 1 3.125 0z"/><path x="3.375" y="3.5" width="29.25" height="10.5" rx="5.25" fill="#4A3BD6" d="M5.391 2.188H17.109A3.281 3.281 0 0 1 20.391 5.469V5.469A3.281 3.281 0 0 1 17.109 8.75H5.391A3.281 3.281 0 0 1 2.109 5.469V5.469A3.281 3.281 0 0 1 5.391 2.188z"/><path x="3.375" y="15.75" width="29.25" height="10.5" rx="5.25" fill="#6F33EC" d="M5.391 9.844H17.109A3.281 3.281 0 0 1 20.391 13.125V13.125A3.281 3.281 0 0 1 17.109 16.406H5.391A3.281 3.281 0 0 1 2.109 13.125V13.125A3.281 3.281 0 0 1 5.391 9.844z"/><path x="3.375" y="28" width="29.25" height="10.5" rx="5.25" fill="#1AB89C" d="M5.391 17.5H17.109A3.281 3.281 0 0 1 20.391 20.781V20.781A3.281 3.281 0 0 1 17.109 24.063H5.391A3.281 3.281 0 0 1 2.109 20.781V20.781A3.281 3.281 0 0 1 5.391 17.5z"/><path d="M5.274 3.879c0.833 0 1.523 0.703 1.523 1.589S6.107 7.056 5.274 7.056C4.44 7.056 3.75 6.354 3.75 5.468s0.69 -1.589 1.524 -1.589Z" stroke="white" stroke-width="0.46875"/><path cx="8.4375" cy="33.2487" rx="2.8125" ry="2.91667" fill="white" d="M7.031 20.78A1.758 1.823 0 0 1 5.273 22.603A1.758 1.823 0 0 1 3.516 20.78A1.758 1.823 0 0 1 7.031 20.78z"/><path cx="8.4375" cy="20.9987" rx="2.8125" ry="2.91667" fill="white" d="M7.031 13.124A1.758 1.823 0 0 1 5.273 14.947A1.758 1.823 0 0 1 3.516 13.124A1.758 1.823 0 0 1 7.031 13.124z"/><path d="m4.571 13.216 0.439 0.456 0.967 -1.094" stroke="#6F33EC" stroke-width="0.234375" stroke-linecap="round" stroke-linejoin="round"/><path d="M46.759 13.235q0 2.929 -1.11 4.984 -1.102 2.054 -3.008 3.138 -1.898 1.075 -4.266 1.075 -2.386 0 -4.284 -1.084t-2.999 -3.138q-1.102 -2.055 -1.102 -4.975 0 -2.928 1.102 -4.983 1.101 -2.054 2.999 -3.129Q35.989 4.037 38.375 4.037q2.369 0 4.266 1.084 1.906 1.075 3.008 3.129 1.11 2.055 1.11 4.983m-3.837 0q0 -1.897 -0.569 -3.2 -0.559 -1.302 -1.583 -1.975 -1.022 -0.674 -2.395 -0.674t-2.396 0.674q-1.023 0.673 -1.591 1.975 -0.559 1.303 -0.559 3.2t0.559 3.2q0.569 1.302 1.591 1.976 1.023 0.673 2.396 0.673t2.395 -0.673q1.022 -0.673 1.583 -1.976 0.569 -1.303 0.569 -3.2M49.494 27.223V8.759h3.672v2.256h0.166q0.244 -0.542 0.708 -1.102 0.472 -0.569 1.224 -0.944 0.761 -0.385 1.888 -0.385 1.469 0 2.711 0.769 1.241 0.761 1.984 2.3 0.743 1.529 0.743 3.837 0 2.247 -0.726 3.794 -0.717 1.539 -1.958 2.334 -1.233 0.787 -2.763 0.787 -1.084 0 -1.845 -0.359 -0.752 -0.358 -1.232 -0.9 -0.481 -0.551 -0.734 -1.111h-0.114v7.186zm3.646 -11.75q0 1.198 0.332 2.089 0.333 0.892 0.962 1.39 0.629 0.49 1.53 0.49 0.909 0 1.539 -0.498 0.629 -0.507 0.953 -1.399 0.332 -0.9 0.332 -2.072 0 -1.163 -0.323 -2.046 -0.324 -0.883 -0.953 -1.381 -0.63 -0.499 -1.547 -0.498 -0.909 0 -1.539 0.481 -0.621 0.481 -0.953 1.364 -0.332 0.883 -0.332 2.081m19.076 -6.714v2.798h-8.086v-2.797zm-6.251 -3.217h3.724v12.519q0 0.516 0.158 0.805 0.158 0.279 0.437 0.393 0.289 0.114 0.664 0.114 0.263 0 0.524 -0.044 0.263 -0.053 0.403 -0.079l0.586 2.771q-0.279 0.088 -0.787 0.201 -0.507 0.122 -1.232 0.149 -1.346 0.052 -2.361 -0.359 -1.005 -0.411 -1.565 -1.276 -0.559 -0.866 -0.551 -2.186zM74.641 22.188V8.759h3.724V22.188zm1.871 -15.159q-0.831 0 -1.425 -0.551 -0.586 -0.559 -0.586 -1.338 0 -0.769 0.586 -1.321 0.594 -0.559 1.425 -0.559t1.416 0.559q0.594 0.551 0.594 1.321 0 0.778 -0.594 1.338 -0.586 0.55 -1.416 0.55m10.904 15.422q-2.037 0 -3.523 -0.866 -1.478 -0.875 -2.282 -2.431 -0.804 -1.565 -0.804 -3.628 0 -2.081 0.804 -3.637 0.804 -1.564 2.282 -2.43 1.486 -0.875 3.523 -0.875 2.037 0 3.514 0.875 1.486 0.865 2.291 2.43 0.804 1.556 0.804 3.638 0 2.063 -0.804 3.628 -0.804 1.556 -2.291 2.431 -1.478 0.866 -3.514 0.866m0.018 -2.885q0.927 0 1.547 -0.525 0.621 -0.533 0.936 -1.451 0.323 -0.917 0.323 -2.089t-0.323 -2.089q-0.315 -0.917 -0.936 -1.451 -0.621 -0.533 -1.547 -0.533 -0.936 0 -1.574 0.533 -0.629 0.534 -0.953 1.451 -0.314 0.919 -0.314 2.089 0 1.172 0.314 2.089 0.324 0.919 0.953 1.451 0.638 0.525 1.574 0.525m12.737 -5.141V22.188h-3.724V8.759h3.549v2.369h0.157a3.75 3.75 0 0 1 1.495 -1.853q1.049 -0.691 2.544 -0.691 1.399 0 2.439 0.612t1.618 1.749q0.577 1.128 0.577 2.692V22.188h-3.724V14.302q0.008 -1.232 -0.63 -1.924 -0.637 -0.699 -1.757 -0.699 -0.752 0 -1.329 0.324 -0.569 0.324 -0.892 0.944 -0.315 0.613 -0.324 1.478m18.733 -5.665v2.797h-8.087v-2.797zm-6.251 -3.217h3.724v12.519q0 0.516 0.158 0.805 0.158 0.279 0.438 0.393 0.288 0.114 0.664 0.114 0.262 0 0.524 -0.044 0.263 -0.053 0.402 -0.079l0.586 2.771q-0.28 0.088 -0.787 0.201 -0.508 0.122 -1.233 0.149 -1.346 0.052 -2.36 -0.359 -1.006 -0.411 -1.565 -1.276 -0.56 -0.866 -0.551 -2.186zM121.331 22.188V8.759h3.724V22.188zm1.871 -15.159q-0.831 0 -1.425 -0.551 -0.586 -0.559 -0.586 -1.338 0 -0.769 0.586 -1.321 0.594 -0.559 1.425 -0.559t1.416 0.559q0.594 0.551 0.594 1.321 0 0.778 -0.594 1.338 -0.586 0.55 -1.416 0.55m10.904 15.422q-2.063 0 -3.549 -0.875 -1.478 -0.882 -2.272 -2.447 -0.787 -1.565 -0.787 -3.602 0 -2.063 0.796 -3.619 0.804 -1.565 2.281 -2.439 1.478 -0.883 3.515 -0.883 1.757 0 3.077 0.637 1.321 0.639 2.089 1.792 0.769 1.154 0.848 2.711h-3.514q-0.148 -1.006 -0.787 -1.618 -0.629 -0.621 -1.653 -0.621 -0.865 0 -1.512 0.472 -0.639 0.463 -0.997 1.355t-0.359 2.159q0 1.286 0.35 2.186 0.358 0.9 1.006 1.373 0.647 0.473 1.512 0.473 0.639 0 1.146 -0.263a2.219 2.219 0 0 0 0.848 -0.761q0.341 -0.506 0.446 -1.215h3.514q-0.088 1.539 -0.839 2.71 -0.742 1.163 -2.054 1.819 -1.311 0.656 -3.104 0.656m19.555 -9.862 -3.409 0.21a1.75 1.75 0 0 0 -0.376 -0.787 2 2 0 0 0 -0.761 -0.569q-0.463 -0.218 -1.11 -0.218 -0.866 0 -1.46 0.367 -0.594 0.358 -0.594 0.961 0 0.481 0.384 -2.666 0 -4.249 -1.111 -1.574 -1.119 -1.845 -3.043l3.663 -0.192q0.166 0.813 0.804 1.241 0.639 0.419 1.635 0.419 0.979 0 1.574 -0.376 0.603 -0.384 0.612 -0.988 -0.009 -0.508 -0.429 -0.831 -0.419 -0.332 -1.294 -0.506l-2.326 -0.464q-1.967 -0.394 -2.929 -1.364 -0.953 -0.971 -0.953 -2.474 0 -1.294 0.699 -2.229 0.708 -0.936 1.984 -1.442 1.286 -0.506 3.008 -0.507 2.544 0 4.004 1.075 1.469 1.076 1.714 2.929" fill="#303030"/></svg>',
'notice' => '',
'demo_link' => '',
--- a/booktics/core/module/fluentcrm/fluentcrm-service.php
+++ b/booktics/core/module/fluentcrm/fluentcrm-service.php
@@ -10,36 +10,41 @@
if ( ! defined( 'ABSPATH' ) ) exit;
use BookticsContractsHookable_Service_Contract;
+use BookticsAbstractsBooktics_Database;
+use BookticsModelsGuest_Model;
class FluentCRM_Service implements Hookable_Service_Contract {
/**
* Register hooks
*/
public function register() {
- add_action( 'booktics_order_created', array( $this, 'add_contact_to_fluentcrm' ) );
+ add_action( 'booktics_after_order_created', array( $this, 'add_contact_to_fluentcrm' ), 10, 2 );
}
/**
* Add contact to FluentCRM
*
- * @param object $order_model The order model
+ * @param object $order_model The order model
+ * @param array $appointments Created appointments (unused).
*/
- public function add_contact_to_fluentcrm( $order_model ) {
+ public function add_contact_to_fluentcrm( $order_model, $appointments = array() ) {
// Check if FluentCRM is active
if ( ! defined( 'FLUENTCRM' ) || ! function_exists( 'FluentCrmApi' ) ) {
return;
}
- // Get customer details
- $customer = get_user_by( 'id', $order_model->customer_id );
- if ( ! $customer ) {
+ // Get customer details. customer_id is a Booktics guest record id, not a WP user id.
+ $customer = ( new Guest_Model( new Booktics_Database() ) )->find( array( 'id' => $order_model->customer_id ) );
+ if ( ! $customer || is_wp_error( $customer ) ) {
return;
}
+ $name_parts = preg_split( '/s+/', trim( (string) $customer->name ), 2 );
+
$customer_data = array(
- 'email' => $customer->user_email,
- 'first_name' => $customer->first_name,
- 'last_name' => $customer->last_name ?: '',
+ 'email' => $customer->email,
+ 'first_name' => $name_parts[0] ?? '',
+ 'last_name' => $name_parts[1] ?? '',
'status' => 'subscribed',
);
--- a/booktics/core/module/google-calendar/Controller/calendar-sync-controller.php
+++ b/booktics/core/module/google-calendar/Controller/calendar-sync-controller.php
@@ -68,6 +68,7 @@
add_action( 'booktics_after_appointment_created', array( $this, 'handle_appointment_created' ), 10, 1 );
add_action( 'booktics_after_appointment_updated', array( $this, 'handle_appointment_updated' ), 10, 1 );
+ add_action( 'booktics_after_appointment_cancelled', array( $this, 'handle_appointment_cancelled' ), 10, 1 );
add_action( 'before_delete_post', array( $this, 'capture_appointment_data_before_delete' ), 10, 1 );
add_action( 'booktics_after_appointment_deleted', array( $this, 'handle_appointment_deleted' ), 10, 1 );
}
@@ -162,13 +163,52 @@
$this->calendar->update_event( $event_id, $appointment, $team_member_id );
}
} catch ( Throwable $e ) {
- if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
+ if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
error_log( 'Failed to updated Google Calendar event: ' . $e->getMessage() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
}
}
}
/**
+ * On appointment cancelled, remove its Google Calendar event.
+ *
+ * A cancellation only flips the appointment status (no post deletion), so
+ * the delete hooks never fire. Without this the calendar event lingers in
+ * the team member's calendar for a booking that was auto-cancelled (e.g. an
+ * abandoned/unpaid online booking) or refunded, keeping the slot visually
+ * blocked. Deleting the event frees the calendar slot to match the freed
+ * appointment slot.
+ *
+ * @param BookticsModelsAppointment_Model $appointment appointment data
+ */
+ public function handle_appointment_cancelled( $appointment ) {
+ try {
+ if ( ! isset( $appointment->id ) ) {
+ return;
+ }
+
+ $event_id = get_post_meta( $appointment->id, '_google_calendar_event_id', true );
+ $team_member_id = get_post_meta( $appointment->id, 'team_member_id', true );
+
+ if ( ! $team_member_id && isset( $appointment->team_member_id ) ) {
+ $team_member_id = $appointment->team_member_id;
+ }
+
+ if ( ! $event_id || ! $team_member_id ) {
+ return;
+ }
+
+ if ( $this->calendar->delete_event( $event_id, $team_member_id ) ) {
+ delete_post_meta( $appointment->id, '_google_calendar_event_id' );
+ }
+ } catch ( Throwable $e ) {
+ if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
+ error_log( '[Booktics Google Calendar] Failed to delete Google Calendar event on cancel: ' . $e->getMessage() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
+ }
+ }
+ }
+
+ /**
* Capture appointment Google Calendar data before WordPress deletes the post.
*
* @param int $post_id Post ID being deleted
@@ -286,9 +326,14 @@
return $notification_flow_data;
}
- $user_id = get_current_user_id();
- $tokens = get_user_meta( $user_id, 'booktics_google_auth_token', true );
- $access_token = $tokens['access_token'] ?? '';
+ $user_id = $formatted_appointment['team']['id'] ?? null;
+
+ if ( empty( $user_id ) ) {
+ return $notification_flow_data;
+ }
+
+ // get_access_token_for_api() also refreshes the token when it has expired.
+ $access_token = $this->calendar->get_access_token_for_api( $user_id );
if ( empty( $access_token ) ) {
return $notification_flow_data;
@@ -298,9 +343,10 @@
$timezone = wp_timezone();
$timezone_string = $timezone->getName();
- // Convert timestamps to ISO 8601 format with timezone
- $start_timestamp = strtotime( $formatted_appointment['start_time'] );
- $end_timestamp = strtotime( $formatted_appointment['end_time'] );
+ // Appointment date/time are stored in UTC. Combine them so the Meet event lands on the actual appointment date instead of "today".
+ $appointment_date = $formatted_appointment['date'] ?? '';
+ $start_timestamp = strtotime( $appointment_date . ' ' . $formatted_appointment['start_time'] . ' UTC' );
+ $end_timestamp = strtotime( $appointment_date . ' ' . $formatted_appointment['end_time'] . ' UTC' );
// Format dates in ISO 8601 format with timezone using wp_date
$start_time = wp_date( 'c', $start_timestamp, $timezone );
--- a/booktics/core/module/mailpoet/Controller/mailpoet-controller.php
+++ b/booktics/core/module/mailpoet/Controller/mailpoet-controller.php
@@ -0,0 +1,181 @@
+<?php
+/**
+ * MailPoet Controller
+ *
+ * Exposes the MailPoet plugin lifecycle (install/activate) and list lookup
+ * to the admin integration card.
+ *
+ * @package Booktics/Module/Mailpoet
+ */
+
+namespace BookticsModuleMailpoetController;
+
+if ( ! defined( 'ABSPATH' ) ) exit;
+
+use BookticsAbstractsBase_Rest_Controller;
+use ArrayticsToolsSdkPluginManager;
+
+class Mailpoet_Controller extends Base_Rest_Controller {
+ /**
+ * The namespace of this controller's route.
+ *
+ * @var string
+ */
+ protected $namespace = 'booktics/v1';
+
+ /**
+ * The base of this controller's route.
+ *
+ * @var string
+ */
+ protected $rest_base = 'mailpoet';
+
+ /**
+ * MailPoet plugin slug (wp.org).
+ *
+ * @var string
+ */
+ const PLUGIN_SLUG = 'mailpoet';
+
+ /**
+ * Register the routes.
+ *
+ * @return void
+ */
+ public function register_routes(): void {
+ register_rest_route(
+ $this->namespace,
+ '/' . $this->rest_base,
+ array(
+ array(
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => array( $this, 'get_status' ),
+ 'permission_callback' => array( $this, 'permissions_check' ),
+ ),
+ array(
+ 'methods' => WP_REST_Server::CREATABLE,
+ 'callback' => array( $this, 'update_plugin_status' ),
+ 'permission_callback' => array( $this, 'permissions_check' ),
+ ),
+ )
+ );
+ }
+
+ /**
+ * Permission check.
+ *
+ * @return bool
+ */
+ public function permissions_check() {
+ return current_user_can( 'manage_options' );
+ }
+
+ /**
+ * Get current MailPoet plugin status and (when active) its lists.
+ *
+ * @return WP_HTTP_Response
+ */
+ public function get_status() {
+ return $this->response( $this->build_status_payload() );
+ }
+
+ /**
+ * Install or activate the MailPoet plugin.
+ *
+ * @param WP_REST_Request $request Request.
+ * @return WP_HTTP_Response
+ */
+ public function update_plugin_status( $request ) {
+ $params = json_decode( $request->get_body(), true );
+ $status = isset( $params['status'] ) ? sanitize_text_field( $params['status'] ) : '';
+
+ if ( ! in_array( $status, array( 'install', 'activate' ), true ) ) {
+ return $this->error( __( 'Invalid status provided', 'booktics' ), 422, 'invalid_status' );
+ }
+
+ if ( 'install' === $status ) {
+ $result = PluginManager::install_plugin( self::PLUGIN_SLUG );
+ if ( $result ) {
+ PluginManager::activate_plugin( self::PLUGIN_SLUG );
+ }
+ } else {
+ $result = PluginManager::activate_plugin( self::PLUGIN_SLUG );
+ }
+
+ if ( false === $result || is_wp_error( $result ) ) {
+ return $this->error(
+ /* translators: %s: action */
+ sprintf( __( 'Could not %s MailPoet', 'booktics' ), $status ),
+ 500,
+ 'operation_failed'
+ );
+ }
+
+ return $this->response(
+ $this->build_status_payload(),
+ /* translators: %s: action */
+ sprintf( __( 'MailPoet %s successfully', 'booktics' ), $status )
+ );
+ }
+
+ /**
+ * Build the status payload (plugin_status + lists when active).
+ *
+ * @return array
+ */
+ private function build_status_payload() {
+ $plugin_status = $this->resolve_plugin_status();
+
+ return array(
+ 'plugin_status' => $plugin_status,
+ 'lists' => 'active' === $plugin_status ? $this->get_lists() : array(),
+ );
+ }
+
+ /**
+ * Resolve the plugin status: install | activate | active.
+ *
+ * @return string
+ */
+ private function resolve_plugin_status() {
+ if ( ! PluginManager::is_installed( self::PLUGIN_SLUG ) ) {
+ return 'install';
+ }
+
+ if ( ! PluginManager::is_activated( self::PLUGIN_SLUG ) ) {
+ return 'activate';
+ }
+
+ return 'active';
+ }
+
+ /**
+ * Get MailPoet lists as {id, name} pairs.
+ *
+ * @return array
+ */
+ private function get_lists() {
+ if ( ! class_exists( 'MailPoetAPIAPI' ) ) {
+ return array();
+ }
+
+ try {
+ $lists = MailPoetAPIAPI::MP( 'v1' )->getLists();
+ } catch ( Throwable $e ) {
+ return array();
+ }
+
+ $result = array();
+ foreach ( (array) $lists as $list ) {
+ if ( empty( $list['id'] ) ) {
+ continue;
+ }
+ $result[] = array(
+ 'id' => (string) $list['id'],
+ 'name' => isset( $list['name'] ) ? $list['name'] : '',
+ );
+ }
+
+ return $result;
+ }
+}
--- a/booktics/core/module/mailpoet/mailpoet-service-provider.php
+++ b/booktics/core/module/mailpoet/mailpoet-service-provider.php
@@ -0,0 +1,34 @@
+<?php
+namespace BookticsModuleMailpoet;
+
+if ( ! defined( 'ABSPATH' ) ) exit;
+
+use BookticsProvidersBase_Service_Provider;
+use BookticsModuleMailpoetControllerMailpoet_Controller;
+
+/**
+ * Mailpoet_Service_Provider responsible for booting the MailPoet integration
+ * service and its REST controller.
+ *
+ * @package Booktics/Module/Mailpoet
+ */
+class Mailpoet_Service_Provider extends Base_Service_Provider {
+ /**
+ * Store services
+ *
+ * @var array
+ */
+ protected $services = array(
+ Mailpoet_Service::class,
+ Mailpoet_Controller::class,
+ );
+
+ /**
+ * Register services
+ *
+ * @return void
+ */
+ public function get_services() {
+ return apply_filters( 'booktics_mailpoet_addon_admin_services', $this->services );
+ }
+}
--- a/booktics/core/module/mailpoet/mailpoet-service.php
+++ b/booktics/core/module/mailpoet/mailpoet-service.php
@@ -0,0 +1,98 @@
+<?php
+/**
+ * MailPoet Service
+ *
+ * Adds Booktics booking customers to MailPoet lists via the MailPoet public API.
+ */
+
+namespace BookticsModuleMailpoet;
+
+if ( ! defined( 'ABSPATH' ) ) exit;
+
+use BookticsContractsHookable_Service_Contract;
+use BookticsAbstractsBooktics_Database;
+use BookticsModelsGuest_Model;
+
+class Mailpoet_Service implements Hookable_Service_Contract {
+ /**
+ * Register hooks
+ */
+ public function register() {
+ add_action( 'booktics_after_order_created', array( $this, 'send_to_mailpoet' ), 10, 2 );
+ }
+
+ /**
+ * Add the booking customer to the configured MailPoet list(s).
+ *
+ * @param object $order_model The order model.
+ * @param array $appointments Created appointments (unused).
+ */
+ public function send_to_mailpoet( $order_model, $appointments = array() ) {
+ // MailPoet plugin may be inactive/uninstalled.
+ if ( ! class_exists( 'MailPoetAPIAPI' ) ) {
+ return;
+ }
+
+ $list_ids = booktics_get_option( 'mailpoet_list_ids' );
+ $list_ids = array_values( array_filter( array_map( 'intval', (array) $list_ids ) ) );
+ if ( empty( $list_ids ) ) {
+ return;
+ }
+
+ // Get customer details. customer_id is a Booktics guest record id, not a WP user id.
+ $customer = ( new Guest_Model( new Booktics_Database() ) )->find( array( 'id' => $order_model->customer_id ) );
+ if ( ! $customer || is_wp_error( $customer ) || empty( $customer->email ) ) {
+ return;
+ }
+
+ $name_parts = preg_split( '/s+/', trim( (string) $customer->name ), 2 );
+
+ $subscriber = array(
+ 'email' => $customer->email,
+ 'first_name' => $name_parts[0] ?? '',
+ 'last_name' => $name_parts[1] ?? '',
+ );
+
+ try {
+ $this->add_subscriber( $subscriber, $list_ids );
+ } catch ( Throwable $e ) {
+ // Ensures silent failure in case of any error.
+ if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
+ error_log( 'MailPoet Error: ' . $e->getMessage() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
+ }
+ }
+ }
+
+ /**
+ * Add a subscriber and subscribe to lists. If the subscriber already
+ * exists, just subscribe the existing record to the lists.
+ *
+ * @param array $subscriber Subscriber fields (email, first_name, last_name).
+ * @param array $list_ids MailPoet list ids.
+ */
+ private function add_subscriber( array $subscriber, array $list_ids ) {
+ $mailpoet = MailPoetAPIAPI::MP( 'v1' );
+
+ // Look up first: getSubscriber throws when the email is not found.
+ $existing = null;
+ try {
+ $existing = $mailpoet->getSubscriber( $subscriber['email'] );
+ } catch ( Exception $e ) {
+ $existing = null;
+ }
+
+ // Existing subscriber - just subscribe the record to the lists.
+ if ( ! empty( $existing['id'] ) ) {
+ $mailpoet->subscribeToLists( $existing['id'], $list_ids );
+ return;
+ }
+
+ // New subscriber - create and subscribe. Any real error here propagates
+ // to send_to_mailpoet() and is logged.
+ $mailpoet->addSubscriber(
+ $subscriber,
+ $list_ids,
+ array( 'skip_subscriber_notification' => true )
+ );
+ }
+}
--- a/booktics/core/module/pabbly/pabbly-service-provider.php
+++ b/booktics/core/module/pabbly/pabbly-service-provider.php
@@ -0,0 +1,31 @@
+<?php
+namespace BookticsModulePabbly;
+
+if ( ! defined( 'ABSPATH' ) ) exit;
+
+use BookticsProvidersBase_Service_Provider;
+
+/**
+ * Pabbly_Service_Provider responsible for booting the Pabbly integration service.
+ *
+ * @package Booktics/Module/Pabbly
+ */
+class Pabbly_Service_Provider extends Base_Service_Provider {
+ /**
+ * Store services
+ *
+ * @var array
+ */
+ protected $services = array(
+ Pabbly_Service::class,
+ );
+
+ /**
+ * Register services
+ *
+ * @return void
+ */
+ public function get_services() {
+ return apply_filters( 'booktics_pabbly_addon_admin_services', $this->services );
+ }
+}
--- a/booktics/core/module/pabbly/pabbly-service.php
+++ b/booktics/core/module/pabbly/pabbly-service.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Pabbly Service
+ *
+ * Handles Pabbly Connect integration for Booktics orders via webhook.
+ */
+
+namespace BookticsModulePabbly;
+
+if ( ! defined( 'ABSPATH' ) ) exit;
+
+use BookticsContractsHookable_Service_Contract;
+use BookticsAbstractsBooktics_Database;
+use BookticsModelsGuest_Model;
+
+class Pabbly_Service implements Hookable_Service_Contract {
+ /**
+ * Register hooks
+ */
+ public function register() {
+ add_action( 'booktics_after_order_created', array( $this, 'send_to_pabbly' ), 10, 2 );
+ }
+
+ /**
+ * Send customer data to the configured Pabbly webhook.
+ *
+ * @param object $order_model The order model.
+ * @param array $appointments Created appointments (unused).
+ */
+ public function send_to_pabbly( $order_model, $appointments = array() ) {
+ $webhook_url = booktics_get_option( 'pabbly_webhook_url' );
+ if ( empty( $webhook_url ) ) {
+ return;
+ }
+
+ // Get customer details. customer_id is a Booktics guest record id, not a WP user id.
+ $customer = ( new Guest_Model( new Booktics_Database() ) )->find( array( 'id' => $order_model->customer_id ) );
+ if ( ! $customer || is_wp_error( $customer ) ) {
+ return;
+ }
+
+ $name_parts = preg_split( '/s+/', trim( (string) $customer->name ), 2 );
+
+ $customer_data = array(
+ 'email' => $customer->email,
+ 'first_name' => $name_parts[0] ?? '',
+ 'last_name' => $name_parts[1] ?? '',
+ 'status' => 'subscribed',
+ );
+
+ try {
+ $this->send_webhook( $webhook_url, $customer_data );
+ } catch ( Throwable $e ) {
+ // Ensures silent failure in case of any error.
+ if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
+ error_log( 'Pabbly Error: ' . $e->getMessage() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
+ }
+ }
+ }
+
+ private function send_webhook( $url, $data ) {
+ $response = wp_remote_post(
+ $url,
+ array(
+ 'body' => wp_json_encode( $data ),
+ 'headers' => array(
+ 'Content-Type' => 'application/json',
+ ),
+ 'timeout' => 15,
+ )
+ );
+
+ if ( is_wp_error( $response ) ) {
+ if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
+ error_log( 'Pabbly Webhook Error: ' . $response->get_error_message() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
+ }
+ }
+ }
+}
--- a/booktics/core/module/stripe-addon/service/stripe-payment-method.php
+++ b/booktics/core/module/stripe-addon/service/stripe-payment-method.php
@@ -151,6 +151,61 @@
}
/**
+ * Decide the reservation action for a stale unpaid order using Stripe's raw
+ * PaymentIntent lifecycle state.
+ *
+ * Unlike get_payment_status(), which collapses several distinct Stripe states
+ * into "processing", this reads the raw status so a customer who is mid-payment
+ * (e.g. on a bank 3D-Secure / OTP screen) is never canceled underneath them,
+ * even with a short reservation timeout.
+ *
+ * @param Order_Model $order The order whose held slot is being evaluated.
+ *
+ * @return string One of the RESERVATION_* constants.
+ */
+ public function resolve_reservation_action( $order ): string {
+ $this->init_stripe_sdk();
+
+ $payment_intent_id = $order->payment_intent_id ?? null;
+
+ if ( ! $payment_intent_id ) {
+ // No intent was ever created — nothing charged, safe to free the slot.
+ return self::RESERVATION_RELEASE;
+ }
+
+ try {
+ $intent = PaymentIntent::retrieve( $payment_intent_id );
+
+ switch ( $intent->status ) {
+ case 'succeeded':
+ // Money was captured; only the client-side confirmation was lost.
+ return self::RESERVATION_REPAIR;
+
+ case 'requires_payment_method':
+ case 'canceled':
+ // Customer never provided a working payment method or the intent
+ // was canceled. The booking is genuinely abandoned — release it.
+ return self::RESERVATION_RELEASE;
+
+ case 'processing':
+ case 'requires_action':
+ case 'requires_confirmation':
+ case 'requires_capture':
+ // Payment is genuinely still in progress (bank verification, async
+ // capture, etc.). Keep the slot and re-check on a later sweep.
+ return self::RESERVATION_WAIT;
+
+ default:
+ // Unknown/unexpected state — do not cancel on uncertainty.
+ return self::RESERVATION_WAIT;
+ }
+ } catch ( Exception $e ) {
+ // Transient API error: err on the safe side and keep the booking held.
+ return self::RESERVATION_WAIT;
+ }
+ }
+
+ /**
* Process a refund through Stripe.
*
* @param Order_Model $order The order to process refund for
--- a/booktics/core/module/zapier/zapier-service-provider.php
+++ b/booktics/core/module/zapier/zapier-service-provider.php
@@ -0,0 +1,31 @@
+<?php
+namespace BookticsModuleZapier;
+
+if ( ! defined( 'ABSPATH' ) ) exit;
+
+use BookticsProvidersBase_Service_Provider;
+
+/**
+ * Zapier_Service_Provider responsible for booting the Zapier integration service.
+ *
+ * @package Booktics/Module/Zapier
+ */
+class Zapier_Service_Provider extends Base_Service_Provider {
+ /**
+ * Store services
+ *
+ * @var array
+ */
+ protected $services = array(
+ Zapier_Service::class,
+ );
+
+ /**
+ * Register services
+ *
+ * @return void
+ */
+ public function get_services() {
+ return apply_filters( 'booktics_zapier_addon_admin_services', $this->services );
+ }
+}
--- a/booktics/core/module/zapier/zapier-service.php
+++ b/booktics/core/module/zapier/zapier-service.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Zapier Service
+ *
+ * Handles Zapier integration for Booktics orders via webhook.
+ */
+
+namespace BookticsModuleZapier;
+
+if ( ! defined( 'ABSPATH' ) ) exit;
+
+use BookticsContractsHookable_Service_Contract;
+use BookticsAbstractsBooktics_Database;
+use BookticsModelsGuest_Model;
+
+class Zapier_Service implements Hookable_Service_Contract {
+ /**
+ * Register hooks
+ */
+ public function register() {
+ add_action( 'booktics_after_order_created', array( $this, 'send_to_zapier' ), 10, 2 );
+ }
+
+ /**
+ * Send customer data to the configured Zapier webhook.
+ *
+ * @param object $order_model The order model.
+ * @param array $appointments Created appointments (unused).
+ */
+ public function send_to_zapier( $order_model, $appointments = array() ) {
+ $webhook_url = booktics_get_option( 'zapier_webhook_url' );
+ if ( empty( $webhook_url ) ) {
+ return;
+ }
+
+ // Get customer details. customer_id is a Booktics guest record id, not a WP user id.
+ $customer = ( new Guest_Model( new Booktics_Database() ) )->find( array( 'id' => $order_model->customer_id ) );
+ if ( ! $customer || is_wp_error( $customer ) ) {
+ return;
+ }
+
+ $name_parts = preg_split( '/s+/', trim( (string) $customer->name ), 2 );
+
+ $customer_data = array(
+ 'email' => $customer->email,
+ 'first_name' => $name_parts[0] ?? '',
+ 'last_name' => $name_parts[1] ?? '',
+ 'status' => 'subscribed',
+ );
+
+ try {
+ $this->send_webhook( $webhook_url, $customer_data );
+ } catch ( Throwable $e ) {
+ // Ensures silent failure in case of any error.
+ if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
+ error_log( 'Zapier Error: ' . $e->getMessage() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
+ }
+ }
+ }
+
+ private function send_webhook( $url, $data ) {
+ $response = wp_remote_post(
+ $url,
+ array(
+ 'body' => wp_json_encode( $data ),
+ 'headers' => array(
+ 'Content-Type' => 'application/json',
+ ),
+ 'timeout' => 15,
+ )
+ );
+
+ if ( is_wp_error( $response ) ) {
+ if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
+ error_log( 'Zapier Webhook Error: ' . $response->get_error_message() ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
+ }
+ }
+ }
+}
--- a/booktics/core/module/zoho/zoho-service-provider.php
+++ b/booktics/core/module/zoho/zoho-service-provider.php
@@ -0,0 +1,31 @@
+<?php
+namespace BookticsModuleZoho;
+
+if ( ! defined( 'ABSPATH' ) ) exit;
+
+use BookticsProvidersBase_Service_Provider;
+
+/**
+ * Zoho_Service_Provider responsible for booting the Zoho integration service.
+ *
+ * @package Booktics/Module/Zoho
+ */
+class Zoho_Service_Provider extends Base_Service_Provider {
+ /**
+ * Store services
+ *
+ * @var array
+ */
+ protected $services = array(
+ Zoho_Service::class,
+ );
+
+ /**
+ * Register services
+ *
+ * @return void
+ */
+ public function get_services() {
+ return apply_filters( 'booktics_zoho_addon_admin_services', $this->services );
+ }
+}
--- a/booktics/core/module/zoho/zoho-service.php
+++ b/booktics/core/module/zoho/zoho-service.php
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Zoho Service
+ *
+ * Handles Zoho integration for Booktics orders via webhook (Zoho Flow).
+ */
+
+namespace BookticsModuleZoho;
+
+if ( ! defined( 'ABSPATH' ) ) exit;
+
+use BookticsContractsHookable_Service_Contract;
+use BookticsAbstractsBooktics_Database;
+use BookticsModelsGuest_Model;
+
+class Zoho_Service