1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Review order table |
4
|
|
|
* |
5
|
|
|
* This template can be overridden by copying it to yourtheme/woocommerce/checkout/review-order.php. |
6
|
|
|
* |
7
|
|
|
* HOWEVER, on occasion WooCommerce will need to update template files and you |
8
|
|
|
* (the theme developer) will need to copy the new files to your theme to |
9
|
|
|
* maintain compatibility. We try to do this as little as possible, but it does |
10
|
|
|
* happen. When this occurs the version of the template file will be bumped and |
11
|
|
|
* the readme will list any important changes. |
12
|
|
|
* |
13
|
|
|
* @see https://docs.woothemes.com/document/template-structure/ |
14
|
|
|
* @author WooThemes |
15
|
|
|
* @package WooCommerce/Templates |
16
|
|
|
* @version 2.3.0 |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
if ( ! defined( 'ABSPATH' ) ) { |
20
|
|
|
exit; |
21
|
|
|
} |
22
|
|
|
?> |
23
|
|
|
<table class="shop_table woocommerce-checkout-review-order-table"> |
24
|
|
|
<thead> |
25
|
|
|
<tr> |
26
|
|
|
<th class="product-name"><?php _e( 'Product', 'woocommerce' ); ?></th> |
27
|
|
|
<th class="product-total"><?php _e( 'Total', 'woocommerce' ); ?></th> |
28
|
|
|
</tr> |
29
|
|
|
</thead> |
30
|
|
|
<tbody> |
31
|
|
|
<?php |
32
|
|
|
do_action( 'woocommerce_review_order_before_cart_contents' ); |
33
|
|
|
|
34
|
|
|
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { |
35
|
|
|
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); |
36
|
|
|
|
37
|
|
|
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) { |
38
|
|
|
?> |
39
|
|
|
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>"> |
40
|
|
|
<td class="product-name"> |
41
|
|
|
<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_title(), $cart_item, $cart_item_key ) . ' '; ?> |
42
|
|
|
<?php echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '× %s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key ); ?> |
43
|
|
|
<?php echo WC()->cart->get_item_data( $cart_item ); ?> |
44
|
|
|
</td> |
45
|
|
|
<td class="product-total"> |
46
|
|
|
<?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); ?> |
47
|
|
|
</td> |
48
|
|
|
</tr> |
49
|
|
|
<?php |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
do_action( 'woocommerce_review_order_after_cart_contents' ); |
54
|
|
|
?> |
55
|
|
|
</tbody> |
56
|
|
|
<tfoot> |
57
|
|
|
|
58
|
|
|
<tr class="cart-subtotal"> |
59
|
|
|
<th><?php _e( 'Subtotal', 'woocommerce' ); ?></th> |
60
|
|
|
<td><?php wc_cart_totals_subtotal_html(); ?></td> |
61
|
|
|
</tr> |
62
|
|
|
|
63
|
|
|
<?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?> |
64
|
|
|
<tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>"> |
65
|
|
|
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th> |
66
|
|
|
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td> |
67
|
|
|
</tr> |
68
|
|
|
<?php endforeach; ?> |
69
|
|
|
|
70
|
|
|
<?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?> |
71
|
|
|
|
72
|
|
|
<?php do_action( 'woocommerce_review_order_before_shipping' ); ?> |
73
|
|
|
|
74
|
|
|
<?php wc_cart_totals_shipping_html(); ?> |
75
|
|
|
|
76
|
|
|
<?php do_action( 'woocommerce_review_order_after_shipping' ); ?> |
77
|
|
|
|
78
|
|
|
<?php endif; ?> |
79
|
|
|
|
80
|
|
View Code Duplication |
<?php foreach ( WC()->cart->get_fees() as $fee ) : ?> |
|
|
|
|
81
|
|
|
<tr class="fee"> |
82
|
|
|
<th><?php echo esc_html( $fee->name ); ?></th> |
83
|
|
|
<td><?php wc_cart_totals_fee_html( $fee ); ?></td> |
84
|
|
|
</tr> |
85
|
|
|
<?php endforeach; ?> |
86
|
|
|
|
87
|
|
|
<?php if ( wc_tax_enabled() && 'excl' === WC()->cart->tax_display_cart ) : ?> |
88
|
|
|
<?php if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?> |
89
|
|
|
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : ?> |
90
|
|
|
<tr class="tax-rate tax-rate-<?php echo sanitize_title( $code ); ?>"> |
91
|
|
|
<th><?php echo esc_html( $tax->label ); ?></th> |
92
|
|
|
<td><?php echo wp_kses_post( $tax->formatted_amount ); ?></td> |
93
|
|
|
</tr> |
94
|
|
|
<?php endforeach; ?> |
95
|
|
|
<?php else : ?> |
96
|
|
|
<tr class="tax-total"> |
97
|
|
|
<th><?php echo esc_html( WC()->countries->tax_or_vat() ); ?></th> |
98
|
|
|
<td><?php wc_cart_totals_taxes_total_html(); ?></td> |
99
|
|
|
</tr> |
100
|
|
|
<?php endif; ?> |
101
|
|
|
<?php endif; ?> |
102
|
|
|
|
103
|
|
|
<?php do_action( 'woocommerce_review_order_before_order_total' ); ?> |
104
|
|
|
|
105
|
|
|
<tr class="order-total"> |
106
|
|
|
<th><?php _e( 'Total', 'woocommerce' ); ?></th> |
107
|
|
|
<td><?php wc_cart_totals_order_total_html(); ?></td> |
108
|
|
|
</tr> |
109
|
|
|
|
110
|
|
|
<?php do_action( 'woocommerce_review_order_after_order_total' ); ?> |
111
|
|
|
|
112
|
|
|
</tfoot> |
113
|
|
|
</table> |
114
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.