{"id":4256,"date":"2018-08-25T16:58:01","date_gmt":"2018-08-25T20:58:01","guid":{"rendered":"https:\/\/themespress.ca\/?p=4256"},"modified":"2021-11-18T06:57:37","modified_gmt":"2021-11-18T11:57:37","slug":"woocommerce-displaying-stats-under-the-client-column","status":"publish","type":"post","link":"https:\/\/themespress.ca\/en\/woocommerce-displaying-stats-under-the-client-column\/","title":{"rendered":"WooCommerce: Displaying Stats Under The Client Column"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><div class=\"vc_row wpb_row vc_row-fluid\"><div class=\"wpb_column vc_column_container vc_col-sm-12\"><div class=\"vc_column-inner\"><div class=\"wpb_wrapper\">\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>With this tutorial, we will show you how to display your WooCommerce customer stats; for example the number of orders or the amount of money a customer spent on your online store. <\/p>\n<p><a href=\"https:\/\/woocommerce.com\/\" target=\"_blank\" rel=\"noopener\">Woocommerce<\/a> is the number 1 e-commerce WordPress plugin for online stores.<\/p>\n<p>WooCommerce Hooks for:<br \/>\nDisplaying the total number of orders: <a href=\"http:\/\/hookr.io\/functions\/wc_get_customer_order_count\/\" target=\"_blank\" rel=\"noopener\"><strong>wc_get_customer_order_count<\/strong><\/a><br \/>\nThe amount of money spent on your store: <a href=\"http:\/\/hookr.io\/functions\/wc_get_customer_total_spent\/\" target=\"_blank\" rel=\"noopener\"><strong>wc_get_customer_total_spent<\/strong><\/a><\/p>\n<p>Now that we know which hooks to use, we will create two columns in the user tables with the <strong>manage_users_columns<\/strong> and the <strong>manage_users_custom_column<\/strong> filters where the former will display both columns and the latter will allow us to generate the results.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<h2 style=\"text-align: left\" class=\"vc_custom_heading vc_do_custom_heading\" >Woocommerce : Afficher des informations dans la colonne utilisateur<\/h2><div id=\"ts-enlighterjs-container-9642928\" class=\"ts-enlighterjs-container-single-enabled  \" style=\"width: 100%;  margin-top: 0px; margin-bottom: 0px;\" data-enlighter-doubleclick=\"true\" data-enlighter-windowbutton=\"true\" data-enlighter-windowtext=\"New Window\" data-enlighter-rawbutton=\"true\" data-enlighter-rawtext=\"RAW Code\" data-enlighter-infobutton=\"false\" data-enlighter-infotext=\"EnlighterJS\" data-enlighter-indent=\"2\"><pre id=\"ts-enlighterjs-pre-9642928\" class=\"\" style=\"white-space: pre-wrap; height: 100%; margin: 0; padding: 0;\" data-enlighter-language=\"php\" data-enlighter-theme=\"enlighter\" data-enlighter-group=\"\" data-enlighter-title=\"\" data-enlighter-linenumbers=\"true\" data-enlighter-lineoffset=\"1\" data-enlighter-highlight=\"\">\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ Woocommerce users results columns \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ \nfunction add_user_details_columns($columns) {\n$columns[&#039;user_orders&#039;] = &#039;Orders&#039;;\n$columns[&#039;user_total_spent&#039;] = &#039;Total Spent&#039;;\nreturn $columns;\n}\n \nfunction show_user_details_column_content($value, $column_name, $user_id) {\nif (&#039;user_orders&#039; == $column_name)\nreturn wc_get_customer_order_count($user_id);\nelse if (&#039;user_total_spent&#039; == $column_name)\nreturn wc_price(wc_get_customer_total_spent($user_id));\nreturn $value;\n}\n \nfunction add_order_details_to_user_list() {\nadd_filter(&#039;manage_users_columns&#039;, &#039;add_user_details_columns&#039;);\nadd_action(&#039;manage_users_custom_column&#039;, &#039;show_user_details_column_content&#039;, 10, 3);\n}\n \nadd_action(&#039;admin_init&#039;, &#039;add_order_details_to_user_list&#039;);\n \n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/<\/pre><\/div>\n\t<div class=\"wpb_text_column wpb_content_element\" >\n\t\t<div class=\"wpb_wrapper\">\n\t\t\t<p>Alternatively, you can also use various plugins to display your WooCommerce stats such as <a href=\"https:\/\/wordpress.org\/plugins\/woo-classement\/\" target=\"_blank\" rel=\"noopener\"><strong>Woocommerce Classement<\/strong><\/a> or <a href=\"https:\/\/wordpress.org\/plugins\/sales-report-for-woocommerce\/\" target=\"_blank\" rel=\"noopener\"><strong>Sales Report for WooCommerce<\/strong><\/a>.<\/p>\n\n\t\t<\/div>\n\t<\/div>\n<\/div><\/div><\/div><\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"With this tutorial, we will show you how to display your WooCommerce customer stats; for example the number of orders or the amount of money a customer spent on your<div class=\"read-more\"><a class=\"btn button-secondary\" href=\"https:\/\/themespress.ca\/en\/woocommerce-displaying-stats-under-the-client-column\/\">Read More<\/a><\/div>","protected":false},"author":81,"featured_media":4957,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[283],"tags":[326,328],"class_list":["post-4256","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-users","tag-woocommerce-config"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/4256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/users\/81"}],"replies":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/comments?post=4256"}],"version-history":[{"count":0,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/posts\/4256\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media\/4957"}],"wp:attachment":[{"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/media?parent=4256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/categories?post=4256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themespress.ca\/en\/wp-json\/wp\/v2\/tags?post=4256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}