PageRenderTime 49ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/templates/checkout/review-order.php

https://github.com/alexcsandru/woocommerce
PHP | 251 lines | 191 code | 50 blank | 10 comment | 30 complexity | e16819205ab8f012f1d3d6d19c14babf MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. /**
  3. * Review order form
  4. *
  5. * @author WooThemes
  6. * @package WooCommerce/Templates
  7. * @version 1.6.4
  8. */
  9. if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  10. global $woocommerce;
  11. $available_methods = $woocommerce->shipping->get_available_shipping_methods();
  12. ?>
  13. <div id="order_review">
  14. <table class="shop_table">
  15. <thead>
  16. <tr>
  17. <th class="product-name"><?php _e( 'Product', 'woocommerce' ); ?></th>
  18. <th class="product-total"><?php _e( 'Total', 'woocommerce' ); ?></th>
  19. </tr>
  20. </thead>
  21. <tfoot>
  22. <tr class="cart-subtotal">
  23. <th><?php _e( 'Cart Subtotal', 'woocommerce' ); ?></th>
  24. <td><?php echo $woocommerce->cart->get_cart_subtotal(); ?></td>
  25. </tr>
  26. <?php if ( $woocommerce->cart->get_discounts_before_tax() ) : ?>
  27. <tr class="discount">
  28. <th><?php _e( 'Cart Discount', 'woocommerce' ); ?></th>
  29. <td>-<?php echo $woocommerce->cart->get_discounts_before_tax(); ?></td>
  30. </tr>
  31. <?php endif; ?>
  32. <?php if ( $woocommerce->cart->needs_shipping() && $woocommerce->cart->show_shipping() ) : ?>
  33. <?php do_action('woocommerce_review_order_before_shipping'); ?>
  34. <tr class="shipping">
  35. <th><?php _e( 'Shipping', 'woocommerce' ); ?></th>
  36. <td><?php woocommerce_get_template( 'cart/shipping-methods.php', array( 'available_methods' => $available_methods ) ); ?></td>
  37. </tr>
  38. <?php do_action('woocommerce_review_order_after_shipping'); ?>
  39. <?php endif; ?>
  40. <?php foreach ( $woocommerce->cart->get_fees() as $fee ) : ?>
  41. <tr class="fee fee-<?php echo $fee->id ?>">
  42. <th><?php echo $fee->name ?></th>
  43. <td><?php
  44. if ( $woocommerce->cart->tax_display_cart == 'excl' )
  45. echo woocommerce_price( $fee->amount );
  46. else
  47. echo woocommerce_price( $fee->amount + $fee->tax );
  48. ?></td>
  49. </tr>
  50. <?php endforeach; ?>
  51. <?php
  52. // Show the tax row if showing prices exlcusive of tax only
  53. if ( $woocommerce->cart->tax_display_cart == 'excl' ) {
  54. $taxes = $woocommerce->cart->get_formatted_taxes();
  55. if ( sizeof( $taxes ) > 0 ) {
  56. $has_compound_tax = false;
  57. foreach ( $taxes as $key => $tax ) {
  58. if ( $woocommerce->cart->tax->is_compound( $key ) ) {
  59. $has_compound_tax = true;
  60. continue;
  61. }
  62. ?>
  63. <tr class="tax-rate tax-rate-<?php echo $key; ?>">
  64. <th><?php echo $woocommerce->cart->tax->get_rate_label( $key ); ?></th>
  65. <td><?php echo $tax; ?></td>
  66. </tr>
  67. <?php
  68. }
  69. if ( $has_compound_tax ) {
  70. ?>
  71. <tr class="order-subtotal">
  72. <th><?php _e( 'Subtotal', 'woocommerce' ); ?></th>
  73. <td><?php echo $woocommerce->cart->get_cart_subtotal( true ); ?></td>
  74. </tr>
  75. <?php
  76. }
  77. foreach ( $taxes as $key => $tax ) {
  78. if ( ! $woocommerce->cart->tax->is_compound( $key ) )
  79. continue;
  80. ?>
  81. <tr class="tax-rate tax-rate-<?php echo $key; ?>">
  82. <th><?php echo $woocommerce->cart->tax->get_rate_label( $key ); ?></th>
  83. <td><?php echo $tax; ?></td>
  84. </tr>
  85. <?php
  86. }
  87. } elseif ( $woocommerce->cart->get_cart_tax() ) {
  88. ?>
  89. <tr class="tax">
  90. <th><?php _e( 'Tax', 'woocommerce' ); ?></th>
  91. <td><?php echo $woocommerce->cart->get_cart_tax(); ?></td>
  92. </tr>
  93. <?php
  94. }
  95. }
  96. ?>
  97. <?php if ($woocommerce->cart->get_discounts_after_tax()) : ?>
  98. <tr class="discount">
  99. <th><?php _e( 'Order Discount', 'woocommerce' ); ?></th>
  100. <td>-<?php echo $woocommerce->cart->get_discounts_after_tax(); ?></td>
  101. </tr>
  102. <?php endif; ?>
  103. <?php do_action( 'woocommerce_review_order_before_order_total' ); ?>
  104. <tr class="total">
  105. <th><strong><?php _e( 'Order Total', 'woocommerce' ); ?></strong></th>
  106. <td>
  107. <strong><?php echo $woocommerce->cart->get_total(); ?></strong>
  108. <?php
  109. // If prices are tax inclusive, show taxes here
  110. if ( $woocommerce->cart->tax_display_cart == 'incl' ) {
  111. $tax_string_array = array();
  112. $taxes = $woocommerce->cart->get_formatted_taxes();
  113. if ( sizeof( $taxes ) > 0 ) {
  114. foreach ( $taxes as $key => $tax ) {
  115. $tax_string_array[] = sprintf( '%s %s', $tax, $woocommerce->cart->tax->get_rate_label( $key ) );
  116. }
  117. } elseif ( $woocommerce->cart->get_cart_tax() ) {
  118. $tax_string_array[] = sprintf( '%s tax', $tax );
  119. }
  120. if ( ! empty( $tax_string_array ) ) {
  121. ?><small class="includes_tax"><?php printf( __( '(Includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) ); ?></small><?php
  122. }
  123. }
  124. ?>
  125. </td>
  126. </tr>
  127. <?php do_action( 'woocommerce_review_order_after_order_total' ); ?>
  128. </tfoot>
  129. <tbody>
  130. <?php
  131. do_action( 'woocommerce_review_order_before_cart_contents' );
  132. if (sizeof($woocommerce->cart->get_cart())>0) :
  133. foreach ($woocommerce->cart->get_cart() as $item_id => $values) :
  134. $_product = $values['data'];
  135. if ($_product->exists() && $values['quantity']>0) :
  136. echo '
  137. <tr class="' . esc_attr( apply_filters('woocommerce_checkout_table_item_class', 'checkout_table_item', $values, $item_id ) ) . '">
  138. <td class="product-name">' . $_product->get_title().$woocommerce->cart->get_item_data( $values ) . ' <strong class="product-quantity">&times; ' . $values['quantity'] . '</strong></td>
  139. <td class="product-total">' . apply_filters( 'woocommerce_checkout_item_subtotal', $woocommerce->cart->get_product_subtotal( $_product, $values['quantity'] ), $values, $item_id ) . '</td>
  140. </tr>';
  141. endif;
  142. endforeach;
  143. endif;
  144. do_action( 'woocommerce_review_order_after_cart_contents' );
  145. ?>
  146. </tbody>
  147. </table>
  148. <div id="payment">
  149. <?php if ($woocommerce->cart->needs_payment()) : ?>
  150. <ul class="payment_methods methods">
  151. <?php
  152. $available_gateways = $woocommerce->payment_gateways->get_available_payment_gateways();
  153. if ( ! empty( $available_gateways ) ) {
  154. // Chosen Method
  155. if ( isset( $woocommerce->session->chosen_payment_method ) && isset( $available_gateways[ $woocommerce->session->chosen_payment_method ] ) ) {
  156. $available_gateways[ $woocommerce->session->chosen_payment_method ]->set_current();
  157. } elseif ( isset( $available_gateways[ get_option( 'woocommerce_default_gateway' ) ] ) ) {
  158. $available_gateways[ get_option( 'woocommerce_default_gateway' ) ]->set_current();
  159. } else {
  160. current( $available_gateways )->set_current();
  161. }
  162. foreach ( $available_gateways as $gateway ) {
  163. ?>
  164. <li>
  165. <input type="radio" id="payment_method_<?php echo $gateway->id; ?>" class="input-radio" name="payment_method" value="<?php echo esc_attr( $gateway->id ); ?>" <?php checked( $gateway->chosen, true ); ?> />
  166. <label for="payment_method_<?php echo $gateway->id; ?>"><?php echo $gateway->get_title(); ?> <?php echo $gateway->get_icon(); ?></label>
  167. <?php
  168. if ( $gateway->has_fields() || $gateway->get_description() ) :
  169. echo '<div class="payment_box payment_method_' . $gateway->id . '" ' . ( $gateway->chosen ? '' : 'style="display:none;"' ) . '>';
  170. $gateway->payment_fields();
  171. echo '</div>';
  172. endif;
  173. ?>
  174. </li>
  175. <?php
  176. }
  177. } else {
  178. if ( ! $woocommerce->customer->get_country() )
  179. echo '<p>' . __( 'Please fill in your details above to see available payment methods.', 'woocommerce' ) . '</p>';
  180. else
  181. echo '<p>' . __( 'Sorry, it seems that there are no available payment methods for your state. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce' ) . '</p>';
  182. }
  183. ?>
  184. </ul>
  185. <?php endif; ?>
  186. <div class="form-row place-order">
  187. <noscript><?php _e( 'Since your browser does not support JavaScript, or it is disabled, please ensure you click the <em>Update Totals</em> button before placing your order. You may be charged more than the amount stated above if you fail to do so.', 'woocommerce' ); ?><br/><input type="submit" class="button alt" name="woocommerce_checkout_update_totals" value="<?php _e( 'Update totals', 'woocommerce' ); ?>" /></noscript>
  188. <?php $woocommerce->nonce_field('process_checkout')?>
  189. <?php do_action( 'woocommerce_review_order_before_submit' ); ?>
  190. <input type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="<?php echo apply_filters('woocommerce_order_button_text', __( 'Place order', 'woocommerce' )); ?>" />
  191. <?php if (woocommerce_get_page_id('terms')>0) : ?>
  192. <p class="form-row terms">
  193. <label for="terms" class="checkbox"><?php _e( 'I have read and accept the', 'woocommerce' ); ?> <a href="<?php echo esc_url( get_permalink(woocommerce_get_page_id('terms')) ); ?>" target="_blank"><?php _e( 'terms &amp; conditions', 'woocommerce' ); ?></a></label>
  194. <input type="checkbox" class="input-checkbox" name="terms" <?php checked( isset( $_POST['terms'] ), true ); ?> id="terms" />
  195. </p>
  196. <?php endif; ?>
  197. <?php do_action( 'woocommerce_review_order_after_submit' ); ?>
  198. </div>
  199. <div class="clear"></div>
  200. </div>
  201. </div>