Uname: Linux premium294.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
Software: LiteSpeed
PHP version: 8.1.32 [ PHP INFO ] PHP os: Linux
Server Ip: 104.21.48.1
Your Ip: 216.73.216.223
User: mjbynoyq (1574) | Group: mjbynoyq (1570)
Safe Mode: OFF
Disable Function:
NONE

name : Ajax.php
<?php

namespace WeDevs\Dokan\Order;

// don't call the file directly
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/**
 * Class Ajax
 *
 * @since 3.10.3
 *
 * @package WeDevs\Dokan\Order
 */
class Ajax {
    /**
     * Class constructor
     *
     * @since 3.10.3
     *
     * @return void
     */
    public function __construct() {
        add_action( 'wp_ajax_dokan_search_downloadable_products', [ $this, 'search_downloadable_products' ] );
    }

    /**
     * Search downloadable products
     *
     * @since 3.10.3
     *
     * @return void
     */
    public function search_downloadable_products() {
        check_ajax_referer( 'search-downloadable-products', '_nonce' );

        $limit = absint( apply_filters( 'woocommerce_json_search_limit', 30 ) );
        if ( ! empty( $_GET['limit'] ) ) {
            $limit = absint( $_GET['limit'] );
        }

        $page = 1;
        if ( ! empty( $_GET['page'] ) ) {
            $page = absint( $_GET['page'] );
        }

        $term = isset( $_GET['q'] ) ? (string) wc_clean( wp_unslash( $_GET['q'] ) ) : '';
        $args = [
            'status'       => 'publish',
            'downloadable' => true,
            'author'       => dokan_get_current_user_id(),
            'page'         => $page,
            'limit'        => $limit,
        ];

        if ( is_numeric( $term ) ) {
            $args['include'] = (array) $term;
        } else {
            $args['s'] = $term;
        }

        $product_objects = wc_get_products( $args );

        $products = array();
        foreach ( $product_objects as $product_object ) {
            $products[ $product_object->get_id() ] = rawurldecode( wp_strip_all_tags( $product_object->get_formatted_name() ) );
        }

        wp_send_json( $products );
    }
}
© 2025 XylotrechusZ