review-order.php
12.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
<?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) . ' '; ?>
<?php // echo apply_filters('woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf('× %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> </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"> </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>