• Resolved cjpicc11

    (@cjpicc11)


    Hello,

    I am building a new wordpress plugin that will help my customers manage their products and billing and I am not sure whether I should build custom tables or the wordpress custom post types to complete my solution.

    If I were to build custom tables, it would look like this.

    Tables:

    Customers (One to Many with link to wp_users table linking there user accounts on my site.
    Products (One to many with link to customers table)
    Invoices (Many to many with links to customers table and products table)

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    It depends on how you need to retrieve the data. If it is mainly by ID, CPT will work fine, with extra data in post meta. If you need to query for results by post meta frequently, you may be better off in a custom table.

    WooCommerce is a popular, successful e-commerce plugin. Looking at what they do would be instructive. Customers are simply WP users, extra data in user meta. Products are CPTs. Orders (or invoices) have their own custom table. The many to many relationship is what justifies the separate table. One to many is easily managed by existing tables.

    It also depends on what other functionality should be available with the data. If you use standard tables, all the plugins already written for those can apply. If you use new tables, none of that plugin functionality is available. This would be things like backups, feeds, import, export, theme templates, core functions for lists and such, etc.

    Think about the woocommerce, it uses the custom post type because WordPress will take care most of the security flows and query functions. What’s more, it finds easy to compatible your CPT using WordPress cores. That is unnecessary to create custom table unless you have the reason for that…

    Thread Starter cjpicc11

    (@cjpicc11)

    Thank you all for your help, your information has really helped me.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Need to determine if I should use CPT or Custom Post tables in WordPress’ is closed to new replies.