review-order.php 12.1 KB
<?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 	    http://docs.woothemes.com/document/template-structure/
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     2.3.0
 */
if (!defined('ABSPATH')) {
    exit;
}
?>
<table id="tvitemorder" class="shop_table woocommerce-checkout-review-order-table">
    <colgroup class="desktop">
        <col width="35%">
        <col width="40%">
        <col width="25%">
    </colgroup>
    <thead class="tvhide">
        <tr>
            <th class="product-name"><?php _e('Product', 'woocommerce'); ?></th>
            <th class="product-total"><?php _e('Total', 'woocommerce'); ?></th>
        </tr>
    </thead>
    <tbody>
        <?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);
            if ($_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters('woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key)) {
                ?>
                <tr class="mobile">
                    <td colspan="3">
                        <?php echo apply_filters('woocommerce_in_cart_product_thumbnail', $_product->get_image(), $values, $cart_item_key); ?>
                    </td>
                </tr>
                <tr class="<?php echo esc_attr(apply_filters('woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key)); ?>">
                    <td class="product-iamge font18 desktop">
                        <?php echo apply_filters('woocommerce_in_cart_product_thumbnail', $_product->get_image(), $values, $cart_item_key); ?>
                    </td>
                    <td class="product-name font18">
                        <?php
                        $_title = '';
                        if ($cart_item['data']->product_type == 'subscription_variation') {
                            $_title = get_post_meta($cart_item['variation_id'], 'attribute_drinks')[0];
                            $number_drink = $_title;
                            if (strpos($_title, 'drinks') == False) {
                                $_title .= ' Drinks';
                            }
                        } else {
                            $_title = $_product->get_title();
                        }
                        ?>
                        <dl><dt><strong><?php echo $_title; ?></strong></dt></dl>
                        <?php // echo apply_filters('woocommerce_cart_item_name', $_title, $cart_item, $cart_item_key) . '&nbsp;'; ?>
                        <?php // echo apply_filters('woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf('&times; %s', $cart_item['quantity']) . '</strong>', $cart_item, $cart_item_key); ?>
                        <?php // echo WC()->cart->get_item_data($cart_item); ?>
                        <?php
                        $product_type = $_product->get_type();
                        if ($product_type == 'subscription_variation') {
                            echo '<div class="delivered_monthly">Delivered Monthly</div>';
                            ?>
                            <style>
                                #order_reviews .shop_table {
                                    padding-bottom: 60px;
                                }
                                @media(min-width:745px) and (max-width: 830px){
                                    #order_reviews .shop_table {
                                        padding-bottom: 80px;
                                    }
                                    #order_reviews table tbody td, #order_reviews table tbody th{
                                        font-size: 16px;
                                    }
                                }
                            </style>
                            <?php
                        }
                        ?>
                    </td>
                    <td class="product-total font18 robotobold  text-right">
                        <?php echo apply_filters('woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal($_product, $cart_item['quantity']), $cart_item, $cart_item_key); ?>
                    </td>
                </tr>
                <?php
            }
        }

        do_action('woocommerce_review_order_after_cart_contents');
        ?>
    </tbody>
    <tfoot>

        <tr class="cart-subtotal tvhide">
            <th>&nbsp;</th>
            <th class="text-uppercase"><?php _e('Subtotal', 'woocommerce'); ?></th>
            <td class="font18 text-right"><?php wc_cart_totals_subtotal_html(); ?></td>
        </tr>

        <?php foreach (WC()->cart->get_coupons() as $code => $coupon) : ?>
            <?php if ($product_type == 'subscription_variation') {
                ?>
                <tr class="cart-before-discount">
                    <th>Total per month:</th>
                    <td><span class="amount"></span></td>
                </tr>
            <?php } ?>
            <tr class="cart-discount coupon-<?php echo esc_attr(sanitize_title($code)); ?>">
                <?php
                if (!session_id())
                    @session_start();
                $session_coupon_code = isset($_SESSION['data_coupon']['coupon_code']) ? $_SESSION['data_coupon']['coupon_code'] : '';
                ?>
                <th>Gift Card: <?php echo (in_array($code, array('firstreferee', 'firstreferee407', 'firstreferee408', 'firstreferee409')) || $code == strtolower($session_coupon_code)) ? '' : $code; ?></th>
                <td><?php wc_cart_totals_coupon_html($coupon); ?></td>
            </tr>
        <?php endforeach; ?>

        <?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) : ?>
            <tr class="fee">
                <th><?php echo esc_html($fee->name); ?></th>
                <td><?php wc_cart_totals_fee_html($fee); ?></td>
            </tr>
        <?php endforeach; ?>

        <?php if (wc_tax_enabled() && 'excl' === WC()->cart->tax_display_cart) : ?>
            <?php if ('itemized' === get_option('woocommerce_tax_total_display')) : ?>
                <?php foreach (WC()->cart->get_tax_totals() as $code => $tax) : ?>
                    <tr class="tax-rate tax-rate-<?php echo sanitize_title($code); ?>">
                        <th><?php echo esc_html($tax->label); ?></th>
                        <td><?php echo wp_kses_post($tax->formatted_amount); ?></td>
                    </tr>
                <?php endforeach; ?>
            <?php else : ?>
                <tr class="tax-total">
                    <th><?php echo esc_html(WC()->countries->tax_or_vat()); ?></th>
                    <td><?php wc_cart_totals_taxes_total_html(); ?></td>
                </tr>
            <?php endif; ?>
        <?php endif; ?>

        <?php do_action('woocommerce_review_order_before_order_total'); ?>

        <tr class="order-total tvhide font18">
            <td class="desktop carthide">&nbsp;</td>
            <th class="text-uppercase">
                <?php
                if ($product_type == 'subscription_variation') {
                    _e('Total per month', 'woocommerce');
                } else {
                    _e('Total', 'woocommerce');
                }
                ?></th>
            <td class=" text-right"><?php wc_cart_totals_order_total_html(); ?></td>
        </tr>

        <?php do_action('woocommerce_review_order_after_order_total'); ?>

    </tfoot>
