/templates/cart/cart-totals.php

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