cart-empty.php
3 years ago
cart-item-data.php
5 years ago
cart-shipping.php
5 years ago
cart-totals.php
5 years ago
cart.php
3 years ago
cross-sells.php
5 years ago
mini-cart.php
5 years ago
proceed-to-checkout-button.php
3 years ago
shipping-calculator.php
3 years ago
cart-totals.php
113 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Cart totals |
| 4 | * |
| 5 | * This template can be overridden by copying it to yourtheme/woocommerce/cart/cart-totals.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.woocommerce.com/document/template-structure/ |
| 14 | * @package WooCommerce\Templates |
| 15 | * @version 2.3.6 |
| 16 | */ |
| 17 | |
| 18 | defined( 'ABSPATH' ) || exit; |
| 19 | |
| 20 | ?> |
| 21 | <div class="cart_totals <?php echo ( WC()->customer->has_calculated_shipping() ) ? 'calculated_shipping' : ''; ?>"> |
| 22 | |
| 23 | <?php do_action( 'woocommerce_before_cart_totals' ); ?> |
| 24 | |
| 25 | <h2><?php esc_html_e( 'Cart totals', 'woocommerce' ); ?></h2> |
| 26 | |
| 27 | <table cellspacing="0" class="shop_table shop_table_responsive"> |
| 28 | |
| 29 | <tr class="cart-subtotal"> |
| 30 | <th><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th> |
| 31 | <td data-title="<?php esc_attr_e( 'Subtotal', 'woocommerce' ); ?>"><?php wc_cart_totals_subtotal_html(); ?></td> |
| 32 | </tr> |
| 33 | |
| 34 | <?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?> |
| 35 | <tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>"> |
| 36 | <th><?php wc_cart_totals_coupon_label( $coupon ); ?></th> |
| 37 | <td data-title="<?php echo esc_attr( wc_cart_totals_coupon_label( $coupon, false ) ); ?>"><?php wc_cart_totals_coupon_html( $coupon ); ?></td> |
| 38 | </tr> |
| 39 | <?php endforeach; ?> |
| 40 | |
| 41 | <?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?> |
| 42 | |
| 43 | <?php do_action( 'woocommerce_cart_totals_before_shipping' ); ?> |
| 44 | |
| 45 | <?php wc_cart_totals_shipping_html(); ?> |
| 46 | |
| 47 | <?php do_action( 'woocommerce_cart_totals_after_shipping' ); ?> |
| 48 | |
| 49 | <?php elseif ( WC()->cart->needs_shipping() && 'yes' === get_option( 'woocommerce_enable_shipping_calc' ) ) : ?> |
| 50 | |
| 51 | <tr class="shipping"> |
| 52 | <th><?php esc_html_e( 'Shipping', 'woocommerce' ); ?></th> |
| 53 | <td data-title="<?php esc_attr_e( 'Shipping', 'woocommerce' ); ?>"><?php woocommerce_shipping_calculator(); ?></td> |
| 54 | </tr> |
| 55 | |
| 56 | <?php endif; ?> |
| 57 | |
| 58 | <?php foreach ( WC()->cart->get_fees() as $fee ) : ?> |
| 59 | <tr class="fee"> |
| 60 | <th><?php echo esc_html( $fee->name ); ?></th> |
| 61 | <td data-title="<?php echo esc_attr( $fee->name ); ?>"><?php wc_cart_totals_fee_html( $fee ); ?></td> |
| 62 | </tr> |
| 63 | <?php endforeach; ?> |
| 64 | |
| 65 | <?php |
| 66 | if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) { |
| 67 | $taxable_address = WC()->customer->get_taxable_address(); |
| 68 | $estimated_text = ''; |
| 69 | |
| 70 | if ( WC()->customer->is_customer_outside_base() && ! WC()->customer->has_calculated_shipping() ) { |
| 71 | /* translators: %s location. */ |
| 72 | $estimated_text = sprintf( ' <small>' . esc_html__( '(estimated for %s)', 'woocommerce' ) . '</small>', WC()->countries->estimated_for_prefix( $taxable_address[0] ) . WC()->countries->countries[ $taxable_address[0] ] ); |
| 73 | } |
| 74 | |
| 75 | if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) { |
| 76 | foreach ( WC()->cart->get_tax_totals() as $code => $tax ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 77 | ?> |
| 78 | <tr class="tax-rate tax-rate-<?php echo esc_attr( sanitize_title( $code ) ); ?>"> |
| 79 | <th><?php echo esc_html( $tax->label ) . $estimated_text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></th> |
| 80 | <td data-title="<?php echo esc_attr( $tax->label ); ?>"><?php echo wp_kses_post( $tax->formatted_amount ); ?></td> |
| 81 | </tr> |
| 82 | <?php |
| 83 | } |
| 84 | } else { |
| 85 | ?> |
| 86 | <tr class="tax-total"> |
| 87 | <th><?php echo esc_html( WC()->countries->tax_or_vat() ) . $estimated_text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></th> |
| 88 | <td data-title="<?php echo esc_attr( WC()->countries->tax_or_vat() ); ?>"><?php wc_cart_totals_taxes_total_html(); ?></td> |
| 89 | </tr> |
| 90 | <?php |
| 91 | } |
| 92 | } |
| 93 | ?> |
| 94 | |
| 95 | <?php do_action( 'woocommerce_cart_totals_before_order_total' ); ?> |
| 96 | |
| 97 | <tr class="order-total"> |
| 98 | <th><?php esc_html_e( 'Total', 'woocommerce' ); ?></th> |
| 99 | <td data-title="<?php esc_attr_e( 'Total', 'woocommerce' ); ?>"><?php wc_cart_totals_order_total_html(); ?></td> |
| 100 | </tr> |
| 101 | |
| 102 | <?php do_action( 'woocommerce_cart_totals_after_order_total' ); ?> |
| 103 | |
| 104 | </table> |
| 105 | |
| 106 | <div class="wc-proceed-to-checkout"> |
| 107 | <?php do_action( 'woocommerce_proceed_to_checkout' ); ?> |
| 108 | </div> |
| 109 | |
| 110 | <?php do_action( 'woocommerce_after_cart_totals' ); ?> |
| 111 | |
| 112 | </div> |
| 113 |