我正在使用WordPress woocommerce插件制作电子商务网站。 woocommerce插件一切都很好。但是, 当我看到注册部分时, 用户将对其所有详细信息进行注册, 因此没有自定义字段, 例如性别, 电话号码, 地址等。在注册页面中, 我需要所有这些东西。那么该怎么做呢?对建议的任何帮助将非常可取。
#1
你可以在此插件中找到http://wordpress.org/extend/plugins/cimy-user-extra-fields/。你将能够在注册表单中添加其他字段, 并将其添加到用户的用户个人资料页面中。
以下是注册表格样本的屏幕截图, 网址为http://wordpress.org/extend/plugins/cimy-user-extra-fields/screenshots/
我个人在这里使用它http://mayumibeats.com/wp-signup.php?blog_id=1
干杯!
#2
你可以添加自己的字段, 将以下代码添加到你的wordpress主题functions.php文件中。
/**
* Add new register fields for WooCommerce registration.
*
* @return string Register fields HTML.
*/
function wooc_extra_register_fields() {
?>
<p class="form-row form-row-first">
<label for="reg_billing_first_name"><?php _e( 'First name', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="billing_first_name" id="reg_billing_first_name" value="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" />
</p>
<p class="form-row form-row-last">
<label for="reg_billing_last_name"><?php _e( 'Last name', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="billing_last_name" id="reg_billing_last_name" value="<?php if ( ! empty( $_POST['billing_last_name'] ) ) esc_attr_e( $_POST['billing_last_name'] ); ?>" />
</p>
<div class="clear"></div>
<p class="form-row form-row-wide">
<label for="reg_billing_phone"><?php _e( 'Phone', 'woocommerce' ); ?> <span class="required">*</span></label>
<input type="text" class="input-text" name="billing_phone" id="reg_billing_phone" value="<?php if ( ! empty( $_POST['billing_phone'] ) ) esc_attr_e( $_POST['billing_phone'] ); ?>" />
</p>
<?php
}
add_action( 'woocommerce_register_form_start', 'wooc_extra_register_fields' );
你可以将字段修改为文本框, 单选按钮或任何不需要的内容。
希望能帮助到你 :)
Manu
#3
你必须编辑插件文件才能具有此功能。可能需要更改的文件是
- templates / form-checkout.php
- classes / class-wc-checkout.php
不需要数据库更改, 因为条目将保存在wp_usermeta表中。
如果你要通过Wordpress的注册页面注册用户, 请使用类似Cimy User Extra Fields的插件
来源:
https://www.srcmini02.com/67414.html