<?php
/**
 * Records the request in the order's own history.
 *
 * @package SkyServers\Retragere
 */

declare(strict_types=1);

namespace SkyServers\Retragere\Wc;

/**
 * A private note, visible to the shop only. The order status is never touched:
 * that would fire invoicing and marketplace automations that are not ours.
 */
final class OrderNote
{
    public static function add(int $orderId, string $reference, string $type): void
    {
        $order = OrderLookup::byId($orderId);

        if (null === $order) {
            return;
        }

        $order->add_order_note(
            sprintf(
                /* translators: 1: reference code, 2: request type. */
                __('Contract withdrawal request recorded: %1$s (%2$s).', 'skyservers-retragere-contract'),
                $reference,
                $type
            )
        );
    }
}
