Existing Ecommerce plugins with Custom Post Types

I am developing a solution which is selling a service (can not be categorized as product) I have developed custom post types and taxonomies but I do not want to re-invent the wheel by adding payment gateways just for this purpose. Is there any way I can customize the "Product" post type in any existing ecommerce plugin available.

Thanks for your support

Topic woocommerce-offtopic plugin-wp-e-commerce Wordpress

Category Web


If you're post type is called 'product' then if you remove the code that registers your post type, and activate, say WooCommerce, the plugin should recognize the posts. You would need to configure some of the meta fields, however.

Following up on your comment, WooCommerce registers the product post type with the following pertinent code:

if ( post_type_exists('product') )
    return;

do_action( 'woocommerce_register_post_type' );

$permalinks        = get_option( 'woocommerce_permalinks' );
$product_permalink = empty( $permalinks['product_base'] ) ? _x( 'product', 'slug', 'woocommerce' ) : $permalinks['product_base'];

register_post_type( "product",
    apply_filters( 'woocommerce_register_post_type_product',
        array(
            'labels' => array(
                    'name'                  => __( 'Products', 'woocommerce' ),
                    'singular_name'         => __( 'Product', 'woocommerce' ),
                    'menu_name'             => _x( 'Products', 'Admin menu name', 'woocommerce' ),
                    'add_new'               => __( 'Add Product', 'woocommerce' ),
                    'add_new_item'          => __( 'Add New Product', 'woocommerce' ),
                    'edit'                  => __( 'Edit', 'woocommerce' ),
                    'edit_item'             => __( 'Edit Product', 'woocommerce' ),
                    'new_item'              => __( 'New Product', 'woocommerce' ),
                    'view'                  => __( 'View Product', 'woocommerce' ),
                    'view_item'             => __( 'View Product', 'woocommerce' ),
                    'search_items'          => __( 'Search Products', 'woocommerce' ),
                    'not_found'             => __( 'No Products found', 'woocommerce' ),
                    'not_found_in_trash'    => __( 'No Products found in trash', 'woocommerce' ),
                    'parent'                => __( 'Parent Product', 'woocommerce' )
                ),
            'description'           => __( 'This is where you can add new products to your store.', 'woocommerce' ),
            'public'                => true,
            'show_ui'               => true,
            'capability_type'       => 'product',
            'map_meta_cap'          => true,
            'publicly_queryable'    => true,
            'exclude_from_search'   => false,
            'hierarchical'          => false, // Hierarchical causes memory issues - WP loads all records!
            'rewrite'               => $product_permalink ? array( 'slug' => untrailingslashit( $product_permalink ), 'with_front' => false, 'feeds' => true ) : false,
            'query_var'             => true,
            'supports'              => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'custom-fields', 'page-attributes' ),
            'has_archive'           => ( $shop_page_id = wc_get_page_id( 'shop' ) ) && get_page( $shop_page_id ) ? get_page_uri( $shop_page_id ) : 'shop',
            'show_in_nav_menus'     => true
        )
    )
);

You will note that all the args for register_post_type are open to filtering via the woocommerce_register_post_type_product filter.

Therefore if you wanted to change all the backend labels to say Services you could do the following:

function wpa_137268( $args ){
    $args['labels'] = array(
        'name'                  => __( 'Services' ),
        'singular_name'         => __( 'Service' ),
        'menu_name'             => _x( 'Services', 'Admin menu name' ),
        'add_new'               => __( 'Add Service' ),
        'add_new_item'          => __( 'Add New Service' ),
        'edit'                  => __( 'Edit' ),
        'edit_item'             => __( 'Edit Service' ),
        'new_item'              => __( 'New Service' ),
        'view'                  => __( 'View Service' ),
        'view_item'             => __( 'View Service' ),
        'search_items'          => __( 'Search Services' ),
        'not_found'             => __( 'No Services found' ),
        'not_found_in_trash'    => __( 'No Services found in trash' ),
        'parent'                => __( 'Parent Service' )
    );
    return $args;
}
add_filter( 'woocommerce_register_post_type_product', 'wpa_137268' );

You can extrapolate from there to change anything else you are interested in changing.


You should download en use WooCommerce with buildin payment gateways

You can add a product type with something like:

function my_add_product_type( $types ) {
    return $types["service"] = "Service";
}
add_filter( "product_type_selector", "my_add_product_type" );

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.