' . print_r($restaurant, true) . ''; // widget_id is optional (?rrbooknow=1&widget_id=2). Only accept a widget of this restaurant. $widget_id = isset($_GET['widget_id']) ? intval($_GET['widget_id']) : 0; $widget = $widget_id ? \Alexr\Settings\WidgetForm::find($widget_id) : null; if ($widget && intval($widget->restaurant_id) !== intval($restaurant->id)) { $widget = null; } if (!$widget) { $widget = \Alexr\Settings\WidgetForm::where( 'restaurant_id', $restaurant->id )->first(); } if (!$widget) { echo 'Widget not found.'; return; } alexr_limit_hooks_to_one(); ?>
where('restaurant_id', $restaurant->id) ->first(); if ($customer) { $ar_customer_data = [ 'first_name' => $customer->first_name ?? '', 'last_name' => $customer->last_name ?? '', 'email' => $customer->email ?? '', 'phone' => $customer->phone ?? '', 'dial_code' => $customer->dial_code ?? '', 'dial_code_country' => $customer->dial_code_country ?? '', 'country_code' => $customer->country_code ?? '', 'birthday' => $customer->birthday ?? '', ]; } } // Priority 2: From missed call — search customer by caller phone, or extract phone parts if (empty($ar_customer_data) && $missed_call_id) { $log = \Alexr\Models\MissedCallLog::find($missed_call_id); if ($log && $log->restaurant_id == $restaurant->id) { $callerPhone = $log->caller_phone; // Try to find existing customer by phone $customer = \Alexr\Models\Customer::findByPhone($restaurant->id, $callerPhone); if ($customer) { $ar_customer_data = [ 'first_name' => $customer->first_name ?? '', 'last_name' => $customer->last_name ?? '', 'email' => $customer->email ?? '', 'phone' => $customer->phone ?? '', 'dial_code' => $customer->dial_code ?? '', 'dial_code_country' => $customer->dial_code_country ?? '', 'country_code' => $customer->country_code ?? '', 'birthday' => $customer->birthday ?? '', ]; } else { // New phone — extract dial_code and phone from full number $phoneParts = alexr_extract_dial_code_and_phone($callerPhone); if ($phoneParts) { $ar_customer_data = [ 'phone' => $phoneParts['phone'], 'dial_code' => $phoneParts['dial_code'], 'dial_code_country' => $phoneParts['dial_code_country'], ]; } } } } ?> id."' embed='yes' hide_button='yes']"); ?>