Keine Beschreibung

cart-totals.php 4.4KB

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