Make this Fast and Queryable

I have 100,000+ registered users on my WooCommerce site.

I have a subscription billing that people earn 5 entries each billing with. All users have the ability to earn entries for every $5.00 spent.

The entries are stored by contest... (A custom post type)

A Single usermeta field containing an array records entry data in the following format.

array('CONTEST_ID' = 'ENTRY_COUNT'); 

or for example

array(1302 = 5, 12053 = 25);

I want to change this to be queryable in some format and store the reason for gaining entries. An example would be

array('CONTEST_ID' = array('reason' = 'initial_signup', 'type' = '+', 'ammount' = 5)
'CONTEST_ID' = array('reason' = 'refunded_order', 'type = '-', 'ammount' = '12'
);

I need to make the entire sequence quickly computable to get a given contests total amount.

Topic woocommerce-offtopic user-meta scale Wordpress

Category Web


Consider custom post type of 'Contest transactions' parent posts could be the contest, then you can use the post meta

meta_key => initial signup, meta-value => +5

meta_key => refunded_order, meta-value => -12

and then you could a query adding up all the transactions.

I prefer to use wp tables and structures where possible as then many features, functions and other plugins are available to use to work with and report on your data. If you go with custom tables, you have to write everything yourself.

About

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