1

我正在使用 WooCommerce 建立一个网上商店。我的地址设置是这样的: 1. 帐单地址 2. 复选框:创建帐户(未登录时) 3. 复选框:运送到不同的地址

因此,当客户选中“创建帐户”框时,他们必须填写密码。我想将帐单地址信息用于帐单地址和送货地址(默认)。但是,当客户现在选中“创建帐户”框并未选中“运送到不同地址”时,表单会出现错误,提示客户还需要填写送货地址字段。下面是我的一段结帐代码(账单地址字段和创建帐户复选框;请评论更多代码)。

我希望有人有解决方案。谢谢。

<div class="woocommerce-billing-fields">
    <?php if ( WC()->cart->ship_to_billing_address_only() && WC()->cart->needs_shipping() ) : ?>

        <h2><?php _e( 'Billing &amp; Shipping', 'woocommerce' ); ?></h2>
    <?php else : ?>
    <?php endif; ?>

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

    <?php foreach ( $checkout->checkout_fields['billing'] as $key => $field ) : ?>

        <?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>

    <?php endforeach; ?>

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

    <?php if ( ! is_user_logged_in() && $checkout->enable_signup ) : ?>
        <div class="create-account-wrapper">
            <?php if ( $checkout->enable_guest_checkout ) : ?>

                <p class="form-row form-row-wide create-account-title walsheim checkbox-wrapper">
                    <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 create-account-content">

                    <p><?php _e( 'Create an account by entering the information below. If you are a returning customer please login at the top of the page.', 'woocommerce' ); ?></p>

                    <?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 ); ?>
        </div>

    <?php endif; ?>
</div>
4

1 回答 1

0

在标签标签woocoomerce下的设置页面中有一个选项。尝试选择选项。shippingShipping DestinationDefault to billing address

于 2015-01-30T22:38:35.217 回答