form-billing.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * Checkout billing information form
  4. *
  5. * This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-billing.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 3.0.9
  17. */
  18. if ( ! defined( 'ABSPATH' ) ) {
  19. exit; // Exit if accessed directly
  20. }
  21. /** @global WC_Checkout $checkout */
  22. ?>
  23. <div class="woocommerce-billing-fields">
  24. <?php if ( wc_ship_to_billing_address_only() && WC()->cart->needs_shipping() ) : ?>
  25. <h3><?php _e( 'Billing &amp; Shipping', 'woocommerce' ); ?></h3>
  26. <?php else : ?>
  27. <h3><?php _e( 'Billing details', 'woocommerce' ); ?></h3>
  28. <?php endif; ?>
  29. <?php do_action( 'woocommerce_before_checkout_billing_form', $checkout ); ?>
  30. <div class="woocommerce-billing-fields__field-wrapper">
  31. <?php
  32. $fields = $checkout->get_checkout_fields( 'billing' );
  33. foreach ( $fields as $key => $field ) {
  34. if ( isset( $field['country_field'], $fields[ $field['country_field'] ] ) ) {
  35. $field['country'] = $checkout->get_value( $field['country_field'] );
  36. }
  37. woocommerce_form_field( $key, $field, $checkout->get_value( $key ) );
  38. }
  39. ?>
  40. </div>
  41. <?php do_action( 'woocommerce_after_checkout_billing_form', $checkout ); ?>
  42. </div>
  43. <?php if ( ! is_user_logged_in() && $checkout->is_registration_enabled() ) : ?>
  44. <div class="woocommerce-account-fields">
  45. <?php if ( ! $checkout->is_registration_required() ) : ?>
  46. <p class="form-row form-row-wide create-account">
  47. <label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
  48. <input class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" id="createaccount" <?php checked( ( true === $checkout->get_value( 'createaccount' ) || ( true === apply_filters( 'woocommerce_create_account_default_checked', false ) ) ), true ) ?> type="checkbox" name="createaccount" value="1" /> <span><?php _e( 'Create an account?', 'woocommerce' ); ?></span>
  49. </label>
  50. </p>
  51. <?php endif; ?>
  52. <?php do_action( 'woocommerce_before_checkout_registration_form', $checkout ); ?>
  53. <?php if ( $checkout->get_checkout_fields( 'account' ) ) : ?>
  54. <div class="create-account">
  55. <?php foreach ( $checkout->get_checkout_fields( 'account' ) as $key => $field ) : ?>
  56. <?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
  57. <?php endforeach; ?>
  58. <div class="clear"></div>
  59. </div>
  60. <?php endif; ?>
  61. <?php do_action( 'woocommerce_after_checkout_registration_form', $checkout ); ?>
  62. </div>
  63. <?php endif; ?>