wpf_woocommerce_user_id

Overview

When WP Fusion processes a WooCommerce checkout for a registered user, it uses the current user’s ID to determine the user’s contact record in your CRM.

That way if a user checks out with a different billing email, their original contact record is properly updated— instead of creating a new contact record and fragmenting your data.

Generally this is desirable, but there may be situations where you don’t want orders to be associated with the current user. For example if your WooCommerce checkouts are being made by agents who are purchasing on behalf of their customers. In that case you would want a new contact record to be created for the customer, rather than updating the contact record of the agent.

The wpf_woocommerce_user_id filter allows you to modify the user ID that WP Fusion uses to determine which user should be associated with the checkout. Returning false from the filter will tell WP Fusion to treat the checkout as a guest checkout.

Parameters

  • $user_id (int): The user ID to be used for the checkout
  • $order (object): The WooCommerce order object

Examples

Treat all checkouts as guest checkouts

add_filter( 'wpf_woocommerce_user_id', function( $user_id, $order ) {
	return false;
}, 10, 2 );

Was this helpful?