<?php

/**
 * Customer payment successful email
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-payment-successful.php.
 *
 * @package ArraySubs\Features\Emails\templates
 * @version 1.0.0
 */

defined('ABSPATH') || exit;

// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WooCommerce core hook
do_action('woocommerce_email_header', $arraysubs_email_heading, $arraysubs_email);
?>

<p>
<?php
    printf(
        /* translators: %s: Customer first name */
        esc_html__('Hi %s,', 'arraysubs'),
        esc_html($arraysubs_customer['first_name'] ?: __('there', 'arraysubs'))
    );
    ?>
    </p>

<p>
<?php
    printf(
        /* translators: %s: subscription ID */
        esc_html__('We have received your payment for subscription #%s. Your subscription has been renewed.', 'arraysubs'),
        esc_html($arraysubs_subscription_id)
    );
    ?>
    </p>

<h2>
<?php
    printf(
        /* translators: %s: Subscription ID */
        esc_html__('Subscription #%s', 'arraysubs'),
        esc_html($arraysubs_subscription_id)
    );
    ?>
    </h2>

<table class="td" cellspacing="0" cellpadding="6" style="width: 100%; margin-bottom: 40px;" border="1">
    <tbody>
        <tr>
            <th class="td" scope="row" style="text-align: left;"><?php esc_html_e('Product', 'arraysubs'); ?></th>
            <td class="td" style="text-align: left;">
                <?php
                $arraysubs_product_name = arraysubs_get_subscription_product_name_by_subscription($arraysubs_subscription_id);
                echo esc_html($arraysubs_product_name ?: __('N/A', 'arraysubs'));
                ?>
            </td>
        </tr>
        <?php if ($arraysubs_order) : ?>
            <tr>
                <th class="td" scope="row" style="text-align: left;"><?php esc_html_e('Amount Paid', 'arraysubs'); ?></th>
                <td class="td" style="text-align: left;">
                    <?php echo wp_kses_post($arraysubs_order->get_formatted_order_total()); ?>
                </td>
            </tr>
            <tr>
                <th class="td" scope="row" style="text-align: left;"><?php esc_html_e('Payment Method', 'arraysubs'); ?></th>
                <td class="td" style="text-align: left;">
                    <?php echo esc_html($arraysubs_order->get_payment_method_title()); ?>
                </td>
            </tr>
        <?php endif; ?>
        <tr>
            <th class="td" scope="row" style="text-align: left;"><?php esc_html_e('Next Payment Date', 'arraysubs'); ?></th>
            <td class="td" style="text-align: left;">
                <?php
                $arraysubs_next_payment = get_post_meta($arraysubs_subscription_id, '_next_payment_date', true);
                echo esc_html(arraysubs_format_date_local($arraysubs_next_payment));
                ?>
            </td>
        </tr>
    </tbody>
</table>

<p>
    <a class="link" href="<?php echo esc_url(wc_get_account_endpoint_url('subscriptions')); ?>">
        <?php esc_html_e('View your subscription', 'arraysubs'); ?>
    </a>
</p>

<?php
if ($arraysubs_additional_content) {
    echo wp_kses_post(wpautop(wptexturize($arraysubs_additional_content)));
}

// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WooCommerce core hook
do_action('woocommerce_email_footer', $arraysubs_email);
