我有一个多步骤结账,因此我创建了一个名为"卡数据"的新自定义步骤,我希望客户填写输入。这些输入还应显示在"我的帐户"的选项卡上。我已经为我的帐户面板创建了一个新的自定义选项卡。请告诉我,我如何在结账过程中创建自定义字段,并使其在"自定义面板"选项卡中可见。客户应该可以通过面板自行更改数据条目。
非常感谢
// i use multistep checkout wizzard plugin. here i create a step, where user
enters the card data
add_action('woocommerce_multistep_checkout_before', 'add_visica_step');
function add_visica_step() {
$contents = '<h1>Visica Daten</h1>';
$contents .= '<div class="visica-step"> Please Enter something </div>';
echo $contents;
}
add_filter ( 'woocommerce_account_menu_items', 'one_more_link' );
function one_more_link( $menu_links ){
$new = array( 'carddata' => 'Card Data' );
$menu_links = array_slice( $menu_links, 0, 1, true )
+ $new
+ array_slice( $menu_links, 1, NULL, true );
return $menu_links;
}
/*
* Step 2. Register Permalink Endpoint
*/
add_action( 'init', 'add_endpoint' );
function add_endpoint() {
// WP_Rewrite is my Achilles' heel, so please do not ask me for detailed
explanation
add_rewrite_endpoint( 'visicadata', EP_PAGES );
}
/**步骤3。我的帐户中新页面的内容,woommerce_Account_{ENDPOINT名称}_终点*/
add_action('woommerce_account_visicadata_endpoint','my_account_endpoint_content'(;函数my_account_endpoint_content(({
echo 'Here I want do display custom fields from checkout';
}
add_filter( 'woocommerce_checkout_fields' ,
'woocommerce_checkout_field_editor'(;
// Our hooked in function - $fields is passed via the filter!
function woocommerce_checkout_field_editor( $fields ) {
$fields['shipping']['shipping_field_value'] = array(
'label' => __('Field Value', 'woocommerce'),
'placeholder' => _x('Field Value', 'placeholder', 'woocommerce'),
'required' => true
);
return $fields;
}
// Display Field on Order Page, but i would like to display it on custom tab
add_action( 'woocommerce_admin_order_data_after_shipping_address',
'edit_woocommerce_checkout_page', 10, 1 );
function edit_woocommerce_checkout_page($order){
global $post_id;
$order = new WC_Order( $post_id );
echo '<p><strong>'.__('Field Value').':</strong> ' . get_post_meta($order->get_id(), '_shipping_field_value', true ) . '</p>';