'success' => false, 'message' => 'Please enter a valid business email address.' ), 400 ); } $result = ia_submit_zoho_profile_update($profile); if (empty($result['success'])) { return new WP_REST_Response( array( 'success' => false, 'message' => isset($result['message']) ? $result['message'] : 'Unable to update exporter profile.' ), 502 ); } return new WP_REST_Response( array( 'success' => true, 'status' => 'profile_updated', 'message' => 'Exporter profile submitted successfully.', 'iec' => $profile['iec'] ), 200 ); } /** * Register the exporter profile REST endpoint. */ function ia_register_exporter_profile_rest_route() { register_rest_route( 'ia/v1', '/profile', array( 'methods' => WP_REST_Server::CREATABLE, 'callback' => 'ia_exporter_profile_rest_callback', 'permission_callback' => '__return_true' ) ); } add_action('rest_api_init', 'ia_register_exporter_profile_rest_route'); /** * Read a Contact Form 7 posted field safely. */ function ia_cf7_exporter_profile_field($submission, $field_name) { if (!$submission || !is_object($submission)) { return ''; } $value = $submission->get_posted_data($field_name); if (is_array($value)) { $value = implode(', ', $value); } return trim((string) $value); } /** * Server-side CF7 -> Zoho sync for the live Indian Exporter Enquiry form. * This is independent of browser AJAX/DOM events. */ function ia_cf7_exporter_profile_sync($contact_form, &$abort, $submission) { if ( !is_object($contact_form) || !method_exists($contact_form, 'title') || $contact_form->title() !== 'Indian Exporter Enquiry' ) { return; } if (!$submission || !is_object($submission)) { return; } $get = function ($name) use ($submission) { return ia_cf7_exporter_profile_field($submission, $name); }; $profile = array( 'iec' => ia_normalize_iec_code($get('iec-code')), 'prior_notice_number' => sanitize_text_field($get('prior-notice-number')), 'full_name' => sanitize_text_field($get('full-name')), 'company_name' => sanitize_text_field($get('company-name')), 'email' => sanitize_email($get('business-email')), 'phone' => sanitize_text_field($get('phone')), 'city' => sanitize_text_field($get('city')), 'state' => sanitize_text_field($get('state')), 'company_website' => esc_url_raw($get('website')), 'business_type' => sanitize_text_field($get('business-type')), 'product_category' => sanitize_text_field($get('product-category')), 'main_products' => sanitize_textarea_field($get('main-products')), 'export_experience' => sanitize_text_field($get('export-experience')), 'countries_exported_to' => sanitize_textarea_field($get('export-countries')), 'monthly_supply_capacity' => sanitize_text_field($get('supply-capacity')), 'minimum_order_quantity' => sanitize_text_field($get('minimum-order')), 'private_label_capability' => sanitize_text_field($get('private-label')), 'catalogue_link' => esc_url_raw($get('catalogue-url')), 'certifications' => sanitize_textarea_field($get('certifications')), 'additional_information' => sanitize_textarea_field($get('additional-information')) ); if ($profile['iec'] === '') { return; } ia_submit_zoho_profile_update($profile); } add_action( 'wpcf7_before_send_mail', 'ia_cf7_exporter_profile_sync', 10, 3 ); https://usimportsprocurement.com/page-sitemap.xml 2026-10-10T12:51:06+00:00