需要wordpress woocommerce插件的自定义输入字段

时间:2012-10-03 07:55:50

标签: wordpress wordpress-plugin wordpress-theming textinput

我正在使用WordPress woocommerce plugin制作eCommerce site。关于woocommerce plugin的一切都很好。但是,当我看到用户register所在的register all of his details部分时,custom fields没有gender, phone no, address etc。我需要register page中的所有这些内容。那怎么办呢?任何帮助建议都会非常明显。

3 个答案:

答案 0 :(得分:3)

此插件正是您正在寻找的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

使用此功能

干杯!

答案 1 :(得分:0)

您可以添加自己的字段,将以下代码添加到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' );

您可以将字段修改为textbox,radiobutton或任何您需要的字段。

希望有所帮助:)

马努。

答案 2 :(得分:-1)

您必须编辑插件文件才能拥有此功能。可能需要更改的文件是

  • 模板/形状checkout.php
  • 类/类-WC-checkout.php

不需要数据库更改,因为条目将保存在wp_usermeta表中。

如果您通过Wordpress的注册页面注册用户,请使用Cimy User Extra Fields等插件