在form-b​​illing.php中保存信息

时间:2016-08-25 20:17:22

标签: php wordpress woocommerce

我修改了form-b​​illing.php文件,问题是这个文件没有保存信息的按钮。 这是代码

<div class="woocommerce-billing-fields">
  <?php if ( wc_ship_to_billing_address_only() && WC()->cart->needs_shipping() ) : ?>
    <h1><?php _e( 'Billing &amp; Shipping', 'woocommerce' ); ?></h1>
  <?php else : ?>
    <h1><?php _e( 'New Customer', 'woocommerce' ); ?></h1>
  <?php endif; ?>

  <?php do_action( 'woocommerce_before_checkout_billing_form', $checkout ); ?>
  <?php foreach ( $checkout->checkout_fields['billing'] as $key => $field ): 
    if($key == 'billing_first_name' )
      woocommerce_form_field( 'billing_first_name', $field, $checkout->get_value( $key )); 

    if($key == 'billing_last_name' )
      woocommerce_form_field( 'billing_last_name', $field, $checkout->get_value( $key ));

    if($key == 'billing_company' ) 
     woocommerce_form_field( 'billing_company', $field, $checkout->get_value( $key ));

    if($key == 'billing_email' ) 
     woocommerce_form_field( 'billing_email', $field, $checkout->get_value( $key )); 
   endforeach; ?>

  <?php if ( ! is_user_logged_in() && $checkout->enable_signup ) : ?>
    <?php if ( $checkout->enable_guest_checkout ) : ?>
      <p class="form-row form-row-wide create-account create-account-paradise">
        <input class="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" /> <label for="createaccount" class="checkbox"><?php _e( 'Create an account?', 'woocommerce' ); ?></label>
      </p>
    <?php endif; ?>
    <?php do_action( 'woocommerce_before_checkout_registration_form', $checkout ); ?>

    <?php if ( ! empty( $checkout->checkout_fields['account'] ) ) : ?>
      <div class="create-account">
        <?php foreach ( $checkout->checkout_fields['account'] as $key => $field ) : ?>
        <?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
        <?php endforeach; ?>
        <div class="clear"></div>
      </div>
    <?php endif; ?>
    <?php do_action( 'woocommerce_after_checkout_registration_form', $checkout ); ?>
  <?php endif; ?>

  <h1><?php _e( 'Billing Address', 'woocommerce' ); ?></h1>

  <?php foreach ( $checkout->checkout_fields['billing'] as $key => $field ):
    if($key == 'billing_address_1' ) 
      woocommerce_form_field( 'billing_address_1', $field, $checkout->get_value( $key ));
    if($key == 'billing_address_2' )  
      woocommerce_form_field( 'billing_address_2', $field, $checkout->get_value( $key ));
    if($key == 'billing_phone' )  
      woocommerce_form_field( 'billing_phone', $field, $checkout->get_value( $key ));
    if($key == 'billing_city' )  
      woocommerce_form_field( 'billing_city', $field, $checkout->get_value( $key ));
    if($key == 'billing_country' )  
      woocommerce_form_field( 'billing_country', $field, $checkout->get_value( $key ));
    if($key == 'billing_state' ) 
      woocommerce_form_field( 'billing_state', $field, $checkout->get_value( $key ));
    // if($key == 'billing_postcode' ) 
    //  woocommerce_form_field( 'billing_postcode', $field, $checkout->get_value( $key ));
  endforeach; ?>

  <?php do_action('woocommerce_after_checkout_billing_form', $checkout ); ?>

</div>

在这种情况下,我有新客户的信息和帐单地址的信息,但我在保存数据时遇到问题。

我尝试将其放入带有按钮的表单中以便像这样保存

<form method="post">

   lines of form-billing.php

    <div class="col-xs-12">
      <input type="submit" class="button" name="save_address" value="<?php esc_attr_e( 'Save Address', 'woocommerce' ); ?>" />
      <?php wp_nonce_field( 'woocommerce-edit_address' ); ?>
      <input type="hidden" name="action" value="edit_address" />
    </div>
 </div>
</form>

但什么都没发生?任何保存此信息的想法。

谢谢你的进步!

0 个答案:

没有答案