| Server IP : 13.126.101.145 / Your IP : 216.73.217.84 Web Server : Apache/2.4.52 (Ubuntu) System : Linux ip-11-115-0-196 6.8.0-1039-aws #41~22.04.1-Ubuntu SMP Thu Sep 11 10:54:48 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 8.3.17 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/rentals_updated/wp-content/plugins/woo-preview-emails/includes/ |
Upload File : |
<?php
namespace Codemanas\WooPreviewEmails;
/**
* Class AjaxHandler
*
* The AjaxHandler class is responsible for handling AJAX requests in WordPress.
*/
class AjaxHandler {
private static $_instance = null;
public static function get_instance() {
return ( self::$_instance == null ) ? self::$_instance = new self() : self::$_instance;
}
private function __construct() {
add_action( 'wp_ajax_woo_preview_orders_search', [ $this, 'get_orders' ] );
}
public function get_orders() {
if ( ! current_user_can( 'manage_woocommerce' ) ) {
return false;
}
$q = sanitize_text_field( filter_input( INPUT_POST, 'query' ) );
$response = [];
$order = wc_get_order($q);
if($order){
$response[] = ['value' => $order->get_id(), 'label' => '#Order: '.$order->get_order_number()];
}
wp_send_json( $response );
wp_die();
}
}