<?php
/**
 * filtersAjax.php
 *
 * @author     alfiopiccione <alfio.piccione@gmail.com>

 * @license    http://opensource.org/licenses/gpl-2.0.php GPL v2
 *
 * Copyright (C) 2025 POP
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

if (! defined('ABSPATH')) {
    exit; // Exit if accessed directly.
}

//
//  array(
//      'filter'        => '',
//      'callback'      => '',
//      'priority'      => '',
//      'accepted_args' => '',
//  )
//
return apply_filters('wfc_ms-filters_ajax', array(
    'ajax' => array(
        'action' => array(
            /**
             * Action get products
             */
            array(
                'filter'   => array(
                    'wp_ajax_updateProductsList',
                ),
                'callback' => function () {
                    \WooPoPToFattureInCloudStock\Functions\updateProductsList(false, 1);
                },
                'priority' => 10,
            ),

            /**
             * Sync of the stock with that of FIC
             */
            array(
                'filter'        => 'wfc-create_invoice',
                'callback'      => function ($issuedDocumentInv, $body) {
                    \WooPoPToFattureInCloudStock\Functions\updateProductStock($issuedDocumentInv, $body);
                },
                'priority'      => 10,
                'accepted_args' => 2,
            ),
        ),
        'filter' => array(),
    ),
));
