<?php

/**
 * Payment Successful Email
 *
 * Sent to customers when a renewal payment is completed successfully.
 *
 * @package ArraySubs\Features\Emails\Emails
 * @since 1.0.0
 */

namespace ArraySubs\Features\Emails\Emails;

defined('ABSPATH') || exit;

use ArraySubs\Features\Emails\Abstracts\BaseSubscriptionEmail;

/**
 * Payment Successful Email class
 */
class PaymentSuccessfulEmail extends BaseSubscriptionEmail
{
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->id             = 'arraysubs_payment_successful';
        $this->customer_email = true;
        $this->title          = __('[ArraySubs] Renewal Payment Successful', 'arraysubs');
        $this->description    = __('Payment successful emails are sent to customers when their renewal payment is completed.', 'arraysubs');

        $this->heading        = __('Payment received', 'arraysubs');
        $this->subject        = __('[{site_title}] Payment received for subscription #{subscription_id}', 'arraysubs');

        $this->template_html  = 'customer-payment-successful.php';
        $this->template_plain = 'plain/customer-payment-successful.php';

        // Add order placeholders with sample values for preview
        $this->placeholders['{order_id}'] = '67890';
        $this->placeholders['{order_total}'] = wc_price(29.99);
        $this->placeholders['{payment_method}'] = __('Credit Card', 'arraysubs');

        parent::__construct();
    }

    /**
     * Populate placeholders
     *
     * @param array $args Additional arguments
     */
    protected function populate_placeholders(array $args = []): void
    {
        parent::populate_placeholders($args);

        if ($this->order) {
            $this->placeholders['{order_id}'] = $this->order->get_id();
            $this->placeholders['{order_total}'] = $this->order->get_formatted_order_total();
            $this->placeholders['{payment_method}'] = $this->order->get_payment_method_title();
        }
    }

    /**
     * Get default additional content
     *
     * @return string
     */
    public function get_default_additional_content(): string
    {
        return __('Thank you for your continued subscription!', 'arraysubs');
    }
}
