Add custom columns to Woocommerce customers table - wordpress

By clicking woocommerce->customers i can get a table of all of the customers.
Is there a way to add columns to it? I found that there is a manage_edit-{$post_type}_columns, but i can't find the customers post type.

woocommerce is not using wordpress tables structure.
this is easily visible by comparing woocommerce->customers table with users->All Users
manage_edit-{$post_type}_columns is defenetly not the filter you're looking for.
the columns are located in this path:
packages/woocommerce-admin/src/API/Reports/Customers/Controller.php.
and the filter to change them is: woocommerce_report_customers_export_columns

Related

Woocommerce Modify or Reset total_sales

I want to change or reset the total_sales to 0 at worst.
When I modify in phpMyAdmin (wc_product_meta_lookup) nothing happens and everything goes back to the way it was before after a new order.
I searched for 2 hours without finding anything.
thank you in advance.
total_sales is a post meta field, a row in postmeta table. wc_product_meta_lookup just contains consolidated data from postmeta to avoid making multiple postmeta selects when product data are needed.
postmeta is the source of truth in this case, you need to set your desired value in there. Either directly in the database or using a custom field in the product edit view.
Reports (including total sales value in the dashboard widget) are dynamically generated, so I believe the value your setting in the database will just be set back to it's true value when WordPress runs.
According to the docs, you need to delete all prior orders (permanently) and clear your browser cache for new reports.
More info: https://docs.woocommerce.com/document/reports/#section-12

Generate and display html table with user data from wordpress

Update: With the help of the answerer below I figured out how to do this. Basically I used a WP Query to get users and their user metadata and I sorted and placed the data in a for each loop in a table.
I'm new to PHP and I need some help. Basically I want to create a leaderboard with different user data. I want to display it in an html table.
This is kinda what i want:
Username GamiPress Points Time since last login
And I want the table to be populated with these data amongst others automatically. I want two versions one that is sorted with the 15 users who have the most points and one that sorts on the 15 users that logged in last.
Can someone point me to the right place on how I can best implement this?
I basically want to create the GamiPress Leaderboard add-on that I, unfortunately, can't afford, but with some extra fields.
There are multiple steps to do if you want to achieve this:
1) Add meta field to your users, so you can store the points. For example you can use "Advanced Custom Fields" plugin for this.
2) Write a function for adding points to this field. Define when this function will be fired.
3) Query the users ordered by that meta value and display it (get_users($args) might be useful).
4) For the Last-Login value you can use a plugin (google Wordpress Last Login) and write another Query and order results by that meta field. You can also write this by your own, here is a link I found: https://www.wpbeginner.com/plugins/how-to-show-users-last-login-date-in-wordpress/
I don't know if this is what you were looking for.
Or did you want to see an example code how you use a wp query and display data in html table?

Showing count of content based on the select list values Drupal 7

I have a requirement in which I need to show some content along with its count based on values in a select list. I wanted to display the allocated,released and resigned resources of a particular department in a selected date range. Using views, date range and department fields are created as exposed filters.
Created a content type for creating resources. The Resources content type is having action as a select list with values allocated,released,resigned. Department is another select list and date field is also added.
Please help me with an answer if views module is not enough. Provide some other solutions also. I'm using Drupal 7.
I figured out how to show node count in views. In my view I’ve some exposed filters and passed my select list cck field as contextual filter. If no result available I made the view to display summary as row count. In the template file, I’m planning to do some calculations for showing the resources count in and out of the project. Please correct me if there is anything wrong in this approach.

WooCommerce Custom Attribute being indexed but shows no results

We're running WordPress 4.7, WooCommerce 2.6.9 and the Algolia 1.6.0.
We've got 7 indexes setup:
Searchable posts [searchable_posts]
Posts [posts_post]
Pages [posts_page]
Products [posts_product]
Brands [terms_product_brand]
Product Categories [terms_product_cat]
Full Code [terms_pa_full-code]
The first 6 all return results as expected but Full Code [terms_pa_full-code], although indexed returns no results. However, there should be several 100 if not 1000 as if a product has a Full Code it is set to be 'Visible on the product page'.
Because it's showing as something that can be indexed I'm assuming we don't need to do any custom coding so not sure why it wouldn't display any results?
Has anyone experienced anything similar
The terms_pa_full-code does only contain some metadata, not the values which are them correctly pushed as part of the product data if everything goes well.
You can then use values of that taxonomy as a facet to display a list of available options given a user search query.
You can also register for the Algolia plugin for WooCommerce here: https://community.algolia.com/wordpress/#woocommerce and get this setup for you in a few clicks.

Wordpress search including multiple categories

I have a search form that has a text field and 3 drop downs, that have categories. What I'm trying to achieve is the current search query that posts appears as follows:
?s=Milk&cat=4&cat=7&cat=15.
What I'm trying to achieve is something like:
?s=Milk&cat=04,7,15
I'm relatively new to WordPress and PHP and haven't been able to find any good documentation or references to what I need to do to accomplish this.
I don't necessarily want the answer, just some guidance in the right direction.
This was already answer: multiple categories query
It must be like this:
/?cat=970,971,972 where the # is the cat id.

Resources