<?php

namespace CouponsPlus\App\Conditions\Stubs\Conditions;

use CouponsPlus\Original\Collections\Collection;
use CouponsPlus\App\Coupon\Abilities\DashboardCardData;

class NewCustomer implements DashboardCardData
{
    const TYPE = 'NewCustomer';

    static public function getName() : string
    {
        return __('New Customer', 'coupons-plus-for-woocommerce');
    }

    static public function getDescription() : string
    {
        return __('Will check if the customer has placed orders in the past. This may include orders that were cancelled or refunded depending on the strictness level selected. Useful for applying offers to new customers. May be used in combination with the New Account condition', 'coupons-plus-for-woocommerce');
    }

    static public function getUseCases(): Collection
    {
        return new Collection([
            __('Apply an offer on a customer\'s first order.', 'coupons-plus-for-woocommerce'),
        ]);
    }

    static public function getNotes() : array
    {
        (array) $allStatuses = wc_get_order_statuses();
        (array) $successfulStatuses = [];

        foreach (wc_get_is_paid_statuses() as $status) {
            (string) $statusKey = 'wc-' . $status;
            $successfulStatuses[] = isset($allStatuses[$statusKey]) ? $allStatuses[$statusKey] : $status;
        }

        return [
            sprintf(
                 /* translators: placeholder is a list of orders */
                __('For non-guests, only orders with these statuses are considered when checking their order history: %s', 'coupons-plus-for-woocommerce'),
                implode(', ', $successfulStatuses)
            )
        ];
    }
}
