【问题标题】:WooCommerce - error on creating an account during checkoutWooCommerce - 在结帐期间创建帐户时出错
【发布时间】:2015-02-03 10:49:45
【问题描述】:

我正在使用 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>

【问题讨论】:

    标签: php wordpress checkbox woocommerce webshop


    【解决方案1】:

    woocoomerce 设置页面中的shipping 标签下有一个选项标记为Shipping Destination。尝试选择Default to billing address 选项。

    【讨论】:

      猜你喜欢
      • 2015-05-01
      • 1970-01-01
      • 2021-08-23
      • 1970-01-01
      • 2021-02-08
      • 1970-01-01
      • 1970-01-01
      • 2016-03-12
      • 1970-01-01
      相关资源
      最近更新 更多