WooCommerce:访客结账无效

时间:2017-01-21 19:40:29

标签: woocommerce

我一直在努力弄清楚如何使我的访客结帐启用的网站工作但到目前为止没有成功。我激活了以下WooCommerce设置:

  • 启用访客结帐
  • 在" Checkout"上启用注册页

通常情况下,用户应该可以在不创建帐户的情况下结帐,但是,如果他们愿意,可以选择创建帐户。但是,如果我将测试订单作为访客并检查"创建帐户?"框+填写用户名和密码字段,没有提供的计费和运输信息显示在“感谢您”页面或WP仪表板中。好像"创建帐户?"框+用户名和密码将被忽略。

我怀疑这与我改变了帐户注册字段的默认位置有关。我已将它们添加到form-login.php文件中,因此它显示在与登录表单相同的部分中。它们最初包含在form-b​​illing.php字段中。请在下面找到这些文件:

形状billing.php

<?php
/**
 * Checkout billing information form
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-billing.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see     https://docs.woocommerce.com/document/template-structure/
 * @author  WooThemes
 * @package WooCommerce/Templates
 * @version 2.1.2
 */

if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly
}

/** @global WC_Checkout $checkout */

?>
<div id="woocommerce-billing-fields" class="woocommerce-billing-fields">
<h3 class="billing-fields-title">Billing Address</h3>
    <?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);
?>




</div>

形状的login.php:

<?php wc_print_notices(); ?>
<?php echo '<div class="panel-group" id="checkout-accordion">'; ?>
<?php
/**
 * Checkout login form
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/checkout/form-login.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see         https://docs.woocommerce.com/document/template-structure/
 * @author         WooThemes
 * @package     WooCommerce/Templates
 * @version     2.0.0
 */

if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly
}

if (is_user_logged_in() || 'no' === get_option('woocommerce_enable_checkout_login_reminder')) {
    return;
}

echo '<div class="panel panel-default checkout-panel" id="panel-login">
    <div class="panel-heading checkout-heading" id="panel-login-heading" data-toggle="collapse" data-parent="#checkout-accordion" href="#collapse-login">
      <h4 class="panel-title checkout-acc-title"> <a class="accordion-checkout">Login/Register <i id="checkout-accordion-login" class="checkout-accordion-icon">&#xe04b;</i></a> </h4>
    </div>
    <div id="collapse-login" class="panel-collapse details collapse in">
      <div class="panel-body checkout-inside"><div class="checkout-left-login"><h3 class="login-option">Login</h3>';
$info_message = apply_filters('woocommerce_checkout_login_message', '<div class="already-registered">' . __('Already registered?', 'woocommerce') . '</div>');
wc_print_notice($info_message, 'notice');

?>



<?php

woocommerce_login_form(
    array(
        'redirect' => wc_get_page_permalink( 'checkout' ),
        'hidden'   => true,
    )
);
echo '</div>';

?>


<?php
if (!is_user_logged_in() && $checkout->enable_signup):
?>

        <?php
    if ($checkout->enable_guest_checkout):
?>

            <p class="form-row form-row-wide create-account">
                <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="checkout-right-register">
<h3 class="login-option">Create an Account</h3>
            <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;
?>




<button id="toggle-login" type="button" class="register-btn-checkout" data-toggle="collapse" onclick="setCookie('panel-billing')" data-parent="#checkout-accordion" href="#collapse-billing">Continue</button>


</div><div class="or-select-guest">OR</div><button id="toggle-login2" type="button" class="guest-btn-checkout" data-toggle="collapse" data-parent="#checkout-accordion" href="#collapse-billing" onclick="setCookie('panel-billing')">Checkout as Guest</button> 

<?php echo'</div></div></div>';

?>

作为旁注:整个结帐表格将是一支手风琴,包括送货+结算,送货方式和付款等部分。

我错过了什么吗?我怀疑这个问题可能与Woocommerce的行为有关,但我无法确定。

1 个答案:

答案 0 :(得分:2)

您是否有机会使用Woocommerce订阅?我问,因为我有一个类似的问题,并最终意识到客人结账实际上适用于除订阅产品之外的任何产品。我碰巧在我的购物车中使用订阅产品测试结帐页面...由于购买订阅产品会分配用户角色,因此在购物车中有一个会在结帐时需要一个帐户。

这可能对您的具体情况没有帮助,但也许它会帮助其他人寻找答案。