HEX
Server: nginx/1.27.1
System: Linux in-4 5.15.0-131-generic #141-Ubuntu SMP Fri Jan 10 21:18:28 UTC 2025 x86_64
User: ilikadirect (1186)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source
Upload Files
File: /storage/v6964/ilikadirect/public_html/wp-content/plugins/wc-pre-order/includes/Admin/Widget.php
<?php

namespace SpringDevs\PreOrder\Admin;

/**
 * Extend Woocommerce Widgets
 *
 * Class Widget
 * @package SpringDevs\PreOrder\Admin
 */
class Widget
{
    public function __construct()
    {
        add_action('woocommerce_after_dashboard_status_widget', [$this, "dashboard_status_widget"]);
    }

    public function dashboard_status_widget($reports)
    {
        $confirmed_items = $this->get_confirmed_items(0);
        $pending_items = $this->get_pending_items(0);
        include 'views/widget.php';
    }

    public function get_confirmed_items($default)
    {
        $args = array(
            'post_type'   => 'sdevs_preorder'
        );
        $preorders = get_posts($args);
        foreach ($preorders as $preorder) {
            $order_id = get_post_meta($preorder->ID, "_order_id", true);
            $order = wc_get_order($order_id);
            if (!$order->has_status("processing")) $default++;
        }
        return $default;
    }

    public function get_pending_items($default)
    {
        $args = array(
            'post_type'   => 'sdevs_preorder'
        );
        $preorders = get_posts($args);
        foreach ($preorders as $preorder) {
            $order_id = get_post_meta($preorder->ID, "_order_id", true);
            $order = wc_get_order($order_id);
            if ($order->has_status("processing")) $default++;
        }
        return $default;
    }
}