【问题标题】:How to edit my account section in WooCommerce checkout?如何在 WooCommerce 结帐中编辑我的帐户部分?
【发布时间】:2020-06-14 02:58:08
【问题描述】:

我在 functions.php 中自定义了我的 WooCommerce 结账功能,以禁用所有账单地址字段,因为我的 Stripe 网关不需要它。

我也希望允许客户在结帐时创建一个帐户,但它只要求输入用户名/密码,而 wordpress 帐户需要电子邮件。由于我在计费部分禁用了电子邮件,因此用户无法注册。

我不希望电子邮件地址保留在帐单详细信息中,因为它会一直显示。

我理想的解决方案是将它放在帐户部分。

我该怎么做

  1. 将电子邮件地址从帐单移至创建帐户部分
  2. 为帐户部分创建一个电子邮件地址字段?

感谢任何帮助。

【问题讨论】:

    标签: php wordpress woocommerce field checkout


    【解决方案1】:

    你可以使用woocommerce_checkout_fields钩子

    https://github.com/woocommerce/woocommerce/blob/4.1.0/includes/class-wc-checkout.php#L265

    • 获取结帐字段数组。

    将以下代码添加到functions.php

    // Add field
    function filter_woocommerce_checkout_fields( $fields ) {    
        $fields['account']['billing_email'] = array(
            'label'        => __('E-mailadres', 'woocommerce'),
            'required'     => true,
            'type'         => 'email',
            'class'        => array('form-row-wide'),
            'validate'     => array('email'),
            'autocomplete' => 'email'
        );
    
        return $fields;
    }
    add_filter( 'woocommerce_checkout_fields' , 'filter_woocommerce_checkout_fields', 10, 1 );
    

    【讨论】:

      猜你喜欢
      • 2019-01-28
      • 2020-08-07
      • 1970-01-01
      • 1970-01-01
      • 2018-12-08
      • 2019-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多