<?php
namespace PayCal\Modules\Bit;

defined('ABSPATH') || exit;

class BitOrderStatus {
  public static function init(): void {
    add_action('init', [__CLASS__, 'register_status']);
    add_filter('wc_order_statuses', [__CLASS__, 'add_to_list']);
  }

  public static function register_status(): void {
    register_post_status('wc-paycal-bit-pending', [
      'label'                     => 'ממתין לתשלום בביט',
      'public'                    => true,
      'exclude_from_search'       => false,
      'show_in_admin_all_list'    => true,
      'show_in_admin_status_list' => true,
      /* translators: %s: number of Bit-pending orders. */
      'label_count'               => _n_noop('ממתין לתשלום בביט <span class="count">(%s)</span>', 'ממתין לתשלום בביט <span class="count">(%s)</span>', 'klamra-paycal-for-aspaclaria')
    ]);
  }

  public static function add_to_list($statuses) {
    $new = [];
    foreach ($statuses as $k => $v) {
      $new[$k] = $v;
      if ($k === 'wc-pending') {
        $new['wc-paycal-bit-pending'] = 'ממתין לתשלום בביט';
      }
    }
    return $new;
  }
}
