Create a WordPress Database query to find users who purchased specific product through WooCommerce [closed]

You’ll find details here: https://gist.github.com/lukecav/05afef12feaf980c121da9afb9291ad5 OR Another approach is https://github.com/woocommerce/woocommerce/wiki/wc_get_orders-and-WC_Order_Query . Use if….else and store order data in Arr[product_id] = OrderArr Kindly accept my answer if it is of any help.

$wpdb selects wrong database

$_SERVER[‘DOCUMENT_ROOT’]; is not going to include secondsite. So all the files, including wp-config.php with the database details, are coming from the root public directory. To get the current directory, including subdirectories, use any of these: getcwd(); dirname(__FILE__); basename(__DIR__); But if your file is in a deeper folder, you can’t find the secondsite directory without specifying … Read more

Insert into db with foreach problem

(See comments) $wpdb->insert( ‘produse’, array( ‘id’ => $post_id, ‘pret’ => $produs[‘pret’], ‘gramaj’ => $produs[‘gramaj’], ‘numar_produs’ => $produs[‘numar_produs’] ), array( ‘%d’, ‘%s’, ‘%s’, ‘%d’ ) );

Delete query won’t run

I see no reason why $_POST[‘delete’] should not be set assuming there are no page redirects involved. I can’t tell from your code if that is the case, but it superficially appears not to be. I do see other potential problems. You are setting your form action to an empty string. While that does sometimes … Read more

Site going down due to slow queries

Perhaps info on this page might help: http://codex.wordpress.org/Class_Reference/wpdb Other than that I would do the usual troubleshooting to start. Backup everything. Turn off all plugins. Switch to a standard WordPress theme like 2015. Then see what errors you are getting now that you have stripped down your install. Then slowly turn things back on until … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)