Wednesday, 15 June 2011

php - Wordpress WooCommerce text attribute -



php - Wordpress WooCommerce text attribute -

i using woocommerce plugin in wordpress. in plugin need add together text input each product in clients can fill in additional product details.

the problem facing whenever add together text attribute, changes select box. please suggest solution. thanks!

do mean clients should have text input field available on frontend?

if it's backend, can add together functions.php:

if (is_admin()){ // add together meta box function add_textfield() { add_meta_box( 'textfield', // $id 'custom textfield', // $title 'show_textfield_backend', // $callback 'product', // $page 'normal', // $context 'high' // $priority ); } add_action('add_meta_boxes', 'add_textfield'); // callback function show_textfield_backend() { global $post; global $wpdb; $meta = get_post_meta($post->id, 'textfield', true); // utilize nonce verification echo '<input type="hidden" name="textfield_nonce" value="'.wp_create_nonce(basename(__file__)).'" />'; _e('custom textfield: '); echo '<input type="text" placeholder="text" id="textfield" class="textfield" name="textfield" ', $meta ? " value='$meta'" : "",' />'; } // save info function save_textfield($post_id) { global $wpdb; // verify nonce if (!wp_verify_nonce($_post['textfield_nonce'], basename(__file__))) homecoming $post_id; // check autosave if (defined('doing_autosave') && doing_autosave) homecoming $post_id; // check permissions if ('page' == $_post['post_type']) { if (!current_user_can('edit_page', $post_id)) homecoming $post_id; } elseif (!current_user_can('edit_post', $post_id)) { homecoming $post_id; } if ( !wp_is_post_revision( $post_id ) ) { $textfield = $_post['textfield']; update_post_meta($post_id, 'textfield', $textfield); } } add_action('save_post', 'save_textfield'); }

php wordpress wordpress-plugin woocommerce

No comments:

Post a Comment