将列添加到Wordpress Post(特别是WP电子商务)

Right, I've got WordPress E-commerce installed on WordPress and I need to add additional columns to the post type.

I've done some investigating. It appears that E-commerce just submits a post type called "Products" and changes the columns in order to add things like Price etc.

I need to add another input. Just a little checkbox that the admin can set to true or false as they add a product. The only problem for me at the moment is finding where exactly to do this.

I think I've found the WordPress E-Commerce post type column settings, but obviously just adding an additional one isn't working.

/wp-content/plugins/wp-e-commerce/wpsc-admin/display-items.page.php

function wpsc_additional_column_names( $columns ){
    $columns = array();

    $columns['cb']            = '';
    $columns['image']         = '';
    $columns['title']         = __('Name', 'wpsc');
    $columns['stock']         = __('Stock', 'wpsc');
    $columns['price']         = __('Price', 'wpsc');
    $columns['sale_price']    = __('Sale', 'wpsc');
    $columns['SKU']           = __('SKU', 'wpsc');
    $columns['weight']        = __('Weight', 'wpsc');
    $columns['cats']          = __('Categories', 'wpsc');
    $columns['featured']      = '';
    $columns['hidden_alerts'] = '';
    $columns['date']          = __('Date', 'wpsc');

    return $columns;
}

Don't edit the core files. You can add custom metaboxes to WP e-Commerce's Products post type just as you would any other post type.

My preferred solution is to use Custom Metaboxes and Fields for WordPress

This sample function will output a checkbox on products using the above plugin (note 'pages' => array('wpsc-product'), this targets products only):

function base_meta_boxes_ba($meta_boxes) {
  /**
   * Page Options meta box
   */
  $meta_boxes[] = array(
  'id'         => 'product_options',
  'title'      => 'Extra Product Options',
  'pages'      => array('wpsc-product'),
  'context'    => 'normal',
  'priority'   => 'high',
  'show_names' => true,        
  'fields'     => array(     
        array(
           'name' => 'Test Checkbox',
           'desc' => 'field description (optional)',
           'id' => $prefix . 'test_checkbox',
           'type' => 'checkbox'
        ),
   )
  );

 return $meta_boxes;
}

add_filter('cmb_meta_boxes', 'base_meta_boxes_ba');