<?php
/**
 * فروشگاه — component partial: recent WooCommerce orders.
 */
if (!defined('ABSPATH')) {
    exit;
}

$wc_ok = class_exists('WooCommerce') && function_exists('wc_get_orders');
?>
<?php zerti_ui_component_open('shop'); ?>
    <?php if (!$wc_ok) : ?>
        <?php zerti_ui_wc_required_notice(__('WooCommerce must be installed and active to view orders.', 'zerti')); ?>
    <?php else : ?>
        <div class="zerti-shop-orders-panel">
            <div class="zerti-shop-orders-wrap">
                <?php
                zerti_ui_toolbar_open(
                    __('Filter and export orders list', 'zerti'),
                    'zerti-shop-grid-toolbar'
                );
                if (function_exists('zerti_user_can_create_shop_order') && zerti_user_can_create_shop_order()) {
                    $new_order_btn_class = 'zerti-shop-order-new-btn';
                    zerti_ui_toolbar_section_open('zerti-shop-orders-toolbar-start');
                    zerti_ui_button([
                        'class' => $new_order_btn_class,
                        'icon' => 'fa-solid fa-plus',
                        'label' => __('New order', 'zerti'),
                        'title' => __('Create a new order', 'zerti'),
                    ]);
                    zerti_ui_toolbar_section_close();
                }
                do_action('zerti_shop_orders_toolbar_export');
                zerti_ui_toolbar_close();
                zerti_ui_ag_grid_region(
                    'zertiShopOrdersGrid',
                    'zerti-shop-orders-grid',
                    __('Orders table', 'zerti')
                );
                ?>
            </div>
        </div>
    <?php endif; ?>
<?php zerti_ui_component_close(); ?>
