cart-totals.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. * @author WooThemes
  15. * @package WooCommerce/Templates
  16. * @version 2.3.6
  17. */
  18. if ( ! defined( 'ABSPATH' ) ) {
  19. exit;
  20. }
  21. ?>
  22. <div class="cart_totals <?php echo ( WC()->customer->has_calculated_shipping() ) ? 'calculated_shipping' : ''; ?>">
  23. <?php do_action( 'woocommerce_before_cart_totals' ); ?>
  24. <h2><?php _e( 'Cart totals', 'woocommerce' ); ?></h2>
  25. <table cellspacing="0" class="shop_table shop_table_responsive">
  26. <tr class="cart-subtotal">
  27. <th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
  28. <td data-title="<?php esc_attr_e( 'Subtotal', 'woocommerce' ); ?>"><?php wc_cart_totals_subtotal_html(); ?></td>
  29. </tr>
  30. <?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
  31. <tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
  32. <th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
  33. <td data-title="<?php echo esc_attr( wc_cart_totals_coupon_label( $coupon, false ) ); ?>"><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
  34. </tr>
  35. <?php endforeach; ?>
  36. <?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>
  37. <?php do_action( 'woocommerce_cart_totals_before_shipping' ); ?>
  38. <?php wc_cart_totals_shipping_html(); ?>
  39. <?php do_action( 'woocommerce_cart_totals_after_shipping' ); ?>
  40. <?php elseif ( WC()->cart->needs_shipping() && 'yes' === get_option( 'woocommerce_enable_shipping_calc' ) ) : ?>
  41. <tr class="shipping">
  42. <th><?php _e( 'Shipping', 'woocommerce' ); ?></th>
  43. <td data-title="<?php esc_attr_e( 'Shipping', 'woocommerce' ); ?>"><?php woocommerce_shipping_calculator(); ?></td>
  44. </tr>
  45. <?php endif; ?>
  46. <?php foreach ( WC()->cart->get_fees() as $fee ) : ?>
  47. <tr class="fee">
  48. <th><?php echo esc_html( $fee->name ); ?></th>
  49. <td data-title="<?php echo esc_attr( $fee->name ); ?>"><?php wc_cart_totals_fee_html( $fee ); ?></td>
  50. </tr>
  51. <?php endforeach; ?>
  52. <?php if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) :
  53. $taxable_address = WC()->customer->get_taxable_address();
  54. $estimated_text = WC()->customer->is_customer_outside_base() && ! WC()->customer->has_calculated_shipping()
  55. ? sprintf( ' <small>' . __( '(estimated for %s)', 'woocommerce' ) . '</small>', WC()->countries->estimated_for_prefix( $taxable_address[0] ) . WC()->countries->countries[ $taxable_address[0] ] )
  56. : '';
  57. if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
  58. <?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : ?>
  59. <tr class="tax-rate tax-rate-<?php echo sanitize_title( $code ); ?>">
  60. <th><?php echo esc_html( $tax->label ) . $estimated_text; ?></th>
  61. <td data-title="<?php echo esc_attr( $tax->label ); ?>"><?php echo wp_kses_post( $tax->formatted_amount ); ?></td>
  62. </tr>
  63. <?php endforeach; ?>
  64. <?php else : ?>
  65. <tr class="tax-total">
  66. <th><?php echo esc_html( WC()->countries->tax_or_vat() ) . $estimated_text; ?></th>
  67. <td data-title="<?php echo esc_attr( WC()->countries->tax_or_vat() ); ?>"><?php wc_cart_totals_taxes_total_html(); ?></td>
  68. </tr>
  69. <?php endif; ?>
  70. <?php endif; ?>
  71. <?php do_action( 'woocommerce_cart_totals_before_order_total' ); ?>
  72. <tr class="order-total">
  73. <th><?php _e( 'Total', 'woocommerce' ); ?></th>
  74. <td data-title="<?php esc_attr_e( 'Total', 'woocommerce' ); ?>"><?php wc_cart_totals_order_total_html(); ?></td>
  75. </tr>
  76. <?php do_action( 'woocommerce_cart_totals_after_order_total' ); ?>
  77. </table>
  78. <div class="wc-proceed-to-checkout">
  79. <?php do_action( 'woocommerce_proceed_to_checkout' ); ?>
  80. </div>
  81. <?php do_action( 'woocommerce_after_cart_totals' ); ?>
  82. </div>