PageRenderTime 47ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/templates/checkout/review-order.php

https://github.com/CammoKing/woocommerce
PHP | 272 lines | 209 code | 53 blank | 10 comment | 40 complexity | afa5bf8130083e23d18eb2b3bb380f8f 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-quantity"><?php _e( 'Qty', 'woocommerce' ); ?></th>
  19. <th class="product-total"><?php _e( 'Totals', 'woocommerce' ); ?></th>
  20. </tr>
  21. </thead>
  22. <tfoot>
  23. <tr class="cart-subtotal">
  24. <th colspan="2"><strong><?php _e( 'Cart Subtotal', 'woocommerce' ); ?></strong></th>
  25. <td><?php echo $woocommerce->cart->get_cart_subtotal(); ?></td>
  26. </tr>
  27. <?php if ($woocommerce->cart->get_discounts_before_tax()) : ?>
  28. <tr class="discount">
  29. <th colspan="2"><?php _e( 'Cart Discount', 'woocommerce' ); ?></th>
  30. <td>-<?php echo $woocommerce->cart->get_discounts_before_tax(); ?></td>
  31. </tr>
  32. <?php endif; ?>
  33. <?php if ( $woocommerce->cart->needs_shipping() && $woocommerce->cart->show_shipping() ) : ?>
  34. <?php do_action('woocommerce_review_order_before_shipping'); ?>
  35. <tr class="shipping">
  36. <th colspan="2"><?php _e( 'Shipping', 'woocommerce' ); ?></th>
  37. <td><?php woocommerce_get_template( 'cart/shipping-methods.php', array( 'available_methods' => $available_methods ) ); ?></td>
  38. </tr>
  39. <?php do_action('woocommerce_review_order_after_shipping'); ?>
  40. <?php endif; ?>
  41. <?php foreach ( $woocommerce->cart->get_fees() as $fee ) : ?>
  42. <tr class="fee fee-<?php echo $fee->id ?>">
  43. <th colspan="2"><?php echo $fee->name ?></th>
  44. <td><?php
  45. if ( $woocommerce->cart->display_totals_ex_tax || ! $woocommerce->cart->prices_include_tax )
  46. echo woocommerce_price( $fee->amount );
  47. else
  48. echo woocommerce_price( $fee->amount + $fee->tax );
  49. ?></td>
  50. </tr>
  51. <?php endforeach; ?>
  52. <?php
  53. // Show the tax row if showing prices exlcusive of tax only
  54. if ( $woocommerce->cart->display_totals_ex_tax || ! $woocommerce->cart->prices_include_tax ) {
  55. if ( $woocommerce->cart->get_cart_tax() ) {
  56. $taxes = $woocommerce->cart->get_formatted_taxes();
  57. if ( sizeof( $taxes ) > 0 ) {
  58. $has_compound_tax = false;
  59. foreach ( $taxes as $key => $tax ) {
  60. if ( $woocommerce->cart->tax->is_compound( $key ) ) {
  61. $has_compound_tax = true;
  62. continue;
  63. }
  64. ?>
  65. <tr class="tax-rate tax-rate-<?php echo $key; ?>">
  66. <th colspan="2"><?php echo $woocommerce->cart->tax->get_rate_label( $key ); ?></th>
  67. <td><?php echo $tax; ?></td>
  68. </tr>
  69. <?php
  70. }
  71. if ( $has_compound_tax ) {
  72. ?>
  73. <tr class="order-subtotal">
  74. <th colspan="2"><strong><?php _e( 'Subtotal', 'woocommerce' ); ?></strong></th>
  75. <td><strong><?php echo $woocommerce->cart->get_cart_subtotal( true ); ?></strong></td>
  76. </tr>
  77. <?php
  78. }
  79. foreach ( $taxes as $key => $tax ) {
  80. if ( ! $woocommerce->cart->tax->is_compound( $key ) )
  81. continue;
  82. ?>
  83. <tr class="tax-rate tax-rate-<?php echo $key; ?>">
  84. <th colspan="2"><?php echo $woocommerce->cart->tax->get_rate_label( $key ); ?></th>
  85. <td><?php echo $tax; ?></td>
  86. </tr>
  87. <?php
  88. }
  89. } else {
  90. ?>
  91. <tr class="tax">
  92. <th colspan="2" colspan="2"><?php _e( 'Tax', 'woocommerce' ); ?></th>
  93. <td><?php echo $woocommerce->cart->get_cart_tax(); ?></td>
  94. </tr>
  95. <?php
  96. }
  97. } elseif ( get_option( 'woocommerce_display_cart_taxes_if_zero' ) == 'yes' ) {
  98. ?>
  99. <tr class="tax">
  100. <th colspan="2"><?php _e( 'Tax', 'woocommerce' ); ?></th>
  101. <td><?php _ex( 'N/A', 'Relating to tax', 'woocommerce' ); ?></td>
  102. </tr>
  103. <?php
  104. }
  105. }
  106. ?>
  107. <?php if ($woocommerce->cart->get_discounts_after_tax()) : ?>
  108. <tr class="discount">
  109. <th colspan="2"><?php _e( 'Order Discount', 'woocommerce' ); ?></th>
  110. <td>-<?php echo $woocommerce->cart->get_discounts_after_tax(); ?></td>
  111. </tr>
  112. <?php endif; ?>
  113. <?php do_action('woocommerce_before_order_total'); ?>
  114. <tr class="total">
  115. <th colspan="2"><strong><?php _e( 'Order Total', 'woocommerce' ); ?></strong></th>
  116. <td>
  117. <strong><?php echo $woocommerce->cart->get_total(); ?></strong>
  118. <?php
  119. // If prices are tax inclusive, show taxes here
  120. if ( ! $woocommerce->cart->display_totals_ex_tax && $woocommerce->cart->prices_include_tax ) {
  121. if ( $woocommerce->cart->get_cart_tax() ) {
  122. $tax_string_array = array();
  123. $taxes = $woocommerce->cart->get_formatted_taxes();
  124. if ( sizeof( $taxes ) > 0 ) {
  125. foreach ( $taxes as $key => $tax ) {
  126. $tax_string_array[] = sprintf( '%s %s', $tax, $woocommerce->cart->tax->get_rate_label( $key ) );
  127. }
  128. } else {
  129. $tax_string_array[] = sprintf( '%s tax', $tax );
  130. }
  131. if ( ! empty( $tax_string_array ) ) {
  132. ?><small class="includes_tax"><?php printf( __( '(Includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) ); ?></small><?php
  133. }
  134. } elseif ( get_option( 'woocommerce_display_cart_taxes_if_zero' ) == 'yes' ) {
  135. ?><small class="includes_tax"><?php printf( __( '(Includes %s tax)', 'woocommerce' ), woocommerce_price( 0 ) ); ?></small><?php
  136. }
  137. }
  138. ?>
  139. </td>
  140. </tr>
  141. <?php do_action('woocommerce_after_order_total'); ?>
  142. </tfoot>
  143. <tbody>
  144. <?php
  145. if (sizeof($woocommerce->cart->get_cart())>0) :
  146. foreach ($woocommerce->cart->get_cart() as $item_id => $values) :
  147. $_product = $values['data'];
  148. if ($_product->exists() && $values['quantity']>0) :
  149. echo '
  150. <tr class = "' . esc_attr( apply_filters('woocommerce_checkout_table_item_class', 'checkout_table_item', $values, $item_id ) ) . '">
  151. <td class="product-name">'.$_product->get_title().$woocommerce->cart->get_item_data( $values ).'</td>
  152. <td class="product-quantity">'.$values['quantity'].'</td>
  153. <td class="product-total">' . apply_filters( 'woocommerce_checkout_item_subtotal', $woocommerce->cart->get_product_subtotal( $_product, $values['quantity'] ), $values, $item_id ) . '</td>
  154. </tr>';
  155. endif;
  156. endforeach;
  157. endif;
  158. do_action( 'woocommerce_cart_contents_review_order' );
  159. ?>
  160. </tbody>
  161. </table>
  162. <div id="payment">
  163. <?php if ($woocommerce->cart->needs_payment()) : ?>
  164. <ul class="payment_methods methods">
  165. <?php
  166. $available_gateways = $woocommerce->payment_gateways->get_available_payment_gateways();
  167. if ($available_gateways) :
  168. // Chosen Method
  169. if (sizeof($available_gateways)) :
  170. $default_gateway = get_option('woocommerce_default_gateway');
  171. if ( isset( $woocommerce->session->chosen_payment_method ) && isset( $available_gateways[ $woocommerce->session->chosen_payment_method ] ) ) {
  172. $available_gateways[ $woocommerce->session->chosen_payment_method ]->set_current();
  173. } elseif ( isset( $available_gateways[ $default_gateway ] ) ) {
  174. $available_gateways[ $default_gateway ]->set_current();
  175. } else {
  176. current( $available_gateways )->set_current();
  177. }
  178. endif;
  179. foreach ($available_gateways as $gateway ) :
  180. ?>
  181. <li>
  182. <input type="radio" id="payment_method_<?php echo $gateway->id; ?>" class="input-radio" name="payment_method" value="<?php echo esc_attr( $gateway->id ); ?>" <?php if ($gateway->chosen) echo 'checked="checked"'; ?> />
  183. <label for="payment_method_<?php echo $gateway->id; ?>"><?php echo $gateway->get_title(); ?> <?php echo $gateway->get_icon(); ?></label>
  184. <?php
  185. if ( $gateway->has_fields() || $gateway->get_description() ) :
  186. echo '<div class="payment_box payment_method_' . $gateway->id . '" style="display:none;">';
  187. $gateway->payment_fields();
  188. echo '</div>';
  189. endif;
  190. ?>
  191. </li>
  192. <?php
  193. endforeach;
  194. else :
  195. if ( !$woocommerce->customer->get_country() ) :
  196. echo '<p>'.__( 'Please fill in your details above to see available payment methods.', 'woocommerce' ).'</p>';
  197. else :
  198. 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>';
  199. endif;
  200. endif;
  201. ?>
  202. </ul>
  203. <?php endif; ?>
  204. <div class="form-row place-order">
  205. <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>
  206. <?php $woocommerce->nonce_field('process_checkout')?>
  207. <?php do_action( 'woocommerce_review_order_before_submit' ); ?>
  208. <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' )); ?>" />
  209. <?php if (woocommerce_get_page_id('terms')>0) : ?>
  210. <p class="form-row terms">
  211. <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>
  212. <input type="checkbox" class="input-checkbox" name="terms" <?php if (isset($_POST['terms'])) echo 'checked="checked"'; ?> id="terms" />
  213. </p>
  214. <?php endif; ?>
  215. <?php do_action( 'woocommerce_review_order_after_submit' ); ?>
  216. </div>
  217. <div class="clear"></div>
  218. </div>
  219. </div>