<?php
/**
 * PW Rewards Checkout Rewards Member
 *
 * Shows the rewards program information on the checkout page.
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/checkout/checkout-rewards-member.php.
 *
 * HOWEVER, on occasion Pimwick will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see https://woocommerce.com/document/template-structure/
 */

defined( 'ABSPATH' ) or exit;

do_action( 'pwlpar_before_checkout_rewards_member' );

$current_balance = pwlpar_current_user_point_balance();
$earned_points = pwlpar_calculate_earned_cart_points();
$new_balance = $current_balance + $earned_points;

?>
<tr class="pwlpar-checkout-order-total order-total">
    <th class="pwlpar-checkout-heading"><?php echo esc_html( pwlpar_program_name() ); ?></th>
    <td>
        <div class="pwlpar-checkout-paragraph">
            <?php
                /* translators: %s is the points earned for the order */
                printf( esc_html__( 'You will earn %s points with this order.', 'pw-loyalty-points-and-rewards-for-woocommerce' ), '<strong>' . esc_html( pwlpar_format_points( $earned_points ) ) . '</strong>' );
            ?>
        </div>
        <div class="pwlpar-checkout-paragraph">
            <?php
                /* translators: %s is the new point balance */
                printf( esc_html__( 'Your new balance will be %s points.', 'pw-loyalty-points-and-rewards-for-woocommerce' ), '<strong>' . esc_html( pwlpar_format_points( $new_balance ) ) . '</strong>' );
            ?>
        </div>
    </td>
</tr>
<?php

do_action( 'pwlpar_after_checkout_rewards_member' );
