Restore woocommerce orders

It’s Simple. Step 1: Create a replica of the instance. Step 2: Import the old .sql file which contained one day lost orders data. Step 3: Use https://wordpress.org/plugins/woocommerce-simply-order-export/ plugin and export CSV or XML of 1 day data which you have lost. Step 4: Install the above plugin in the LIVE instance and import the … Read more

Get wp_current_user_id using PHP and MySQL

Thanks to @Samuel Elh I manage to get this done. I added this to my order-confirmation.php after I included config.php require (‘../wp-blog-header.php’); global $wpdb; global $current_user; get_currentuserinfo(); $skrivID = $current_user->ID; Then the insert query, I added the table I wanted the user ID stored in and used the variable $skrivID as value. $sql = mysqli_query($db_conn, … Read more

Regenerate user_nicename column

The obvious method would be to write a custom WP-CLI script to run through the table, extract the first and last names, use sanitize_title to create a new nicename and update the record. You’d also need to copy the first and last names in wp_usermeta as you mention, at the same time. I’m not sure … Read more

WordPress plugin boilerplate table create

it is better you write like this: class My_Activator { public function jal_install() { global $wpdb; global $jal_db_version; $table_name = $wpdb->prefix . ‘fnotice’; $charset_collate = $wpdb->get_charset_collate(); $sql = “CREATE TABLE $table_name ( id INT NOT NULL AUTO_INCREMENT, msg varchar(500) NOT NULL, time DATETIME NOT NULL, type varchar(350) NOT NULL, link varchar(350) NOT NULL, status ENUM(‘0’, … Read more

WP Query – filtering terms with regex

This is untested, but give it a go. First get a list of the term names in the taxonomy. Then filter the returned array of names against your regex. Then use that filtered array of names for your WP query. // assumes these assignments: // // $taxonomy – the taxonomy name you are querying against … Read more

Can I customised default WP table

I’ve checked and WordPress does, by default, retrieve & cache all post meta along with the main query’s posts, so you’re perfectly fine storing a product’s additional fields as standard post meta. You might want to store Brands (merchants? manufacturers?) as a custom taxonomy so that you can take advantage of built-in templates and queries … Read more