WooCommerce Function of the Week: wc_get_customer_total_spent

Categorized under:

, ,
Photo of author
Written By Rodolfo Melogli

6 thoughts on “WooCommerce Function of the Week: wc_get_customer_total_spent”

    • Hey Peter, if I understand well you misunderstood the “public function get_total_spent( &$customer )……” function meaning. That’s the function present at WooCommerce core and should not be used for development purposes.

      On the other hand, look at the wc_get_customer_total_spent( $user_id ) function, and use that within a plugin or a snippet, and magic will happen

    • It can’t work with guest checkout because guests aren’t logged in. As a result, you (or rather WooCommerce) can’t identify the guest with an existing user account and its previous purchase history.

      Guest checkout is often used by people who do not have an account and do not wish to have one on your site for privacy or some other reason. If they become repeat customers, it’s more likely they will establish a user account. But until then, all you can do is look at how many guest purchases you’ve had and maybe guess (by IP logging) how many people are buying from you that way, and what the total revenue is from “guests.”

      If you have a lot of guest checkouts taking place, maybe you should look at the reasons for that — is it difficult or unclear how to create an account? Maybe adding some instructions and incentives would help — explain the benefit to the customer, offer them a reward (like ad discount code/coupon) for creating an account.

Comments are closed.

A2 Hosting
Omnisend
WordPress.com