سیستم نوبتدهی آنلاین برای کسبوکارهای ایرانی
هوکها (Actions & Filters) — مستندات پرونوبت
مستندات مرجع هوکها و فیلترها هوکها (Actions & Filters)
هوکها (Actions & Filters)
امضای پارامترها در این صفحه دقیقاً با کد افزونه مطابقت دارد. به تعداد و ترتیب آرگومانها در add_action/add_filter دقت کنید.
Actions
pronobat_appointment_created
هنگام ثبت یک نوبت جدید فراخوانی میشود. آرگومان دوم (آرایهی نوبت) در نوبتهای فرزندِ سری تکرارشونده ممکن است ارسال نشود.
add_action ( 'pronobat_appointment_created' , function ( int $id, array $appointment ) {
error_log ( "نوبت جدید: #{ $id }" );
}, 10 , 2 );
pronobat_appointment_status_changed
هنگام تغییر وضعیت نوبت فراخوانی میشود. ترتیب: ابتدا وضعیت قبلی، سپس وضعیت جدید.
پرونوبت را همین الان امتحان کنید یک نمونه کامل و زنده از افزونه با دادههای واقعی — بدون نیاز به نصب.
add_action ( 'pronobat_appointment_status_changed' , function (
int $id, string $old_status, string $new_status
) {
// ...
}, 10 , 3 );
pronobat_appointment_confirmedاکشن مشتقشده که هنگام تغییر وضعیت به confirmed فراخوانی میشود. فقط شناسهی نوبت را میگیرد.
add_action ( 'pronobat_appointment_confirmed' , function ( int $id ) {
// ارسال اعلان سفارشی هنگام تأیید نوبت
}, 10 , 1 );
pronobat_appointment_cancelledهنگام لغو نوبت. آرگومان سوم نشان میدهد آیا درخواست استرداد همراه لغو بوده است. (در فرزندان سری تکرارشونده فقط $id ارسال میشود.)
add_action ( 'pronobat_appointment_cancelled' , function ( int $id, array $appointment, bool $refund ) {
// ...
}, 10 , 3 );
pronobat_appointment_rescheduledهنگام جابهجایی زمان نوبت توسط مدیر، با (int $id, array $appointment) فراخوانی میشود.
add_action ( 'pronobat_appointment_rescheduled' , function ( int $id, array $appointment ) {
// ...
}, 10 , 2 ); در مسیر عمومی (جابهجایی توسط مشتری با توکن)، این اکشن با امضای (int $old_id, int $new_id) فراخوانی میشود.
pronobat_payment_receivedپس از تأیید موفق پرداخت توسط درگاه. چهار آرگومان دارد:
add_action ( 'pronobat_payment_received' , function (
int $payment_id, int $appointment_id, int $amount_toman, string $gateway
) {
// ...
}, 10 , 4 );
pronobat_payment_refundedپس از استرداد وجه. آرگومان سوم پاسخ خام درگاه است.
add_action ( 'pronobat_payment_refunded' , function (
int $payment_id, int $amount_toman, array $raw
) {
// ...
}, 10 , 3 );
pronobat_settings_updatedهنگام ذخیرهی هر بخش از تنظیمات (یا 'all' هنگام import).
add_action ( 'pronobat_settings_updated' , function (
string $section, array $old_settings, array $new_settings
) {
if ( $section === 'payments' ) { /* ... */ }
}, 10 , 3 );
pronobat_customer_anonymizedپس از ناشناسسازی یک مشتری.
add_action ( 'pronobat_customer_anonymized' , function ( int $customer_id ) {
// ...
}, 10 , 1 );
pronobat_broadcast_notificationهنگام ارسال پیام گروهی از صفحهی اعلانها.
add_action ( 'pronobat_broadcast_notification' , function (
string $channel, string $message, int $service_id, int $staff_id
) {
// ...
}, 10 , 4 );
pronobat_sms_before_send_actionدقیقاً پیش از ارسال پیامک (فقط اطلاعرسانی؛ برای جلوگیری از ارسال از فیلتر pronobat_sms_before_send استفاده کنید).
add_action ( 'pronobat_sms_before_send_action' , function (
string $phone, string $message, string $event
) {
// ...
}, 10 , 3 );
Filters
pronobat_available_slotsلیست بازههای خالی را پیش از ارسال به کلاینت فیلتر میکند. هر بازه آرایهای به شکل { start, end, capacity_remaining, is_holiday } است (مقادیر start/end بهصورت 'HH:MM').
add_filter ( 'pronobat_available_slots' , function (
array $slots, int $staff_id, string $date, int $service_id
) {
// حذف بازهی ۱۲:۰۰
return array_values ( array_filter ( $slots, fn ( $s ) => $s[ 'start' ] !== '12:00' ) );
}, 10 , 4 );
pronobat_payment_gatewaysنقشهی درگاههای پرداخت را تغییر میدهد. مقدار هر کلید باید یک نمونه (instance) از PaymentGatewayInterface باشد (افزونه با instanceof بررسی میکند).
add_filter ( 'pronobat_payment_gateways' , function ( array $gateways ) {
$gateways[ 'my_gateway' ] = new MyCustomGateway ();
return $gateways;
} );
pronobat_appointment_priceمبلغ نهایی پرداخت (به تومان ) را پیش از ایجاد تراکنش تغییر میدهد.
add_filter ( 'pronobat_appointment_price' , function ( int $amount_toman, int $appointment_id ) {
return ( int ) round ( $amount_toman * 0.8 ); // ۲۰٪ تخفیف
}, 10 , 2 );
pronobat_sms_messageمتن پیامک را قبل از ارسال تغییر میدهد. آرگومان سوم شناسهی نوبت است.
add_filter ( 'pronobat_sms_message' , function ( string $message, string $event, int $appointment_id ) {
return $message . " \n\n با تشکر از اعتماد شما" ;
}, 10 , 3 );
pronobat_sms_before_sendتعیین میکند پیامک ارسال شود یا نه. آرگومان چهارم نام رویداد است. برای لغو ارسال، false برگردانید.
add_filter ( 'pronobat_sms_before_send' , function (
bool $should_send, string $phone, string $message, string $event
) {
$hour = ( int ) current_time ( 'H' );
if ( $hour >= 23 || $hour < 7 ) return false ; // بدون ارسال شبانه
return $should_send;
}, 10 , 4 ); pronobat_refund_manual یک هوک نیست؛ بلکه کد خطایی (پاسخ HTTP 422) است که هنگام درخواست استرداد برای درگاههای بدون پشتیبانی استرداد خودکار (مانند نکستپی) بازگردانده میشود. برای واکنش به استرداد موفق از اکشن pronobat_payment_refunded استفاده کنید.