</table>
<script>
    jQuery(document).ready(function ($) {
        if (jQuery('#content').css('opacity') === '0') {
            jQuery('#content').css('opacity', '1');
        }
        if (jQuery(window).width() > 744) {
            bottom = jQuery('#order_reviews tfoot').outerHeight();
            jQuery('#tvitemorder').css('margin-bottom', bottom + 'px');
            jQuery('#order_reviews tfoot').css('bottom', '-' + bottom + 'px');
        }
        $total = getAmount('.product-total .amount');
        $discount = getAmount('.cart-discount  .amount');
        if ($('.shipping-upgrade').length > 0) {
            $shippingwc = getAmount('.shipping-upgrade .amount');
        } else {
            $shippingwc = getAmount('.shippingwc .amount');
        }
        if ($('.order-total .amount').length > 0) {
            if ($('.cart-before-discount').length > 0) {
                $('.cart-before-discount .amount').html('$' + ($total + $shippingwc).toFixed(2));
                $('.order-total th').html('First Month Payment:');
            }
            $('.order-total .amount').html('$' + ($total - $discount + $shippingwc).toFixed(2));
        }
        $('.amount').each(function () {
            current_amount = $(this).html();
            if (current_amount.indexOf('AUD') === -1 && current_amount.indexOf('$') !== -1) {
                $(this).html($(this).html() + ' AUD');
            }
        });
<?php
$shipping__country = $_POST['s_country'];

if (isset($shipping__country) && $shipping__country != '' && $shipping__country != 'AUD') {
    ?>
            //            if ($('.link_term_different_currency').length === 0) {
            //                $('input[name="woocommerce_checkout_place_order"]').closest('div').append('<br/><span class="link_term_different_currency">If you are paying in a different currency from AUD, <a href="#">Click Here</a> to read our Terms and Conditions</span>');
            //            }
            //            else {
            //                $('input[name="woocommerce_checkout_place_order"]').closest('div').find('.link_term_different_currency').remove();
            //                $('input[name="woocommerce_checkout_place_order"]').closest('div').find('br').remove();
            //            }

<?php } ?>
//        $('#term_different_currency_popup').appendTo('body');
//        $('.link_term_different_currency a').click(function (e) {
//            e.preventDefault();
//            $('#term_different_currency_popup').fadeIn();
//            $('.blur').fadeIn();
//        });
//        $('.blur').click(function (e) {
//            if ($('#term_different_currency_popup').css('display') !== 'none') {
//                $('#term_different_currency_popup').fadeOut();
//                $('.blur').fadeOut();
//            }
//        });
//        Change words if coupon is applied.
        if ($('.cart-discount').length > 0) {
            $('.add_gift_card').html('Gift Card? Code already applied.');
        }
    });
    function getAmount(element_class) {
        if (jQuery(element_class).length > 0) {
            return parseFloat(jQuery(element_class).html().replace('$', '').replace('AUD', ''));
        } else {
            return 0;
        }
    }

    jQuery(document).ready(function ($) {
        screenWidth = $(window).width();
        if ($('.woocommerce-checkout').length > 0) {
            if (screenWidth < 746) {
                $('#tvitemorder .order-total').removeClass('tvhide');
                $('#tvitemorder .shipping').removeClass('tvhide');
            }
        }
    });

    (function ($) {
        var $window = $(window),
                $order_total = $('#tvitemorder .order-total');

        function resize() {
            if ($window.width() < 746) {
                return $order_total.removeClass('tvhide');
            }
        }

        $window
                .resize(resize)
                .trigger('resize');
    })(jQuery);
</script>