<?php
/**
 * Review order table
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/checkout/review-order.php.
 *
 * HOWEVER, on occasion WooCommerce 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://docs.woocommerce.com/document/template-structure/
 * @package WooCommerce\Templates
 * @version 5.2.0
 */

defined( 'ABSPATH' ) || exit;
// Initialize flags
$has_non_donation = false;

// Loop through the cart items to check for donation and non-donation products.
foreach ( WC()->cart->get_cart() as $cart_item ) {
	$product_id = $cart_item['product_id'];
}
	
?>


<div class="custom-review-table">
    <h3 class="cs_fs_24 cs_medium cs_secondary_font mb-0"><?php esc_html_e( 'ORDER SUMMARY', 'glowify-wp' ); ?></h3>
    <div class="cs_height_8 cs_height_lg_8"></div>
    
    <ul class="cs_mp_0 cs_order_summary">
        <?php
        do_action( 'woocommerce_review_order_before_cart_contents' );

        foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
            $_product   = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
            $product_id = $cart_item['product_id'];

            if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) :
                ?>
                <li>
                    <div class="cs_order_summary_list_title">
                        <h3 class="mb-0 cs_secondary_font cs_semibold cs_fs_16">
                            <?php echo wp_kses_post( $_product->get_name() ); ?>
                        </h3>
                        <h3 class="mb-0 cs_secondary_font cs_semibold cs_fs_16 cs_accent_color">
                            <?php echo wc_price( $_product->get_price() ); ?>
                        </h3>
                    </div>
                    <?php echo wc_get_formatted_cart_item_data( $cart_item ); ?>
                    <p><?php esc_html_e( 'Quantity:', 'glowify-wp' ); ?> <?php echo esc_html( $cart_item['quantity'] ); ?></p>
                </li>
                <?php
            endif;
        }

        do_action( 'woocommerce_review_order_after_cart_contents' );
        ?>
    </ul>

    <div class="cs_height_40 cs_height_lg_30"></div>

    <ul class="cs_card_price_list cs_type_1 cs_mp_0">
        <li>
            <span class="cs_light"><?php esc_html_e( 'Subtotal', 'glowify-wp' ); ?></span>
            <span class="cs_semibold cs_primary_color cs_semibold"><?php wc_cart_totals_subtotal_html(); ?></span>
        </li>

        <?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>
            <?php do_action( 'woocommerce_review_order_before_shipping' ); ?>
            <?php wc_cart_totals_shipping_html(); ?>
            <?php do_action( 'woocommerce_review_order_after_shipping' ); ?>
        <?php endif; ?>

        <?php foreach ( WC()->cart->get_fees() as $fee ) : ?>
            <li>
                <span class="cs_light"><?php echo esc_html( $fee->name ); ?></span>
                <span class="cs_semibold cs_primary_color cs_semibold"><?php wc_cart_totals_fee_html( $fee ); ?></span>
            </li>
        <?php endforeach; ?>

        <?php if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) : ?>
            <?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : ?>
                <li>
                    <span class="cs_light"><?php echo esc_html( $tax->label ); ?></span>
                    <span class="cs_semibold cs_primary_color cs_semibold"><?php echo wp_kses_post( $tax->formatted_amount ); ?></span>
                </li>
            <?php endforeach; ?>
        <?php endif; ?>

        <li class="cs_total_price">
            <span class="cs_fs_18 cs_primary_color"><?php esc_html_e( 'Total', 'glowify-wp' ); ?></span>
            <span class="cs_fs_18 cs_primary_color"><?php wc_cart_totals_order_total_html(); ?></span>
        </li>
    </ul>

    <div class="cs_height_50 cs_height_lg_40"></div>
</div>

