0
私はwoocommerceプロダクトノートを保存するためにtextareaフィールドを作成しました。カート内で入手可能なプロダクトノートがある場合、これらのノートを管理者の注文に保存します。Woocommerceプロダクトノートオーダーメイドに追加
// WooCommerce Products Custom Field
add_action('woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields');
function woo_add_custom_general_fields() {
global $woocommerce, $post;
echo '<div class="options_group">';
// Textarea Field
\t woocommerce_wp_textarea_input(
\t \t array(
\t \t \t 'id' => 'product_notes',
\t \t \t 'label' => __('Product Notes', 'woocommerce'),
\t \t \t 'placeholder' => 'Enter product notes here.',
\t \t \t 'desc_tip' => 'true',
\t \t \t 'description' => __('Enter product notes here.', 'woocommerce')
\t \t)
\t);
echo '</div>'; \t
}
// Save Product notes
add_action('woocommerce_process_product_meta', 'woo_add_custom_general_fields_save');
function woo_add_custom_general_fields_save($post_id){
\t // Textarea
\t $woocommerce_textarea = $_POST['product_notes'];
\t if(!empty($woocommerce_textarea))
\t \t update_post_meta($post_id, 'product_notes', esc_html($woocommerce_textarea));
}