snave07

form-checkout.php

Oct 13th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.44 KB | None | 0 0
  1. <?php
  2. /**
  3. * Checkout Form
  4. *
  5. * This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-checkout.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 3.5.0
  16. */
  17.  
  18. if ( ! defined( 'ABSPATH' ) ) {
  19. exit;
  20. }
  21.  
  22. $thegem_checkout_type = thegem_get_option('checkout_type', 'multi-step');
  23.  
  24. wc_print_notices();
  25.  
  26. // If checkout registration is disabled and not logged in, the user cannot checkout.
  27. if ( ! $checkout->is_registration_enabled() && $checkout->is_registration_required() && ! is_user_logged_in() ) {
  28. echo esc_html( apply_filters( 'woocommerce_checkout_must_be_logged_in_message', __( 'You must be logged in to checkout.', 'woocommerce' ) ) );
  29. return;
  30. }
  31.  
  32.  
  33. wp_enqueue_script('thegem-checkout');
  34. wp_enqueue_script('thegem-woocommerce'); ?>
  35.  
  36. <?php do_action( 'thegem_woocommerce_before_checkout', $checkout ); ?>
  37.  
  38. <?php if ($thegem_checkout_type == 'multi-step'): ?>
  39. <div class="checkout-steps <?php if(is_user_logged_in()): ?>user-logged<?php endif; ?> clearfix">
  40. <?php if(is_user_logged_in() || 'no' === get_option( 'woocommerce_enable_checkout_login_reminder' )): ?>
  41. <div class="checkout-step active" data-tab-id="checkout-billing"><?php esc_html_e('1. Billing','thegem'); ?></div>
  42. <div class="checkout-step" data-tab-id="checkout-payment"><?php esc_html_e('2. Payment','thegem'); ?></div>
  43. <div class="checkout-step disabled" data-tab-id="checkout-confirmation"><?php esc_html_e('3. Confirmation','thegem'); ?></div>
  44. <?php else: ?>
  45. <div class="checkout-step active" data-tab-id="checkout-signin"><?php esc_html_e('1. Sign in','thegem'); ?></div>
  46. <div class="checkout-step" data-tab-id="checkout-billing"><?php esc_html_e('2. Billing','thegem'); ?></div>
  47. <div class="checkout-step" data-tab-id="checkout-payment"><?php esc_html_e('3. Payment','thegem'); ?></div>
  48. <div class="checkout-step disabled" data-tab-id="checkout-confirmation"><?php esc_html_e('4. Confirmation','thegem'); ?></div>
  49. <?php endif; ?>
  50. </div>
  51. <?php endif; ?>
  52.  
  53. <?php if ($thegem_checkout_type == 'one-page'): ?>
  54. <div class="checkout-steps clearfix woocommerce-steps-<?php echo $thegem_checkout_type; ?>">
  55. <div class="checkout-step disabled before-active"><?php esc_html_e('Shopping cart','thegem'); ?></div>
  56. <div class="checkout-step disabled active"><?php esc_html_e('Checkout details','thegem'); ?></div>
  57. <div class="checkout-step disabled"><?php esc_html_e('Order complete','thegem'); ?></div>
  58. </div>
  59. <?php endif; ?>
  60.  
  61. <?php
  62. if ($thegem_checkout_type == 'multi-step') {
  63. woocommerce_checkout_coupon_form();
  64. }
  65. if ($thegem_checkout_type == 'one-page'): ?>
  66. <div class="checkout-before-checkout-form">
  67. <?php
  68. do_action( 'woocommerce_before_checkout_form', $checkout );
  69. woocommerce_checkout_coupon_form();
  70. ?>
  71. </div>
  72. <?php endif; ?>
  73.  
  74. <?php if($thegem_checkout_type == 'multi-step' && !is_user_logged_in()): ?>
  75. <div class="checkout-contents clearfix" data-tab-content-id="checkout-signin">
  76. <div class="row" id="customer_details">
  77. <div class="col-sm-6 col-xs-12 checkout-login">
  78. <?php
  79. do_action( 'woocommerce_before_checkout_form', $checkout );
  80. ?>
  81. </div>
  82. <?php if ($checkout->enable_guest_checkout || $checkout->enable_signup): ?>
  83. <div class="col-sm-6 col-xs-12 checkout-signin">
  84. <h2><span class="light"><?php esc_html_e('New customer','thegem'); ?></span></h2>
  85. <?php
  86. if ($checkout->enable_guest_checkout) {
  87. thegem_button(array(
  88. 'tag' => 'button',
  89. 'text' => esc_html__( 'checkout as guest', 'thegem' ),
  90. 'style' => 'flat',
  91. 'extra_class' => 'checkout-as-guest',
  92. 'attributes' => array(
  93. 'type' => 'button',
  94. )
  95. ), true);
  96. }
  97. ?>
  98. <?php
  99. if ($checkout->enable_signup) {
  100. thegem_button(array(
  101. 'tag' => 'button',
  102. 'text' => esc_html__( 'create an account', 'thegem' ),
  103. 'style' => 'flat',
  104. 'extra_class' => 'checkout-create-account',
  105. 'attributes' => array(
  106. 'type' => 'button',
  107. )
  108. ), true);
  109. }
  110. ?>
  111. </div>
  112. <?php endif; ?>
  113. </div>
  114. </div>
  115. <?php endif; ?>
  116.  
  117. <form name="checkout" method="post" novalidate class="checkout woocommerce-checkout woocommerce-checkout-<?php echo $thegem_checkout_type; ?> clearfix" action="<?php echo esc_url( wc_get_checkout_url() ); ?>" enctype="multipart/form-data">
  118.  
  119. <?php if ( $checkout->get_checkout_fields() ) : ?>
  120. <div class="checkout-contents clearfix" data-tab-content-id="checkout-billing">
  121. <?php do_action( 'woocommerce_checkout_before_customer_details' ); ?>
  122.  
  123. <div class="row" id="customer_details">
  124. <div class="col-sm-6 col-xs-12">
  125. <?php do_action( 'woocommerce_checkout_billing' ); ?>
  126. </div>
  127. <div class="col-sm-6 col-xs-12">
  128. <?php do_action( 'woocommerce_checkout_shipping' ); ?>
  129. </div>
  130. </div>
  131.  
  132. <?php do_action( 'woocommerce_checkout_after_customer_details' ); ?>
  133.  
  134. <div class="checkout-navigation-buttons clearfix">
  135. <?php
  136. thegem_button(array(
  137. 'tag' => 'button',
  138. 'text' => esc_html__( 'Previous step', 'thegem' ),
  139. 'style' => 'outline',
  140. 'size' => 'medium',
  141. 'extra_class' => 'checkout-prev-step',
  142. 'attributes' => array(
  143. 'value' => esc_attr__( 'Previous step', 'thegem' ),
  144. 'type' => 'button',
  145. )
  146. ), true);
  147. ?>
  148. <?php
  149. thegem_button(array(
  150. 'tag' => 'button',
  151. 'text' => esc_html__( 'Next step', 'thegem' ),
  152. 'style' => 'outline',
  153. 'size' => 'medium',
  154. 'extra_class' => 'checkout-next-step',
  155. 'attributes' => array(
  156. 'value' => esc_attr__( 'Next step', 'thegem' ),
  157. 'type' => 'button',
  158. )
  159. ), true);
  160. ?>
  161. </div>
  162. </div>
  163. <?php endif; ?>
  164.  
  165. <div class="checkout-contents clearfix" data-tab-content-id="checkout-payment">
  166. <?php do_action( 'woocommerce_checkout_before_order_review' ); ?>
  167.  
  168. <h2 id="order_review_heading"><span class="light"><?php esc_html_e( 'Your order', 'woocommerce' ); ?></span></h2>
  169.  
  170. <div class="gem-table checkout-payment">
  171. <?php
  172. if ($thegem_checkout_type == 'one-page') {
  173. $pattern_id = 'pattern-'.time().'-'.rand(0, 100);
  174. echo '<div class="checkout-order-review-pattern"><svg width="100%" height="27" style="fill: #f0f3f2;"><defs><pattern id="'.$pattern_id.'" x="10" y="0" width="20" height="28" patternUnits="userSpaceOnUse" ><path d="M20,8V0H0v8c3.314,0,6,2.687,6,6c0,3.313-2.686,6-6,6v8h20v-8c-3.313,0-6-2.687-6-6C14,10.687,16.687,8,20,8z" /></pattern></defs><rect x="0" y="0" width="100%" height="28" style="fill: url(#'.$pattern_id.');" /></svg></div>';
  175. }
  176. ?>
  177. <div id="order_review" class="woocommerce-checkout-review-order">
  178. <?php do_action( 'woocommerce_checkout_order_review' ); ?>
  179. </div>
  180. </div>
  181.  
  182. <?php do_action( 'woocommerce_checkout_after_order_review' ); ?>
  183. </div>
  184.  
  185. </form>
  186.  
  187. <?php do_action( 'woocommerce_after_checkout_form', $checkout ); ?>
  188.  
  189. <?php if ($thegem_checkout_type == 'multi-step'): ?>
  190. <script>
  191. (function($) {
  192. function active_checkout_tab($tab, isinit) {
  193. if ($tab.length == 0 || ($tab.hasClass('active') && !isinit)) {
  194. return false;
  195. }
  196.  
  197. $tab.parent().find('.checkout-step').removeClass('active before-active');
  198. $tab.addClass('active');
  199. $tab.prev('.checkout-step').addClass('before-active');
  200. var tab_id = $tab.data('tab-id');
  201. $('.checkout-contents').removeClass('active');
  202. $('.checkout-contents[data-tab-content-id="' + tab_id + '"]').addClass('active');
  203. window.location.hash = '#' + tab_id;
  204. }
  205.  
  206. var m = window.location.hash.match(/#checkout\-(.+)/);
  207. if (m && $('.checkout-steps .checkout-step[data-tab-id="checkout-' + m[1] + '"]').length == 1) {
  208. active_checkout_tab($('.checkout-steps .checkout-step[data-tab-id="checkout-' + m[1] + '"]'), true);
  209. } else {
  210. active_checkout_tab($('.checkout-steps .checkout-step:first'), true);
  211. }
  212.  
  213. $('.checkout-steps .checkout-step').not('.disabled').click(function() {
  214. active_checkout_tab($(this), false);
  215. });
  216. })(jQuery);
  217. </script>
  218. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment